(menu-bar-epatch-menu, menu-bar-ediff-merge-menu)
[emacs.git] / lisp / gnus.el
blob1b6be07ddc94d536aad3918f024d8f105de7f62f
1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;; Keywords: news
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 ;;; Commentary:
26 ;; Although Gnus looks suspiciously like GNUS, it isn't quite the same
27 ;; beast. Most internal structures have been changed. If you have
28 ;; written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
32 ;; fail.
34 ;;; Code:
36 (eval '(run-hooks 'gnus-load-hook))
38 (require 'mail-utils)
39 (require 'timezone)
40 (require 'nnheader)
42 ;; Site dependent variables. These variables should be defined in
43 ;; paths.el.
45 (defvar gnus-default-nntp-server nil
46 "Specify a default NNTP server.
47 This variable should be defined in paths.el, and should never be set
48 by the user.
49 If you want to change servers, you should use `gnus-select-method'.
50 See the documentation to that variable.")
52 (defconst gnus-backup-default-subscribed-newsgroups
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
54 "Default default new newsgroups the first time Gnus is run.
55 Should be set in paths.el, and shouldn't be touched by the user.")
57 (defvar gnus-local-domain nil
58 "Local domain name without a host name.
59 The DOMAINNAME environment variable is used instead if it is defined.
60 If the `system-name' function returns the full Internet name, there is
61 no need to set this variable.")
63 (defvar gnus-local-organization nil
64 "String with a description of what organization (if any) the user belongs to.
65 The ORGANIZATION environment variable is used instead if it is defined.
66 If this variable contains a function, this function will be called
67 with the current newsgroup name as the argument. The function should
68 return a string.
70 In any case, if the string (either in the variable, in the environment
71 variable, or returned by the function) is a file name, the contents of
72 this file will be used as the organization.")
74 (defvar gnus-use-generic-from nil
75 "If nil, the full host name will be the system name prepended to the domain name.
76 If this is a string, the full host name will be this string.
77 If this is non-nil, non-string, the domain name will be used as the
78 full host name.")
80 (defvar gnus-use-generic-path nil
81 "If nil, use the NNTP server name in the Path header.
82 If stringp, use this; if non-nil, use no host name (user name only).")
85 ;; Customization variables
87 ;; Don't touch this variable.
88 (defvar gnus-nntp-service "nntp"
89 "*NNTP service name (\"nntp\" or 119).
90 This is an obsolete variable, which is scarcely used. If you use an
91 nntp server for your newsgroup and want to change the port number
92 used to 899, you would say something along these lines:
94 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
96 (defvar gnus-select-method
97 (nconc
98 (list 'nntp (or (getenv "NNTPSERVER")
99 (if (and gnus-default-nntp-server
100 (not (string= gnus-default-nntp-server "")))
101 gnus-default-nntp-server)
102 (system-name)))
103 (if (or (null gnus-nntp-service)
104 (equal gnus-nntp-service "nntp"))
105 nil
106 (list gnus-nntp-service)))
107 "*Default method for selecting a newsgroup.
108 This variable should be a list, where the first element is how the
109 news is to be fetched, the second is the address.
111 For instance, if you want to get your news via NNTP from
112 \"flab.flab.edu\", you could say:
114 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
116 If you want to use your local spool, say:
118 (setq gnus-select-method (list 'nnspool (system-name)))
120 If you use this variable, you must set `gnus-nntp-server' to nil.
122 There is a lot more to know about select methods and virtual servers -
123 see the manual for details.")
125 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
126 (defvar gnus-post-method nil
127 "*Preferred method for posting USENET news.
128 If this variable is nil, Gnus will use the current method to decide
129 which method to use when posting. If it is non-nil, it will override
130 the current method. This method will not be used in mail groups and
131 the like, only in \"real\" newsgroups.
133 The value must be a valid method as discussed in the documentation of
134 `gnus-select-method'.")
136 (defvar gnus-refer-article-method nil
137 "*Preferred method for fetching an article by Message-ID.
138 If you are reading news from the local spool (with nnspool), fetching
139 articles by Message-ID is painfully slow. By setting this method to an
140 nntp method, you might get acceptable results.
142 The value of this variable must be a valid select method as discussed
143 in the documentation of `gnus-select-method'")
145 (defvar gnus-secondary-select-methods nil
146 "*A list of secondary methods that will be used for reading news.
147 This is a list where each element is a complete select method (see
148 `gnus-select-method').
150 If, for instance, you want to read your mail with the nnml backend,
151 you could set this variable:
153 (setq gnus-secondary-select-methods '((nnml \"\")))")
155 (defvar gnus-secondary-servers nil
156 "*List of NNTP servers that the user can choose between interactively.
157 To make Gnus query you for a server, you have to give `gnus' a
158 non-numeric prefix - `C-u M-x gnus', in short.")
160 (defvar gnus-nntp-server nil
161 "*The name of the host running the NNTP server.
162 This variable is semi-obsolete. Use the `gnus-select-method'
163 variable instead.")
165 (defvar gnus-startup-file "~/.newsrc"
166 "*Your `.newsrc' file.
167 `.newsrc-SERVER' will be used instead if that exists.")
169 (defvar gnus-init-file "~/.gnus"
170 "*Your Gnus elisp startup file.
171 If a file with the .el or .elc suffixes exist, it will be read
172 instead.")
174 (defvar gnus-group-faq-directory
175 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
176 "*Directory where the group FAQs are stored.
177 This will most commonly be on a remote machine, and the file will be
178 fetched by ange-ftp.
180 Note that Gnus uses an aol machine as the default directory. If this
181 feels fundamentally unclean, just think of it as a way to finally get
182 something of value back from them.
184 If the default site is too slow, try one of these:
186 North America: ftp.uu.net /usenet/news.answers
187 mirrors.aol.com /pub/rtfm/usenet
188 ftp.seas.gwu.edu /pub/rtfm
189 rtfm.mit.edu /pub/usenet/news.answers
190 Europe: ftp.uni-paderborn.de /pub/FAQ
191 ftp.Germany.EU.net /pub/newsarchive/news.answers
192 ftp.sunet.se /pub/usenet
193 Asia: nctuccca.edu.tw /USENET/FAQ
194 hwarang.postech.ac.kr /pub/usenet/news.answers
195 ftp.hk.super.net /mirror/faqs")
197 (defvar gnus-group-archive-directory
198 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
199 "*The address of the (ding) archives.")
201 (defvar gnus-group-recent-archive-directory
202 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
203 "*The address of the most recent (ding) articles.")
205 (defvar gnus-default-subscribed-newsgroups nil
206 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
207 It should be a list of strings.
208 If it is `t', Gnus will not do anything special the first time it is
209 started; it'll just use the normal newsgroups subscription methods.")
211 (defvar gnus-use-cross-reference t
212 "*Non-nil means that cross referenced articles will be marked as read.
213 If nil, ignore cross references. If t, mark articles as read in
214 subscribed newsgroups. If neither t nor nil, mark as read in all
215 newsgroups.")
217 (defvar gnus-use-dribble-file t
218 "*Non-nil means that Gnus will use a dribble file to store user updates.
219 If Emacs should crash without saving the .newsrc files, complete
220 information can be restored from the dribble file.")
222 (defvar gnus-asynchronous nil
223 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
225 (defvar gnus-asynchronous-article-function nil
226 "*Function for picking articles to pre-fetch, possibly.")
228 (defvar gnus-score-file-single-match-alist nil
229 "*Alist mapping regexps to lists of score files.
230 Each element of this alist should be of the form
231 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
233 If the name of a group is matched by REGEXP, the corresponding scorefiles
234 will be used for that group.
235 The first match found is used, subsequent matching entries are ignored (to
236 use multiple matches, see gnus-score-file-multiple-match-alist).
238 These score files are loaded in addition to any files returned by
239 gnus-score-find-score-files-function (which see).")
241 (defvar gnus-score-file-multiple-match-alist nil
242 "*Alist mapping regexps to lists of score files.
243 Each element of this alist should be of the form
244 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
246 If the name of a group is matched by REGEXP, the corresponding scorefiles
247 will be used for that group.
248 If multiple REGEXPs match a group, the score files corresponding to each
249 match will be used (for only one match to be used, see
250 gnus-score-file-single-match-alist).
252 These score files are loaded in addition to any files returned by
253 gnus-score-find-score-files-function (which see).")
256 (defvar gnus-score-file-suffix "SCORE"
257 "*Suffix of the score files.")
259 (defvar gnus-adaptive-file-suffix "ADAPT"
260 "*Suffix of the adaptive score files.")
262 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
263 "*Function used to find score files.
264 The function will be called with the group name as the argument, and
265 should return a list of score files to apply to that group. The score
266 files do not actually have to exist.
268 Predefined values are:
270 gnus-score-find-single: Only apply the group's own score file.
271 gnus-score-find-hierarchical: Also apply score files from parent groups.
272 gnus-score-find-bnews: Apply score files whose names matches.
274 See the documentation to these functions for more information.
276 This variable can also be a list of functions to be called. Each
277 function should either return a list of score files, or a list of
278 score alists.")
280 (defvar gnus-score-interactive-default-score 1000
281 "*Scoring commands will raise/lower the score with this number as the default.")
283 (defvar gnus-large-newsgroup 200
284 "*The number of articles which indicates a large newsgroup.
285 If the number of articles in a newsgroup is greater than this value,
286 confirmation is required for selecting the newsgroup.")
288 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
289 (defvar gnus-no-groups-message "No news is horrible news"
290 "*Message displayed by Gnus when no groups are available.")
292 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
293 "*Non-nil means that the default name of a file to save articles in is the group name.
294 If it's nil, the directory form of the group name is used instead.
296 If this variable is a list, and the list contains the element
297 `not-score', long file names will not be used for score files; if it
298 contains the element `not-save', long file names will not be used for
299 saving; and if it contains the element `not-kill', long file names
300 will not be used for kill files.")
302 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
303 "*Name of the directory articles will be saved in (default \"~/News\").
304 Initialized from the SAVEDIR environment variable.")
306 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
307 "*Name of the directory where kill files will be stored (default \"~/News\").
308 Initialized from the SAVEDIR environment variable.")
310 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
311 "*A function to save articles in your favorite format.
312 The function must be interactively callable (in other words, it must
313 be an Emacs command).
315 Gnus provides the following functions:
317 * gnus-summary-save-in-rmail (Rmail format)
318 * gnus-summary-save-in-mail (Unix mail format)
319 * gnus-summary-save-in-folder (MH folder)
320 * gnus-summary-save-in-file (article format).
321 * gnus-summary-save-in-vm (use VM's folder format).")
323 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
324 "*A function generating a file name to save articles in Rmail format.
325 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
327 (defvar gnus-mail-save-name (function gnus-plain-save-name)
328 "*A function generating a file name to save articles in Unix mail format.
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
331 (defvar gnus-folder-save-name (function gnus-folder-save-name)
332 "*A function generating a file name to save articles in MH folder.
333 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
335 (defvar gnus-file-save-name (function gnus-numeric-save-name)
336 "*A function generating a file name to save articles in article format.
337 The function is called with NEWSGROUP, HEADERS, and optional
338 LAST-FILE.")
340 (defvar gnus-split-methods nil
341 "*Variable used to suggest where articles are to be saved.
342 The syntax of this variable is the same as `nnmail-split-methods'.
344 For instance, if you would like to save articles related to Gnus in
345 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
346 you could set this variable to something like:
348 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
349 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
351 (defvar gnus-save-score nil
352 "*If non-nil, save group scoring info.")
354 (defvar gnus-use-adaptive-scoring nil
355 "*If non-nil, use some adaptive scoring scheme.")
357 (defvar gnus-use-cache nil
358 "*If non-nil, Gnus will cache (some) articles locally.")
360 (defvar gnus-use-scoring t
361 "*If non-nil, enable scoring.")
363 (defvar gnus-fetch-old-headers nil
364 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
365 If an unread article in the group refers to an older, already read (or
366 just marked as read) article, the old article will not normally be
367 displayed in the Summary buffer. If this variable is non-nil, Gnus
368 will attempt to grab the headers to the old articles, and thereby
369 build complete threads. If it has the value `some', only enough
370 headers to connect otherwise loose threads will be displayed.
372 The server has to support XOVER for any of this to work.")
374 ;see gnus-cus.el
375 ;(defvar gnus-visual t
376 ; "*If non-nil, will do various highlighting.
377 ;If nil, no mouse highlights (or any other highlights) will be
378 ;performed. This might speed up Gnus some when generating large group
379 ;and summary buffers.")
381 (defvar gnus-novice-user t
382 "*Non-nil means that you are a usenet novice.
383 If non-nil, verbose messages may be displayed and confirmations may be
384 required.")
386 (defvar gnus-expert-user nil
387 "*Non-nil means that you will never be asked for confirmation about anything.
388 And that means *anything*.")
390 (defvar gnus-verbose 7
391 "*Integer that says how verbose Gnus should be.
392 The higher the number, the more messages Gnus will flash to say what
393 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
394 display most important messages; and at ten, Gnus will keep on
395 jabbering all the time.")
397 (defvar gnus-keep-same-level nil
398 "*Non-nil means that the next newsgroup after the current will be on the same level.
399 When you type, for instance, `n' after reading the last article in the
400 current newsgroup, you will go to the next newsgroup. If this variable
401 is nil, the next newsgroup will be the next from the group
402 buffer.
403 If this variable is non-nil, Gnus will either put you in the
404 next newsgroup with the same level, or, if no such newsgroup is
405 available, the next newsgroup with the lowest possible level higher
406 than the current level.
407 If this variable is `best', Gnus will make the next newsgroup the one
408 with the best level.")
410 (defvar gnus-summary-make-false-root 'adopt
411 "*nil means that Gnus won't gather loose threads.
412 If the root of a thread has expired or been read in a previous
413 session, the information necessary to build a complete thread has been
414 lost. Instead of having many small sub-threads from this original thread
415 scattered all over the summary buffer, Gnus can gather them.
417 If non-nil, Gnus will try to gather all loose sub-threads from an
418 original thread into one large thread.
420 If this variable is non-nil, it should be one of `none', `adopt',
421 `dummy' or `empty'.
423 If this variable is `none', Gnus will not make a false root, but just
424 present the sub-threads after another.
425 If this variable is `dummy', Gnus will create a dummy root that will
426 have all the sub-threads as children.
427 If this variable is `adopt', Gnus will make one of the \"children\"
428 the parent and mark all the step-children as such.
429 If this variable is `empty', the \"children\" are printed with empty
430 subject fields. (Or rather, they will be printed with a string
431 given by the `gnus-summary-same-subject' variable.)")
433 (defvar gnus-summary-gather-subject-limit nil
434 "*Maximum length of subject comparisons when gathering loose threads.
435 Use nil to compare full subjects. Setting this variable to a low
436 number will help gather threads that have been corrupted by
437 newsreaders chopping off subject lines, but it might also mean that
438 unrelated articles that have subject that happen to begin with the
439 same few characters will be incorrectly gathered.
441 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
442 comparing subjects.")
444 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
445 (defvar gnus-summary-same-subject ""
446 "*String indicating that the current article has the same subject as the previous.
447 This variable will only be used if the value of
448 `gnus-summary-make-false-root' is `empty'.")
450 (defvar gnus-summary-goto-unread t
451 "*If non-nil, marking commands will go to the next unread article.")
453 (defvar gnus-group-goto-unread t
454 "*If non-nil, movement commands will go to the next unread and subscribed group.")
456 (defvar gnus-check-new-newsgroups t
457 "*Non-nil means that Gnus will add new newsgroups at startup.
458 If this variable is `ask-server', Gnus will ask the server for new
459 groups since the last time it checked. This means that the killed list
460 is no longer necessary, so you could set `gnus-save-killed-list' to
461 nil.
463 A variant is to have this variable be a list of select methods. Gnus
464 will then use the `ask-server' method on all these select methods to
465 query for new groups from all those servers.
468 (setq gnus-check-new-newsgroups
469 '((nntp \"some.server\") (nntp \"other.server\")))
471 If this variable is nil, then you have to tell Gnus explicitly to
472 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
474 (defvar gnus-check-bogus-newsgroups nil
475 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
476 If this variable is nil, then you have to tell Gnus explicitly to
477 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
479 (defvar gnus-read-active-file t
480 "*Non-nil means that Gnus will read the entire active file at startup.
481 If this variable is nil, Gnus will only know about the groups in your
482 `.newsrc' file.
484 If this variable is `some', Gnus will try to only read the relevant
485 parts of the active file from the server. Not all servers support
486 this, and it might be quite slow with other servers, but this should
487 generally be faster than both the t and nil value.
489 If you set this variable to nil or `some', you probably still want to
490 be told about new newsgroups that arrive. To do that, set
491 `gnus-check-new-newsgroups' to `ask-server'. This may not work
492 properly with all servers.")
494 (defvar gnus-level-subscribed 5
495 "*Groups with levels less than or equal to this variable are subscribed.")
497 (defvar gnus-level-unsubscribed 7
498 "*Groups with levels less than or equal to this variable are unsubscribed.
499 Groups with levels less than `gnus-level-subscribed', which should be
500 less than this variable, are subscribed.")
502 (defvar gnus-level-zombie 8
503 "*Groups with this level are zombie groups.")
505 (defvar gnus-level-killed 9
506 "*Groups with this level are killed.")
508 (defvar gnus-level-default-subscribed 3
509 "*New subscribed groups will be subscribed at this level.")
511 (defvar gnus-level-default-unsubscribed 6
512 "*New unsubscribed groups will be unsubscribed at this level.")
514 (defvar gnus-activate-foreign-newsgroups 4
515 "*If nil, Gnus will not check foreign newsgroups at startup.
516 If it is non-nil, it should be a number between one and nine. Foreign
517 newsgroups that have a level lower or equal to this number will be
518 activated on startup. For instance, if you want to active all
519 subscribed newsgroups, but not the rest, you'd set this variable to
520 `gnus-level-subscribed'.
522 If you subscribe to lots of newsgroups from different servers, startup
523 might take a while. By setting this variable to nil, you'll save time,
524 but you won't be told how many unread articles there are in the
525 groups.")
527 (defvar gnus-save-newsrc-file t
528 "*Non-nil means that Gnus will save the `.newsrc' file.
529 Gnus always saves its own startup file, which is called
530 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
531 be readily understood by other newsreaders. If you don't plan on
532 using other newsreaders, set this variable to nil to save some time on
533 exit.")
535 (defvar gnus-save-killed-list t
536 "*If non-nil, save the list of killed groups to the startup file.
537 This will save both time (when starting and quitting) and space (both
538 memory and disk), but it will also mean that Gnus has no record of
539 which groups are new and which are old, so the automatic new
540 newsgroups subscription methods become meaningless. You should always
541 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
542 variable to nil.")
544 (defvar gnus-interactive-catchup t
545 "*If non-nil, require your confirmation when catching up a group.")
547 (defvar gnus-interactive-post t
548 "*If non-nil, group name will be asked for when posting.")
550 (defvar gnus-interactive-exit t
551 "*If non-nil, require your confirmation when exiting Gnus.")
553 (defvar gnus-kill-killed t
554 "*If non-nil, Gnus will apply kill files to already killed articles.
555 If it is nil, Gnus will never apply kill files to articles that have
556 already been through the scoring process, which might very well save lots
557 of time.")
559 (defvar gnus-extract-address-components 'gnus-extract-address-components
560 "*Function for extracting address components from a From header.
561 Two pre-defined function exist: `gnus-extract-address-components',
562 which is the default, quite fast, and too simplistic solution, and
563 `mail-extract-address-components', which works much better, but is
564 slower.")
566 (defvar gnus-summary-default-score 0
567 "*Default article score level.
568 If this variable is nil, scoring will be disabled.")
570 (defvar gnus-summary-zcore-fuzz 0
571 "*Fuzziness factor for the zcore in the summary buffer.
572 Articles with scores closer than this to `gnus-summary-default-score'
573 will not be marked.")
575 (defvar gnus-simplify-subject-fuzzy-regexp nil
576 "*Regular expression that will be removed from subject strings if
577 fuzzy subject simplification is selected.")
579 (defvar gnus-group-default-list-level gnus-level-subscribed
580 "*Default listing level.
581 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
583 (defvar gnus-group-use-permanent-levels nil
584 "*If non-nil, once you set a level, Gnus will use this level.")
586 (defvar gnus-show-mime nil
587 "*If non-nil, do mime processing of articles.
588 The articles will simply be fed to the function given by
589 `gnus-show-mime-method'.")
591 (defvar gnus-strict-mime t
592 "*If nil, decode MIME header even if there is not Mime-Version field.")
594 (defvar gnus-show-mime-method (function metamail-buffer)
595 "*Function to process a MIME message.
596 The function is called from the article buffer.")
598 (defvar gnus-show-threads t
599 "*If non-nil, display threads in summary mode.")
601 (defvar gnus-thread-hide-subtree nil
602 "*If non-nil, hide all threads initially.
603 If threads are hidden, you have to run the command
604 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
605 to expose hidden threads.")
607 (defvar gnus-thread-hide-killed t
608 "*If non-nil, hide killed threads automatically.")
610 (defvar gnus-thread-ignore-subject nil
611 "*If non-nil, ignore subjects and do all threading based on the Reference header.
612 If nil, which is the default, articles that have different subjects
613 from their parents will start separate threads.")
615 (defvar gnus-thread-indent-level 4
616 "*Number that says how much each sub-thread should be indented.")
618 (defvar gnus-ignored-newsgroups
619 (purecopy (mapconcat 'identity
620 '("^to\\." ; not "real" groups
621 "^[0-9. \t]+ " ; all digits in name
622 "[][\"#'()]" ; bogus characters
624 "\\|"))
625 "*A regexp to match uninteresting newsgroups in the active file.
626 Any lines in the active file matching this regular expression are
627 removed from the newsgroup list before anything else is done to it,
628 thus making them effectively non-existent.")
630 (defvar gnus-ignored-headers
631 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
632 "*All headers that match this regexp will be hidden.
633 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
635 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
636 "*All headers that do not match this regexp will be hidden.
637 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
639 (defvar gnus-sorted-header-list
640 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
641 "^Cc:" "^Date:" "^Organization:")
642 "*This variable is a list of regular expressions.
643 If it is non-nil, headers that match the regular expressions will
644 be placed first in the article buffer in the sequence specified by
645 this list.")
647 (defvar gnus-show-all-headers nil
648 "*If non-nil, don't hide any headers.")
650 (defvar gnus-save-all-headers t
651 "*If non-nil, don't remove any headers before saving.")
653 (defvar gnus-inhibit-startup-message nil
654 "*If non-nil, the startup message will not be displayed.")
656 (defvar gnus-signature-separator "^-- *$"
657 "Regexp matching signature separator.")
659 (defvar gnus-auto-extend-newsgroup t
660 "*If non-nil, extend newsgroup forward and backward when requested.")
662 (defvar gnus-auto-select-first t
663 "*If non-nil, select the first unread article when entering a group.
664 If you want to prevent automatic selection of the first unread article
665 in some newsgroups, set the variable to nil in
666 `gnus-select-group-hook'.")
668 (defvar gnus-auto-select-next t
669 "*If non-nil, offer to go to the next group from the end of the previous.
670 If the value is t and the next newsgroup is empty, Gnus will exit
671 summary mode and go back to group mode. If the value is neither nil
672 nor t, Gnus will select the following unread newsgroup. In
673 particular, if the value is the symbol `quietly', the next unread
674 newsgroup will be selected without any confirmations.")
676 (defvar gnus-auto-select-same nil
677 "*If non-nil, select the next article with the same subject.")
679 (defvar gnus-summary-check-current nil
680 "*If non-nil, consider the current article when moving.
681 The \"unread\" movement commands will stay on the same line if the
682 current article is unread.")
684 (defvar gnus-auto-center-summary t
685 "*If non-nil, always center the current summary buffer.")
687 (defvar gnus-break-pages t
688 "*If non-nil, do page breaking on articles.
689 The page delimiter is specified by the `gnus-page-delimiter'
690 variable.")
692 (defvar gnus-page-delimiter "^\^L"
693 "*Regexp describing what to use as article page delimiters.
694 The default value is \"^\^L\", which is a form linefeed at the
695 beginning of a line.")
697 (defvar gnus-use-full-window t
698 "*If non-nil, use the entire Emacs screen.")
700 (defvar gnus-window-configuration nil
701 "Obsolete variable. See `gnus-buffer-configuration'.")
703 (defvar gnus-buffer-configuration
704 '((group ([group 1.0 point]
705 (if gnus-carpal [group-carpal 4])))
706 (summary ([summary 1.0 point]
707 (if gnus-carpal [summary-carpal 4])))
708 (article ([summary 0.25 point]
709 (if gnus-carpal [summary-carpal 4])
710 [article 1.0]))
711 (server ([server 1.0 point]
712 (if gnus-carpal [server-carpal 2])))
713 (browse ([browse 1.0 point]
714 (if gnus-carpal [browse-carpal 2])))
715 (group-mail ([mail 1.0 point]))
716 (summary-mail ([mail 1.0 point]))
717 (summary-reply ([article 0.5]
718 [mail 1.0 point]))
719 (info ([nil 1.0 point]))
720 (summary-faq ([summary 0.25]
721 [faq 1.0 point]))
722 (edit-group ([group 0.5]
723 [edit-group 1.0 point]))
724 (edit-server ([server 0.5]
725 [edit-server 1.0 point]))
726 (edit-score ([summary 0.25]
727 [edit-score 1.0 point]))
728 (post ([post 1.0 point]))
729 (reply ([article 0.5]
730 [mail 1.0 point]))
731 (mail-forward ([mail 1.0 point]))
732 (post-forward ([post 1.0 point]))
733 (reply-yank ([mail 1.0 point]))
734 (followup ([article 0.5]
735 [post 1.0 point]))
736 (followup-yank ([post 1.0 point])))
737 "Window configuration for all possible Gnus buffers.
738 This variable is a list of lists. Each of these lists has a NAME and
739 a RULE. The NAMEs are commonsense names like `group', which names a
740 rule used when displaying the group buffer; `summary', which names a
741 rule for what happens when you enter a group and do not display an
742 article buffer; and so on. See the value of this variable for a
743 complete list of NAMEs.
745 Each RULE is a list of vectors. The first element in this vector is
746 the name of the buffer to be displayed; the second element is the
747 percentage of the screen this buffer is to occupy (a number in the
748 0.0-0.99 range); the optional third element is `point', which should
749 be present to denote which buffer point is to go to after making this
750 buffer configuration.")
752 (defvar gnus-window-to-buffer
753 '((group . gnus-group-buffer)
754 (summary . gnus-summary-buffer)
755 (article . gnus-article-buffer)
756 (server . gnus-server-buffer)
757 (browse . "*Gnus Browse Server*")
758 (edit-group . gnus-group-edit-buffer)
759 (edit-server . gnus-server-edit-buffer)
760 (group-carpal . gnus-carpal-group-buffer)
761 (summary-carpal . gnus-carpal-summary-buffer)
762 (server-carpal . gnus-carpal-server-buffer)
763 (browse-carpal . gnus-carpal-browse-buffer)
764 (edit-score . gnus-score-edit-buffer)
765 (mail . gnus-mail-buffer)
766 (post . gnus-post-news-buffer)
767 (faq . gnus-faq-buffer))
768 "Mapping from short symbols to buffer names or buffer variables.")
770 (defvar gnus-carpal nil
771 "*If non-nil, display clickable icons.")
773 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
774 "*Function called with a group name when new group is detected.
775 A few pre-made functions are supplied: `gnus-subscribe-randomly'
776 inserts new groups at the beginning of the list of groups;
777 `gnus-subscribe-alphabetically' inserts new groups in strict
778 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
779 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
780 for your decision.")
782 ;; Suggested by a bug report by Hallvard B Furuseth.
783 ;; <h.b.furuseth@usit.uio.no>.
784 (defvar gnus-subscribe-options-newsgroup-method
785 (function gnus-subscribe-alphabetically)
786 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
787 If, for instance, you want to subscribe to all newsgroups in the
788 \"no\" and \"alt\" hierarchies, you'd put the following in your
789 .newsrc file:
791 options -n no.all alt.all
793 Gnus will the subscribe all new newsgroups in these hierarchies with
794 the subscription method in this variable.")
796 (defvar gnus-subscribe-hierarchical-interactive nil
797 "*If non-nil, Gnus will offer to subscribe hierarchically.
798 When a new hierarchy appears, Gnus will ask the user:
800 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
802 If the user pressed `d', Gnus will descend the hierarchy, `y' will
803 subscribe to all newsgroups in the hierarchy and `s' will skip this
804 hierarchy in its entirety.")
806 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
807 "*Function used for sorting the group buffer.
808 This function will be called with group info entries as the arguments
809 for the groups to be sorted. Pre-made functions include
810 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
811 `gnus-group-sort-by-level'")
813 ;; Mark variables suggested by Thomas Michanek
814 ;; <Thomas.Michanek@telelogic.se>.
815 (defvar gnus-unread-mark ?
816 "*Mark used for unread articles.")
817 (defvar gnus-ticked-mark ?!
818 "*Mark used for ticked articles.")
819 (defvar gnus-dormant-mark ??
820 "*Mark used for dormant articles.")
821 (defvar gnus-del-mark ?r
822 "*Mark used for del'd articles.")
823 (defvar gnus-read-mark ?R
824 "*Mark used for read articles.")
825 (defvar gnus-expirable-mark ?E
826 "*Mark used for expirable articles.")
827 (defvar gnus-killed-mark ?K
828 "*Mark used for killed articles.")
829 (defvar gnus-kill-file-mark ?X
830 "*Mark used for articles killed by kill files.")
831 (defvar gnus-low-score-mark ?Y
832 "*Mark used for articles with a low score.")
833 (defvar gnus-catchup-mark ?C
834 "*Mark used for articles that are caught up.")
835 (defvar gnus-replied-mark ?A
836 "*Mark used for articles that have been replied to.")
837 (defvar gnus-process-mark ?#
838 "*Process mark.")
839 (defvar gnus-ancient-mark ?O
840 "*Mark used for ancient articles.")
841 (defvar gnus-canceled-mark ?G
842 "*Mark used for canceled articles.")
843 (defvar gnus-score-over-mark ?+
844 "*Score mark used for articles with high scores.")
845 (defvar gnus-score-below-mark ?-
846 "*Score mark used for articles with low scores.")
847 (defvar gnus-empty-thread-mark ?
848 "*There is no thread under the article.")
849 (defvar gnus-not-empty-thread-mark ?=
850 "*There is a thread under the article.")
851 (defvar gnus-dummy-mark ?Z
852 "*This is a dummy article.")
854 (defvar gnus-view-pseudo-asynchronously nil
855 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
857 (defvar gnus-view-pseudos nil
858 "*If `automatic', pseudo-articles will be viewed automatically.
859 If `not-confirm', pseudos will be viewed automatically, and the user
860 will not be asked to confirm the command.")
862 (defvar gnus-view-pseudos-separately t
863 "*If non-nil, one pseudo-article will be created for each file to be viewed.
864 If nil, all files that use the same viewing command will be given as a
865 list of parameters to that command.")
867 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
868 "*Format of group lines.
869 It works along the same lines as a normal formatting string,
870 with some simple extensions.
872 %M Only marked articles (character, \"*\" or \" \")
873 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
874 %L Level of subscribedness (integer)
875 %N Number of unread articles (integer)
876 %I Number of dormant articles (integer)
877 %i Number of ticked and dormant (integer)
878 %T Number of ticked articles (integer)
879 %R Number of read articles (integer)
880 %t Total number of articles (integer)
881 %y Number of unread, unticked articles (integer)
882 %G Group name (string)
883 %g Qualified group name (string)
884 %D Group description (string)
885 %s Select method (string)
886 %o Moderated group (char, \"m\")
887 %p Process mark (char)
888 %O Moderated group (string, \"(m)\" or \"\")
889 %n Select from where (string)
890 %z A string that look like `<%s:%n>' if a foreign select method is used
891 %u User defined specifier. The next character in the format string should
892 be a letter. Gnus will call the function gnus-user-format-function-X,
893 where X is the letter following %u. The function will be passed the
894 current header as argument. The function should return a string, which
895 will be inserted into the buffer just like information from any other
896 group specifier.
898 Text between %( and %) will be highlighted with `gnus-mouse-face' when
899 the mouse point move inside the area. There can only be one such area.
901 Note that this format specification is not always respected. For
902 reasons of efficiency, when listing killed groups, this specification
903 is ignored altogether. If the spec is changed considerably, your
904 output may end up looking strange when listing both alive and killed
905 groups.
907 If you use %o or %O, reading the active file will be slower and quite
908 a bit of extra memory will be used. %D will also worsen performance.
909 Also note that if you change the format specification to include any
910 of these specs, you must probably re-start Gnus to see them go into
911 effect.")
913 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
914 "*The format specification of the lines in the summary buffer.
916 It works along the same lines as a normal formatting string,
917 with some simple extensions.
919 %N Article number, left padded with spaces (string)
920 %S Subject (string)
921 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
922 %n Name of the poster (string)
923 %a Extracted name of the poster (string)
924 %A Extracted address of the poster (string)
925 %F Contents of the From: header (string)
926 %x Contents of the Xref: header (string)
927 %D Date of the article (string)
928 %d Date of the article (string) in DD-MMM format
929 %M Message-id of the article (string)
930 %r References of the article (string)
931 %c Number of characters in the article (integer)
932 %L Number of lines in the article (integer)
933 %I Indentation based on thread level (a string of spaces)
934 %T A string with two possible values: 80 spaces if the article
935 is on thread level two or larger and 0 spaces on level one
936 %R \"A\" if this article has been replied to, \" \" otherwise (character)
937 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
938 %[ Opening bracket (character, \"[\" or \"<\")
939 %] Closing bracket (character, \"]\" or \">\")
940 %> Spaces of length thread-level (string)
941 %< Spaces of length (- 20 thread-level) (string)
942 %i Article score (number)
943 %z Article zcore (character)
944 %t Number of articles under the current thread (number).
945 %e Whether the thread is empty or not (character).
946 %u User defined specifier. The next character in the format string should
947 be a letter. Gnus will call the function gnus-user-format-function-X,
948 where X is the letter following %u. The function will be passed the
949 current header as argument. The function should return a string, which
950 will be inserted into the summary just like information from any other
951 summary specifier.
953 Text between %( and %) will be highlighted with `gnus-mouse-face'
954 when the mouse point is placed inside the area. There can only be one
955 such area.
957 The %U (status), %R (replied) and %z (zcore) specs have to be handled
958 with care. For reasons of efficiency, Gnus will compute what column
959 these characters will end up in, and \"hard-code\" that. This means that
960 it is illegal to have these specs after a variable-length spec. Well,
961 you might not be arrested, but your summary buffer will look strange,
962 which is bad enough.
964 The smart choice is to have these specs as for to the left as
965 possible.
967 This restriction may disappear in later versions of Gnus.")
969 (defvar gnus-summary-dummy-line-format "* : : %S\n"
970 "*The format specification for the dummy roots in the summary buffer.
971 It works along the same lines as a normal formatting string,
972 with some simple extensions.
974 %S The subject")
976 (defvar gnus-summary-mode-line-format "Gnus %G/%A %Z"
977 "*The format specification for the summary mode line.")
979 (defvar gnus-article-mode-line-format "Gnus %G/%A %S"
980 "*The format specification for the article mode line.")
982 (defvar gnus-group-mode-line-format "Gnus List of groups {%M:%S} "
983 "*The format specification for the group mode line.")
985 (defvar gnus-valid-select-methods
986 '(("nntp" post address prompt-address)
987 ("nnspool" post)
988 ("nnvirtual" none virtual prompt-address)
989 ("nnmbox" mail respool)
990 ("nnml" mail respool)
991 ("nnmh" mail respool)
992 ("nndir" none prompt-address address)
993 ("nneething" none prompt-address)
994 ("nndigest" none)
995 ("nndoc" none prompt-address)
996 ("nnbabyl" mail respool)
997 ("nnkiboze" post virtual)
998 ;;("nnsoup" post)
999 ("nnfolder" mail respool))
1000 "An alist of valid select methods.
1001 The first element of each list lists should be a string with the name
1002 of the select method. The other elements may be be the category of
1003 this method (ie. `post', `mail', `none' or whatever) or other
1004 properties that this method has (like being respoolable).
1005 If you implement a new select method, all you should have to change is
1006 this variable. I think.")
1008 (defvar gnus-updated-mode-lines '(group article summary)
1009 "*List of buffers that should update their mode lines.
1010 The list may contain the symbols `group', `article' and `summary'. If
1011 the corresponding symbol is present, Gnus will keep that mode line
1012 updated with information that may be pertinent.
1013 If this variable is nil, screen refresh may be quicker.")
1015 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1016 (defvar gnus-mode-non-string-length 21
1017 "*Max length of mode-line non-string contents.
1018 If this is nil, Gnus will take space as is needed, leaving the rest
1019 of the modeline intact.")
1021 ;see gnus-cus.el
1022 ;(defvar gnus-mouse-face 'highlight
1023 ; "*Face used for mouse highlighting in Gnus.
1024 ;No mouse highlights will be done if `gnus-visual' is nil.")
1026 (defvar gnus-summary-mark-below nil
1027 "*Mark all articles with a score below this variable as read.
1028 This variable is local to each summary buffer and usually set by the
1029 score file.")
1031 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1032 "*List of functions used for sorting threads in the summary buffer.
1033 By default, threads are sorted by article number.
1035 Each function takes two threads and return non-nil if the first thread
1036 should be sorted before the other. If you use more than one function,
1037 the primary sort function should be the last.
1039 Ready-mady functions include `gnus-thread-sort-by-number',
1040 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1041 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1042 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1044 (defvar gnus-thread-score-function '+
1045 "*Function used for calculating the total score of a thread.
1047 The function is called with the scores of the article and each
1048 subthread and should then return the score of the thread.
1050 Some functions you can use are `+', `max', or `min'.")
1052 (defvar gnus-options-subscribe nil
1053 "*All new groups matching this regexp will be subscribed unconditionally.
1054 Note that this variable deals only with new newsgroups. This variable
1055 does not affect old newsgroups.")
1057 (defvar gnus-options-not-subscribe nil
1058 "*All new groups matching this regexp will be ignored.
1059 Note that this variable deals only with new newsgroups. This variable
1060 does not affect old (already subscribed) newsgroups.")
1062 (defvar gnus-auto-expirable-newsgroups nil
1063 "*Groups in which to automatically mark read articles as expirable.
1064 If non-nil, this should be a regexp that should match all groups in
1065 which to perform auto-expiry. This only makes sense for mail groups.")
1067 (defvar gnus-hidden-properties '(invisible t intangible t)
1068 "Property list to use for hiding text.")
1070 (defvar gnus-modtime-botch nil
1071 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1072 due to the bogus appearance that .newsrc was modified on disc.")
1074 ;; Hooks.
1076 (defvar gnus-group-mode-hook nil
1077 "*A hook for Gnus group mode.")
1079 (defvar gnus-summary-mode-hook nil
1080 "*A hook for Gnus summary mode.
1081 This hook is run before any variables are set in the summary buffer.")
1083 (defvar gnus-article-mode-hook nil
1084 "*A hook for Gnus article mode.")
1086 (defun gnus-summary-prepare-exit-hook nil
1087 "*A hook called when preparing to exit from the summary buffer.
1088 It calls `gnus-summary-expire-articles' by default.")
1089 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1091 (defun gnus-summary-exit-hook nil
1092 "*A hook called on exit from the summary buffer.")
1094 (defvar gnus-open-server-hook nil
1095 "*A hook called just before opening connection to the news server.")
1097 (defvar gnus-load-hook nil
1098 "*A hook run while Gnus is loaded.")
1100 (defvar gnus-startup-hook nil
1101 "*A hook called at startup.
1102 This hook is called after Gnus is connected to the NNTP server.")
1104 (defvar gnus-get-new-news-hook nil
1105 "*A hook run just before Gnus checks for new news.")
1107 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1108 "*A function that is called to generate the group buffer.
1109 The function is called with three arguments: The first is a number;
1110 all group with a level less or equal to that number should be listed,
1111 if the second is non-nil, empty groups should also be displayed. If
1112 the third is non-nil, it is a number. No groups with a level lower
1113 than this number should be displayed.
1115 The only current function implemented is `gnus-group-prepare-flat'.")
1117 (defvar gnus-group-prepare-hook nil
1118 "*A hook called after the group buffer has been generated.
1119 If you want to modify the group buffer, you can use this hook.")
1121 (defvar gnus-summary-prepare-hook nil
1122 "*A hook called after the summary buffer has been generated.
1123 If you want to modify the summary buffer, you can use this hook.")
1125 (defvar gnus-article-prepare-hook nil
1126 "*A hook called after an article has been prepared in the article buffer.
1127 If you want to run a special decoding program like nkf, use this hook.")
1129 ;(defvar gnus-article-display-hook nil
1130 ; "*A hook called after the article is displayed in the article buffer.
1131 ;The hook is designed to change the contents of the article
1132 ;buffer. Typical functions that this hook may contain are
1133 ;`gnus-article-hide-headers' (hide selected headers),
1134 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1135 ;`gnus-article-hide-signature' (hide signature) and
1136 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1137 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1138 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1139 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1141 (defvar gnus-article-x-face-command
1142 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1143 "String or function to be executed to display an X-Face header.
1144 If it is a string, the command will be executed in a sub-shell
1145 asynchronously. The compressed face will be piped to this command.")
1147 (defvar gnus-article-x-face-too-ugly nil
1148 "Regexp matching posters whose face shouldn't be shown automatically.")
1150 (defvar gnus-select-group-hook nil
1151 "*A hook called when a newsgroup is selected.
1153 If you'd like to simplify subjects like the
1154 `gnus-summary-next-same-subject' command does, you can use the
1155 following hook:
1157 (setq gnus-select-group-hook
1158 (list
1159 (lambda ()
1160 (mapcar (lambda (header)
1161 (mail-header-set-subject
1162 header
1163 (gnus-simplify-subject
1164 (mail-header-subject header) 're-only)))
1165 gnus-newsgroup-headers))))")
1167 (defvar gnus-select-article-hook
1168 '(gnus-summary-show-thread)
1169 "*A hook called when an article is selected.
1170 The default hook shows conversation thread subtrees of the selected
1171 article automatically using `gnus-summary-show-thread'.")
1173 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1174 "*A hook called to apply kill files to a group.
1175 This hook is intended to apply a kill file to the selected newsgroup.
1176 The function `gnus-apply-kill-file' is called by default.
1178 Since a general kill file is too heavy to use only for a few
1179 newsgroups, I recommend you to use a lighter hook function. For
1180 example, if you'd like to apply a kill file to articles which contains
1181 a string `rmgroup' in subject in newsgroup `control', you can use the
1182 following hook:
1184 (setq gnus-apply-kill-hook
1185 (list
1186 (lambda ()
1187 (cond ((string-match \"control\" gnus-newsgroup-name)
1188 (gnus-kill \"Subject\" \"rmgroup\")
1189 (gnus-expunge \"X\"))))))")
1191 (defvar gnus-visual-mark-article-hook
1192 (list 'gnus-highlight-selected-summary)
1193 "*Hook run after selecting an article in the summary buffer.
1194 It is meant to be used for highlighting the article in some way. It
1195 is not run if `gnus-visual' is nil.")
1197 (defvar gnus-exit-group-hook nil
1198 "*A hook called when exiting (not quitting) summary mode.")
1200 (defvar gnus-suspend-gnus-hook nil
1201 "*A hook called when suspending (not exiting) Gnus.")
1203 (defvar gnus-exit-gnus-hook nil
1204 "*A hook called when exiting Gnus.")
1206 (defvar gnus-save-newsrc-hook nil
1207 "*A hook called when saving the newsrc file.")
1209 (defvar gnus-summary-update-hook
1210 (list 'gnus-summary-highlight-line)
1211 "*A hook called when a summary line is changed.
1212 The hook will not be called if `gnus-visual' is nil.
1214 The default function `gnus-summary-highlight-line' will
1215 highlight the line according to the `gnus-summary-highlight'
1216 variable.")
1218 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1219 "*A hook called when an article is selected for the first time.
1220 The hook is intended to mark an article as read (or unread)
1221 automatically when it is selected.")
1223 ;; Remove any hilit infestation.
1224 (add-hook 'gnus-startup-hook
1225 (lambda ()
1226 (remove-hook 'gnus-summary-prepare-hook
1227 'hilit-rehighlight-buffer-quietly)
1228 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1229 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1230 (remove-hook 'gnus-article-prepare-hook
1231 'hilit-rehighlight-buffer-quietly)))
1235 ;; Internal variables
1237 ;; Avoid highlighting in kill files.
1238 (defvar gnus-summary-inhibit-highlight nil)
1239 (defvar gnus-newsgroup-selected-overlay nil)
1241 (defvar gnus-article-mode-map nil)
1242 (defvar gnus-dribble-buffer nil)
1243 (defvar gnus-headers-retrieved-by nil)
1244 (defvar gnus-article-reply nil)
1245 (defvar gnus-override-method nil)
1246 (defvar gnus-article-check-size nil)
1248 (defvar gnus-current-score-file nil)
1249 (defvar gnus-internal-global-score-files nil)
1250 (defvar gnus-score-file-list nil)
1251 (defvar gnus-scores-exclude-files nil)
1253 (defvar gnus-current-move-group nil)
1255 (defvar gnus-newsgroup-dependencies nil)
1256 (defvar gnus-newsgroup-threads nil)
1257 (defvar gnus-newsgroup-async nil)
1258 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1260 (defvar gnus-newsgroup-adaptive nil)
1262 (defvar gnus-summary-display-table nil)
1264 (defconst gnus-group-line-format-alist
1265 (list (list ?M 'marked ?c)
1266 (list ?S 'subscribed ?c)
1267 (list ?L 'level ?d)
1268 (list ?N 'number ?s)
1269 (list ?I 'number-of-dormant ?d)
1270 (list ?T 'number-of-ticked ?d)
1271 (list ?R 'number-of-read ?s)
1272 (list ?t 'number-total ?d)
1273 (list ?y 'number-of-unread-unticked ?s)
1274 (list ?i 'number-of-ticked-and-dormant ?d)
1275 (list ?g 'group ?s)
1276 (list ?G 'qualified-group ?s)
1277 (list ?D 'newsgroup-description ?s)
1278 (list ?o 'moderated ?c)
1279 (list ?O 'moderated-string ?s)
1280 (list ?p 'process-marked ?c)
1281 (list ?s 'news-server ?s)
1282 (list ?n 'news-method ?s)
1283 (list ?z 'news-method-string ?s)
1284 (list ?u 'user-defined ?s)))
1286 (defconst gnus-summary-line-format-alist
1287 (list (list ?N 'number ?d)
1288 (list ?S 'subject ?s)
1289 (list ?s 'subject-or-nil ?s)
1290 (list ?n 'name ?s)
1291 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1293 (list ?a '(or (car (funcall gnus-extract-address-components from))
1294 from) ?s)
1295 (list ?F 'from ?s)
1296 (list ?x (macroexpand '(mail-header-xref header)) ?s)
1297 (list ?D (macroexpand '(mail-header-date header)) ?s)
1298 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s)
1299 (list ?M (macroexpand '(mail-header-id header)) ?s)
1300 (list ?r (macroexpand '(mail-header-references header)) ?s)
1301 (list ?c '(or (mail-header-chars header) 0) ?d)
1302 (list ?L 'lines ?d)
1303 (list ?I 'indentation ?s)
1304 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1305 (list ?R 'replied ?c)
1306 (list ?\[ 'opening-bracket ?c)
1307 (list ?\] 'closing-bracket ?c)
1308 (list ?\> '(make-string level ? ) ?s)
1309 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1310 (list ?i 'score ?d)
1311 (list ?z 'score-char ?c)
1312 (list ?U 'unread ?c)
1313 (list ?t '(gnus-summary-number-of-articles-in-thread
1314 (and (boundp 'thread) (car thread)))
1316 (list ?e '(gnus-summary-number-of-articles-in-thread
1317 (and (boundp 'thread) (car thread)) t)
1319 (list ?u 'user-defined ?s))
1320 "An alist of format specifications that can appear in summary lines,
1321 and what variables they correspond with, along with the type of the
1322 variable (string, integer, character, etc).")
1324 (defconst gnus-summary-dummy-line-format-alist
1325 (list (list ?S 'subject ?s)
1326 (list ?N 'number ?d)
1327 (list ?u 'user-defined ?s)))
1329 (defconst gnus-summary-mode-line-format-alist
1330 (list (list ?G 'group-name ?s)
1331 (list ?g '(gnus-short-group-name group-name) ?s)
1332 (list ?A 'article-number ?d)
1333 (list ?Z 'unread-and-unselected ?s)
1334 (list ?V 'gnus-version ?s)
1335 (list ?U 'unread ?d)
1336 (list ?S 'subject ?s)
1337 (list ?e 'unselected ?d)
1338 (list ?u 'user-defined ?s)
1339 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1341 (defconst gnus-group-mode-line-format-alist
1342 (list (list ?S 'news-server ?s)
1343 (list ?M 'news-method ?s)
1344 (list ?u 'user-defined ?s)))
1346 (defvar gnus-have-read-active-file nil)
1348 (defconst gnus-maintainer
1349 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1350 "The mail address of the Gnus maintainers.")
1352 (defconst gnus-version "Gnus v5.1"
1353 "Version number for this version of Gnus.")
1355 (defvar gnus-info-nodes
1356 '((gnus-group-mode "(gnus)The Group Buffer")
1357 (gnus-summary-mode "(gnus)The Summary Buffer")
1358 (gnus-article-mode "(gnus)The Article Buffer"))
1359 "Assoc list of major modes and related Info nodes.")
1361 (defvar gnus-group-buffer "*Group*")
1362 (defvar gnus-summary-buffer "*Summary*")
1363 (defvar gnus-article-buffer "*Article*")
1364 (defvar gnus-server-buffer "*Server*")
1366 (defvar gnus-work-buffer " *gnus work*")
1368 (defvar gnus-buffer-list nil
1369 "Gnus buffers that should be killed on exit.")
1371 (defvar gnus-server-alist nil
1372 "List of available servers.")
1374 (defvar gnus-variable-list
1375 '(gnus-newsrc-options gnus-newsrc-options-n
1376 gnus-newsrc-last-checked-date
1377 gnus-newsrc-alist gnus-server-alist
1378 gnus-killed-list gnus-zombie-list)
1379 "Gnus variables saved in the quick startup file.")
1381 (defvar gnus-overload-functions
1382 '((news-inews gnus-inews-news "rnewspost"))
1383 "Functions overloaded by gnus.
1384 It is a list of `(original overload &optional file)'.")
1386 (defvar gnus-newsrc-options nil
1387 "Options line in the .newsrc file.")
1389 (defvar gnus-newsrc-options-n nil
1390 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1392 (defvar gnus-newsrc-last-checked-date nil
1393 "Date Gnus last asked server for new newsgroups.")
1395 (defvar gnus-newsrc-alist nil
1396 "Assoc list of read articles.
1397 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1399 (defvar gnus-newsrc-hashtb nil
1400 "Hashtable of gnus-newsrc-alist.")
1402 (defvar gnus-killed-list nil
1403 "List of killed newsgroups.")
1405 (defvar gnus-killed-hashtb nil
1406 "Hash table equivalent of gnus-killed-list.")
1408 (defvar gnus-zombie-list nil
1409 "List of almost dead newsgroups.")
1411 (defvar gnus-description-hashtb nil
1412 "Descriptions of newsgroups.")
1414 (defvar gnus-list-of-killed-groups nil
1415 "List of newsgroups that have recently been killed by the user.")
1417 (defvar gnus-active-hashtb nil
1418 "Hashtable of active articles.")
1420 (defvar gnus-moderated-list nil
1421 "List of moderated newsgroups.")
1423 (defvar gnus-group-marked nil)
1425 (defvar gnus-current-startup-file nil
1426 "Startup file for the current host.")
1428 (defvar gnus-last-search-regexp nil
1429 "Default regexp for article search command.")
1431 (defvar gnus-last-shell-command nil
1432 "Default shell command on article.")
1434 (defvar gnus-current-select-method nil
1435 "The current method for selecting a newsgroup.")
1437 (defvar gnus-group-list-mode nil)
1439 (defvar gnus-article-internal-prepare-hook nil)
1441 (defvar gnus-newsgroup-name nil)
1442 (defvar gnus-newsgroup-begin nil)
1443 (defvar gnus-newsgroup-end nil)
1444 (defvar gnus-newsgroup-last-rmail nil)
1445 (defvar gnus-newsgroup-last-mail nil)
1446 (defvar gnus-newsgroup-last-folder nil)
1447 (defvar gnus-newsgroup-last-file nil)
1448 (defvar gnus-newsgroup-auto-expire nil)
1449 (defvar gnus-newsgroup-active nil)
1451 (defvar gnus-newsgroup-unreads nil
1452 "List of unread articles in the current newsgroup.")
1454 (defvar gnus-newsgroup-unselected nil
1455 "List of unselected unread articles in the current newsgroup.")
1457 (defvar gnus-newsgroup-reads nil
1458 "Alist of read articles and article marks in the current newsgroup.")
1460 (defvar gnus-newsgroup-marked nil
1461 "List of ticked articles in the current newsgroup (a subset of unread art).")
1463 (defvar gnus-newsgroup-killed nil
1464 "List of ranges of articles that have been through the scoring process.")
1466 (defvar gnus-newsgroup-kill-headers nil)
1468 (defvar gnus-newsgroup-replied nil
1469 "List of articles that have been replied to in the current newsgroup.")
1471 (defvar gnus-newsgroup-expirable nil
1472 "List of articles in the current newsgroup that can be expired.")
1474 (defvar gnus-newsgroup-processable nil
1475 "List of articles in the current newsgroup that can be processed.")
1477 (defvar gnus-newsgroup-bookmarks nil
1478 "List of articles in the current newsgroup that have bookmarks.")
1480 (defvar gnus-newsgroup-dormant nil
1481 "List of dormant articles in the current newsgroup.")
1483 (defvar gnus-newsgroup-scored nil
1484 "List of scored articles in the current newsgroup.")
1486 (defvar gnus-newsgroup-headers nil
1487 "List of article headers in the current newsgroup.")
1488 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1490 (defvar gnus-newsgroup-ancient nil
1491 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1493 (defvar gnus-current-article nil)
1494 (defvar gnus-article-current nil)
1495 (defvar gnus-current-headers nil)
1496 (defvar gnus-have-all-headers nil)
1497 (defvar gnus-last-article nil)
1498 (defvar gnus-newsgroup-history nil)
1499 (defvar gnus-current-kill-article nil)
1501 ;; Save window configuration.
1502 (defvar gnus-prev-winconf nil)
1504 ;; Format specs
1505 (defvar gnus-summary-line-format-spec nil)
1506 (defvar gnus-summary-dummy-line-format-spec nil)
1507 (defvar gnus-group-line-format-spec nil)
1508 (defvar gnus-summary-mode-line-format-spec nil)
1509 (defvar gnus-article-mode-line-format-spec nil)
1510 (defvar gnus-group-mode-line-format-spec nil)
1511 (defvar gnus-summary-mark-positions nil)
1512 (defvar gnus-group-mark-positions nil)
1514 (defvar gnus-summary-expunge-below nil)
1515 (defvar gnus-reffed-article-number nil)
1517 ; Let the byte-compiler know that we know about this variable.
1518 (defvar rmail-default-rmail-file)
1520 (defvar gnus-cache-removeable-articles nil)
1522 (defconst gnus-summary-local-variables
1523 '(gnus-newsgroup-name
1524 gnus-newsgroup-begin gnus-newsgroup-end
1525 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1526 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1527 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1528 gnus-newsgroup-unselected gnus-newsgroup-marked
1529 gnus-newsgroup-reads
1530 gnus-newsgroup-replied gnus-newsgroup-expirable
1531 gnus-newsgroup-processable gnus-newsgroup-killed
1532 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1533 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1534 gnus-current-article gnus-current-headers gnus-have-all-headers
1535 gnus-last-article gnus-article-internal-prepare-hook
1536 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1537 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1538 gnus-newsgroup-threads gnus-newsgroup-async
1539 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1540 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1541 gnus-newsgroup-history gnus-newsgroup-ancient
1542 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1543 gnus-cache-removeable-articles)
1544 "Variables that are buffer-local to the summary buffers.")
1546 (defconst gnus-bug-message
1547 "Sending a bug report to the Gnus Towers.
1548 ========================================
1550 The buffer below is a mail buffer. When you press `C-c C-c', it will
1551 be sent to the Gnus Bug Exterminators.
1553 At the bottom of the buffer you'll see lots of variable settings.
1554 Please do not delete those. They will tell the Bug People what your
1555 environment is, so that it will be easier to locate the bugs.
1557 If you have found a bug that makes Emacs go \"beep\", set
1558 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1559 and include the backtrace in your bug report.
1561 Please describe the bug in annoying, painstaking detail.
1563 Thank you for your help in stamping out bugs.
1566 ;;; End of variables.
1568 ;; Define some autoload functions Gnus might use.
1569 (eval-and-compile
1571 ;; Various
1572 (autoload 'metamail-buffer "metamail")
1573 (autoload 'Info-goto-node "info")
1574 (autoload 'hexl-hex-string-to-integer "hexl")
1575 (autoload 'pp "pp")
1576 (autoload 'pp-to-string "pp")
1577 (autoload 'pp-eval-expression "pp")
1578 (autoload 'mail-extract-address-components "mail-extr")
1580 (autoload 'nnmail-split-fancy "nnmail")
1581 (autoload 'nnvirtual-catchup-group "nnvirtual")
1583 ;; timezone
1584 (autoload 'timezone-make-date-arpa-standard "timezone")
1585 (autoload 'timezone-fix-time "timezone")
1586 (autoload 'timezone-make-sortable-date "timezone")
1587 (autoload 'timezone-make-time-string "timezone")
1589 ;; rmail & friends
1590 (autoload 'mail-position-on-field "sendmail")
1591 (autoload 'mail-setup "sendmail")
1592 (autoload 'rmail-output "rmailout")
1593 (autoload 'news-mail-other-window "rnewspost")
1594 (autoload 'news-reply-yank-original "rnewspost")
1595 (autoload 'news-caesar-buffer-body "rnewspost")
1596 (autoload 'rmail-insert-rmail-file-header "rmail")
1597 (autoload 'rmail-count-new-messages "rmail")
1598 (autoload 'rmail-show-message "rmail")
1600 ;; gnus-soup
1601 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1602 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1603 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1604 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1605 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1606 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1607 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1609 ;; gnus-mh
1610 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1611 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1612 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1613 (autoload 'gnus-summary-save-in-folder "gnus-mh" nil t)
1614 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1615 (autoload 'gnus-Folder-save-name "gnus-mh")
1616 (autoload 'gnus-folder-save-name "gnus-mh")
1618 ;; gnus-vis misc
1619 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1620 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1621 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1622 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1623 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1624 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1625 (autoload 'gnus-summary-highlight-line "gnus-vis")
1626 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1628 ;; gnus-vis article
1629 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1630 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1631 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1632 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1633 (autoload 'gnus-article-hide "gnus-vis" nil t)
1634 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1635 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1636 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1637 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1638 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1639 (autoload 'gnus-article-add-button "gnus-vis")
1641 ;; gnus-cite
1642 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1643 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1644 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1646 ;; gnus-kill
1647 (autoload 'gnus-kill "gnus-kill")
1648 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1649 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1650 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1651 (autoload 'gnus-execute "gnus-kill")
1652 (autoload 'gnus-expunge "gnus-kill")
1654 ;; gnus-cache
1655 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1656 (autoload 'gnus-cache-save-buffers "gnus-cache")
1657 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1658 (autoload 'gnus-cache-request-article "gnus-cache")
1659 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1660 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1661 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1662 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1664 ;; gnus-score
1665 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1666 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1667 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1668 (autoload 'gnus-score-save "gnus-score")
1669 (autoload 'gnus-score-headers "gnus-score")
1670 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1671 (autoload 'gnus-score-adaptive "gnus-score")
1672 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1673 (autoload 'gnus-score-find-trace "gnus-score")
1675 ;; gnus-edit
1676 (autoload 'gnus-score-customize "gnus-edit" nil t)
1678 ;; gnus-uu
1679 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1680 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1681 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1682 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1683 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1684 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1685 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1686 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1687 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1688 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1689 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1690 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1691 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1692 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1693 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1694 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1695 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1696 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1697 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1698 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1699 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1700 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1702 ;; gnus-msg
1703 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1704 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1705 (autoload 'gnus-group-mail "gnus-msg" nil t)
1706 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1707 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1708 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1709 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1710 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1711 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1712 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1713 (autoload 'gnus-post-news "gnus-msg" nil t)
1714 (autoload 'gnus-inews-news "gnus-msg" nil t)
1715 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1716 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1717 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1718 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1719 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1720 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1721 (autoload 'gnus-mail-yank-original "gnus-msg")
1722 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1723 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1724 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1725 (autoload 'gnus-article-mail "gnus-msg")
1726 (autoload 'gnus-bug "gnus-msg" nil t)
1728 ;; gnus-vm
1729 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1730 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1731 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1732 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1733 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1734 (autoload 'gnus-yank-article "gnus-vm" nil t)
1740 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1741 ;; If you want the cursor to go somewhere else, set these two
1742 ;; functions in some startup hook to whatever you want.
1743 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1744 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1746 ;;; Various macros and substs.
1748 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1749 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1750 (` (let ((GnusStartBufferWindow (selected-window)))
1751 (unwind-protect
1752 (progn
1753 (pop-to-buffer (, buffer))
1754 (,@ forms))
1755 (select-window GnusStartBufferWindow)))))
1757 (defmacro gnus-gethash (string hashtable)
1758 "Get hash value of STRING in HASHTABLE."
1759 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1760 ;;(` (abbrev-expansion (, string) (, hashtable)))
1761 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1763 (defmacro gnus-sethash (string value hashtable)
1764 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1765 ;; We cannot use define-abbrev since it only accepts string as value.
1766 ;; (set (intern string hashtable) value))
1767 (` (set (intern (, string) (, hashtable)) (, value))))
1769 (defsubst gnus-buffer-substring (beg end)
1770 (buffer-substring (match-beginning beg) (match-end end)))
1772 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1773 ;; function `substring' might cut on a middle of multi-octet
1774 ;; character.
1775 (defun gnus-truncate-string (str width)
1776 (substring str 0 width))
1778 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1779 ;; to limit the length of a string. This function is necessary since
1780 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1781 (defsubst gnus-limit-string (str width)
1782 (if (> (length str) width)
1783 (substring str 0 width)
1784 str))
1786 (defsubst gnus-simplify-subject-re (subject)
1787 "Remove \"Re:\" from subject lines."
1788 (let ((case-fold-search t))
1789 (if (string-match "^re: *" subject)
1790 (substring subject (match-end 0))
1791 subject)))
1793 (defsubst gnus-goto-char (point)
1794 (and point (goto-char point)))
1796 (defmacro gnus-buffer-exists-p (buffer)
1797 (` (and (, buffer)
1798 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1799 (, buffer)))))
1801 (defmacro gnus-kill-buffer (buffer)
1802 (` (if (gnus-buffer-exists-p (, buffer))
1803 (kill-buffer (, buffer)))))
1805 (defsubst gnus-point-at-bol ()
1806 "Return point at the beginning of line."
1807 (let ((p (point)))
1808 (beginning-of-line)
1809 (prog1
1810 (point)
1811 (goto-char p))))
1813 (defsubst gnus-point-at-eol ()
1814 "Return point at the beginning of line."
1815 (let ((p (point)))
1816 (end-of-line)
1817 (prog1
1818 (point)
1819 (goto-char p))))
1821 ;; Delete the current line (and the next N lines.);
1822 (defmacro gnus-delete-line (&optional n)
1823 (` (delete-region (progn (beginning-of-line) (point))
1824 (progn (forward-line (, (or n 1))) (point)))))
1826 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1827 (defvar gnus-init-inhibit nil)
1828 (defun gnus-read-init-file (&optional inhibit-next)
1829 (if gnus-init-inhibit
1830 (setq gnus-init-inhibit nil)
1831 (setq gnus-init-inhibit inhibit-next)
1832 (and gnus-init-file
1833 (or (and (file-exists-p gnus-init-file)
1834 ;; Don't try to load a directory.
1835 (not (file-directory-p gnus-init-file)))
1836 (file-exists-p (concat gnus-init-file ".el"))
1837 (file-exists-p (concat gnus-init-file ".elc")))
1838 (load gnus-init-file nil t))))
1840 ;;; Load the user startup file.
1841 ;; (eval '(gnus-read-init-file 'inhibit))
1843 ;;; Load the compatability functions.
1845 (require 'gnus-cus)
1846 (require 'gnus-ems)
1850 ;;; Gnus Utility Functions
1853 (defun gnus-extract-address-components (from)
1854 (let (name address)
1855 ;; First find the address - the thing with the @ in it. This may
1856 ;; not be accurate in mail addresses, but does the trick most of
1857 ;; the time in news messages.
1858 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1859 (setq address (substring from (match-beginning 0) (match-end 0))))
1860 ;; Then we check whether the "name <address>" format is used.
1861 (and address
1862 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1863 ;; Linear white space is not required.
1864 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
1865 (and (setq name (substring from 0 (match-beginning 0)))
1866 ;; Strip any quotes from the name.
1867 (string-match "\".*\"" name)
1868 (setq name (substring name 1 (1- (match-end 0))))))
1869 ;; If not, then "address (name)" is used.
1870 (or name
1871 (and (string-match "(.+)" from)
1872 (setq name (substring from (1+ (match-beginning 0))
1873 (1- (match-end 0)))))
1874 (and (string-match "()" from)
1875 (setq name address))
1876 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1877 ;; XOVER might not support folded From headers.
1878 (and (string-match "(.*" from)
1879 (setq name (substring from (1+ (match-beginning 0))
1880 (match-end 0)))))
1881 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1882 (list (or name from) (or address from))))
1884 (defun gnus-fetch-field (field)
1885 "Return the value of the header FIELD of current article."
1886 (save-excursion
1887 (save-restriction
1888 (let ((case-fold-search t))
1889 (gnus-narrow-to-headers)
1890 (mail-fetch-field field)))))
1892 (defun gnus-goto-colon ()
1893 (beginning-of-line)
1894 (search-forward ":" (gnus-point-at-eol) t))
1896 (defun gnus-narrow-to-headers ()
1897 (widen)
1898 (save-excursion
1899 (narrow-to-region
1900 (goto-char (point-min))
1901 (if (search-forward "\n\n" nil t)
1902 (1- (point))
1903 (point-max)))))
1905 (defvar gnus-old-specs nil)
1907 (defun gnus-update-format-specifications ()
1908 (gnus-make-thread-indent-array)
1910 (let ((formats '(summary summary-dummy group
1911 summary-mode group-mode article-mode))
1912 old-format new-format)
1913 (while formats
1914 (setq new-format (symbol-value
1915 (intern (format "gnus-%s-line-format" (car formats)))))
1916 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1917 (equal old-format new-format))
1918 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1919 (gnus-parse-format
1920 new-format
1921 (symbol-value
1922 (intern (format "gnus-%s-line-format-alist"
1923 (if (eq (car formats) 'article-mode)
1924 'summary-mode (car formats))))))))
1925 (setq gnus-old-specs (cons (cons (car formats) new-format)
1926 (delq (car formats) gnus-old-specs)))
1927 (setq formats (cdr formats))))
1929 (gnus-update-group-mark-positions)
1930 (gnus-update-summary-mark-positions)
1932 (if (and (string-match "%D" gnus-group-line-format)
1933 (not gnus-description-hashtb)
1934 gnus-read-active-file)
1935 (gnus-read-all-descriptions-files)))
1937 (defun gnus-update-summary-mark-positions ()
1938 (save-excursion
1939 (let ((gnus-replied-mark 129)
1940 (gnus-score-below-mark 130)
1941 (gnus-score-over-mark 130)
1942 (thread nil)
1943 pos)
1944 (gnus-set-work-buffer)
1945 (gnus-summary-insert-line
1946 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1947 (goto-char (point-min))
1948 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1949 (- (point) 2)))))
1950 (goto-char (point-min))
1951 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1952 (- (point) 2))) pos))
1953 (goto-char (point-min))
1954 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1955 (- (point) 2))) pos))
1956 (setq gnus-summary-mark-positions pos))))
1958 (defun gnus-update-group-mark-positions ()
1959 (save-excursion
1960 (let ((gnus-process-mark 128)
1961 (gnus-group-marked '("dummy.group")))
1962 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
1963 (gnus-set-work-buffer)
1964 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1965 (goto-char (point-min))
1966 (setq gnus-group-mark-positions
1967 (list (cons 'process (and (search-forward "\200" nil t)
1968 (- (point) 2))))))))
1970 (defun gnus-mouse-face-function (form)
1971 (` (let ((string (, form)))
1972 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1973 string)))
1975 (defun gnus-max-width-function (el max-width)
1976 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1977 (` (let* ((val (eval (, el)))
1978 (valstr (if (numberp val)
1979 (int-to-string val) val)))
1980 (if (> (length valstr) (, max-width))
1981 (substring valstr 0 (, max-width))
1982 valstr))))
1984 (defun gnus-parse-format (format spec-alist)
1985 ;; This function parses the FORMAT string with the help of the
1986 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1987 ;; string. If the FORMAT string contains the specifiers %( and %)
1988 ;; the text between them will have the mouse-face text property.
1989 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1990 (if (and gnus-visual gnus-mouse-face)
1991 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1992 (button (substring format (match-beginning 2) (match-end 2)))
1993 (post (substring format (match-beginning 3) (match-end 3))))
1994 (list 'concat
1995 (gnus-parse-simple-format pre spec-alist)
1996 (gnus-mouse-face-function
1997 (gnus-parse-simple-format button spec-alist))
1998 (gnus-parse-simple-format post spec-alist)))
1999 (gnus-parse-simple-format
2000 (concat (substring format (match-beginning 1) (match-end 1))
2001 (substring format (match-beginning 2) (match-end 2))
2002 (substring format (match-beginning 3) (match-end 3)))
2003 spec-alist))
2004 (gnus-parse-simple-format format spec-alist)))
2006 (defun gnus-parse-simple-format (format spec-alist)
2007 ;; This function parses the FORMAT string with the help of the
2008 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2009 ;; string. The list will consist of the symbol `format', a format
2010 ;; specification string, and a list of forms depending on the
2011 ;; SPEC-ALIST.
2012 (let ((max-width 0)
2013 spec flist fstring newspec elem beg)
2014 (save-excursion
2015 (gnus-set-work-buffer)
2016 (insert format)
2017 (goto-char (point-min))
2018 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?" nil t)
2019 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2020 (match-end 2))))
2021 ;; First check if there are any specs that look anything like
2022 ;; "%12,12A", ie. with a "max width specification". These have
2023 ;; to be treated specially.
2024 (if (setq beg (match-beginning 1))
2025 (setq max-width
2026 (string-to-int
2027 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2028 (setq max-width 0)
2029 (setq beg (match-beginning 2)))
2030 ;; Find the specification from `spec-alist'.
2031 (if (not (setq elem (cdr (assq spec spec-alist))))
2032 (setq elem '("*" ?s)))
2033 ;; Treat user defined format specifiers specially
2034 (and (eq (car elem) 'user-defined)
2035 (setq elem
2036 (list
2037 (list (intern (concat "gnus-user-format-function-"
2038 (buffer-substring
2039 (match-beginning 3)
2040 (match-end 3))))
2041 'header)
2042 ?s))
2043 (delete-region (match-beginning 3) (match-end 3)))
2044 (if (not (zerop max-width))
2045 (let ((el (car elem)))
2046 (cond ((= (car (cdr elem)) ?c)
2047 (setq el (list 'char-to-string el)))
2048 ((= (car (cdr elem)) ?d)
2049 (numberp el) (setq el (list 'int-to-string el))))
2050 (setq flist (cons (gnus-max-width-function el max-width)
2051 flist))
2052 (setq newspec ?s))
2053 (setq flist (cons (car elem) flist))
2054 (setq newspec (car (cdr elem))))
2055 ;; Remove the old specification (and possibly a ",12" string).
2056 (delete-region beg (match-end 2))
2057 ;; Insert the new specification.
2058 (goto-char beg)
2059 (insert newspec))
2060 (setq fstring (buffer-substring 1 (point-max))))
2061 (cons 'format (cons fstring (nreverse flist)))))
2063 (defun gnus-set-work-buffer ()
2064 (if (get-buffer gnus-work-buffer)
2065 (progn
2066 (set-buffer gnus-work-buffer)
2067 (erase-buffer))
2068 (set-buffer (get-buffer-create gnus-work-buffer))
2069 (kill-all-local-variables)
2070 (buffer-disable-undo (current-buffer))
2071 (gnus-add-current-to-buffer-list)))
2073 ;; Article file names when saving.
2075 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2076 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2077 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2078 Otherwise, it is like ~/News/news/group/num."
2079 (let ((default
2080 (expand-file-name
2081 (concat (if (gnus-use-long-file-name 'not-save)
2082 (gnus-capitalize-newsgroup newsgroup)
2083 (gnus-newsgroup-directory-form newsgroup))
2084 "/" (int-to-string (mail-header-number headers)))
2085 (or gnus-article-save-directory "~/News"))))
2086 (if (and last-file
2087 (string-equal (file-name-directory default)
2088 (file-name-directory last-file))
2089 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2090 default
2091 (or last-file default))))
2093 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2094 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2095 If variable `gnus-use-long-file-name' is non-nil, it is
2096 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2097 (let ((default
2098 (expand-file-name
2099 (concat (if (gnus-use-long-file-name 'not-save)
2100 newsgroup
2101 (gnus-newsgroup-directory-form newsgroup))
2102 "/" (int-to-string (mail-header-number headers)))
2103 (or gnus-article-save-directory "~/News"))))
2104 (if (and last-file
2105 (string-equal (file-name-directory default)
2106 (file-name-directory last-file))
2107 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2108 default
2109 (or last-file default))))
2111 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2112 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2113 If variable `gnus-use-long-file-name' is non-nil, it is
2114 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2115 (or last-file
2116 (expand-file-name
2117 (if (gnus-use-long-file-name 'not-save)
2118 (gnus-capitalize-newsgroup newsgroup)
2119 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2120 (or gnus-article-save-directory "~/News"))))
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 newsgroup
2130 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2131 (or gnus-article-save-directory "~/News"))))
2133 ;; For subscribing new newsgroup
2135 (defun gnus-subscribe-hierarchical-interactive (groups)
2136 (let ((groups (sort groups 'string<))
2137 prefixes prefix start ans group starts)
2138 (while groups
2139 (setq prefixes (list "^"))
2140 (while (and groups prefixes)
2141 (while (not (string-match (car prefixes) (car groups)))
2142 (setq prefixes (cdr prefixes)))
2143 (setq prefix (car prefixes))
2144 (setq start (1- (length prefix)))
2145 (if (and (string-match "[^\\.]\\." (car groups) start)
2146 (cdr groups)
2147 (setq prefix
2148 (concat "^" (substring (car groups) 0 (match-end 0))))
2149 (string-match prefix (car (cdr groups))))
2150 (progn
2151 (setq prefixes (cons prefix prefixes))
2152 (message "Descend hierarchy %s? ([y]nsq): "
2153 (substring prefix 1 (1- (length prefix))))
2154 (setq ans (read-char))
2155 (cond ((= ans ?n)
2156 (while (and groups
2157 (string-match prefix
2158 (setq group (car groups))))
2159 (setq gnus-killed-list
2160 (cons group gnus-killed-list))
2161 (gnus-sethash group group gnus-killed-hashtb)
2162 (setq groups (cdr groups)))
2163 (setq starts (cdr starts)))
2164 ((= ans ?s)
2165 (while (and groups
2166 (string-match prefix
2167 (setq group (car groups))))
2168 (gnus-sethash group group gnus-killed-hashtb)
2169 (gnus-subscribe-alphabetically (car groups))
2170 (setq groups (cdr groups)))
2171 (setq starts (cdr starts)))
2172 ((= ans ?q)
2173 (while groups
2174 (setq group (car groups))
2175 (setq gnus-killed-list (cons group gnus-killed-list))
2176 (gnus-sethash group group gnus-killed-hashtb)
2177 (setq groups (cdr groups))))
2178 (t nil)))
2179 (message "Subscribe %s? ([n]yq)" (car groups))
2180 (setq ans (read-char))
2181 (setq group (car groups))
2182 (cond ((= ans ?y)
2183 (gnus-subscribe-alphabetically (car groups))
2184 (gnus-sethash group group gnus-killed-hashtb))
2185 ((= ans ?q)
2186 (while groups
2187 (setq group (car groups))
2188 (setq gnus-killed-list (cons group gnus-killed-list))
2189 (gnus-sethash group group gnus-killed-hashtb)
2190 (setq groups (cdr groups))))
2192 (setq gnus-killed-list (cons group gnus-killed-list))
2193 (gnus-sethash group group gnus-killed-hashtb)))
2194 (setq groups (cdr groups)))))))
2196 (defun gnus-subscribe-randomly (newsgroup)
2197 "Subscribe new NEWSGROUP by making it the first newsgroup."
2198 (gnus-subscribe-newsgroup newsgroup))
2200 (defun gnus-subscribe-alphabetically (newgroup)
2201 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2202 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2203 (let ((groups (cdr gnus-newsrc-alist))
2204 before)
2205 (while (and (not before) groups)
2206 (if (string< newgroup (car (car groups)))
2207 (setq before (car (car groups)))
2208 (setq groups (cdr groups))))
2209 (gnus-subscribe-newsgroup newgroup before)))
2211 (defun gnus-subscribe-hierarchically (newgroup)
2212 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2213 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2214 (save-excursion
2215 (set-buffer (find-file-noselect gnus-current-startup-file))
2216 (let ((groupkey newgroup)
2217 before)
2218 (while (and (not before) groupkey)
2219 (goto-char (point-min))
2220 (let ((groupkey-re
2221 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2222 (while (and (re-search-forward groupkey-re nil t)
2223 (progn
2224 (setq before (buffer-substring
2225 (match-beginning 1) (match-end 1)))
2226 (string< before newgroup)))))
2227 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2228 (setq groupkey
2229 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2230 (substring groupkey (match-beginning 1) (match-end 1)))))
2231 (gnus-subscribe-newsgroup newgroup before))))
2233 (defun gnus-subscribe-interactively (newsgroup)
2234 "Subscribe new NEWSGROUP interactively.
2235 It is inserted in hierarchical newsgroup order if subscribed. If not,
2236 it is killed."
2237 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2238 (gnus-subscribe-hierarchically newsgroup)
2239 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2241 (defun gnus-subscribe-zombies (newsgroup)
2242 "Make new NEWSGROUP a zombie group."
2243 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2245 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2246 "Subscribe new NEWSGROUP.
2247 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2248 the first newsgroup."
2249 ;; We subscribe the group by changing its level to `subscribed'.
2250 (gnus-group-change-level
2251 newsgroup gnus-level-default-subscribed
2252 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2253 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2255 ;; For directories
2257 (defun gnus-newsgroup-directory-form (newsgroup)
2258 "Make hierarchical directory name from NEWSGROUP name."
2259 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2260 (len (length newsgroup))
2261 idx)
2262 ;; If this is a foreign group, we don't want to translate the
2263 ;; entire name.
2264 (if (setq idx (string-match ":" newsgroup))
2265 (aset newsgroup idx ?/)
2266 (setq idx 0))
2267 ;; Replace all occurrences of `.' with `/'.
2268 (while (< idx len)
2269 (if (= (aref newsgroup idx) ?.)
2270 (aset newsgroup idx ?/))
2271 (setq idx (1+ idx)))
2272 newsgroup))
2274 (defun gnus-newsgroup-saveable-name (group)
2275 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2276 ;; with dots.
2277 (gnus-replace-chars-in-string group ?/ ?.))
2279 (defun gnus-make-directory (dir)
2280 "Make DIRECTORY recursively."
2281 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2282 ;; of the many mysteries of the universe.
2283 (let* ((dir (expand-file-name dir default-directory))
2284 dirs err)
2285 (if (string-match "/$" dir)
2286 (setq dir (substring dir 0 (match-beginning 0))))
2287 ;; First go down the path until we find a directory that exists.
2288 (while (not (file-exists-p dir))
2289 (setq dirs (cons dir dirs))
2290 (string-match "/[^/]+$" dir)
2291 (setq dir (substring dir 0 (match-beginning 0))))
2292 ;; Then create all the subdirs.
2293 (while (and dirs (not err))
2294 (condition-case ()
2295 (make-directory (car dirs))
2296 (error (setq err t)))
2297 (setq dirs (cdr dirs)))
2298 ;; We return whether we were successful or not.
2299 (not dirs)))
2301 (defun gnus-capitalize-newsgroup (newsgroup)
2302 "Capitalize NEWSGROUP name."
2303 (and (not (zerop (length newsgroup)))
2304 (concat (char-to-string (upcase (aref newsgroup 0)))
2305 (substring newsgroup 1))))
2307 ;; Var
2309 (defun gnus-simplify-subject (subject &optional re-only)
2310 "Remove `Re:' and words in parentheses.
2311 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2312 (let ((case-fold-search t)) ;Ignore case.
2313 ;; Remove `Re:' and `Re^N:'.
2314 (if (string-match "^re:[ \t]*" subject)
2315 (setq subject (substring subject (match-end 0))))
2316 ;; Remove words in parentheses from end.
2317 (or re-only
2318 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2319 (setq subject (substring subject 0 (match-beginning 0)))))
2320 ;; Return subject string.
2321 subject))
2323 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2324 ;; all whitespace.
2325 (defun gnus-simplify-subject-fuzzy (subject)
2326 (let ((case-fold-search t))
2327 (save-excursion
2328 (gnus-set-work-buffer)
2329 (insert subject)
2330 (inline (gnus-simplify-buffer-fuzzy))
2331 (buffer-string))))
2333 (defun gnus-simplify-buffer-fuzzy ()
2334 (goto-char (point-min))
2335 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2336 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2337 nil t)
2338 (replace-match "" t t))
2339 (goto-char (point-min))
2340 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2341 (replace-match "" t t))
2342 (goto-char (point-min))
2343 (while (re-search-forward "[ \t]+" nil t)
2344 (replace-match " " t t))
2345 (goto-char (point-min))
2346 (while (re-search-forward "[ \t]+$" nil t)
2347 (replace-match "" t t))
2348 (goto-char (point-min))
2349 (while (re-search-forward "^[ \t]+" nil t)
2350 (replace-match "" t t))
2351 (if gnus-simplify-subject-fuzzy-regexp
2352 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2353 (replace-match "" t t))))
2355 ;; Add the current buffer to the list of buffers to be killed on exit.
2356 (defun gnus-add-current-to-buffer-list ()
2357 (or (memq (current-buffer) gnus-buffer-list)
2358 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2360 (defun gnus-string> (s1 s2)
2361 (not (or (string< s1 s2)
2362 (string= s1 s2))))
2364 ;; Functions accessing headers.
2365 ;; Functions are more convenient than macros in some cases.
2367 (defun gnus-header-number (header)
2368 (mail-header-number header))
2370 (defun gnus-header-subject (header)
2371 (mail-header-subject header))
2373 (defun gnus-header-from (header)
2374 (mail-header-from header))
2376 (defun gnus-header-xref (header)
2377 (mail-header-xref header))
2379 (defun gnus-header-lines (header)
2380 (mail-header-lines header))
2382 (defun gnus-header-date (header)
2383 (mail-header-date header))
2385 (defun gnus-header-id (header)
2386 (mail-header-id header))
2388 (defun gnus-header-message-id (header)
2389 (mail-header-id header))
2391 (defun gnus-header-chars (header)
2392 (mail-header-chars header))
2394 (defun gnus-header-references (header)
2395 (mail-header-references header))
2397 ;;; General various misc type functions.
2399 (defun gnus-clear-system ()
2400 "Clear all variables and buffers."
2401 ;; Clear Gnus variables.
2402 (let ((variables gnus-variable-list))
2403 (while variables
2404 (set (car variables) nil)
2405 (setq variables (cdr variables))))
2406 ;; Clear other internal variables.
2407 (setq gnus-list-of-killed-groups nil
2408 gnus-have-read-active-file nil
2409 gnus-newsrc-alist nil
2410 gnus-newsrc-hashtb nil
2411 gnus-killed-list nil
2412 gnus-zombie-list nil
2413 gnus-killed-hashtb nil
2414 gnus-active-hashtb nil
2415 gnus-moderated-list nil
2416 gnus-description-hashtb nil
2417 gnus-newsgroup-headers nil
2418 gnus-newsgroup-headers-hashtb-by-number nil
2419 gnus-newsgroup-name nil
2420 gnus-server-alist nil
2421 gnus-current-select-method nil)
2422 ;; Reset any score variables.
2423 (and (boundp 'gnus-score-cache)
2424 (set 'gnus-score-cache nil))
2425 (and (boundp 'gnus-internal-global-score-files)
2426 (set 'gnus-internal-global-score-files nil))
2427 ;; Kill the startup file.
2428 (and gnus-current-startup-file
2429 (get-file-buffer gnus-current-startup-file)
2430 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2431 ;; Save any cache buffers.
2432 (and gnus-use-cache (gnus-cache-save-buffers))
2433 ;; Clear the dribble buffer.
2434 (gnus-dribble-clear)
2435 ;; Kill global KILL file buffer.
2436 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2437 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2438 (gnus-kill-buffer nntp-server-buffer)
2439 ;; Kill Gnus buffers.
2440 (while gnus-buffer-list
2441 (gnus-kill-buffer (car gnus-buffer-list))
2442 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2444 (defun gnus-windows-old-to-new (setting)
2445 ;; First we take care of the really, really old Gnus 3 actions.
2446 (if (symbolp setting)
2447 (setq setting
2448 (cond ((memq setting '(SelectArticle))
2449 'article)
2450 ((memq setting '(SelectSubject ExpandSubject))
2451 'summary)
2452 ((memq setting '(SelectNewsgroup ExitNewsgroup))
2453 'group)
2454 (t setting))))
2455 (if (or (listp setting)
2456 (not (and gnus-window-configuration
2457 (memq setting '(group summary article)))))
2458 setting
2459 (let* ((setting (if (eq setting 'group)
2460 (if (assq 'newsgroup gnus-window-configuration)
2461 'newsgroup
2462 'newsgroups) setting))
2463 (elem (car (cdr (assq setting gnus-window-configuration))))
2464 (total (apply '+ elem))
2465 (types '(group summary article))
2466 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2467 (i 0)
2468 perc
2469 out)
2470 (while (< i 3)
2471 (or (not (numberp (nth i elem)))
2472 (zerop (nth i elem))
2473 (progn
2474 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2475 (setq out (cons (if (eq pbuf (nth i types))
2476 (vector (nth i types) perc 'point)
2477 (vector (nth i types) perc))
2478 out))))
2479 (setq i (1+ i)))
2480 (list (nreverse out)))))
2482 (defun gnus-add-configuration (conf)
2483 (setq gnus-buffer-configuration
2484 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2485 gnus-buffer-configuration))))
2487 (defun gnus-configure-windows (setting &optional force)
2488 (setq setting (gnus-windows-old-to-new setting))
2489 (let ((r (if (symbolp setting)
2490 (cdr (assq setting gnus-buffer-configuration))
2491 setting))
2492 (in-buf (current-buffer))
2493 rule val w height hor ohor heights sub jump-buffer
2494 rel total to-buf all-visible)
2495 (or r (error "No such setting: %s" setting))
2497 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2498 ;; All the windows mentioned are already visible, so we just
2499 ;; put point in the assigned buffer, and do not touch the
2500 ;; winconf.
2501 (select-window (get-buffer-window all-visible t))
2504 ;; Either remove all windows or just remove all Gnus windows.
2505 (if gnus-use-full-window
2506 (delete-other-windows)
2507 (gnus-remove-some-windows)
2508 (switch-to-buffer nntp-server-buffer))
2510 (while r
2511 (setq hor (car r)
2512 ohor nil)
2514 ;; We have to do the (possible) horizontal splitting before the
2515 ;; vertical.
2516 (if (and (listp (car hor))
2517 (eq (car (car hor)) 'horizontal))
2518 (progn
2519 (split-window
2521 (if (integerp (nth 1 (car hor)))
2522 (nth 1 (car hor))
2523 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2525 (setq hor (cdr hor))))
2527 ;; Go through the rules and eval the elements that are to be
2528 ;; evaled.
2529 (while hor
2530 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2531 (progn
2532 ;; Expand short buffer name.
2533 (setq w (aref val 0))
2534 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2535 (progn
2536 (setq val (apply 'vector (mapcar 'identity val)))
2537 (aset val 0 w)))
2538 (setq ohor (cons val ohor))))
2539 (setq hor (cdr hor)))
2540 (setq rule (cons (nreverse ohor) rule))
2541 (setq r (cdr r)))
2542 (setq rule (nreverse rule))
2544 ;; We tally the window sizes.
2545 (setq total (window-height))
2546 (while rule
2547 (setq hor (car rule))
2548 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2549 (setq hor (cdr hor)))
2550 (setq sub 0)
2551 (while hor
2552 (setq rel (aref (car hor) 1)
2553 heights (cons
2554 (cond ((and (floatp rel) (= 1.0 rel))
2556 ((integerp rel)
2557 rel)
2559 (max (floor (* total rel)) 4)))
2560 heights)
2561 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2562 hor (cdr hor)))
2563 (setq heights (nreverse heights)
2564 hor (car rule))
2566 ;; We then go through these heighs and create windows for them.
2567 (while heights
2568 (setq height (car heights)
2569 heights (cdr heights))
2570 (and (eq height 'x)
2571 (setq height (- total sub)))
2572 (and heights
2573 (split-window nil height))
2574 (setq to-buf (aref (car hor) 0))
2575 (switch-to-buffer
2576 (cond ((not to-buf)
2577 in-buf)
2578 ((symbolp to-buf)
2579 (symbol-value (aref (car hor) 0)))
2581 (aref (car hor) 0))))
2582 (and (> (length (car hor)) 2)
2583 (eq (aref (car hor) 2) 'point)
2584 (setq jump-buffer (current-buffer)))
2585 (other-window 1)
2586 (setq hor (cdr hor)))
2588 (setq rule (cdr rule)))
2590 ;; Finally, we pop to the buffer that's supposed to have point.
2591 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2593 (select-window (get-buffer-window jump-buffer t))
2594 (set-buffer jump-buffer))))
2596 (defun gnus-all-windows-visible-p (rule)
2597 (let (invisible hor jump-buffer val buffer)
2598 ;; Go through the rules and eval the elements that are to be
2599 ;; evaled.
2600 (while (and rule (not invisible))
2601 (setq hor (car rule)
2602 rule (cdr rule))
2603 (while (and hor (not invisible))
2604 (if (setq val (if (vectorp (car hor))
2605 (car hor)
2606 (if (not (eq (car (car hor)) 'horizontal))
2607 (eval (car hor)))))
2608 (progn
2609 ;; Expand short buffer name.
2610 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2611 (aref val 0)))
2612 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2613 buffer))
2614 (and (> (length val) 2) (eq 'point (aref val 2))
2615 (setq jump-buffer buffer))
2616 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2617 (setq hor (cdr hor))))
2618 (and (not invisible) jump-buffer)))
2620 (defun gnus-window-top-edge (&optional window)
2621 (nth 1 (window-edges window)))
2623 (defun gnus-remove-some-windows ()
2624 (let ((buffers gnus-window-to-buffer)
2625 buf bufs lowest-buf lowest)
2626 (save-excursion
2627 ;; Remove windows on all known Gnus buffers.
2628 (while buffers
2629 (setq buf (cdr (car buffers)))
2630 (if (symbolp buf)
2631 (setq buf (and (boundp buf) (symbol-value buf))))
2632 (and buf
2633 (get-buffer-window buf)
2634 (progn
2635 (setq bufs (cons buf bufs))
2636 (pop-to-buffer buf)
2637 (if (or (not lowest)
2638 (< (gnus-window-top-edge) lowest))
2639 (progn
2640 (setq lowest (gnus-window-top-edge))
2641 (setq lowest-buf buf)))))
2642 (setq buffers (cdr buffers)))
2643 ;; Remove windows on *all* summary buffers.
2644 (let (wins)
2645 (walk-windows
2646 (lambda (win)
2647 (let ((buf (window-buffer win)))
2648 (if (string-match "^\\*Summary" (buffer-name buf))
2649 (progn
2650 (setq bufs (cons buf bufs))
2651 (pop-to-buffer buf)
2652 (if (or (not lowest)
2653 (< (gnus-window-top-edge) lowest))
2654 (progn
2655 (setq lowest-buf buf)
2656 (setq lowest (gnus-window-top-edge))))))))))
2657 (and lowest-buf
2658 (progn
2659 (pop-to-buffer lowest-buf)
2660 (switch-to-buffer nntp-server-buffer)))
2661 (while bufs
2662 (and (not (eq (car bufs) lowest-buf))
2663 (delete-windows-on (car bufs)))
2664 (setq bufs (cdr bufs))))))
2666 (defun gnus-version ()
2667 "Version numbers of this version of Gnus."
2668 (interactive)
2669 (let ((methods gnus-valid-select-methods)
2670 (mess gnus-version)
2671 meth)
2672 ;; Go through all the legal select methods and add their version
2673 ;; numbers to the total version string. Only the backends that are
2674 ;; currently in use will have their message numbers taken into
2675 ;; consideration.
2676 (while methods
2677 (setq meth (intern (concat (car (car methods)) "-version")))
2678 (and (boundp meth)
2679 (stringp (symbol-value meth))
2680 (setq mess (concat mess "; " (symbol-value meth))))
2681 (setq methods (cdr methods)))
2682 (gnus-message 2 mess)))
2684 (defun gnus-info-find-node ()
2685 "Find Info documentation of Gnus."
2686 (interactive)
2687 ;; Enlarge info window if needed.
2688 (let ((mode major-mode))
2689 (gnus-configure-windows 'info)
2690 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2692 (defun gnus-overload-functions (&optional overloads)
2693 "Overload functions specified by optional argument OVERLOADS.
2694 If nothing is specified, use the variable gnus-overload-functions."
2695 (let ((defs nil)
2696 (overloads (or overloads gnus-overload-functions)))
2697 (while overloads
2698 (setq defs (car overloads))
2699 (setq overloads (cdr overloads))
2700 ;; Load file before overloading function if necessary. Make
2701 ;; sure we cannot use `require' always.
2702 (and (not (fboundp (car defs)))
2703 (car (cdr (cdr defs)))
2704 (load (car (cdr (cdr defs))) nil 'nomessage))
2705 (fset (car defs) (car (cdr defs))))))
2707 (defun gnus-replace-chars-in-string (string &rest pairs)
2708 "Replace characters in STRING from FROM to TO."
2709 (let ((string (substring string 0)) ;Copy string.
2710 (len (length string))
2711 (idx 0)
2712 sym to)
2713 (or (zerop (% (length pairs) 2))
2714 (error "Odd number of translation pairs"))
2715 (setplist 'sym pairs)
2716 ;; Replace all occurrences of FROM with TO.
2717 (while (< idx len)
2718 (if (setq to (get 'sym (aref string idx)))
2719 (aset string idx to))
2720 (setq idx (1+ idx)))
2721 string))
2723 (defun gnus-days-between (date1 date2)
2724 ;; Return the number of days between date1 and date2.
2725 (- (gnus-day-number date1) (gnus-day-number date2)))
2727 (defun gnus-day-number (date)
2728 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2729 (timezone-parse-date date))))
2730 (timezone-absolute-from-gregorian
2731 (nth 1 dat) (nth 2 dat) (car dat))))
2733 ;; Returns a floating point number that says how many seconds have
2734 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2735 (defun gnus-seconds-since-epoch (date)
2736 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2737 (timezone-parse-date date)))
2738 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2739 (timezone-parse-time
2740 (aref (timezone-parse-date date) 3))))
2741 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2742 (timezone-parse-date "Jan 1 12:00:00 1970")))
2743 (tday (- (timezone-absolute-from-gregorian
2744 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2745 (timezone-absolute-from-gregorian
2746 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2747 (+ (nth 2 ttime)
2748 (* (nth 1 ttime) 60)
2749 (* 1.0 (nth 0 ttime) 60 60)
2750 (* 1.0 tday 60 60 24))))
2752 (defun gnus-file-newer-than (file date)
2753 (let ((fdate (nth 5 (file-attributes file))))
2754 (or (> (car fdate) (car date))
2755 (and (= (car fdate) (car date))
2756 (> (nth 1 fdate) (nth 1 date))))))
2758 (defun gnus-group-read-only-p (&optional group)
2759 "Check whether GROUP supports editing or not.
2760 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
2761 that that variable is buffer-local to the summary buffers."
2762 (let ((group (or group gnus-newsgroup-name)))
2763 (not (gnus-check-backend-function 'request-replace-article group))))
2765 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2766 ;; the echo area.
2767 (defun gnus-y-or-n-p (prompt)
2768 (prog1
2769 (y-or-n-p prompt)
2770 (message "")))
2772 (defun gnus-yes-or-no-p (prompt)
2773 (prog1
2774 (yes-or-no-p prompt)
2775 (message "")))
2777 ;; Check whether to use long file names.
2778 (defun gnus-use-long-file-name (symbol)
2779 ;; The variable has to be set...
2780 (and gnus-use-long-file-name
2781 ;; If it isn't a list, then we return t.
2782 (or (not (listp gnus-use-long-file-name))
2783 ;; If it is a list, and the list contains `symbol', we
2784 ;; return nil.
2785 (not (memq symbol gnus-use-long-file-name)))))
2787 ;; I suspect there's a better way, but I haven't taken the time to do
2788 ;; it yet. -erik selberg@cs.washington.edu
2789 (defun gnus-dd-mmm (messy-date)
2790 "Return a string like DD-MMM from a big messy string"
2791 (let ((datevec (timezone-parse-date messy-date)))
2792 (format "%2s-%s"
2793 (or (aref datevec 2) "??")
2794 (capitalize
2795 (or (car
2796 (nth (1- (string-to-number (aref datevec 1)))
2797 timezone-months-assoc))
2798 "???")))))
2800 ;; Make a hash table (default and minimum size is 255).
2801 ;; Optional argument HASHSIZE specifies the table size.
2802 (defun gnus-make-hashtable (&optional hashsize)
2803 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2805 ;; Make a number that is suitable for hashing; bigger than MIN and one
2806 ;; less than 2^x.
2807 (defun gnus-create-hash-size (min)
2808 (let ((i 1))
2809 (while (< i min)
2810 (setq i (* 2 i)))
2811 (1- i)))
2813 ;; Show message if message has a lower level than `gnus-verbose'.
2814 ;; Guide-line for numbers:
2815 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2816 ;; for things that take a long time, 7 - not very important messages
2817 ;; on stuff, 9 - messages inside loops.
2818 (defun gnus-message (level &rest args)
2819 (if (<= level gnus-verbose)
2820 (apply 'message args)
2821 ;; We have to do this format thingie here even if the result isn't
2822 ;; shown - the return value has to be the same as the return value
2823 ;; from `message'.
2824 (apply 'format args)))
2826 ;; Generate a unique new group name.
2827 (defun gnus-generate-new-group-name (leaf)
2828 (let ((name leaf)
2829 (num 0))
2830 (while (gnus-gethash name gnus-newsrc-hashtb)
2831 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2832 name))
2834 (defun gnus-ephemeral-group-p (group)
2835 "Say whether GROUP is ephemeral or not."
2836 (assoc 'quit-config (gnus-find-method-for-group group)))
2838 (defun gnus-group-quit-config (group)
2839 "Return the quit-config of GROUP."
2840 (nth 1 (assoc 'quit-config (gnus-find-method-for-group group))))
2842 ;;; List and range functions
2844 (defun gnus-last-element (list)
2845 "Return last element of LIST."
2846 (while (cdr list)
2847 (setq list (cdr list)))
2848 (car list))
2850 (defun gnus-copy-sequence (list)
2851 "Do a complete, total copy of a list."
2852 (if (and (consp list) (not (consp (cdr list))))
2853 (cons (car list) (cdr list))
2854 (mapcar (lambda (elem) (if (consp elem)
2855 (if (consp (cdr elem))
2856 (gnus-copy-sequence elem)
2857 (cons (car elem) (cdr elem)))
2858 elem))
2859 list)))
2861 (defun gnus-set-difference (list1 list2)
2862 "Return a list of elements of LIST1 that do not appear in LIST2."
2863 (let ((list1 (copy-sequence list1)))
2864 (while list2
2865 (setq list1 (delq (car list2) list1))
2866 (setq list2 (cdr list2)))
2867 list1))
2869 (defun gnus-sorted-complement (list1 list2)
2870 "Return a list of elements of LIST1 that do not appear in LIST2.
2871 Both lists have to be sorted over <."
2872 (let (out)
2873 (if (or (null list1) (null list2))
2874 (or list1 list2)
2875 (while (and list1 list2)
2876 (cond ((= (car list1) (car list2))
2877 (setq list1 (cdr list1)
2878 list2 (cdr list2)))
2879 ((< (car list1) (car list2))
2880 (setq out (cons (car list1) out))
2881 (setq list1 (cdr list1)))
2883 (setq out (cons (car list2) out))
2884 (setq list2 (cdr list2)))))
2885 (nconc (nreverse out) (or list1 list2)))))
2887 (defun gnus-intersection (list1 list2)
2888 (let ((result nil))
2889 (while list2
2890 (if (memq (car list2) list1)
2891 (setq result (cons (car list2) result)))
2892 (setq list2 (cdr list2)))
2893 result))
2895 (defun gnus-sorted-intersection (list1 list2)
2896 ;; LIST1 and LIST2 have to be sorted over <.
2897 (let (out)
2898 (while (and list1 list2)
2899 (cond ((= (car list1) (car list2))
2900 (setq out (cons (car list1) out)
2901 list1 (cdr list1)
2902 list2 (cdr list2)))
2903 ((< (car list1) (car list2))
2904 (setq list1 (cdr list1)))
2906 (setq list2 (cdr list2)))))
2907 (nreverse out)))
2909 (defun gnus-set-sorted-intersection (list1 list2)
2910 ;; LIST1 and LIST2 have to be sorted over <.
2911 ;; This function modifies LIST1.
2912 (let* ((top (cons nil list1))
2913 (prev top))
2914 (while (and list1 list2)
2915 (cond ((= (car list1) (car list2))
2916 (setq prev list1
2917 list1 (cdr list1)
2918 list2 (cdr list2)))
2919 ((< (car list1) (car list2))
2920 (setcdr prev (cdr list1))
2921 (setq list1 (cdr list1)))
2923 (setq list2 (cdr list2)))))
2924 (setcdr prev nil)
2925 (cdr top)))
2927 (defun gnus-compress-sequence (numbers &optional always-list)
2928 "Convert list of numbers to a list of ranges or a single range.
2929 If ALWAYS-LIST is non-nil, this function will always release a list of
2930 ranges."
2931 (let* ((first (car numbers))
2932 (last (car numbers))
2933 result)
2934 (if (null numbers)
2936 (if (not (listp (cdr numbers)))
2937 numbers
2938 (while numbers
2939 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2940 ((= (1+ last) (car numbers)) ;Still in sequence
2941 (setq last (car numbers)))
2942 (t ;End of one sequence
2943 (setq result
2944 (cons (if (= first last) first
2945 (cons first last)) result))
2946 (setq first (car numbers))
2947 (setq last (car numbers))))
2948 (setq numbers (cdr numbers)))
2949 (if (and (not always-list) (null result))
2950 (if (= first last) (list first) (cons first last))
2951 (nreverse (cons (if (= first last) first (cons first last))
2952 result)))))))
2954 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2955 (defun gnus-uncompress-range (ranges)
2956 "Expand a list of ranges into a list of numbers.
2957 RANGES is either a single range on the form `(num . num)' or a list of
2958 these ranges."
2959 (let (first last result)
2960 (cond
2961 ((null ranges)
2962 nil)
2963 ((not (listp (cdr ranges)))
2964 (setq first (car ranges))
2965 (setq last (cdr ranges))
2966 (while (<= first last)
2967 (setq result (cons first result))
2968 (setq first (1+ first)))
2969 (nreverse result))
2971 (while ranges
2972 (if (atom (car ranges))
2973 (if (numberp (car ranges))
2974 (setq result (cons (car ranges) result)))
2975 (setq first (car (car ranges)))
2976 (setq last (cdr (car ranges)))
2977 (while (<= first last)
2978 (setq result (cons first result))
2979 (setq first (1+ first))))
2980 (setq ranges (cdr ranges)))
2981 (nreverse result)))))
2983 (defun gnus-add-to-range (ranges list)
2984 "Return a list of ranges that has all articles from both RANGES and LIST.
2985 Note: LIST has to be sorted over `<'."
2986 (if (not ranges)
2987 (gnus-compress-sequence list t)
2988 (setq list (copy-sequence list))
2989 (or (listp (cdr ranges))
2990 (setq ranges (list ranges)))
2991 (let ((out ranges)
2992 ilist lowest highest temp)
2993 (while (and ranges list)
2994 (setq ilist list)
2995 (setq lowest (or (and (atom (car ranges)) (car ranges))
2996 (car (car ranges))))
2997 (while (and list (cdr list) (< (car (cdr list)) lowest))
2998 (setq list (cdr list)))
2999 (if (< (car ilist) lowest)
3000 (progn
3001 (setq temp list)
3002 (setq list (cdr list))
3003 (setcdr temp nil)
3004 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3005 (setq highest (or (and (atom (car ranges)) (car ranges))
3006 (cdr (car ranges))))
3007 (while (and list (<= (car list) highest))
3008 (setq list (cdr list)))
3009 (setq ranges (cdr ranges)))
3010 (if list
3011 (setq out (nconc (gnus-compress-sequence list t) out)))
3012 (setq out (sort out (lambda (r1 r2)
3013 (< (or (and (atom r1) r1) (car r1))
3014 (or (and (atom r2) r2) (car r2))))))
3015 (setq ranges out)
3016 (while ranges
3017 (if (atom (car ranges))
3018 (if (cdr ranges)
3019 (if (atom (car (cdr ranges)))
3020 (if (= (1+ (car ranges)) (car (cdr ranges)))
3021 (progn
3022 (setcar ranges (cons (car ranges)
3023 (car (cdr ranges))))
3024 (setcdr ranges (cdr (cdr ranges)))))
3025 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3026 (progn
3027 (setcar (car (cdr ranges)) (car ranges))
3028 (setcar ranges (car (cdr ranges)))
3029 (setcdr ranges (cdr (cdr ranges)))))))
3030 (if (cdr ranges)
3031 (if (atom (car (cdr ranges)))
3032 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3033 (progn
3034 (setcdr (car ranges) (car (cdr ranges)))
3035 (setcdr ranges (cdr (cdr ranges)))))
3036 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3037 (progn
3038 (setcdr (car ranges) (cdr (car (cdr ranges))))
3039 (setcdr ranges (cdr (cdr ranges))))))))
3040 (setq ranges (cdr ranges)))
3041 out)))
3043 (defun gnus-remove-from-range (ranges list)
3044 "Return a list of ranges that has all articles from LIST removed from RANGES.
3045 Note: LIST has to be sorted over `<'."
3046 ;; !!! This function shouldn't look like this, but I've got a headache.
3047 (gnus-compress-sequence
3048 (gnus-sorted-complement
3049 (gnus-uncompress-range ranges) list)))
3051 (defun gnus-member-of-range (number ranges)
3052 (if (not (listp (cdr ranges)))
3053 (and (>= number (car ranges))
3054 (<= number (cdr ranges)))
3055 (let ((not-stop t))
3056 (while (and ranges
3057 (if (numberp (car ranges))
3058 (>= number (car ranges))
3059 (>= number (car (car ranges))))
3060 not-stop)
3061 (if (if (numberp (car ranges))
3062 (= number (car ranges))
3063 (and (>= number (car (car ranges)))
3064 (<= number (cdr (car ranges)))))
3065 (setq not-stop nil))
3066 (setq ranges (cdr ranges)))
3067 (not not-stop))))
3071 ;;; Gnus group mode
3074 (defvar gnus-group-mode-map nil)
3075 (defvar gnus-group-group-map nil)
3076 (defvar gnus-group-mark-map nil)
3077 (defvar gnus-group-list-map nil)
3078 (defvar gnus-group-sub-map nil)
3079 (put 'gnus-group-mode 'mode-class 'special)
3081 (if gnus-group-mode-map
3083 (setq gnus-group-mode-map (make-keymap))
3084 (suppress-keymap gnus-group-mode-map)
3085 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3086 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3087 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3088 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3089 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3090 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3091 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3092 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3093 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3094 (define-key gnus-group-mode-map
3095 "\M-n" 'gnus-group-next-unread-group-same-level)
3096 (define-key gnus-group-mode-map
3097 "\M-p" 'gnus-group-prev-unread-group-same-level)
3098 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3099 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3100 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3101 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3102 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3103 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3104 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3105 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3106 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3107 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3108 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3109 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3110 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3111 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3112 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3113 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3114 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3115 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3116 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3117 (define-key gnus-group-mode-map "\C-c\M-\C-a" 'gnus-group-description-apropos)
3118 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3119 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3120 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3121 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3122 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3123 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3124 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3125 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3126 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3127 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3128 (define-key gnus-group-mode-map "V" 'gnus-version)
3129 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3130 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3131 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3132 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3133 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3134 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3135 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3136 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3137 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3138 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3139 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3140 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3141 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3142 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3143 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3145 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3146 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3147 (define-prefix-command 'gnus-group-mark-map)
3148 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3149 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3150 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3151 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3153 (define-prefix-command 'gnus-group-group-map)
3154 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3155 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3156 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3157 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3158 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3159 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3160 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3161 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3162 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3163 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3164 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3165 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3166 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3167 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3168 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3169 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3170 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3171 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3173 (define-prefix-command 'gnus-group-list-map)
3174 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3175 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3176 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3177 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3178 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3179 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3180 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3181 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3182 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3184 (define-prefix-command 'gnus-group-sub-map)
3185 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3186 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3187 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3188 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3189 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3190 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3191 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3192 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3194 (defun gnus-group-mode ()
3195 "Major mode for reading news.
3197 All normal editing commands are switched off.
3198 \\<gnus-group-mode-map>
3199 The group buffer lists (some of) the groups available. For instance,
3200 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3201 lists all zombie groups.
3203 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3204 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3206 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3208 The following commands are available:
3210 \\{gnus-group-mode-map}"
3211 (interactive)
3212 (if gnus-visual (gnus-group-make-menu-bar))
3213 (kill-all-local-variables)
3214 (setq mode-line-modified "-- ")
3215 (make-local-variable 'mode-line-format)
3216 (setq mode-line-format (copy-sequence mode-line-format))
3217 (and (equal (nth 3 mode-line-format) " ")
3218 (setcar (nthcdr 3 mode-line-format) ""))
3219 (setq major-mode 'gnus-group-mode)
3220 (setq mode-name "Group")
3221 (gnus-group-set-mode-line)
3222 (setq mode-line-process nil)
3223 (use-local-map gnus-group-mode-map)
3224 (buffer-disable-undo (current-buffer))
3225 (setq truncate-lines t)
3226 (setq buffer-read-only t)
3227 (run-hooks 'gnus-group-mode-hook))
3229 (defun gnus-mouse-pick-group (e)
3230 (interactive "e")
3231 (mouse-set-point e)
3232 (gnus-group-read-group nil))
3234 ;; Look at LEVEL and find out what the level is really supposed to be.
3235 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3236 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3237 (defun gnus-group-default-level (&optional level number-or-nil)
3238 (cond
3239 (gnus-group-use-permanent-levels
3240 (setq gnus-group-default-list-level
3241 (or level gnus-group-default-list-level))
3242 (or gnus-group-default-list-level gnus-level-subscribed))
3243 (number-or-nil
3244 level)
3246 (or level gnus-group-default-list-level gnus-level-subscribed))))
3249 (defvar gnus-tmp-prev-perm nil)
3251 ;;;###autoload
3252 (defun gnus-no-server (&optional arg)
3253 "Read network news.
3254 If ARG is a positive number, Gnus will use that as the
3255 startup level. If ARG is nil, Gnus will be started at level 2.
3256 If ARG is non-nil and not a positive number, Gnus will
3257 prompt the user for the name of an NNTP server to use.
3258 As opposed to `gnus', this command will not connect to the local server."
3259 (interactive "P")
3260 (let ((perm
3261 (cons gnus-group-use-permanent-levels gnus-group-default-list-level)))
3262 (setq gnus-tmp-prev-perm nil)
3263 (setq gnus-group-use-permanent-levels t)
3264 (gnus (or arg (1- gnus-level-default-subscribed)) t)
3265 (setq gnus-tmp-prev-perm perm)))
3267 ;;;###autoload
3268 (defun gnus (&optional arg dont-connect)
3269 "Read network news.
3270 If ARG is non-nil and a positive number, Gnus will use that as the
3271 startup level. If ARG is non-nil and not a positive number, Gnus will
3272 prompt the user for the name of an NNTP server to use."
3273 (interactive "P")
3274 (if (get-buffer gnus-group-buffer)
3275 (progn
3276 (switch-to-buffer gnus-group-buffer)
3277 (gnus-group-get-new-news))
3279 (gnus-clear-system)
3281 (nnheader-init-server-buffer)
3282 ;; We do this if `gnus-no-server' has been run.
3283 (if gnus-tmp-prev-perm
3284 (setq gnus-group-use-permanent-levels (car gnus-tmp-prev-perm)
3285 gnus-group-default-list-level (cdr gnus-tmp-prev-perm)
3286 gnus-tmp-prev-perm nil))
3287 (gnus-read-init-file)
3289 (gnus-group-setup-buffer)
3290 (let ((buffer-read-only nil))
3291 (erase-buffer)
3292 (if (not gnus-inhibit-startup-message)
3293 (progn
3294 (gnus-group-startup-message)
3295 (sit-for 0))))
3297 (let ((level (and arg (numberp arg) (> arg 0) arg))
3298 did-connect)
3299 (unwind-protect
3300 (progn
3301 (or dont-connect
3302 (setq did-connect
3303 (gnus-start-news-server (and arg (not level))))))
3304 (if (and (not dont-connect)
3305 (not did-connect))
3306 (gnus-group-quit)
3307 (run-hooks 'gnus-startup-hook)
3308 ;; NNTP server is successfully open.
3310 ;; Find the current startup file name.
3311 (setq gnus-current-startup-file
3312 (gnus-make-newsrc-file gnus-startup-file))
3314 ;; Read the dribble file.
3315 (and gnus-use-dribble-file (gnus-dribble-read-file))
3317 (gnus-summary-make-display-table)
3318 (gnus-setup-news nil level)
3319 (gnus-group-list-groups level)
3320 (gnus-configure-windows 'group))))))
3322 (defun gnus-unload ()
3323 "Unload all Gnus features."
3324 (interactive)
3325 (or (boundp 'load-history)
3326 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3327 (let ((history load-history)
3328 feature)
3329 (while history
3330 (and (string-match "^gnus" (car (car history)))
3331 (setq feature (cdr (assq 'provide (car history))))
3332 (unload-feature feature 'force))
3333 (setq history (cdr history)))))
3335 (defun gnus-group-startup-message (&optional x y)
3336 "Insert startup message in current buffer."
3337 ;; Insert the message.
3338 (erase-buffer)
3339 (insert
3340 (format "
3341 _ ___ _ _
3342 _ ___ __ ___ __ _ ___
3343 __ _ ___ __ ___
3344 _ ___ _
3345 _ _ __ _
3346 ___ __ _
3347 __ _
3348 _ _ _
3349 _ _ _
3350 _ _ _
3351 __ ___
3352 _ _ _ _
3353 _ _
3354 _ _
3355 _ _
3360 Gnus * A newsreader for Emacsen
3361 A Praxis release * larsi@ifi.uio.no
3363 gnus-version))
3364 ;; And then hack it.
3365 ;; 18 is the longest line.
3366 (indent-rigidly (point-min) (point-max)
3367 (/ (max (- (window-width) (or x 46)) 0) 2))
3368 (goto-char (point-min))
3369 (let* ((pheight (count-lines (point-min) (point-max)))
3370 (wheight (window-height))
3371 (rest (- wheight pheight)))
3372 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3376 ;; Fontify some.
3377 (goto-char (point-min))
3378 (search-forward "Praxis")
3379 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3380 (goto-char (point-min)))
3382 (defun gnus-group-startup-message-old (&optional x y)
3383 "Insert startup message in current buffer."
3384 ;; Insert the message.
3385 (erase-buffer)
3386 (insert
3387 (format "
3389 A newsreader
3390 for GNU Emacs
3392 Based on GNUS
3393 written by
3394 Masanobu UMEDA
3396 A Praxis Release
3397 larsi@ifi.uio.no
3399 gnus-version))
3400 ;; And then hack it.
3401 ;; 18 is the longest line.
3402 (indent-rigidly (point-min) (point-max)
3403 (/ (max (- (window-width) (or x 28)) 0) 2))
3404 (goto-char (point-min))
3405 ;; +4 is fuzzy factor.
3406 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3408 ;; Fontify some.
3409 (goto-char (point-min))
3410 (search-forward "Praxis")
3411 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3412 (goto-char (point-min)))
3414 (defun gnus-group-setup-buffer ()
3415 (or (get-buffer gnus-group-buffer)
3416 (progn
3417 (switch-to-buffer gnus-group-buffer)
3418 (gnus-add-current-to-buffer-list)
3419 (gnus-group-mode)
3420 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3422 (defun gnus-group-list-groups (&optional level unread)
3423 "List newsgroups with level LEVEL or lower that have unread articles.
3424 Default is all subscribed groups.
3425 If argument UNREAD is non-nil, groups with no unread articles are also
3426 listed."
3427 (interactive (list (if current-prefix-arg
3428 (prefix-numeric-value current-prefix-arg)
3430 (gnus-group-default-level nil t)
3431 gnus-group-default-list-level
3432 gnus-level-subscribed))))
3433 (or level
3434 (setq level (car gnus-group-list-mode)
3435 unread (cdr gnus-group-list-mode)))
3436 (setq level (gnus-group-default-level level))
3437 (gnus-group-setup-buffer) ;May call from out of group buffer
3438 (let ((case-fold-search nil)
3439 (group (gnus-group-group-name)))
3440 (funcall gnus-group-prepare-function level unread nil)
3441 (if (zerop (buffer-size))
3442 (gnus-message 5 gnus-no-groups-message)
3443 (goto-char (point-min))
3444 (if (not group)
3445 ;; Go to the first group with unread articles.
3446 (gnus-group-search-forward nil nil nil t)
3447 ;; Find the right group to put point on. If the current group
3448 ;; has disapeared in the new listing, try to find the next
3449 ;; one. If no next one can be found, just leave point at the
3450 ;; first newsgroup in the buffer.
3451 (if (not (gnus-goto-char
3452 (text-property-any (point-min) (point-max)
3453 'gnus-group (intern group))))
3454 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3455 (while (and newsrc
3456 (not (gnus-goto-char
3457 (text-property-any
3458 (point-min) (point-max) 'gnus-group
3459 (intern (car (car newsrc)))))))
3460 (setq newsrc (cdr newsrc)))
3461 (or newsrc (progn (goto-char (point-max))
3462 (forward-line -1))))))
3463 ;; Adjust cursor point.
3464 (gnus-group-position-cursor))))
3466 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3467 "List all newsgroups with unread articles of level LEVEL or lower.
3468 If ALL is non-nil, list groups that have no unread articles.
3469 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3470 If REGEXP, only list groups matching REGEXP."
3471 (set-buffer gnus-group-buffer)
3472 (let ((buffer-read-only nil)
3473 (newsrc (cdr gnus-newsrc-alist))
3474 (lowest (or lowest 1))
3475 info clevel unread group)
3476 (erase-buffer)
3477 (if (< lowest gnus-level-zombie)
3478 ;; List living groups.
3479 (while newsrc
3480 (setq info (car newsrc)
3481 group (car info)
3482 newsrc (cdr newsrc)
3483 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3484 (and unread ; This group might be bogus
3485 (or (not regexp)
3486 (string-match regexp group))
3487 (<= (setq clevel (car (cdr info))) level)
3488 (>= clevel lowest)
3489 (or all ; We list all groups?
3490 (eq unread t) ; We list unactivated groups
3491 (> unread 0) ; We list groups with unread articles
3492 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3493 (gnus-group-insert-group-line
3494 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3496 ;; List dead groups.
3497 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3498 (gnus-group-prepare-flat-list-dead
3499 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3500 gnus-level-zombie ?Z
3501 regexp))
3502 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3503 (gnus-group-prepare-flat-list-dead
3504 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3505 gnus-level-killed ?K regexp))
3507 (gnus-group-set-mode-line)
3508 (setq gnus-group-list-mode (cons level all))
3509 (run-hooks 'gnus-group-prepare-hook)))
3511 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3512 ;; List zombies and killed lists somehwat faster, which was
3513 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3514 ;; this by ignoring the group format specification altogether.
3515 (let (group beg)
3516 (while groups
3517 (setq group (car groups)
3518 groups (cdr groups))
3519 (if (or (not regexp)
3520 (string-match regexp group))
3521 (progn
3522 (setq beg (point))
3523 (insert (format " %c *: %s\n" mark group))
3524 (add-text-properties
3525 beg (1+ beg)
3526 (list 'gnus-group (intern group)
3527 'gnus-unread t
3528 'gnus-level level)))))))
3530 (defun gnus-group-real-name (group)
3531 "Find the real name of a foreign newsgroup."
3532 (if (string-match ":[^:]+$" group)
3533 (substring group (1+ (match-beginning 0)))
3534 group))
3536 (defun gnus-group-prefixed-name (group method)
3537 "Return the whole name from GROUP and METHOD."
3538 (and (stringp method) (setq method (gnus-server-to-method method)))
3539 (concat (format "%s" (car method))
3540 (if (and
3541 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3542 (not (string= (nth 1 method) "")))
3543 (concat "+" (nth 1 method)))
3544 ":" group))
3546 (defun gnus-group-real-prefix (group)
3547 "Return the prefix of the current group name."
3548 (if (string-match "^[^:]+:" group)
3549 (substring group 0 (match-end 0))
3550 ""))
3552 (defun gnus-group-method-name (group)
3553 "Return the method used for selecting GROUP."
3554 (let ((prefix (gnus-group-real-prefix group)))
3555 (if (equal prefix "")
3556 gnus-select-method
3557 (if (string-match "^[^\\+]+\\+" prefix)
3558 (list (intern (substring prefix 0 (1- (match-end 0))))
3559 (substring prefix (match-end 0) (1- (length prefix))))
3560 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3562 (defun gnus-group-foreign-p (group)
3563 "Return nil if GROUP is native, non-nil if it is foreign."
3564 (string-match ":" group))
3566 (defun gnus-group-set-info (info &optional method-only-group part)
3567 (let* ((entry (gnus-gethash
3568 (or method-only-group (car info)) gnus-newsrc-hashtb))
3569 (part-info info)
3570 (info (if method-only-group (nth 2 entry) info)))
3571 (if (not method-only-group)
3573 (or entry
3574 (error "Trying to change non-existent group %s" method-only-group))
3575 ;; We have recevied parts of the actual group info - either the
3576 ;; select method or the group parameters. We first check
3577 ;; whether we have to extend the info, and if so, do that.
3578 (let ((len (length info))
3579 (total (if (eq part 'method) 5 6)))
3580 (and (< len total)
3581 (setcdr (nthcdr (1- len) info)
3582 (make-list (- total len) nil)))
3583 ;; Then we enter the new info.
3584 (setcar (nthcdr (1- total) info) part-info)))
3585 ;; We uncompress some lists of marked articles.
3586 (let (marked)
3587 (if (not (setq marked (nth 3 info)))
3589 (while marked
3590 (or (eq 'score (car (car marked)))
3591 (eq 'bookmark (car (car marked)))
3592 (eq 'killed (car (car marked)))
3593 (setcdr (car marked)
3594 (gnus-uncompress-range (cdr (car marked)))))
3595 (setq marked (cdr marked)))))
3596 (if entry
3598 ;; This is a new group, so we just create it.
3599 (save-excursion
3600 (set-buffer gnus-group-buffer)
3601 (if (nth 4 info)
3602 ;; It's a foreign group...
3603 (gnus-group-make-group
3604 (gnus-group-real-name (car info))
3605 (prin1-to-string (car (nth 4 info)))
3606 (nth 1 (nth 4 info)))
3607 ;; It's a native group.
3608 (gnus-group-make-group (car info)))
3609 (gnus-message 6 "Note: New group created")
3610 (setq entry
3611 (gnus-gethash (gnus-group-prefixed-name
3612 (gnus-group-real-name (car info))
3613 (or (nth 4 info) gnus-select-method))
3614 gnus-newsrc-hashtb))))
3615 ;; Whether it was a new group or not, we now have the entry, so we
3616 ;; can do the update.
3617 (if entry
3618 (progn
3619 (setcar (nthcdr 2 entry) info)
3620 (if (and (not (eq (car entry) t))
3621 (gnus-gethash (car info) gnus-active-hashtb))
3622 (let ((marked (nth 3 info)))
3623 (setcar entry
3624 (max 0 (- (length (gnus-list-of-unread-articles
3625 (car info)))
3626 (length (cdr (assq 'tick marked)))
3627 (length (cdr (assq 'dormant marked)))))))))
3628 (error "No such group: %s" (car info)))))
3630 (defun gnus-group-set-method-info (group select-method)
3631 (gnus-group-set-info select-method group 'method))
3633 (defun gnus-group-set-params-info (group params)
3634 (gnus-group-set-info params group 'params))
3636 (defun gnus-group-update-group-line ()
3637 "This function updates the current line in the newsgroup buffer and
3638 moves the point to the colon."
3639 (let* ((buffer-read-only nil)
3640 (group (gnus-group-group-name))
3641 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3642 (if (and entry (not (gnus-ephemeral-group-p group)))
3643 (gnus-dribble-enter
3644 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3645 ")")))
3646 (beginning-of-line)
3647 (delete-region (point) (progn (forward-line 1) (point)))
3648 (gnus-group-insert-group-line-info group)
3649 (forward-line -1)
3650 (gnus-group-position-cursor)))
3652 (defun gnus-group-insert-group-line-info (group)
3653 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3654 active info)
3655 (if entry
3656 (progn
3657 (setq info (nth 2 entry))
3658 (gnus-group-insert-group-line
3659 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3660 (setq active (gnus-gethash group gnus-active-hashtb))
3661 (gnus-group-insert-group-line
3662 nil group
3663 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3664 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3666 (defun gnus-group-insert-group-line (gformat group level marked number method)
3667 (let* ((gformat (or gformat gnus-group-line-format-spec))
3668 (active (gnus-gethash group gnus-active-hashtb))
3669 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3670 (number-of-dormant (length (cdr (assq 'dormant marked))))
3671 (number-of-ticked (length (cdr (assq 'tick marked))))
3672 (number-of-ticked-and-dormant
3673 (+ number-of-ticked number-of-dormant))
3674 (number-of-unread-unticked
3675 (if (numberp number) (int-to-string (max 0 number))
3676 "*"))
3677 (number-of-read
3678 (if (numberp number)
3679 (max 0 (- number-total number))
3680 "*"))
3681 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3682 ((<= level gnus-level-unsubscribed) ?U)
3683 ((= level gnus-level-zombie) ?Z)
3684 (t ?K)))
3685 (qualified-group (gnus-group-real-name group))
3686 (newsgroup-description
3687 (if gnus-description-hashtb
3688 (or (gnus-gethash group gnus-description-hashtb) "")
3689 ""))
3690 (moderated (if (member group gnus-moderated-list) ?m ? ))
3691 (moderated-string (if (eq moderated ?m) "(m)" ""))
3692 (method (gnus-server-get-method group method))
3693 (news-server (or (car (cdr method)) ""))
3694 (news-method (or (car method) ""))
3695 (news-method-string
3696 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3697 (marked (if (and
3698 (numberp number)
3699 (zerop number)
3700 (> number-of-ticked 0))
3701 ?* ? ))
3702 (number (if (eq number t) "*" (+ number number-of-dormant
3703 number-of-ticked)))
3704 (process-marked (if (member group gnus-group-marked)
3705 gnus-process-mark ? ))
3706 (buffer-read-only nil)
3707 header ; passed as parameter to user-funcs.
3709 (beginning-of-line)
3710 (setq b (point))
3711 ;; Insert the text.
3712 (insert (eval gformat))
3714 (add-text-properties
3715 b (1+ b) (list 'gnus-group (intern group)
3716 'gnus-unread (if (numberp number)
3717 (string-to-int number-of-unread-unticked)
3719 'gnus-marked marked
3720 'gnus-level level))))
3722 (defun gnus-group-update-group (group &optional visible-only)
3723 "Update newsgroup info of GROUP.
3724 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3725 (save-excursion
3726 (set-buffer gnus-group-buffer)
3727 (let ((buffer-read-only nil)
3728 visible)
3729 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3730 (if (and entry
3731 (not (gnus-ephemeral-group-p group)))
3732 (gnus-dribble-enter
3733 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3734 ")"))))
3735 ;; Buffer may be narrowed.
3736 (save-restriction
3737 (widen)
3738 ;; Search a line to modify. If the buffer is large, the search
3739 ;; takes long time. In most cases, current point is on the line
3740 ;; we are looking for. So, first of all, check current line.
3741 (if (or (progn
3742 (beginning-of-line)
3743 (eq (get-text-property (point) 'gnus-group)
3744 (intern group)))
3745 (progn
3746 (gnus-goto-char
3747 (text-property-any
3748 (point-min) (point-max) 'gnus-group (intern group)))))
3749 ;; GROUP is listed in current buffer. So, delete old line.
3750 (progn
3751 (setq visible t)
3752 (beginning-of-line)
3753 (delete-region (point) (progn (forward-line 1) (point))))
3754 ;; No such line in the buffer, find out where it's supposed to
3755 ;; go, and insert it there (or at the end of the buffer).
3756 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3757 (or visible-only
3758 (let ((entry
3759 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3760 (while (and entry
3761 (car entry)
3762 (not
3763 (gnus-goto-char
3764 (text-property-any
3765 (point-min) (point-max)
3766 'gnus-group (intern (car (car entry)))))))
3767 (setq entry (cdr entry)))
3768 (or entry (goto-char (point-max)))))))
3769 (if (or visible (not visible-only))
3770 (gnus-group-insert-group-line-info group))
3771 (gnus-group-set-mode-line))))
3773 (defun gnus-group-set-mode-line ()
3774 (if (memq 'group gnus-updated-mode-lines)
3775 (let* ((gformat (or gnus-group-mode-line-format-spec
3776 (setq gnus-group-mode-line-format-spec
3777 (gnus-parse-format
3778 gnus-group-mode-line-format
3779 gnus-group-mode-line-format-alist))))
3780 (news-server (car (cdr gnus-select-method)))
3781 (news-method (car gnus-select-method))
3782 (max-len 60)
3783 (mode-string (eval gformat)))
3784 (setq mode-string (eval gformat))
3785 (if (> (length mode-string) max-len)
3786 (setq mode-string (substring mode-string 0 (- max-len 4))))
3787 (setq mode-line-buffer-identification mode-string)
3788 (set-buffer-modified-p t))))
3790 (defun gnus-group-group-name ()
3791 "Get the name of the newsgroup on the current line."
3792 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3793 (and group (symbol-name group))))
3795 (defun gnus-group-group-level ()
3796 "Get the level of the newsgroup on the current line."
3797 (get-text-property (gnus-point-at-bol) 'gnus-level))
3799 (defun gnus-group-group-unread ()
3800 "Get the number of unread articles of the newsgroup on the current line."
3801 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3803 (defun gnus-group-search-forward (&optional backward all level first-too)
3804 "Find the next newsgroup with unread articles.
3805 If BACKWARD is non-nil, find the previous newsgroup instead.
3806 If ALL is non-nil, just find any newsgroup.
3807 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3808 group exists.
3809 If FIRST-TOO, the current line is also eligible as a target."
3810 (let ((way (if backward -1 1))
3811 (low gnus-level-killed)
3812 (beg (point))
3813 pos found lev)
3814 (if (and backward (progn (beginning-of-line)) (bobp))
3816 (or first-too (forward-line way))
3817 (while (and
3818 (not (eobp))
3819 (not (setq
3820 found
3821 (and (or all
3822 (and
3823 (let ((unread
3824 (get-text-property (point) 'gnus-unread)))
3825 (or (eq unread t) (and unread (> unread 0))))
3826 (setq lev (get-text-property (point)
3827 'gnus-level))
3828 (<= lev gnus-level-subscribed)))
3829 (or (not level)
3830 (and (setq lev (get-text-property (point)
3831 'gnus-level))
3832 (or (= lev level)
3833 (and (< lev low)
3834 (< level lev)
3835 (progn
3836 (setq low lev)
3837 (setq pos (point))
3838 nil))))))))
3839 (zerop (forward-line way)))))
3840 (if found
3841 (progn (gnus-group-position-cursor) t)
3842 (goto-char (or pos beg))
3843 (and pos t))))
3845 ;;; Gnus group mode commands
3847 ;; Group marking.
3849 (defun gnus-group-mark-group (n &optional unmark no-advance)
3850 "Mark the current group."
3851 (interactive "p")
3852 (let ((buffer-read-only nil)
3853 group)
3854 (while
3855 (and (> n 0)
3856 (setq group (gnus-group-group-name))
3857 (progn
3858 (beginning-of-line)
3859 (forward-char
3860 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3861 (delete-char 1)
3862 (if unmark
3863 (progn
3864 (insert " ")
3865 (setq gnus-group-marked (delete group gnus-group-marked)))
3866 (insert "#")
3867 (setq gnus-group-marked
3868 (cons group (delete group gnus-group-marked))))
3870 (or no-advance (zerop (gnus-group-next-group 1))))
3871 (setq n (1- n)))
3872 (gnus-summary-position-cursor)
3875 (defun gnus-group-unmark-group (n)
3876 "Remove the mark from the current group."
3877 (interactive "p")
3878 (gnus-group-mark-group n 'unmark))
3880 (defun gnus-group-mark-region (unmark beg end)
3881 "Mark all groups between point and mark.
3882 If UNMARK, remove the mark instead."
3883 (interactive "P\nr")
3884 (let ((num (count-lines beg end)))
3885 (save-excursion
3886 (goto-char beg)
3887 (- num (gnus-group-mark-group num unmark)))))
3889 (defun gnus-group-remove-mark (group)
3890 (and (gnus-group-goto-group group)
3891 (save-excursion
3892 (gnus-group-mark-group 1 'unmark t))))
3894 ;; Return a list of groups to work on. Take into consideration N (the
3895 ;; prefix) and the list of marked groups.
3896 (defun gnus-group-process-prefix (n)
3897 (cond (n
3898 (setq n (prefix-numeric-value n))
3899 ;; There is a prefix, so we return a list of the N next
3900 ;; groups.
3901 (let ((way (if (< n 0) -1 1))
3902 (n (abs n))
3903 group groups)
3904 (save-excursion
3905 (while (and (> n 0)
3906 (setq group (gnus-group-group-name)))
3907 (setq groups (cons group groups))
3908 (setq n (1- n))
3909 (forward-line way)))
3910 (nreverse groups)))
3911 (gnus-group-marked
3912 ;; No prefix, but a list of marked articles.
3913 (reverse gnus-group-marked))
3915 ;; Neither marked articles or a prefix, so we return the
3916 ;; current group.
3917 (let ((group (gnus-group-group-name)))
3918 (and group (list group))))))
3920 ;; Selecting groups.
3922 (defun gnus-group-read-group (&optional all no-article group)
3923 "Read news in this newsgroup.
3924 If the prefix argument ALL is non-nil, already read articles become
3925 readable. If the optional argument NO-ARTICLE is non-nil, no article
3926 will be auto-selected upon group entry."
3927 (interactive "P")
3928 (let ((group (or group (gnus-group-group-name)))
3929 number active marked entry)
3930 (or group (error "No group on current line"))
3931 (setq marked
3932 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3933 ;; This group might be a dead group. In that case we have to get
3934 ;; the number of unread articles from `gnus-active-hashtb'.
3935 (if entry
3936 (setq number (car entry))
3937 (if (setq active (gnus-gethash group gnus-active-hashtb))
3938 (setq number (- (1+ (cdr active)) (car active)))))
3939 (gnus-summary-read-group
3940 group (or all (and (numberp number)
3941 (zerop (+ number (length (cdr (assq 'tick marked)))
3942 (length (cdr (assq 'dormant marked)))))))
3943 no-article)))
3945 (defun gnus-group-select-group (&optional all)
3946 "Select this newsgroup.
3947 No article is selected automatically.
3948 If argument ALL is non-nil, already read articles become readable."
3949 (interactive "P")
3950 (gnus-group-read-group all t))
3952 (defun gnus-group-select-group-all ()
3953 "Select the current group and display all articles in it."
3954 (interactive)
3955 (gnus-group-select-group 'all))
3957 ;; Enter a group that is not in the group buffer. Non-nil is returned
3958 ;; if selection was successful.
3959 (defun gnus-group-read-ephemeral-group
3960 (group method &optional activate quit-config)
3961 (let ((group (if (gnus-group-foreign-p group) group
3962 (gnus-group-prefixed-name group method))))
3963 (gnus-sethash
3964 group
3965 (list t nil (list group gnus-level-default-subscribed nil nil
3966 (append method
3967 (list
3968 (list 'quit-config
3969 (if quit-config quit-config
3970 (cons (current-buffer) 'summary)))))))
3971 gnus-newsrc-hashtb)
3972 (set-buffer gnus-group-buffer)
3973 (or (gnus-check-server method)
3974 (error "Unable to contact server: %s" (gnus-status-message method)))
3975 (if activate (or (gnus-request-group group)
3976 (error "Couldn't request group")))
3977 (condition-case ()
3978 (gnus-group-read-group t t group)
3979 (error nil)
3980 (quit nil))
3981 (not (equal major-mode 'gnus-group-mode))))
3983 (defun gnus-group-jump-to-group (group)
3984 "Jump to newsgroup GROUP."
3985 (interactive
3986 (list (completing-read
3987 "Group: " gnus-active-hashtb nil
3988 (memq gnus-select-method gnus-have-read-active-file))))
3990 (if (equal group "")
3991 (error "Empty group name"))
3993 (let ((b (text-property-any
3994 (point-min) (point-max) 'gnus-group (intern group))))
3995 (if b
3996 ;; Either go to the line in the group buffer...
3997 (goto-char b)
3998 ;; ... or insert the line.
4000 (gnus-gethash group gnus-active-hashtb)
4001 (gnus-activate-group group)
4002 (error "%s error: %s" group (gnus-status-message group)))
4004 (gnus-group-update-group group)
4005 (goto-char (text-property-any
4006 (point-min) (point-max) 'gnus-group (intern group)))))
4007 ;; Adjust cursor point.
4008 (gnus-group-position-cursor))
4010 (defun gnus-group-goto-group (group)
4011 "Goto to newsgroup GROUP."
4012 (let ((b (text-property-any (point-min) (point-max)
4013 'gnus-group (intern group))))
4014 (and b (goto-char b))))
4016 (defun gnus-group-next-group (n)
4017 "Go to next N'th newsgroup.
4018 If N is negative, search backward instead.
4019 Returns the difference between N and the number of skips actually
4020 done."
4021 (interactive "p")
4022 (gnus-group-next-unread-group n t))
4024 (defun gnus-group-next-unread-group (n &optional all level)
4025 "Go to next N'th unread newsgroup.
4026 If N is negative, search backward instead.
4027 If ALL is non-nil, choose any newsgroup, unread or not.
4028 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4029 such group can be found, the next group with a level higher than
4030 LEVEL.
4031 Returns the difference between N and the number of skips actually
4032 made."
4033 (interactive "p")
4034 (let ((backward (< n 0))
4035 (n (abs n)))
4036 (while (and (> n 0)
4037 (gnus-group-search-forward
4038 backward (or (not gnus-group-goto-unread) all) level))
4039 (setq n (1- n)))
4040 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4041 (if level " on this level or higher" "")))
4044 (defun gnus-group-prev-group (n)
4045 "Go to previous N'th newsgroup.
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-prev-unread-group (n)
4052 "Go to previous N'th unread newsgroup.
4053 Returns the difference between N and the number of skips actually
4054 done."
4055 (interactive "p")
4056 (gnus-group-next-unread-group (- n)))
4058 (defun gnus-group-next-unread-group-same-level (n)
4059 "Go to next N'th unread newsgroup on the same level.
4060 If N is negative, search backward instead.
4061 Returns the difference between N and the number of skips actually
4062 done."
4063 (interactive "p")
4064 (gnus-group-next-unread-group n t (gnus-group-group-level))
4065 (gnus-group-position-cursor))
4067 (defun gnus-group-prev-unread-group-same-level (n)
4068 "Go to next N'th unread newsgroup on the same level.
4069 Returns the difference between N and the number of skips actually
4070 done."
4071 (interactive "p")
4072 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4073 (gnus-group-position-cursor))
4075 (defun gnus-group-best-unread-group (&optional exclude-group)
4076 "Go to the group with the highest level.
4077 If EXCLUDE-GROUP, do not go to that group."
4078 (interactive)
4079 (goto-char (point-min))
4080 (let ((best 100000)
4081 unread best-point)
4082 (while (setq unread (get-text-property (point) 'gnus-unread))
4083 (if (and (numberp unread) (> unread 0))
4084 (progn
4085 (if (and (< (get-text-property (point) 'gnus-level) best)
4086 (or (not exclude-group)
4087 (not (equal exclude-group (gnus-group-group-name)))))
4088 (progn
4089 (setq best (get-text-property (point) 'gnus-level))
4090 (setq best-point (point))))))
4091 (forward-line 1))
4092 (if best-point (goto-char best-point))
4093 (gnus-summary-position-cursor)
4094 (and best-point (gnus-group-group-name))))
4096 (defun gnus-group-first-unread-group ()
4097 "Go to the first group with unread articles."
4098 (interactive)
4099 (prog1
4100 (let ((opoint (point))
4101 unread)
4102 (goto-char (point-min))
4103 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4104 (not (zerop unread)) ; Has unread articles.
4105 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4106 (point) ; Success.
4107 (goto-char opoint)
4108 nil)) ; Not success.
4109 (gnus-group-position-cursor)))
4111 (defun gnus-group-enter-server-mode ()
4112 "Jump to the server buffer."
4113 (interactive)
4114 (gnus-server-setup-buffer)
4115 (gnus-configure-windows 'server)
4116 (gnus-server-prepare))
4118 (defun gnus-group-make-group (name &optional method address)
4119 "Add a new newsgroup.
4120 The user will be prompted for a NAME, for a select METHOD, and an
4121 ADDRESS."
4122 (interactive
4123 (cons
4124 (read-string "Group name: ")
4125 (let ((method
4126 (completing-read
4127 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4128 nil t)))
4129 (if (assoc method gnus-valid-select-methods)
4130 (list method
4131 (if (memq 'prompt-address
4132 (assoc method gnus-valid-select-methods))
4133 (read-string "Address: ")
4134 ""))
4135 (list method nil)))))
4137 (let* ((meth (and method (if address (list (intern method) address) method)))
4138 (nname (if method (gnus-group-prefixed-name name meth) name))
4139 info)
4140 (and (gnus-gethash nname gnus-newsrc-hashtb)
4141 (error "Group %s already exists" nname))
4142 (gnus-group-change-level
4143 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4144 gnus-level-default-subscribed gnus-level-killed
4145 (and (gnus-group-group-name)
4146 (gnus-gethash (gnus-group-group-name)
4147 gnus-newsrc-hashtb))
4149 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4150 (or (gnus-ephemeral-group-p name)
4151 (gnus-dribble-enter
4152 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
4153 (gnus-group-insert-group-line-info nname)
4155 (if (assoc method gnus-valid-select-methods)
4156 (require (intern method)))
4157 (and (gnus-check-backend-function 'request-create-group nname)
4158 (gnus-request-create-group nname))))
4160 (defun gnus-group-edit-group (group &optional part)
4161 "Edit the group on the current line."
4162 (interactive (list (gnus-group-group-name)))
4163 (let ((done-func '(lambda ()
4164 "Exit editing mode and update the information."
4165 (interactive)
4166 (gnus-group-edit-group-done 'part 'group)))
4167 (part (or part 'info))
4168 (winconf (current-window-configuration))
4169 info)
4170 (or group (error "No group on current line"))
4171 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4172 (error "Killed group; can't be edited"))
4173 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4174 (gnus-configure-windows 'edit-group)
4175 (gnus-add-current-to-buffer-list)
4176 (emacs-lisp-mode)
4177 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4178 (use-local-map (copy-keymap emacs-lisp-mode-map))
4179 (local-set-key "\C-c\C-c" done-func)
4180 (make-local-variable 'gnus-prev-winconf)
4181 (setq gnus-prev-winconf winconf)
4182 ;; We modify the func to let it know what part it is editing.
4183 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4184 (setcar (cdr (cdr (nth 4 done-func))) group)
4185 (erase-buffer)
4186 (insert
4187 (cond
4188 ((eq part 'method)
4189 ";; Type `C-c C-c' after editing the select method.\n\n")
4190 ((eq part 'params)
4191 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4192 ((eq part 'info)
4193 ";; Type `C-c C-c' after editing the group info.\n\n")))
4194 (let ((cinfo (gnus-copy-sequence info))
4195 marked)
4196 (if (not (setq marked (nth 3 cinfo)))
4198 (while marked
4199 (or (eq 'score (car (car marked)))
4200 (eq 'bookmark (car (car marked)))
4201 (eq 'killed (car (car marked)))
4202 (not (numberp (car (cdr (car marked)))))
4203 (setcdr (car marked)
4204 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4205 (setq marked (cdr marked))))
4206 (insert
4207 (pp-to-string
4208 (cond ((eq part 'method)
4209 (or (nth 4 info) "native"))
4210 ((eq part 'params)
4211 (nth 5 info))
4213 cinfo)))
4214 "\n"))))
4216 (defun gnus-group-edit-group-method (group)
4217 "Edit the select method of GROUP."
4218 (interactive (list (gnus-group-group-name)))
4219 (gnus-group-edit-group group 'method))
4221 (defun gnus-group-edit-group-parameters (group)
4222 "Edit the group parameters of GROUP."
4223 (interactive (list (gnus-group-group-name)))
4224 (gnus-group-edit-group group 'params))
4226 (defun gnus-group-edit-group-done (part group)
4227 "Get info from buffer, update variables and jump to the group buffer."
4228 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4229 (goto-char (point-min))
4230 (let ((form (read (current-buffer)))
4231 (winconf gnus-prev-winconf))
4232 (if (eq part 'info)
4233 (gnus-group-set-info form)
4234 (gnus-group-set-info form group part))
4235 (kill-buffer (current-buffer))
4236 (and winconf (set-window-configuration winconf))
4237 (set-buffer gnus-group-buffer)
4238 (gnus-group-update-group (gnus-group-group-name))
4239 (gnus-group-position-cursor)))
4241 (defun gnus-group-make-help-group ()
4242 "Create the Gnus documentation group."
4243 (interactive)
4244 (let ((path (cons (concat installation-directory "etc/") load-path))
4245 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
4246 file)
4247 (and (gnus-gethash name gnus-newsrc-hashtb)
4248 (error "Documentation group already exists"))
4249 (while (and path
4250 (not (file-exists-p
4251 (setq file (concat (file-name-as-directory (car path))
4252 "gnus-tut.txt")))))
4253 (setq path (cdr path)))
4254 (if (not path)
4255 (message "Couldn't find doc group")
4256 (gnus-group-make-group
4257 (gnus-group-real-name name)
4258 (list 'nndoc name
4259 (list 'nndoc-address file)
4260 (list 'nndoc-article-type 'mbox)))))
4261 (gnus-group-position-cursor))
4263 (defun gnus-group-make-doc-group (file type)
4264 "Create a group that uses a single file as the source."
4265 (interactive
4266 (list (read-file-name "File name: ")
4267 (let ((err "")
4268 found char)
4269 (while (not found)
4270 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4271 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4272 ((= char ?b) 'babyl)
4273 ((= char ?d) 'digest)
4274 (t (setq err (format "%c unknown. " char))
4275 nil))))
4276 found)))
4277 (let* ((file (expand-file-name file))
4278 (name (gnus-generate-new-group-name
4279 (gnus-group-prefixed-name
4280 (file-name-nondirectory file) '(nndoc "")))))
4281 (gnus-group-make-group
4282 (gnus-group-real-name name)
4283 (list 'nndoc name
4284 (list 'nndoc-address file)
4285 (list 'nndoc-article-type type)))))
4287 (defun gnus-group-make-archive-group (&optional all)
4288 "Create the (ding) Gnus archive group of the most recent articles.
4289 Given a prefix, create a full group."
4290 (interactive "P")
4291 (let ((group (gnus-group-prefixed-name
4292 (if all "ding.archives" "ding.recent") '(nndir ""))))
4293 (and (gnus-gethash group gnus-newsrc-hashtb)
4294 (error "Archive group already exists"))
4295 (gnus-group-make-group
4296 (gnus-group-real-name group)
4297 "nndir"
4298 (if all gnus-group-archive-directory
4299 gnus-group-recent-archive-directory)))
4300 (gnus-group-position-cursor))
4302 (defun gnus-group-make-directory-group (dir)
4303 "Create an nndir group.
4304 The user will be prompted for a directory. The contents of this
4305 directory will be used as a newsgroup. The directory should contain
4306 mail messages or news articles in files that have numeric names."
4307 (interactive
4308 (list (read-file-name "Create group from directory: ")))
4309 (or (file-exists-p dir) (error "No such directory"))
4310 (or (file-directory-p dir) (error "Not a directory"))
4311 (gnus-group-make-group dir "nndir" dir)
4312 (gnus-group-position-cursor))
4314 (defun gnus-group-make-kiboze-group (group address scores)
4315 "Create an nnkiboze group.
4316 The user will be prompted for a name, a regexp to match groups, and
4317 score file entries for articles to include in the group."
4318 (interactive
4319 (list
4320 (read-string "nnkiboze group name: ")
4321 (read-string "Source groups (regexp): ")
4322 (let ((headers (mapcar (lambda (group) (list group))
4323 '("subject" "from" "number" "date" "message-id"
4324 "references" "chars" "lines" "xref")))
4325 scores header regexp regexps)
4326 (while (not (equal "" (setq header (completing-read
4327 "Match on header: " headers nil t))))
4328 (setq regexps nil)
4329 (while (not (equal "" (setq regexp (read-string
4330 (format "Match on %s (string): "
4331 header)))))
4332 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4333 (setq scores (cons (cons header regexps) scores)))
4334 scores)))
4335 (gnus-group-make-group group "nnkiboze" address)
4336 (save-excursion
4337 (gnus-set-work-buffer)
4338 (let (emacs-lisp-mode-hook)
4339 (pp scores (current-buffer)))
4340 (write-region (point-min) (point-max)
4341 (concat (or gnus-kill-files-directory "~/News")
4342 "nnkiboze:" group "." gnus-score-file-suffix)))
4343 (gnus-group-position-cursor))
4345 (defun gnus-group-add-to-virtual (n vgroup)
4346 "Add the current group to a virtual group."
4347 (interactive
4348 (list current-prefix-arg
4349 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4350 "nnvirtual:")))
4351 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4352 (error "%s is not an nnvirtual group" vgroup))
4353 (let* ((groups (gnus-group-process-prefix n))
4354 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4355 (setcar (cdr method)
4356 (concat
4357 (nth 1 method) "\\|"
4358 (mapconcat
4359 (lambda (s)
4360 (gnus-group-remove-mark s)
4361 (concat "\\(^" (regexp-quote s) "$\\)"))
4362 groups "\\|"))))
4363 (gnus-group-position-cursor))
4365 (defun gnus-group-make-empty-virtual (group)
4366 "Create a new, fresh, empty virtual group."
4367 (interactive "sCreate new, empty virtual group: ")
4368 (let* ((method (list 'nnvirtual "^$"))
4369 (pgroup (gnus-group-prefixed-name group method)))
4370 ;; Check whether it exists already.
4371 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4372 (error "Group %s already exists." pgroup))
4373 ;; Subscribe the new group after the group on the current line.
4374 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4375 (gnus-group-update-group pgroup)
4376 (forward-line -1)
4377 (gnus-group-position-cursor)))
4379 (defun gnus-group-enter-directory (dir)
4380 "Enter an ephemeral nneething group."
4381 (interactive "DDirectory to read: ")
4382 (let* ((method (list 'nneething dir))
4383 (leaf (gnus-group-prefixed-name
4384 (file-name-nondirectory (directory-file-name dir))
4385 method))
4386 (name (gnus-generate-new-group-name leaf)))
4387 (let ((nneething-read-only t))
4388 (or (gnus-group-read-ephemeral-group
4389 name method t
4390 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4391 'summary 'group)))
4392 (error "Couldn't enter %s" dir)))))
4394 ;; Group sorting commands
4395 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4397 (defun gnus-group-sort-groups ()
4398 "Sort the group buffer using `gnus-group-sort-function'."
4399 (interactive)
4400 (setq gnus-newsrc-alist
4401 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4402 (gnus-make-hashtable-from-newsrc-alist)
4403 (gnus-group-list-groups))
4405 (defun gnus-group-sort-by-alphabet (info1 info2)
4406 (string< (car info1) (car info2)))
4408 (defun gnus-group-sort-by-unread (info1 info2)
4409 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4410 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4411 (< (or (and (numberp n1) n1) 0)
4412 (or (and (numberp n2) n2) 0))))
4414 (defun gnus-group-sort-by-level (info1 info2)
4415 (< (nth 1 info1) (nth 1 info2)))
4417 ;; Group catching up.
4419 (defun gnus-group-catchup-current (&optional n all)
4420 "Mark all articles not marked as unread in current newsgroup as read.
4421 If prefix argument N is numeric, the ARG next newsgroups will be
4422 caught up. If ALL is non-nil, marked articles will also be marked as
4423 read. Cross references (Xref: header) of articles are ignored.
4424 The difference between N and actual number of newsgroups that were
4425 caught up is returned."
4426 (interactive "P")
4427 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4428 gnus-expert-user
4429 (gnus-y-or-n-p
4430 (if all
4431 "Do you really want to mark all articles as read? "
4432 "Mark all unread articles as read? "))))
4434 (let ((groups (gnus-group-process-prefix n))
4435 (ret 0))
4436 (while groups
4437 ;; Virtual groups have to be given special treatment.
4438 (let ((method (gnus-find-method-for-group (car groups))))
4439 (if (eq 'nnvirtual (car method))
4440 (nnvirtual-catchup-group
4441 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4442 (gnus-group-remove-mark (car groups))
4443 (if (prog1
4444 (gnus-group-goto-group (car groups))
4445 (gnus-group-catchup (car groups) all))
4446 (gnus-group-update-group-line)
4447 (setq ret (1+ ret)))
4448 (setq groups (cdr groups)))
4449 (gnus-group-next-unread-group 1)
4450 ret)))
4452 (defun gnus-group-catchup-current-all (&optional n)
4453 "Mark all articles in current newsgroup as read.
4454 Cross references (Xref: header) of articles are ignored."
4455 (interactive "P")
4456 (gnus-group-catchup-current n 'all))
4458 (defun gnus-group-catchup (group &optional all)
4459 "Mark all articles in GROUP as read.
4460 If ALL is non-nil, all articles are marked as read.
4461 The return value is the number of articles that were marked as read,
4462 or nil if no action could be taken."
4463 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4464 (num (car entry))
4465 (marked (nth 3 (nth 2 entry))))
4466 (if (not (numberp (car entry)))
4467 (gnus-message 1 "Can't catch up; non-active group")
4468 ;; Do the updating only if the newsgroup isn't killed.
4469 (if (not entry)
4471 (gnus-update-read-articles
4472 group (and (not all) (append (cdr (assq 'tick marked))
4473 (cdr (assq 'dormant marked))))
4474 nil (and (not all) (cdr (assq 'tick marked))))
4475 (and all
4476 (setq marked (nth 3 (nth 2 entry)))
4477 (setcar (nthcdr 3 (nth 2 entry))
4478 (delq (assq 'dormant marked)
4479 (nth 3 (nth 2 entry)))))))
4480 num))
4482 (defun gnus-group-expire-articles (&optional n)
4483 "Expire all expirable articles in the current newsgroup."
4484 (interactive "P")
4485 (let ((groups (gnus-group-process-prefix n))
4486 group)
4487 (or groups (error "No groups to expire"))
4488 (while groups
4489 (setq group (car groups)
4490 groups (cdr groups))
4491 (gnus-group-remove-mark group)
4492 (if (not (gnus-check-backend-function 'request-expire-articles group))
4494 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4495 (expirable (if (memq 'total-expire (nth 5 info))
4496 (cons nil (gnus-list-of-read-articles group))
4497 (assq 'expire (nth 3 info)))))
4498 (and expirable
4499 (setcdr expirable
4500 (gnus-request-expire-articles
4501 (cdr expirable) group))))))))
4503 (defun gnus-group-expire-all-groups ()
4504 "Expire all expirable articles in all newsgroups."
4505 (interactive)
4506 (save-excursion
4507 (gnus-message 5 "Expiring...")
4508 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4509 (cdr gnus-newsrc-alist))))
4510 (gnus-group-expire-articles nil)))
4511 (gnus-group-position-cursor)
4512 (gnus-message 5 "Expiring...done"))
4514 (defun gnus-group-set-current-level (n level)
4515 "Set the level of the next N groups to LEVEL."
4516 (interactive "P\nnLevel: ")
4517 (or (and (>= level 1) (<= level gnus-level-killed))
4518 (error "Illegal level: %d" level))
4519 (let ((groups (gnus-group-process-prefix n))
4520 group)
4521 (while groups
4522 (setq group (car groups)
4523 groups (cdr groups))
4524 (gnus-group-remove-mark group)
4525 (gnus-message 6 "Changed level of %s from %d to %d"
4526 group (gnus-group-group-level) level)
4527 (gnus-group-change-level group level
4528 (gnus-group-group-level))
4529 (gnus-group-update-group-line)))
4530 (gnus-group-position-cursor))
4532 (defun gnus-group-unsubscribe-current-group (&optional n)
4533 "Toggle subscription of the current group.
4534 If given numerical prefix, toggle the N next groups."
4535 (interactive "P")
4536 (let ((groups (gnus-group-process-prefix n))
4537 group)
4538 (while groups
4539 (setq group (car groups)
4540 groups (cdr groups))
4541 (gnus-group-remove-mark group)
4542 (gnus-group-unsubscribe-group
4543 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4544 gnus-level-default-unsubscribed
4545 gnus-level-default-subscribed))
4546 (gnus-group-update-group-line))
4547 (gnus-group-next-group 1)))
4549 (defun gnus-group-unsubscribe-group (group &optional level)
4550 "Toggle subscribe from/to unsubscribe GROUP.
4551 New newsgroup is added to .newsrc automatically."
4552 (interactive
4553 (list (completing-read
4554 "Group: " gnus-active-hashtb nil
4555 (memq gnus-select-method gnus-have-read-active-file))))
4556 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4557 (cond
4558 ((string-match "^[ \t]$" group)
4559 (error "Empty group name"))
4560 (newsrc
4561 ;; Toggle subscription flag.
4562 (gnus-group-change-level
4563 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4564 gnus-level-subscribed)
4565 (1+ gnus-level-subscribed)
4566 gnus-level-default-subscribed)))
4567 (gnus-group-update-group group))
4568 ((and (stringp group)
4569 (or (not (memq gnus-select-method gnus-have-read-active-file))
4570 (gnus-gethash group gnus-active-hashtb)))
4571 ;; Add new newsgroup.
4572 (gnus-group-change-level
4573 group
4574 (if level level gnus-level-default-subscribed)
4575 (or (and (member group gnus-zombie-list)
4576 gnus-level-zombie)
4577 gnus-level-killed)
4578 (and (gnus-group-group-name)
4579 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4580 (gnus-group-update-group group))
4581 (t (error "No such newsgroup: %s" group)))
4582 (gnus-group-position-cursor)))
4584 (defun gnus-group-transpose-groups (n)
4585 "Move the current newsgroup up N places.
4586 If given a negative prefix, move down instead. The difference between
4587 N and the number of steps taken is returned."
4588 (interactive "p")
4589 (or (gnus-group-group-name)
4590 (error "No group on current line"))
4591 (gnus-group-kill-group 1)
4592 (prog1
4593 (forward-line (- n))
4594 (gnus-group-yank-group)
4595 (gnus-group-position-cursor)))
4597 (defun gnus-group-kill-all-zombies ()
4598 "Kill all zombie newsgroups."
4599 (interactive)
4600 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4601 (setq gnus-zombie-list nil)
4602 (gnus-group-list-groups))
4604 (defun gnus-group-kill-region (begin end)
4605 "Kill newsgroups in current region (excluding current point).
4606 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4607 (interactive "r")
4608 (let ((lines
4609 ;; Count lines.
4610 (save-excursion
4611 (count-lines
4612 (progn
4613 (goto-char begin)
4614 (beginning-of-line)
4615 (point))
4616 (progn
4617 (goto-char end)
4618 (beginning-of-line)
4619 (point))))))
4620 (goto-char begin)
4621 (beginning-of-line) ;Important when LINES < 1
4622 (gnus-group-kill-group lines)))
4624 (defun gnus-group-kill-group (&optional n)
4625 "The the next N groups.
4626 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4627 However, only groups that were alive can be yanked; already killed
4628 groups or zombie groups can't be yanked.
4629 The return value is the name of the (last) group that was killed."
4630 (interactive "P")
4631 (let ((buffer-read-only nil)
4632 (groups (gnus-group-process-prefix n))
4633 group entry level)
4634 (while groups
4635 (setq group (car groups)
4636 groups (cdr groups))
4637 (gnus-group-remove-mark group)
4638 (setq level (gnus-group-group-level))
4639 (gnus-delete-line)
4640 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4641 (setq gnus-list-of-killed-groups
4642 (cons (cons (car entry) (nth 2 entry))
4643 gnus-list-of-killed-groups)))
4644 (gnus-group-change-level
4645 (if entry entry group) gnus-level-killed (if entry nil level)))
4646 (gnus-group-position-cursor)
4647 group))
4649 (defun gnus-group-yank-group (&optional arg)
4650 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4651 inserting it before the current newsgroup. The numeric ARG specifies
4652 how many newsgroups are to be yanked. The name of the (last)
4653 newsgroup yanked is returned."
4654 (interactive "p")
4655 (if (not arg) (setq arg 1))
4656 (let (info group prev)
4657 (while (>= (setq arg (1- arg)) 0)
4658 (if (not (setq info (car gnus-list-of-killed-groups)))
4659 (error "No more newsgroups to yank"))
4660 (setq group (nth 2 info))
4661 ;; Find which newsgroup to insert this one before - search
4662 ;; backward until something suitable is found. If there are no
4663 ;; other newsgroups in this buffer, just make this newsgroup the
4664 ;; first newsgroup.
4665 (setq prev (gnus-group-group-name))
4666 (gnus-group-change-level
4667 info (nth 2 info) gnus-level-killed
4668 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4670 (gnus-group-insert-group-line-info (nth 1 info))
4671 (setq gnus-list-of-killed-groups
4672 (cdr gnus-list-of-killed-groups)))
4673 (forward-line -1)
4674 (gnus-group-position-cursor)
4675 group))
4677 (defun gnus-group-list-all-groups (&optional arg)
4678 "List all newsgroups with level ARG or lower.
4679 Default is gnus-level-unsubscribed, which lists all subscribed and most
4680 unsubscribed groups."
4681 (interactive "P")
4682 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4684 (defun gnus-group-list-killed ()
4685 "List all killed newsgroups in the group buffer."
4686 (interactive)
4687 (if (not gnus-killed-list)
4688 (gnus-message 6 "No killed groups")
4689 (let (gnus-group-list-mode)
4690 (funcall gnus-group-prepare-function
4691 gnus-level-killed t gnus-level-killed))
4692 (goto-char (point-min)))
4693 (gnus-group-position-cursor))
4695 (defun gnus-group-list-zombies ()
4696 "List all zombie newsgroups in the group buffer."
4697 (interactive)
4698 (if (not gnus-zombie-list)
4699 (gnus-message 6 "No zombie groups")
4700 (let (gnus-group-list-mode)
4701 (funcall gnus-group-prepare-function
4702 gnus-level-zombie t gnus-level-zombie))
4703 (goto-char (point-min)))
4704 (gnus-group-position-cursor))
4706 (defun gnus-group-get-new-news (&optional arg)
4707 "Get newly arrived articles.
4708 If ARG is non-nil, it should be a number between one and nine to
4709 specify which levels you are interested in re-scanning."
4710 (interactive "P")
4711 (run-hooks 'gnus-get-new-news-hook)
4712 (setq arg (gnus-group-default-level arg t))
4713 (if (and gnus-read-active-file (not arg))
4714 (progn
4715 (gnus-read-active-file)
4716 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4717 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
4718 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4719 (gnus-group-list-groups))
4721 (defun gnus-group-get-new-news-this-group (&optional n)
4722 "Check for newly arrived news in the current group (and the N-1 next groups).
4723 The difference between N and the number of newsgroup checked is returned.
4724 If N is negative, this group and the N-1 previous groups will be checked."
4725 (interactive "P")
4726 (let* ((groups (gnus-group-process-prefix n))
4727 (ret (if (numberp n) (- n (length groups)) 0))
4728 group)
4729 (while groups
4730 (setq group (car groups)
4731 groups (cdr groups))
4732 (gnus-group-remove-mark group)
4733 (or (gnus-get-new-news-in-group group)
4734 (progn
4735 (ding)
4736 (message "%s error: %s" group (gnus-status-message group))
4737 (sit-for 2))))
4738 (gnus-group-next-unread-group 1 t)
4739 (gnus-summary-position-cursor)
4740 ret))
4742 (defun gnus-get-new-news-in-group (group)
4743 (and group
4744 (gnus-activate-group group)
4745 (progn
4746 (gnus-get-unread-articles-in-group
4747 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4748 (gnus-gethash group gnus-active-hashtb))
4749 (gnus-group-update-group-line)
4750 t)))
4752 (defun gnus-group-fetch-faq (group)
4753 "Fetch the FAQ for the current group."
4754 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4755 (or group (error "No group name given"))
4756 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group))))
4757 (if (not (file-exists-p file))
4758 (error "No such file: %s" file)
4759 (find-file file))))
4761 (defun gnus-group-describe-group (force &optional group)
4762 "Display a description of the current newsgroup."
4763 (interactive (list current-prefix-arg (gnus-group-group-name)))
4764 (and force (setq gnus-description-hashtb nil))
4765 (let ((method (gnus-find-method-for-group group))
4766 desc)
4767 (or group (error "No group name given"))
4768 (and (or (and gnus-description-hashtb
4769 ;; We check whether this group's method has been
4770 ;; queried for a description file.
4771 (gnus-gethash
4772 (gnus-group-prefixed-name "" method)
4773 gnus-description-hashtb))
4774 (setq desc (gnus-group-get-description group))
4775 (gnus-read-descriptions-file method))
4776 (message
4777 (or desc (gnus-gethash group gnus-description-hashtb)
4778 "No description available")))))
4780 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4781 (defun gnus-group-describe-all-groups (&optional force)
4782 "Pop up a buffer with descriptions of all newsgroups."
4783 (interactive "P")
4784 (and force (setq gnus-description-hashtb nil))
4785 (if (not (or gnus-description-hashtb
4786 (gnus-read-all-descriptions-files)))
4787 (error "Couldn't request descriptions file"))
4788 (let ((buffer-read-only nil)
4790 (erase-buffer)
4791 (mapatoms
4792 (lambda (group)
4793 (setq b (point))
4794 (insert (format " *: %-20s %s\n" (symbol-name group)
4795 (symbol-value group)))
4796 (add-text-properties
4797 b (1+ b) (list 'gnus-group group
4798 'gnus-unread t 'gnus-marked nil
4799 'gnus-level (1+ gnus-level-subscribed))))
4800 gnus-description-hashtb)
4801 (goto-char (point-min))
4802 (gnus-group-position-cursor)))
4804 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4805 (defun gnus-group-apropos (regexp &optional search-description)
4806 "List all newsgroups that have names that match a regexp."
4807 (interactive "sGnus apropos (regexp): ")
4808 (let ((prev "")
4809 (obuf (current-buffer))
4810 groups des)
4811 ;; Go through all newsgroups that are known to Gnus.
4812 (mapatoms
4813 (lambda (group)
4814 (and (symbol-name group)
4815 (string-match regexp (symbol-name group))
4816 (setq groups (cons (symbol-name group) groups))))
4817 gnus-active-hashtb)
4818 ;; Go through all descriptions that are known to Gnus.
4819 (if search-description
4820 (mapatoms
4821 (lambda (group)
4822 (and (string-match regexp (symbol-value group))
4823 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4824 (setq groups (cons (symbol-name group) groups))))
4825 gnus-description-hashtb))
4826 (if (not groups)
4827 (gnus-message 3 "No groups matched \"%s\"." regexp)
4828 ;; Print out all the groups.
4829 (save-excursion
4830 (pop-to-buffer "*Gnus Help*")
4831 (buffer-disable-undo (current-buffer))
4832 (erase-buffer)
4833 (setq groups (sort groups 'string<))
4834 (while groups
4835 ;; Groups may be entered twice into the list of groups.
4836 (if (not (string= (car groups) prev))
4837 (progn
4838 (insert (setq prev (car groups)) "\n")
4839 (if (and gnus-description-hashtb
4840 (setq des (gnus-gethash (car groups)
4841 gnus-description-hashtb)))
4842 (insert " " des "\n"))))
4843 (setq groups (cdr groups)))
4844 (goto-char (point-min))))
4845 (pop-to-buffer obuf)))
4847 (defun gnus-group-description-apropos (regexp)
4848 "List all newsgroups that have names or descriptions that match a regexp."
4849 (interactive "sGnus description apropos (regexp): ")
4850 (if (not (or gnus-description-hashtb
4851 (gnus-read-all-descriptions-files)))
4852 (error "Couldn't request descriptions file"))
4853 (gnus-group-apropos regexp t))
4855 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4856 (defun gnus-group-list-matching (level regexp &optional all lowest)
4857 "List all groups with unread articles that match REGEXP.
4858 If the prefix LEVEL is non-nil, it should be a number that says which
4859 level to cut off listing groups.
4860 If ALL, also list groups with no unread articles.
4861 If LOWEST, don't list groups with level lower than LOWEST."
4862 (interactive "P\nsList newsgroups matching: ")
4863 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4864 all (or lowest 1) regexp)
4865 (goto-char (point-min))
4866 (gnus-group-position-cursor))
4868 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4869 "List all groups that match REGEXP.
4870 If the prefix LEVEL is non-nil, it should be a number that says which
4871 level to cut off listing groups.
4872 If LOWEST, don't list groups with level lower than LOWEST."
4873 (interactive "P\nsList newsgroups matching: ")
4874 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4876 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4877 (defun gnus-group-save-newsrc ()
4878 "Save the Gnus startup files."
4879 (interactive)
4880 (gnus-save-newsrc-file))
4882 (defun gnus-group-restart (&optional arg)
4883 "Force Gnus to read the .newsrc file."
4884 (interactive "P")
4885 (gnus-save-newsrc-file)
4886 (gnus-setup-news 'force)
4887 (gnus-group-list-groups arg))
4889 (defun gnus-group-read-init-file ()
4890 "Read the Gnus elisp init file."
4891 (interactive)
4892 (gnus-read-init-file))
4894 (defun gnus-group-check-bogus-groups (&optional silent)
4895 "Check bogus newsgroups.
4896 If given a prefix, don't ask for confirmation before removing a bogus
4897 group."
4898 (interactive "P")
4899 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4900 (gnus-group-list-groups))
4902 (defun gnus-group-edit-global-kill (&optional article group)
4903 "Edit the global kill file.
4904 If GROUP, edit that local kill file instead."
4905 (interactive "P")
4906 (setq gnus-current-kill-article article)
4907 (gnus-kill-file-edit-file group)
4908 (gnus-message
4910 (substitute-command-keys
4911 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4913 (defun gnus-group-edit-local-kill (article group)
4914 "Edit a local kill file."
4915 (interactive (list nil (gnus-group-group-name)))
4916 (gnus-group-edit-global-kill article group))
4918 (defun gnus-group-force-update ()
4919 "Update `.newsrc' file."
4920 (interactive)
4921 (gnus-save-newsrc-file))
4923 (defun gnus-group-suspend ()
4924 "Suspend the current Gnus session.
4925 In fact, cleanup buffers except for group mode buffer.
4926 The hook gnus-suspend-gnus-hook is called before actually suspending."
4927 (interactive)
4928 (run-hooks 'gnus-suspend-gnus-hook)
4929 ;; Kill Gnus buffers except for group mode buffer.
4930 (let ((group-buf (get-buffer gnus-group-buffer)))
4931 ;; Do this on a separate list in case the user does a ^G before we finish
4932 (let ((gnus-buffer-list
4933 (delq group-buf (delq gnus-dribble-buffer
4934 (append gnus-buffer-list nil)))))
4935 (while gnus-buffer-list
4936 (gnus-kill-buffer (car gnus-buffer-list))
4937 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4938 (if group-buf
4939 (progn
4940 (setq gnus-buffer-list (list group-buf))
4941 (bury-buffer group-buf)
4942 (delete-windows-on group-buf t)))))
4944 (defun gnus-group-clear-dribble ()
4945 "Clear all information from the dribble buffer."
4946 (interactive)
4947 (gnus-dribble-clear))
4949 (defun gnus-group-exit ()
4950 "Quit reading news after updating .newsrc.eld and .newsrc.
4951 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4952 (interactive)
4953 (if (or noninteractive ;For gnus-batch-kill
4954 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4955 (not gnus-interactive-exit) ;Without confirmation
4956 gnus-expert-user
4957 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4958 (progn
4959 (run-hooks 'gnus-exit-gnus-hook)
4960 ;; Offer to save data from non-quitted summary buffers.
4961 (gnus-offer-save-summaries)
4962 ;; Save the newsrc file(s).
4963 (gnus-save-newsrc-file)
4964 ;; Kill-em-all.
4965 (gnus-close-backends)
4966 ;; Reset everything.
4967 (gnus-clear-system))))
4969 (defun gnus-close-backends ()
4970 ;; Send a close request to all backends that support such a request.
4971 (let ((methods gnus-valid-select-methods)
4972 func)
4973 (while methods
4974 (if (fboundp (setq func (intern (concat (car (car methods))
4975 "-request-close"))))
4976 (funcall func))
4977 (setq methods (cdr methods)))))
4979 (defun gnus-group-quit ()
4980 "Quit reading news without updating .newsrc.eld or .newsrc.
4981 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4982 (interactive)
4983 (if (or noninteractive ;For gnus-batch-kill
4984 (zerop (buffer-size))
4985 (not (gnus-server-opened gnus-select-method))
4986 gnus-expert-user
4987 (not gnus-current-startup-file)
4988 (gnus-yes-or-no-p
4989 (format "Quit reading news without saving %s? "
4990 (file-name-nondirectory gnus-current-startup-file))))
4991 (progn
4992 (run-hooks 'gnus-exit-gnus-hook)
4993 (if gnus-use-full-window
4994 (delete-other-windows)
4995 (gnus-remove-some-windows))
4996 (gnus-dribble-save)
4997 (gnus-close-backends)
4998 (gnus-clear-system))))
5000 (defun gnus-offer-save-summaries ()
5001 (save-excursion
5002 (let ((buflist (buffer-list))
5003 buffers bufname)
5004 (while buflist
5005 (and (setq bufname (buffer-name (car buflist)))
5006 (string-match "Summary" bufname)
5007 (save-excursion
5008 (set-buffer bufname)
5009 ;; We check that this is, indeed, a summary buffer.
5010 (eq major-mode 'gnus-summary-mode))
5011 (setq buffers (cons bufname buffers)))
5012 (setq buflist (cdr buflist)))
5013 (and buffers
5014 (map-y-or-n-p
5015 "Update summary buffer %s? "
5016 (lambda (buf)
5017 (set-buffer buf)
5018 (gnus-summary-exit))
5019 buffers)))))
5021 (defun gnus-group-describe-briefly ()
5022 "Give a one line description of the group mode commands."
5023 (interactive)
5024 (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")))
5026 (defun gnus-group-browse-foreign-server (method)
5027 "Browse a foreign news server.
5028 If called interactively, this function will ask for a select method
5029 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5030 If not, METHOD should be a list where the first element is the method
5031 and the second element is the address."
5032 (interactive
5033 (list (let ((how (completing-read
5034 "Which backend: "
5035 (append gnus-valid-select-methods gnus-server-alist)
5036 nil t "nntp")))
5037 ;; We either got a backend name or a virtual server name.
5038 ;; If the first, we also need an address.
5039 (if (assoc how gnus-valid-select-methods)
5040 (list (intern how)
5041 ;; Suggested by mapjph@bath.ac.uk.
5042 (completing-read
5043 "Address: "
5044 (mapcar (lambda (server) (list server))
5045 gnus-secondary-servers)))
5046 ;; We got a server name, so we find the method.
5047 (gnus-server-to-method how)))))
5048 (gnus-browse-foreign-server method))
5052 ;;; Browse Server Mode
5055 (defvar gnus-browse-mode-hook nil)
5056 (defvar gnus-browse-mode-map nil)
5057 (put 'gnus-browse-mode 'mode-class 'special)
5059 (if gnus-browse-mode-map
5061 (setq gnus-browse-mode-map (make-keymap))
5062 (suppress-keymap gnus-browse-mode-map)
5063 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5064 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5065 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5066 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5067 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5068 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5069 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5070 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5071 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5072 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5073 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5074 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5075 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5076 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5077 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5078 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5079 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5080 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5083 (defvar gnus-browse-current-method nil)
5084 (defvar gnus-browse-return-buffer nil)
5086 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5088 (defun gnus-browse-foreign-server (method &optional return-buffer)
5089 (setq gnus-browse-current-method method)
5090 (setq gnus-browse-return-buffer return-buffer)
5091 (let ((gnus-select-method method)
5092 groups group)
5093 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5094 (or (gnus-check-server method)
5095 (error "Unable to contact server: %s" (gnus-status-message method)))
5096 (or (gnus-request-list method)
5097 (error "Couldn't request list: %s" (gnus-status-message method)))
5098 (get-buffer-create gnus-browse-buffer)
5099 (gnus-add-current-to-buffer-list)
5100 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5101 (gnus-configure-windows 'browse)
5102 (buffer-disable-undo (current-buffer))
5103 (let ((buffer-read-only nil))
5104 (erase-buffer))
5105 (gnus-browse-mode)
5106 (setq mode-line-buffer-identification
5107 (format
5108 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5109 (save-excursion
5110 (set-buffer nntp-server-buffer)
5111 (let ((cur (current-buffer)))
5112 (goto-char (point-min))
5113 (or (string= gnus-ignored-newsgroups "")
5114 (delete-matching-lines gnus-ignored-newsgroups))
5115 (while (re-search-forward
5116 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5117 (goto-char (match-end 1))
5118 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5119 (match-end 1))
5120 (max 0 (- (1+ (read cur)) (read cur))))
5121 groups)))))
5122 (setq groups (sort groups
5123 (lambda (l1 l2)
5124 (string< (car l1) (car l2)))))
5125 (let ((buffer-read-only nil))
5126 (while groups
5127 (setq group (car groups))
5128 (insert
5129 (format "K%7d: %s\n" (cdr group) (car group)))
5130 (setq groups (cdr groups))))
5131 (switch-to-buffer (current-buffer))
5132 (goto-char (point-min))
5133 (gnus-group-position-cursor)))
5135 (defun gnus-browse-mode ()
5136 "Major mode for browsing a foreign server.
5138 All normal editing commands are switched off.
5140 \\<gnus-browse-mode-map>
5141 The only things you can do in this buffer is
5143 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5144 The group will be inserted into the group buffer upon exit from this
5145 buffer.
5147 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5149 3) `\\[gnus-browse-exit]' to return to the group buffer."
5150 (interactive)
5151 (kill-all-local-variables)
5152 (if gnus-visual (gnus-browse-make-menu-bar))
5153 (setq mode-line-modified "-- ")
5154 (make-local-variable 'mode-line-format)
5155 (setq mode-line-format (copy-sequence mode-line-format))
5156 (and (equal (nth 3 mode-line-format) " ")
5157 (setcar (nthcdr 3 mode-line-format) ""))
5158 (setq major-mode 'gnus-browse-mode)
5159 (setq mode-name "Browse Server")
5160 (setq mode-line-process nil)
5161 (use-local-map gnus-browse-mode-map)
5162 (buffer-disable-undo (current-buffer))
5163 (setq truncate-lines t)
5164 (setq buffer-read-only t)
5165 (run-hooks 'gnus-browse-mode-hook))
5167 (defun gnus-browse-read-group (&optional no-article)
5168 "Enter the group at the current line."
5169 (interactive)
5170 (let ((group (gnus-browse-group-name)))
5171 (or (gnus-group-read-ephemeral-group
5172 group gnus-browse-current-method nil
5173 (cons (current-buffer) 'browse))
5174 (error "Couldn't enter %s" group))))
5176 (defun gnus-browse-select-group ()
5177 "Select the current group."
5178 (interactive)
5179 (gnus-browse-read-group 'no))
5181 (defun gnus-browse-next-group (n)
5182 "Go to the next group."
5183 (interactive "p")
5184 (prog1
5185 (forward-line n)
5186 (gnus-group-position-cursor)))
5188 (defun gnus-browse-prev-group (n)
5189 "Go to the next group."
5190 (interactive "p")
5191 (gnus-browse-next-group (- n)))
5193 (defun gnus-browse-unsubscribe-current-group (arg)
5194 "(Un)subscribe to the next ARG groups."
5195 (interactive "p")
5196 (and (eobp)
5197 (error "No group at current line."))
5198 (let ((ward (if (< arg 0) -1 1))
5199 (arg (abs arg)))
5200 (while (and (> arg 0)
5201 (not (eobp))
5202 (gnus-browse-unsubscribe-group)
5203 (zerop (gnus-browse-next-group ward)))
5204 (setq arg (1- arg)))
5205 (gnus-group-position-cursor)
5206 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5207 arg))
5209 (defun gnus-browse-group-name ()
5210 (save-excursion
5211 (beginning-of-line)
5212 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5214 (gnus-group-prefixed-name
5215 (buffer-substring (match-beginning 1) (match-end 1))
5216 gnus-browse-current-method))))
5218 (defun gnus-browse-unsubscribe-group ()
5219 "Toggle subscription of the current group in the browse buffer."
5220 (let ((sub nil)
5221 (buffer-read-only nil)
5222 group)
5223 (save-excursion
5224 (beginning-of-line)
5225 ;; If this group it killed, then we want to subscribe it.
5226 (if (= (following-char) ?K) (setq sub t))
5227 (setq group (gnus-browse-group-name))
5228 (delete-char 1)
5229 (if sub
5230 (progn
5231 (gnus-group-change-level
5232 (list t group gnus-level-default-subscribed
5233 nil nil gnus-browse-current-method)
5234 gnus-level-default-subscribed gnus-level-killed
5235 (and (car (nth 1 gnus-newsrc-alist))
5236 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5237 gnus-newsrc-hashtb))
5239 (insert ? ))
5240 (gnus-group-change-level
5241 group gnus-level-killed gnus-level-default-subscribed)
5242 (insert ?K)))
5245 (defun gnus-browse-exit ()
5246 "Quit browsing and return to the group buffer."
5247 (interactive)
5248 (if (eq major-mode 'gnus-browse-mode)
5249 (kill-buffer (current-buffer)))
5250 (if gnus-browse-return-buffer
5251 (gnus-configure-windows 'server 'force)
5252 (gnus-configure-windows 'group 'force)
5253 (gnus-group-list-groups nil)))
5255 (defun gnus-browse-describe-briefly ()
5256 "Give a one line description of the group mode commands."
5257 (interactive)
5258 (gnus-message 6
5259 (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")))
5263 ;;; Gnus summary mode
5266 (defvar gnus-summary-mode-map nil)
5267 (defvar gnus-summary-mark-map nil)
5268 (defvar gnus-summary-mscore-map nil)
5269 (defvar gnus-summary-article-map nil)
5270 (defvar gnus-summary-thread-map nil)
5271 (defvar gnus-summary-goto-map nil)
5272 (defvar gnus-summary-exit-map nil)
5273 (defvar gnus-summary-interest-map nil)
5274 (defvar gnus-summary-sort-map nil)
5275 (defvar gnus-summary-backend-map nil)
5276 (defvar gnus-summary-save-map nil)
5277 (defvar gnus-summary-wash-map nil)
5278 (defvar gnus-summary-wash-hide-map nil)
5279 (defvar gnus-summary-wash-highlight-map nil)
5280 (defvar gnus-summary-wash-time-map nil)
5281 (defvar gnus-summary-help-map nil)
5283 (put 'gnus-summary-mode 'mode-class 'special)
5285 (if gnus-summary-mode-map
5287 (setq gnus-summary-mode-map (make-keymap))
5288 (suppress-keymap gnus-summary-mode-map)
5290 ;; Non-orthogonal keys
5292 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5293 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5294 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5295 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5296 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5297 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5298 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5299 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5300 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5301 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5302 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5303 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5304 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5305 (define-key gnus-summary-mode-map
5306 "\M-s" 'gnus-summary-search-article-forward)
5307 (define-key gnus-summary-mode-map
5308 "\M-r" 'gnus-summary-search-article-backward)
5309 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5310 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5311 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5312 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5313 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5314 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5315 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5316 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5317 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5318 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5319 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5320 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5321 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5322 (define-key gnus-summary-mode-map
5323 "k" 'gnus-summary-kill-same-subject-and-select)
5324 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5325 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5326 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5327 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5328 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5329 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5330 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5331 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5332 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5333 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5334 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5335 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5336 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5337 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5338 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5339 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5340 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5341 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5342 (define-key gnus-summary-mode-map
5343 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5344 (define-key gnus-summary-mode-map
5345 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5346 (define-key gnus-summary-mode-map
5347 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5348 (define-key gnus-summary-mode-map
5349 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5350 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5351 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5352 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5353 (define-key gnus-summary-mode-map
5354 "\C-x\C-s" 'gnus-summary-reselect-current-group)
5355 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5356 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5357 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5358 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5359 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5360 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5361 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5362 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5363 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5364 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5365 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5366 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5367 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5368 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5369 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5370 (define-key gnus-summary-mode-map "V" 'gnus-version)
5371 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5372 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5373 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5374 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5375 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5376 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5377 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5378 (define-key gnus-summary-mode-map
5379 "x" 'gnus-summary-remove-lines-marked-as-read)
5380 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5381 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5382 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5383 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5384 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5385 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5386 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5387 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5388 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5389 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5392 ;; Sort of orthogonal keymap
5393 (define-prefix-command 'gnus-summary-mark-map)
5394 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5395 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5396 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5397 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5398 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5399 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5400 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5401 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5402 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5403 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5404 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5405 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5406 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5407 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5408 (define-key gnus-summary-mark-map
5409 "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5410 (define-key gnus-summary-mark-map
5411 "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5412 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5413 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5414 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5415 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5416 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5417 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5418 (define-key gnus-summary-mark-map
5419 "k" 'gnus-summary-kill-same-subject-and-select)
5420 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5422 (define-prefix-command 'gnus-summary-mscore-map)
5423 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5424 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5425 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5426 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5427 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5429 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5431 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5433 (define-prefix-command 'gnus-summary-goto-map)
5434 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5435 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5436 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5437 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5438 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5439 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5440 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5441 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5442 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5443 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5444 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5445 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5446 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5447 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5450 (define-prefix-command 'gnus-summary-thread-map)
5451 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5452 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5453 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5454 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5455 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5456 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5457 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5458 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5459 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5460 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5461 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5462 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5463 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5464 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5467 (define-prefix-command 'gnus-summary-exit-map)
5468 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5469 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5470 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5471 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5472 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5473 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5474 (define-key gnus-summary-exit-map
5475 "n" 'gnus-summary-catchup-and-goto-next-group)
5476 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5477 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5478 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5479 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5482 (define-prefix-command 'gnus-summary-article-map)
5483 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5484 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5485 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5486 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5487 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5488 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5489 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5490 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5491 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5492 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5493 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5494 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5495 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5496 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5500 (define-prefix-command 'gnus-summary-wash-map)
5501 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5503 (define-prefix-command 'gnus-summary-wash-hide-map)
5504 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5505 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5506 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5507 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5508 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5509 (define-key gnus-summary-wash-hide-map
5510 "\C-c" 'gnus-article-hide-citation-maybe)
5512 (define-prefix-command 'gnus-summary-wash-highlight-map)
5513 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5514 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5515 (define-key gnus-summary-wash-highlight-map
5516 "h" 'gnus-article-highlight-headers)
5517 (define-key gnus-summary-wash-highlight-map
5518 "c" 'gnus-article-highlight-citation)
5519 (define-key gnus-summary-wash-highlight-map
5520 "s" 'gnus-article-highlight-signature)
5522 (define-prefix-command 'gnus-summary-wash-time-map)
5523 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5524 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5525 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5526 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5527 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5529 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5530 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5531 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5532 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5533 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5534 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5535 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5536 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5537 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5538 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5541 (define-prefix-command 'gnus-summary-help-map)
5542 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5543 (define-key gnus-summary-help-map "v" 'gnus-version)
5544 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5545 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5546 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5547 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5550 (define-prefix-command 'gnus-summary-backend-map)
5551 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5552 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5553 (define-key gnus-summary-backend-map "\M-\C-e"
5554 'gnus-summary-expire-articles-now)
5555 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5556 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5557 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5558 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5559 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5560 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5561 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5564 (define-prefix-command 'gnus-summary-save-map)
5565 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5566 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5567 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5568 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5569 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5570 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5571 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5572 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5573 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5575 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5577 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5578 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5579 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5580 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5581 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5582 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5583 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5584 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5585 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5586 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5588 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5590 ; (define-prefix-command 'gnus-summary-sort-map)
5591 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5592 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5593 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5594 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5595 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5596 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5598 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5599 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5605 (defun gnus-summary-mode (&optional group)
5606 "Major mode for reading articles.
5608 All normal editing commands are switched off.
5609 \\<gnus-summary-mode-map>
5610 Each line in this buffer represents one article. To read an
5611 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5612 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5613 respectively.
5615 You can also post articles and send mail from this buffer. To
5616 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5617 of an article, type `\\[gnus-summary-reply]'.
5619 There are approx. one gazillion commands you can execute in this
5620 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5622 The following commands are available:
5624 \\{gnus-summary-mode-map}"
5625 (interactive)
5626 (if gnus-visual (gnus-summary-make-menu-bar))
5627 (kill-all-local-variables)
5628 (let ((locals gnus-summary-local-variables))
5629 (while locals
5630 (if (consp (car locals))
5631 (progn
5632 (make-local-variable (car (car locals)))
5633 (set (car (car locals)) (eval (cdr (car locals)))))
5634 (make-local-variable (car locals))
5635 (set (car locals) nil))
5636 (setq locals (cdr locals))))
5637 (gnus-make-thread-indent-array)
5638 (setq mode-line-modified "-- ")
5639 (make-local-variable 'mode-line-format)
5640 (setq mode-line-format (copy-sequence mode-line-format))
5641 (and (equal (nth 3 mode-line-format) " ")
5642 (setcar (nthcdr 3 mode-line-format) ""))
5643 (setq major-mode 'gnus-summary-mode)
5644 (setq mode-name "Summary")
5645 (make-local-variable 'minor-mode-alist)
5646 (use-local-map gnus-summary-mode-map)
5647 (buffer-disable-undo (current-buffer))
5648 (setq buffer-read-only t) ;Disable modification
5649 (setq truncate-lines t)
5650 (setq selective-display t)
5651 (setq selective-display-ellipses t) ;Display `...'
5652 (setq buffer-display-table gnus-summary-display-table)
5653 (setq gnus-newsgroup-name group)
5654 (run-hooks 'gnus-summary-mode-hook))
5656 (defun gnus-summary-make-display-table ()
5657 ;; Change the display table. Odd characters have a tendency to mess
5658 ;; up nicely formatted displays - we make all possible glyphs
5659 ;; display only a single character.
5661 ;; We start from the standard display table, if any.
5662 (setq gnus-summary-display-table
5663 (or (copy-sequence standard-display-table)
5664 (make-display-table)))
5665 ;; Nix out all the control chars...
5666 (let ((i 32))
5667 (while (>= (setq i (1- i)) 0)
5668 (aset gnus-summary-display-table i [??])))
5669 ;; ... but not newline and cr, of course. (cr is necessary for the
5670 ;; selective display).
5671 (aset gnus-summary-display-table ?\n nil)
5672 (aset gnus-summary-display-table ?\r nil)
5673 ;; We nix out any glyphs over 126 that are not set already.
5674 (let ((i 256))
5675 (while (>= (setq i (1- i)) 127)
5676 ;; Only modify if the entry is nil.
5677 (or (aref gnus-summary-display-table i)
5678 (aset gnus-summary-display-table i [??])))))
5680 (defun gnus-summary-clear-local-variables ()
5681 (let ((locals gnus-summary-local-variables))
5682 (while locals
5683 (if (consp (car locals))
5684 (and (vectorp (car (car locals)))
5685 (set (car (car locals)) nil))
5686 (and (vectorp (car locals))
5687 (set (car locals) nil)))
5688 (setq locals (cdr locals)))))
5690 ;; Some summary mode macros.
5692 ;; Return a header specified by a NUMBER.
5693 (defun gnus-get-header-by-number (number)
5694 (save-excursion
5695 (set-buffer gnus-summary-buffer)
5696 (or gnus-newsgroup-headers-hashtb-by-number
5697 (gnus-make-headers-hashtable-by-number))
5698 (gnus-gethash (int-to-string number)
5699 gnus-newsgroup-headers-hashtb-by-number)))
5701 ;; Fast version of the function above.
5702 (defmacro gnus-get-header-by-num (number)
5703 (` (gnus-gethash (int-to-string (, number))
5704 gnus-newsgroup-headers-hashtb-by-number)))
5706 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5707 "Search for article forward.
5708 If UNREAD is non-nil, only unread articles are selected.
5709 If SUBJECT is non-nil, the article which has the same subject will be
5710 searched for.
5711 If BACKWARD is non-nil, the search will be performed backwards instead."
5712 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5714 (defmacro gnus-summary-search-backward (&optional unread subject)
5715 "Search for article backward.
5716 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5717 If 2nd optional argument SUBJECT is non-nil, the article which has
5718 the same subject will be searched for."
5719 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5721 (defmacro gnus-summary-article-number (&optional number-or-nil)
5722 "The article number of the article on the current line.
5723 If there isn's an article number here, then we return the current
5724 article number."
5725 (if number-or-nil
5726 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5727 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5728 gnus-current-article)))
5730 (defmacro gnus-summary-thread-level ()
5731 "The thread level of the article on the current line."
5732 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5735 (defmacro gnus-summary-article-mark ()
5736 "The mark on the current line."
5737 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5739 (defun gnus-summary-subject-string ()
5740 "Return current subject string or nil if nothing."
5741 (let ((article (gnus-summary-article-number))
5742 header)
5743 (and article
5744 (setq header (gnus-get-header-by-num article))
5745 (vectorp header)
5746 (mail-header-subject header))))
5748 ;; Various summary mode internalish functions.
5750 (defun gnus-mouse-pick-article (e)
5751 (interactive "e")
5752 (mouse-set-point e)
5753 (gnus-summary-next-page nil t))
5755 (defun gnus-summary-setup-buffer (group)
5756 "Initialize summary buffer."
5757 (let ((buffer (concat "*Summary " group "*")))
5758 (if (get-buffer buffer)
5759 (progn
5760 (set-buffer buffer)
5761 (not gnus-newsgroup-begin))
5762 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5763 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5764 (gnus-add-current-to-buffer-list)
5765 (gnus-summary-mode group)
5766 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5767 (setq gnus-newsgroup-name group)
5768 t)))
5770 (defun gnus-set-global-variables ()
5771 ;; Set the global equivalents of the summary buffer-local variables
5772 ;; to the latest values they had. These reflect the summary buffer
5773 ;; that was in action when the last article was fetched.
5774 (if (eq major-mode 'gnus-summary-mode)
5775 (progn
5776 (setq gnus-summary-buffer (current-buffer))
5777 (let ((name gnus-newsgroup-name)
5778 (marked gnus-newsgroup-marked)
5779 (unread gnus-newsgroup-unreads)
5780 (headers gnus-current-headers)
5781 (score-file gnus-current-score-file))
5782 (save-excursion
5783 (set-buffer gnus-group-buffer)
5784 (setq gnus-newsgroup-name name)
5785 (setq gnus-newsgroup-marked marked)
5786 (setq gnus-newsgroup-unreads unread)
5787 (setq gnus-current-headers headers)
5788 (setq gnus-current-score-file score-file))))))
5790 (defun gnus-summary-insert-dummy-line (sformat subject number)
5791 (if (not sformat)
5792 (setq sformat gnus-summary-dummy-line-format-spec))
5793 (let (b)
5794 (beginning-of-line)
5795 (setq b (point))
5796 (insert (eval sformat))
5797 (add-text-properties
5798 b (1+ b)
5799 (list 'gnus-number number
5800 'gnus-mark gnus-dummy-mark
5801 'gnus-level 0))))
5803 (defvar gnus-thread-indent-array nil)
5804 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5805 (defun gnus-make-thread-indent-array ()
5806 (let ((n 200))
5807 (if (and gnus-thread-indent-array
5808 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5810 (setq gnus-thread-indent-array (make-vector 201 "")
5811 gnus-thread-indent-array-level gnus-thread-indent-level)
5812 (while (>= n 0)
5813 (aset gnus-thread-indent-array n
5814 (make-string (* n gnus-thread-indent-level) ? ))
5815 (setq n (1- n))))))
5817 (defun gnus-summary-insert-line
5818 (sformat header level current unread replied expirable subject-or-nil
5819 &optional dummy score process)
5820 (or sformat (setq sformat gnus-summary-line-format-spec))
5821 (let* ((indentation (aref gnus-thread-indent-array level))
5822 (lines (mail-header-lines header))
5823 (score (or score gnus-summary-default-score 0))
5824 (score-char
5825 (if (or (null gnus-summary-default-score)
5826 (<= (abs (- score gnus-summary-default-score))
5827 gnus-summary-zcore-fuzz)) ?
5828 (if (< score gnus-summary-default-score)
5829 gnus-score-below-mark gnus-score-over-mark)))
5830 (replied (cond (process gnus-process-mark)
5831 (replied gnus-replied-mark)
5832 (t gnus-unread-mark)))
5833 (from (mail-header-from header))
5834 (name (cond
5835 ((string-match "(.+)" from)
5836 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5837 ((string-match "<[^>]+> *$" from)
5838 (let ((beg (match-beginning 0)))
5839 (or (and (string-match "^\"[^\"]*\"" from)
5840 (substring from (1+ (match-beginning 0))
5841 (1- (match-end 0))))
5842 (substring from 0 beg))))
5843 (t from)))
5844 (subject (mail-header-subject header))
5845 (number (mail-header-number header))
5846 (opening-bracket (if dummy ?\< ?\[))
5847 (closing-bracket (if dummy ?\> ?\]))
5848 (buffer-read-only nil)
5849 (b (progn (beginning-of-line) (point))))
5850 (or (numberp lines) (setq lines 0))
5851 (insert (eval sformat))
5852 (add-text-properties
5853 b (1+ b) (list 'gnus-number number
5854 'gnus-mark (or unread gnus-unread-mark)
5855 'gnus-level level))))
5857 (defun gnus-summary-update-line (&optional dont-update)
5858 ;; Update summary line after change.
5859 (or (not gnus-summary-default-score)
5860 gnus-summary-inhibit-highlight
5861 (let ((gnus-summary-inhibit-highlight t)
5862 (article (gnus-summary-article-number)))
5863 (progn
5864 (or dont-update
5865 (if (and gnus-summary-mark-below
5866 (< (gnus-summary-article-score)
5867 gnus-summary-mark-below))
5868 (and (not (memq article gnus-newsgroup-marked))
5869 (not (memq article gnus-newsgroup-dormant))
5870 (memq article gnus-newsgroup-unreads)
5871 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5872 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5873 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5874 (and gnus-visual
5875 (run-hooks 'gnus-summary-update-hook))))))
5877 (defun gnus-summary-update-lines (&optional beg end)
5878 ;; Mark article as read (or not) by taking into account scores.
5879 (let ((beg (or beg (point-min)))
5880 (end (or end (point-max))))
5881 (if (or (not gnus-summary-default-score)
5882 gnus-summary-inhibit-highlight)
5884 (let ((gnus-summary-inhibit-highlight t)
5885 article)
5886 (save-excursion
5887 (set-buffer gnus-summary-buffer)
5888 (goto-char beg)
5889 (beginning-of-line)
5890 (while (and (not (eobp)) (< (point) end))
5891 (if (and gnus-summary-mark-below
5892 (< (or (cdr (assq
5893 (setq article (get-text-property
5894 (point) 'gnus-number))
5895 gnus-newsgroup-scored))
5896 gnus-summary-default-score 0)
5897 gnus-summary-mark-below))
5898 ;; We want to possibly mark it as read...
5899 (and (not (memq article gnus-newsgroup-marked))
5900 (not (memq article gnus-newsgroup-dormant))
5901 (memq article gnus-newsgroup-unreads)
5902 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5903 ;; We want to possibly mark it as unread.
5904 (and (eq (get-text-property (point) 'gnus-mark)
5905 gnus-low-score-mark)
5906 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5907 ;; Do the visual highlights at the same time.
5908 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5909 (forward-line 1)))))))
5911 (defvar gnus-tmp-gathered nil)
5913 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5914 ;; Sum up all elements (and sub-elements) in a list.
5915 (let* ((number
5916 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5917 (if (and (consp thread) (cdr thread))
5918 (apply
5919 '+ 1 (mapcar
5920 'gnus-summary-number-of-articles-in-thread
5921 (cdr thread)))
5922 1)))
5923 (if char
5924 (if (> number 1) gnus-not-empty-thread-mark
5925 gnus-empty-thread-mark)
5926 number)))
5928 (defun gnus-summary-read-group
5929 (group &optional show-all no-article kill-buffer)
5930 "Start reading news in newsgroup GROUP.
5931 If SHOW-ALL is non-nil, already read articles are also listed.
5932 If NO-ARTICLE is non-nil, no article is selected initially."
5933 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5934 (let* ((new-group (gnus-summary-setup-buffer group))
5935 (quit-config (gnus-group-quit-config group))
5936 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5937 (cond
5938 ((not new-group)
5939 (gnus-set-global-variables)
5940 (gnus-kill-buffer kill-buffer)
5941 (gnus-configure-windows 'summary 'force)
5942 (gnus-set-mode-line 'summary)
5943 (gnus-summary-position-cursor)
5944 (message "")
5946 ((null did-select)
5947 (and (eq major-mode 'gnus-summary-mode)
5948 (not (equal (current-buffer) kill-buffer))
5949 (progn
5950 (kill-buffer (current-buffer))
5951 (if (not quit-config)
5952 (progn
5953 (set-buffer gnus-group-buffer)
5954 (gnus-group-jump-to-group group)
5955 (gnus-group-next-unread-group 1))
5956 (if (not (buffer-name (car quit-config)))
5957 (gnus-configure-windows 'group 'force)
5958 (set-buffer (car quit-config))
5959 (and (eq major-mode 'gnus-summary-mode)
5960 (gnus-set-global-variables))
5961 (gnus-configure-windows (cdr quit-config))))))
5962 (message "Can't select group")
5963 nil)
5964 ((eq did-select 'quit)
5965 (and (eq major-mode 'gnus-summary-mode)
5966 (not (equal (current-buffer) kill-buffer))
5967 (kill-buffer (current-buffer)))
5968 (gnus-kill-buffer kill-buffer)
5969 (if (not quit-config)
5970 (progn
5971 (set-buffer gnus-group-buffer)
5972 (gnus-group-jump-to-group group)
5973 (gnus-group-next-unread-group 1)
5974 (gnus-configure-windows 'group 'force))
5975 (if (not (buffer-name (car quit-config)))
5976 (gnus-configure-windows 'group 'force)
5977 (set-buffer (car quit-config))
5978 (and (eq major-mode 'gnus-summary-mode)
5979 (gnus-set-global-variables))
5980 (gnus-configure-windows (cdr quit-config))))
5981 (signal 'quit nil))
5983 (gnus-set-global-variables)
5984 ;; Save the active value in effect when the group was entered.
5985 (setq gnus-newsgroup-active
5986 (gnus-copy-sequence
5987 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5988 ;; You can change the subjects in this hook.
5989 (run-hooks 'gnus-select-group-hook)
5990 ;; Do score processing.
5991 (and gnus-use-scoring (gnus-possibly-score-headers))
5992 (gnus-update-format-specifications)
5993 ;; Generate the summary buffer.
5994 (gnus-summary-prepare)
5995 (if (zerop (buffer-size))
5996 (cond (gnus-newsgroup-dormant
5997 (gnus-summary-show-all-dormant))
5998 ((and gnus-newsgroup-scored show-all)
5999 (gnus-summary-show-all-expunged))))
6000 ;; Function `gnus-apply-kill-file' must be called in this hook.
6001 (run-hooks 'gnus-apply-kill-hook)
6002 (if (zerop (buffer-size))
6003 (progn
6004 ;; This newsgroup is empty.
6005 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
6006 (gnus-message 6 "No unread news")
6007 (gnus-kill-buffer kill-buffer)
6008 nil)
6009 ;;(save-excursion
6010 ;; (if kill-buffer
6011 ;; (let ((gnus-summary-buffer kill-buffer))
6012 ;; (gnus-configure-windows 'group))))
6013 ;; Hide conversation thread subtrees. We cannot do this in
6014 ;; gnus-summary-prepare-hook since kill processing may not
6015 ;; work with hidden articles.
6016 (and gnus-show-threads
6017 gnus-thread-hide-subtree
6018 (gnus-summary-hide-all-threads))
6019 ;; Show first unread article if requested.
6020 (goto-char (point-min))
6021 (if (and (not no-article)
6022 gnus-auto-select-first
6023 (gnus-summary-first-unread-article))
6025 (gnus-configure-windows 'summary 'force))
6026 (gnus-set-mode-line 'summary)
6027 (gnus-summary-position-cursor)
6028 ;; If in async mode, we send some info to the backend.
6029 (and gnus-newsgroup-async
6030 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
6031 (gnus-request-asynchronous
6032 gnus-newsgroup-name
6033 (if (and gnus-asynchronous-article-function
6034 (fboundp gnus-asynchronous-article-function))
6035 (funcall gnus-asynchronous-article-function
6036 gnus-newsgroup-threads)
6037 gnus-newsgroup-threads)))
6038 (gnus-kill-buffer kill-buffer)
6039 (if (not (get-buffer-window gnus-group-buffer))
6041 ;; gotta use windows, because recenter does wierd stuff if
6042 ;; the current buffer ain't the displayed window.
6043 (let ((owin (selected-window)))
6044 (select-window (get-buffer-window gnus-group-buffer))
6045 (and (gnus-group-goto-group group)
6046 (recenter))
6047 (select-window owin))))
6048 t))))
6050 (defun gnus-summary-prepare ()
6051 ;; Generate the summary buffer.
6052 (let ((buffer-read-only nil))
6053 (erase-buffer)
6054 (gnus-summary-prepare-threads
6055 (if gnus-show-threads
6056 (gnus-gather-threads
6057 (gnus-sort-threads
6058 (if (and gnus-summary-expunge-below
6059 (not gnus-fetch-old-headers))
6060 (gnus-make-threads-and-expunge)
6061 (gnus-make-threads))))
6062 gnus-newsgroup-headers)
6063 'cull)
6064 (gnus-summary-update-lines)
6065 ;; Create the header hashtb.
6066 (gnus-make-headers-hashtable-by-number)
6067 ;; Call hooks for modifying summary buffer.
6068 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6069 (goto-char (point-min))
6070 (run-hooks 'gnus-summary-prepare-hook)))
6072 (defun gnus-gather-threads (threads)
6073 "Gather threads that have lost their roots."
6074 (if (not gnus-summary-make-false-root)
6075 threads
6076 (let ((hashtb (gnus-make-hashtable 1023))
6077 (prev threads)
6078 (result threads)
6079 subject hthread whole-subject)
6080 (while threads
6081 (setq whole-subject
6082 (setq subject (mail-header-subject (car (car threads)))))
6083 (if gnus-summary-gather-subject-limit
6084 (or (and (numberp gnus-summary-gather-subject-limit)
6085 (> (length subject) gnus-summary-gather-subject-limit)
6086 (setq subject
6087 (substring subject 0
6088 gnus-summary-gather-subject-limit)))
6089 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6090 (setq subject (gnus-simplify-subject-fuzzy subject))))
6091 (setq subject (gnus-simplify-subject-re subject)))
6092 (if (setq hthread
6093 (gnus-gethash subject hashtb))
6094 (progn
6095 (or (stringp (car (car hthread)))
6096 (setcar hthread (list whole-subject (car hthread))))
6097 (setcdr (car hthread) (nconc (cdr (car hthread))
6098 (list (car threads))))
6099 (setcdr prev (cdr threads))
6100 (setq threads prev))
6101 (gnus-sethash subject threads hashtb))
6102 (setq prev threads)
6103 (setq threads (cdr threads)))
6104 result)))
6106 (defun gnus-make-threads ()
6107 ;; This function takes the dependencies already made by
6108 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6109 ;; through the dependecies in the hash table and finds all the
6110 ;; roots. Roots do not refer back to any valid articles.
6111 (gnus-message 6 "Threading...")
6112 (let (roots new-roots)
6113 (and gnus-fetch-old-headers
6114 (eq gnus-headers-retrieved-by 'nov)
6115 (gnus-build-old-threads))
6116 (mapatoms
6117 (lambda (refs)
6118 (if (not (car (symbol-value refs)))
6119 (setq roots (append (cdr (symbol-value refs)) roots))
6120 ;; Ok, these refer back to valid articles, but if
6121 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6122 ;; the root has the same subject as its children. The children
6123 ;; that do not are made into roots and removed from the list
6124 ;; of children.
6125 (or gnus-thread-ignore-subject
6126 (let* ((prev (symbol-value refs))
6127 (subject (gnus-simplify-subject-re
6128 (mail-header-subject (car prev))))
6129 (headers (cdr prev)))
6130 (while headers
6131 (if (not (string= subject
6132 (gnus-simplify-subject-re
6133 (mail-header-subject (car headers)))))
6134 (progn
6135 (setq new-roots (cons (car headers) new-roots))
6136 (setcdr prev (cdr headers)))
6137 (setq prev headers))
6138 (setq headers (cdr headers)))))))
6139 gnus-newsgroup-dependencies)
6141 ;; We enter the new roots into the dependencies structure to
6142 ;; ensure that any possible later thread-regeneration will be
6143 ;; possible.
6144 (let ((r new-roots))
6145 (while r
6146 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6147 (list nil (car r)) gnus-newsgroup-dependencies)
6148 (setq r (cdr r))))
6150 (setq roots (nconc new-roots roots))
6152 (prog1
6153 (mapcar 'gnus-trim-thread
6154 (apply 'append
6155 (mapcar 'gnus-cut-thread
6156 (mapcar 'gnus-make-sub-thread roots))))
6157 (gnus-message 6 "Threading...done"))))
6160 (defun gnus-make-threads-and-expunge ()
6161 ;; This function takes the dependencies already made by
6162 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6163 ;; through the dependecies in the hash table and finds all the
6164 ;; roots. Roots do not refer back to any valid articles.
6165 (gnus-message 6 "Threading...")
6166 (let ((default (or gnus-summary-default-score 0))
6167 (below gnus-summary-expunge-below)
6168 roots article new-roots)
6169 (and gnus-fetch-old-headers
6170 (eq gnus-headers-retrieved-by 'nov)
6171 (gnus-build-old-threads))
6172 (mapatoms
6173 (lambda (refs)
6174 (if (not (car (symbol-value refs)))
6175 ;; These articles do not refer back to any other articles -
6176 ;; they are roots.
6177 (let ((headers (cdr (symbol-value refs))))
6178 ;; We weed out the low-scored articles.
6179 (while headers
6180 (if (not (< (or (cdr (assq (mail-header-number (car headers))
6181 gnus-newsgroup-scored)) default)
6182 below))
6183 ;; It is over.
6184 (setq roots (cons (car headers) roots))
6185 ;; It is below, so we mark it as read.
6186 (setq gnus-newsgroup-unreads
6187 (delq (mail-header-number (car headers))
6188 gnus-newsgroup-unreads))
6189 (setq gnus-newsgroup-reads
6190 (cons (cons (mail-header-number (car headers))
6191 gnus-low-score-mark)
6192 gnus-newsgroup-reads)))
6193 (setq headers (cdr headers))))
6194 ;; Ok, these refer back to valid articles, but if
6195 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6196 ;; the root has the same subject as its children. The children
6197 ;; that do not are made into roots and removed from the list
6198 ;; of children.
6199 (or gnus-thread-ignore-subject
6200 (let* ((prev (symbol-value refs))
6201 (subject (gnus-simplify-subject-re
6202 (mail-header-subject (car prev))))
6203 (headers (cdr prev)))
6204 (while headers
6205 (if (not (string= subject
6206 (gnus-simplify-subject-re
6207 (mail-header-subject (car headers)))))
6208 (progn
6209 (if (not (< (or (cdr (assq (mail-header-number
6210 (car headers))
6211 gnus-newsgroup-scored))
6212 default) below))
6213 (setq new-roots (cons (car headers) new-roots))
6214 (setq gnus-newsgroup-unreads
6215 (delq (mail-header-number (car headers))
6216 gnus-newsgroup-unreads))
6217 (setq gnus-newsgroup-reads
6218 (cons (cons (mail-header-number (car headers))
6219 gnus-low-score-mark)
6220 gnus-newsgroup-reads)))
6221 (setcdr prev (cdr headers)))
6222 (setq prev headers))
6223 (setq headers (cdr headers)))))
6224 ;; If this article is expunged, some of the children might be
6225 ;; roots.
6226 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs)))
6227 gnus-newsgroup-scored)) default)
6228 below)
6229 (let* ((prev (symbol-value refs))
6230 (headers (cdr prev)))
6231 (while headers
6232 (setq article (mail-header-number (car headers)))
6233 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6234 default) below))
6235 (progn (setq new-roots (cons (car headers) new-roots))
6236 (setq prev headers))
6237 (setq gnus-newsgroup-unreads
6238 (delq article gnus-newsgroup-unreads))
6239 (setq gnus-newsgroup-reads
6240 (cons (cons article gnus-low-score-mark)
6241 gnus-newsgroup-reads))
6242 (setcdr prev (cdr headers)))
6243 (setq headers (cdr headers))))
6244 ;; It was not expunged, but we look at expunged children.
6245 (let* ((prev (symbol-value refs))
6246 (headers (cdr prev))
6247 article)
6248 (while headers
6249 (setq article (mail-header-number (car headers)))
6250 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6251 default) below))
6252 (setq prev headers)
6253 (setq gnus-newsgroup-unreads
6254 (delq article gnus-newsgroup-unreads))
6255 (setq gnus-newsgroup-reads
6256 (cons (cons article gnus-low-score-mark)
6257 gnus-newsgroup-reads))
6258 (setcdr prev (cdr headers)))
6259 (setq headers (cdr headers)))))))
6260 gnus-newsgroup-dependencies)
6262 ;; We enter the new roots into the dependencies structure to
6263 ;; ensure that any possible later thread-regeneration will be
6264 ;; possible.
6265 (let ((r new-roots))
6266 (while r
6267 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6268 (list nil (car r)) gnus-newsgroup-dependencies)
6269 (setq r (cdr r))))
6271 (setq roots (nconc new-roots roots))
6273 (prog1
6274 (mapcar 'gnus-trim-thread
6275 (apply 'append
6276 (mapcar 'gnus-cut-thread
6277 (mapcar 'gnus-make-sub-thread roots))))
6278 (gnus-message 6 "Threading...done"))))
6281 (defun gnus-cut-thread (thread)
6282 ;; Remove leaf dormant or ancient articles from THREAD.
6283 (let ((head (car thread))
6284 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6285 (if (and (null tail)
6286 (let ((number (mail-header-number head)))
6287 (or (memq number gnus-newsgroup-ancient)
6288 (memq number gnus-newsgroup-dormant)
6289 (and gnus-summary-expunge-below
6290 (eq gnus-fetch-old-headers 'some)
6291 (< (or (cdr (assq number gnus-newsgroup-scored))
6292 gnus-summary-default-score 0)
6293 gnus-summary-expunge-below)
6294 (progn
6295 (setq gnus-newsgroup-unreads
6296 (delq number gnus-newsgroup-unreads))
6297 (setq gnus-newsgroup-reads
6298 (cons (cons number gnus-low-score-mark)
6299 gnus-newsgroup-reads))
6300 t)))))
6302 (list (cons head tail)))))
6304 (defun gnus-trim-thread (thread)
6305 ;; Remove root ancient articles with only one child from THREAD.
6306 (if (and (eq gnus-fetch-old-headers 'some)
6307 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6308 (= (length thread) 2))
6309 (gnus-trim-thread (nth 1 thread))
6310 thread))
6312 (defun gnus-make-sub-thread (root)
6313 ;; This function makes a sub-tree for a node in the tree.
6314 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6315 gnus-newsgroup-dependencies)))))
6316 (cons root (mapcar 'gnus-make-sub-thread children))))
6318 (defun gnus-build-old-threads ()
6319 ;; Look at all the articles that refer back to old articles, and
6320 ;; fetch the headers for the articles that aren't there. This will
6321 ;; build complete threads - if the roots haven't been expired by the
6322 ;; server, that is.
6323 (let (id heads)
6324 (mapatoms
6325 (lambda (refs)
6326 (if (not (car (symbol-value refs)))
6327 (progn
6328 (setq heads (cdr (symbol-value refs)))
6329 (while heads
6330 (if (not (memq (mail-header-number (car heads))
6331 gnus-newsgroup-dormant))
6332 (progn
6333 (setq id (symbol-name refs))
6334 (while (and (setq id (gnus-build-get-header id))
6335 (not (car (gnus-gethash
6336 id gnus-newsgroup-dependencies)))))
6337 (setq heads nil))
6338 (setq heads (cdr heads)))))))
6339 gnus-newsgroup-dependencies)))
6341 (defun gnus-build-get-header (id)
6342 ;; Look through the buffer of NOV lines and find the header to
6343 ;; ID. Enter this line into the dependencies hash table, and return
6344 ;; the id of the parent article (if any).
6345 (let ((deps gnus-newsgroup-dependencies)
6346 found header)
6347 (prog1
6348 (save-excursion
6349 (set-buffer nntp-server-buffer)
6350 (goto-char (point-min))
6351 (while (and (not found) (search-forward id nil t))
6352 (beginning-of-line)
6353 (setq found (looking-at
6354 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6355 (regexp-quote id))))
6356 (or found (beginning-of-line 2)))
6357 (if found
6358 (let (ref)
6359 (beginning-of-line)
6360 (and
6361 (setq header (gnus-nov-parse-line
6362 (read (current-buffer)) deps))
6363 (setq ref (mail-header-references header))
6364 (string-match "\\(<[^>]+>\\) *$" ref)
6365 (substring ref (match-beginning 1) (match-end 1))))))
6366 (and header
6367 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6368 gnus-newsgroup-ancient (cons (mail-header-number header)
6369 gnus-newsgroup-ancient))))))
6371 ;; Re-build the thread containing ID.
6372 (defun gnus-rebuild-thread (id)
6373 (let ((dep gnus-newsgroup-dependencies)
6374 (buffer-read-only nil)
6375 parent headers refs thread art)
6376 (while (and id (setq headers
6377 (car (setq art (gnus-gethash (downcase id) dep)))))
6378 (setq parent art)
6379 (setq id (and (setq refs (mail-header-references headers))
6380 (string-match "\\(<[^>]+>\\) *$" refs)
6381 (substring refs (match-beginning 1) (match-end 1)))))
6382 (setq thread (gnus-make-sub-thread (car parent)))
6383 (gnus-rebuild-remove-articles thread)
6384 (let ((beg (point)))
6385 (gnus-summary-prepare-threads (list thread))
6386 (gnus-summary-update-lines beg (point)))))
6388 ;; Delete all lines in the summary buffer that correspond to articles
6389 ;; in this thread.
6390 (defun gnus-rebuild-remove-articles (thread)
6391 (and (gnus-summary-goto-subject (mail-header-number (car thread)))
6392 (gnus-delete-line))
6393 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6395 (defun gnus-sort-threads (threads)
6396 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6397 (let ((fun gnus-thread-sort-functions))
6398 (while fun
6399 (gnus-message 6 "Sorting with %S..." fun)
6400 (setq threads (sort threads (car fun))
6401 fun (cdr fun))))
6402 (if gnus-thread-sort-functions
6403 (gnus-message 6 "Sorting...done"))
6404 threads)
6406 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6407 (defmacro gnus-thread-header (thread)
6408 ;; Return header of first article in THREAD.
6409 ;; Note that THREAD must never, evr be anything else than a variable -
6410 ;; using some other form will lead to serious barfage.
6411 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6412 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6413 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6414 (vector thread) 2))
6416 (defun gnus-thread-sort-by-number (h1 h2)
6417 "Sort threads by root article number."
6418 (< (mail-header-number (gnus-thread-header h1))
6419 (mail-header-number (gnus-thread-header h2))))
6421 (defun gnus-thread-sort-by-author (h1 h2)
6422 "Sort threads by root author."
6423 (string-lessp
6424 (let ((extract (funcall
6425 gnus-extract-address-components
6426 (mail-header-from (gnus-thread-header h1)))))
6427 (or (car extract) (cdr extract)))
6428 (let ((extract (funcall
6429 gnus-extract-address-components
6430 (mail-header-from (gnus-thread-header h2)))))
6431 (or (car extract) (cdr extract)))))
6433 (defun gnus-thread-sort-by-subject (h1 h2)
6434 "Sort threads by root subject."
6435 (string-lessp
6436 (downcase (gnus-simplify-subject-re
6437 (mail-header-subject (gnus-thread-header h1))))
6438 (downcase (gnus-simplify-subject-re
6439 (mail-header-subject (gnus-thread-header h2))))))
6441 (defun gnus-thread-sort-by-date (h1 h2)
6442 "Sort threads by root article date."
6443 (string-lessp
6444 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6445 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6447 (defun gnus-thread-sort-by-score (h1 h2)
6448 "Sort threads by root article score.
6449 Unscored articles will be counted as having a score of zero."
6450 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6451 gnus-newsgroup-scored))
6452 gnus-summary-default-score 0)
6453 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6454 gnus-newsgroup-scored))
6455 gnus-summary-default-score 0)))
6457 (defun gnus-thread-sort-by-total-score (h1 h2)
6458 "Sort threads by the sum of all scores in the thread.
6459 Unscored articles will be counted as having a score of zero."
6460 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6462 (defun gnus-thread-total-score (thread)
6463 ;; This function find the total score of THREAD.
6464 (if (consp thread)
6465 (if (stringp (car thread))
6466 (apply gnus-thread-score-function 0
6467 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6468 (gnus-thread-total-score-1 thread))
6469 (gnus-thread-total-score-1 (list thread))))
6471 (defun gnus-thread-total-score-1 (root)
6472 ;; This function find the total score of the thread below ROOT.
6473 (setq root (car root))
6474 (apply gnus-thread-score-function
6475 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6476 gnus-summary-default-score 0)
6477 (mapcar 'gnus-thread-total-score
6478 (cdr (gnus-gethash (downcase (mail-header-id root))
6479 gnus-newsgroup-dependencies)))))
6481 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6482 (defvar gnus-tmp-prev-subject "")
6484 (defun gnus-summary-prepare-threads (threads &optional cull)
6485 "Prepare summary buffer from THREADS and indentation LEVEL.
6486 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6487 or a straight list of headers."
6488 (message "Generating summary...")
6489 (let ((level 0)
6490 thread header number subject stack state gnus-tmp-gathered)
6491 (if (vectorp (car threads))
6492 ;; If this is a straight (sic) list of headers, then a
6493 ;; threaded summary display isn't required, so we just create
6494 ;; an unthreaded one.
6495 (gnus-summary-prepare-unthreaded threads cull)
6497 ;; Do the threaded display.
6499 (while (or threads stack)
6501 (if threads
6502 ;; If there are some threads, we do them before the
6503 ;; threads on the stack.
6504 (setq thread threads
6505 header (car (car thread)))
6506 ;; There were no current threads, so we pop something off
6507 ;; the stack.
6508 (setq state (car stack)
6509 level (car state)
6510 thread (cdr state)
6511 stack (cdr stack)
6512 header (car (car thread))))
6514 (if (stringp header)
6515 (progn
6516 ;; The header is a dummy root.
6517 (cond
6518 ((eq gnus-summary-make-false-root 'adopt)
6519 ;; We let the first article adopt the rest.
6520 (let ((th (car (cdr (car thread)))))
6521 (while (cdr th)
6522 (setq th (cdr th)))
6523 (setcdr th (cdr (cdr (car thread))))
6524 (setq gnus-tmp-gathered
6525 (nconc (mapcar
6526 (lambda (h) (mail-header-number (car h)))
6527 (cdr (cdr (car thread))))
6528 gnus-tmp-gathered))
6529 (setcdr (cdr (car thread)) nil))
6530 (setq level -1))
6531 ((eq gnus-summary-make-false-root 'empty)
6532 ;; We print adopted articles with empty subject fields.
6533 (setq gnus-tmp-gathered
6534 (nconc (mapcar
6535 (lambda (h) (mail-header-number (car h)))
6536 (cdr (cdr (car thread))))
6537 gnus-tmp-gathered))
6538 (setq level -1))
6539 ((eq gnus-summary-make-false-root 'dummy)
6540 ;; We output a dummy root.
6541 (gnus-summary-insert-dummy-line
6542 nil header (mail-header-number
6543 (car (car (cdr (car thread)))))))
6545 ;; We do not make a root for the gathered
6546 ;; sub-threads at all.
6547 (setq level -1))))
6549 (setq number (mail-header-number header)
6550 subject (mail-header-subject header))
6552 ;; Do the async thing.
6553 (and gnus-newsgroup-async
6554 (setq gnus-newsgroup-threads
6555 (cons (cons number (mail-header-lines header))
6556 gnus-newsgroup-threads)))
6558 ;; We may have to root out some bad articles...
6559 (and cull
6560 (= level 0)
6561 (cond ((and (memq (setq number (mail-header-number header))
6562 gnus-newsgroup-dormant)
6563 (null thread))
6564 (setq header nil))
6565 ((and gnus-summary-expunge-below
6566 (< (or (cdr (assq number gnus-newsgroup-scored))
6567 gnus-summary-default-score 0)
6568 gnus-summary-expunge-below))
6569 (setq header nil)
6570 (setq gnus-newsgroup-unreads
6571 (delq number gnus-newsgroup-unreads))
6572 (setq gnus-newsgroup-reads
6573 (cons (cons number gnus-low-score-mark)
6574 gnus-newsgroup-reads)))))
6576 (and
6577 header
6578 (progn
6579 (inline
6580 (gnus-summary-insert-line
6581 nil header level nil
6582 (cond
6583 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6584 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6585 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6586 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6587 (t (or (cdr (assq number gnus-newsgroup-reads))
6588 gnus-ancient-mark)))
6589 (memq number gnus-newsgroup-replied)
6590 (memq number gnus-newsgroup-expirable)
6591 (cond
6592 ((and gnus-thread-ignore-subject
6593 (not (string=
6594 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6595 (gnus-simplify-subject-re subject))))
6596 subject)
6597 ((zerop level)
6598 (if (and (eq gnus-summary-make-false-root 'empty)
6599 (memq number gnus-tmp-gathered))
6600 gnus-summary-same-subject
6601 subject))
6602 (t gnus-summary-same-subject))
6603 (and (eq gnus-summary-make-false-root 'adopt)
6604 (memq number gnus-tmp-gathered))
6605 (cdr (assq number gnus-newsgroup-scored))
6606 (memq number gnus-newsgroup-processable))
6608 (setq gnus-tmp-prev-subject subject)))))
6610 (if (nth 1 thread)
6611 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6612 (setq level (1+ level))
6613 (setq threads (cdr (car thread))))))
6614 (message "Generating summary...done"))
6618 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6619 (let (header number)
6621 ;; Do the async thing, if that is required.
6622 (if gnus-newsgroup-async
6623 (setq gnus-newsgroup-threads
6624 (mapcar (lambda (h)
6625 (cons (mail-header-number h) (mail-header-lines h)))
6626 headers)))
6628 (while headers
6629 (setq header (car headers)
6630 headers (cdr headers)
6631 number (mail-header-number header))
6633 ;; We may have to root out some bad articles...
6634 (cond
6635 ((and cull
6636 (memq (setq number (mail-header-number header))
6637 gnus-newsgroup-dormant)))
6638 ((and cull gnus-summary-expunge-below
6639 (< (or (cdr (assq number gnus-newsgroup-scored))
6640 gnus-summary-default-score 0)
6641 gnus-summary-expunge-below))
6642 (setq gnus-newsgroup-unreads
6643 (delq number gnus-newsgroup-unreads))
6644 (setq gnus-newsgroup-reads
6645 (cons (cons number gnus-low-score-mark)
6646 gnus-newsgroup-reads)))
6648 (gnus-summary-insert-line
6649 nil header 0 nil
6650 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6651 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6652 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6653 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6654 (t (or (cdr (assq number gnus-newsgroup-reads))
6655 gnus-ancient-mark)))
6656 (memq number gnus-newsgroup-replied)
6657 (memq number gnus-newsgroup-expirable)
6658 (mail-header-subject header) nil
6659 (cdr (assq number gnus-newsgroup-scored))
6660 (memq number gnus-newsgroup-processable)))))))
6662 (defun gnus-select-newsgroup (group &optional read-all)
6663 "Select newsgroup GROUP.
6664 If READ-ALL is non-nil, all articles in the group are selected."
6665 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6666 (info (nth 2 entry))
6667 articles)
6669 (or (gnus-check-server
6670 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6671 (error "Couldn't open server"))
6673 (or (and entry (not (eq (car entry) t))) ; Either it's active...
6674 (gnus-activate-group group) ; Or we can activate it...
6675 (progn ; Or we bug out.
6676 (kill-buffer (current-buffer))
6677 (error "Couldn't request group %s: %s"
6678 group (gnus-status-message group))))
6680 (setq gnus-newsgroup-name group)
6681 (setq gnus-newsgroup-unselected nil)
6682 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6684 (and gnus-asynchronous
6685 (gnus-check-backend-function
6686 'request-asynchronous gnus-newsgroup-name)
6687 (setq gnus-newsgroup-async
6688 (gnus-request-asynchronous gnus-newsgroup-name)))
6690 (setq articles (gnus-articles-to-read group read-all))
6692 (cond
6693 ((null articles)
6694 (gnus-message 3 "Couldn't select newsgroup")
6695 'quit)
6696 ((eq articles 0) nil)
6698 ;; Init the dependencies hash table.
6699 (setq gnus-newsgroup-dependencies
6700 (gnus-make-hashtable (length articles)))
6701 ;; Retrieve the headers and read them in.
6702 (gnus-message 5 "Fetching headers...")
6703 (setq gnus-newsgroup-headers
6704 (if (eq 'nov (setq gnus-headers-retrieved-by
6705 ;; This is a naughty hack. To get the
6706 ;; retrieval of old headers to work, we
6707 ;; set `nntp-nov-gap' to nil (locally),
6708 ;; and then just retrieve the headers.
6709 ;; Mucho magic.
6710 (if gnus-fetch-old-headers
6711 (let (nntp-nov-gap)
6712 (gnus-retrieve-headers
6713 (if (not (eq 1 (car articles)))
6714 (cons 1 articles)
6715 articles)
6716 gnus-newsgroup-name))
6717 (gnus-retrieve-headers
6718 articles gnus-newsgroup-name))))
6719 (progn
6720 (gnus-get-newsgroup-headers-xover articles))
6721 ;; If we were to fetch old headers, but the backend didn't
6722 ;; support XOVER, then it is possible we fetched one article
6723 ;; that we shouldn't have. If that's the case, we remove it.
6724 (if (or (not gnus-fetch-old-headers)
6725 (eq 1 (car articles)))
6727 (save-excursion
6728 (set-buffer nntp-server-buffer)
6729 (goto-char (point-min))
6730 (and
6731 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6732 (delete-region ; So we delete this head.
6733 (point)
6734 (search-forward "\n.\n" nil t)))))
6735 (gnus-get-newsgroup-headers)))
6736 (gnus-message 5 "Fetching headers...done")
6737 ;; Remove canceled articles from the list of unread articles.
6738 (setq gnus-newsgroup-unreads
6739 (gnus-set-sorted-intersection
6740 gnus-newsgroup-unreads
6741 (mapcar (lambda (headers) (mail-header-number headers))
6742 gnus-newsgroup-headers)))
6743 ;; Adjust and set lists of article marks.
6744 (and info
6745 (let (marked)
6746 (gnus-adjust-marked-articles info)
6747 (setq gnus-newsgroup-marked
6748 (copy-sequence
6749 (cdr (assq 'tick (setq marked (nth 3 info))))))
6750 (setq gnus-newsgroup-replied
6751 (copy-sequence (cdr (assq 'reply marked))))
6752 (setq gnus-newsgroup-expirable
6753 (copy-sequence (cdr (assq 'expire marked))))
6754 (setq gnus-newsgroup-killed
6755 (copy-sequence (cdr (assq 'killed marked))))
6756 (setq gnus-newsgroup-bookmarks
6757 (copy-sequence (cdr (assq 'bookmark marked))))
6758 (setq gnus-newsgroup-dormant
6759 (copy-sequence (cdr (assq 'dormant marked))))
6760 (setq gnus-newsgroup-scored
6761 (copy-sequence (cdr (assq 'score marked))))
6762 (setq gnus-newsgroup-processable nil)))
6763 ;; Check whether auto-expire is to be done in this group.
6764 (setq gnus-newsgroup-auto-expire
6765 (or (and (stringp gnus-auto-expirable-newsgroups)
6766 (string-match gnus-auto-expirable-newsgroups group))
6767 (memq 'auto-expire (nth 5 info))))
6768 ;; First and last article in this newsgroup.
6769 (and gnus-newsgroup-headers
6770 (setq gnus-newsgroup-begin
6771 (mail-header-number (car gnus-newsgroup-headers)))
6772 (setq gnus-newsgroup-end
6773 (mail-header-number
6774 (gnus-last-element gnus-newsgroup-headers))))
6775 (setq gnus-reffed-article-number -1)
6776 ;; GROUP is successfully selected.
6777 (or gnus-newsgroup-headers t)))))
6779 (defun gnus-articles-to-read (group read-all)
6780 ;; Find out what articles the user wants to read.
6781 (let* ((articles
6782 ;; Select all articles if `read-all' is non-nil, or if all the
6783 ;; unread articles are dormant articles.
6784 (if (or read-all
6785 (= (length gnus-newsgroup-unreads)
6786 (length gnus-newsgroup-dormant)))
6787 (gnus-uncompress-range
6788 (gnus-gethash group gnus-active-hashtb))
6789 gnus-newsgroup-unreads))
6790 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6791 (scored (length scored-list))
6792 (number (length articles))
6793 (marked (+ (length gnus-newsgroup-marked)
6794 (length gnus-newsgroup-dormant)))
6795 (select
6796 (cond
6797 ((numberp read-all)
6798 read-all)
6800 (condition-case ()
6801 (cond ((and (or (<= scored marked)
6802 (= scored number))
6803 (numberp gnus-large-newsgroup)
6804 (> number gnus-large-newsgroup))
6805 (let ((input
6806 (read-string
6807 (format
6808 "How many articles from %s (default %d): "
6809 gnus-newsgroup-name number))))
6810 (if (string-match "^[ \t]*$" input)
6811 number input)))
6812 ((and (> scored marked) (< scored number))
6813 (let ((input
6814 (read-string
6815 (format
6816 "%s %s (%d scored, %d total): "
6817 "How many articles from"
6818 group scored number))))
6819 (if (string-match "^[ \t]*$" input)
6820 number input)))
6821 (t number))
6822 (quit nil))))))
6823 (setq select (if (stringp select) (string-to-number select) select))
6824 (if (or (null select) (zerop select))
6825 select
6826 (if (and (not (zerop scored)) (<= (abs select) scored))
6827 (progn
6828 (setq articles (sort scored-list '<))
6829 (setq number (length articles)))
6830 (setq articles (copy-sequence articles)))
6832 (if (< (abs select) number)
6833 (if (< select 0)
6834 ;; Select the N oldest articles.
6835 (setcdr (nthcdr (1- (abs select)) articles) nil)
6836 ;; Select the N most recent articles.
6837 (setq articles (nthcdr (- number select) articles))))
6838 (setq gnus-newsgroup-unselected
6839 (gnus-sorted-intersection
6840 gnus-newsgroup-unreads
6841 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6842 articles)))
6844 (defun gnus-killed-articles (killed articles)
6845 (let (out)
6846 (while articles
6847 (if (inline (gnus-member-of-range (car articles) killed))
6848 (setq out (cons (car articles) out)))
6849 (setq articles (cdr articles)))
6850 out))
6852 (defun gnus-adjust-marked-articles (info &optional active)
6853 "Remove all marked articles that are no longer legal."
6854 (let ((marked-lists (nth 3 info))
6855 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6856 m prev)
6857 ;; There are many types of marked articles.
6858 (while marked-lists
6859 (setq m (cdr (setq prev (car marked-lists))))
6860 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6861 ;; Make sure that all ticked articles are a subset of the
6862 ;; unread/unselected articles.
6863 (while m
6864 (if (or (memq (car m) gnus-newsgroup-unreads)
6865 (memq (car m) gnus-newsgroup-unselected))
6866 (setq prev m)
6867 (setcdr prev (cdr m)))
6868 (setq m (cdr m))))
6869 ((eq 'score (car prev))
6870 ;; Scored articles should be a subset of
6871 ;; unread/unselected articles.
6872 (while m
6873 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6874 (memq (car (car m)) gnus-newsgroup-unreads))
6875 (setq prev m)
6876 (setcdr prev (cdr m)))
6877 (setq m (cdr m))))
6878 ((eq 'bookmark (car prev))
6879 ;; Bookmarks should be a subset of active articles.
6880 (while m
6881 (if (< (car (car m)) (car active))
6882 (setcdr prev (cdr m))
6883 (setq prev m))
6884 (setq m (cdr m))))
6885 ((eq 'killed (car prev))
6886 ;; Articles that have been through the kill process are
6887 ;; to be a subset of active articles.
6888 (while (and m (< (or (and (numberp (car m)) (car m))
6889 (cdr (car m)))
6890 (car active)))
6891 (setcdr prev (cdr m))
6892 (setq m (cdr m)))
6893 (if (and m (< (or (and (numberp (car m)) (car m))
6894 (car (car m)))
6895 (car active)))
6896 (setcar (if (numberp (car m)) m (car m)) (car active))))
6897 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6898 ;; The replied and expirable articles have to be articles
6899 ;; that are active.
6900 (while m
6901 (if (< (car m) (car active))
6902 (setcdr prev (cdr m))
6903 (setq prev m))
6904 (setq m (cdr m)))))
6905 (setq marked-lists (cdr marked-lists)))
6906 ;; Remove all lists that are empty.
6907 (setq marked-lists (nth 3 info))
6908 (if marked-lists
6909 (progn
6910 (while (= 1 (length (car marked-lists)))
6911 (setq marked-lists (cdr marked-lists)))
6912 (setq m (cdr (setq prev marked-lists)))
6913 (while m
6914 (if (= 1 (length (car m)))
6915 (setcdr prev (cdr m))
6916 (setq prev m))
6917 (setq m (cdr m)))
6918 (setcar (nthcdr 3 info) marked-lists)))
6919 ;; Finally, if there are no marked lists at all left, and if there
6920 ;; are no elements after the lists in the info list, we just chop
6921 ;; the info list off before the marked lists.
6922 (and (null marked-lists)
6923 (not (nthcdr 4 info))
6924 (setcdr (nthcdr 2 info) nil)))
6925 info)
6927 (defun gnus-set-marked-articles
6928 (info ticked replied expirable killed dormant bookmark score)
6929 "Enter the various lists of marked articles into the newsgroup info list."
6930 (let (newmarked)
6931 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6932 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6933 (and expirable (setq newmarked (cons (cons 'expire expirable)
6934 newmarked)))
6935 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6936 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6937 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6938 newmarked)))
6939 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6940 (if (nthcdr 3 info)
6941 (progn
6942 (setcar (nthcdr 3 info) newmarked)
6943 (and (not newmarked)
6944 (not (nthcdr 4 info))
6945 (setcdr (nthcdr 2 info) nil)))
6946 (if newmarked
6947 (setcdr (nthcdr 2 info) (list newmarked))))))
6949 (defun gnus-add-marked-articles (group type articles &optional info force)
6950 ;; Add ARTICLES of TYPE to the info of GROUP.
6951 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6952 ;; add, but replace marked articles of TYPE with ARTICLES.
6953 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6954 marked m)
6955 (or (not info)
6956 (and (not (setq marked (nthcdr 3 info)))
6957 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6958 (and (not (setq m (assq type (car marked))))
6959 (setcar marked (cons (cons type articles) (car marked))))
6960 (if force
6961 (setcdr m articles)
6962 (nconc m articles)))))
6964 (defun gnus-set-mode-line (where)
6965 "This function sets the mode line of the article or summary buffers.
6966 If WHERE is `summary', the summary mode line format will be used."
6967 (if (memq where gnus-updated-mode-lines)
6968 (let (mode-string)
6969 (save-excursion
6970 (set-buffer gnus-summary-buffer)
6971 (let* ((mformat (if (eq where 'article)
6972 gnus-article-mode-line-format-spec
6973 gnus-summary-mode-line-format-spec))
6974 (group-name gnus-newsgroup-name)
6975 (article-number (or gnus-current-article 0))
6976 (unread (- (length gnus-newsgroup-unreads)
6977 (length gnus-newsgroup-dormant)))
6978 (unread-and-unticked
6979 (- unread (length gnus-newsgroup-marked)))
6980 (unselected (length gnus-newsgroup-unselected))
6981 (unread-and-unselected
6982 (cond ((and (zerop unread-and-unticked)
6983 (zerop unselected)) "")
6984 ((zerop unselected)
6985 (format "{%d more}" unread-and-unticked))
6986 (t (format "{%d(+%d) more}"
6987 unread-and-unticked unselected))))
6988 (subject
6989 (if gnus-current-headers
6990 (mail-header-subject gnus-current-headers) ""))
6991 (max-len (and gnus-mode-non-string-length
6992 (- (frame-width) gnus-mode-non-string-length)))
6993 header);; passed as argument to any user-format-funcs
6994 (setq mode-string (eval mformat))
6995 (or (numberp max-len)
6996 (setq max-len (length mode-string)))
6997 (if (< max-len 4) (setq max-len 4))
6998 (if (> (length mode-string) max-len)
6999 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
7000 ;; function `substring' might cut on a middle
7001 ;; of multi-octet character.
7002 (setq mode-string
7003 (concat (gnus-truncate-string mode-string (- max-len 3))
7004 "...")))
7005 (setq mode-string (format (format "%%-%ds" max-len)
7006 mode-string))))
7007 (setq mode-line-buffer-identification mode-string)
7008 (set-buffer-modified-p t))))
7010 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
7011 "Go through the HEADERS list and add all Xrefs to a hash table.
7012 The resulting hash table is returned, or nil if no Xrefs were found."
7013 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
7014 (prefix (if (and
7015 (gnus-group-foreign-p from-newsgroup)
7016 (not (memq 'virtual
7017 (assoc (symbol-name (car from-method))
7018 gnus-valid-select-methods))))
7019 (gnus-group-real-prefix from-newsgroup)))
7020 (xref-hashtb (make-vector 63 0))
7021 start group entry number xrefs header)
7022 (while headers
7023 (setq header (car headers))
7024 (if (and (setq xrefs (mail-header-xref header))
7025 (not (memq (mail-header-number header) unreads)))
7026 (progn
7027 (setq start 0)
7028 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
7029 (setq start (match-end 0))
7030 (setq group (concat prefix (substring xrefs (match-beginning 1)
7031 (match-end 1))))
7032 (setq number
7033 (string-to-int (substring xrefs (match-beginning 2)
7034 (match-end 2))))
7035 (if (setq entry (gnus-gethash group xref-hashtb))
7036 (setcdr entry (cons number (cdr entry)))
7037 (gnus-sethash group (cons number nil) xref-hashtb)))))
7038 (setq headers (cdr headers)))
7039 (if start xref-hashtb nil)))
7041 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
7042 "Look through all the headers and mark the Xrefs as read."
7043 (let ((virtual (memq 'virtual
7044 (assoc (symbol-name (car (gnus-find-method-for-group
7045 from-newsgroup)))
7046 gnus-valid-select-methods)))
7047 name entry info xref-hashtb idlist method
7048 nth4)
7049 (save-excursion
7050 (set-buffer gnus-group-buffer)
7051 (if (setq xref-hashtb
7052 (gnus-create-xref-hashtb from-newsgroup headers unreads))
7053 (mapatoms
7054 (lambda (group)
7055 (if (string= from-newsgroup (setq name (symbol-name group)))
7057 (setq idlist (symbol-value group))
7058 ;; Dead groups are not updated.
7059 (if (and (prog1
7060 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7061 info (nth 2 entry))
7062 (if (stringp (setq nth4 (nth 4 info)))
7063 (setq nth4 (gnus-server-to-method nth4))))
7064 ;; Only do the xrefs if the group has the same
7065 ;; select method as the group we have just read.
7066 (or (gnus-methods-equal-p
7067 nth4 (gnus-find-method-for-group from-newsgroup))
7068 virtual
7069 (equal nth4
7070 (setq method (gnus-find-method-for-group
7071 from-newsgroup)))
7072 (and (equal (car nth4) (car method))
7073 (equal (nth 1 nth4) (nth 1 method))))
7074 gnus-use-cross-reference
7075 (or (not (eq gnus-use-cross-reference t))
7076 virtual
7077 ;; Only do cross-references on subscribed
7078 ;; groups, if that is what is wanted.
7079 (<= (nth 1 info) gnus-level-subscribed)))
7080 (gnus-group-make-articles-read name idlist expirable))))
7081 xref-hashtb)))))
7083 (defun gnus-group-make-articles-read (group articles expirable)
7084 (let* ((num 0)
7085 (entry (gnus-gethash group gnus-newsrc-hashtb))
7086 (info (nth 2 entry))
7087 (active (gnus-gethash group gnus-active-hashtb))
7088 exps expirable range)
7089 ;; First peel off all illegal article numbers.
7090 (if active
7091 (let ((ids articles)
7092 (ticked (cdr (assq 'tick (nth 3 info))))
7093 (dormant (cdr (assq 'dormant (nth 3 info))))
7094 id first)
7095 (setq exps nil)
7096 (while ids
7097 (setq id (car ids))
7098 (if (and first (> id (cdr active)))
7099 (progn
7100 ;; We'll end up in this situation in one particular
7101 ;; obscure situation. If you re-scan a group and get
7102 ;; a new article that is cross-posted to a different
7103 ;; group that has not been re-scanned, you might get
7104 ;; crossposted article that has a higher number than
7105 ;; Gnus believes possible. So we re-activate this
7106 ;; group as well. This might mean doing the
7107 ;; crossposting thingie will *increase* the number
7108 ;; of articles in some groups. Tsk, tsk.
7109 (setq active (or (gnus-activate-group group) active))))
7110 (if (or (> id (cdr active))
7111 (< id (car active))
7112 (memq id ticked)
7113 (memq id dormant))
7114 (setq articles (delq id articles)))
7115 (and (memq id expirable)
7116 (setq exps (cons id exps)))
7117 (setq ids (cdr ids)))))
7118 ;; Update expirable articles.
7119 (gnus-add-marked-articles nil 'expirable exps info)
7120 (and active
7121 (null (nth 2 info))
7122 (> (car active) 1)
7123 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7124 (setcar (nthcdr 2 info)
7125 (setq range
7126 (gnus-add-to-range
7127 (nth 2 info)
7128 (setq articles (sort articles '<)))))
7129 ;; Then we have to re-compute how many unread
7130 ;; articles there are in this group.
7131 (if active
7132 (progn
7133 (cond
7134 ((not range)
7135 (setq num (- (1+ (cdr active)) (car active))))
7136 ((not (listp (cdr range)))
7137 (setq num (- (cdr active) (- (1+ (cdr range))
7138 (car range)))))
7140 (while range
7141 (if (numberp (car range))
7142 (setq num (1+ num))
7143 (setq num (+ num (- (1+ (cdr (car range)))
7144 (car (car range))))))
7145 (setq range (cdr range)))
7146 (setq num (- (cdr active) num))))
7147 ;; Update the number of unread articles.
7148 (setcar
7149 entry
7150 (max 0 (- num
7151 (length (cdr (assq 'tick (nth 3 info))))
7152 (length
7153 (cdr (assq 'dormant (nth 3 info)))))))
7154 ;; Update the group buffer.
7155 (gnus-group-update-group group t)))))
7157 (defun gnus-methods-equal-p (m1 m2)
7158 (let ((m1 (or m1 gnus-select-method))
7159 (m2 (or m2 gnus-select-method)))
7160 (or (equal m1 m2)
7161 (and (eq (car m1) (car m2))
7162 (or (not (memq 'address (assoc (symbol-name (car m1))
7163 gnus-valid-select-methods)))
7164 (equal (nth 1 m1) (nth 1 m2)))))))
7166 (defsubst gnus-header-value ()
7167 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7169 (defvar gnus-newsgroup-none-id 0)
7171 (defun gnus-get-newsgroup-headers ()
7172 (setq gnus-article-internal-prepare-hook nil)
7173 (let ((cur nntp-server-buffer)
7174 (dependencies gnus-newsgroup-dependencies)
7175 headers id dep end ref)
7176 (save-excursion
7177 (set-buffer nntp-server-buffer)
7178 (goto-char (point-min))
7179 ;; Search to the beginning of the next header. Error messages
7180 ;; do not begin with 2 or 3.
7181 (while (re-search-forward "^[23][0-9]+ " nil t)
7182 (let ((header (make-vector 9 nil))
7183 (case-fold-search t)
7184 (p (point))
7185 in-reply-to)
7186 (setq id nil
7187 ref nil)
7188 (mail-header-set-number header (read cur))
7189 ;; This implementation of this function, with nine
7190 ;; search-forwards instead of the one re-search-forward and
7191 ;; a case (which basically was the old function) is actually
7192 ;; about twice as fast, even though it looks messier. You
7193 ;; can't have everything, I guess. Speed and elegance
7194 ;; doesn't always come hand in hand.
7195 (save-restriction
7196 (narrow-to-region (point) (or (save-excursion
7197 (search-forward "\n.\n" nil t))
7198 (point)))
7199 (if (search-forward "\nfrom: " nil t)
7200 (mail-header-set-from header (gnus-header-value))
7201 (mail-header-set-from header "(nobody)"))
7202 (goto-char p)
7203 (if (search-forward "\nsubject: " nil t)
7204 (mail-header-set-subject header (gnus-header-value))
7205 (mail-header-set-subject header "(none)"))
7206 (goto-char p)
7207 (and (search-forward "\nxref: " nil t)
7208 (mail-header-set-xref header (gnus-header-value)))
7209 (goto-char p)
7210 (or (numberp (and (search-forward "\nlines: " nil t)
7211 (mail-header-set-lines header (read cur))))
7212 (mail-header-set-lines header 0))
7213 (goto-char p)
7214 (and (search-forward "\ndate: " nil t)
7215 (mail-header-set-date header (gnus-header-value)))
7216 (goto-char p)
7217 (if (search-forward "\nmessage-id: " nil t)
7218 (mail-header-set-id header (setq id (gnus-header-value)))
7219 ;; If there was no message-id, we just fake one to make
7220 ;; subsequent routines simpler.
7221 (mail-header-set-id
7222 header
7223 (setq id (concat "none+"
7224 (int-to-string
7225 (setq gnus-newsgroup-none-id
7226 (1+ gnus-newsgroup-none-id)))))))
7227 (goto-char p)
7228 (if (search-forward "\nreferences: " nil t)
7229 (progn
7230 (mail-header-set-references header (gnus-header-value))
7231 (setq end (match-end 0))
7232 (save-excursion
7233 (setq ref
7234 (downcase
7235 (buffer-substring
7236 (progn
7237 (end-of-line)
7238 (search-backward ">" end t)
7239 (1+ (point)))
7240 (progn
7241 (search-backward "<" end t)
7242 (point)))))))
7243 ;; Get the references from the in-reply-to header if there
7244 ;; ware no references and the in-reply-to header looks
7245 ;; promising.
7246 (if (and (search-forward "\nin-reply-to: " nil t)
7247 (setq in-reply-to (gnus-header-value))
7248 (string-match "<[^>]+>" in-reply-to))
7249 (progn
7250 (mail-header-set-references
7251 header
7252 (setq ref (substring in-reply-to (match-beginning 0)
7253 (match-end 0))))
7254 (setq ref (downcase ref)))
7255 (setq ref "none")))
7256 ;; We do some threading while we read the headers. The
7257 ;; message-id and the last reference are both entered into
7258 ;; the same hash table. Some tippy-toeing around has to be
7259 ;; done in case an article has arrived before the article
7260 ;; which it refers to.
7261 (if (boundp (setq dep (intern (downcase id) dependencies)))
7262 (if (car (symbol-value dep))
7263 ;; An article with this Message-ID has already
7264 ;; been seen, so we ignore this one, except we add
7265 ;; any additional Xrefs (in case the two articles
7266 ;; came from different servers.
7267 (progn
7268 (mail-header-set-xref
7269 (car (symbol-value dep))
7270 (concat (or (mail-header-xref
7271 (car (symbol-value dep))) "")
7272 (or (mail-header-xref header) "")))
7273 (setq header nil))
7274 (setcar (symbol-value dep) header))
7275 (set dep (list header)))
7276 (if header
7277 (progn
7278 (if (boundp (setq dep (intern ref dependencies)))
7279 (setcdr (symbol-value dep)
7280 (cons header (cdr (symbol-value dep))))
7281 (set dep (list nil header)))
7282 (setq headers (cons header headers))))
7283 (goto-char (point-max))))))
7284 (nreverse headers)))
7286 ;; The following macros and functions were written by Felix Lee
7287 ;; <flee@cse.psu.edu>.
7289 (defmacro gnus-nov-read-integer ()
7290 '(prog1
7291 (if (= (following-char) ?\t)
7293 (let ((num (condition-case nil (read buffer) (error nil))))
7294 (if (numberp num) num 0)))
7295 (or (eobp) (forward-char 1))))
7297 (defmacro gnus-nov-skip-field ()
7298 '(search-forward "\t" eol 'move))
7300 (defmacro gnus-nov-field ()
7301 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7303 ;; Goes through the xover lines and returns a list of vectors
7304 (defun gnus-get-newsgroup-headers-xover (sequence)
7305 "Parse the news overview data in the server buffer, and return a
7306 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7307 ;; Get the Xref when the users reads the articles since most/some
7308 ;; NNTP servers do not include Xrefs when using XOVER.
7309 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7310 (let ((cur nntp-server-buffer)
7311 (dependencies gnus-newsgroup-dependencies)
7312 number headers header)
7313 (save-excursion
7314 (set-buffer nntp-server-buffer)
7315 (goto-char (point-min))
7316 (while (and sequence (not (eobp)))
7317 (setq number (read cur))
7318 (while (and sequence (< (car sequence) number))
7319 (setq sequence (cdr sequence)))
7320 (and sequence
7321 (eq number (car sequence))
7322 (progn
7323 (setq sequence (cdr sequence))
7324 (if (setq header
7325 (inline (gnus-nov-parse-line number dependencies)))
7326 (setq headers (cons header headers)))))
7327 (forward-line 1))
7328 (setq headers (nreverse headers)))
7329 headers))
7331 ;; This function has to be called with point after the article number
7332 ;; on the beginning of the line.
7333 (defun gnus-nov-parse-line (number dependencies)
7334 (let ((none 0)
7335 (eol (gnus-point-at-eol))
7336 (buffer (current-buffer))
7337 header ref id dep)
7339 ;; overview: [num subject from date id refs chars lines misc]
7340 (narrow-to-region (point) eol)
7341 (or (eobp) (forward-char))
7343 (condition-case nil
7344 (setq header
7345 (vector
7346 number ; number
7347 (gnus-nov-field) ; subject
7348 (gnus-nov-field) ; from
7349 (gnus-nov-field) ; date
7350 (setq id (or (gnus-nov-field)
7351 (concat "none+"
7352 (int-to-string
7353 (setq none (1+ none)))))) ; id
7354 (progn
7355 (save-excursion
7356 (let ((beg (point)))
7357 (search-forward "\t" eol)
7358 (if (search-backward ">" beg t)
7359 (setq ref
7360 (downcase
7361 (buffer-substring
7362 (1+ (point))
7363 (progn
7364 (search-backward "<" beg t)
7365 (point)))))
7366 (setq ref nil))))
7367 (gnus-nov-field)) ; refs
7368 (gnus-nov-read-integer) ; chars
7369 (gnus-nov-read-integer) ; lines
7370 (if (= (following-char) ?\n)
7372 (gnus-nov-field)) ; misc
7374 (error (progn
7375 (ding)
7376 (message "Strange nov line.")
7377 (setq header nil)
7378 (goto-char eol))))
7380 (widen)
7382 ;; We build the thread tree.
7383 (and header
7384 (if (boundp (setq dep (intern (downcase id) dependencies)))
7385 (if (car (symbol-value dep))
7386 ;; An article with this Message-ID has already been seen,
7387 ;; so we ignore this one, except we add any additional
7388 ;; Xrefs (in case the two articles came from different
7389 ;; servers.
7390 (progn
7391 (mail-header-set-xref
7392 (car (symbol-value dep))
7393 (concat (or (mail-header-xref (car (symbol-value dep))) "")
7394 (or (mail-header-xref header) "")))
7395 (setq header nil))
7396 (setcar (symbol-value dep) header))
7397 (set dep (list header))))
7398 (if header
7399 (progn
7400 (if (boundp (setq dep (intern (or ref "none")
7401 dependencies)))
7402 (setcdr (symbol-value dep)
7403 (cons header (cdr (symbol-value dep))))
7404 (set dep (list nil header)))))
7405 header))
7407 (defun gnus-article-get-xrefs ()
7408 "Fill in the Xref value in `gnus-current-headers', if necessary.
7409 This is meant to be called in `gnus-article-internal-prepare-hook'."
7410 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7411 gnus-current-headers)))
7412 (or (not gnus-use-cross-reference)
7413 (not headers)
7414 (and (mail-header-xref headers)
7415 (not (string= (mail-header-xref headers) "")))
7416 (let ((case-fold-search t)
7417 xref)
7418 (save-restriction
7419 (gnus-narrow-to-headers)
7420 (goto-char (point-min))
7421 (if (or (and (eq (downcase (following-char)) ?x)
7422 (looking-at "Xref:"))
7423 (search-forward "\nXref:" nil t))
7424 (progn
7425 (goto-char (1+ (match-end 0)))
7426 (setq xref (buffer-substring (point)
7427 (progn (end-of-line) (point))))
7428 (mail-header-set-xref headers xref))))))))
7430 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7431 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7433 (defun gnus-make-headers-hashtable-by-number ()
7434 "Make hashtable for the variable gnus-newsgroup-headers by number."
7435 (save-excursion
7436 (set-buffer gnus-summary-buffer)
7437 (let ((headers gnus-newsgroup-headers)
7438 header)
7439 (setq gnus-newsgroup-headers-hashtb-by-number
7440 (gnus-make-hashtable (length headers)))
7441 (while headers
7442 (setq header (car headers))
7443 (gnus-sethash (int-to-string (mail-header-number header))
7444 header gnus-newsgroup-headers-hashtb-by-number)
7445 (setq headers (cdr headers))))))
7447 (defun gnus-more-header-backward ()
7448 "Find new header backward."
7449 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7450 (artnum gnus-newsgroup-begin)
7451 (header nil))
7452 (while (and (not header)
7453 (> artnum first))
7454 (setq artnum (1- artnum))
7455 (setq header (gnus-read-header artnum)))
7456 header))
7458 (defun gnus-more-header-forward (&optional backward)
7459 "Find new header forward.
7460 If BACKWARD, find new header backward instead."
7461 (if backward
7462 (gnus-more-header-backward)
7463 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7464 (artnum gnus-newsgroup-end)
7465 (header nil))
7466 (while (and (not header)
7467 (< artnum last))
7468 (setq artnum (1+ artnum))
7469 (setq header (gnus-read-header artnum)))
7470 header)))
7472 (defun gnus-extend-newsgroup (header &optional backward)
7473 "Extend newsgroup selection with HEADER.
7474 Optional argument BACKWARD means extend toward backward."
7475 (if header
7476 (let ((artnum (mail-header-number header)))
7477 (setq gnus-newsgroup-headers
7478 (if backward
7479 (cons header gnus-newsgroup-headers)
7480 (nconc gnus-newsgroup-headers (list header))))
7481 (setq gnus-newsgroup-unselected
7482 (delq artnum gnus-newsgroup-unselected))
7483 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7484 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7486 (defun gnus-summary-work-articles (n)
7487 "Return a list of articles to be worked upon. The prefix argument,
7488 the list of process marked articles, and the current article will be
7489 taken into consideration."
7490 (let (articles)
7491 (if (and n (numberp n))
7492 (let ((backward (< n 0))
7493 (n (abs n)))
7494 (save-excursion
7495 (while (and (> n 0)
7496 (setq articles (cons (gnus-summary-article-number)
7497 articles))
7498 (gnus-summary-search-forward nil nil backward))
7499 (setq n (1- n))))
7500 (sort articles (function <)))
7501 (or (reverse gnus-newsgroup-processable)
7502 (list (gnus-summary-article-number))))))
7504 (defun gnus-summary-search-group (&optional backward use-level)
7505 "Search for next unread newsgroup.
7506 If optional argument BACKWARD is non-nil, search backward instead."
7507 (save-excursion
7508 (set-buffer gnus-group-buffer)
7509 (if (gnus-group-search-forward
7510 backward nil (if use-level (gnus-group-group-level) nil))
7511 (gnus-group-group-name))))
7513 (defun gnus-summary-best-group (&optional exclude-group)
7514 "Find the name of the best unread group.
7515 If EXCLUDE-GROUP, do not go to this group."
7516 (save-excursion
7517 (set-buffer gnus-group-buffer)
7518 (save-excursion
7519 (gnus-group-best-unread-group exclude-group))))
7521 (defun gnus-subject-equal (s1 s2)
7522 (cond
7523 ((null gnus-summary-gather-subject-limit)
7524 (equal (gnus-simplify-subject-re s1)
7525 (gnus-simplify-subject-re s2)))
7526 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7527 (equal (gnus-simplify-subject-fuzzy s1)
7528 (gnus-simplify-subject-fuzzy s2)))
7529 ((numberp gnus-summary-gather-subject-limit)
7530 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7531 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7533 (equal s1 s2))))
7535 (defun gnus-summary-search-subject (&optional backward unread subject)
7536 "Search for article forward.
7537 If BACKWARD is non-nil, search backward.
7538 If UNREAD is non-nil, only unread articles are selected.
7539 If SUBJECT is non-nil, the article which has the same subject will be
7540 searched for."
7541 (let ((func (if backward 'previous-single-property-change
7542 'next-single-property-change))
7543 (beg (point))
7544 (did t)
7545 pos psubject)
7546 (beginning-of-line)
7547 (and gnus-summary-check-current unread
7548 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7549 (setq did nil))
7550 (if (not did)
7552 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7553 (while
7554 (and
7555 (setq pos (funcall func (point) 'gnus-number))
7556 (goto-char (if backward (1- pos) pos))
7557 (setq did
7558 (not (and
7559 (or (not unread)
7560 (eq (get-text-property (point) 'gnus-mark)
7561 gnus-unread-mark))
7562 (or (not subject)
7563 (and (setq psubject
7564 (inline (gnus-summary-subject-string)))
7565 (inline
7566 (gnus-subject-equal subject psubject)))))))
7567 (if backward (if (bobp) nil (forward-char -1) t)
7568 (if (eobp) nil (forward-char 1) t)))))
7569 (if did
7570 (progn (goto-char beg) nil)
7571 (prog1
7572 (get-text-property (point) 'gnus-number)
7573 (gnus-summary-show-thread)
7574 (gnus-summary-position-cursor)))))
7576 (defun gnus-summary-pseudo-article ()
7577 "The thread level of the article on the current line."
7578 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7580 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7581 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7582 (defun gnus-summary-article-score ()
7583 "Return current article score."
7584 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7585 gnus-summary-default-score 0))
7587 (defun gnus-summary-recenter ()
7588 "Center point in the summary window.
7589 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7590 displayed, no centering will be performed."
7591 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7592 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7593 (let* ((top (cond ((< (window-height) 4) 0)
7594 ((< (window-height) 7) 1)
7595 (t 2)))
7596 (height (1- (window-height)))
7597 (bottom (save-excursion (goto-char (point-max))
7598 (forward-line (- height))
7599 (point)))
7600 (window (get-buffer-window (current-buffer))))
7601 (and
7602 ;; The user has to want it,
7603 gnus-auto-center-summary
7604 ;; the article buffer must be displayed,
7605 (get-buffer-window gnus-article-buffer)
7606 ;; Set the window start to either `bottom', which is the biggest
7607 ;; possible valid number, or the second line from the top,
7608 ;; whichever is the least.
7609 (set-window-start
7610 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7612 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7613 (defun gnus-short-group-name (group &optional levels)
7614 "Collapse GROUP name LEVELS."
7615 (let* ((name "") (foreign "") (depth -1) (skip 1)
7616 (levels (or levels
7617 (progn
7618 (while (string-match "\\." group skip)
7619 (setq skip (match-end 0)
7620 depth (+ depth 1)))
7621 depth))))
7622 (if (string-match ":" group)
7623 (setq foreign (substring group 0 (match-end 0))
7624 group (substring group (match-end 0))))
7625 (while group
7626 (if (and (string-match "\\." group) (> levels 0))
7627 (setq name (concat name (substring group 0 1))
7628 group (substring group (match-end 0))
7629 levels (- levels 1)
7630 name (concat name "."))
7631 (setq name (concat foreign name group)
7632 group nil)))
7633 name))
7635 (defun gnus-summary-jump-to-group (newsgroup)
7636 "Move point to NEWSGROUP in group mode buffer."
7637 ;; Keep update point of group mode buffer if visible.
7638 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7639 (save-window-excursion
7640 ;; Take care of tree window mode.
7641 (if (get-buffer-window gnus-group-buffer)
7642 (pop-to-buffer gnus-group-buffer))
7643 (gnus-group-jump-to-group newsgroup))
7644 (save-excursion
7645 ;; Take care of tree window mode.
7646 (if (get-buffer-window gnus-group-buffer)
7647 (pop-to-buffer gnus-group-buffer)
7648 (set-buffer gnus-group-buffer))
7649 (gnus-group-jump-to-group newsgroup))))
7651 ;; This function returns a list of article numbers based on the
7652 ;; difference between the ranges of read articles in this group and
7653 ;; the range of active articles.
7654 (defun gnus-list-of-unread-articles (group)
7655 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7656 (active (gnus-gethash group gnus-active-hashtb))
7657 (last (cdr active))
7658 first nlast unread)
7659 ;; If none are read, then all are unread.
7660 (if (not read)
7661 (setq first (car active))
7662 ;; If the range of read articles is a single range, then the
7663 ;; first unread article is the article after the last read
7664 ;; article. Sounds logical, doesn't it?
7665 (if (not (listp (cdr read)))
7666 (setq first (1+ (cdr read)))
7667 ;; `read' is a list of ranges.
7668 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7669 (car (car read)))) 1)
7670 (setq first 1))
7671 (while read
7672 (if first
7673 (while (< first nlast)
7674 (setq unread (cons first unread))
7675 (setq first (1+ first))))
7676 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7677 (setq nlast (if (atom (car (cdr read)))
7678 (car (cdr read))
7679 (car (car (cdr read)))))
7680 (setq read (cdr read)))))
7681 ;; And add the last unread articles.
7682 (while (<= first last)
7683 (setq unread (cons first unread))
7684 (setq first (1+ first)))
7685 ;; Return the list of unread articles.
7686 (nreverse unread)))
7688 (defun gnus-list-of-read-articles (group)
7689 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7690 (active (gnus-gethash group gnus-active-hashtb)))
7691 (and info active
7692 (gnus-sorted-complement
7693 (gnus-uncompress-range active)
7694 (gnus-list-of-unread-articles group)))))
7696 ;; Various summary commands
7698 (defun gnus-summary-universal-argument ()
7699 "Perform any operation on all articles marked with the process mark."
7700 (interactive)
7701 (gnus-set-global-variables)
7702 (let ((articles (reverse gnus-newsgroup-processable))
7703 func)
7704 (or articles (error "No articles marked"))
7705 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7706 (error "Undefined key"))
7707 (while articles
7708 (gnus-summary-goto-subject (car articles))
7709 (command-execute func)
7710 (gnus-summary-remove-process-mark (car articles))
7711 (setq articles (cdr articles)))))
7713 (defun gnus-summary-toggle-truncation (&optional arg)
7714 "Toggle truncation of summary lines.
7715 With arg, turn line truncation on iff arg is positive."
7716 (interactive "P")
7717 (setq truncate-lines
7718 (if (null arg) (not truncate-lines)
7719 (> (prefix-numeric-value arg) 0)))
7720 (redraw-display))
7722 (defun gnus-summary-reselect-current-group (&optional all)
7723 "Once exit and then reselect the current newsgroup.
7724 The prefix argument ALL means to select all articles."
7725 (interactive "P")
7726 (gnus-set-global-variables)
7727 (let ((current-subject (gnus-summary-article-number))
7728 (group gnus-newsgroup-name))
7729 (setq gnus-newsgroup-begin nil)
7730 (gnus-summary-exit t)
7731 ;; We have to adjust the point of group mode buffer because the
7732 ;; current point was moved to the next unread newsgroup by
7733 ;; exiting.
7734 (gnus-summary-jump-to-group group)
7735 (gnus-group-read-group all t)
7736 (gnus-summary-goto-subject current-subject)))
7738 (defun gnus-summary-rescan-group (&optional all)
7739 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7740 (interactive "P")
7741 (gnus-set-global-variables)
7742 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7743 (let ((group gnus-newsgroup-name))
7744 (gnus-summary-exit)
7745 (gnus-summary-jump-to-group group)
7746 (save-excursion
7747 (set-buffer gnus-group-buffer)
7748 (gnus-group-get-new-news-this-group 1))
7749 (gnus-summary-jump-to-group group)
7750 (gnus-group-read-group all)))
7752 (defun gnus-summary-update-info ()
7753 (let* ((group gnus-newsgroup-name))
7754 (if gnus-newsgroup-kill-headers
7755 (setq gnus-newsgroup-killed
7756 (gnus-compress-sequence
7757 (nconc
7758 (gnus-set-sorted-intersection
7759 (gnus-uncompress-range gnus-newsgroup-killed)
7760 (setq gnus-newsgroup-unselected
7761 (sort gnus-newsgroup-unselected '<)))
7762 (setq gnus-newsgroup-unreads
7763 (sort gnus-newsgroup-unreads '<))) t)))
7764 (or (listp (cdr gnus-newsgroup-killed))
7765 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7766 (let ((headers gnus-newsgroup-headers))
7767 (gnus-close-group group)
7768 (run-hooks 'gnus-exit-group-hook)
7769 (gnus-update-read-articles
7770 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7771 gnus-newsgroup-marked
7772 t gnus-newsgroup-replied gnus-newsgroup-expirable
7773 gnus-newsgroup-killed gnus-newsgroup-dormant
7774 gnus-newsgroup-bookmarks
7775 (and gnus-save-score gnus-newsgroup-scored))
7776 (and gnus-use-cross-reference
7777 (gnus-mark-xrefs-as-read
7778 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7779 ;; Do adaptive scoring, and possibly save score files.
7780 (and gnus-newsgroup-adaptive
7781 (gnus-score-adaptive))
7782 (and gnus-use-scoring
7783 (fboundp 'gnus-score-save)
7784 (funcall 'gnus-score-save))
7785 ;; Do not switch windows but change the buffer to work.
7786 (set-buffer gnus-group-buffer)
7787 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
7788 (gnus-group-update-group group)))))
7790 (defun gnus-summary-exit (&optional temporary)
7791 "Exit reading current newsgroup, and then return to group selection mode.
7792 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7793 (interactive)
7794 (gnus-set-global-variables)
7795 (gnus-kill-save-kill-buffer)
7796 (let* ((group gnus-newsgroup-name)
7797 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7798 (mode major-mode)
7799 (buf (current-buffer)))
7800 (run-hooks 'gnus-summary-prepare-exit-hook)
7801 ;; Make all changes in this group permanent.
7802 (gnus-summary-update-info)
7803 (set-buffer buf)
7804 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7805 ;; Make sure where I was, and go to next newsgroup.
7806 (set-buffer gnus-group-buffer)
7807 (or quit-config
7808 (progn
7809 (gnus-group-jump-to-group group)
7810 (gnus-group-next-unread-group 1)))
7811 (if temporary
7812 nil ;Nothing to do.
7813 ;; We set all buffer-local variables to nil. It is unclear why
7814 ;; this is needed, but if we don't, buffer-local variables are
7815 ;; not garbage-collected, it seems. This would the lead to en
7816 ;; ever-growing Emacs.
7817 (set-buffer buf)
7818 (gnus-summary-clear-local-variables)
7819 ;; We clear the global counterparts of the buffer-local
7820 ;; variables as well, just to be on the safe side.
7821 (gnus-configure-windows 'group 'force)
7822 (gnus-summary-clear-local-variables)
7823 ;; Return to group mode buffer.
7824 (if (eq mode 'gnus-summary-mode)
7825 (gnus-kill-buffer buf))
7826 (if (get-buffer gnus-article-buffer)
7827 (bury-buffer gnus-article-buffer))
7828 (setq gnus-current-select-method gnus-select-method)
7829 (pop-to-buffer gnus-group-buffer)
7830 (if (not quit-config)
7831 (progn
7832 (gnus-group-jump-to-group group)
7833 (gnus-group-next-unread-group 1))
7834 (if (not (buffer-name (car quit-config)))
7835 (gnus-configure-windows 'group 'force)
7836 (set-buffer (car quit-config))
7837 (and (eq major-mode 'gnus-summary-mode)
7838 (gnus-set-global-variables))
7839 (gnus-configure-windows (cdr quit-config))))
7840 (run-hooks 'gnus-summary-exit-hook))))
7842 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7843 (defun gnus-summary-exit-no-update (&optional no-questions)
7844 "Quit reading current newsgroup without updating read article info."
7845 (interactive)
7846 (gnus-set-global-variables)
7847 (let* ((group gnus-newsgroup-name)
7848 (quit-config (gnus-group-quit-config group)))
7849 (if (or no-questions
7850 gnus-expert-user
7851 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7852 (progn
7853 (gnus-close-group group)
7854 (gnus-summary-clear-local-variables)
7855 (set-buffer gnus-group-buffer)
7856 (gnus-summary-clear-local-variables)
7857 ;; Return to group selection mode.
7858 (gnus-configure-windows 'group 'force)
7859 (if (get-buffer gnus-summary-buffer)
7860 (kill-buffer gnus-summary-buffer))
7861 (if (get-buffer gnus-article-buffer)
7862 (bury-buffer gnus-article-buffer))
7863 (if (equal (gnus-group-group-name) group)
7864 (gnus-group-next-unread-group 1))
7865 (if quit-config
7866 (progn
7867 (if (not (buffer-name (car quit-config)))
7868 (gnus-configure-windows 'group 'force)
7869 (set-buffer (car quit-config))
7870 (and (eq major-mode 'gnus-summary-mode)
7871 (gnus-set-global-variables))
7872 (gnus-configure-windows (cdr quit-config)))))))))
7874 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7875 (defun gnus-summary-fetch-faq (group)
7876 "Fetch the FAQ for the current group."
7877 (interactive (list gnus-newsgroup-name))
7878 (let (gnus-faq-buffer)
7879 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group))
7880 (gnus-configure-windows 'summary-faq))))
7882 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7883 (defun gnus-summary-describe-group (&optional force)
7884 "Describe the current newsgroup."
7885 (interactive "P")
7886 (gnus-group-describe-group force gnus-newsgroup-name))
7888 (defun gnus-summary-describe-briefly ()
7889 "Describe summary mode commands briefly."
7890 (interactive)
7891 (gnus-message 6
7892 (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")))
7894 ;; Walking around group mode buffer from summary mode.
7896 (defun gnus-summary-next-group (&optional no-article target-group backward)
7897 "Exit current newsgroup and then select next unread newsgroup.
7898 If prefix argument NO-ARTICLE is non-nil, no article is selected
7899 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7900 previous group instead."
7901 (interactive "P")
7902 (gnus-set-global-variables)
7903 (let ((current-group gnus-newsgroup-name)
7904 (current-buffer (current-buffer))
7905 entered)
7906 ;; First we semi-exit this group to update Xrefs and all variables.
7907 ;; We can't do a real exit, because the window conf must remain
7908 ;; the same in case the user is prompted for info, and we don't
7909 ;; want the window conf to change before that...
7910 (gnus-summary-exit t)
7911 (while (not entered)
7912 ;; Then we find what group we are supposed to enter.
7913 (set-buffer gnus-group-buffer)
7914 (gnus-group-jump-to-group current-group)
7915 (setq target-group
7916 (or target-group
7917 (if (eq gnus-keep-same-level 'best)
7918 (gnus-summary-best-group gnus-newsgroup-name)
7919 (gnus-summary-search-group backward gnus-keep-same-level))))
7920 (if (not target-group)
7921 ;; There are no further groups, so we return to the group
7922 ;; buffer.
7923 (progn
7924 (gnus-message 5 "Returning to the group buffer")
7925 (setq entered t)
7926 (set-buffer current-buffer)
7927 (gnus-summary-exit))
7928 ;; We try to enter the target group.
7929 (gnus-group-jump-to-group target-group)
7930 (let ((unreads (gnus-group-group-unread)))
7931 (if (and (or (eq t unreads)
7932 (and unreads (not (zerop unreads))))
7933 (gnus-summary-read-group
7934 target-group nil no-article current-buffer))
7935 (setq entered t)
7936 (setq current-group target-group
7937 target-group nil)))))))
7939 (defun gnus-summary-next-group-old (&optional no-article group backward)
7940 "Exit current newsgroup and then select next unread newsgroup.
7941 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7942 If BACKWARD, go to previous group instead."
7943 (interactive "P")
7944 (gnus-set-global-variables)
7945 (let ((ingroup gnus-newsgroup-name)
7946 (sumbuf (current-buffer))
7947 num)
7948 (set-buffer gnus-group-buffer)
7949 (if (and group
7950 (or (and (numberp (setq num (car (gnus-gethash
7951 group gnus-newsrc-hashtb))))
7952 (< num 1))
7953 (null num)))
7954 (progn
7955 (gnus-group-jump-to-group group)
7956 (setq group nil))
7957 (gnus-group-jump-to-group ingroup))
7958 (gnus-summary-search-group backward)
7959 (let ((group (or group (gnus-summary-search-group backward))))
7960 (set-buffer sumbuf)
7961 (gnus-summary-exit t) ;Update all information.
7962 (if (null group)
7963 (gnus-summary-exit-no-update t)
7964 (gnus-group-jump-to-group ingroup)
7965 (setq group (gnus-summary-search-group backward))
7966 (gnus-message 5 "Selecting %s..." group)
7967 (set-buffer gnus-group-buffer)
7968 ;; We are now in group mode buffer.
7969 ;; Make sure group mode buffer point is on GROUP.
7970 (gnus-group-jump-to-group group)
7971 (if (not (eq gnus-auto-select-next 'quietly))
7972 (progn
7973 (gnus-summary-read-group group nil no-article sumbuf)
7974 (and (string= gnus-newsgroup-name ingroup)
7975 (bufferp sumbuf) (buffer-name sumbuf)
7976 (progn
7977 (set-buffer (setq gnus-summary-buffer sumbuf))
7978 (gnus-summary-exit-no-update t))))
7979 (let ((prevgroup group))
7980 (gnus-group-jump-to-group ingroup)
7981 (setq group (gnus-summary-search-group backward))
7982 (gnus-summary-read-group group nil no-article sumbuf)
7983 (while (and (string= gnus-newsgroup-name ingroup)
7984 (bufferp sumbuf)
7985 (buffer-name sumbuf)
7986 (not (string= prevgroup (gnus-group-group-name))))
7987 (set-buffer gnus-group-buffer)
7988 (gnus-summary-read-group
7989 (setq prevgroup (gnus-group-group-name))
7990 nil no-article sumbuf))
7991 (and (string= prevgroup (gnus-group-group-name))
7992 ;; We have reached the final group in the group
7993 ;; buffer.
7994 (progn
7995 (if (buffer-name sumbuf)
7996 (progn
7997 (set-buffer sumbuf)
7998 (gnus-summary-exit)))))))))))
8000 (defun gnus-summary-prev-group (&optional no-article)
8001 "Exit current newsgroup and then select previous unread newsgroup.
8002 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
8003 (interactive "P")
8004 (gnus-summary-next-group no-article nil t))
8006 ;; Walking around summary lines.
8008 (defun gnus-summary-first-subject (&optional unread)
8009 "Go to the first unread subject.
8010 If UNREAD is non-nil, go to the first unread article.
8011 Returns nil if there are no unread articles."
8012 (interactive "P")
8013 (prog1
8014 (cond ((not unread)
8015 (goto-char (point-min)))
8016 ((gnus-goto-char
8017 (text-property-any
8018 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
8021 ;; There are no unread articles.
8022 (gnus-message 3 "No more unread articles")
8023 nil))
8024 (gnus-summary-position-cursor)))
8026 (defun gnus-summary-next-subject (n &optional unread dont-display)
8027 "Go to next N'th summary line.
8028 If N is negative, go to the previous N'th subject line.
8029 If UNREAD is non-nil, only unread articles are selected.
8030 The difference between N and the actual number of steps taken is
8031 returned."
8032 (interactive "p")
8033 (let ((backward (< n 0))
8034 (n (abs n)))
8035 (while (and (> n 0)
8036 (gnus-summary-search-forward unread nil backward))
8037 (setq n (1- n)))
8038 (if (/= 0 n) (gnus-message 7 "No more%s articles"
8039 (if unread " unread" "")))
8040 (or dont-display
8041 (progn
8042 (gnus-summary-recenter)
8043 (gnus-summary-position-cursor)))
8046 (defun gnus-summary-next-unread-subject (n)
8047 "Go to next N'th unread summary line."
8048 (interactive "p")
8049 (gnus-summary-next-subject n t))
8051 (defun gnus-summary-prev-subject (n &optional unread)
8052 "Go to previous N'th summary line.
8053 If optional argument UNREAD is non-nil, only unread article is selected."
8054 (interactive "p")
8055 (gnus-summary-next-subject (- n) unread))
8057 (defun gnus-summary-prev-unread-subject (n)
8058 "Go to previous N'th unread summary line."
8059 (interactive "p")
8060 (gnus-summary-next-subject (- n) t))
8062 (defun gnus-summary-goto-subject (article)
8063 "Go the subject line of ARTICLE."
8064 (interactive
8065 (list
8066 (string-to-int
8067 (completing-read "Article number: "
8068 (mapcar
8069 (lambda (headers)
8070 (list
8071 (int-to-string (mail-header-number headers))))
8072 gnus-newsgroup-headers)
8073 nil 'require-match))))
8074 (or article (error "No article number"))
8075 (let ((b (point)))
8076 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
8077 'gnus-number article)))
8079 (gnus-summary-show-thread)
8080 ;; Skip dummy articles.
8081 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8082 (forward-line 1))
8083 (prog1
8084 (if (not (eobp))
8085 article
8086 (goto-char b)
8087 nil)
8088 (gnus-summary-position-cursor)))))
8090 ;; Walking around summary lines with displaying articles.
8092 (defun gnus-summary-expand-window (&optional arg)
8093 "Make the summary buffer take up the entire Emacs frame.
8094 Given a prefix, will force an `article' buffer configuration."
8095 (interactive "P")
8096 (gnus-set-global-variables)
8097 (if arg
8098 (gnus-configure-windows 'article 'force)
8099 (gnus-configure-windows 'summary 'force)))
8101 (defun gnus-summary-display-article (article &optional all-header)
8102 "Display ARTICLE in article buffer."
8103 (gnus-set-global-variables)
8104 (if (null article)
8106 (prog1
8107 (gnus-article-prepare article all-header)
8108 (gnus-summary-show-thread)
8109 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8110 (progn
8111 (forward-line 1)
8112 (gnus-summary-position-cursor)))
8113 (run-hooks 'gnus-select-article-hook)
8114 (gnus-summary-recenter)
8115 (gnus-summary-goto-subject article)
8116 ;; Successfully display article.
8117 (gnus-summary-update-line)
8118 (gnus-article-set-window-start
8119 (cdr (assq article gnus-newsgroup-bookmarks)))
8120 t)))
8122 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8123 "Select the current article.
8124 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8125 non-nil, the article will be re-fetched even if it already present in
8126 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8127 be displayed."
8128 (and (not pseudo) (gnus-summary-pseudo-article)
8129 (error "This is a pseudo-article."))
8130 (let ((article (or article (gnus-summary-article-number)))
8131 (all-headers (not (not all-headers))) ;Must be T or NIL.
8132 did)
8133 (prog1
8134 (save-excursion
8135 (set-buffer gnus-summary-buffer)
8136 (if (or (null gnus-current-article)
8137 (null gnus-article-current)
8138 (null (get-buffer gnus-article-buffer))
8139 (not (eq article (cdr gnus-article-current)))
8140 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8141 force)
8142 ;; The requested article is different from the current article.
8143 (progn
8144 (gnus-summary-display-article article all-headers)
8145 (setq did article))
8146 (if (or all-headers gnus-show-all-headers)
8147 (gnus-article-show-all-headers))
8148 nil))
8149 (if did
8150 (gnus-article-set-window-start
8151 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8153 (defun gnus-summary-set-current-mark (&optional current-mark)
8154 "Obsolete function."
8155 nil)
8157 (defun gnus-summary-next-article (&optional unread subject backward)
8158 "Select the next article.
8159 If UNREAD, only unread articles are selected.
8160 If SUBJECT, only articles with SUBJECT are selected.
8161 If BACKWARD, the previous article is selected instead of the next."
8162 (interactive "P")
8163 (gnus-set-global-variables)
8164 (let (header)
8165 (cond
8166 ;; Is there such an article?
8167 ((and (gnus-summary-search-forward unread subject backward)
8168 (or (gnus-summary-display-article (gnus-summary-article-number))
8169 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8170 (gnus-summary-position-cursor))
8171 ;; If not, we try the first unread, if that is wanted.
8172 ((and subject
8173 gnus-auto-select-same
8174 (or (gnus-summary-first-unread-article)
8175 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8176 (gnus-summary-position-cursor)
8177 (gnus-message 6 "Wrapped"))
8178 ;; Try to get next/previous article not displayed in this group.
8179 ((and gnus-auto-extend-newsgroup
8180 (not unread) (not subject)
8181 (setq header (gnus-more-header-forward backward)))
8182 (gnus-extend-newsgroup header backward)
8183 (let ((buffer-read-only nil))
8184 (goto-char (if backward (point-min) (point-max)))
8185 (gnus-summary-prepare-threads (list header)))
8186 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8187 gnus-newsgroup-end)))
8188 ;; Go to next/previous group.
8190 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
8191 (gnus-summary-jump-to-group gnus-newsgroup-name))
8192 (let ((cmd last-command-char)
8193 (group
8194 (if (eq gnus-keep-same-level 'best)
8195 (gnus-summary-best-group gnus-newsgroup-name)
8196 (gnus-summary-search-group backward gnus-keep-same-level))))
8197 ;; For some reason, the group window gets selected. We change
8198 ;; it back.
8199 (select-window (get-buffer-window (current-buffer)))
8200 ;; Keep just the event type of CMD.
8201 ;(and (listp cmd) (setq cmd (car cmd)))
8202 ;; Select next unread newsgroup automagically.
8203 (cond
8204 ((not gnus-auto-select-next)
8205 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8206 ((eq gnus-auto-select-next 'quietly)
8207 ;; Select quietly.
8208 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
8209 (gnus-summary-exit)
8210 (gnus-message 7 "No more%s articles (%s)..."
8211 (if unread " unread" "")
8212 (if group (concat "selecting " group)
8213 "exiting"))
8214 (gnus-summary-next-group nil group backward)))
8216 (let ((keystrokes '(?\C-n ?\C-p))
8217 key)
8218 (while (or (null key) (memq key keystrokes))
8219 (gnus-message
8220 7 "No more%s articles%s" (if unread " unread" "")
8221 (if (and group
8222 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
8223 (format " (Type %s for %s [%s])"
8224 (single-key-description cmd) group
8225 (car (gnus-gethash group gnus-newsrc-hashtb)))
8226 (format " (Type %s to exit %s)"
8227 (single-key-description cmd)
8228 gnus-newsgroup-name)))
8229 ;; Confirm auto selection.
8230 (let* ((event (read-char)))
8231 (setq key (if (listp event) (car event) event))
8232 (if (memq key keystrokes)
8233 (let ((obuf (current-buffer)))
8234 (switch-to-buffer gnus-group-buffer)
8235 (and group
8236 (gnus-group-jump-to-group group))
8237 (condition-case ()
8238 (execute-kbd-macro (char-to-string key))
8239 (error (ding) nil))
8240 (setq group (gnus-group-group-name))
8241 (switch-to-buffer obuf)))))
8242 (if (equal key cmd)
8243 (if (or (not group)
8244 (gnus-ephemeral-group-p gnus-newsgroup-name))
8245 (gnus-summary-exit)
8246 (gnus-summary-next-group nil group backward))
8247 (execute-kbd-macro (char-to-string key)))))))))))
8249 (defun gnus-summary-next-unread-article ()
8250 "Select unread article after current one."
8251 (interactive)
8252 (gnus-summary-next-article t (and gnus-auto-select-same
8253 (gnus-summary-subject-string))))
8255 (defun gnus-summary-prev-article (&optional unread subject)
8256 "Select the article after the current one.
8257 If UNREAD is non-nil, only unread articles are selected."
8258 (interactive "P")
8259 (gnus-summary-next-article unread subject t))
8261 (defun gnus-summary-prev-unread-article ()
8262 "Select unred article before current one."
8263 (interactive)
8264 (gnus-summary-prev-article t (and gnus-auto-select-same
8265 (gnus-summary-subject-string))))
8267 (defun gnus-summary-next-page (&optional lines circular)
8268 "Show next page of selected article.
8269 If end of article, select next article.
8270 Argument LINES specifies lines to be scrolled up.
8271 If CIRCULAR is non-nil, go to the start of the article instead of
8272 instead of selecting the next article when reaching the end of the
8273 current article."
8274 (interactive "P")
8275 (setq gnus-summary-buffer (current-buffer))
8276 (gnus-set-global-variables)
8277 (let ((article (gnus-summary-article-number))
8278 (endp nil))
8279 (gnus-configure-windows 'article)
8280 (if (or (null gnus-current-article)
8281 (null gnus-article-current)
8282 (/= article (cdr gnus-article-current))
8283 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8284 ;; Selected subject is different from current article's.
8285 (gnus-summary-display-article article)
8286 (gnus-eval-in-buffer-window
8287 gnus-article-buffer
8288 (setq endp (gnus-article-next-page lines)))
8289 (if endp
8290 (cond (circular
8291 (gnus-summary-beginning-of-article))
8292 (lines
8293 (gnus-message 3 "End of message"))
8294 ((null lines)
8295 (gnus-summary-next-unread-article)))))
8296 (gnus-summary-recenter)
8297 (gnus-summary-position-cursor)))
8299 (defun gnus-summary-prev-page (&optional lines)
8300 "Show previous page of selected article.
8301 Argument LINES specifies lines to be scrolled down."
8302 (interactive "P")
8303 (gnus-set-global-variables)
8304 (let ((article (gnus-summary-article-number)))
8305 (gnus-configure-windows 'article)
8306 (if (or (null gnus-current-article)
8307 (null gnus-article-current)
8308 (/= article (cdr gnus-article-current))
8309 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8310 ;; Selected subject is different from current article's.
8311 (gnus-summary-display-article article)
8312 (gnus-summary-recenter)
8313 (gnus-eval-in-buffer-window gnus-article-buffer
8314 (gnus-article-prev-page lines))))
8315 (gnus-summary-position-cursor))
8317 (defun gnus-summary-scroll-up (lines)
8318 "Scroll up (or down) one line current article.
8319 Argument LINES specifies lines to be scrolled up (or down if negative)."
8320 (interactive "p")
8321 (gnus-set-global-variables)
8322 (gnus-configure-windows 'article)
8323 (or (gnus-summary-select-article nil nil 'pseudo)
8324 (gnus-eval-in-buffer-window
8325 gnus-article-buffer
8326 (cond ((> lines 0)
8327 (if (gnus-article-next-page lines)
8328 (gnus-message 3 "End of message")))
8329 ((< lines 0)
8330 (gnus-article-prev-page (- lines))))))
8331 (gnus-summary-recenter)
8332 (gnus-summary-position-cursor))
8334 (defun gnus-summary-next-same-subject ()
8335 "Select next article which has the same subject as current one."
8336 (interactive)
8337 (gnus-set-global-variables)
8338 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8340 (defun gnus-summary-prev-same-subject ()
8341 "Select previous article which has the same subject as current one."
8342 (interactive)
8343 (gnus-set-global-variables)
8344 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8346 (defun gnus-summary-next-unread-same-subject ()
8347 "Select next unread article which has the same subject as current one."
8348 (interactive)
8349 (gnus-set-global-variables)
8350 (gnus-summary-next-article t (gnus-summary-subject-string)))
8352 (defun gnus-summary-prev-unread-same-subject ()
8353 "Select previous unread article which has the same subject as current one."
8354 (interactive)
8355 (gnus-set-global-variables)
8356 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8358 (defun gnus-summary-first-unread-article ()
8359 "Select the first unread article.
8360 Return nil if there are no unread articles."
8361 (interactive)
8362 (gnus-set-global-variables)
8363 (prog1
8364 (if (gnus-summary-first-subject t)
8365 (progn
8366 (gnus-summary-show-thread)
8367 (gnus-summary-first-subject t)
8368 (gnus-summary-display-article (gnus-summary-article-number))))
8369 (gnus-summary-position-cursor)))
8371 (defun gnus-summary-best-unread-article ()
8372 "Select the unread article with the highest score."
8373 (interactive)
8374 (gnus-set-global-variables)
8375 (let ((best -1000000)
8376 article score)
8377 (save-excursion
8378 (or (gnus-summary-first-subject t)
8379 (error "No unread articles"))
8380 (while
8381 (and
8382 (progn
8383 (and (> (setq score (gnus-summary-article-score)) best)
8384 (setq best score
8385 article (gnus-summary-article-number)))
8387 (gnus-summary-search-subject nil t))))
8388 (if (not article)
8389 (error "No unread articles")
8390 (gnus-summary-goto-article article))
8391 (gnus-summary-position-cursor)))
8393 (defun gnus-summary-goto-article (article &optional all-headers)
8394 "Fetch ARTICLE and display it if it exists.
8395 If ALL-HEADERS is non-nil, no header lines are hidden."
8396 (interactive
8397 (list
8398 (string-to-int
8399 (completing-read
8400 "Article number: "
8401 (mapcar (lambda (headers)
8402 (list (int-to-string (mail-header-number headers))))
8403 gnus-newsgroup-headers)
8404 nil 'require-match))))
8405 (prog1
8406 (and (gnus-summary-goto-subject article)
8407 (gnus-summary-display-article article all-headers))
8408 (gnus-summary-position-cursor)))
8410 (defun gnus-summary-goto-last-article ()
8411 "Go to the previously read article."
8412 (interactive)
8413 (prog1
8414 (and gnus-last-article
8415 (gnus-summary-goto-article gnus-last-article))
8416 (gnus-summary-position-cursor)))
8418 (defun gnus-summary-pop-article (number)
8419 "Pop one article off the history and go to the previous.
8420 NUMBER articles will be popped off."
8421 (interactive "p")
8422 (let (to)
8423 (setq gnus-newsgroup-history
8424 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8425 (if to
8426 (gnus-summary-goto-article (car to))
8427 (error "Article history empty")))
8428 (gnus-summary-position-cursor))
8430 ;; Summary article oriented commands
8432 (defun gnus-summary-refer-parent-article (n)
8433 "Refer parent article N times.
8434 The difference between N and the number of articles fetched is returned."
8435 (interactive "p")
8436 (gnus-set-global-variables)
8437 (while
8438 (and
8439 (> n 0)
8440 (let ((ref (mail-header-references (gnus-get-header-by-num
8441 (gnus-summary-article-number)))))
8442 (if (and ref (not (equal ref ""))
8443 (string-match "<[^<>]*>[ \t]*$" ref))
8444 (gnus-summary-refer-article
8445 (substring ref (match-beginning 0) (match-end 0)))
8446 (gnus-message 1 "No references in article %d"
8447 (gnus-summary-article-number))
8448 nil)))
8449 (setq n (1- n)))
8450 (gnus-summary-position-cursor)
8453 (defun gnus-summary-refer-article (message-id)
8454 "Refer article specified by MESSAGE-ID.
8455 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8456 (interactive "sMessage-ID: ")
8457 (if (or (not (stringp message-id))
8458 (zerop (length message-id)))
8460 ;; Construct the correct Message-ID if necessary.
8461 ;; Suggested by tale@pawl.rpi.edu.
8462 (or (string-match "^<" message-id)
8463 (setq message-id (concat "<" message-id)))
8464 (or (string-match ">$" message-id)
8465 (setq message-id (concat message-id ">")))
8466 (let ((header (car (gnus-gethash (downcase message-id)
8467 gnus-newsgroup-dependencies))))
8468 (if header
8469 (or (gnus-summary-goto-article (mail-header-number header))
8470 ;; The header has been read, but the article had been
8471 ;; expunged, so we insert it again.
8472 (progn
8473 (gnus-summary-insert-line
8474 nil header 0 nil gnus-read-mark nil nil
8475 (mail-header-subject header))
8476 (forward-line -1)
8477 (mail-header-number header)))
8478 (let ((gnus-override-method gnus-refer-article-method)
8479 (gnus-ancient-mark gnus-read-mark)
8480 (tmp-point (window-start
8481 (get-buffer-window gnus-article-buffer)))
8482 number tmp-buf)
8483 (and gnus-refer-article-method
8484 (gnus-check-server gnus-refer-article-method))
8485 ;; Save the old article buffer.
8486 (save-excursion
8487 (set-buffer (gnus-article-setup-buffer))
8488 (gnus-kill-buffer " *temp Article*")
8489 (setq tmp-buf (rename-buffer " *temp Article*")))
8490 (prog1
8491 (if (gnus-article-prepare
8492 message-id nil (gnus-read-header message-id))
8493 (progn
8494 (setq number (mail-header-number gnus-current-headers))
8495 (gnus-rebuild-thread message-id)
8496 (gnus-summary-goto-subject number)
8497 (if (null gnus-use-full-window)
8498 (progn
8499 (delete-windows-on tmp-buf)
8500 (gnus-configure-windows 'article 'force)))
8501 (gnus-summary-recenter)
8502 (gnus-article-set-window-start
8503 (cdr (assq number gnus-newsgroup-bookmarks)))
8504 (and gnus-visual
8505 (run-hooks 'gnus-visual-mark-article-hook))
8506 message-id)
8507 ;; We restore the old article buffer.
8508 (save-excursion
8509 (kill-buffer gnus-article-buffer)
8510 (set-buffer tmp-buf)
8511 (rename-buffer gnus-article-buffer)
8512 (let ((buffer-read-only nil))
8513 (and tmp-point
8514 (set-window-start (get-buffer-window (current-buffer))
8515 tmp-point)))))))))))
8517 (defun gnus-summary-enter-digest-group ()
8518 "Enter a digest group based on the current article."
8519 (interactive)
8520 (gnus-set-global-variables)
8521 (gnus-summary-select-article)
8522 ;; We do not want a narrowed article.
8523 (gnus-summary-stop-page-breaking)
8524 (let ((name (format "%s-%d"
8525 (gnus-group-prefixed-name
8526 gnus-newsgroup-name (list 'nndoc ""))
8527 gnus-current-article))
8528 (ogroup gnus-newsgroup-name)
8529 (buf (current-buffer)))
8530 (if (gnus-group-read-ephemeral-group
8531 name (list 'nndoc name
8532 (list 'nndoc-address (get-buffer gnus-article-buffer))
8533 '(nndoc-article-type digest))
8535 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8536 (list (list (cons 'to-group ogroup))))
8537 (switch-to-buffer buf)
8538 (gnus-set-global-variables)
8539 (gnus-configure-windows 'summary)
8540 (gnus-message 3 "Article not a digest?"))))
8542 (defun gnus-summary-isearch-article ()
8543 "Do incremental search forward on current article."
8544 (interactive)
8545 (gnus-set-global-variables)
8546 (gnus-summary-select-article)
8547 (gnus-eval-in-buffer-window
8548 gnus-article-buffer (isearch-forward)))
8550 (defun gnus-summary-search-article-forward (regexp &optional backward)
8551 "Search for an article containing REGEXP forward.
8552 If BACKWARD, search backward instead."
8553 (interactive
8554 (list (read-string
8555 (format "Search article %s (regexp%s): "
8556 (if current-prefix-arg "backward" "forward")
8557 (if gnus-last-search-regexp
8558 (concat ", default " gnus-last-search-regexp)
8559 "")))
8560 current-prefix-arg))
8561 (gnus-set-global-variables)
8562 (if (string-equal regexp "")
8563 (setq regexp (or gnus-last-search-regexp ""))
8564 (setq gnus-last-search-regexp regexp))
8565 (if (gnus-summary-search-article regexp backward)
8566 (gnus-article-set-window-start
8567 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8568 (error "Search failed: \"%s\"" regexp)))
8570 (defun gnus-summary-search-article-backward (regexp)
8571 "Search for an article containing REGEXP backward."
8572 (interactive
8573 (list (read-string
8574 (format "Search article backward (regexp%s): "
8575 (if gnus-last-search-regexp
8576 (concat ", default " gnus-last-search-regexp)
8577 "")))))
8578 (gnus-summary-search-article-forward regexp 'backward))
8580 (defun gnus-summary-search-article (regexp &optional backward)
8581 "Search for an article containing REGEXP.
8582 Optional argument BACKWARD means do search for backward.
8583 gnus-select-article-hook is not called during the search."
8584 (let ((gnus-select-article-hook nil) ;Disable hook.
8585 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8586 (re-search
8587 (if backward
8588 (function re-search-backward) (function re-search-forward)))
8589 (found nil)
8590 (last nil))
8591 ;; Hidden thread subtrees must be searched for ,too.
8592 (gnus-summary-show-all-threads)
8593 (if (eobp) (forward-line -1))
8594 ;; First of all, search current article.
8595 ;; We don't want to read article again from NNTP server nor reset
8596 ;; current point.
8597 (gnus-summary-select-article)
8598 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8599 (setq last gnus-current-article)
8600 (gnus-eval-in-buffer-window
8601 gnus-article-buffer
8602 (save-restriction
8603 (widen)
8604 ;; Begin search from current point.
8605 (setq found (funcall re-search regexp nil t))))
8606 ;; Then search next articles.
8607 (while (and (not found)
8608 (gnus-summary-display-article
8609 (gnus-summary-search-subject backward nil nil)))
8610 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8611 (gnus-eval-in-buffer-window
8612 gnus-article-buffer
8613 (save-restriction
8614 (widen)
8615 (goto-char (if backward (point-max) (point-min)))
8616 (setq found (funcall re-search regexp nil t)))))
8617 (message "")
8618 ;; Adjust article pointer.
8619 (or (eq last gnus-current-article)
8620 (setq gnus-last-article last))
8621 ;; Return T if found such article.
8622 found))
8624 (defun gnus-summary-execute-command (header regexp command &optional backward)
8625 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8626 If HEADER is an empty string (or nil), the match is done on the entire
8627 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8628 (interactive
8629 (list (let ((completion-ignore-case t))
8630 (completing-read
8631 "Header name: "
8632 (mapcar (lambda (string) (list string))
8633 '("Number" "Subject" "From" "Lines" "Date"
8634 "Message-ID" "Xref" "References"))
8635 nil 'require-match))
8636 (read-string "Regexp: ")
8637 (read-key-sequence "Command: ")
8638 current-prefix-arg))
8639 (gnus-set-global-variables)
8640 ;; Hidden thread subtrees must be searched as well.
8641 (gnus-summary-show-all-threads)
8642 ;; We don't want to change current point nor window configuration.
8643 (save-excursion
8644 (save-window-excursion
8645 (gnus-message 6 "Executing %s..." (key-description command))
8646 ;; We'd like to execute COMMAND interactively so as to give arguments.
8647 (gnus-execute header regexp
8648 (` (lambda ()
8649 (call-interactively '(, (key-binding command)))))
8650 backward)
8651 (gnus-message 6 "Executing %s...done" (key-description command)))))
8653 (defun gnus-summary-beginning-of-article ()
8654 "Scroll the article back to the beginning."
8655 (interactive)
8656 (gnus-set-global-variables)
8657 (gnus-summary-select-article)
8658 (gnus-configure-windows 'article)
8659 (gnus-eval-in-buffer-window
8660 gnus-article-buffer
8661 (widen)
8662 (goto-char (point-min))
8663 (and gnus-break-pages (gnus-narrow-to-page))))
8665 (defun gnus-summary-end-of-article ()
8666 "Scroll to the end of the article."
8667 (interactive)
8668 (gnus-set-global-variables)
8669 (gnus-summary-select-article)
8670 (gnus-configure-windows 'article)
8671 (gnus-eval-in-buffer-window
8672 gnus-article-buffer
8673 (widen)
8674 (goto-char (point-max))
8675 (recenter -3)
8676 (and gnus-break-pages (gnus-narrow-to-page))))
8678 (defun gnus-summary-show-article ()
8679 "Force re-fetching of the current article."
8680 (interactive)
8681 (gnus-set-global-variables)
8682 (gnus-summary-select-article nil 'force)
8683 (gnus-configure-windows 'article)
8684 (gnus-summary-position-cursor))
8686 (defun gnus-summary-verbose-headers (&optional arg)
8687 "Toggle permanent full header display.
8688 If ARG is a positive number, turn header display on.
8689 If ARG is a negative number, turn header display off."
8690 (interactive "P")
8691 (gnus-set-global-variables)
8692 (gnus-summary-toggle-header arg)
8693 (setq gnus-show-all-headers
8694 (cond ((or (not (numberp arg))
8695 (zerop arg))
8696 (not gnus-show-all-headers))
8697 ((natnump arg)
8698 t))))
8700 (defun gnus-summary-toggle-header (&optional arg)
8701 "Show the headers if they are hidden, or hide them if they are shown.
8702 If ARG is a positive number, show the entire header.
8703 If ARG is a negative number, hide the unwanted header lines."
8704 (interactive "P")
8705 (gnus-set-global-variables)
8706 (save-excursion
8707 (set-buffer gnus-article-buffer)
8708 (let ((buffer-read-only nil))
8709 (if (numberp arg)
8710 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8711 gnus-hidden-properties)
8712 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8713 (if (text-property-any (point-min) (point-max) 'invisible t)
8714 (remove-text-properties
8715 (point-min) (point-max) gnus-hidden-properties)
8716 ;; We hide the headers. This song and dance act below is
8717 ;; done because `gnus-have-all-headers' is buffer-local to
8718 ;; the summary buffer, and we only want to temporarily
8719 ;; change it in that buffer. Ugh.
8720 (let ((have gnus-have-all-headers))
8721 (save-excursion
8722 (set-buffer gnus-summary-buffer)
8723 (setq gnus-have-all-headers nil)
8724 (save-excursion
8725 (set-buffer gnus-article-buffer)
8726 (run-hooks 'gnus-article-display-hook))
8727 (setq gnus-have-all-headers have)))))
8728 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8730 (defun gnus-summary-show-all-headers ()
8731 "Make all header lines visible."
8732 (interactive)
8733 (gnus-set-global-variables)
8734 (gnus-article-show-all-headers))
8736 (defun gnus-summary-toggle-mime (&optional arg)
8737 "Toggle MIME processing.
8738 If ARG is a positive number, turn MIME processing on."
8739 (interactive "P")
8740 (gnus-set-global-variables)
8741 (setq gnus-show-mime
8742 (if (null arg) (not gnus-show-mime)
8743 (> (prefix-numeric-value arg) 0)))
8744 (gnus-summary-select-article t 'force))
8746 (defun gnus-summary-caesar-message (&optional arg)
8747 "Caesar rotate the current article by 13.
8748 The numerical prefix specifies how manu places to rotate each letter
8749 forward."
8750 (interactive "P")
8751 (gnus-set-global-variables)
8752 (gnus-summary-select-article)
8753 (let ((mail-header-separator ""))
8754 (gnus-eval-in-buffer-window
8755 gnus-article-buffer
8756 (save-restriction
8757 (widen)
8758 (let ((start (window-start)))
8759 (news-caesar-buffer-body arg)
8760 (set-window-start (get-buffer-window (current-buffer)) start))))))
8762 (defun gnus-summary-stop-page-breaking ()
8763 "Stop page breaking in the current article."
8764 (interactive)
8765 (gnus-set-global-variables)
8766 (gnus-summary-select-article)
8767 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8769 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8771 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8772 "Move the current article to a different newsgroup.
8773 If N is a positive number, move the N next articles.
8774 If N is a negative number, move the N previous articles.
8775 If N is nil and any articles have been marked with the process mark,
8776 move those articles instead.
8777 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8778 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8779 re-spool using this method.
8780 For this function to work, both the current newsgroup and the
8781 newsgroup that you want to move to have to support the `request-move'
8782 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8783 (interactive "P")
8784 (gnus-set-global-variables)
8785 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8786 (error "The current newsgroup does not support article moving"))
8787 (let ((articles (gnus-summary-work-articles n))
8788 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8789 art-group to-method sel-met)
8790 (if (and (not to-newsgroup) (not select-method))
8791 (setq to-newsgroup
8792 (completing-read
8793 (format "Where do you want to move %s? %s"
8794 (if (> (length articles) 1)
8795 (format "these %d articles" (length articles))
8796 "this article")
8797 (if gnus-current-move-group
8798 (format "(%s default) " gnus-current-move-group)
8799 ""))
8800 gnus-active-hashtb nil nil prefix)))
8801 (if to-newsgroup
8802 (progn
8803 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8804 (setq to-newsgroup (or gnus-current-move-group "")))
8805 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8806 (gnus-activate-group to-newsgroup)
8807 (error "No such group: %s" to-newsgroup))
8808 (setq gnus-current-move-group to-newsgroup)))
8809 (setq to-method (if select-method (list select-method "")
8810 (gnus-find-method-for-group to-newsgroup)))
8811 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8812 (error "%s does not support article copying" (car to-method)))
8813 (or (gnus-check-server to-method)
8814 (error "Can't open server %s" (car to-method)))
8815 (gnus-message 6 "Moving to %s: %s..."
8816 (or select-method to-newsgroup) articles)
8817 (while articles
8818 (if (setq art-group
8819 (gnus-request-move-article
8820 (car articles) ; Article to move
8821 gnus-newsgroup-name ; From newsgrouo
8822 (nth 1 (gnus-find-method-for-group
8823 gnus-newsgroup-name)) ; Server
8824 (list 'gnus-request-accept-article
8825 (if select-method
8826 (list 'quote select-method)
8827 to-newsgroup)
8828 (not (cdr articles))) ; Accept form
8829 (not (cdr articles)))) ; Only save nov last time
8830 (let* ((buffer-read-only nil)
8831 (entry
8833 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8834 (gnus-gethash
8835 (gnus-group-prefixed-name
8836 (car art-group)
8837 (if select-method (list select-method "")
8838 (gnus-find-method-for-group to-newsgroup)))
8839 gnus-newsrc-hashtb)))
8840 (info (nth 2 entry))
8841 (article (car articles)))
8842 (gnus-summary-goto-subject article)
8843 (beginning-of-line)
8844 (delete-region (point) (progn (forward-line 1) (point)))
8845 ;; Update the group that has been moved to.
8846 (if (not info)
8847 () ; This group does not exist yet.
8848 (if (not (memq article gnus-newsgroup-unreads))
8849 (setcar (cdr (cdr info))
8850 (gnus-add-to-range (nth 2 info)
8851 (list (cdr art-group)))))
8852 ;; Copy any marks over to the new group.
8853 (let ((marks '((tick . gnus-newsgroup-marked)
8854 (dormant . gnus-newsgroup-dormant)
8855 (expire . gnus-newsgroup-expirable)
8856 (bookmark . gnus-newsgroup-bookmarks)
8857 (reply . gnus-newsgroup-replied)))
8858 (to-article (cdr art-group)))
8859 (while marks
8860 (if (memq article (symbol-value (cdr (car marks))))
8861 (gnus-add-marked-articles
8862 (car info) (car (car marks)) (list to-article) info))
8863 (setq marks (cdr marks)))))
8864 ;; Update marks.
8865 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8866 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8867 (setq gnus-newsgroup-dormant
8868 (delq article gnus-newsgroup-dormant))
8869 (setq gnus-newsgroup-reads
8870 (cons (cons article gnus-canceled-mark)
8871 gnus-newsgroup-reads)))
8872 (gnus-message 1 "Couldn't move article %s" (car articles)))
8873 (gnus-summary-remove-process-mark (car articles))
8874 (setq articles (cdr articles)))
8875 (gnus-set-mode-line 'summary)))
8877 (defun gnus-summary-respool-article (&optional n respool-method)
8878 "Respool the current article.
8879 The article will be squeezed through the mail spooling process again,
8880 which means that it will be put in some mail newsgroup or other
8881 depending on `nnmail-split-methods'.
8882 If N is a positive number, respool the N next articles.
8883 If N is a negative number, respool the N previous articles.
8884 If N is nil and any articles have been marked with the process mark,
8885 respool those articles instead.
8887 Respooling can be done both from mail groups and \"real\" newsgroups.
8888 In the former case, the articles in question will be moved from the
8889 current group into whatever groups they are destined to. In the
8890 latter case, they will be copied into the relevant groups."
8891 (interactive "P")
8892 (gnus-set-global-variables)
8893 (let ((respool-methods (gnus-methods-using 'respool))
8894 (methname
8895 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8896 (or respool-method
8897 (setq respool-method
8898 (completing-read
8899 "What method do you want to use when respooling? "
8900 respool-methods nil t methname)))
8901 (or (string= respool-method "")
8902 (if (assoc (symbol-name
8903 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8904 respool-methods)
8905 (gnus-summary-move-article n nil (intern respool-method))
8906 (gnus-summary-copy-article n nil (intern respool-method))))))
8908 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8909 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8910 "Move the current article to a different newsgroup.
8911 If N is a positive number, move the N next articles.
8912 If N is a negative number, move the N previous articles.
8913 If N is nil and any articles have been marked with the process mark,
8914 move those articles instead.
8915 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8916 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8917 re-spool using this method.
8918 For this function to work, the newsgroup that you want to move to have
8919 to support the `request-move' and `request-accept'
8920 functions. (Ie. mail newsgroups at present.)"
8921 (interactive "P")
8922 (gnus-set-global-variables)
8923 (let ((articles (gnus-summary-work-articles n))
8924 (copy-buf (get-buffer-create "*copy work*"))
8925 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8926 art-group to-method)
8927 (buffer-disable-undo copy-buf)
8928 (if (and (not to-newsgroup) (not select-method))
8929 (setq to-newsgroup
8930 (completing-read
8931 (format "Where do you want to copy %s? %s"
8932 (if (> (length articles) 1)
8933 (format "these %d articles" (length articles))
8934 "this article")
8935 (if gnus-current-move-group
8936 (format "(%s default) " gnus-current-move-group)
8937 ""))
8938 gnus-active-hashtb nil nil prefix)))
8939 (if to-newsgroup
8940 (progn
8941 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8942 (setq to-newsgroup (or gnus-current-move-group "")))
8943 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8944 (gnus-activate-group to-newsgroup)
8945 (error "No such group: %s" to-newsgroup))
8946 (setq gnus-current-move-group to-newsgroup)))
8947 (setq to-method (if select-method (list select-method "")
8948 (gnus-find-method-for-group to-newsgroup)))
8949 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8950 (error "%s does not support article copying" (car to-method)))
8951 (or (gnus-check-server to-method)
8952 (error "Can't open server %s" (car to-method)))
8953 (while articles
8954 (gnus-message 6 "Copying to %s: %s..."
8955 (or select-method to-newsgroup) articles)
8956 (if (setq art-group
8957 (save-excursion
8958 (set-buffer copy-buf)
8959 (gnus-request-article-this-buffer
8960 (car articles) gnus-newsgroup-name)
8961 (gnus-request-accept-article
8962 (if select-method (quote select-method) to-newsgroup)
8963 (not (cdr articles)))))
8964 (let* ((entry
8966 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8967 (gnus-gethash
8968 (gnus-group-prefixed-name
8969 (car art-group)
8970 (if select-method (list select-method "")
8971 (gnus-find-method-for-group to-newsgroup)))
8972 gnus-newsrc-hashtb)))
8973 (info (nth 2 entry))
8974 (article (car articles)))
8975 ;; We copy the info over to the new group.
8976 (if (not info)
8977 () ; This group does not exist (yet).
8978 (if (not (memq article gnus-newsgroup-unreads))
8979 (setcar (cdr (cdr info))
8980 (gnus-add-to-range (nth 2 info)
8981 (list (cdr art-group)))))
8982 ;; Copy any marks over to the new group.
8983 (let ((marks '((tick . gnus-newsgroup-marked)
8984 (dormant . gnus-newsgroup-dormant)
8985 (expire . gnus-newsgroup-expirable)
8986 (bookmark . gnus-newsgroup-bookmarks)
8987 (reply . gnus-newsgroup-replied)))
8988 (to-article (cdr art-group)))
8989 (while marks
8990 (if (memq article (symbol-value (cdr (car marks))))
8991 (gnus-add-marked-articles
8992 (car info) (car (car marks)) (list to-article) info))
8993 (setq marks (cdr marks))))))
8994 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8995 (gnus-summary-remove-process-mark (car articles))
8996 (setq articles (cdr articles)))
8997 (kill-buffer copy-buf)))
8999 (defun gnus-summary-import-article (file)
9000 "Import a random file into a mail newsgroup."
9001 (interactive "fImport file: ")
9002 (let ((group gnus-newsgroup-name)
9003 atts)
9004 (or (gnus-check-backend-function 'request-accept-article group)
9005 (error "%s does not support article importing" group))
9006 (or (file-readable-p file)
9007 (not (file-regular-p file))
9008 (error "Can't read %s" file))
9009 (save-excursion
9010 (set-buffer (get-buffer-create " *import file*"))
9011 (buffer-disable-undo (current-buffer))
9012 (erase-buffer)
9013 (insert-file-contents file)
9014 (goto-char (point-min))
9015 (if (nnheader-article-p)
9017 (setq atts (file-attributes file))
9018 (insert "From: " (read-string "From: ") "\n"
9019 "Subject: " (read-string "Subject: ") "\n"
9020 "Date: " (current-time-string (nth 5 atts)) "\n"
9021 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9022 (gnus-request-accept-article group t)
9023 (kill-buffer (current-buffer)))))
9025 (defun gnus-summary-expire-articles ()
9026 "Expire all articles that are marked as expirable in the current group."
9027 (interactive)
9028 (if (not (gnus-check-backend-function
9029 'request-expire-articles gnus-newsgroup-name))
9031 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
9032 gnus-newsrc-hashtb)))
9033 (total (memq 'total-expire (nth 5 info)))
9034 (expirable (if total
9035 (gnus-list-of-read-articles gnus-newsgroup-name)
9036 (setq gnus-newsgroup-expirable
9037 (sort gnus-newsgroup-expirable '<))))
9039 (if (not expirable)
9041 (gnus-message 6 "Expiring articles...")
9042 ;; The list of articles that weren't expired is returned.
9043 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
9044 (or total (setq gnus-newsgroup-expirable es))
9045 ;; We go through the old list of expirable, and mark all
9046 ;; really expired articles as non-existant.
9047 (or (eq es expirable) ;If nothing was expired, we don't mark.
9048 (let ((gnus-use-cache nil))
9049 (while expirable
9050 (or (memq (car expirable) es)
9051 (gnus-summary-mark-article
9052 (car expirable) gnus-canceled-mark))
9053 (setq expirable (cdr expirable)))))
9054 (gnus-message 6 "Expiring articles...done")))))
9056 (defun gnus-summary-expire-articles-now ()
9057 "Expunge all expirable articles in the current group.
9058 This means that *all* articles that are marked as expirable will be
9059 deleted forever, right now."
9060 (interactive)
9061 (or gnus-expert-user
9062 (gnus-y-or-n-p
9063 "Are you really, really, really sure you want to expunge? ")
9064 (error "Phew!"))
9065 (let ((nnmail-expiry-wait -1)
9066 (nnmail-expiry-wait-function nil))
9067 (gnus-summary-expire-articles)))
9069 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9070 (defun gnus-summary-delete-article (&optional n)
9071 "Delete the N next (mail) articles.
9072 This command actually deletes articles. This is not a marking
9073 command. The article will disappear forever from you life, never to
9074 return.
9075 If N is negative, delete backwards.
9076 If N is nil and articles have been marked with the process mark,
9077 delete these instead."
9078 (interactive "P")
9079 (or (gnus-check-backend-function 'request-expire-articles
9080 gnus-newsgroup-name)
9081 (error "The current newsgroup does not support article deletion."))
9082 ;; Compute the list of articles to delete.
9083 (let ((articles (gnus-summary-work-articles n))
9084 not-deleted)
9085 (if (and gnus-novice-user
9086 (not (gnus-y-or-n-p
9087 (format "Do you really want to delete %s forever? "
9088 (if (> (length articles) 1) "these articles"
9089 "this article")))))
9091 ;; Delete the articles.
9092 (setq not-deleted (gnus-request-expire-articles
9093 articles gnus-newsgroup-name 'force))
9094 (while articles
9095 (gnus-summary-remove-process-mark (car articles))
9096 ;; The backend might not have been able to delete the article
9097 ;; after all.
9098 (or (memq (car articles) not-deleted)
9099 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9100 (setq articles (cdr articles))))
9101 (gnus-summary-position-cursor)
9102 (gnus-set-mode-line 'summary)
9103 not-deleted))
9105 (defun gnus-summary-edit-article (&optional force)
9106 "Enter into a buffer and edit the current article.
9107 This will have permanent effect only in mail groups.
9108 If FORCE is non-nil, allow editing of articles even in read-only
9109 groups."
9110 (interactive "P")
9111 (or force
9112 (not (gnus-group-read-only-p))
9113 (error "The current newsgroup does not support article editing."))
9114 (gnus-summary-select-article t)
9115 (gnus-configure-windows 'article)
9116 (select-window (get-buffer-window gnus-article-buffer))
9117 (gnus-message 6 "C-c C-c to end edits")
9118 (setq buffer-read-only nil)
9119 (text-mode)
9120 (use-local-map (copy-keymap (current-local-map)))
9121 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9122 (buffer-enable-undo)
9123 (widen)
9124 (goto-char (point-min))
9125 (search-forward "\n\n" nil t))
9127 (defun gnus-summary-edit-article-done ()
9128 "Make edits to the current article permanent."
9129 (interactive)
9130 (if (gnus-group-read-only-p)
9131 (progn
9132 (gnus-summary-edit-article-postpone)
9133 (message "The current newsgroup does not support article editing.")
9134 (ding))
9135 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9136 (erase-buffer)
9137 (insert buf)
9138 (if (not (gnus-request-replace-article
9139 (cdr gnus-article-current) (car gnus-article-current)
9140 (current-buffer)))
9141 (error "Couldn't replace article.")
9142 (gnus-article-mode)
9143 (use-local-map gnus-article-mode-map)
9144 (setq buffer-read-only t)
9145 (buffer-disable-undo (current-buffer))
9146 (gnus-configure-windows 'summary))
9147 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))))
9149 (defun gnus-summary-edit-article-postpone ()
9150 "Postpone changes to the current article."
9151 (interactive)
9152 (gnus-article-mode)
9153 (use-local-map gnus-article-mode-map)
9154 (setq buffer-read-only t)
9155 (buffer-disable-undo (current-buffer))
9156 (gnus-configure-windows 'summary)
9157 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9159 (defun gnus-summary-fancy-query ()
9160 "Query where the fancy respool algorithm would put this article."
9161 (interactive)
9162 (gnus-summary-select-article)
9163 (save-excursion
9164 (set-buffer gnus-article-buffer)
9165 (save-restriction
9166 (goto-char (point-min))
9167 (search-forward "\n\n")
9168 (narrow-to-region (point-min) (point))
9169 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9171 ;; Summary score commands.
9173 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9175 (defun gnus-summary-raise-score (n)
9176 "Raise the score of the current article by N."
9177 (interactive "p")
9178 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9180 (defun gnus-summary-set-score (n)
9181 "Set the score of the current article to N."
9182 (interactive "p")
9183 ;; Skip dummy header line.
9184 (save-excursion
9185 (gnus-summary-show-thread)
9186 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9187 (forward-line 1))
9188 (let ((buffer-read-only nil))
9189 ;; Set score.
9190 (gnus-summary-update-mark
9191 (if (= n (or gnus-summary-default-score 0)) ?
9192 (if (< n (or gnus-summary-default-score 0))
9193 gnus-score-below-mark gnus-score-over-mark)) 'score))
9194 (let* ((article (gnus-summary-article-number))
9195 (score (assq article gnus-newsgroup-scored)))
9196 (if score (setcdr score n)
9197 (setq gnus-newsgroup-scored
9198 (cons (cons article n) gnus-newsgroup-scored))))
9199 (gnus-summary-update-line)))
9201 (defun gnus-summary-current-score ()
9202 "Return the score of the current article."
9203 (interactive)
9204 (message "%s" (gnus-summary-article-score)))
9206 ;; Summary marking commands.
9208 (defun gnus-summary-raise-same-subject-and-select (score)
9209 "Raise articles which has the same subject with SCORE and select the next."
9210 (interactive "p")
9211 (let ((subject (gnus-summary-subject-string)))
9212 (gnus-summary-raise-score score)
9213 (while (gnus-summary-search-subject nil nil subject)
9214 (gnus-summary-raise-score score))
9215 (gnus-summary-next-article t)))
9217 (defun gnus-summary-raise-same-subject (score)
9218 "Raise articles which has the same subject with SCORE."
9219 (interactive "p")
9220 (let ((subject (gnus-summary-subject-string)))
9221 (gnus-summary-raise-score score)
9222 (while (gnus-summary-search-subject nil nil subject)
9223 (gnus-summary-raise-score score))
9224 (gnus-summary-next-subject 1 t)))
9226 (defun gnus-score-default (level)
9227 (if level (prefix-numeric-value level)
9228 gnus-score-interactive-default-score))
9230 (defun gnus-summary-raise-thread (&optional score)
9231 "Raise the score of the articles in the current thread with SCORE."
9232 (interactive "P")
9233 (setq score (gnus-score-default score))
9234 (let (e)
9235 (save-excursion
9236 (let ((level (gnus-summary-thread-level)))
9237 (gnus-summary-raise-score score)
9238 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9239 (> (gnus-summary-thread-level) level))
9240 (gnus-summary-raise-score score))
9241 (setq e (point))))
9242 (let ((gnus-summary-check-current t))
9243 (or (zerop (gnus-summary-next-subject 1 t))
9244 (goto-char e))))
9245 (gnus-summary-recenter)
9246 (gnus-summary-position-cursor)
9247 (gnus-set-mode-line 'summary))
9249 (defun gnus-summary-lower-same-subject-and-select (score)
9250 "Raise articles which has the same subject with SCORE and select the next."
9251 (interactive "p")
9252 (gnus-summary-raise-same-subject-and-select (- score)))
9254 (defun gnus-summary-lower-same-subject (score)
9255 "Raise articles which has the same subject with SCORE."
9256 (interactive "p")
9257 (gnus-summary-raise-same-subject (- score)))
9259 (defun gnus-summary-lower-thread (&optional score)
9260 "Lower score of articles in the current thread with SCORE."
9261 (interactive "P")
9262 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9264 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9265 "Mark articles which has the same subject as read, and then select the next.
9266 If UNMARK is positive, remove any kind of mark.
9267 If UNMARK is negative, tick articles."
9268 (interactive "P")
9269 (if unmark
9270 (setq unmark (prefix-numeric-value unmark)))
9271 (let ((count
9272 (gnus-summary-mark-same-subject
9273 (gnus-summary-subject-string) unmark)))
9274 ;; Select next unread article. If auto-select-same mode, should
9275 ;; select the first unread article.
9276 (gnus-summary-next-article t (and gnus-auto-select-same
9277 (gnus-summary-subject-string)))
9278 (gnus-message 7 "%d article%s marked as %s"
9279 count (if (= count 1) " is" "s are")
9280 (if unmark "unread" "read"))))
9282 (defun gnus-summary-kill-same-subject (&optional unmark)
9283 "Mark articles which has the same subject as read.
9284 If UNMARK is positive, remove any kind of mark.
9285 If UNMARK is negative, tick articles."
9286 (interactive "P")
9287 (if unmark
9288 (setq unmark (prefix-numeric-value unmark)))
9289 (let ((count
9290 (gnus-summary-mark-same-subject
9291 (gnus-summary-subject-string) unmark)))
9292 ;; If marked as read, go to next unread subject.
9293 (if (null unmark)
9294 ;; Go to next unread subject.
9295 (gnus-summary-next-subject 1 t))
9296 (gnus-message 7 "%d articles are marked as %s"
9297 count (if unmark "unread" "read"))))
9299 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9300 "Mark articles with same SUBJECT as read, and return marked number.
9301 If optional argument UNMARK is positive, remove any kinds of marks.
9302 If optional argument UNMARK is negative, mark articles as unread instead."
9303 (let ((count 1))
9304 (save-excursion
9305 (cond
9306 ((null unmark) ; Mark as read.
9307 (while (and
9308 (progn
9309 (gnus-summary-mark-article-as-read gnus-killed-mark)
9310 (gnus-summary-show-thread) t)
9311 (gnus-summary-search-forward nil subject))
9312 (setq count (1+ count))))
9313 ((> unmark 0) ; Tick.
9314 (while (and
9315 (progn
9316 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9317 (gnus-summary-show-thread) t)
9318 (gnus-summary-search-forward nil subject))
9319 (setq count (1+ count))))
9320 (t ; Mark as unread.
9321 (while (and
9322 (progn
9323 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9324 (gnus-summary-show-thread) t)
9325 (gnus-summary-search-forward nil subject))
9326 (setq count (1+ count)))))
9327 (gnus-set-mode-line 'summary)
9328 ;; Return the number of marked articles.
9329 count)))
9331 (defun gnus-summary-mark-as-processable (n &optional unmark)
9332 "Set the process mark on the next N articles.
9333 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9334 the process mark instead. The difference between N and the actual
9335 number of articles marked is returned."
9336 (interactive "p")
9337 (let ((backward (< n 0))
9338 (n (abs n)))
9339 (while (and
9340 (> n 0)
9341 (if unmark
9342 (gnus-summary-remove-process-mark
9343 (gnus-summary-article-number))
9344 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9345 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9346 (setq n (1- n)))
9347 (if (/= 0 n) (gnus-message 7 "No more articles"))
9348 (gnus-summary-recenter)
9349 (gnus-summary-position-cursor)
9352 (defun gnus-summary-unmark-as-processable (n)
9353 "Remove the process mark from the next N articles.
9354 If N is negative, mark backward instead. The difference between N and
9355 the actual number of articles marked is returned."
9356 (interactive "p")
9357 (gnus-summary-mark-as-processable n t))
9359 (defun gnus-summary-unmark-all-processable ()
9360 "Remove the process mark from all articles."
9361 (interactive)
9362 (save-excursion
9363 (while gnus-newsgroup-processable
9364 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9365 (gnus-summary-position-cursor))
9367 (defun gnus-summary-mark-as-expirable (n)
9368 "Mark N articles forward as expirable.
9369 If N is negative, mark backward instead. The difference between N and
9370 the actual number of articles marked is returned."
9371 (interactive "p")
9372 (gnus-summary-mark-forward n gnus-expirable-mark))
9374 (defun gnus-summary-mark-article-as-replied (article)
9375 "Mark ARTICLE replied and update the summary line."
9376 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9377 (let ((buffer-read-only nil))
9378 (if (gnus-summary-goto-subject article)
9379 (progn
9380 (gnus-summary-update-mark gnus-replied-mark 'replied)
9381 t))))
9383 (defun gnus-summary-set-bookmark (article)
9384 "Set a bookmark in current article."
9385 (interactive (list (gnus-summary-article-number)))
9386 (if (or (not (get-buffer gnus-article-buffer))
9387 (not gnus-current-article)
9388 (not gnus-article-current)
9389 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9390 (error "No current article selected"))
9391 ;; Remove old bookmark, if one exists.
9392 (let ((old (assq article gnus-newsgroup-bookmarks)))
9393 (if old (setq gnus-newsgroup-bookmarks
9394 (delq old gnus-newsgroup-bookmarks))))
9395 ;; Set the new bookmark, which is on the form
9396 ;; (article-number . line-number-in-body).
9397 (setq gnus-newsgroup-bookmarks
9398 (cons
9399 (cons article
9400 (save-excursion
9401 (set-buffer gnus-article-buffer)
9402 (count-lines
9403 (min (point)
9404 (save-excursion
9405 (goto-char (point-min))
9406 (search-forward "\n\n" nil t)
9407 (point)))
9408 (point))))
9409 gnus-newsgroup-bookmarks))
9410 (gnus-message 6 "A bookmark has been added to the current article."))
9412 (defun gnus-summary-remove-bookmark (article)
9413 "Remove the bookmark from the current article."
9414 (interactive (list (gnus-summary-article-number)))
9415 ;; Remove old bookmark, if one exists.
9416 (let ((old (assq article gnus-newsgroup-bookmarks)))
9417 (if old
9418 (progn
9419 (setq gnus-newsgroup-bookmarks
9420 (delq old gnus-newsgroup-bookmarks))
9421 (gnus-message 6 "Removed bookmark."))
9422 (gnus-message 6 "No bookmark in current article."))))
9424 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9425 (defun gnus-summary-mark-as-dormant (n)
9426 "Mark N articles forward as dormant.
9427 If N is negative, mark backward instead. The difference between N and
9428 the actual number of articles marked is returned."
9429 (interactive "p")
9430 (gnus-summary-mark-forward n gnus-dormant-mark))
9432 (defun gnus-summary-set-process-mark (article)
9433 "Set the process mark on ARTICLE and update the summary line."
9434 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9435 (let ((buffer-read-only nil))
9436 (if (gnus-summary-goto-subject article)
9437 (progn
9438 (gnus-summary-show-thread)
9439 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9440 (forward-line 1))
9441 (gnus-summary-update-mark gnus-process-mark 'replied)
9442 t))))
9444 (defun gnus-summary-remove-process-mark (article)
9445 "Remove the process mark from ARTICLE and update the summary line."
9446 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9447 (let ((buffer-read-only nil))
9448 (if (gnus-summary-goto-subject article)
9449 (progn
9450 (gnus-summary-show-thread)
9451 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9452 (forward-line 1))
9453 (gnus-summary-update-mark ? 'replied)
9454 (if (memq article gnus-newsgroup-replied)
9455 (gnus-summary-update-mark gnus-replied-mark 'replied))
9456 t))))
9458 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9459 "Mark N articles as read forwards.
9460 If N is negative, mark backwards instead.
9461 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9462 marked as unread.
9463 The difference between N and the actual number of articles marked is
9464 returned."
9465 (interactive "p")
9466 (gnus-set-global-variables)
9467 (let ((backward (< n 0))
9468 (gnus-summary-goto-unread
9469 (and gnus-summary-goto-unread
9470 (not (memq mark (list gnus-unread-mark
9471 gnus-ticked-mark gnus-dormant-mark)))))
9472 (n (abs n))
9473 (mark (or mark gnus-del-mark)))
9474 (while (and (> n 0)
9475 (gnus-summary-mark-article nil mark no-expire)
9476 (zerop (gnus-summary-next-subject
9477 (if backward -1 1) gnus-summary-goto-unread t)))
9478 (setq n (1- n)))
9479 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9480 (gnus-summary-recenter)
9481 (gnus-summary-position-cursor)
9482 (gnus-set-mode-line 'summary)
9485 (defun gnus-summary-mark-article-as-read (mark)
9486 "Mark the current article quickly as read with MARK."
9487 (let ((article (gnus-summary-article-number)))
9488 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9489 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9490 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9491 (setq gnus-newsgroup-reads
9492 (cons (cons article mark) gnus-newsgroup-reads))
9493 ;; Possibly remove from cache, if that is used.
9494 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9495 (and gnus-newsgroup-auto-expire
9496 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9497 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9498 (= mark gnus-read-mark))
9499 (progn
9500 (setq mark gnus-expirable-mark)
9501 (setq gnus-newsgroup-expirable
9502 (cons article gnus-newsgroup-expirable))))
9503 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9504 (forward-line 1))
9505 ;; Fix the mark.
9506 (gnus-summary-update-mark mark 'unread)
9509 (defun gnus-summary-mark-article-as-unread (mark)
9510 "Mark the current article quickly as unread with MARK."
9511 (let ((article (gnus-summary-article-number)))
9512 (or (memq article gnus-newsgroup-unreads)
9513 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9514 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9515 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9516 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9517 (setq gnus-newsgroup-reads
9518 (delq (assq article gnus-newsgroup-reads)
9519 gnus-newsgroup-reads))
9520 (if (= mark gnus-ticked-mark)
9521 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9522 (if (= mark gnus-dormant-mark)
9523 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9525 ;; See whether the article is to be put in the cache.
9526 (and gnus-use-cache
9527 (vectorp (gnus-get-header-by-num article))
9528 (save-excursion
9529 (gnus-cache-possibly-enter-article
9530 gnus-newsgroup-name article
9531 (gnus-get-header-by-num article)
9532 (= mark gnus-ticked-mark)
9533 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
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 (&optional article mark no-expire)
9542 "Mark ARTICLE with MARK. MARK can be any character.
9543 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9544 (dormant) and `?E' (expirable).
9545 If MARK is nil, then the default character `?D' is used.
9546 If ARTICLE is nil, then the article on the current line will be
9547 marked."
9548 (and (stringp mark)
9549 (setq mark (aref mark 0)))
9550 ;; If no mark is given, then we check auto-expiring.
9551 (and (not no-expire)
9552 gnus-newsgroup-auto-expire
9553 (or (not mark)
9554 (and (numberp mark)
9555 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9556 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9557 (= mark gnus-read-mark))))
9558 (setq mark gnus-expirable-mark))
9559 (let* ((mark (or mark gnus-del-mark))
9560 (article (or article (gnus-summary-article-number))))
9561 (or article (error "No article on current line"))
9562 (if (or (= mark gnus-unread-mark)
9563 (= mark gnus-ticked-mark)
9564 (= mark gnus-dormant-mark))
9565 (gnus-mark-article-as-unread article mark)
9566 (gnus-mark-article-as-read article mark))
9568 ;; See whether the article is to be put in the cache.
9569 (and gnus-use-cache
9570 (not (= mark gnus-canceled-mark))
9571 (vectorp (gnus-get-header-by-num article))
9572 (save-excursion
9573 (gnus-cache-possibly-enter-article
9574 gnus-newsgroup-name article
9575 (gnus-get-header-by-num article)
9576 (= mark gnus-ticked-mark)
9577 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9579 (if (gnus-summary-goto-subject article)
9580 (let ((buffer-read-only nil))
9581 (gnus-summary-show-thread)
9582 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9583 (forward-line 1))
9584 ;; Fix the mark.
9585 (gnus-summary-update-mark mark 'unread)
9586 t))))
9588 (defun gnus-summary-update-mark (mark type)
9589 (beginning-of-line)
9590 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9591 (buffer-read-only nil)
9592 plist)
9593 (if (not forward)
9595 (forward-char forward)
9596 (setq plist (text-properties-at (point)))
9597 (delete-char 1)
9598 (insert mark)
9599 (and plist (add-text-properties (1- (point)) (point) plist))
9600 (and (eq type 'unread)
9601 (progn
9602 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark))
9603 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9605 (defun gnus-mark-article-as-read (article &optional mark)
9606 "Enter ARTICLE in the pertinent lists and remove it from others."
9607 ;; Make the article expirable.
9608 (let ((mark (or mark gnus-del-mark)))
9609 (if (= mark gnus-expirable-mark)
9610 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9611 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9612 ;; Remove from unread and marked lists.
9613 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9614 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9615 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9616 (setq gnus-newsgroup-reads
9617 (cons (cons article mark) gnus-newsgroup-reads))
9618 ;; Possibly remove from cache, if that is used.
9619 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9621 (defun gnus-mark-article-as-unread (article &optional mark)
9622 "Enter ARTICLE in the pertinent lists and remove it from others."
9623 (let ((mark (or mark gnus-ticked-mark)))
9624 ;; Add to unread list.
9625 (or (memq article gnus-newsgroup-unreads)
9626 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9627 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9628 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9629 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9630 (setq gnus-newsgroup-reads
9631 (delq (assq article gnus-newsgroup-reads)
9632 gnus-newsgroup-reads))
9633 (if (= mark gnus-ticked-mark)
9634 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9635 (if (= mark gnus-dormant-mark)
9636 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9638 (defalias 'gnus-summary-mark-as-unread-forward
9639 'gnus-summary-tick-article-forward)
9640 (make-obsolete 'gnus-summary-mark-as-unread-forward
9641 'gnus-summary-tick-article-forward)
9642 (defun gnus-summary-tick-article-forward (n)
9643 "Tick N articles forwards.
9644 If N is negative, tick backwards instead.
9645 The difference between N and the number of articles ticked is returned."
9646 (interactive "p")
9647 (gnus-summary-mark-forward n gnus-ticked-mark))
9649 (defalias 'gnus-summary-mark-as-unread-backward
9650 'gnus-summary-tick-article-backward)
9651 (make-obsolete 'gnus-summary-mark-as-unread-backward
9652 'gnus-summary-tick-article-backward)
9653 (defun gnus-summary-tick-article-backward (n)
9654 "Tick N articles backwards.
9655 The difference between N and the number of articles ticked is returned."
9656 (interactive "p")
9657 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9659 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9660 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9661 (defun gnus-summary-tick-article (&optional article clear-mark)
9662 "Mark current article as unread.
9663 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9664 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9665 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9666 gnus-ticked-mark)))
9668 (defun gnus-summary-mark-as-read-forward (n)
9669 "Mark N articles as read forwards.
9670 If N is negative, mark backwards instead.
9671 The difference between N and the actual number of articles marked is
9672 returned."
9673 (interactive "p")
9674 (gnus-summary-mark-forward n gnus-del-mark t))
9676 (defun gnus-summary-mark-as-read-backward (n)
9677 "Mark the N articles as read backwards.
9678 The difference between N and the actual number of articles marked is
9679 returned."
9680 (interactive "p")
9681 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9683 (defun gnus-summary-mark-as-read (&optional article mark)
9684 "Mark current article as read.
9685 ARTICLE specifies the article to be marked as read.
9686 MARK specifies a string to be inserted at the beginning of the line."
9687 (gnus-summary-mark-article article mark))
9689 (defun gnus-summary-clear-mark-forward (n)
9690 "Clear marks from N articles forward.
9691 If N is negative, clear backward instead.
9692 The difference between N and the number of marks cleared is returned."
9693 (interactive "p")
9694 (gnus-summary-mark-forward n gnus-unread-mark))
9696 (defun gnus-summary-clear-mark-backward (n)
9697 "Clear marks from N articles backward.
9698 The difference between N and the number of marks cleared is returned."
9699 (interactive "p")
9700 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9702 (defun gnus-summary-mark-unread-as-read ()
9703 "Intended to be used by `gnus-summary-mark-article-hook'."
9704 (or (memq gnus-current-article gnus-newsgroup-marked)
9705 (memq gnus-current-article gnus-newsgroup-dormant)
9706 (memq gnus-current-article gnus-newsgroup-expirable)
9707 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9709 (defun gnus-summary-mark-region-as-read (point mark all)
9710 "Mark all unread articles between point and mark as read.
9711 If given a prefix, mark all articles between point and mark as read,
9712 even ticked and dormant ones."
9713 (interactive "r\nP")
9714 (save-excursion
9715 (goto-char point)
9716 (beginning-of-line)
9717 (while (and
9718 (< (point) mark)
9719 (progn
9720 (and
9721 (or all
9722 (and
9723 (not (memq (gnus-summary-article-number)
9724 gnus-newsgroup-marked))
9725 (not (memq (gnus-summary-article-number)
9726 gnus-newsgroup-dormant))))
9727 (gnus-summary-mark-article
9728 (gnus-summary-article-number) gnus-del-mark))
9730 (zerop (forward-line 1))))))
9732 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9733 (defalias 'gnus-summary-delete-marked-as-read
9734 'gnus-summary-remove-lines-marked-as-read)
9735 (make-obsolete 'gnus-summary-delete-marked-as-read
9736 'gnus-summary-remove-lines-marked-as-read)
9737 (defun gnus-summary-remove-lines-marked-as-read ()
9738 "Remove lines that are marked as read."
9739 (interactive)
9740 (gnus-summary-remove-lines-marked-with
9741 (concat (mapconcat
9742 (lambda (char) (char-to-string (symbol-value char)))
9743 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9744 gnus-killed-mark gnus-kill-file-mark
9745 gnus-low-score-mark gnus-expirable-mark
9746 gnus-canceled-mark gnus-catchup-mark)
9747 ""))))
9749 (defalias 'gnus-summary-delete-marked-with
9750 'gnus-summary-remove-lines-marked-with)
9751 (make-obsolete 'gnus-summary-delete-marked-with
9752 'gnus-summary-remove-lines-marked-with)
9753 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9754 (defun gnus-summary-remove-lines-marked-with (marks)
9755 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9756 (interactive "sMarks: ")
9757 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9758 (gnus-set-global-variables)
9759 (let ((buffer-read-only nil)
9760 (orig-article (gnus-summary-article-number))
9761 (marks (concat "^[" marks "]")))
9762 (goto-char (point-min))
9763 (if gnus-newsgroup-adaptive
9764 (gnus-score-remove-lines-adaptive marks)
9765 (while (re-search-forward marks nil t)
9766 (gnus-delete-line)))
9767 ;; If we use dummy roots, we have to do an additional sweep over
9768 ;; the buffer.
9769 (if (not (eq gnus-summary-make-false-root 'dummy))
9771 (goto-char (point-min))
9772 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9773 (while (re-search-forward marks nil t)
9774 (if (gnus-subject-equal
9775 (gnus-summary-subject-string)
9776 (progn
9777 (forward-line 1)
9778 (gnus-summary-subject-string)))
9780 (forward-line -1)
9781 (gnus-delete-line))))
9782 (or (zerop (buffer-size))
9783 (gnus-summary-goto-subject orig-article)
9784 (if (eobp)
9785 (gnus-summary-prev-subject 1)
9786 (gnus-summary-position-cursor)))))
9788 (defun gnus-summary-expunge-below (&optional score)
9789 "Remove articles with score less than SCORE."
9790 (interactive "P")
9791 (gnus-set-global-variables)
9792 (setq score (if score
9793 (prefix-numeric-value score)
9794 (or gnus-summary-default-score 0)))
9795 (save-excursion
9796 (set-buffer gnus-summary-buffer)
9797 (goto-char (point-min))
9798 (let ((buffer-read-only nil)
9799 beg)
9800 (while (not (eobp))
9801 (if (< (gnus-summary-article-score) score)
9802 (progn
9803 (setq beg (point))
9804 (forward-line 1)
9805 (delete-region beg (point)))
9806 (forward-line 1)))
9807 ;; Adjust point.
9808 (or (zerop (buffer-size))
9809 (if (eobp)
9810 (gnus-summary-prev-subject 1)
9811 (gnus-summary-position-cursor))))))
9813 (defun gnus-summary-mark-below (score mark)
9814 "Mark articles with score less than SCORE with MARK."
9815 (interactive "P\ncMark: ")
9816 (gnus-set-global-variables)
9817 (setq score (if score
9818 (prefix-numeric-value score)
9819 (or gnus-summary-default-score 0)))
9820 (save-excursion
9821 (set-buffer gnus-summary-buffer)
9822 (goto-char (point-min))
9823 (while (not (eobp))
9824 (and (< (gnus-summary-article-score) score)
9825 (gnus-summary-mark-article nil mark))
9826 (forward-line 1))))
9828 (defun gnus-summary-kill-below (&optional score)
9829 "Mark articles with score below SCORE as read."
9830 (interactive "P")
9831 (gnus-set-global-variables)
9832 (gnus-summary-mark-below score gnus-killed-mark))
9834 (defun gnus-summary-clear-above (&optional score)
9835 "Clear all marks from articles with score above SCORE."
9836 (interactive "P")
9837 (gnus-set-global-variables)
9838 (gnus-summary-mark-above score gnus-unread-mark))
9840 (defun gnus-summary-tick-above (&optional score)
9841 "Tick all articles with score above SCORE."
9842 (interactive "P")
9843 (gnus-set-global-variables)
9844 (gnus-summary-mark-above score gnus-ticked-mark))
9846 (defun gnus-summary-mark-above (score mark)
9847 "Mark articles with score over SCORE with MARK."
9848 (interactive "P\ncMark: ")
9849 (gnus-set-global-variables)
9850 (setq score (if score
9851 (prefix-numeric-value score)
9852 (or gnus-summary-default-score 0)))
9853 (save-excursion
9854 (set-buffer gnus-summary-buffer)
9855 (goto-char (point-min))
9856 (while (not (eobp))
9857 (if (> (gnus-summary-article-score) score)
9858 (progn
9859 (gnus-summary-mark-article nil mark)
9860 (forward-line 1))
9861 (forward-line 1)))))
9863 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9864 (defun gnus-summary-show-all-expunged ()
9865 "Display all the hidden articles that were expunged for low scores."
9866 (interactive)
9867 (gnus-set-global-variables)
9868 (let ((buffer-read-only nil))
9869 (let ((scored gnus-newsgroup-scored)
9870 headers h)
9871 (while scored
9872 (or (gnus-summary-goto-subject (car (car scored)))
9873 (and (setq h (gnus-get-header-by-num (car (car scored))))
9874 (< (cdr (car scored)) gnus-summary-expunge-below)
9875 (setq headers (cons h headers))))
9876 (setq scored (cdr scored)))
9877 (or headers (error "No expunged articles hidden."))
9878 (goto-char (point-min))
9879 (save-excursion
9880 (gnus-summary-update-lines
9881 (point)
9882 (progn
9883 (gnus-summary-prepare-unthreaded (nreverse headers))
9884 (point)))))
9885 (goto-char (point-min))
9886 (gnus-summary-position-cursor)))
9888 (defun gnus-summary-show-all-dormant ()
9889 "Display all the hidden articles that are marked as dormant."
9890 (interactive)
9891 (gnus-set-global-variables)
9892 (let ((buffer-read-only nil))
9893 (let ((dormant gnus-newsgroup-dormant)
9894 headers h)
9895 (while dormant
9896 (or (gnus-summary-goto-subject (car dormant))
9897 (and (setq h (gnus-get-header-by-num (car dormant)))
9898 (setq headers (cons h headers))))
9899 (setq dormant (cdr dormant)))
9900 (or headers (error "No dormant articles hidden."))
9901 (goto-char (point-min))
9902 (save-excursion
9903 (gnus-summary-update-lines
9904 (point)
9905 (progn
9906 (gnus-summary-prepare-unthreaded (nreverse headers))
9907 (point)))))
9908 (goto-char (point-min))
9909 (gnus-summary-position-cursor)))
9911 (defun gnus-summary-hide-all-dormant ()
9912 "Hide all dormant articles."
9913 (interactive)
9914 (gnus-set-global-variables)
9915 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9916 (gnus-summary-position-cursor))
9918 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9919 "Mark all articles not marked as unread in this newsgroup as read.
9920 If prefix argument ALL is non-nil, all articles are marked as read.
9921 If QUIETLY is non-nil, no questions will be asked.
9922 If TO-HERE is non-nil, it should be a point in the buffer. All
9923 articles before this point will be marked as read.
9924 The number of articles marked as read is returned."
9925 (interactive "P")
9926 (gnus-set-global-variables)
9927 (prog1
9928 (if (or quietly
9929 (not gnus-interactive-catchup) ;Without confirmation?
9930 gnus-expert-user
9931 (gnus-y-or-n-p
9932 (if all
9933 "Mark absolutely all articles as read? "
9934 "Mark all unread articles as read? ")))
9935 (if (and not-mark
9936 (not gnus-newsgroup-adaptive)
9937 (not gnus-newsgroup-auto-expire))
9938 (progn
9939 (and all (setq gnus-newsgroup-marked nil
9940 gnus-newsgroup-dormant nil))
9941 (setq gnus-newsgroup-unreads
9942 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9943 ;; We actually mark all articles as canceled, which we
9944 ;; have to do when using auto-expiry or adaptive scoring.
9945 (gnus-summary-show-all-threads)
9946 (if (gnus-summary-first-subject (not all))
9947 (while (and
9948 (if to-here (< (point) to-here) t)
9949 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9950 (gnus-summary-search-subject nil (not all)))))
9951 (or to-here
9952 (setq gnus-newsgroup-unreads
9953 (append gnus-newsgroup-marked
9954 gnus-newsgroup-dormant)))))
9955 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9956 (if (and (not to-here) (eq 'nnvirtual (car method)))
9957 (nnvirtual-catchup-group
9958 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9959 (gnus-summary-position-cursor)))
9961 (defun gnus-summary-catchup-to-here (&optional all)
9962 "Mark all unticked articles before the current one as read.
9963 If ALL is non-nil, also mark ticked and dormant articles as read."
9964 (interactive "P")
9965 (gnus-set-global-variables)
9966 (save-excursion
9967 (and (zerop (forward-line -1))
9968 (progn
9969 (end-of-line)
9970 (gnus-summary-catchup all t (point))
9971 (gnus-set-mode-line 'summary))))
9972 (gnus-summary-position-cursor))
9974 (defun gnus-summary-catchup-all (&optional quietly)
9975 "Mark all articles in this newsgroup as read."
9976 (interactive "P")
9977 (gnus-set-global-variables)
9978 (gnus-summary-catchup t quietly))
9980 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9981 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9982 If prefix argument ALL is non-nil, all articles are marked as read."
9983 (interactive "P")
9984 (gnus-set-global-variables)
9985 (gnus-summary-catchup all quietly nil 'fast)
9986 ;; Select next newsgroup or exit.
9987 (if (and (eq gnus-auto-select-next 'quietly)
9988 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
9989 (gnus-summary-next-group nil)
9990 (gnus-summary-exit)))
9992 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9993 "Mark all articles in this newsgroup as read, and then exit."
9994 (interactive "P")
9995 (gnus-set-global-variables)
9996 (gnus-summary-catchup-and-exit t quietly))
9998 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9999 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10000 "Mark all articles in this group as read and select the next group.
10001 If given a prefix, mark all articles, unread as well as ticked, as
10002 read."
10003 (interactive "P")
10004 (gnus-set-global-variables)
10005 (gnus-summary-catchup all)
10006 (gnus-summary-next-group))
10008 ;; Thread-based commands.
10010 (defun gnus-summary-toggle-threads (&optional arg)
10011 "Toggle showing conversation threads.
10012 If ARG is positive number, turn showing conversation threads on."
10013 (interactive "P")
10014 (gnus-set-global-variables)
10015 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10016 (setq gnus-show-threads
10017 (if (null arg) (not gnus-show-threads)
10018 (> (prefix-numeric-value arg) 0)))
10019 (gnus-summary-prepare)
10020 (gnus-summary-goto-subject current)
10021 (gnus-summary-position-cursor)))
10023 (defun gnus-summary-show-all-threads ()
10024 "Show all threads."
10025 (interactive)
10026 (gnus-set-global-variables)
10027 (save-excursion
10028 (let ((buffer-read-only nil))
10029 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10030 (gnus-summary-position-cursor))
10032 (defun gnus-summary-show-thread ()
10033 "Show thread subtrees.
10034 Returns nil if no thread was there to be shown."
10035 (interactive)
10036 (gnus-set-global-variables)
10037 (let ((buffer-read-only nil)
10038 (orig (prog1 (point) (gnus-summary-hide-thread)))
10039 ;; first goto end then to beg, to have point at beg after let
10040 (end (progn (end-of-line) (point)))
10041 (beg (progn (beginning-of-line) (point))))
10042 (prog1
10043 ;; Any hidden lines here?
10044 (search-forward "\r" end t)
10045 (subst-char-in-region beg end ?\^M ?\n t)
10046 (goto-char orig)
10047 (gnus-summary-position-cursor))))
10049 (defun gnus-summary-hide-all-threads ()
10050 "Hide all thread subtrees."
10051 (interactive)
10052 (gnus-set-global-variables)
10053 (save-excursion
10054 (goto-char (point-min))
10055 (gnus-summary-hide-thread)
10056 (while (and (not (eobp)) (zerop (forward-line 1)))
10057 (gnus-summary-hide-thread)))
10058 (gnus-summary-position-cursor))
10060 (defun gnus-summary-hide-thread ()
10061 "Hide thread subtrees.
10062 Returns nil if no threads were there to be hidden."
10063 (interactive)
10064 (gnus-set-global-variables)
10065 (let ((buffer-read-only nil)
10066 (start (point))
10067 (level (gnus-summary-thread-level))
10068 (end (point)))
10069 ;; Go forward until either the buffer ends or the subthread
10070 ;; ends.
10071 (if (eobp)
10073 (while (and (zerop (forward-line 1))
10074 (> (gnus-summary-thread-level) level))
10075 (setq end (point)))
10076 (prog1
10077 (save-excursion
10078 (goto-char end)
10079 (search-backward "\n" start t))
10080 (subst-char-in-region start end ?\n ?\^M t)
10081 (forward-line -1)
10082 (gnus-summary-position-cursor)))))
10084 (defun gnus-summary-go-to-next-thread (&optional previous)
10085 "Go to the same level (or less) next thread.
10086 If PREVIOUS is non-nil, go to previous thread instead.
10087 Return the article number moved to, or nil if moving was impossible."
10088 (let ((level (gnus-summary-thread-level))
10089 (article (gnus-summary-article-number)))
10090 (if previous
10091 (while (and (zerop (forward-line -1))
10092 (> (gnus-summary-thread-level) level)))
10093 (while (and (save-excursion
10094 (forward-line 1)
10095 (not (eobp)))
10096 (zerop (forward-line 1))
10097 (> (gnus-summary-thread-level) level))))
10098 (gnus-summary-recenter)
10099 (gnus-summary-position-cursor)
10100 (let ((oart (gnus-summary-article-number)))
10101 (and (/= oart article) oart))))
10103 (defun gnus-summary-next-thread (n)
10104 "Go to the same level next N'th thread.
10105 If N is negative, search backward instead.
10106 Returns the difference between N and the number of skips actually
10107 done."
10108 (interactive "p")
10109 (gnus-set-global-variables)
10110 (let ((backward (< n 0))
10111 (n (abs n)))
10112 (while (and (> n 0)
10113 (gnus-summary-go-to-next-thread backward))
10114 (setq n (1- n)))
10115 (gnus-summary-position-cursor)
10116 (if (/= 0 n) (gnus-message 7 "No more threads"))
10119 (defun gnus-summary-prev-thread (n)
10120 "Go to the same level previous N'th thread.
10121 Returns the difference between N and the number of skips actually
10122 done."
10123 (interactive "p")
10124 (gnus-set-global-variables)
10125 (gnus-summary-next-thread (- n)))
10127 (defun gnus-summary-go-down-thread (&optional same)
10128 "Go down one level in the current thread.
10129 If SAME is non-nil, also move to articles of the same level."
10130 (let ((level (gnus-summary-thread-level))
10131 (start (point)))
10132 (if (and (zerop (forward-line 1))
10133 (> (gnus-summary-thread-level) level))
10135 (goto-char start)
10136 nil)))
10138 (defun gnus-summary-go-up-thread ()
10139 "Go up one level in the current thread."
10140 (let ((level (gnus-summary-thread-level))
10141 (start (point)))
10142 (while (and (zerop (forward-line -1))
10143 (>= (gnus-summary-thread-level) level)))
10144 (if (>= (gnus-summary-thread-level) level)
10145 (progn
10146 (goto-char start)
10147 nil)
10148 t)))
10150 (defun gnus-summary-down-thread (n)
10151 "Go down thread N steps.
10152 If N is negative, go up instead.
10153 Returns the difference between N and how many steps down that were
10154 taken."
10155 (interactive "p")
10156 (gnus-set-global-variables)
10157 (let ((up (< n 0))
10158 (n (abs n)))
10159 (while (and (> n 0)
10160 (if up (gnus-summary-go-up-thread)
10161 (gnus-summary-go-down-thread)))
10162 (setq n (1- n)))
10163 (gnus-summary-position-cursor)
10164 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10167 (defun gnus-summary-up-thread (n)
10168 "Go up thread N steps.
10169 If N is negative, go up instead.
10170 Returns the difference between N and how many steps down that were
10171 taken."
10172 (interactive "p")
10173 (gnus-set-global-variables)
10174 (gnus-summary-down-thread (- n)))
10176 (defun gnus-summary-kill-thread (&optional unmark)
10177 "Mark articles under current thread as read.
10178 If the prefix argument is positive, remove any kinds of marks.
10179 If the prefix argument is negative, tick articles instead."
10180 (interactive "P")
10181 (gnus-set-global-variables)
10182 (if unmark
10183 (setq unmark (prefix-numeric-value unmark)))
10184 (let ((killing t)
10185 (level (gnus-summary-thread-level)))
10186 (save-excursion
10187 ;; Expand the thread.
10188 (gnus-summary-show-thread)
10189 (while killing
10190 ;; Mark the article...
10191 (cond ((null unmark) (gnus-summary-mark-article-as-read
10192 gnus-killed-mark))
10193 ((> unmark 0) (gnus-summary-mark-article-as-unread
10194 gnus-unread-mark))
10195 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10196 ;; ...and go forward until either the buffer ends or the subtree
10197 ;; ends.
10198 (if (not (and (zerop (forward-line 1))
10199 (> (gnus-summary-thread-level) level)))
10200 (setq killing nil))))
10201 ;; Hide killed subtrees.
10202 (and (null unmark)
10203 gnus-thread-hide-killed
10204 (gnus-summary-hide-thread))
10205 ;; If marked as read, go to next unread subject.
10206 (if (null unmark)
10207 ;; Go to next unread subject.
10208 (gnus-summary-next-subject 1 t)))
10209 (gnus-set-mode-line 'summary))
10211 ;; Summary sorting commands
10213 (defun gnus-summary-sort-by-number (&optional reverse)
10214 "Sort summary buffer by article number.
10215 Argument REVERSE means reverse order."
10216 (interactive "P")
10217 (gnus-set-global-variables)
10218 (gnus-summary-sort
10219 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10220 ;; a function, so we wrap it.
10221 (cons (lambda () (gnus-summary-article-number))
10222 'gnus-thread-sort-by-number) reverse))
10224 (defun gnus-summary-sort-by-author (&optional reverse)
10225 "Sort summary buffer by author name alphabetically.
10226 If case-fold-search is non-nil, case of letters is ignored.
10227 Argument REVERSE means reverse order."
10228 (interactive "P")
10229 (gnus-set-global-variables)
10230 (gnus-summary-sort
10231 (cons
10232 (lambda ()
10233 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10234 (extract (funcall
10235 gnus-extract-address-components
10236 (mail-header-from header))))
10237 (concat (or (car extract) (cdr extract))
10238 "\r" (int-to-string (mail-header-number header))
10239 "\r" (mail-header-subject header))))
10240 'gnus-thread-sort-by-author)
10241 reverse))
10243 (defun gnus-summary-sort-by-subject (&optional reverse)
10244 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10245 If case-fold-search is non-nil, case of letters is ignored.
10246 Argument REVERSE means reverse order."
10247 (interactive "P")
10248 (gnus-set-global-variables)
10249 (gnus-summary-sort
10250 (cons
10251 (lambda ()
10252 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10253 (extract (funcall
10254 gnus-extract-address-components
10255 (mail-header-from header))))
10256 (concat
10257 (downcase (gnus-simplify-subject (gnus-summary-subject-string) t))
10258 "\r" (int-to-string (mail-header-number header))
10259 "\r" (or (car extract) (cdr extract)))))
10260 'gnus-thread-sort-by-subject)
10261 reverse))
10263 (defun gnus-summary-sort-by-date (&optional reverse)
10264 "Sort summary buffer by date.
10265 Argument REVERSE means reverse order."
10266 (interactive "P")
10267 (gnus-set-global-variables)
10268 (gnus-summary-sort
10269 (cons
10270 (lambda ()
10271 (gnus-sortable-date
10272 (mail-header-date
10273 (gnus-get-header-by-num (gnus-summary-article-number)))))
10274 'gnus-thread-sort-by-date)
10275 reverse))
10277 (defun gnus-summary-sort-by-score (&optional reverse)
10278 "Sort summary buffer by score.
10279 Argument REVERSE means reverse order."
10280 (interactive "P")
10281 (gnus-set-global-variables)
10282 (gnus-summary-sort
10283 (cons (lambda () (gnus-summary-article-score))
10284 'gnus-thread-sort-by-score)
10285 (not reverse)))
10287 (defvar gnus-summary-already-sorted nil)
10288 (defun gnus-summary-sort (predicate reverse)
10289 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10290 (if gnus-summary-already-sorted
10292 (let (buffer-read-only)
10293 (if (not gnus-show-threads)
10294 ;; We do untreaded sorting...
10295 (progn
10296 (goto-char (point-min))
10297 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10298 ;; ... or we do threaded sorting.
10299 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10300 (gnus-summary-prepare-hook nil)
10301 (gnus-summary-already-sorted nil))
10302 ;; We do that by simply regenerating the threads.
10303 (gnus-summary-prepare)
10304 (and gnus-show-threads
10305 gnus-thread-hide-subtree
10306 (gnus-summary-hide-all-threads))
10307 ;; If in async mode, we send some info to the backend.
10308 (and gnus-newsgroup-async
10309 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10310 (gnus-request-asynchronous
10311 gnus-newsgroup-name
10312 (if (and gnus-asynchronous-article-function
10313 (fboundp gnus-asynchronous-article-function))
10314 (funcall gnus-asynchronous-article-function
10315 gnus-newsgroup-threads)
10316 gnus-newsgroup-threads))))))))
10319 (defun gnus-sortable-date (date)
10320 "Make sortable string by string-lessp from DATE.
10321 Timezone package is used."
10322 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10323 (year (aref date 0))
10324 (month (aref date 1))
10325 (day (aref date 2)))
10326 (timezone-make-sortable-date
10327 year month day
10328 (timezone-make-time-string
10329 (aref date 3) (aref date 4) (aref date 5)))))
10332 ;; Summary saving commands.
10334 (defun gnus-summary-save-article (&optional n)
10335 "Save the current article using the default saver function.
10336 If N is a positive number, save the N next articles.
10337 If N is a negative number, save the N previous articles.
10338 If N is nil and any articles have been marked with the process mark,
10339 save those articles instead.
10340 The variable `gnus-default-article-saver' specifies the saver function."
10341 (interactive "P")
10342 (gnus-set-global-variables)
10343 (let ((articles (gnus-summary-work-articles n)))
10344 (while articles
10345 (let ((header (gnus-get-header-by-num (car articles))))
10346 (if (vectorp header)
10347 (progn
10348 (save-window-excursion
10349 (gnus-summary-select-article t nil nil (car articles)))
10350 (or gnus-save-all-headers
10351 (gnus-article-hide-headers t))
10352 ;; Remove any X-Gnus lines.
10353 (save-excursion
10354 (save-restriction
10355 (set-buffer gnus-article-buffer)
10356 (let ((buffer-read-only nil))
10357 (goto-char (point-min))
10358 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10359 (point-max)))
10360 (while (re-search-forward "^X-Gnus" nil t)
10361 (beginning-of-line)
10362 (delete-region (point)
10363 (progn (forward-line 1) (point))))
10364 (widen))))
10365 (save-window-excursion
10366 (if gnus-default-article-saver
10367 (funcall gnus-default-article-saver)
10368 (error "No default saver is defined."))))
10369 (if (assq 'name header)
10370 (gnus-copy-file (cdr (assq 'name header)))
10371 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10372 (gnus-summary-remove-process-mark (car articles))
10373 (setq articles (cdr articles)))
10374 (gnus-summary-position-cursor)
10377 (defun gnus-summary-pipe-output (&optional arg)
10378 "Pipe the current article to a subprocess.
10379 If N is a positive number, pipe the N next articles.
10380 If N is a negative number, pipe the N previous articles.
10381 If N is nil and any articles have been marked with the process mark,
10382 pipe those articles instead."
10383 (interactive "P")
10384 (gnus-set-global-variables)
10385 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10386 (gnus-summary-save-article arg)))
10388 (defun gnus-summary-save-article-mail (&optional arg)
10389 "Append the current article to an mail file.
10390 If N is a positive number, save the N next articles.
10391 If N is a negative number, save the N previous articles.
10392 If N is nil and any articles have been marked with the process mark,
10393 save those articles instead."
10394 (interactive "P")
10395 (gnus-set-global-variables)
10396 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10397 (gnus-summary-save-article arg)))
10399 (defun gnus-summary-save-article-rmail (&optional arg)
10400 "Append the current article to an rmail file.
10401 If N is a positive number, save the N next articles.
10402 If N is a negative number, save the N previous articles.
10403 If N is nil and any articles have been marked with the process mark,
10404 save those articles instead."
10405 (interactive "P")
10406 (gnus-set-global-variables)
10407 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10408 (gnus-summary-save-article arg)))
10410 (defun gnus-summary-save-article-file (&optional arg)
10411 "Append the current article to a file.
10412 If N is a positive number, save the N next articles.
10413 If N is a negative number, save the N previous articles.
10414 If N is nil and any articles have been marked with the process mark,
10415 save those articles instead."
10416 (interactive "P")
10417 (gnus-set-global-variables)
10418 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10419 (gnus-summary-save-article arg)))
10421 (defun gnus-read-save-file-name (prompt default-name)
10422 (let ((methods gnus-split-methods)
10423 split-name)
10424 (if (not gnus-split-methods)
10426 (save-excursion
10427 (set-buffer gnus-article-buffer)
10428 (gnus-narrow-to-headers)
10429 (while methods
10430 (goto-char (point-min))
10431 (and (condition-case ()
10432 (re-search-forward (car (car methods)) nil t)
10433 (error nil))
10434 (setq split-name (cons (nth 1 (car methods)) split-name)))
10435 (setq methods (cdr methods)))
10436 (widen)))
10437 (cond ((null split-name)
10438 (read-file-name
10439 (concat prompt " (default "
10440 (file-name-nondirectory default-name) ") ")
10441 (file-name-directory default-name)
10442 default-name))
10443 ((= 1 (length split-name))
10444 (read-file-name
10445 (concat prompt " (default " (car split-name) ") ")
10446 gnus-article-save-directory
10447 (concat gnus-article-save-directory (car split-name))))
10449 (setq split-name (mapcar (lambda (el) (list el))
10450 (nreverse split-name)))
10451 (let ((result (completing-read
10452 (concat prompt " ")
10453 split-name nil nil)))
10454 (concat gnus-article-save-directory
10455 (if (string= result "")
10456 (car (car split-name))
10457 result)))))))
10459 (defun gnus-summary-save-in-rmail (&optional filename)
10460 "Append this article to Rmail file.
10461 Optional argument FILENAME specifies file name.
10462 Directory to save to is default to `gnus-article-save-directory' which
10463 is initialized from the SAVEDIR environment variable."
10464 (interactive)
10465 (gnus-set-global-variables)
10466 (let ((default-name
10467 (funcall gnus-rmail-save-name gnus-newsgroup-name
10468 gnus-current-headers gnus-newsgroup-last-rmail)))
10469 (or filename
10470 (setq filename (gnus-read-save-file-name
10471 "Save in rmail file:" default-name)))
10472 (gnus-make-directory (file-name-directory filename))
10473 (gnus-eval-in-buffer-window
10474 gnus-article-buffer
10475 (save-excursion
10476 (save-restriction
10477 (widen)
10478 (gnus-output-to-rmail filename))))
10479 ;; Remember the directory name to save articles
10480 (setq gnus-newsgroup-last-rmail filename)))
10482 (defun gnus-summary-save-in-mail (&optional filename)
10483 "Append this article to Unix mail file.
10484 Optional argument FILENAME specifies file name.
10485 Directory to save to is default to `gnus-article-save-directory' which
10486 is initialized from the SAVEDIR environment variable."
10487 (interactive)
10488 (gnus-set-global-variables)
10489 (let ((default-name
10490 (funcall gnus-mail-save-name gnus-newsgroup-name
10491 gnus-current-headers gnus-newsgroup-last-mail)))
10492 (or filename
10493 (setq filename (gnus-read-save-file-name
10494 "Save in Unix mail file:" default-name)))
10495 (setq filename
10496 (expand-file-name filename
10497 (and default-name
10498 (file-name-directory default-name))))
10499 (gnus-make-directory (file-name-directory filename))
10500 (gnus-eval-in-buffer-window
10501 gnus-article-buffer
10502 (save-excursion
10503 (save-restriction
10504 (widen)
10505 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
10506 (gnus-output-to-rmail filename)
10507 (rmail-output filename 1 t t)))))
10508 ;; Remember the directory name to save articles.
10509 (setq gnus-newsgroup-last-mail filename)))
10511 (defun gnus-summary-save-in-file (&optional filename)
10512 "Append this article to file.
10513 Optional argument FILENAME specifies file name.
10514 Directory to save to is default to `gnus-article-save-directory' which
10515 is initialized from the SAVEDIR environment variable."
10516 (interactive)
10517 (gnus-set-global-variables)
10518 (let ((default-name
10519 (funcall gnus-file-save-name gnus-newsgroup-name
10520 gnus-current-headers gnus-newsgroup-last-file)))
10521 (or filename
10522 (setq filename (gnus-read-save-file-name
10523 "Save in file:" default-name)))
10524 (gnus-make-directory (file-name-directory filename))
10525 (gnus-eval-in-buffer-window
10526 gnus-article-buffer
10527 (save-excursion
10528 (save-restriction
10529 (widen)
10530 (gnus-output-to-file filename))))
10531 ;; Remember the directory name to save articles.
10532 (setq gnus-newsgroup-last-file filename)))
10534 (defun gnus-summary-save-in-pipe (&optional command)
10535 "Pipe this article to subprocess."
10536 (interactive)
10537 (gnus-set-global-variables)
10538 (let ((command (read-string "Shell command on article: "
10539 gnus-last-shell-command)))
10540 (if (string-equal command "")
10541 (setq command gnus-last-shell-command))
10542 (gnus-eval-in-buffer-window
10543 gnus-article-buffer
10544 (save-restriction
10545 (widen)
10546 (shell-command-on-region (point-min) (point-max) command nil)))
10547 (setq gnus-last-shell-command command)))
10549 ;; Summary extract commands
10551 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10552 (let ((buffer-read-only nil)
10553 (article (gnus-summary-article-number))
10555 (or (gnus-summary-goto-subject article)
10556 (error (format "No such article: %d" article)))
10557 (gnus-summary-position-cursor)
10558 ;; If all commands are to be bunched up on one line, we collect
10559 ;; them here.
10560 (if gnus-view-pseudos-separately
10562 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10563 files action)
10564 (while ps
10565 (setq action (cdr (assq 'action (car ps))))
10566 (setq files (list (cdr (assq 'name (car ps)))))
10567 (while (and ps (cdr ps)
10568 (string= (or action "1")
10569 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10570 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10571 (setcdr ps (cdr (cdr ps))))
10572 (if (not files)
10574 (if (not (string-match "%s" action))
10575 (setq files (cons " " files)))
10576 (setq files (cons " " files))
10577 (and (assq 'execute (car ps))
10578 (setcdr (assq 'execute (car ps))
10579 (funcall (if (string-match "%s" action)
10580 'format 'concat)
10581 action
10582 (mapconcat (lambda (f) f) files " ")))))
10583 (setq ps (cdr ps)))))
10584 (if (and gnus-view-pseudos (not not-view))
10585 (while pslist
10586 (and (assq 'execute (car pslist))
10587 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10588 (eq gnus-view-pseudos 'not-confirm)))
10589 (setq pslist (cdr pslist)))
10590 (save-excursion
10591 (while pslist
10592 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10593 (gnus-summary-article-number)))
10594 (forward-line 1)
10595 (setq b (point))
10596 (insert " " (file-name-nondirectory
10597 (cdr (assq 'name (car pslist))))
10598 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10599 (add-text-properties
10600 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10601 'gnus-mark gnus-unread-mark
10602 'gnus-level 0
10603 'gnus-pseudo (car pslist)))
10604 (forward-line -1)
10605 (gnus-sethash (int-to-string gnus-reffed-article-number)
10606 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10607 (setq gnus-newsgroup-unreads
10608 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10609 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10610 (setq pslist (cdr pslist)))))))
10612 (defun gnus-pseudos< (p1 p2)
10613 (let ((c1 (cdr (assq 'action p1)))
10614 (c2 (cdr (assq 'action p2))))
10615 (and c1 c2 (string< c1 c2))))
10617 (defun gnus-request-pseudo-article (props)
10618 (cond ((assq 'execute props)
10619 (gnus-execute-command (cdr (assq 'execute props)))))
10620 (let ((gnus-current-article (gnus-summary-article-number)))
10621 (run-hooks 'gnus-mark-article-hook)))
10623 (defun gnus-execute-command (command &optional automatic)
10624 (save-excursion
10625 (gnus-article-setup-buffer)
10626 (set-buffer gnus-article-buffer)
10627 (let ((command (if automatic command (read-string "Command: " command)))
10628 (buffer-read-only nil))
10629 (erase-buffer)
10630 (insert "$ " command "\n\n")
10631 (if gnus-view-pseudo-asynchronously
10632 (start-process "gnus-execute" nil "sh" "-c" command)
10633 (call-process "sh" nil t nil "-c" command)))))
10635 (defun gnus-copy-file (file &optional to)
10636 "Copy FILE to TO."
10637 (interactive
10638 (list (read-file-name "Copy file: " default-directory)
10639 (read-file-name "Copy file to: " default-directory)))
10640 (gnus-set-global-variables)
10641 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10642 (and (file-directory-p to)
10643 (setq to (concat (file-name-as-directory to)
10644 (file-name-nondirectory file))))
10645 (copy-file file to))
10647 ;; Summary kill commands.
10649 (defun gnus-summary-edit-global-kill (article)
10650 "Edit the \"global\" kill file."
10651 (interactive (list (gnus-summary-article-number)))
10652 (gnus-set-global-variables)
10653 (gnus-group-edit-global-kill article))
10655 (defun gnus-summary-edit-local-kill ()
10656 "Edit a local kill file applied to the current newsgroup."
10657 (interactive)
10658 (gnus-set-global-variables)
10659 (setq gnus-current-headers
10660 (gnus-gethash
10661 (int-to-string (gnus-summary-article-number))
10662 gnus-newsgroup-headers-hashtb-by-number))
10663 (gnus-set-global-variables)
10664 (gnus-group-edit-local-kill
10665 (gnus-summary-article-number) gnus-newsgroup-name))
10669 ;;; Gnus article mode
10672 (put 'gnus-article-mode 'mode-class 'special)
10674 (defvar gnus-boogaboo nil)
10676 (if gnus-article-mode-map
10678 (setq gnus-article-mode-map (make-keymap))
10679 (suppress-keymap gnus-article-mode-map)
10680 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10681 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10682 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10683 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10684 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10685 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10686 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10687 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10688 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10689 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10690 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10692 ;; Duplicate almost all summary keystrokes in the article mode map.
10693 (let ((commands
10694 (list
10695 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10696 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10697 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10698 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10699 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10700 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10701 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10702 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10703 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10704 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10705 "\C-c\C-v\C-v" "\C-d" "v"
10706 ;; "Mt" "M!" "Md" "Mr"
10707 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10708 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10709 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10710 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10711 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10712 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10713 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10714 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10715 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10716 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10717 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10719 (while (and gnus-boogaboo commands) ; disabled
10720 (define-key gnus-article-mode-map (car commands)
10721 'gnus-article-summary-command)
10722 (setq commands (cdr commands))))
10724 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10725 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10726 "=" "n" "^" "\M-^")))
10727 (while (and gnus-boogaboo commands) ; disabled
10728 (define-key gnus-article-mode-map (car commands)
10729 'gnus-article-summary-command-nosave)
10730 (setq commands (cdr commands)))))
10733 (defun gnus-article-mode ()
10734 "Major mode for displaying an article.
10736 All normal editing commands are switched off.
10738 The following commands are available:
10740 \\<gnus-article-mode-map>
10741 \\[gnus-article-next-page]\t Scroll the article one page forwards
10742 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10743 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10744 \\[gnus-article-show-summary]\t Display the summary buffer
10745 \\[gnus-article-mail]\t Send a reply to the address near point
10746 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10747 \\[gnus-info-find-node]\t Go to the Gnus info node"
10748 (interactive)
10749 (if gnus-visual (gnus-article-make-menu-bar))
10750 (kill-all-local-variables)
10751 (setq mode-line-modified "-- ")
10752 (make-local-variable 'mode-line-format)
10753 (setq mode-line-format (copy-sequence mode-line-format))
10754 (and (equal (nth 3 mode-line-format) " ")
10755 (setcar (nthcdr 3 mode-line-format) ""))
10756 (setq mode-name "Article")
10757 (setq major-mode 'gnus-article-mode)
10758 (make-local-variable 'minor-mode-alist)
10759 (or (assq 'gnus-show-mime minor-mode-alist)
10760 (setq minor-mode-alist
10761 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10762 (use-local-map gnus-article-mode-map)
10763 (make-local-variable 'page-delimiter)
10764 (setq page-delimiter gnus-page-delimiter)
10765 (buffer-disable-undo (current-buffer))
10766 (setq buffer-read-only t) ;Disable modification
10767 (run-hooks 'gnus-article-mode-hook))
10769 (defun gnus-article-setup-buffer ()
10770 "Initialize article mode buffer."
10771 ;; Returns the article buffer.
10772 (if (get-buffer gnus-article-buffer)
10773 (save-excursion
10774 (set-buffer gnus-article-buffer)
10775 (buffer-disable-undo (current-buffer))
10776 (setq buffer-read-only t)
10777 (gnus-add-current-to-buffer-list)
10778 (or (eq major-mode 'gnus-article-mode)
10779 (gnus-article-mode))
10780 (current-buffer))
10781 (save-excursion
10782 (set-buffer (get-buffer-create gnus-article-buffer))
10783 (gnus-add-current-to-buffer-list)
10784 (gnus-article-mode)
10785 (current-buffer))))
10787 ;; Set article window start at LINE, where LINE is the number of lines
10788 ;; from the head of the article.
10789 (defun gnus-article-set-window-start (&optional line)
10790 (set-window-start
10791 (get-buffer-window gnus-article-buffer)
10792 (save-excursion
10793 (set-buffer gnus-article-buffer)
10794 (goto-char (point-min))
10795 (if (not line)
10796 (point-min)
10797 (gnus-message 6 "Moved to bookmark")
10798 (search-forward "\n\n" nil t)
10799 (forward-line line)
10800 (point)))))
10802 (defun gnus-request-article-this-buffer (article group)
10803 "Get an article and insert it into this buffer."
10804 (setq group (or group gnus-newsgroup-name))
10806 ;; Open server if it has closed.
10807 (gnus-check-server (gnus-find-method-for-group group))
10809 ;; Using `gnus-request-article' directly will insert the article into
10810 ;; `nntp-server-buffer' - so we'll save some time by not having to
10811 ;; copy it from the server buffer into the article buffer.
10813 ;; We only request an article by message-id when we do not have the
10814 ;; headers for it, so we'll have to get those.
10815 (and (stringp article)
10816 (let ((gnus-override-method gnus-refer-article-method))
10817 (gnus-read-header article)))
10819 ;; If the article number is negative, that means that this article
10820 ;; doesn't belong in this newsgroup (possibly), so we find its
10821 ;; message-id and request it by id instead of number.
10822 (if (not (numberp article))
10824 (save-excursion
10825 (set-buffer gnus-summary-buffer)
10826 (let ((header (gnus-get-header-by-num article)))
10827 (if (< article 0)
10828 (if (vectorp header)
10829 ;; It's a real article.
10830 (setq article (mail-header-id header))
10831 ;; It is an extracted pseudo-article.
10832 (setq article 'pseudo)
10833 (gnus-request-pseudo-article header)))
10835 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10836 (if (not (eq (car method) 'nneething))
10838 (let ((dir (concat (file-name-as-directory (nth 1 method))
10839 (mail-header-subject header))))
10840 (if (file-directory-p dir)
10841 (progn
10842 (setq article 'nneething)
10843 (gnus-group-enter-directory dir)))))))))
10845 ;; Check the cache.
10846 (if (and gnus-use-cache
10847 (numberp article)
10848 (gnus-cache-request-article article group))
10849 'article
10850 ;; Get the article and put into the article buffer.
10851 (if (or (stringp article) (numberp article))
10852 (progn
10853 (erase-buffer)
10854 ;; There may be some overlays that we have to kill...
10855 (insert "i")
10856 (let ((overlays (overlays-at (point-min))))
10857 (while overlays
10858 (delete-overlay (car overlays))
10859 (setq overlays (cdr overlays))))
10860 (erase-buffer)
10861 (let ((gnus-override-method
10862 (and (stringp article) gnus-refer-article-method)))
10863 (and (gnus-request-article article group (current-buffer))
10864 'article)))
10865 article)))
10867 (defun gnus-read-header (id)
10868 "Read the headers of article ID and enter them into the Gnus system."
10869 (let (header)
10870 (if (not (setq header
10871 (car (if (let ((gnus-nov-is-evil t))
10872 (gnus-retrieve-headers
10873 (list id) gnus-newsgroup-name))
10874 (gnus-get-newsgroup-headers)))))
10876 (if (stringp id)
10877 (mail-header-set-number header gnus-reffed-article-number))
10878 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10879 (gnus-sethash (int-to-string (mail-header-number header)) header
10880 gnus-newsgroup-headers-hashtb-by-number)
10881 (if (stringp id)
10882 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10883 (setq gnus-current-headers header)
10884 header)))
10886 (defun gnus-article-prepare (article &optional all-headers header)
10887 "Prepare ARTICLE in article mode buffer.
10888 ARTICLE should either be an article number or a Message-ID.
10889 If ARTICLE is an id, HEADER should be the article headers.
10890 If ALL-HEADERS is non-nil, no headers are hidden."
10891 (save-excursion
10892 ;; Make sure we start in a summary buffer.
10893 (or (eq major-mode 'gnus-summary-mode)
10894 (set-buffer gnus-summary-buffer))
10895 (setq gnus-summary-buffer (current-buffer))
10896 ;; Make sure the connection to the server is alive.
10897 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10898 (progn
10899 (gnus-check-server
10900 (gnus-find-method-for-group gnus-newsgroup-name))
10901 (gnus-request-group gnus-newsgroup-name t)))
10902 (let* ((article (if header (mail-header-number header) article))
10903 (summary-buffer (current-buffer))
10904 (internal-hook gnus-article-internal-prepare-hook)
10905 (group gnus-newsgroup-name)
10906 result)
10907 (save-excursion
10908 (gnus-article-setup-buffer)
10909 (set-buffer gnus-article-buffer)
10910 (if (not (setq result (let ((buffer-read-only nil))
10911 (gnus-request-article-this-buffer
10912 article group))))
10913 ;; There is no such article.
10914 (save-excursion
10915 (if (not (numberp article))
10917 (setq gnus-article-current
10918 (cons gnus-newsgroup-name article))
10919 (set-buffer gnus-summary-buffer)
10920 (setq gnus-current-article article)
10921 (gnus-summary-mark-article article gnus-canceled-mark))
10922 (gnus-message 1 "No such article (may be canceled)")
10923 (ding)
10924 nil)
10925 (if (or (eq result 'pseudo) (eq result 'nneething))
10926 (progn
10927 (save-excursion
10928 (set-buffer summary-buffer)
10929 (setq gnus-last-article gnus-current-article
10930 gnus-newsgroup-history (cons gnus-current-article
10931 gnus-newsgroup-history)
10932 gnus-current-article 0
10933 gnus-current-headers nil
10934 gnus-article-current nil)
10935 (if (eq result 'nneething)
10936 (gnus-configure-windows 'summary)
10937 (gnus-configure-windows 'article))
10938 (gnus-set-global-variables))
10939 (gnus-set-mode-line 'article))
10940 ;; The result from the `request' was an actual article -
10941 ;; or at least some text that is now displayed in the
10942 ;; article buffer.
10943 (if (and (numberp article)
10944 (not (eq article gnus-current-article)))
10945 ;; Seems like a new article has been selected.
10946 ;; `gnus-current-article' must be an article number.
10947 (save-excursion
10948 (set-buffer summary-buffer)
10949 (setq gnus-last-article gnus-current-article
10950 gnus-newsgroup-history (cons gnus-current-article
10951 gnus-newsgroup-history)
10952 gnus-current-article article
10953 gnus-current-headers
10954 (gnus-get-header-by-num gnus-current-article)
10955 gnus-article-current
10956 (cons gnus-newsgroup-name gnus-current-article))
10957 (gnus-summary-show-thread)
10958 (run-hooks 'gnus-mark-article-hook)
10959 (gnus-set-mode-line 'summary)
10960 (and gnus-visual
10961 (run-hooks 'gnus-visual-mark-article-hook))
10962 ;; Set the global newsgroup variables here.
10963 ;; Suggested by Jim Sisolak
10964 ;; <sisolak@trans4.neep.wisc.edu>.
10965 (gnus-set-global-variables)
10966 (setq gnus-have-all-headers
10967 (or all-headers gnus-show-all-headers))
10968 (and gnus-use-cache
10969 (vectorp (gnus-get-header-by-number article))
10970 (gnus-cache-possibly-enter-article
10971 group article
10972 (gnus-get-header-by-number article)
10973 (memq article gnus-newsgroup-marked)
10974 (memq article gnus-newsgroup-dormant)
10975 (memq article gnus-newsgroup-unreads)))))
10976 ;; Hooks for getting information from the article.
10977 ;; This hook must be called before being narrowed.
10978 (let (buffer-read-only)
10979 (run-hooks 'internal-hook)
10980 (run-hooks 'gnus-article-prepare-hook)
10981 ;; Decode MIME message.
10982 (if (and gnus-show-mime
10983 (or (not gnus-strict-mime)
10984 (gnus-fetch-field "Mime-Version")))
10985 (funcall gnus-show-mime-method))
10986 ;; Perform the article display hooks.
10987 (run-hooks 'gnus-article-display-hook))
10988 ;; Do page break.
10989 (goto-char (point-min))
10990 (and gnus-break-pages (gnus-narrow-to-page))
10991 (gnus-set-mode-line 'article)
10992 (gnus-configure-windows 'article)
10993 (goto-char (point-min))
10994 t))))))
10996 (defun gnus-article-show-all-headers ()
10997 "Show all article headers in article mode buffer."
10998 (save-excursion
10999 (gnus-article-setup-buffer)
11000 (set-buffer gnus-article-buffer)
11001 (let ((buffer-read-only nil))
11002 (remove-text-properties (point-min) (point-max)
11003 gnus-hidden-properties))))
11005 (defun gnus-article-hide-headers-if-wanted ()
11006 "Hide unwanted headers if `gnus-have-all-headers' is nil.
11007 Provided for backwards compatability."
11008 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
11009 (gnus-article-hide-headers)))
11011 (defun gnus-article-hide-headers (&optional delete)
11012 "Hide unwanted headers and possibly sort them as well."
11013 (interactive "P")
11014 (save-excursion
11015 (set-buffer gnus-article-buffer)
11016 (save-restriction
11017 (let ((sorted gnus-sorted-header-list)
11018 (buffer-read-only nil)
11019 want-list beg want-l)
11020 ;; First we narrow to just the headers.
11021 (widen)
11022 (goto-char (point-min))
11023 ;; Hide any "From " lines at the beginning of (mail) articles.
11024 (while (looking-at "From ")
11025 (forward-line 1))
11026 (or (bobp)
11027 (add-text-properties (point-min) (point) gnus-hidden-properties))
11028 ;; Then treat the rest of the header lines.
11029 (narrow-to-region
11030 (point)
11031 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
11032 ;; Then we use the two regular expressions
11033 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11034 ;; select which header lines is to remain visible in the
11035 ;; article buffer.
11036 (goto-char (point-min))
11037 (while (re-search-forward "^[^ \t]*:" nil t)
11038 (beginning-of-line)
11039 ;; We add the headers we want to keep to a list and delete
11040 ;; them from the buffer.
11041 (if (or (and (stringp gnus-visible-headers)
11042 (looking-at gnus-visible-headers))
11043 (and (not (stringp gnus-visible-headers))
11044 (stringp gnus-ignored-headers)
11045 (not (looking-at gnus-ignored-headers))))
11046 (progn
11047 (setq beg (point))
11048 (forward-line 1)
11049 ;; Be sure to get multi-line headers...
11050 (re-search-forward "^[^ \t]*:" nil t)
11051 (beginning-of-line)
11052 (setq want-list
11053 (cons (buffer-substring beg (point)) want-list))
11054 (delete-region beg (point))
11055 (goto-char beg))
11056 (forward-line 1)))
11057 ;; Next we perform the sorting by looking at
11058 ;; `gnus-sorted-header-list'.
11059 (goto-char (point-min))
11060 (while (and sorted want-list)
11061 (setq want-l want-list)
11062 (while (and want-l
11063 (not (string-match (car sorted) (car want-l))))
11064 (setq want-l (cdr want-l)))
11065 (if want-l
11066 (progn
11067 (insert (car want-l))
11068 (setq want-list (delq (car want-l) want-list))))
11069 (setq sorted (cdr sorted)))
11070 ;; Any headers that were not matched by the sorted list we
11071 ;; just tack on the end of the visible header list.
11072 (while want-list
11073 (insert (car want-list))
11074 (setq want-list (cdr want-list)))
11075 ;; And finally we make the unwanted headers invisible.
11076 (if delete
11077 (delete-region (point) (point-max))
11078 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11079 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11081 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11082 (defun gnus-article-treat-overstrike ()
11083 "Translate overstrikes into bold text."
11084 (interactive)
11085 (save-excursion
11086 (set-buffer gnus-article-buffer)
11087 (let ((buffer-read-only nil))
11088 (while (search-forward "\b" nil t)
11089 (let ((next (following-char))
11090 (previous (char-after (- (point) 2))))
11091 (cond ((eq next previous)
11092 (put-text-property (- (point) 2) (point)
11093 'invisible t)
11094 (put-text-property (point) (1+ (point))
11095 'face 'bold))
11096 ((eq next ?_)
11097 (put-text-property (1- (point)) (1+ (point))
11098 'invisible t)
11099 (put-text-property (1- (point)) (point)
11100 'face 'underline))
11101 ((eq previous ?_)
11102 (put-text-property (- (point) 2) (point)
11103 'invisible t)
11104 (put-text-property (point) (1+ (point))
11105 'face 'underline))))))))
11107 (defun gnus-article-word-wrap ()
11108 "Format too long lines."
11109 (interactive)
11110 (save-excursion
11111 (set-buffer gnus-article-buffer)
11112 (let ((buffer-read-only nil))
11113 (goto-char (point-min))
11114 (search-forward "\n\n" nil t)
11115 (end-of-line 1)
11116 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11117 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11118 (adaptive-fill-mode t))
11119 (while (not (eobp))
11120 (and (>= (current-column) (min fill-column (window-width)))
11121 (/= (preceding-char) ?:)
11122 (fill-paragraph nil))
11123 (end-of-line 2))))))
11125 (defun gnus-article-remove-cr ()
11126 "Remove carriage returns from an article."
11127 (interactive)
11128 (save-excursion
11129 (set-buffer gnus-article-buffer)
11130 (let ((buffer-read-only nil))
11131 (goto-char (point-min))
11132 (while (search-forward "\r" nil t)
11133 (replace-match "" t t)))))
11135 (defun gnus-article-display-x-face (&optional force)
11136 "Look for an X-Face header and display it if present."
11137 (interactive (list 'force))
11138 (save-excursion
11139 (set-buffer gnus-article-buffer)
11140 (let ((inhibit-point-motion-hooks t)
11141 (case-fold-search nil)
11142 from)
11143 (save-restriction
11144 (goto-char (point-min))
11145 (search-forward "\n\n")
11146 (narrow-to-region (point-min) (point))
11147 (goto-char (point-min))
11148 (setq from (mail-fetch-field "from"))
11149 (if (not (and gnus-article-x-face-command
11150 (or force
11151 (not gnus-article-x-face-too-ugly)
11152 (and gnus-article-x-face-too-ugly from
11153 (not (string-match gnus-article-x-face-too-ugly
11154 from))))
11155 (progn
11156 (goto-char (point-min))
11157 (re-search-forward "^X-Face: " nil t))))
11159 (let ((beg (point))
11160 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11161 (if (symbolp gnus-article-x-face-command)
11162 (and (or (fboundp gnus-article-x-face-command)
11163 (error "%s is not a function"
11164 gnus-article-x-face-command))
11165 (funcall gnus-article-x-face-command beg end))
11166 (call-process-region beg end "sh" nil 0 nil
11167 "-c" gnus-article-x-face-command))))))))
11169 (defun gnus-article-de-quoted-unreadable (&optional force)
11170 "Do a naive translation of a quoted-printable-encoded article.
11171 This is in no way, shape or form meant as a replacement for real MIME
11172 processing, but is simply a stop-gap measure until MIME support is
11173 written.
11174 If FORCE, decode the article whether it is marked as quoted-printable
11175 or not."
11176 (interactive (list 'force))
11177 (save-excursion
11178 (set-buffer gnus-article-buffer)
11179 (let ((case-fold-search t)
11180 (buffer-read-only nil)
11181 (type (gnus-fetch-field "content-transfer-encoding")))
11182 (if (or force (and type (string-match "quoted-printable" type)))
11183 (progn
11184 (goto-char (point-min))
11185 (search-forward "\n\n" nil 'move)
11186 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11188 (defun gnus-mime-decode-quoted-printable (from to)
11189 ;; Decode quoted-printable from region between FROM and TO.
11190 (save-excursion
11191 (goto-char from)
11192 (while (search-forward "=" to t)
11193 (cond ((eq (following-char) ?\n)
11194 (delete-char -1)
11195 (delete-char 1))
11196 ((looking-at "[0-9A-F][0-9A-F]")
11197 (delete-char -1)
11198 (insert (hexl-hex-string-to-integer
11199 (buffer-substring (point) (+ 2 (point)))))
11200 (delete-char 2))
11201 ((looking-at "=")
11202 (delete-char 1))
11203 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11205 (defvar gnus-article-time-units
11206 (list (cons 'year (* 365.25 24 60 60))
11207 (cons 'week (* 7 24 60 60))
11208 (cons 'day (* 24 60 60))
11209 (cons 'hour (* 60 60))
11210 (cons 'minute 60)
11211 (cons 'second 1)))
11213 (defun gnus-article-date-ut (&optional type)
11214 "Convert DATE date to universal time in the current article.
11215 If TYPE is `local', convert to local time; if it is `lapsed', output
11216 how much time has lapsed since DATE."
11217 (interactive (list 'ut))
11218 (let ((date (mail-header-date (or gnus-current-headers
11219 (gnus-get-header-by-number
11220 (gnus-summary-article-number))"")))
11221 (date-regexp "^Date: \\|^X-Sent: "))
11222 (if (or (not date)
11223 (string= date ""))
11225 (save-excursion
11226 (set-buffer gnus-article-buffer)
11227 (let ((buffer-read-only nil))
11228 (goto-char (point-min))
11229 (if (and (re-search-forward date-regexp nil t)
11230 (progn
11231 (beginning-of-line)
11232 (looking-at date-regexp)))
11233 (delete-region (gnus-point-at-bol)
11234 (progn (end-of-line) (1+ (point))))
11235 (goto-char (point-min))
11236 (goto-char (- (search-forward "\n\n") 2)))
11237 (insert
11238 (cond
11239 ((eq type 'local)
11240 (concat "Date: " (condition-case ()
11241 (timezone-make-date-arpa-standard date)
11242 (error date))
11243 "\n"))
11244 ((eq type 'ut)
11245 (concat "Date: "
11246 (condition-case ()
11247 (timezone-make-date-arpa-standard date nil "UT")
11248 (error date))
11249 "\n"))
11250 ((eq type 'lapsed)
11251 ;; If the date is seriously mangled, the timezone
11252 ;; functions are liable to bug out, so we condition-case
11253 ;; the entire thing.
11254 (let* ((real-sec (condition-case ()
11255 (- (gnus-seconds-since-epoch
11256 (timezone-make-date-arpa-standard
11257 (current-time-string)
11258 (current-time-zone) "UT"))
11259 (gnus-seconds-since-epoch
11260 (timezone-make-date-arpa-standard
11261 date nil "UT")))
11262 (error 0)))
11263 (sec (abs real-sec))
11264 num prev)
11265 (if (zerop sec)
11266 "X-Sent: Now\n"
11267 (concat
11268 "X-Sent: "
11269 (mapconcat
11270 (lambda (unit)
11271 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11273 (setq sec (- sec (* num (cdr unit))))
11274 (prog1
11275 (concat (if prev ", " "") (int-to-string
11276 (floor num))
11277 " " (symbol-name (car unit))
11278 (if (> num 1) "s" ""))
11279 (setq prev t))))
11280 gnus-article-time-units "")
11281 (if (> real-sec 0)
11282 " ago\n"
11283 " in the future\n")))))
11285 (error "Unknown conversion type: %s" type)))))))))
11287 (defun gnus-article-date-local ()
11288 "Convert the current article date to the local timezone."
11289 (interactive)
11290 (gnus-article-date-ut 'local))
11292 (defun gnus-article-date-lapsed ()
11293 "Convert the current article date to time lapsed since it was sent."
11294 (interactive)
11295 (gnus-article-date-ut 'lapsed))
11297 (defun gnus-article-maybe-highlight ()
11298 "Do some article highlighting if `gnus-visual' is non-nil."
11299 (if gnus-visual (gnus-article-highlight-some)))
11301 ;; Article savers.
11303 (defun gnus-output-to-rmail (file-name)
11304 "Append the current article to an Rmail file named FILE-NAME."
11305 (require 'rmail)
11306 ;; Most of these codes are borrowed from rmailout.el.
11307 (setq file-name (expand-file-name file-name))
11308 (setq rmail-default-rmail-file file-name)
11309 (let ((artbuf (current-buffer))
11310 (tmpbuf (get-buffer-create " *Gnus-output*")))
11311 (save-excursion
11312 (or (get-file-buffer file-name)
11313 (file-exists-p file-name)
11314 (if (gnus-yes-or-no-p
11315 (concat "\"" file-name "\" does not exist, create it? "))
11316 (let ((file-buffer (create-file-buffer file-name)))
11317 (save-excursion
11318 (set-buffer file-buffer)
11319 (rmail-insert-rmail-file-header)
11320 (let ((require-final-newline nil))
11321 (write-region (point-min) (point-max) file-name t 1)))
11322 (kill-buffer file-buffer))
11323 (error "Output file does not exist")))
11324 (set-buffer tmpbuf)
11325 (buffer-disable-undo (current-buffer))
11326 (erase-buffer)
11327 (insert-buffer-substring artbuf)
11328 (gnus-convert-article-to-rmail)
11329 ;; Decide whether to append to a file or to an Emacs buffer.
11330 (let ((outbuf (get-file-buffer file-name)))
11331 (if (not outbuf)
11332 (append-to-file (point-min) (point-max) file-name)
11333 ;; File has been visited, in buffer OUTBUF.
11334 (set-buffer outbuf)
11335 (let ((buffer-read-only nil)
11336 (msg (and (boundp 'rmail-current-message)
11337 (symbol-value 'rmail-current-message))))
11338 ;; If MSG is non-nil, buffer is in RMAIL mode.
11339 (if msg
11340 (progn (widen)
11341 (narrow-to-region (point-max) (point-max))))
11342 (insert-buffer-substring tmpbuf)
11343 (if msg
11344 (progn
11345 (goto-char (point-min))
11346 (widen)
11347 (search-backward "\^_")
11348 (narrow-to-region (point) (point-max))
11349 (goto-char (1+ (point-min)))
11350 (rmail-count-new-messages t)
11351 (rmail-show-message msg)))))))
11352 (kill-buffer tmpbuf)))
11354 (defun gnus-output-to-file (file-name)
11355 "Append the current article to a file named FILE-NAME."
11356 (setq file-name (expand-file-name file-name))
11357 (let ((artbuf (current-buffer))
11358 (tmpbuf (get-buffer-create " *Gnus-output*")))
11359 (save-excursion
11360 (set-buffer tmpbuf)
11361 (buffer-disable-undo (current-buffer))
11362 (erase-buffer)
11363 (insert-buffer-substring artbuf)
11364 ;; Append newline at end of the buffer as separator, and then
11365 ;; save it to file.
11366 (goto-char (point-max))
11367 (insert "\n")
11368 (append-to-file (point-min) (point-max) file-name))
11369 (kill-buffer tmpbuf)))
11371 (defun gnus-convert-article-to-rmail ()
11372 "Convert article in current buffer to Rmail message format."
11373 (let ((buffer-read-only nil))
11374 ;; Convert article directly into Babyl format.
11375 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11376 (goto-char (point-min))
11377 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11378 (while (search-forward "\n\^_" nil t) ;single char
11379 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11380 (goto-char (point-max))
11381 (insert "\^_")))
11383 (defun gnus-narrow-to-page (&optional arg)
11384 "Make text outside current page invisible except for page delimiter.
11385 A numeric arg specifies to move forward or backward by that many pages,
11386 thus showing a page other than the one point was originally in."
11387 (interactive "P")
11388 (setq arg (if arg (prefix-numeric-value arg) 0))
11389 (save-excursion
11390 (forward-page -1) ;Beginning of current page.
11391 (widen)
11392 (if (> arg 0)
11393 (forward-page arg)
11394 (if (< arg 0)
11395 (forward-page (1- arg))))
11396 ;; Find the end of the page.
11397 (forward-page)
11398 ;; If we stopped due to end of buffer, stay there.
11399 ;; If we stopped after a page delimiter, put end of restriction
11400 ;; at the beginning of that line.
11401 ;; These are commented out.
11402 ;; (if (save-excursion (beginning-of-line)
11403 ;; (looking-at page-delimiter))
11404 ;; (beginning-of-line))
11405 (narrow-to-region (point)
11406 (progn
11407 ;; Find the top of the page.
11408 (forward-page -1)
11409 ;; If we found beginning of buffer, stay there.
11410 ;; If extra text follows page delimiter on same line,
11411 ;; include it.
11412 ;; Otherwise, show text starting with following line.
11413 (if (and (eolp) (not (bobp)))
11414 (forward-line 1))
11415 (point)))))
11417 (defun gnus-gmt-to-local ()
11418 "Rewrite Date header described in GMT to local in current buffer.
11419 Intended to be used with gnus-article-prepare-hook."
11420 (save-excursion
11421 (save-restriction
11422 (widen)
11423 (goto-char (point-min))
11424 (narrow-to-region (point-min)
11425 (progn (search-forward "\n\n" nil 'move) (point)))
11426 (goto-char (point-min))
11427 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11428 (let ((buffer-read-only nil)
11429 (date (buffer-substring-no-properties
11430 (match-beginning 1) (match-end 1))))
11431 (delete-region (match-beginning 1) (match-end 1))
11432 (insert
11433 (timezone-make-date-arpa-standard
11434 date nil (current-time-zone))))))))
11437 ;; Article mode commands
11439 (defun gnus-article-next-page (&optional lines)
11440 "Show next page of current article.
11441 If end of article, return non-nil. Otherwise return nil.
11442 Argument LINES specifies lines to be scrolled up."
11443 (interactive "P")
11444 (move-to-window-line -1)
11445 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11446 (if (save-excursion
11447 (end-of-line)
11448 (and (pos-visible-in-window-p) ;Not continuation line.
11449 (eobp)))
11450 ;; Nothing in this page.
11451 (if (or (not gnus-break-pages)
11452 (save-excursion
11453 (save-restriction
11454 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11455 t ;Nothing more.
11456 (gnus-narrow-to-page 1) ;Go to next page.
11457 nil)
11458 ;; More in this page.
11459 (condition-case ()
11460 (scroll-up lines)
11461 (end-of-buffer
11462 ;; Long lines may cause an end-of-buffer error.
11463 (goto-char (point-max))))
11464 nil))
11466 (defun gnus-article-prev-page (&optional lines)
11467 "Show previous page of current article.
11468 Argument LINES specifies lines to be scrolled down."
11469 (interactive "P")
11470 (move-to-window-line 0)
11471 (if (and gnus-break-pages
11472 (bobp)
11473 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11474 (progn
11475 (gnus-narrow-to-page -1) ;Go to previous page.
11476 (goto-char (point-max))
11477 (recenter -1))
11478 (scroll-down lines)))
11480 (defun gnus-article-refer-article ()
11481 "Read article specified by message-id around point."
11482 (interactive)
11483 (search-forward ">" nil t) ;Move point to end of "<....>".
11484 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11485 (let ((message-id
11486 (buffer-substring (match-beginning 1) (match-end 1))))
11487 (set-buffer gnus-summary-buffer)
11488 (gnus-summary-refer-article message-id))
11489 (error "No references around point")))
11491 (defun gnus-article-show-summary ()
11492 "Reconfigure windows to show summary buffer."
11493 (interactive)
11494 (gnus-configure-windows 'article)
11495 (gnus-summary-goto-subject gnus-current-article))
11497 (defun gnus-article-describe-briefly ()
11498 "Describe article mode commands briefly."
11499 (interactive)
11500 (gnus-message 6
11501 (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")))
11503 (defun gnus-article-summary-command ()
11504 "Execute the last keystroke in the summary buffer."
11505 (interactive)
11506 (let ((obuf (current-buffer))
11507 (owin (current-window-configuration))
11508 func)
11509 (switch-to-buffer gnus-summary-buffer 'norecord)
11510 (setq func (lookup-key (current-local-map) (this-command-keys)))
11511 (call-interactively func)
11512 (set-buffer obuf)
11513 (set-window-configuration owin)
11514 (set-window-point (get-buffer-window (current-buffer)) (point))))
11516 (defun gnus-article-summary-command-nosave ()
11517 "Execute the last keystroke in the summary buffer."
11518 (interactive)
11519 (let (func)
11520 (pop-to-buffer gnus-summary-buffer 'norecord)
11521 (setq func (lookup-key (current-local-map) (this-command-keys)))
11522 (call-interactively func)))
11525 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11527 ;;;###autoload
11528 (defalias 'gnus-batch-kill 'gnus-batch-score)
11529 ;;;###autoload
11530 (defun gnus-batch-score ()
11531 "Run batched scoring.
11532 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11533 Newsgroups is a list of strings in Bnews format. If you want to score
11534 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11535 score the alt hierarchy, you'd say \"!alt.all\"."
11536 (interactive)
11537 (let* ((yes-and-no
11538 (gnus-newsrc-parse-options
11539 (apply (function concat)
11540 (mapcar (lambda (g) (concat g " "))
11541 command-line-args-left))))
11542 (gnus-expert-user t)
11543 (nnmail-spool-file nil)
11544 (gnus-use-dribble-file nil)
11545 (yes (car yes-and-no))
11546 (no (cdr yes-and-no))
11547 group newsrc entry
11548 ;; Disable verbose message.
11549 gnus-novice-user gnus-large-newsgroup)
11550 ;; Eat all arguments.
11551 (setq command-line-args-left nil)
11552 ;; Start Gnus.
11553 (gnus)
11554 ;; Apply kills to specified newsgroups in command line arguments.
11555 (setq newsrc (cdr gnus-newsrc-alist))
11556 (while newsrc
11557 (setq group (car (car newsrc)))
11558 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11559 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11560 (and (car entry)
11561 (or (eq (car entry) t)
11562 (not (zerop (car entry)))))
11563 (if yes (string-match yes group) t)
11564 (or (null no) (not (string-match no group))))
11565 (progn
11566 (gnus-summary-read-group group nil t)
11567 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11568 (gnus-summary-exit))))
11569 (setq newsrc (cdr newsrc)))
11570 ;; Exit Emacs.
11571 (switch-to-buffer gnus-group-buffer)
11572 (gnus-group-save-newsrc)))
11574 (defun gnus-apply-kill-file ()
11575 "Apply a kill file to the current newsgroup.
11576 Returns the number of articles marked as read."
11577 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11578 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11579 (gnus-apply-kill-file-internal)
11582 (defun gnus-kill-save-kill-buffer ()
11583 (save-excursion
11584 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11585 (if (get-file-buffer file)
11586 (progn
11587 (set-buffer (get-file-buffer file))
11588 (and (buffer-modified-p) (save-buffer))
11589 (kill-buffer (current-buffer)))))))
11591 (defvar gnus-kill-file-name "KILL"
11592 "Suffix of the kill files.")
11594 (defun gnus-newsgroup-kill-file (newsgroup)
11595 "Return the name of a kill file name for NEWSGROUP.
11596 If NEWSGROUP is nil, return the global kill file name instead."
11597 (cond ((or (null newsgroup)
11598 (string-equal newsgroup ""))
11599 ;; The global KILL file is placed at top of the directory.
11600 (expand-file-name gnus-kill-file-name
11601 (or gnus-kill-files-directory "~/News")))
11602 ((gnus-use-long-file-name 'not-kill)
11603 ;; Append ".KILL" to newsgroup name.
11604 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
11605 "." gnus-kill-file-name)
11606 (or gnus-kill-files-directory "~/News")))
11608 ;; Place "KILL" under the hierarchical directory.
11609 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11610 "/" gnus-kill-file-name)
11611 (or gnus-kill-files-directory "~/News")))))
11615 ;;; Dribble file
11618 (defvar gnus-dribble-ignore nil)
11619 (defvar gnus-dribble-eval-file nil)
11621 (defun gnus-dribble-file-name ()
11622 (concat gnus-current-startup-file "-dribble"))
11624 (defun gnus-dribble-enter (string)
11625 (if (and (not gnus-dribble-ignore)
11626 gnus-dribble-buffer
11627 (buffer-name gnus-dribble-buffer))
11628 (let ((obuf (current-buffer)))
11629 (set-buffer gnus-dribble-buffer)
11630 (insert string "\n")
11631 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11632 (set-buffer obuf))))
11634 (defun gnus-dribble-read-file ()
11635 (let ((dribble-file (gnus-dribble-file-name)))
11636 (save-excursion
11637 (set-buffer (setq gnus-dribble-buffer
11638 (get-buffer-create
11639 (file-name-nondirectory dribble-file))))
11640 (gnus-add-current-to-buffer-list)
11641 (erase-buffer)
11642 (set-visited-file-name dribble-file)
11643 (buffer-disable-undo (current-buffer))
11644 (bury-buffer (current-buffer))
11645 (set-buffer-modified-p nil)
11646 (let ((auto (make-auto-save-file-name))
11647 (gnus-dribble-ignore t))
11648 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11649 (progn
11650 (if (file-newer-than-file-p auto dribble-file)
11651 (setq dribble-file auto))
11652 (insert-file-contents dribble-file)
11653 (if (not (zerop (buffer-size)))
11654 (set-buffer-modified-p t))
11655 (if (gnus-y-or-n-p
11656 "Auto-save file exists. Do you want to read it? ")
11657 (setq gnus-dribble-eval-file t))))))))
11659 (defun gnus-dribble-eval-file ()
11660 (if (not gnus-dribble-eval-file)
11662 (setq gnus-dribble-eval-file nil)
11663 (save-excursion
11664 (let ((gnus-dribble-ignore t))
11665 (set-buffer gnus-dribble-buffer)
11666 (eval-buffer (current-buffer))))))
11668 (defun gnus-dribble-delete-file ()
11669 (if (file-exists-p (gnus-dribble-file-name))
11670 (delete-file (gnus-dribble-file-name)))
11671 (if gnus-dribble-buffer
11672 (save-excursion
11673 (set-buffer gnus-dribble-buffer)
11674 (let ((auto (make-auto-save-file-name)))
11675 (if (file-exists-p auto)
11676 (delete-file auto))
11677 (erase-buffer)
11678 (set-buffer-modified-p nil)))))
11680 (defun gnus-dribble-save ()
11681 (if (and gnus-dribble-buffer
11682 (buffer-name gnus-dribble-buffer))
11683 (save-excursion
11684 (set-buffer gnus-dribble-buffer)
11685 (save-buffer))))
11687 (defun gnus-dribble-clear ()
11688 (save-excursion
11689 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11690 (progn
11691 (set-buffer gnus-dribble-buffer)
11692 (erase-buffer)
11693 (set-buffer-modified-p nil)
11694 (setq buffer-saved-size (buffer-size))))))
11697 ;;; Server Communication
11700 (defun gnus-start-news-server (&optional confirm)
11701 "Open a method for getting news.
11702 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11703 (let (how)
11704 (if gnus-current-select-method
11705 ;; Stream is already opened.
11707 ;; Open NNTP server.
11708 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11709 (if confirm
11710 (progn
11711 ;; Read server name with completion.
11712 (setq gnus-nntp-server
11713 (completing-read "NNTP server: "
11714 (mapcar (lambda (server) (list server))
11715 (cons (list gnus-nntp-server)
11716 gnus-secondary-servers))
11717 nil nil gnus-nntp-server))))
11719 (if (and gnus-nntp-server
11720 (stringp gnus-nntp-server)
11721 (not (string= gnus-nntp-server "")))
11722 (setq gnus-select-method
11723 (cond ((or (string= gnus-nntp-server "")
11724 (string= gnus-nntp-server "::"))
11725 (list 'nnspool (system-name)))
11726 ((string-match "^:" gnus-nntp-server)
11727 (list 'nnmh gnus-nntp-server
11728 (list 'nnmh-directory
11729 (file-name-as-directory
11730 (expand-file-name
11731 (concat "~/" (substring
11732 gnus-nntp-server 1)))))
11733 (list 'nnmh-get-new-mail nil)))
11735 (list 'nntp gnus-nntp-server)))))
11737 (setq how (car gnus-select-method))
11738 (cond ((eq how 'nnspool)
11739 (require 'nnspool)
11740 (gnus-message 5 "Looking up local news spool..."))
11741 ((eq how 'nnmh)
11742 (require 'nnmh)
11743 (gnus-message 5 "Looking up mh spool..."))
11745 (require 'nntp)))
11746 (setq gnus-current-select-method gnus-select-method)
11747 (run-hooks 'gnus-open-server-hook)
11748 (or
11749 ;; gnus-open-server-hook might have opened it
11750 (gnus-server-opened gnus-select-method)
11751 (gnus-open-server gnus-select-method)
11752 (gnus-y-or-n-p
11753 (format
11754 "%s open error: '%s'. Continue? "
11755 (nth 1 gnus-select-method)
11756 (gnus-status-message gnus-select-method)))
11757 (progn
11758 (gnus-message 1 "Couldn't open server on %s"
11759 (nth 1 gnus-select-method))
11760 (ding)
11761 nil)))))
11763 (defun gnus-check-server (&optional method)
11764 "If the news server is down, start it up again."
11765 (let ((method (if method method gnus-select-method)))
11766 (and (stringp method)
11767 (setq method (gnus-server-to-method method)))
11768 (if (gnus-server-opened method)
11769 ;; Stream is already opened.
11771 ;; Open server.
11772 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11773 (run-hooks 'gnus-open-server-hook)
11774 (prog1
11775 (gnus-open-server method)
11776 (message "")))))
11778 (defun gnus-nntp-message (&optional message)
11779 "Check the status of the NNTP server.
11780 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11781 is returned insted of the status string."
11782 (let ((status (gnus-status-message (gnus-find-method-for-group
11783 gnus-newsgroup-name)))
11784 (message (or message "")))
11785 (if (and (stringp status) (> (length status) 0))
11786 status message)))
11788 (defun gnus-get-function (method function)
11789 (and (stringp method)
11790 (setq method (gnus-server-to-method method)))
11791 (let ((func (intern (format "%s-%s" (car method) function))))
11792 (if (not (fboundp func))
11793 (progn
11794 (require (car method))
11795 (if (not (fboundp func))
11796 (error "No such function: %s" func))))
11797 func))
11799 ;;; Interface functions to the backends.
11801 (defun gnus-open-server (method)
11802 (funcall (gnus-get-function method 'open-server)
11803 (nth 1 method) (nthcdr 2 method)))
11805 (defun gnus-close-server (method)
11806 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11808 (defun gnus-request-list (method)
11809 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11811 (defun gnus-request-list-newsgroups (method)
11812 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11814 (defun gnus-request-newgroups (date method)
11815 (funcall (gnus-get-function method 'request-newgroups)
11816 date (nth 1 method)))
11818 (defun gnus-server-opened (method)
11819 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11821 (defun gnus-status-message (method)
11822 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11823 method)))
11824 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11826 (defun gnus-request-group (group &optional dont-check)
11827 (let ((method (gnus-find-method-for-group group)))
11828 (funcall (gnus-get-function method 'request-group)
11829 (gnus-group-real-name group) (nth 1 method) dont-check)))
11831 (defun gnus-request-asynchronous (group &optional articles)
11832 (let ((method (gnus-find-method-for-group group)))
11833 (funcall (gnus-get-function method 'request-asynchronous)
11834 (gnus-group-real-name group) (nth 1 method) articles)))
11836 (defun gnus-list-active-group (group)
11837 (let ((method (gnus-find-method-for-group group))
11838 (func 'list-active-group))
11839 (and (gnus-check-backend-function func group)
11840 (funcall (gnus-get-function method func)
11841 (gnus-group-real-name group) (nth 1 method)))))
11843 (defun gnus-request-group-description (group)
11844 (let ((method (gnus-find-method-for-group group))
11845 (func 'request-group-description))
11846 (and (gnus-check-backend-function func group)
11847 (funcall (gnus-get-function method func)
11848 (gnus-group-real-name group) (nth 1 method)))))
11850 (defun gnus-close-group (group)
11851 (let ((method (gnus-find-method-for-group group)))
11852 (funcall (gnus-get-function method 'close-group)
11853 (gnus-group-real-name group) (nth 1 method))))
11855 (defun gnus-retrieve-headers (articles group)
11856 (let ((method (gnus-find-method-for-group group)))
11857 (if (and gnus-use-cache (numberp (car articles)))
11858 (gnus-cache-retrieve-headers articles group)
11859 (funcall (gnus-get-function method 'retrieve-headers)
11860 articles (gnus-group-real-name group) (nth 1 method)))))
11862 (defun gnus-retrieve-groups (groups method)
11863 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11865 (defun gnus-request-article (article group &optional buffer)
11866 (let ((method (gnus-find-method-for-group group)))
11867 (funcall (gnus-get-function method 'request-article)
11868 article (gnus-group-real-name group) (nth 1 method) buffer)))
11870 (defun gnus-request-head (article group)
11871 (let ((method (gnus-find-method-for-group group)))
11872 (funcall (gnus-get-function method 'request-head)
11873 article (gnus-group-real-name group) (nth 1 method))))
11875 (defun gnus-request-body (article group)
11876 (let ((method (gnus-find-method-for-group group)))
11877 (funcall (gnus-get-function method 'request-body)
11878 article (gnus-group-real-name group) (nth 1 method))))
11880 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11881 (defun gnus-request-post-buffer (post group subject header artbuf
11882 info follow-to respect-poster)
11883 (let* ((info (or info (and group (nth 2 (gnus-gethash
11884 group gnus-newsrc-hashtb)))))
11885 (method
11886 (if (and gnus-post-method
11887 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11888 (memq 'post (assoc
11889 (format "%s" (car (gnus-find-method-for-group
11890 gnus-newsgroup-name)))
11891 gnus-valid-select-methods)))
11892 gnus-post-method
11893 (gnus-find-method-for-group gnus-newsgroup-name))))
11894 (or (gnus-check-server method)
11895 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11896 (let ((mail-self-blind nil)
11897 (mail-archive-file-name nil))
11898 (funcall (gnus-get-function method 'request-post-buffer)
11899 post group subject header artbuf info follow-to
11900 respect-poster))))
11902 (defun gnus-request-post (method &optional force)
11903 (and (stringp method)
11904 (setq method (gnus-server-to-method method)))
11905 (and (not force) gnus-post-method
11906 (memq 'post (assoc (format "%s" (car method))
11907 gnus-valid-select-methods))
11908 (setq method gnus-post-method))
11909 (funcall (gnus-get-function method 'request-post)
11910 (nth 1 method)))
11912 (defun gnus-request-expire-articles (articles group &optional force)
11913 (let ((method (gnus-find-method-for-group group)))
11914 (funcall (gnus-get-function method 'request-expire-articles)
11915 articles (gnus-group-real-name group) (nth 1 method)
11916 force)))
11918 (defun gnus-request-move-article
11919 (article group server accept-function &optional last)
11920 (let ((method (gnus-find-method-for-group group)))
11921 (funcall (gnus-get-function method 'request-move-article)
11922 article (gnus-group-real-name group)
11923 (nth 1 method) accept-function last)))
11925 (defun gnus-request-accept-article (group &optional last)
11926 (let ((func (if (symbolp group) group
11927 (car (gnus-find-method-for-group group)))))
11928 (funcall (intern (format "%s-request-accept-article" func))
11929 (if (stringp group) (gnus-group-real-name group) group)
11930 last)))
11932 (defun gnus-request-replace-article (article group buffer)
11933 (let ((func (car (gnus-find-method-for-group group))))
11934 (funcall (intern (format "%s-request-replace-article" func))
11935 article (gnus-group-real-name group) buffer)))
11937 (defun gnus-request-create-group (group)
11938 (let ((method (gnus-find-method-for-group group)))
11939 (funcall (gnus-get-function method 'request-create-group)
11940 (gnus-group-real-name group) (nth 1 method))))
11942 (defun gnus-member-of-valid (symbol group)
11943 (memq symbol (assoc
11944 (format "%s" (car (gnus-find-method-for-group group)))
11945 gnus-valid-select-methods)))
11947 (defun gnus-secondary-method-p (method)
11948 (let ((methods gnus-secondary-select-methods)
11949 (gmethod (gnus-server-get-method nil method)))
11950 (while (and methods
11951 (not (equal (gnus-server-get-method nil (car methods))
11952 gmethod)))
11953 (setq methods (cdr methods)))
11954 methods))
11956 (defun gnus-find-method-for-group (group &optional info)
11957 (or gnus-override-method
11958 (and (not group)
11959 gnus-select-method)
11960 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11961 method)
11962 (if (or (not info)
11963 (not (setq method (nth 4 info))))
11964 (setq method gnus-select-method)
11965 (setq method
11966 (cond ((stringp method)
11967 (gnus-server-to-method method))
11968 ((stringp (car method))
11969 (gnus-server-extend-method group method))
11971 method))))
11972 (gnus-server-add-address method))))
11974 (defun gnus-check-backend-function (func group)
11975 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11976 group)))
11977 (fboundp (intern (format "%s-%s" method func)))))
11979 (defun gnus-methods-using (method)
11980 (let ((valids gnus-valid-select-methods)
11981 outs)
11982 (while valids
11983 (if (memq method (car valids))
11984 (setq outs (cons (car valids) outs)))
11985 (setq valids (cdr valids)))
11986 outs))
11988 ;;;
11989 ;;; Active & Newsrc File Handling
11992 ;; Newsrc related functions.
11993 ;; Gnus internal format of gnus-newsrc-alist:
11994 ;; (("alt.general" 3 (1 . 1))
11995 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11996 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11997 ;; The first item is the group name; the second is the subscription
11998 ;; level; the third is either a range of a list of ranges of read
11999 ;; articles, the optional fourth element is a list of marked articles,
12000 ;; the optional fifth element is the select method.
12002 ;; Gnus internal format of gnus-newsrc-hashtb:
12003 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12004 ;; This is the entry for "alt.misc". The first element is the number
12005 ;; of unread articles in "alt.misc". The cdr of this entry is the
12006 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12007 ;; trivial to remove or add new elements into gnus-newsrc-alist
12008 ;; without scanning the entire list. So, to get the actual information
12009 ;; of "alt.misc", you'd say something like
12010 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12012 ;; Gnus internal format of gnus-active-hashtb:
12013 ;; ((1 . 1))
12014 ;; (5 . 10))
12015 ;; (67 . 99)) ...)
12016 ;; The only element in each entry in this hash table is a range of
12017 ;; (possibly) available articles. (Articles in this range may have
12018 ;; been expired or canceled.)
12020 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12021 ;; ("alt.misc" "alt.test" "alt.general" ...)
12023 (defun gnus-setup-news (&optional rawfile level)
12024 "Setup news information.
12025 If RAWFILE is non-nil, the .newsrc file will also be read.
12026 If LEVEL is non-nil, the news will be set up at level LEVEL."
12027 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12028 ;; Clear some variables to re-initialize news information.
12029 (if init (setq gnus-newsrc-alist nil
12030 gnus-active-hashtb nil))
12032 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12033 (if init (gnus-read-newsrc-file rawfile))
12035 ;; If we don't read the complete active file, we fill in the
12036 ;; hashtb here.
12037 (if (or (null gnus-read-active-file)
12038 (eq gnus-read-active-file 'some))
12039 (gnus-update-active-hashtb-from-killed))
12041 ;; Read the active file and create `gnus-active-hashtb'.
12042 ;; If `gnus-read-active-file' is nil, then we just create an empty
12043 ;; hash table. The partial filling out of the hash table will be
12044 ;; done in `gnus-get-unread-articles'.
12045 (and gnus-read-active-file
12046 (not level)
12047 (gnus-read-active-file))
12049 (or gnus-active-hashtb
12050 (setq gnus-active-hashtb (make-vector 4095 0)))
12052 ;; Possibly eval the dribble file.
12053 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12055 (gnus-update-format-specifications)
12057 ;; Find new newsgroups and treat them.
12058 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12059 (gnus-server-opened gnus-select-method))
12060 (gnus-find-new-newsgroups))
12062 ;; Find the number of unread articles in each non-dead group.
12063 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12064 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12066 (if (and init gnus-check-bogus-newsgroups
12067 gnus-read-active-file (not level)
12068 (gnus-server-opened gnus-select-method))
12069 (gnus-check-bogus-newsgroups))))
12071 (defun gnus-find-new-newsgroups ()
12072 "Search for new newsgroups and add them.
12073 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12074 The `-n' option line from .newsrc is respected."
12075 (interactive)
12076 (or (gnus-check-first-time-used)
12077 (if (or (consp gnus-check-new-newsgroups)
12078 (eq gnus-check-new-newsgroups 'ask-server))
12079 (gnus-ask-server-for-new-groups)
12080 (let ((groups 0)
12081 group new-newsgroups)
12082 (gnus-message 5 "Looking for new newsgroups...")
12083 (or gnus-have-read-active-file (gnus-read-active-file))
12084 (setq gnus-newsrc-last-checked-date (current-time-string))
12085 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12086 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12087 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12088 (mapatoms
12089 (lambda (sym)
12090 (if (or (null (setq group (symbol-name sym)))
12091 (null (symbol-value sym))
12092 (gnus-gethash group gnus-killed-hashtb)
12093 (gnus-gethash group gnus-newsrc-hashtb))
12095 (let ((do-sub (gnus-matches-options-n group)))
12096 (cond
12097 ((eq do-sub 'subscribe)
12098 (setq groups (1+ groups))
12099 (gnus-sethash group group gnus-killed-hashtb)
12100 (funcall gnus-subscribe-options-newsgroup-method group))
12101 ((eq do-sub 'ignore)
12102 nil)
12104 (setq groups (1+ groups))
12105 (gnus-sethash group group gnus-killed-hashtb)
12106 (if gnus-subscribe-hierarchical-interactive
12107 (setq new-newsgroups (cons group new-newsgroups))
12108 (funcall gnus-subscribe-newsgroup-method group)))))))
12109 gnus-active-hashtb)
12110 (if new-newsgroups
12111 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12112 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12113 (if (> groups 0)
12114 (gnus-message 6 "%d new newsgroup%s arrived."
12115 groups (if (> groups 1) "s have" " has"))
12116 (gnus-message 6 "No new newsgroups."))))))
12118 (defun gnus-matches-options-n (group)
12119 ;; Returns `subscribe' if the group is to be uncoditionally
12120 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12121 ;; no match for the group.
12123 ;; First we check the two user variables.
12124 (cond
12125 ((and gnus-options-subscribe
12126 (string-match gnus-options-subscribe group))
12127 'subscribe)
12128 ((and gnus-options-not-subscribe
12129 (string-match gnus-options-not-subscribe group))
12130 'ignore)
12131 ;; Then we go through the list that was retrieved from the .newsrc
12132 ;; file. This list has elements on the form
12133 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12134 ;; is in the reverse order of the options line) is returned.
12136 (let ((regs gnus-newsrc-options-n))
12137 (while (and regs
12138 (not (string-match (car (car regs)) group)))
12139 (setq regs (cdr regs)))
12140 (and regs (cdr (car regs)))))))
12142 (defun gnus-ask-server-for-new-groups ()
12143 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12144 (methods (cons gnus-select-method
12145 (append
12146 (and (consp gnus-check-new-newsgroups)
12147 gnus-check-new-newsgroups)
12148 gnus-secondary-select-methods)))
12149 (groups 0)
12150 (new-date (current-time-string))
12151 (hashtb (gnus-make-hashtable 100))
12152 group new-newsgroups got-new method)
12153 ;; Go through both primary and secondary select methods and
12154 ;; request new newsgroups.
12155 (while methods
12156 (setq method (gnus-server-get-method nil (car methods)))
12157 (and (gnus-check-server method)
12158 (gnus-request-newgroups date method)
12159 (save-excursion
12160 (setq got-new t)
12161 (set-buffer nntp-server-buffer)
12162 ;; Enter all the new groups in a hashtable.
12163 (gnus-active-to-gnus-format method hashtb 'ignore)))
12164 (setq methods (cdr methods)))
12165 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12166 ;; Now all new groups from all select methods are in `hashtb'.
12167 (mapatoms
12168 (lambda (group-sym)
12169 (setq group (symbol-name group-sym))
12170 (if (or (null group)
12171 (null (symbol-value group-sym))
12172 (gnus-gethash group gnus-newsrc-hashtb)
12173 (member group gnus-zombie-list)
12174 (member group gnus-killed-list))
12175 ;; The group is already known.
12177 (and (symbol-value group-sym)
12178 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12179 (let ((do-sub (gnus-matches-options-n group)))
12180 (cond ((eq do-sub 'subscribe)
12181 (setq groups (1+ groups))
12182 (gnus-sethash group group gnus-killed-hashtb)
12183 (funcall
12184 gnus-subscribe-options-newsgroup-method group))
12185 ((eq do-sub 'ignore)
12186 nil)
12188 (setq groups (1+ groups))
12189 (gnus-sethash group group gnus-killed-hashtb)
12190 (if gnus-subscribe-hierarchical-interactive
12191 (setq new-newsgroups (cons group new-newsgroups))
12192 (funcall gnus-subscribe-newsgroup-method group)))))))
12193 hashtb)
12194 (if new-newsgroups
12195 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12196 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12197 (if (> groups 0)
12198 (gnus-message 6 "%d new newsgroup%s arrived."
12199 groups (if (> groups 1) "s have" " has")))
12200 got-new))
12202 (defun gnus-check-first-time-used ()
12203 (if (or (> (length gnus-newsrc-alist) 1)
12204 (file-exists-p gnus-startup-file)
12205 (file-exists-p (concat gnus-startup-file ".el"))
12206 (file-exists-p (concat gnus-startup-file ".eld")))
12208 (gnus-message 6 "First time user; subscribing you to default groups")
12209 (or gnus-have-read-active-file (gnus-read-active-file))
12210 (setq gnus-newsrc-last-checked-date (current-time-string))
12211 (let ((groups gnus-default-subscribed-newsgroups)
12212 group)
12213 (if (eq groups t)
12215 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12216 (mapatoms
12217 (lambda (sym)
12218 (if (null (setq group (symbol-name sym)))
12220 (let ((do-sub (gnus-matches-options-n group)))
12221 (cond
12222 ((eq do-sub 'subscribe)
12223 (gnus-sethash group group gnus-killed-hashtb)
12224 (funcall gnus-subscribe-options-newsgroup-method group))
12225 ((eq do-sub 'ignore)
12226 nil)
12228 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12229 gnus-active-hashtb)
12230 (while groups
12231 (if (gnus-gethash (car groups) gnus-active-hashtb)
12232 (gnus-group-change-level
12233 (car groups) gnus-level-default-subscribed gnus-level-killed))
12234 (setq groups (cdr groups)))
12235 (gnus-group-make-help-group)
12236 (and gnus-novice-user
12237 (gnus-message 7 "`A k' to list killed groups"))))))
12239 (defun gnus-subscribe-group (group previous &optional method)
12240 (gnus-group-change-level
12241 (if method
12242 (list t group gnus-level-default-subscribed nil nil method)
12243 group)
12244 gnus-level-default-subscribed gnus-level-killed previous t))
12246 ;; `gnus-group-change-level' is the fundamental function for changing
12247 ;; subscription levels of newsgroups. This might mean just changing
12248 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12249 ;; again, which subscribes/unsubscribes a group, which is equally
12250 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12251 ;; from 8-9 to 1-7 means that you remove the group from the list of
12252 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12253 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12254 ;; which is trivial.
12255 ;; ENTRY can either be a string (newsgroup name) or a list (if
12256 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12257 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12258 ;; entries.
12259 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12260 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12261 ;; after.
12262 (defun gnus-group-change-level (entry level &optional oldlevel
12263 previous fromkilled)
12264 (let (group info active num)
12265 ;; Glean what info we can from the arguments
12266 (if (consp entry)
12267 (if fromkilled (setq group (nth 1 entry))
12268 (setq group (car (nth 2 entry))))
12269 (setq group entry))
12270 (if (and (stringp entry)
12271 oldlevel
12272 (< oldlevel gnus-level-zombie))
12273 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12274 (if (and (not oldlevel)
12275 (consp entry))
12276 (setq oldlevel (car (cdr (nth 2 entry)))))
12277 (if (stringp previous)
12278 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12280 (if (and (>= oldlevel gnus-level-zombie)
12281 (gnus-gethash group gnus-newsrc-hashtb))
12282 ;; We are trying to subscribe a group that is already
12283 ;; subscribed.
12284 () ; Do nothing.
12286 (or (gnus-ephemeral-group-p group)
12287 (gnus-dribble-enter
12288 (format "(gnus-group-change-level %S %S %S %S %S)"
12289 group level oldlevel (car (nth 2 previous)) fromkilled)))
12291 ;; Then we remove the newgroup from any old structures, if needed.
12292 ;; If the group was killed, we remove it from the killed or zombie
12293 ;; list. If not, and it is in fact going to be killed, we remove
12294 ;; it from the newsrc hash table and assoc.
12295 (cond ((>= oldlevel gnus-level-zombie)
12296 (if (= oldlevel gnus-level-zombie)
12297 (setq gnus-zombie-list (delete group gnus-zombie-list))
12298 (setq gnus-killed-list (delete group gnus-killed-list))))
12300 (if (and (>= level gnus-level-zombie)
12301 entry)
12302 (progn
12303 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12304 (if (nth 3 entry)
12305 (setcdr (gnus-gethash (car (nth 3 entry))
12306 gnus-newsrc-hashtb)
12307 (cdr entry)))
12308 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12310 ;; Finally we enter (if needed) the list where it is supposed to
12311 ;; go, and change the subscription level. If it is to be killed,
12312 ;; we enter it into the killed or zombie list.
12313 (cond ((>= level gnus-level-zombie)
12314 ;; Remove from the hash table.
12315 (gnus-sethash group nil gnus-newsrc-hashtb)
12316 (or (gnus-group-foreign-p group)
12317 ;; We do not enter foreign groups into the list of dead
12318 ;; groups.
12319 (if (= level gnus-level-zombie)
12320 (setq gnus-zombie-list (cons group gnus-zombie-list))
12321 (setq gnus-killed-list (cons group gnus-killed-list)))))
12323 ;; If the list is to be entered into the newsrc assoc, and
12324 ;; it was killed, we have to create an entry in the newsrc
12325 ;; hashtb format and fix the pointers in the newsrc assoc.
12326 (if (>= oldlevel gnus-level-zombie)
12327 (progn
12328 (if (listp entry)
12329 (progn
12330 (setq info (cdr entry))
12331 (setq num (car entry)))
12332 (setq active (gnus-gethash group gnus-active-hashtb))
12333 (setq num
12334 (if active (- (1+ (cdr active)) (car active)) t))
12335 ;; Check whether the group is foreign. If so, the
12336 ;; foreign select method has to be entered into the
12337 ;; info.
12338 (let ((method (gnus-group-method-name group)))
12339 (if (eq method gnus-select-method)
12340 (setq info (list group level nil))
12341 (setq info (list group level nil nil method)))))
12342 (or previous
12343 (setq previous
12344 (let ((p gnus-newsrc-alist))
12345 (while (cdr (cdr p))
12346 (setq p (cdr p)))
12347 p)))
12348 (setq entry (cons info (cdr (cdr previous))))
12349 (if (cdr previous)
12350 (progn
12351 (setcdr (cdr previous) entry)
12352 (gnus-sethash group (cons num (cdr previous))
12353 gnus-newsrc-hashtb))
12354 (setcdr previous entry)
12355 (gnus-sethash group (cons num previous)
12356 gnus-newsrc-hashtb))
12357 (if (cdr entry)
12358 (setcdr (gnus-gethash (car (car (cdr entry)))
12359 gnus-newsrc-hashtb)
12360 entry)))
12361 ;; It was alive, and it is going to stay alive, so we
12362 ;; just change the level and don't change any pointers or
12363 ;; hash table entries.
12364 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12366 (defun gnus-kill-newsgroup (newsgroup)
12367 "Obsolete function. Kills a newsgroup."
12368 (gnus-group-change-level
12369 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12371 (defun gnus-check-bogus-newsgroups (&optional confirm)
12372 "Remove bogus newsgroups.
12373 If CONFIRM is non-nil, the user has to confirm the deletion of every
12374 newsgroup."
12375 (let ((newsrc (cdr gnus-newsrc-alist))
12376 bogus group entry)
12377 (gnus-message 5 "Checking bogus newsgroups...")
12378 (or gnus-have-read-active-file (gnus-read-active-file))
12379 ;; Find all bogus newsgroup that are subscribed.
12380 (while newsrc
12381 (setq group (car (car newsrc)))
12382 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12383 (nth 4 (car newsrc)) ; Foreign
12384 (and confirm
12385 (not (gnus-y-or-n-p
12386 (format "Remove bogus newsgroup: %s " group)))))
12387 ;; Don't remove.
12389 ;; Found a bogus newsgroup.
12390 (setq bogus (cons group bogus)))
12391 (setq newsrc (cdr newsrc)))
12392 ;; Remove all bogus subscribed groups by first killing them, and
12393 ;; then removing them from the list of killed groups.
12394 (while bogus
12395 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12396 (progn
12397 (gnus-group-change-level entry gnus-level-killed)
12398 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12399 (setq bogus (cdr bogus)))
12400 ;; Then we remove all bogus groups from the list of killed and
12401 ;; zombie groups. They are are removed without confirmation.
12402 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12403 killed)
12404 (while dead-lists
12405 (setq killed (symbol-value (car dead-lists)))
12406 (while killed
12407 (setq group (car killed))
12408 (or (gnus-gethash group gnus-active-hashtb)
12409 ;; The group is bogus.
12410 (set (car dead-lists)
12411 (delete group (symbol-value (car dead-lists)))))
12412 (setq killed (cdr killed)))
12413 (setq dead-lists (cdr dead-lists))))
12414 (gnus-message 5 "Checking bogus newsgroups...done")))
12416 (defun gnus-check-duplicate-killed-groups ()
12417 "Remove duplicates from the list of killed groups."
12418 (interactive)
12419 (let ((killed gnus-killed-list))
12420 (while killed
12421 (gnus-message 9 "%d" (length killed))
12422 (setcdr killed (delete (car killed) (cdr killed)))
12423 (setq killed (cdr killed)))))
12425 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12426 ;; and compute how many unread articles there are in each group.
12427 (defun gnus-get-unread-articles (&optional level)
12428 (let* ((newsrc (cdr gnus-newsrc-alist))
12429 (level (or level (1+ gnus-level-subscribed)))
12430 (foreign-level
12431 (min
12432 (cond ((and gnus-activate-foreign-newsgroups
12433 (not (numberp gnus-activate-foreign-newsgroups)))
12434 (1+ gnus-level-subscribed))
12435 ((numberp gnus-activate-foreign-newsgroups)
12436 gnus-activate-foreign-newsgroups)
12437 (t 0))
12438 level))
12439 info group active virtuals method)
12440 (gnus-message 5 "Checking new news...")
12442 (while newsrc
12443 (setq info (car newsrc)
12444 group (car info)
12445 active (gnus-gethash group gnus-active-hashtb))
12447 ;; Check newsgroups. If the user doesn't want to check them, or
12448 ;; they can't be checked (for instance, if the news server can't
12449 ;; be reached) we just set the number of unread articles in this
12450 ;; newsgroup to t. This means that Gnus thinks that there are
12451 ;; unread articles, but it has no idea how many.
12452 (if (and (setq method (nth 4 info))
12453 (not (gnus-server-equal gnus-select-method
12454 (gnus-server-get-method nil method)))
12455 (not (gnus-secondary-method-p method)))
12456 ;; These groups are foreign. Check the level.
12457 (if (<= (nth 1 info) foreign-level)
12458 (if (eq (car (if (stringp method)
12459 (gnus-server-to-method method)
12460 (nth 4 info))) 'nnvirtual)
12461 ;; We have to activate the virtual groups after all
12462 ;; the others, so we just pop them on a list for
12463 ;; now.
12464 (setq virtuals (cons info virtuals))
12465 (and (setq active (gnus-activate-group (car info)))
12466 ;; Close the groups as we look at them!
12467 (gnus-close-group group))))
12469 ;; These groups are native or secondary.
12470 (if (and (not gnus-read-active-file)
12471 (<= (nth 1 info) level))
12472 (progn
12473 (or gnus-read-active-file (gnus-check-server method))
12474 (setq active (gnus-activate-group (car info))))))
12476 (if active
12477 (gnus-get-unread-articles-in-group info active)
12478 ;; The group couldn't be reached, so we nix out the number of
12479 ;; unread articles and stuff.
12480 (gnus-sethash group nil gnus-active-hashtb)
12481 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12483 (setq newsrc (cdr newsrc)))
12485 ;; Activate the virtual groups. This has to be done after all the
12486 ;; other groups.
12487 ;; !!! If one virtual group contains another virtual group, even
12488 ;; doing it this way might cause problems.
12489 (while virtuals
12490 (and (setq active (gnus-activate-group (car (car virtuals))))
12491 (gnus-get-unread-articles-in-group (car virtuals) active))
12492 (setq virtuals (cdr virtuals)))
12494 (gnus-message 5 "Checking new news...done")))
12496 ;; Create a hash table out of the newsrc alist. The `car's of the
12497 ;; alist elements are used as keys.
12498 (defun gnus-make-hashtable-from-newsrc-alist ()
12499 (let ((alist gnus-newsrc-alist)
12500 (ohashtb gnus-newsrc-hashtb)
12501 prev)
12502 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12503 (setq alist
12504 (setq prev (setq gnus-newsrc-alist
12505 (if (equal (car (car gnus-newsrc-alist))
12506 "dummy.group")
12507 gnus-newsrc-alist
12508 (cons (list "dummy.group" 0 nil) alist)))))
12509 (while alist
12510 (gnus-sethash (car (car alist))
12511 (cons (and ohashtb (car (gnus-gethash
12512 (car (car alist)) ohashtb)))
12513 prev) gnus-newsrc-hashtb)
12514 (setq prev alist
12515 alist (cdr alist)))))
12517 (defun gnus-make-hashtable-from-killed ()
12518 "Create a hash table from the killed and zombie lists."
12519 (let ((lists '(gnus-killed-list gnus-zombie-list))
12520 list)
12521 (setq gnus-killed-hashtb
12522 (gnus-make-hashtable
12523 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12524 (while lists
12525 (setq list (symbol-value (car lists)))
12526 (setq lists (cdr lists))
12527 (while list
12528 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12529 (setq list (cdr list))))))
12531 (defun gnus-get-unread-articles-in-group (info active)
12532 (let* ((range (nth 2 info))
12533 (num 0)
12534 (marked (nth 3 info)))
12535 ;; If a cache is present, we may have to alter the active info.
12536 (and gnus-use-cache
12537 (gnus-cache-possibly-alter-active (car info) active))
12538 ;; Modify the list of read articles according to what articles
12539 ;; are available; then tally the unread articles and add the
12540 ;; number to the group hash table entry.
12541 (cond
12542 ((zerop (cdr active))
12543 (setq num 0))
12544 ((not range)
12545 (setq num (- (1+ (cdr active)) (car active))))
12546 ((not (listp (cdr range)))
12547 ;; Fix a single (num . num) range according to the
12548 ;; active hash table.
12549 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12550 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12551 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12552 ;; Compute number of unread articles.
12553 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12555 ;; The read list is a list of ranges. Fix them according to
12556 ;; the active hash table.
12557 ;; First peel off any elements that are below the lower
12558 ;; active limit.
12559 (while (and (cdr range)
12560 (>= (car active)
12561 (or (and (atom (car (cdr range))) (car (cdr range)))
12562 (car (car (cdr range))))))
12563 (if (numberp (car range))
12564 (setcar range
12565 (cons (car range)
12566 (or (and (numberp (car (cdr range)))
12567 (car (cdr range)))
12568 (cdr (car (cdr range))))))
12569 (setcdr (car range)
12570 (or (and (numberp (nth 1 range)) (nth 1 range))
12571 (cdr (car (cdr range))))))
12572 (setcdr range (cdr (cdr range))))
12573 ;; Adjust the first element to be the same as the lower limit.
12574 (if (and (not (atom (car range)))
12575 (< (cdr (car range)) (car active)))
12576 (setcdr (car range) (1- (car active))))
12577 ;; Then we want to peel off any elements that are higher
12578 ;; than the upper active limit.
12579 (let ((srange range))
12580 ;; Go past all legal elements.
12581 (while (and (cdr srange)
12582 (<= (or (and (atom (car (cdr srange)))
12583 (car (cdr srange)))
12584 (car (car (cdr srange)))) (cdr active)))
12585 (setq srange (cdr srange)))
12586 (if (cdr srange)
12587 ;; Nuke all remaining illegal elements.
12588 (setcdr srange nil))
12590 ;; Adjust the final element.
12591 (if (and (not (atom (car srange)))
12592 (> (cdr (car srange)) (cdr active)))
12593 (setcdr (car srange) (cdr active))))
12594 ;; Compute the number of unread articles.
12595 (while range
12596 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12597 (cdr (car range))))
12598 (or (and (atom (car range)) (car range))
12599 (car (car range))))))
12600 (setq range (cdr range)))
12601 (setq num (max 0 (- (cdr active) num)))))
12602 (and info
12603 (progn
12604 (and (assq 'tick marked)
12605 (inline (gnus-remove-illegal-marked-articles
12606 (assq 'tick marked) (nth 2 info))))
12607 (and (assq 'dormant marked)
12608 (inline (gnus-remove-illegal-marked-articles
12609 (assq 'dormant marked) (nth 2 info))))
12610 (setcar
12611 (gnus-gethash (car info) gnus-newsrc-hashtb)
12612 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12613 (length (cdr (assq 'dormant marked)))))))))
12614 num))
12616 (defun gnus-remove-illegal-marked-articles (marked ranges)
12617 (let ((m (cdr marked)))
12618 ;; Make sure that all ticked articles are a subset of the unread
12619 ;; articles.
12620 (while m
12621 (if (gnus-member-of-range (car m) ranges)
12622 (setcdr marked (cdr m))
12623 (setq marked m))
12624 (setq m (cdr m)))))
12626 (defun gnus-activate-group (group)
12627 ;; Check whether a group has been activated or not.
12628 (let ((method (gnus-find-method-for-group group))
12629 active)
12630 (and (gnus-check-server method)
12631 ;; We escape all bugs and quit here to make it possible to
12632 ;; continue if a group is so out-there that it reports bugs
12633 ;; and stuff.
12634 (condition-case ()
12635 (gnus-request-group group)
12636 (error nil)
12637 (quit nil))
12638 (save-excursion
12639 (set-buffer nntp-server-buffer)
12640 (goto-char (point-min))
12641 ;; Parse the result we got from `gnus-request-group'.
12642 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12643 (progn
12644 (goto-char (match-beginning 1))
12645 (gnus-sethash
12646 group (setq active (cons (read (current-buffer))
12647 (read (current-buffer))))
12648 gnus-active-hashtb))
12649 ;; Return the new active info.
12650 active)))))
12652 (defun gnus-update-read-articles
12653 (group unread unselected ticked &optional domarks replied expirable killed
12654 dormant bookmark score)
12655 "Update the list of read and ticked articles in GROUP using the
12656 UNREAD and TICKED lists.
12657 Note: UNSELECTED has to be sorted over `<'.
12658 Returns whether the updating was successful."
12659 (let* ((active (or gnus-newsgroup-active
12660 (gnus-gethash group gnus-active-hashtb)))
12661 (entry (gnus-gethash group gnus-newsrc-hashtb))
12662 (info (nth 2 entry))
12663 (marked (nth 3 info))
12664 (prev 1)
12665 (unread (sort (copy-sequence unread) (function <)))
12666 read)
12667 (if (or (not info) (not active))
12668 ;; There is no info on this group if it was, in fact,
12669 ;; killed. Gnus stores no information on killed groups, so
12670 ;; there's nothing to be done.
12671 ;; One could store the information somewhere temporarily,
12672 ;; perhaps... Hmmm...
12674 ;; Remove any negative articles numbers.
12675 (while (and unread (< (car unread) 0))
12676 (setq unread (cdr unread)))
12677 ;; Remove any expired article numbers
12678 (while (and unread (< (car unread) (car active)))
12679 (setq unread (cdr unread)))
12680 (while (and ticked (< (car ticked) (car active)))
12681 (setq ticked (cdr ticked)))
12682 (while (and dormant (< (car dormant) (car active)))
12683 (setq dormant (cdr dormant)))
12684 (setq unread (sort (append unselected unread) '<))
12685 ;; Compute the ranges of read articles by looking at the list of
12686 ;; unread articles.
12687 (while unread
12688 (if (/= (car unread) prev)
12689 (setq read (cons (if (= prev (1- (car unread))) prev
12690 (cons prev (1- (car unread)))) read)))
12691 (setq prev (1+ (car unread)))
12692 (setq unread (cdr unread)))
12693 (if (<= prev (cdr active))
12694 (setq read (cons (cons prev (cdr active)) read)))
12695 ;; Enter this list into the group info.
12696 (setcar (cdr (cdr info))
12697 (if (> (length read) 1) (nreverse read) read))
12698 ;; Enter the list of ticked articles.
12699 (gnus-set-marked-articles
12700 info ticked
12701 (if domarks replied (cdr (assq 'reply marked)))
12702 (if domarks expirable (cdr (assq 'expire marked)))
12703 (if domarks killed (cdr (assq 'killed marked)))
12704 (if domarks dormant (cdr (assq 'dormant marked)))
12705 (if domarks bookmark (cdr (assq 'bookmark marked)))
12706 (if domarks score (cdr (assq 'score marked))))
12707 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12708 (gnus-get-unread-articles-in-group
12709 info (gnus-gethash group gnus-active-hashtb))
12710 t)))
12712 (defun gnus-make-articles-unread (group articles)
12713 "Mark ARTICLES in GROUP as unread."
12714 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12715 (gnus-gethash (gnus-group-real-name group)
12716 gnus-newsrc-hashtb))))
12717 (ranges (nth 2 info))
12718 news)
12719 (while articles
12720 (and (gnus-member-of-range (car articles) ranges)
12721 (setq news (cons (car articles) news)))
12722 (setq articles (cdr articles)))
12723 (if (not news)
12725 (setcar (nthcdr 2 info)
12726 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12727 (gnus-group-update-group group t))))
12729 ;; Enter all dead groups into the hashtb.
12730 (defun gnus-update-active-hashtb-from-killed ()
12731 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12732 (lists (list gnus-killed-list gnus-zombie-list))
12733 killed)
12734 (while lists
12735 (setq killed (car lists))
12736 (while killed
12737 (gnus-sethash (car killed) nil hashtb)
12738 (setq killed (cdr killed)))
12739 (setq lists (cdr lists)))))
12741 ;; Get the active file(s) from the backend(s).
12742 (defun gnus-read-active-file ()
12743 (gnus-group-set-mode-line)
12744 (let ((methods (if (gnus-check-server gnus-select-method)
12745 ;; The native server is available.
12746 (cons gnus-select-method gnus-secondary-select-methods)
12747 ;; The native server is down, so we just do the
12748 ;; secondary ones.
12749 gnus-secondary-select-methods))
12750 list-type)
12751 (setq gnus-have-read-active-file nil)
12752 (save-excursion
12753 (set-buffer nntp-server-buffer)
12754 (while methods
12755 (let* ((method (gnus-server-get-method nil (car methods)))
12756 (where (nth 1 method))
12757 (mesg (format "Reading active file%s via %s..."
12758 (if (and where (not (zerop (length where))))
12759 (concat " from " where) "")
12760 (car method))))
12761 (gnus-message 5 mesg)
12762 (if (not (gnus-check-server method))
12764 (cond
12765 ((and (eq gnus-read-active-file 'some)
12766 (gnus-check-backend-function 'retrieve-groups (car method)))
12767 (let ((newsrc (cdr gnus-newsrc-alist))
12768 (gmethod (gnus-server-get-method nil method))
12769 groups)
12770 (while newsrc
12771 (and (gnus-server-equal
12772 (gnus-find-method-for-group
12773 (car (car newsrc)) (car newsrc))
12774 gmethod)
12775 (setq groups (cons (gnus-group-real-name
12776 (car (car newsrc))) groups)))
12777 (setq newsrc (cdr newsrc)))
12778 (gnus-check-server method)
12779 (setq list-type (gnus-retrieve-groups groups method))
12780 (cond
12781 ((not list-type)
12782 (gnus-message
12783 1 "Cannot read partial active file from %s server."
12784 (car method))
12785 (ding)
12786 (sit-for 2))
12787 ((eq list-type 'active)
12788 (gnus-active-to-gnus-format method gnus-active-hashtb))
12790 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12792 (if (not (gnus-request-list method))
12793 (progn
12794 (gnus-message 1 "Cannot read active file from %s server."
12795 (car method))
12796 (ding))
12797 (gnus-active-to-gnus-format method)
12798 ;; We mark this active file as read.
12799 (setq gnus-have-read-active-file
12800 (cons method gnus-have-read-active-file))
12801 (gnus-message 5 "%sdone" mesg))))))
12802 (setq methods (cdr methods))))))
12804 ;; Read an active file and place the results in `gnus-active-hashtb'.
12805 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12806 (let ((cur (current-buffer))
12807 (hashtb (or hashtb
12808 (if (and gnus-active-hashtb
12809 (not (equal method gnus-select-method)))
12810 gnus-active-hashtb
12811 (setq gnus-active-hashtb
12812 (if (equal method gnus-select-method)
12813 (gnus-make-hashtable
12814 (count-lines (point-min) (point-max)))
12815 (gnus-make-hashtable 4096))))))
12816 (flag-hashtb (gnus-make-hashtable 60)))
12817 ;; Delete unnecessary lines.
12818 (goto-char (point-min))
12819 (while (search-forward "\nto." nil t)
12820 (delete-region (1+ (match-beginning 0))
12821 (progn (forward-line 1) (point))))
12822 (or (string= gnus-ignored-newsgroups "")
12823 (progn
12824 (goto-char (point-min))
12825 (delete-matching-lines gnus-ignored-newsgroups)))
12826 ;; Make the group names readable as a lisp expression even if they
12827 ;; contain special characters.
12828 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12829 (goto-char (point-max))
12830 (while (re-search-backward "[][';?()#]" nil t)
12831 (insert ?\\))
12832 ;; If these are groups from a foreign select method, we insert the
12833 ;; group prefix in front of the group names.
12834 (and method (not (gnus-server-equal
12835 (gnus-server-get-method nil method)
12836 (gnus-server-get-method nil gnus-select-method)))
12837 (let ((prefix (gnus-group-prefixed-name "" method)))
12838 (goto-char (point-min))
12839 (while (and (not (eobp))
12840 (progn (insert prefix)
12841 (zerop (forward-line 1)))))))
12842 ;; Store the active file in a hash table.
12843 (goto-char (point-min))
12844 (if (string-match "%[oO]" gnus-group-line-format)
12845 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12846 ;; If we want information on moderated groups, we use this
12847 ;; loop...
12848 (let* ((mod-hashtb (make-vector 7 0))
12849 (m (intern "m" mod-hashtb))
12850 group max min)
12851 (while (not (eobp))
12852 (condition-case nil
12853 (progn
12854 (narrow-to-region (point) (gnus-point-at-eol))
12855 (setq group (let ((obarray hashtb)) (read cur)))
12856 (if (and (numberp (setq max (read cur)))
12857 (numberp (setq min (read cur)))
12858 (progn
12859 (skip-chars-forward " \t")
12860 (not
12861 (or (= (following-char) ?=)
12862 (= (following-char) ?x)
12863 (= (following-char) ?j)))))
12864 (set group (cons min max))
12865 (set group nil))
12866 ;; Enter moderated groups into a list.
12867 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12868 (setq gnus-moderated-list
12869 (cons (symbol-name group) gnus-moderated-list))))
12870 (error
12871 (and group
12872 (symbolp group)
12873 (set group nil))))
12874 (widen)
12875 (forward-line 1)))
12876 ;; And if we do not care about moderation, we use this loop,
12877 ;; which is faster.
12878 (let (group max min)
12879 (while (not (eobp))
12880 (condition-case ()
12881 (progn
12882 (narrow-to-region (point) (gnus-point-at-eol))
12883 ;; group gets set to a symbol interned in the hash table
12884 ;; (what a hack!!) - jwz
12885 (setq group (let ((obarray hashtb)) (read cur)))
12886 (if (and (numberp (setq max (read cur)))
12887 (numberp (setq min (read cur)))
12888 (progn
12889 (skip-chars-forward " \t")
12890 (not
12891 (or (= (following-char) ?=)
12892 (= (following-char) ?x)
12893 (= (following-char) ?j)))))
12894 (set group (cons min max))
12895 (set group nil)))
12896 (error
12897 (progn
12898 (and group
12899 (symbolp group)
12900 (set group nil))
12901 (or ignore-errors
12902 (gnus-message 3 "Warning - illegal active: %s"
12903 (buffer-substring
12904 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12905 (widen)
12906 (forward-line 1))))))
12908 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12909 ;; Parse a "groups" active file.
12910 (let ((cur (current-buffer))
12911 (hashtb (or hashtb
12912 (if (and method gnus-active-hashtb)
12913 gnus-active-hashtb
12914 (setq gnus-active-hashtb
12915 (gnus-make-hashtable
12916 (count-lines (point-min) (point-max)))))))
12917 (prefix (and method
12918 (not (gnus-server-equal
12919 (gnus-server-get-method nil method)
12920 (gnus-server-get-method nil gnus-select-method)))
12921 (gnus-group-prefixed-name "" method))))
12923 (goto-char (point-min))
12924 ;; We split this into to separate loops, one with the prefix
12925 ;; and one without to speed the reading up somewhat.
12926 (if prefix
12927 (let (min max opoint group)
12928 (while (not (eobp))
12929 (condition-case ()
12930 (progn
12931 (read cur) (read cur)
12932 (setq min (read cur)
12933 max (read cur)
12934 opoint (point))
12935 (skip-chars-forward " \t")
12936 (insert prefix)
12937 (goto-char opoint)
12938 (set (let ((obarray hashtb)) (read cur))
12939 (cons min max)))
12940 (error (and group (symbolp group) (set group nil))))
12941 (forward-line 1)))
12942 (let (min max group)
12943 (while (not (eobp))
12944 (condition-case ()
12945 (if (= (following-char) ?2)
12946 (progn
12947 (read cur) (read cur)
12948 (setq min (read cur)
12949 max (read cur))
12950 (set (setq group (let ((obarray hashtb)) (read cur)))
12951 (cons min max))))
12952 (error (and group (symbolp group) (set group nil))))
12953 (forward-line 1))))))
12955 (defun gnus-read-newsrc-file (&optional force)
12956 "Read startup file.
12957 If FORCE is non-nil, the .newsrc file is read."
12958 ;; Reset variables that might be defined in the .newsrc.eld file.
12959 (let ((variables gnus-variable-list))
12960 (while variables
12961 (set (car variables) nil)
12962 (setq variables (cdr variables))))
12963 (let* ((newsrc-file gnus-current-startup-file)
12964 (quick-file (concat newsrc-file ".el")))
12965 (save-excursion
12966 ;; We always load the .newsrc.eld file. If always contains
12967 ;; much information that can not be gotten from the .newsrc
12968 ;; file (ticked articles, killed groups, foreign methods, etc.)
12969 (gnus-read-newsrc-el-file quick-file)
12971 (if (or force
12972 (and (file-newer-than-file-p newsrc-file quick-file)
12973 (file-newer-than-file-p newsrc-file
12974 (concat quick-file "d")))
12975 (not gnus-newsrc-alist))
12976 ;; We read the .newsrc file. Note that if there if a
12977 ;; .newsrc.eld file exists, it has already been read, and
12978 ;; the `gnus-newsrc-hashtb' has been created. While reading
12979 ;; the .newsrc file, Gnus will only use the information it
12980 ;; can find there for changing the data already read -
12981 ;; ie. reading the .newsrc file will not trash the data
12982 ;; already read (except for read articles).
12983 (save-excursion
12984 (gnus-message 5 "Reading %s..." newsrc-file)
12985 (set-buffer (find-file-noselect newsrc-file))
12986 (buffer-disable-undo (current-buffer))
12987 (gnus-newsrc-to-gnus-format)
12988 (kill-buffer (current-buffer))
12989 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12991 (defun gnus-read-newsrc-el-file (file)
12992 (let ((ding-file (concat file "d")))
12993 ;; We always, always read the .eld file.
12994 (gnus-message 5 "Reading %s..." ding-file)
12995 (let (gnus-newsrc-assoc)
12996 (condition-case nil
12997 (load ding-file t t t)
12998 (error nil))
12999 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
13000 (let ((inhibit-quit t))
13001 (gnus-uncompress-newsrc-alist))
13002 (gnus-make-hashtable-from-newsrc-alist)
13003 (if (not (file-newer-than-file-p file ding-file))
13005 ;; Old format quick file
13006 (gnus-message 5 "Reading %s..." file)
13007 ;; The .el file is newer than the .eld file, so we read that one
13008 ;; as well.
13009 (gnus-read-old-newsrc-el-file file))))
13011 ;; Parse the old-style quick startup file
13012 (defun gnus-read-old-newsrc-el-file (file)
13013 (let (newsrc killed marked group m)
13014 (prog1
13015 (let ((gnus-killed-assoc nil)
13016 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13017 (prog1
13018 (condition-case nil
13019 (load file t t t)
13020 (error nil))
13021 (setq newsrc gnus-newsrc-assoc
13022 killed gnus-killed-assoc
13023 marked gnus-marked-assoc)))
13024 (setq gnus-newsrc-alist nil)
13025 (while newsrc
13026 (setq group (car newsrc))
13027 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13028 (if info
13029 (progn
13030 (setcar (nthcdr 2 info) (cdr (cdr group)))
13031 (setcar (cdr info)
13032 (if (nth 1 group) gnus-level-default-subscribed
13033 gnus-level-default-unsubscribed))
13034 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13035 (setq gnus-newsrc-alist
13036 (cons
13037 (setq info
13038 (list (car group)
13039 (if (nth 1 group) gnus-level-default-subscribed
13040 gnus-level-default-unsubscribed)
13041 (cdr (cdr group))))
13042 gnus-newsrc-alist)))
13043 (if (setq m (assoc (car group) marked))
13044 (setcdr (cdr (cdr info))
13045 (cons (list (cons 'tick (cdr m))) nil))))
13046 (setq newsrc (cdr newsrc)))
13047 (setq newsrc killed)
13048 (while newsrc
13049 (setcar newsrc (car (car newsrc)))
13050 (setq newsrc (cdr newsrc)))
13051 (setq gnus-killed-list killed))
13052 ;; The .el file version of this variable does not begin with
13053 ;; "options", while the .eld version does, so we just add it if it
13054 ;; isn't there.
13055 (and
13056 gnus-newsrc-options
13057 (progn
13058 (and (not (string-match "^ *options" gnus-newsrc-options))
13059 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13060 (and (not (string-match "\n$" gnus-newsrc-options))
13061 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
13062 ;; Finally, if we read some options lines, we parse them.
13063 (or (string= gnus-newsrc-options "")
13064 (gnus-newsrc-parse-options gnus-newsrc-options))))
13066 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13067 (gnus-make-hashtable-from-newsrc-alist)))
13069 (defun gnus-make-newsrc-file (file)
13070 "Make server dependent file name by catenating FILE and server host name."
13071 (let* ((file (expand-file-name file nil))
13072 (real-file (concat file "-" (nth 1 gnus-select-method))))
13073 (if (or (file-exists-p real-file)
13074 (file-exists-p (concat real-file ".el"))
13075 (file-exists-p (concat real-file ".eld")))
13076 real-file file)))
13078 (defun gnus-uncompress-newsrc-alist ()
13079 ;; Uncompress all lists of marked articles in the newsrc assoc.
13080 (let ((newsrc gnus-newsrc-alist)
13081 marked)
13082 (while newsrc
13083 (if (not (setq marked (nth 3 (car newsrc))))
13085 (while marked
13086 (or (eq 'score (car (car marked)))
13087 (eq 'bookmark (car (car marked)))
13088 (eq 'killed (car (car marked)))
13089 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13090 (setq marked (cdr marked))))
13091 (setq newsrc (cdr newsrc)))))
13093 (defun gnus-compress-newsrc-alist ()
13094 ;; Compress all lists of marked articles in the newsrc assoc.
13095 (let ((newsrc gnus-newsrc-alist)
13096 marked)
13097 (while newsrc
13098 (if (not (setq marked (nth 3 (car newsrc))))
13100 (while marked
13101 (or (eq 'score (car (car marked)))
13102 (eq 'bookmark (car (car marked)))
13103 (eq 'killed (car (car marked)))
13104 (setcdr (car marked)
13105 (condition-case ()
13106 (gnus-compress-sequence
13107 (sort (cdr (car marked)) '<) t)
13108 (error (cdr (car marked))))))
13109 (setq marked (cdr marked))))
13110 (setq newsrc (cdr newsrc)))))
13112 (defun gnus-newsrc-to-gnus-format ()
13113 (setq gnus-newsrc-options "")
13114 (setq gnus-newsrc-options-n nil)
13116 (or gnus-active-hashtb
13117 (setq gnus-active-hashtb (make-vector 4095 0)))
13118 (let ((buf (current-buffer))
13119 (already-read (> (length gnus-newsrc-alist) 1))
13120 group subscribed options-symbol newsrc Options-symbol
13121 symbol reads num1)
13122 (goto-char (point-min))
13123 ;; We intern the symbol `options' in the active hashtb so that we
13124 ;; can `eq' against it later.
13125 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13126 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13128 (while (not (eobp))
13129 ;; We first read the first word on the line by narrowing and
13130 ;; then reading into `gnus-active-hashtb'. Most groups will
13131 ;; already exist in that hashtb, so this will save some string
13132 ;; space.
13133 (narrow-to-region
13134 (point)
13135 (progn (skip-chars-forward "^ \t!:\n") (point)))
13136 (goto-char (point-min))
13137 (setq symbol
13138 (and (/= (point-min) (point-max))
13139 (let ((obarray gnus-active-hashtb)) (read buf))))
13140 (widen)
13141 ;; Now, the symbol we have read is either `options' or a group
13142 ;; name. If it is an options line, we just add it to a string.
13143 (cond
13144 ((or (eq symbol options-symbol)
13145 (eq symbol Options-symbol))
13146 (setq gnus-newsrc-options
13147 ;; This concatting is quite inefficient, but since our
13148 ;; thorough studies show that approx 99.37% of all
13149 ;; .newsrc files only contain a single options line, we
13150 ;; don't give a damn, frankly, my dear.
13151 (concat gnus-newsrc-options
13152 (buffer-substring
13153 (gnus-point-at-bol)
13154 ;; Options may continue on the next line.
13155 (or (and (re-search-forward "^[^ \t]" nil 'move)
13156 (progn (beginning-of-line) (point)))
13157 (point)))))
13158 (forward-line -1))
13159 (symbol
13160 (or (boundp symbol) (set symbol nil))
13161 ;; It was a group name.
13162 (setq subscribed (= (following-char) ?:)
13163 group (symbol-name symbol)
13164 reads nil)
13165 (if (eolp)
13166 ;; If the line ends here, this is clearly a buggy line, so
13167 ;; we put point a the beginning of line and let the cond
13168 ;; below do the error handling.
13169 (beginning-of-line)
13170 ;; We skip to the beginning of the ranges.
13171 (skip-chars-forward "!: \t"))
13172 ;; We are now at the beginning of the list of read articles.
13173 ;; We read them range by range.
13174 (while
13175 (cond
13176 ((looking-at "[0-9]+")
13177 ;; We narrow and read a number instead of buffer-substring/
13178 ;; string-to-int because it's faster. narrow/widen is
13179 ;; faster than save-restriction/narrow, and save-restriction
13180 ;; produces a garbage object.
13181 (setq num1 (progn
13182 (narrow-to-region (match-beginning 0) (match-end 0))
13183 (read buf)))
13184 (widen)
13185 ;; If the next character is a dash, then this is a range.
13186 (if (= (following-char) ?-)
13187 (progn
13188 ;; We read the upper bound of the range.
13189 (forward-char 1)
13190 (if (not (looking-at "[0-9]+"))
13191 ;; This is a buggy line, by we pretend that
13192 ;; it's kinda OK. Perhaps the user should be
13193 ;; dinged?
13194 (setq reads (cons num1 reads))
13195 (setq reads
13196 (cons
13197 (cons num1
13198 (progn
13199 (narrow-to-region (match-beginning 0)
13200 (match-end 0))
13201 (read buf)))
13202 reads))
13203 (widen)))
13204 ;; It was just a simple number, so we add it to the
13205 ;; list of ranges.
13206 (setq reads (cons num1 reads)))
13207 ;; If the next char in ?\n, then we have reached the end
13208 ;; of the line and return nil.
13209 (/= (following-char) ?\n))
13210 ((= (following-char) ?\n)
13211 ;; End of line, so we end.
13212 nil)
13214 ;; Not numbers and not eol, so this might be a buggy
13215 ;; line...
13216 (or (eobp)
13217 ;; If it was eob instead of ?\n, we allow it.
13218 (progn
13219 ;; The line was buggy.
13220 (setq group nil)
13221 (gnus-message 3 "Mangled line: %s"
13222 (buffer-substring (gnus-point-at-bol)
13223 (gnus-point-at-eol)))
13224 (ding)
13225 (sit-for 1)))
13226 nil))
13227 ;; Skip past ", ". Spaces are illegal in these ranges, but
13228 ;; we allow them, because it's a common mistake to put a
13229 ;; space after the comma.
13230 (skip-chars-forward ", "))
13232 ;; We have already read .newsrc.eld, so we gently update the
13233 ;; data in the hash table with the information we have just
13234 ;; read.
13235 (if (not group)
13237 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13238 level)
13239 (if info
13240 ;; There is an entry for this file in the alist.
13241 (progn
13242 (setcar (nthcdr 2 info) (nreverse reads))
13243 ;; We update the level very gently. In fact, we
13244 ;; only change it if there's been a status change
13245 ;; from subscribed to unsubscribed, or vice versa.
13246 (setq level (nth 1 info))
13247 (cond ((and (<= level gnus-level-subscribed)
13248 (not subscribed))
13249 (setq level (if reads
13250 gnus-level-default-unsubscribed
13251 (1+ gnus-level-default-unsubscribed))))
13252 ((and (> level gnus-level-subscribed) subscribed)
13253 (setq level gnus-level-default-subscribed)))
13254 (setcar (cdr info) level))
13255 ;; This is a new group.
13256 (setq info (list group
13257 (if subscribed
13258 gnus-level-default-subscribed
13259 (if reads
13260 (1+ gnus-level-subscribed)
13261 gnus-level-default-unsubscribed))
13262 (nreverse reads))))
13263 (setq newsrc (cons info newsrc))))))
13264 (forward-line 1))
13266 (setq newsrc (nreverse newsrc))
13268 (if (not already-read)
13270 ;; We now have two newsrc lists - `newsrc', which is what we
13271 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13272 ;; what we've read from .newsrc.eld. We have to merge these
13273 ;; lists. We do this by "attaching" any (foreign) groups in the
13274 ;; gnus-newsrc-alist to the (native) group that precedes them.
13275 (let ((rc (cdr gnus-newsrc-alist))
13276 (prev gnus-newsrc-alist)
13277 entry mentry)
13278 (while rc
13279 (or (null (nth 4 (car rc))) ; It's a native group.
13280 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13281 (if (setq entry (assoc (car (car prev)) newsrc))
13282 (setcdr (setq mentry (memq entry newsrc))
13283 (cons (car rc) (cdr mentry)))
13284 (setq newsrc (cons (car rc) newsrc))))
13285 (setq prev rc
13286 rc (cdr rc)))))
13288 (setq gnus-newsrc-alist newsrc)
13289 ;; We make the newsrc hashtb.
13290 (gnus-make-hashtable-from-newsrc-alist)
13292 ;; Finally, if we read some options lines, we parse them.
13293 (or (string= gnus-newsrc-options "")
13294 (gnus-newsrc-parse-options gnus-newsrc-options))))
13296 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13297 ;; The return value will be a list on the form
13298 ;; ((regexp1 . ignore)
13299 ;; (regexp2 . subscribe)...)
13300 ;; When handling new newsgroups, groups that match a `ignore' regexp
13301 ;; will be ignored, and groups that match a `subscribe' regexp will be
13302 ;; subscribed. A line like
13303 ;; options -n !all rec.all
13304 ;; will lead to a list that looks like
13305 ;; (("^rec\\..+" . subscribe)
13306 ;; ("^.+" . ignore))
13307 ;; So all "rec.*" groups will be subscribed, while all the other
13308 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13309 ;; different from "options -n rec.all !all".
13310 (defun gnus-newsrc-parse-options (options)
13311 (let (out eol)
13312 (save-excursion
13313 (gnus-set-work-buffer)
13314 (insert (regexp-quote options))
13315 ;; First we treat all continuation lines.
13316 (goto-char (point-min))
13317 (while (re-search-forward "\n[ \t]+" nil t)
13318 (replace-match " " t t))
13319 ;; Then we transform all "all"s into ".+"s.
13320 (goto-char (point-min))
13321 (while (re-search-forward "\\ball\\b" nil t)
13322 (replace-match ".+" t t))
13323 (goto-char (point-min))
13324 ;; We remove all other options than the "-n" ones.
13325 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13326 (replace-match " ")
13327 (forward-char -1))
13328 (goto-char (point-min))
13330 ;; We are only interested in "options -n" lines - we
13331 ;; ignore the other option lines.
13332 (while (re-search-forward "[ \t]-n" nil t)
13333 (setq eol
13334 (or (save-excursion
13335 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13336 (- (point) 2)))
13337 (gnus-point-at-eol)))
13338 ;; Search for all "words"...
13339 (while (re-search-forward "[^ \t,\n]+" eol t)
13340 (if (= (char-after (match-beginning 0)) ?!)
13341 ;; If the word begins with a bang (!), this is a "not"
13342 ;; spec. We put this spec (minus the bang) and the
13343 ;; symbol `ignore' into the list.
13344 (setq out (cons (cons (concat
13345 "^" (buffer-substring
13346 (1+ (match-beginning 0))
13347 (match-end 0)))
13348 'ignore) out))
13349 ;; There was no bang, so this is a "yes" spec.
13350 (setq out (cons (cons (concat
13351 "^" (buffer-substring (match-beginning 0)
13352 (match-end 0)))
13353 'subscribe) out)))))
13355 (setq gnus-newsrc-options-n out))))
13358 (defun gnus-save-newsrc-file ()
13359 "Save .newsrc file."
13360 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13361 ;; from the variable gnus-newsrc-alist.
13362 (and (or gnus-newsrc-alist gnus-killed-list)
13363 gnus-current-startup-file
13364 (progn
13365 (run-hooks 'gnus-save-newsrc-hook)
13366 (save-excursion
13367 (if (and gnus-use-dribble-file
13368 (or (not gnus-dribble-buffer)
13369 (not (buffer-name gnus-dribble-buffer))
13370 (zerop (save-excursion
13371 (set-buffer gnus-dribble-buffer)
13372 (buffer-size)))))
13373 (gnus-message 4 "(No changes need to be saved)")
13374 (if gnus-save-newsrc-file
13375 (progn
13376 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13377 ;; Make backup file of master newsrc.
13378 (gnus-gnus-to-newsrc-format)
13379 (gnus-message 5 "Saving %s...done"
13380 gnus-current-startup-file)))
13381 ;; Quickly loadable .newsrc.
13382 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13383 (setq buffer-file-name (concat gnus-current-startup-file ".eld"))
13384 (gnus-add-current-to-buffer-list)
13385 (buffer-disable-undo (current-buffer))
13386 (erase-buffer)
13387 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13388 (gnus-gnus-to-quick-newsrc-format)
13389 (save-buffer)
13390 (kill-buffer (current-buffer))
13391 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13392 (gnus-dribble-delete-file))))))
13394 (defun gnus-gnus-to-quick-newsrc-format ()
13395 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13396 (insert ";; Gnus startup file.\n")
13397 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13398 (insert ";; to read .newsrc.\n")
13399 (insert "(setq gnus-newsrc-file-version "
13400 (prin1-to-string gnus-version) ")\n")
13401 (let ((variables gnus-variable-list)
13402 (inhibit-quit t)
13403 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13404 variable)
13405 ;; insert lisp expressions.
13406 (gnus-compress-newsrc-alist)
13407 (while variables
13408 (setq variable (car variables))
13409 (and (boundp variable)
13410 (symbol-value variable)
13411 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13412 (insert "(setq " (symbol-name variable) " '"
13413 (prin1-to-string (symbol-value variable))
13414 ")\n"))
13415 (setq variables (cdr variables)))
13416 (gnus-uncompress-newsrc-alist)))
13419 (defun gnus-gnus-to-newsrc-format ()
13420 ;; Generate and save the .newsrc file.
13421 (let ((newsrc (cdr gnus-newsrc-alist))
13422 info ranges range)
13423 (save-excursion
13424 (set-buffer (create-file-buffer gnus-current-startup-file))
13425 (setq buffer-file-name gnus-current-startup-file)
13426 (buffer-disable-undo (current-buffer))
13427 (erase-buffer)
13428 ;; Write options.
13429 (if gnus-newsrc-options (insert gnus-newsrc-options))
13430 ;; Write subscribed and unsubscribed.
13431 (while newsrc
13432 (setq info (car newsrc))
13433 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13434 (progn
13435 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13436 "!" ":"))
13437 (if (setq ranges (nth 2 info))
13438 (progn
13439 (insert " ")
13440 (if (not (listp (cdr ranges)))
13441 (if (= (car ranges) (cdr ranges))
13442 (insert (int-to-string (car ranges)))
13443 (insert (int-to-string (car ranges)) "-"
13444 (int-to-string (cdr ranges))))
13445 (while ranges
13446 (setq range (car ranges)
13447 ranges (cdr ranges))
13448 (if (or (atom range) (= (car range) (cdr range)))
13449 (insert (int-to-string
13450 (or (and (atom range) range)
13451 (car range))))
13452 (insert (int-to-string (car range)) "-"
13453 (int-to-string (cdr range))))
13454 (if ranges (insert ","))))))
13455 (insert "\n")))
13456 (setq newsrc (cdr newsrc)))
13457 ;; It has been reported that sometime the modtime on the .newsrc
13458 ;; file seems to be off. We really do want to overwrite it, so
13459 ;; we clear the modtime here before saving. It's a bit odd,
13460 ;; though...
13461 ;; sometimes the modtime clear isn't sufficient. most brute force:
13462 ;; delete the silly thing entirely first. but this fails to provide
13463 ;; such niceties as .newsrc~ creation.
13464 (if gnus-modtime-botch
13465 (delete-file gnus-startup-file)
13466 (clear-visited-file-modtime))
13467 (save-buffer)
13468 (kill-buffer (current-buffer)))))
13470 (defun gnus-read-all-descriptions-files ()
13471 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13472 (while methods
13473 (gnus-read-descriptions-file (car methods))
13474 (setq methods (cdr methods)))
13477 (defun gnus-read-descriptions-file (&optional method)
13478 (let ((method (or method gnus-select-method)))
13479 ;; We create the hashtable whether we manage to read the desc file
13480 ;; to avoid trying to re-read after a failed read.
13481 (or gnus-description-hashtb
13482 (setq gnus-description-hashtb
13483 (gnus-make-hashtable (length gnus-active-hashtb))))
13484 ;; Mark this method's desc file as read.
13485 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13486 gnus-description-hashtb)
13488 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13489 (cond
13490 ((not (gnus-check-server method))
13491 (gnus-message 1 "Couldn't open server")
13492 nil)
13493 ((not (gnus-request-list-newsgroups method))
13494 (gnus-message 1 "Couldn't read newsgroups descriptions")
13495 nil)
13497 (let (group)
13498 (save-excursion
13499 (save-restriction
13500 (set-buffer nntp-server-buffer)
13501 (goto-char (point-min))
13502 (if (or (search-forward "\n.\n" nil t)
13503 (goto-char (point-max)))
13504 (progn
13505 (beginning-of-line)
13506 (narrow-to-region (point-min) (point))))
13507 (goto-char (point-min))
13508 (while (not (eobp))
13509 ;; If we get an error, we set group to 0, which is not a
13510 ;; symbol...
13511 (setq group
13512 (condition-case ()
13513 (let ((obarray gnus-description-hashtb))
13514 ;; Group is set to a symbol interned in this
13515 ;; hash table.
13516 (read nntp-server-buffer))
13517 (error 0)))
13518 (skip-chars-forward " \t")
13519 ;; ... which leads to this line being effectively ignored.
13520 (and (symbolp group)
13521 (set group (buffer-substring
13522 (point) (progn (end-of-line) (point)))))
13523 (forward-line 1))))
13524 (gnus-message 5 "Reading descriptions file...done")
13525 t)))))
13527 (defun gnus-group-get-description (group)
13528 ;; Get the description of a group by sending XGTITLE to the server.
13529 (and (gnus-request-group-description group)
13530 (save-excursion
13531 (set-buffer nntp-server-buffer)
13532 (goto-char (point-min))
13533 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13534 (buffer-substring (match-beginning 1) (match-end 1))))))
13537 ;;; Server
13540 (defvar gnus-server-mode-hook nil
13541 "Hook run in `gnus-server-mode' buffers.")
13543 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13544 "Format of server lines.
13545 It works along the same lines as a normal formatting string,
13546 with some simple extensions.")
13548 (defvar gnus-server-mode-line-format "Gnus List of servers"
13549 "The format specification for the server mode line.")
13551 (defconst gnus-server-line-format-alist
13552 (list (list ?h 'how ?s)
13553 (list ?n 'name ?s)
13554 (list ?w 'where ?s)
13557 (defconst gnus-server-mode-line-format-alist
13558 (list (list ?S 'news-server ?s)
13559 (list ?M 'news-method ?s)
13560 (list ?u 'user-defined ?s)))
13562 (defvar gnus-server-line-format-spec nil)
13563 (defvar gnus-server-mode-line-format-spec nil)
13564 (defvar gnus-server-killed-servers nil)
13566 (defvar gnus-server-mode-map nil)
13567 (put 'gnus-server-mode 'mode-class 'special)
13569 (if gnus-server-mode-map
13571 (setq gnus-server-mode-map (make-sparse-keymap))
13572 (suppress-keymap gnus-server-mode-map)
13573 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13574 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13575 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13576 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13577 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13578 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13579 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13580 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13581 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13582 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13584 (defun gnus-server-mode ()
13585 "Major mode for listing and editing servers.
13587 All normal editing commands are switched off.
13588 \\<gnus-server-mode-map>
13590 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13592 The following commands are available:
13594 \\{gnus-server-mode-map}"
13595 (interactive)
13596 (if gnus-visual (gnus-server-make-menu-bar))
13597 (kill-all-local-variables)
13598 (setq mode-line-modified "-- ")
13599 (make-local-variable 'mode-line-format)
13600 (setq mode-line-format (copy-sequence mode-line-format))
13601 (and (equal (nth 3 mode-line-format) " ")
13602 (setcar (nthcdr 3 mode-line-format) ""))
13603 (setq major-mode 'gnus-server-mode)
13604 (setq mode-name "Server")
13605 ; (gnus-group-set-mode-line)
13606 (setq mode-line-process nil)
13607 (use-local-map gnus-server-mode-map)
13608 (buffer-disable-undo (current-buffer))
13609 (setq truncate-lines t)
13610 (setq buffer-read-only t)
13611 (run-hooks 'gnus-server-mode-hook))
13613 (defun gnus-server-insert-server-line (sformat name method)
13614 (let* ((sformat (or sformat gnus-server-line-format-spec))
13615 (how (car method))
13616 (where (nth 1 method))
13618 (beginning-of-line)
13619 (setq b (point))
13620 ;; Insert the text.
13621 (insert (eval sformat))
13622 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13624 (defun gnus-server-setup-buffer ()
13625 (if (get-buffer gnus-server-buffer)
13627 (save-excursion
13628 (set-buffer (get-buffer-create gnus-server-buffer))
13629 (gnus-server-mode)
13630 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13632 (defun gnus-server-prepare ()
13633 (setq gnus-server-mode-line-format-spec
13634 (gnus-parse-format gnus-server-mode-line-format
13635 gnus-server-mode-line-format-alist))
13636 (setq gnus-server-line-format-spec
13637 (gnus-parse-format gnus-server-line-format
13638 gnus-server-line-format-alist))
13639 (let ((alist gnus-server-alist)
13640 (buffer-read-only nil))
13641 (erase-buffer)
13642 (while alist
13643 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13644 (setq alist (cdr alist))))
13645 (goto-char (point-min))
13646 (gnus-server-position-cursor))
13648 (defun gnus-server-server-name ()
13649 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13650 (and server (symbol-name server))))
13652 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13654 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13656 (defun gnus-server-update-server (server)
13657 (save-excursion
13658 (set-buffer gnus-server-buffer)
13659 (let ((buffer-read-only nil)
13660 (info (cdr (assoc server gnus-server-alist))))
13661 (gnus-dribble-enter
13662 (concat "(gnus-server-set-info \"" server "\" '"
13663 (prin1-to-string info) ")"))
13664 ;; Buffer may be narrowed.
13665 (save-restriction
13666 (widen)
13667 (if (gnus-server-goto-server server)
13668 (delete-region (progn (beginning-of-line) (point))
13669 (progn (forward-line 1) (point))))
13670 (let ((entry (assoc server gnus-server-alist)))
13671 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13672 (gnus-server-position-cursor))))))
13674 (defun gnus-server-set-info (server info)
13675 ;; Enter a select method into the virtual server alist.
13676 (gnus-dribble-enter
13677 (concat "(gnus-server-set-info \"" server "\" '"
13678 (prin1-to-string info) ")"))
13679 (let* ((server (nth 1 info))
13680 (entry (assoc server gnus-server-alist)))
13681 (if entry (setcdr entry info)
13682 (setq gnus-server-alist
13683 (nconc gnus-server-alist (list (cons server info)))))))
13685 (defun gnus-server-to-method (server)
13686 ;; Map virtual server names to select methods.
13687 (or (and (equal server "native") gnus-select-method)
13688 (cdr (assoc server gnus-server-alist))))
13690 (defun gnus-server-extend-method (group method)
13691 ;; This function "extends" a virtual server. If the server is
13692 ;; "hello", and the select method is ("hello" (my-var "something"))
13693 ;; in the group "alt.alt", this will result in a new virtual server
13694 ;; called "helly+alt.alt".
13695 (let ((entry
13696 (gnus-copy-sequence
13697 (if (equal (car method) "native") gnus-select-method
13698 (cdr (assoc (car method) gnus-server-alist))))))
13699 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13700 (nconc entry (cdr method))))
13702 (defun gnus-server-get-method (group method)
13703 ;; Input either a server name, and extended server name, or a
13704 ;; select method, and return a select method.
13705 (cond ((stringp method)
13706 (gnus-server-to-method method))
13707 ((and (stringp (car method)) group)
13708 (gnus-server-extend-method group method))
13710 (gnus-server-add-address method))))
13712 (defun gnus-server-add-address (method)
13713 (let ((method-name (symbol-name (car method))))
13714 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13715 (not (assq (intern (concat method-name "-address")) method)))
13716 (append method (list (list (intern (concat method-name "-address"))
13717 (nth 1 method))))
13718 method)))
13720 (defun gnus-server-equal (s1 s2)
13721 (or (equal s1 s2)
13722 (and (= (length s1) (length s2))
13723 (progn
13724 (while (and s1 (member (car s1) s2))
13725 (setq s1 (cdr s1)))
13726 (null s1)))))
13728 ;;; Interactive server functions.
13730 (defun gnus-server-kill-server (server)
13731 "Kill the server on the current line."
13732 (interactive (list (gnus-server-server-name)))
13733 (or (gnus-server-goto-server server)
13734 (if server (error "No such server: %s" server)
13735 (error "No server on the current line")))
13736 (gnus-dribble-enter "")
13737 (let ((buffer-read-only nil))
13738 (delete-region (progn (beginning-of-line) (point))
13739 (progn (forward-line 1) (point))))
13740 (setq gnus-server-killed-servers
13741 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13742 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13743 gnus-server-alist))
13744 (gnus-server-position-cursor))
13746 (defun gnus-server-yank-server ()
13747 "Yank the previously killed server."
13748 (interactive)
13749 (or gnus-server-killed-servers
13750 (error "No killed servers to be yanked"))
13751 (let ((alist gnus-server-alist)
13752 (server (gnus-server-server-name))
13753 (killed (car gnus-server-killed-servers)))
13754 (if (not server)
13755 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13756 (if (string= server (car (car gnus-server-alist)))
13757 (setq gnus-server-alist (cons killed gnus-server-alist))
13758 (while (and (cdr alist)
13759 (not (string= server (car (car (cdr alist))))))
13760 (setq alist (cdr alist)))
13761 (setcdr alist (cons killed (cdr alist)))))
13762 (gnus-server-update-server (car killed))
13763 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13764 (gnus-server-position-cursor)))
13766 (defun gnus-server-exit ()
13767 "Return to the group buffer."
13768 (interactive)
13769 (kill-buffer (current-buffer))
13770 (switch-to-buffer gnus-group-buffer))
13772 (defun gnus-server-list-servers ()
13773 "List all available servers."
13774 (interactive)
13775 (let ((cur (gnus-server-server-name)))
13776 (gnus-server-prepare)
13777 (if cur (gnus-server-goto-server cur)
13778 (goto-char (point-max))
13779 (forward-line -1))
13780 (gnus-server-position-cursor)))
13782 (defun gnus-server-copy-server (from to)
13783 (interactive
13784 (list
13785 (or (gnus-server-server-name)
13786 (error "No server on the current line"))
13787 (read-string "Copy to: ")))
13788 (or from (error "No server on current line"))
13789 (or (and to (not (string= to ""))) (error "No name to copy to"))
13790 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13791 (or (assoc from gnus-server-alist)
13792 (error "%s: no such server" from))
13793 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13794 (setcar to-entry to)
13795 (setcar (nthcdr 2 to-entry) to)
13796 (setq gnus-server-killed-servers
13797 (cons to-entry gnus-server-killed-servers))
13798 (gnus-server-yank-server)))
13800 (defun gnus-server-add-server (how where)
13801 (interactive
13802 (list (intern (completing-read "Server method: "
13803 gnus-valid-select-methods nil t))
13804 (read-string "Server name: ")))
13805 (setq gnus-server-killed-servers
13806 (cons (list where how where) gnus-server-killed-servers))
13807 (gnus-server-yank-server))
13809 (defun gnus-server-goto-server (server)
13810 "Jump to a server line."
13811 (interactive
13812 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13813 (let ((to (text-property-any (point-min) (point-max)
13814 'gnus-server (intern server))))
13815 (and to
13816 (progn
13817 (goto-char to)
13818 (gnus-server-position-cursor)))))
13820 (defun gnus-server-edit-server (server)
13821 "Edit the server on the current line."
13822 (interactive (list (gnus-server-server-name)))
13823 (or server
13824 (error "No server on current line"))
13825 (let ((winconf (current-window-configuration)))
13826 (get-buffer-create gnus-server-edit-buffer)
13827 (gnus-configure-windows 'edit-server)
13828 (gnus-add-current-to-buffer-list)
13829 (emacs-lisp-mode)
13830 (make-local-variable 'gnus-prev-winconf)
13831 (setq gnus-prev-winconf winconf)
13832 (use-local-map (copy-keymap (current-local-map)))
13833 (let ((done-func '(lambda ()
13834 "Exit editing mode and update the information."
13835 (interactive)
13836 (gnus-server-edit-server-done 'group))))
13837 (setcar (cdr (nth 4 done-func)) server)
13838 (local-set-key "\C-c\C-c" done-func))
13839 (erase-buffer)
13840 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13841 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13843 (defun gnus-server-edit-server-done (server)
13844 (interactive)
13845 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13846 (goto-char (point-min))
13847 (let ((form (read (current-buffer)))
13848 (winconf gnus-prev-winconf))
13849 (gnus-server-set-info server form)
13850 (kill-buffer (current-buffer))
13851 (and winconf (set-window-configuration winconf))
13852 (set-buffer gnus-server-buffer)
13853 (gnus-server-update-server (gnus-server-server-name))
13854 (gnus-server-list-servers)
13855 (gnus-server-position-cursor)))
13857 (defun gnus-server-read-server (server)
13858 "Browse a server."
13859 (interactive (list (gnus-server-server-name)))
13860 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13862 (defun gnus-mouse-pick-server (e)
13863 (interactive "e")
13864 (mouse-set-point e)
13865 (gnus-server-read-server (gnus-server-server-name)))
13868 ;;; entry points into gnus-score.el
13871 ;;; Finding score files.
13873 (defvar gnus-global-score-files nil
13874 "*List of global score files and directories.
13875 Set this variable if you want to use people's score files. One entry
13876 for each score file or each score file directory. Gnus will decide
13877 by itself what score files are applicable to which group.
13879 Say you want to use the single score file
13880 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13881 score files in the \"/ftp.some-where:/pub/score\" directory.
13883 (setq gnus-global-score-files
13884 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13885 \"/ftp.some-where:/pub/score\"))")
13887 (defun gnus-score-score-files (group)
13888 "Return a list of all possible score files."
13889 ;; Search and set any global score files.
13890 (and gnus-global-score-files
13891 (or gnus-internal-global-score-files
13892 (gnus-score-search-global-directories gnus-global-score-files)))
13893 ;; Fix the kill-file dir variable.
13894 (setq gnus-kill-files-directory
13895 (file-name-as-directory
13896 (or gnus-kill-files-directory "~/News/")))
13897 ;; If we can't read it, there are no score files.
13898 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13899 (setq gnus-score-file-list nil)
13900 (if (gnus-use-long-file-name 'not-score)
13901 ;; We want long file names.
13902 (if (or (not gnus-score-file-list)
13903 (not (car gnus-score-file-list))
13904 (gnus-file-newer-than gnus-kill-files-directory
13905 (car gnus-score-file-list)))
13906 (setq gnus-score-file-list
13907 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13908 (nreverse
13909 (directory-files
13910 gnus-kill-files-directory t
13911 (gnus-score-file-regexp))))))
13912 ;; We do not use long file names, so we have to do some
13913 ;; directory traversing.
13914 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13915 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13916 dir files suffix)
13917 (while suffixes
13918 (setq dir (expand-file-name
13919 (concat gnus-kill-files-directory
13920 (gnus-replace-chars-in-string group ?. ?/))))
13921 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13922 (setq suffix (car suffixes)
13923 suffixes (cdr suffixes))
13924 (if (file-exists-p (concat dir "/" suffix))
13925 (setq files (cons (concat dir "/" suffix) files)))
13926 (while (>= (1+ (length dir)) mdir)
13927 (and (file-exists-p (concat dir "/all/" suffix))
13928 (setq files (cons (concat dir "/all/" suffix) files)))
13929 (string-match "/[^/]*$" dir)
13930 (setq dir (substring dir 0 (match-beginning 0)))))
13931 (setq gnus-score-file-list
13932 (cons nil (nreverse files)))))
13933 (cdr gnus-score-file-list)))
13935 (defun gnus-score-file-regexp ()
13936 (concat "\\(" gnus-score-file-suffix
13937 "\\|" gnus-adaptive-file-suffix "\\)$"))
13939 (defun gnus-score-find-bnews (group)
13940 "Return a list of score files for GROUP.
13941 The score files are those files in the ~/News directory which matches
13942 GROUP using BNews sys file syntax."
13943 (let* ((sfiles (append (gnus-score-score-files group)
13944 gnus-internal-global-score-files))
13945 (kill-dir (file-name-as-directory
13946 (expand-file-name gnus-kill-files-directory)))
13947 (klen (length kill-dir))
13948 ofiles not-match regexp)
13949 (save-excursion
13950 (set-buffer (get-buffer-create "*gnus score files*"))
13951 (buffer-disable-undo (current-buffer))
13952 ;; Go through all score file names and create regexp with them
13953 ;; as the source.
13954 (while sfiles
13955 (erase-buffer)
13956 (insert (car sfiles))
13957 (goto-char (point-min))
13958 ;; First remove the suffix itself.
13959 (re-search-forward (concat "." (gnus-score-file-regexp)))
13960 (replace-match "" t t)
13961 (goto-char (point-min))
13962 (if (looking-at (regexp-quote kill-dir))
13963 ;; If the file name was just "SCORE", `klen' is one character
13964 ;; too much.
13965 (delete-char (min (1- (point-max)) klen))
13966 (goto-char (point-max))
13967 (search-backward "/")
13968 (delete-region (1+ (point)) (point-min)))
13969 ;; If short file names were used, we have to translate slashes.
13970 (goto-char (point-min))
13971 (while (re-search-forward "[/:]" nil t)
13972 (replace-match "." t t))
13973 ;; Cludge to get rid of "nntp+" problems.
13974 (goto-char (point-min))
13975 (and (looking-at "nn[a-z]+\\+")
13976 (progn
13977 (search-forward "+")
13978 (forward-char -1)
13979 (insert "\\")))
13980 ;; Translate ".all" to "[./].*";
13981 (while (search-forward ".all" nil t)
13982 (replace-match "[./:].*" t t))
13983 (goto-char (point-min))
13984 ;; Translate "all" to ".*".
13985 (while (search-forward "all" nil t)
13986 (replace-match ".*" t t))
13987 (goto-char (point-min))
13988 ;; Deal with "not."s.
13989 (if (looking-at "not.")
13990 (progn
13991 (setq not-match t)
13992 (setq regexp (buffer-substring 5 (point-max))))
13993 (setq regexp (buffer-substring 1 (point-max)))
13994 (setq not-match nil))
13995 ;; Finally - if this resulting regexp matches the group name,
13996 ;; we add this score file to the list of score files
13997 ;; applicable to this group.
13998 (if (or (and not-match
13999 (not (string-match regexp group)))
14000 (and (not not-match)
14001 (string-match regexp group)))
14002 (setq ofiles (cons (car sfiles) ofiles)))
14003 (setq sfiles (cdr sfiles)))
14004 (kill-buffer (current-buffer))
14005 ;; Slight kludge here - the last score file returned should be
14006 ;; the local score file, whether it exists or not. This is so
14007 ;; that any score commands the user enters will go to the right
14008 ;; file, and not end up in some global score file.
14009 (let ((localscore
14010 (expand-file-name
14011 (if (gnus-use-long-file-name 'not-score)
14012 (concat gnus-kill-files-directory group "."
14013 gnus-score-file-suffix)
14014 (concat gnus-kill-files-directory
14015 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
14016 "/" gnus-score-file-suffix)))))
14017 ;; The localest score file might already be there, but it's
14018 ;; supposed to be the very last file, so we delete it from the
14019 ;; list if it's already there, and add it to the head of the
14020 ;; list.
14021 (setq ofiles (cons localscore (delete localscore ofiles))))
14022 (nreverse ofiles))))
14024 (defun gnus-score-find-single (group)
14025 "Return list containing the score file for GROUP."
14026 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
14027 (gnus-score-file-name group)))
14029 (defun gnus-score-find-hierarchical (group)
14030 "Return list of score files for GROUP.
14031 This includes the score file for the group and all its parents."
14032 (let ((all (copy-sequence '(nil)))
14033 (start 0))
14034 (while (string-match "\\." group (1+ start))
14035 (setq start (match-beginning 0))
14036 (setq all (cons (substring group 0 start) all)))
14037 (setq all (cons group all))
14038 (nconc
14039 (mapcar (lambda (newsgroup)
14040 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14041 (setq all (nreverse all)))
14042 (mapcar 'gnus-score-file-name all))))
14044 (defvar gnus-score-file-alist-cache nil)
14046 (defun gnus-score-find-alist (group)
14047 "Return list of score files for GROUP.
14048 The list is determined from the variable gnus-score-file-alist."
14049 (let ((alist gnus-score-file-multiple-match-alist)
14050 score-files)
14051 ;; if this group has been seen before, return the cached entry
14052 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14053 (cdr score-files) ;ensures caching groups with no matches
14054 ;; handle the multiple match alist
14055 (while alist
14056 (and (string-match (car (car alist)) group)
14057 (setq score-files
14058 (nconc score-files (copy-sequence (cdr (car alist))))))
14059 (setq alist (cdr alist)))
14060 (setq alist gnus-score-file-single-match-alist)
14061 ;; handle the single match alist
14062 (while alist
14063 (and (string-match (car (car alist)) group)
14064 ;; progn used just in case ("regexp") has no files
14065 ;; and score-files is still nil. -sj
14066 ;; this can be construed as a "stop searching here" feature :>
14067 ;; and used to simplify regexps in the single-alist
14068 (progn
14069 (setq score-files
14070 (nconc score-files (copy-sequence (cdr (car alist)))))
14071 (setq alist nil)))
14072 (setq alist (cdr alist)))
14073 ;; cache the score files
14074 (setq gnus-score-file-alist-cache
14075 (cons (cons group score-files) gnus-score-file-alist-cache))
14076 score-files)))
14079 (defun gnus-possibly-score-headers (&optional trace)
14080 (let ((func gnus-score-find-score-files-function)
14081 score-files)
14082 (and func (not (listp func))
14083 (setq func (list func)))
14084 ;; Go through all the functions for finding score files (or actual
14085 ;; scores) and add them to a list.
14086 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14087 (while func
14088 (and (symbolp (car func))
14089 (fboundp (car func))
14090 (setq score-files
14091 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14092 (setq func (cdr func)))
14093 (if score-files (gnus-score-headers score-files trace))))
14095 (defun gnus-score-file-name (newsgroup &optional suffix)
14096 "Return the name of a score file for NEWSGROUP."
14097 (let ((suffix (or suffix gnus-score-file-suffix)))
14098 (cond
14099 ((or (null newsgroup)
14100 (string-equal newsgroup ""))
14101 ;; The global score file is placed at top of the directory.
14102 (expand-file-name
14103 suffix (or gnus-kill-files-directory "~/News")))
14104 ((gnus-use-long-file-name 'not-score)
14105 ;; Append ".SCORE" to newsgroup name.
14106 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14107 "." suffix)
14108 (or gnus-kill-files-directory "~/News")))
14110 ;; Place "SCORE" under the hierarchical directory.
14111 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14112 "/" suffix)
14113 (or gnus-kill-files-directory "~/News"))))))
14115 (defun gnus-score-search-global-directories (files)
14116 "Scan all global score directories for score files."
14117 ;; Set the variable `gnus-internal-global-score-files' to all
14118 ;; available global score files.
14119 (interactive (list gnus-global-score-files))
14120 (let (out)
14121 (while files
14122 (if (string-match "/$" (car files))
14123 (setq out (nconc (directory-files
14124 (car files) t
14125 (concat (gnus-score-file-regexp) "$"))))
14126 (setq out (cons (car files) out)))
14127 (setq files (cdr files)))
14128 (setq gnus-internal-global-score-files out)))
14130 ;; Allow redefinition of Gnus functions.
14132 (gnus-ems-redefine)
14134 (provide 'gnus)
14136 ;;; gnus.el ends here