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>
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)
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.
26 ;; Although (ding) Gnus looks suspiciously like GNUS, it isn't quite
27 ;; the same beast. Most internal structures have been changed. If you
28 ;; have 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
40 ;; Site dependent variables. These variables should be defined in
43 (defvar gnus-default-nntp-server nil
44 "Specify a default NNTP server.
45 This variable should be defined in paths.el, and should never be set
47 If you want to change servers, you should use `gnus-select-method'.
48 See the documentation to that variable.")
50 (defconst gnus-backup-default-subscribed-newsgroups
51 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
52 "Default default new newsgroups the first time Gnus is run.
53 Should be set in paths.el, and shouldn't be touched by the user.")
55 (defvar gnus-local-domain nil
56 "Local domain name without a host name.
57 The DOMAINNAME environment variable is used instead if it is defined.
58 If the `system-name' function returns the full Internet name, there is
59 no need to set this variable.")
61 (defvar gnus-local-organization nil
62 "String with a description of what organization (if any) the user belongs to.
63 The ORGANIZATION environment variable is used instead if it is defined.
64 If this variable contains a function, this function will be called
65 with the current newsgroup name as the argument. The function should
68 In any case, if the string (either in the variable, in the environment
69 variable, or returned by the function) is a file name, the contents of
70 this file will be used as the organization.")
72 (defvar gnus-use-generic-from nil
73 "If nil, the full host name will be the system name prepended to the domain name.
74 If this is a string, the full host name will be this string.
75 If this is non-nil, non-string, the domain name will be used as the
78 (defvar gnus-use-generic-path nil
79 "If nil, use the NNTP server name in the Path header.
80 If stringp, use this; if non-nil, use no host name (user name only).")
83 ;; Customization variables
85 (defvar gnus-select-method
86 (list 'nntp (or (getenv "NNTPSERVER")
87 (if (and gnus-default-nntp-server
88 (not (string= gnus-default-nntp-server "")))
89 gnus-default-nntp-server)
91 "*Default method for selecting a newsgroup.
92 This variable should be a list, where the first element is how the
93 news is to be fetched, the second is the address.
95 For instance, if you want to get your news via NNTP from
96 \"flab.flab.edu\", you could say:
98 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
100 If you want to use your local spool, say:
102 (setq gnus-select-method (list 'nnspool (system-name)))
104 If you use this variable, you must set `gnus-nntp-server' to nil.
106 There is a lot more to know about select methods and virtual servers -
107 see the manual for details.")
109 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
110 (defvar gnus-post-method nil
111 "*Preferred method for posting USENET news.
112 If this variable is nil, Gnus will use the current method to decide
113 which method to use when posting. If it is non-nil, it will override
114 the current method. This method will not be used in mail groups and
115 the like, only in \"real\" newsgroups.
117 The value must be a valid method as discussed in the documentation of
118 `gnus-select-method'.")
120 (defvar gnus-refer-article-method nil
121 "*Preferred method for fetching an article by Message-ID.
122 If you are reading news from the local spool (with nnspool), fetching
123 articles by Message-ID is painfully slow. By setting this method to an
124 nntp method, you might get acceptable results.
126 The value of this variable must be a valid select method as discussed
127 in the documentation of `gnus-select-method'")
129 (defvar gnus-secondary-select-methods nil
130 "*A list of secondary methods that will be used for reading news.
131 This is a list where each element is a complete select methdod (see
132 `gnus-select-method').
134 If, for instance, you want to read your mail with the nnml backend,
135 you could set this variable:
137 (setq gnus-secondary-select-methods '((nnml \"\"))")
139 (defvar gnus-secondary-servers nil
140 "*List of NNTP servers that the user can choose between interactively.
141 To make Gnus query you for a server, you have to give `gnus' a
142 non-numeric prefix - `C-u M-x gnus', in short.")
144 (defvar gnus-nntp-server nil
145 "*The name of the host running the NNTP server.
146 This variable is semi-obsolete. Use the `gnus-select-method'
149 (defvar gnus-nntp-service "nntp"
150 "*NNTP service name (\"nntp\" or 119).
151 This is an obsolete variable, which is scarcely used. If you use an
152 nntp server for your newsgroup and want to change the port number
153 used to 899, you would say something along these lines:
155 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
157 (defvar gnus-startup-file "~/.newsrc"
158 "*Your `.newsrc' file.
159 `.newsrc-SERVER' will be used instead if that exists.")
161 (defvar gnus-init-file "~/.gnus"
162 "*Your Gnus elisp startup file.
163 If a file with the .el or .elc suffixes exist, it will be read
166 (defvar gnus-group-faq-directory
167 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
168 "*Directory where the group FAQs are stored.
169 This will most commonly be on a remote machine, and the file will be
170 fetched by ange-ftp.")
172 (defvar gnus-group-archive-directory
173 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
174 "*The address of the (ding) archives.")
176 (defvar gnus-default-subscribed-newsgroups nil
177 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
178 It should be a list of strings.
179 If it is `t', Gnus will not do anything special the first time it is
180 started; it'll just use the normal newsgroups subscription methods.")
182 (defvar gnus-use-cross-reference t
183 "*Non-nil means that cross referenced articles will be marked as read.
184 If nil, ignore cross references. If t, mark articles as read in
185 subscribed newsgroups. If neither t nor nil, mark as read in all
188 (defvar gnus-use-dribble-file t
189 "*Non-nil means that Gnus will use a dribble file to store user updates.
190 If Emacs should crash without saving the .newsrc files, complete
191 information can be restored from the dribble file.")
193 (defvar gnus-asynchronous nil
194 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
196 (defvar gnus-asynchronous-article-function nil
197 "*Function for picking articles to pre-fetch, possibly.")
199 (defvar gnus-score-file-single-match-alist nil
200 "*Alist mapping regexps to lists of score files.
201 Each element of this alist should be of the form
202 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
204 If the name of a group is matched by REGEXP, the corresponding scorefiles
205 will be used for that group.
206 The first match found is used, subsequent matching entries are ignored (to
207 use mutliple matches, see gnus-score-file-multiple-match-alist).
209 These score files are loaded in addition to any files returned by
210 gnus-score-find-score-files-function (which see).")
212 (defvar gnus-score-file-multiple-match-alist nil
213 "*Alist mapping regexps to lists of score files.
214 Each element of this alist should be of the form
215 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
217 If the name of a group is matched by REGEXP, the corresponding scorefiles
218 will be used for that group.
219 If multiple REGEXPs match a group, the score files corresponding to each
220 match will be used (for only one match to be used, see
221 gnus-score-file-single-match-alist).
223 These score files are loaded in addition to any files returned by
224 gnus-score-find-score-files-function (which see).")
227 (defvar gnus-score-file-suffix "SCORE"
228 "*Suffix of the score files.")
230 (defvar gnus-adaptive-file-suffix "ADAPT"
231 "*Suffix of the adaptive score files.")
233 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
234 "*Function used to find SCORE files.
235 The function will be called with the group name as the argument, and
236 should return a list of score files to apply to that group. The score
237 files do not actually have to exist.
239 Predefined values are:
241 gnus-score-find-single: Only apply the group's own SCORE file.
242 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
243 gnus-score-find-bnews: Apply SCORE files whose names matches.
245 See the documentation to these functions for more information.
247 This variable can also be a list of functions to be called. Each
248 function should either return a list of score files, or a list of
251 (defvar gnus-score-interactive-default-score 1000
252 "*Scoring commands will raise/lower the score with this number as the default.")
254 (defvar gnus-large-newsgroup 200
255 "*The number of articles which indicates a large newsgroup.
256 If the number of articles in a newsgroup is greater than this value,
257 confirmation is required for selecting the newsgroup.")
259 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
260 (defvar gnus-no-groups-message "No news is horrible news"
261 "*Message displayed by Gnus when no groups are available.")
263 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
264 "*Non-nil means that the default name of a file to save articles in is the group name.
265 If it's nil, the directory form of the group name is used instead.
267 If this variable is a list, and the list contains the element
268 `not-score', long file names will not be used for score files; if it
269 contains the element `not-save', long file names will not be used for
270 saving; and if it contains the element `not-kill', long file names
271 will not be used for kill files.")
273 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
274 "*Name of the directory articles will be saved in (default \"~/News\").
275 Initialized from the SAVEDIR environment variable.")
277 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
278 "*Name of the directory where kill files will be stored (default \"~/News\").
279 Initialized from the SAVEDIR environment variable.")
281 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
282 "*A function to save articles in your favorite format.
283 The function must be interactively callable (in other words, it must
284 be an Emacs command).
286 Gnus provides the following functions:
288 * gnus-summary-save-in-rmail (Rmail format)
289 * gnus-summary-save-in-mail (Unix mail format)
290 * gnus-summary-save-in-folder (MH folder)
291 * gnus-summary-save-in-file (article format).
292 * gnus-summary-save-in-vm (use VM's folder format).")
294 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
295 "*A function generating a file name to save articles in Rmail format.
296 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
298 (defvar gnus-mail-save-name (function gnus-plain-save-name)
299 "*A function generating a file name to save articles in Unix mail format.
300 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
302 (defvar gnus-folder-save-name (function gnus-folder-save-name)
303 "*A function generating a file name to save articles in MH folder.
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
306 (defvar gnus-file-save-name (function gnus-numeric-save-name)
307 "*A function generating a file name to save articles in article format.
308 The function is called with NEWSGROUP, HEADERS, and optional
311 (defvar gnus-split-methods nil
312 "*Variable used to suggest where articles are to be saved.
313 The syntax of this variable is the same as `nnmail-split-methods'.
315 For instance, if you would like to save articles related to Gnus in
316 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
317 you could set this variable to something like:
319 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
320 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
322 (defvar gnus-save-score nil
323 "*If non-nil, save group scoring info.")
325 (defvar gnus-use-adaptive-scoring nil
326 "*If non-nil, use some adaptive scoring scheme.")
328 (defvar gnus-use-cache nil
329 "*If non-nil, Gnus will cache (some) articles locally.")
331 (defvar gnus-use-scoring t
332 "*If non-nil, enable scoring.")
334 (defvar gnus-fetch-old-headers nil
335 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
336 If an unread article in the group refers to an older, already read (or
337 just marked as read) article, the old article will not normally be
338 displayed in the Summary buffer. If this variable is non-nil, Gnus
339 will attempt to grab the headers to the old articles, and thereby
340 build complete threads. If it has the value `some', only enough
341 headers to connect otherwise loose threads will be displayed.
343 The server has to support XOVER for any of this to work.")
345 (defvar gnus-visual t
346 "*If non-nil, will do various highlighting.
347 If nil, no mouse highlights (or any other highlights) will be
348 performed. This might speed up Gnus some when generating large group
349 and summary buffers.")
351 (defvar gnus-novice-user t
352 "*Non-nil means that you are a usenet novice.
353 If non-nil, verbose messages may be displayed and confirmations may be
356 (defvar gnus-expert-user nil
357 "*Non-nil means that you will never be asked for confirmation about anything.
358 And that means *anything*.")
360 (defvar gnus-verbose 7
361 "*Integer that says how verbose Gnus should be.
362 The higher the number, the more messages Gnus will flash to say what
363 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
364 display most important messages; and at ten, Gnus will keep on
365 jabbering all the time.")
367 (defvar gnus-keep-same-level nil
368 "*Non-nil means that the next newsgroup after the current will be on the same level.
369 When you type, for instance, `n' after reading the last article in the
370 current newsgroup, you will go to the next newsgroup. If this variable
371 is nil, the next newsgroup will be the next from the group
373 If this variable is non-nil, Gnus will either put you in the
374 next newsgroup with the same level, or, if no such newsgroup is
375 available, the next newsgroup with the lowest possible level higher
376 than the current level.
377 If this variable is `best', Gnus will make the next newsgroup the one
378 with the best level.")
380 (defvar gnus-summary-make-false-root 'adopt
381 "*nil means that Gnus won't gather loose threads.
382 If the root of a thread has expired or been read in a previous
383 session, the information necessary to build a complete thread has been
384 lost. Instead of having many small sub-threads from this original thread
385 scattered all over the summary buffer, Gnus can gather them.
387 If non-nil, Gnus will try to gather all loose sub-threads from an
388 original thread into one large thread.
390 If this variable is non-nil, it should be one of `none', `adopt',
393 If this variable is `none', Gnus will not make a false root, but just
394 present the sub-threads after another.
395 If this variable is `dummy', Gnus will create a dummy root that will
396 have all the sub-threads as children.
397 If this variable is `adopt', Gnus will make one of the \"children\"
398 the parent and mark all the step-children as such.
399 If this variable is `empty', the \"children\" are printed with empty
400 subject fields. (Or rather, they will be printed with a string
401 given by the `gnus-summary-same-subject' variable.)")
403 (defvar gnus-summary-gather-subject-limit nil
404 "*Maximum length of subject comparisons when gathering loose threads.
405 Use nil to compare full subjects. Setting this variable to a low
406 number will help gather threads that have been corrupted by
407 newsreaders chopping off subject lines, but it might also mean that
408 unrelated articles that have subject that happen to begin with the
409 same few characters will be incorrectly gathered.
411 If this variable is `fuzzy', Gnus will use a fuzzy algortihm when
412 comparing subjects.")
414 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
415 (defvar gnus-summary-same-subject ""
416 "*String indicating that the current article has the same subject as the previous.
417 This variable will only be used if the value of
418 `gnus-summary-make-false-root' is `empty'.")
420 (defvar gnus-summary-goto-unread nil
421 "*If non-nil, marking commands will go to the next unread article.")
423 (defvar gnus-group-goto-unread t
424 "*If non-nil, movement commands will go to the next unread and subscribed group.")
426 (defvar gnus-check-new-newsgroups t
427 "*Non-nil means that Gnus will add new newsgroups at startup.
428 If this variable is `ask-server', Gnus will ask the server for new
429 groups since the last time it checked. This means that the killed list
430 is no longer necessary, so you could set `gnus-save-killed-list' to
433 A variant is to have this variable be a list of select methods. Gnus
434 will then use the `ask-server' method on all these select methods to
435 query for new groups from all those servers.
438 (setq gnus-check-new-newsgroups
439 '((nntp \"some.server\") (nntp \"other.server\")))
441 If this variable is nil, then you have to tell Gnus explicitly to
442 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
444 (defvar gnus-check-bogus-newsgroups nil
445 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
446 If this variable is nil, then you have to tell Gnus explicitly to
447 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
449 (defvar gnus-read-active-file t
450 "*Non-nil means that Gnus will read the entire active file at startup.
451 If this variable is nil, Gnus will only know about the groups in your
454 If this variable is `some', Gnus will try to only read the relevant
455 parts of the active file from the server. Not all servers support
456 this, and it might be quite slow with other servers, but this should
457 generally be faster than both the t and nil value.
459 If you set this variable to nil or `some', you probably still want to
460 be told about new newsgroups that arrive. To do that, set
461 `gnus-check-new-newsgroups' to `ask-server'. This may not work
462 properly with all servers.")
464 (defvar gnus-level-subscribed 5
465 "*Groups with levels less than or equal to this variable are subscribed.")
467 (defvar gnus-level-unsubscribed 7
468 "*Groups with levels less than or equal to this variable are unsubscribed.
469 Groups with levels less than `gnus-level-subscribed', which should be
470 less than this variable, are subscribed.")
472 (defvar gnus-level-zombie 8
473 "*Groups with this level are zombie groups.")
475 (defvar gnus-level-killed 9
476 "*Groups with this level are killed.")
478 (defvar gnus-level-default-subscribed 3
479 "*New subscribed groups will be subscribed at this level.")
481 (defvar gnus-level-default-unsubscribed 6
482 "*New unsubscribed groups will be unsubscribed at this level.")
484 (defvar gnus-activate-foreign-newsgroups nil
485 "*If nil, Gnus will not check foreign newsgroups at startup.
486 If it is non-nil, it should be a number between one and nine. Foreign
487 newsgroups that have a level lower or equal to this number will be
488 activated on startup. For instance, if you want to active all
489 subscribed newsgroups, but not the rest, you'd set this variable to
490 `gnus-level-subscribed'.
492 If you subscribe to lots of newsgroups from different servers, startup
493 might take a while. By setting this variable to nil, you'll save time,
494 but you won't be told how many unread articles there are in the
497 (defvar gnus-save-newsrc-file t
498 "*Non-nil means that Gnus will save the `.newsrc' file.
499 Gnus always saves its own startup file, which is called
500 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
501 be readily understood by other newsreaders. If you don't plan on
502 using other newsreaders, set this variable to nil to save some time on
505 (defvar gnus-save-killed-list t
506 "*If non-nil, save the list of killed groups to the startup file.
507 This will save both time (when starting and quitting) and space (both
508 memory and disk), but it will also mean that Gnus has no record of
509 which groups are new and which are old, so the automatic new
510 newsgroups subscription methods become meaningless. You should always
511 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
514 (defvar gnus-interactive-catchup t
515 "*If non-nil, require your confirmation when catching up a group.")
517 (defvar gnus-interactive-post t
518 "*If non-nil, group name will be asked for when posting.")
520 (defvar gnus-interactive-exit t
521 "*If non-nil, require your confirmation when exiting Gnus.")
523 (defvar gnus-kill-killed nil
524 "*If non-nil, Gnus will apply kill files to already killed articles.
525 If it is nil, Gnus will never apply kill files to articles that have
526 already been through the scoring process, which might very well save lots
529 (defvar gnus-extract-address-components 'gnus-extract-address-components
530 "*Function for extracting address components from a From header.
531 Two pre-defined function exist: `gnus-extract-address-components',
532 which is the default, quite fast, and too simplistic solution, and
533 `mail-extract-address-components', which works much better, but is
536 (defvar gnus-summary-default-score 0
537 "*Default article score level.
538 If this variable is nil, scoring will be disabled.")
540 (defvar gnus-group-default-list-level gnus-level-subscribed
541 "*Default listing level.
542 Ignored if `gnus-group-use-permanent-levels' is nil.")
544 (defvar gnus-group-use-permanent-levels nil
545 "*If non-nil, once you set a level, Gnus will use this level.")
547 (defvar gnus-show-mime nil
548 "*If non-ni, do mime processing of articles.
549 The articles will simply be fed to the function given by
550 `gnus-show-mime-method'.")
552 (defvar gnus-show-mime-method (function metamail-buffer)
553 "*Function to process a MIME message.
554 The function is called from the article buffer.")
556 (defvar gnus-show-threads t
557 "*If non-nil, display threads in summary mode.")
559 (defvar gnus-thread-hide-subtree nil
560 "*If non-nil, hide all threads initially.
561 If threads are hidden, you have to run the command
562 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
563 to expose hidden threads.")
565 (defvar gnus-thread-hide-killed t
566 "*If non-nil, hide killed threads automatically.")
568 (defvar gnus-thread-ignore-subject nil
569 "*If non-nil, ignore subjects and do all threading based on the Reference header.
570 If nil, which is the default, articles that have different subjects
571 from their parents will start separate threads.")
573 (defvar gnus-thread-indent-level 4
574 "*Number that says how much each sub-thread should be indented.")
576 (defvar gnus-ignored-newsgroups ""
577 "*A regexp to match uninteresting newsgroups in the active file.
578 Any lines in the active file matching this regular expression are
579 removed from the newsgroup list before anything else is done to it,
580 thus making them effectively non-existant.")
582 (defvar gnus-ignored-headers
583 "^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:"
584 "*All headers that match this regexp will be hidden.
585 Also see `gnus-visible-headers'.")
587 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
588 "*All headers that do not match this regexp will be hidden.
589 Also see `gnus-ignored-headers'.")
591 (defvar gnus-sorted-header-list
592 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
593 "^Cc:" "^Date:" "^Organization:")
594 "*This variable is a list of regular expressions.
595 If it is non-nil, headers that match the regular expressions will
596 be placed first in the article buffer in the sequence specified by
599 (defvar gnus-show-all-headers nil
600 "*If non-nil, don't hide any headers.")
602 (defvar gnus-save-all-headers t
603 "*If non-nil, don't remove any headers before saving.")
605 (defvar gnus-inhibit-startup-message nil
606 "*If non-nil, the startup message will not be displayed.")
608 (defvar gnus-signature-separator "^-- *$"
609 "Regexp matching signature separator.")
611 (defvar gnus-auto-extend-newsgroup t
612 "*If non-nil, extend newsgroup forward and backward when requested.")
614 (defvar gnus-auto-select-first t
615 "*If non-nil, select the first unread article when entering a group.
616 If you want to prevent automatic selection of the first unread article
617 in some newsgroups, set the variable to nil in
618 `gnus-select-group-hook'.")
620 (defvar gnus-auto-select-next t
621 "*If non-nil, offer to go to the next group from the end of the previous.
622 If the value is t and the next newsgroup is empty, Gnus will exit
623 summary mode and go back to group mode. If the value is neither nil
624 nor t, Gnus will select the following unread newsgroup. In
625 particular, if the value is the symbol `quietly', the next unread
626 newsgroup will be selected without any confirmations.")
628 (defvar gnus-auto-select-same nil
629 "*If non-nil, select the next article with the same subject.")
631 (defvar gnus-summary-check-current nil
632 "*If non-nil, consider the current article when moving.
633 The \"unread\" movement commands will stay on the same line if the
634 current article is unread.")
636 (defvar gnus-auto-center-summary t
637 "*If non-nil, always center the current summary buffer.")
639 (defvar gnus-break-pages t
640 "*If non-nil, do page breaking on articles.
641 The page delimiter is specified by the `gnus-page-delimiter'
644 (defvar gnus-page-delimiter "^\^L"
645 "*Regexp describing what to use as article page delimiters.
646 The default value is \"^\^L\", which is a form linefeed at the
647 beginning of a line.")
649 (defvar gnus-use-full-window t
650 "*If non-nil, use the entire Emacs screen.")
652 (defvar gnus-window-configuration nil
653 "Obsolete variable. See `gnus-buffer-configuration'.")
655 (defvar gnus-buffer-configuration
656 '((group ([group 1.0 point]
657 (if gnus-carpal [group-carpal 4])))
658 (summary ([summary 1.0 point]
659 (if gnus-carpal [summary-carpal 4])))
660 (article ([summary 0.25 point]
661 (if gnus-carpal [summary-carpal 4])
663 (server ([server 1.0 point]
664 (if gnus-carpal [server-carpal 2])))
665 (browse ([browse 1.0 point]
666 (if gnus-carpal [browse-carpal 2])))
667 (group-mail ([mail 1.0 point]))
668 (summary-mail ([mail 1.0 point]))
669 (summary-reply ([article 0.5]
671 (info ([nil 1.0 point]))
672 (summary-faq ([summary 0.25]
673 [article 1.0 point]))
674 (edit-group ([group 0.5]
675 [edit-group 1.0 point]))
676 (edit-server ([server 0.5]
677 [edit-server 1.0 point]))
678 (post ([post 1.0 point]))
679 (reply ([article 0.5]
681 (mail-forward ([mail 1.0 point]))
682 (post-forward ([post 1.0 point]))
683 (reply-yank ([mail 1.0 point]))
684 (followup ([article 0.5]
686 (followup-yank ([post 1.0 point])))
687 "Window configuration for all possible Gnus buffers.
688 This variable is a list of lists. Each of these lists has a NAME and
689 a RULE. The NAMEs are commonsense names like `group', which names a
690 rule used when displaying the group buffer; `summary', which names a
691 rule for what happens when you enter a group and do not display an
692 article buffer; and so on. See the value of this variable for a
693 complete list of NAMEs.
695 Each RULE is a list of vectors. The first element in this vector is
696 the name of the buffer to be displayed; the second element is the
697 percentage of the screen this buffer is to occupy (a number in the
698 0.0-0.99 range); the optional third element is `point', which should
699 be present to denote which buffer point is to go to after making this
700 buffer configuration.")
702 (defvar gnus-window-to-buffer
703 '((group . gnus-group-buffer)
704 (summary . gnus-summary-buffer)
705 (article . gnus-article-buffer)
706 (server . gnus-server-buffer)
707 (browse . "*Gnus Browse Server*")
708 (edit-group . gnus-group-edit-buffer)
709 (edit-server . gnus-server-edit-buffer)
710 (group-carpal . gnus-carpal-group-buffer)
711 (summary-carpal . gnus-carpal-summary-buffer)
712 (server-carpal . gnus-carpal-server-buffer)
713 (browse-carpal . gnus-carpal-browse-buffer)
715 (post . gnus-post-news-buffer))
716 "Mapping from short symbols to buffer names or buffer variables.")
718 (defvar gnus-carpal nil
719 "*If non-nil, display clickable icons.")
721 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
722 "*Function called with a group name when new group is detected.
723 A few pre-made functions are supplied: `gnus-subscribe-randomly'
724 inserts new groups at the beginning of the list of groups;
725 `gnus-subscribe-alphabetically' inserts new groups in strict
726 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
727 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
730 ;; Suggested by a bug report by Hallvard B Furuseth.
731 ;; <h.b.furuseth@usit.uio.no>.
732 (defvar gnus-subscribe-options-newsgroup-method
733 (function gnus-subscribe-alphabetically)
734 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
735 If, for instance, you want to subscribe to all newsgroups in the
736 \"no\" and \"alt\" hierarchies, you'd put the following in your
739 options -n no.all alt.all
741 Gnus will the subscribe all new newsgroups in these hierarchies with
742 the subscription method in this variable.")
744 (defvar gnus-subscribe-hierarchical-interactive nil
745 "*If non-nil, Gnus will offer to subscribe hierarchically.
746 When a new hierarchy appears, Gnus will ask the user:
748 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
750 If the user pressed `d', Gnus will descend the hierarchy, `y' will
751 subscribe to all newsgroups in the hierarchy and `s' will skip this
752 hierarchy in its entirety.")
754 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
755 "*Function used for sorting the group buffer.
756 This function will be called with group info entries as the arguments
757 for the groups to be sorted. Pre-made functions include
758 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
759 `gnus-sort-by-level'")
761 ;; Mark variables suggested by Thomas Michanek
762 ;; <Thomas.Michanek@telelogic.se>.
763 (defvar gnus-unread-mark ?
764 "*Mark used for unread articles.")
765 (defvar gnus-ticked-mark ?!
766 "*Mark used for ticked articles.")
767 (defvar gnus-dormant-mark ??
768 "*Mark used for dormant articles.")
769 (defvar gnus-del-mark ?D
770 "*Mark used for del'd articles.")
771 (defvar gnus-read-mark ?d
772 "*Mark used for read articles.")
773 (defvar gnus-expirable-mark ?E
774 "*Mark used for expirable articles.")
775 (defvar gnus-killed-mark ?K
776 "*Mark used for killed articles.")
777 (defvar gnus-kill-file-mark ?X
778 "*Mark used for articles killed by kill files.")
779 (defvar gnus-low-score-mark ?Y
780 "*Mark used for articles with a low score.")
781 (defvar gnus-catchup-mark ?C
782 "*Mark used for articles that are caught up.")
783 (defvar gnus-replied-mark ?R
784 "*Mark used for articles that have been replied to.")
785 (defvar gnus-process-mark ?#
787 (defvar gnus-ancient-mark ?A
788 "*Mark used for ancient articles.")
789 (defvar gnus-canceled-mark ?G
790 "*Mark used for cancelled articles.")
791 (defvar gnus-score-over-mark ?+
792 "*Score mark used for articles with high scores.")
793 (defvar gnus-score-below-mark ?-
794 "*Score mark used for articles with low scores.")
795 (defvar gnus-empty-thread-mark ?
796 "*There is no thread under the article.")
797 (defvar gnus-not-empty-thread-mark ?=
798 "*There is a thread under the article.")
799 (defvar gnus-dummy-mark ?Z
800 "*This is a dummy article.")
802 (defvar gnus-view-pseudo-asynchronously nil
803 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
805 (defvar gnus-view-pseudos nil
806 "*If `automatic', pseudo-articles will be viewed automatically.
807 If `not-confirm', pseudos will be viewed automatically, and the user
808 will not be asked to confirm the command.")
810 (defvar gnus-view-pseudos-separately t
811 "*If non-nil, one pseudo-article will be created for each file to be viewed.
812 If nil, all files that use the same viewing command will be given as a
813 list of parameters to that command.")
815 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
816 "*Format of group lines.
817 It works along the same lines as a normal formatting string,
818 with some simple extensions.
820 %M Only marked articles (character, \"*\" or \" \")
821 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
822 %L Level of subscribedness (integer)
823 %N Number of unread articles (integer)
824 %I Number of dormant articles (integer)
825 %i Number of ticked and dormant (integer)
826 %T Number of ticked articles (integer)
827 %R Number of read articles (integer)
828 %t Total number of articles (integer)
829 %y Number of unread, unticked articles (integer)
830 %G Group name (string)
831 %g Qualified group name (string)
832 %D Group description (string)
833 %s Select method (string)
834 %o Moderated group (char, \"m\")
835 %O Moderated group (string, \"(m)\" or \"\")
836 %n Select from where (string)
837 %z A string that look like `<%s:%n>' if a foreign select method is used
838 %u User defined specifier. The next character in the format string should
839 be a letter. Gnus will call the function gnus-user-format-function-X,
840 where X is the letter following %u. The function will be passed the
841 current header as argument. The function should return a string, which
842 will be inserted into the buffer just like information from any other
845 Text between %( and %) will be highlighted with `gnus-mouse-face' when
846 the mouse point move inside the area. There can only be one such area.
848 Note that this format specification is not always respected. For
849 reasons of efficiency, when listing killed groups, this specification
850 is ignored altogether. If the spec is changed considerably, your
851 output may end up looking strange when listing both alive and killed
854 If you use %o or %O, reading the active file will be slower and quite
855 a bit of extra memory will be used. %D will also worsen performance.
856 Also note that if you change the format specification to include any
857 of these specs, you must probably re-start Gnus to see them go into
860 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
861 "*The format specification of the lines in the summary buffer.
863 It works along the same lines as a normal formatting string,
864 with some simple extensions.
866 %N Article number, left padded with spaces (string)
868 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
869 %n Name of the poster (string)
870 %A Address of the poster (string)
871 %F Contents of the From: header (string)
872 %x Contents of the Xref: header (string)
873 %D Date of the article (string)
874 %d Date of the article (string) in DD-MMM format
875 %M Message-id of the article (string)
876 %r References of the article (string)
877 %c Number of characters in the article (integer)
878 %L Number of lines in the article (integer)
879 %I Indentation based on thread level (a string of spaces)
880 %T A string with two possible values: 80 spaces if the article
881 is on thread level two or larger and 0 spaces on level one
882 %R \"R\" if this article has been replied to, \" \" otherwise (character)
883 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
884 %[ Opening bracket (character, \"[\" or \"<\")
885 %] Closing bracket (character, \"]\" or \">\")
886 %> Spaces of length thread-level (string)
887 %< Spaces of length (- 20 thread-level) (string)
888 %i Article score (number)
889 %z Article zcore (character)
890 %t Number of articles under the current thread (number).
891 %e Whether the thread is empty or not (character).
892 %u User defined specifier. The next character in the format string should
893 be a letter. Gnus will call the function gnus-user-format-function-X,
894 where X is the letter following %u. The function will be passed the
895 current header as argument. The function should return a string, which
896 will be inserted into the summary just like information from any other
899 Text between %( and %) will be highlighted with `gnus-mouse-face'
900 when the mouse point is placed inside the area. There can only be one
903 The %U (status), %R (replied) and %z (zcore) specs have to be handled
904 with care. For reasons of efficiency, Gnus will compute what column
905 these characters will end up in, and \"hard-code\" that. This means that
906 it is illegal to have these specs after a variable-length spec. Well,
907 you might not be arrested, but your summary buffer will look strange,
910 The smart choice is to have these specs as for to the left as
913 This restriction may disappear in later versions of Gnus.")
915 (defvar gnus-summary-dummy-line-format "* : : %S\n"
916 "*The format specification for the dummy roots in the summary buffer.
917 It works along the same lines as a normal formatting string,
918 with some simple extensions.
922 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
923 "*The format specification for the summary mode line.")
925 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
926 "*The format specification for the article mode line.")
928 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
929 "*The format specification for the group mode line.")
931 (defvar gnus-valid-select-methods
932 '(("nntp" post address prompt-address)
934 ("nnvirtual" none virtual prompt-address)
935 ("nnmbox" mail respool)
936 ("nnml" mail respool)
937 ("nnmh" mail respool)
938 ("nndir" none prompt-address address)
939 ("nneething" none prompt-address)
941 ("nndoc" none prompt-address)
942 ("nnbabyl" mail respool)
943 ("nnkiboze" none virtual)
944 ("nnfolder" mail respool))
945 "An alist of valid select methods.
946 The first element of each list lists should be a string with the name
947 of the select method. The other elements may be be the category of
948 this method (ie. `post', `mail', `none' or whatever) or other
949 properties that this method has (like being respoolable).
950 If you implement a new select method, all you should have to change is
951 this variable. I think.")
953 (defvar gnus-updated-mode-lines '(group article summary)
954 "*List of buffers that should update their mode lines.
955 The list may contain the symbols `group', `article' and `summary'. If
956 the corresponding symbol is present, Gnus will keep that mode line
957 updated with information that may be pertinent.
958 If this variable is nil, screen refresh may be quicker.")
960 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
961 (defvar gnus-mode-non-string-length 21
962 "*Max length of mode-line non-string contents.
963 If this is nil, Gnus will take space as is needed, leaving the rest
964 of the modeline intact.")
966 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
967 (defvar gnus-mouse-face 'highlight
968 "*Face used for mouse highlighting in Gnus.
969 No mouse highlights will be done if `gnus-visual' is nil.")
971 (defvar gnus-summary-mark-below nil
972 "*Mark all articles with a score below this variable as read.
973 This variable is local to each summary buffer and usually set by the
976 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
977 "*List of functions used for sorting threads in the summary buffer.
978 By default, threads are sorted by article number.
980 Each function takes two threads and return non-nil if the first thread
981 should be sorted before the other. If you use more than one function,
982 the primary sort function should be the last.
984 Ready-mady functions include `gnus-thread-sort-by-number',
985 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
986 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
987 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
989 (defvar gnus-thread-score-function '+
990 "*Function used for calculating the total score of a thread.
992 The function is called with the scores of the article and each
993 subthread and should then return the score of the thread.
995 Some functions you can use are `+', `max', or `min'.")
997 (defvar gnus-options-subscribe nil
998 "*All new groups matching this regexp will be subscribed unconditionally.
999 Note that this variable deals only with new newsgroups. This variable
1000 does not affect old newsgroups.")
1002 (defvar gnus-options-not-subscribe nil
1003 "*All new groups matching this regexp will be ignored.
1004 Note that this variable deals only with new newsgroups. This variable
1005 does not affect old (already subscribed) newsgroups.")
1007 (defvar gnus-auto-expirable-newsgroups nil
1008 "*Groups in which to automatically mark read articles as expirable.
1009 If non-nil, this should be a regexp that should match all groups in
1010 which to perform auto-expiry. This only makes sense for mail groups.")
1012 (defvar gnus-hidden-properties '(invisible t intangible t)
1013 "Property list to use for hiding text.")
1017 (defvar gnus-group-mode-hook nil
1018 "*A hook for Gnus group mode.")
1020 (defvar gnus-summary-mode-hook nil
1021 "*A hook for Gnus summary mode.")
1023 (defvar gnus-article-mode-hook nil
1024 "*A hook for Gnus article mode.")
1026 (defvar gnus-open-server-hook nil
1027 "*A hook called just before opening connection to the news server.")
1029 (defvar gnus-startup-hook nil
1030 "*A hook called at startup.
1031 This hook is called after Gnus is connected to the NNTP server.")
1033 (defvar gnus-get-new-news-hook nil
1034 "*A hook run just before Gnus checks for new news.")
1036 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1037 "*A function that is called to generate the group buffer.
1038 The function is called with three arguments: The first is a number;
1039 all group with a level less or equal to that number should be listed,
1040 if the second is non-nil, empty groups should also be displayed. If
1041 the third is non-nil, it is a number. No groups with a level lower
1042 than this number should be displayed.
1044 The only current function implemented is `gnus-group-prepare-flat'.")
1046 (defvar gnus-group-prepare-hook nil
1047 "*A hook called after the group buffer has been generated.
1048 If you want to modify the group buffer, you can use this hook.")
1050 (defvar gnus-summary-prepare-hook nil
1051 "*A hook called after the summary buffer has been generated.
1052 If you want to modify the summary buffer, you can use this hook.")
1054 (defvar gnus-article-prepare-hook nil
1055 "*A hook called after an article has been prepared in the article buffer.
1056 If you want to run a special decoding program like nkf, use this hook.")
1058 (defvar gnus-article-display-hook nil
1059 "*A hook called after the article is displayed in the article buffer.
1060 The hook is designed to change the contents of the article
1061 buffer. Typical functions that this hook may contain are
1062 `gnus-article-hide-headers' (hide selected headers),
1063 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1064 `gnus-article-hide-signature' (hide signature) and
1065 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1066 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1067 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1069 (defvar gnus-article-x-face-command
1070 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1071 "String or function to be executed to display an X-Face header.
1072 If it is a string, the command will be executed in a sub-shell
1073 asynchronously. The compressed face will be piped to this command.")
1075 (defvar gnus-article-x-face-too-ugly nil
1076 "Regexp matching posters whose face shouldn't be shown automatically.")
1078 (defvar gnus-select-group-hook nil
1079 "*A hook called when a newsgroup is selected.
1081 If you'd like to simplify subjects like the
1082 `gnus-summary-next-same-subject' command does, you can use the
1085 (setq gnus-select-group-hook
1088 (mapcar (lambda (header)
1091 (gnus-simplify-subject
1092 (header-subject header) 're-only)))
1093 gnus-newsgroup-headers))))")
1095 (defvar gnus-select-article-hook
1096 '(gnus-summary-show-thread)
1097 "*A hook called when an article is selected.
1098 The default hook shows conversation thread subtrees of the selected
1099 article automatically using `gnus-summary-show-thread'.")
1101 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1102 "*A hook called to apply kill files to a group.
1103 This hook is intended to apply a kill file to the selected newsgroup.
1104 The function `gnus-apply-kill-file' is called by default.
1106 Since a general kill file is too heavy to use only for a few
1107 newsgroups, I recommend you to use a lighter hook function. For
1108 example, if you'd like to apply a kill file to articles which contains
1109 a string `rmgroup' in subject in newsgroup `control', you can use the
1112 \(setq gnus-apply-kill-hook
1115 (cond ((string-match \"control\" gnus-newsgroup-name)
1116 (gnus-kill \"Subject\" \"rmgroup\")
1117 (gnus-expunge \"X\"))))))")
1119 (defvar gnus-visual-mark-article-hook
1120 (list 'gnus-highlight-selected-summary)
1121 "*Hook run after selecting an article in the summary buffer.
1122 It is meant to be used for highlighting the article in some way. It
1123 is not run if `gnus-visual' is nil.")
1125 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1126 "*A hook called after preparing body, but before preparing header headers.
1127 The default hook (`gnus-inews-insert-signature') inserts a signature
1128 file specified by the variable `gnus-signature-file'.")
1130 (defvar gnus-exit-group-hook nil
1131 "*A hook called when exiting (not quitting) summary mode.")
1133 (defvar gnus-suspend-gnus-hook nil
1134 "*A hook called when suspending (not exiting) Gnus.")
1136 (defvar gnus-exit-gnus-hook nil
1137 "*A hook called when exiting Gnus.")
1139 (defvar gnus-save-newsrc-hook nil
1140 "*A hook called when saving the newsrc file.")
1142 (defvar gnus-summary-update-hook
1143 (list 'gnus-summary-highlight-line)
1144 "*A hook called when a summary line is changed.
1145 The hook will not be called if `gnus-visual' is nil.
1147 The default function `gnus-summary-highlight-line' will
1148 highlight the line according to the `gnus-summary-highlight'
1151 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1152 "*A hook called when an article is selected for the first time.
1153 The hook is intended to mark an article as read (or unread)
1154 automatically when it is selected.")
1157 ;; Internal variables
1159 ;; Avoid highlighting in kill files.
1160 (defvar gnus-summary-inhibit-highlight nil)
1161 (defvar gnus-newsgroup-selected-overlay nil)
1163 (defvar gnus-article-mode-map nil)
1164 (defvar caesar-translate-table nil)
1165 (defvar gnus-dribble-buffer nil)
1166 (defvar gnus-headers-retrieved-by nil)
1167 (defvar gnus-article-reply nil)
1168 (defvar gnus-override-method nil)
1169 (defvar gnus-article-check-size nil)
1171 (defvar gnus-current-score-file nil)
1172 (defvar gnus-internal-global-score-files nil)
1173 (defvar gnus-score-file-list nil)
1176 (defvar gnus-current-move-group nil)
1178 (defvar gnus-newsgroup-dependencies nil)
1179 (defvar gnus-newsgroup-threads nil)
1180 (defvar gnus-newsgroup-async nil)
1181 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1183 (defvar gnus-newsgroup-adaptive nil)
1185 (defvar gnus-summary-display-table nil)
1187 (defconst gnus-group-line-format-alist
1188 (list (list ?M 'marked ?c)
1189 (list ?S 'subscribed ?c)
1191 (list ?N 'number ?s)
1192 (list ?I 'number-of-dormant ?d)
1193 (list ?T 'number-of-ticked ?d)
1194 (list ?R 'number-of-read ?s)
1195 (list ?t 'number-total ?d)
1196 (list ?y 'number-of-unread-unticked ?s)
1197 (list ?i 'number-of-ticked-and-dormant ?d)
1199 (list ?G 'qualified-group ?s)
1200 (list ?D 'newsgroup-description ?s)
1201 (list ?o 'moderated ?c)
1202 (list ?O 'moderated-string ?s)
1203 (list ?s 'news-server ?s)
1204 (list ?n 'news-method ?s)
1205 (list ?z 'news-method-string ?s)
1206 (list ?u 'user-defined ?s)))
1208 (defconst gnus-summary-line-format-alist
1209 (list (list ?N 'number ?d)
1210 (list ?S 'subject ?s)
1211 (list ?s 'subject-or-nil ?s)
1213 (list ?A 'address ?s)
1215 (list ?x (macroexpand '(header-xref header)) ?s)
1216 (list ?D (macroexpand '(header-date header)) ?s)
1217 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1218 (list ?M (macroexpand '(header-id header)) ?s)
1219 (list ?r (macroexpand '(header-references header)) ?s)
1220 (list ?c '(or (header-chars header) 0) ?d)
1222 (list ?I 'indentation ?s)
1223 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1224 (list ?R 'replied ?c)
1225 (list ?\[ 'opening-bracket ?c)
1226 (list ?\] 'closing-bracket ?c)
1227 (list ?\> '(make-string level ? ) ?s)
1228 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1230 (list ?z 'score-char ?c)
1231 (list ?U 'unread ?c)
1232 (list ?t '(gnus-summary-number-of-articles-in-thread
1233 (or (prog1 gnus-tmp-adopt-thread
1234 (setq gnus-tmp-adopt-thread nil))
1235 (if (boundp 'thread) (symbol-value 'thread)
1238 (list ?e '(gnus-summary-number-of-articles-in-thread
1239 (or gnus-tmp-adopt-thread
1240 (if (boundp 'thread) (symbol-value 'thread)
1243 (list ?u 'user-defined ?s))
1244 "An alist of format specifications that can appear in summary lines,
1245 and what variables they correspond with, along with the type of the
1246 variable (string, integer, character, etc).")
1248 (defconst gnus-summary-dummy-line-format-alist
1249 (list (list ?S 'subject ?s)
1250 (list ?N 'number ?d)
1251 (list ?u 'user-defined ?s)))
1253 (defconst gnus-summary-mode-line-format-alist
1254 (list (list ?G 'group-name ?s)
1255 (list ?g '(gnus-short-group-name group-name) ?s)
1256 (list ?A 'article-number ?d)
1257 (list ?Z 'unread-and-unselected ?s)
1258 (list ?V 'gnus-version ?s)
1259 (list ?U 'unread ?d)
1260 (list ?S 'subject ?s)
1261 (list ?e 'unselected ?d)
1262 (list ?u 'user-defined ?s)
1263 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1265 (defconst gnus-group-mode-line-format-alist
1266 (list (list ?S 'news-server ?s)
1267 (list ?M 'news-method ?s)
1268 (list ?u 'user-defined ?s)))
1270 (defvar gnus-have-read-active-file nil)
1272 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls & Boys)"
1273 "The mail address of the Gnus maintainer.")
1275 (defconst gnus-version "(ding) Gnus v0.79"
1276 "Version number for this version of Gnus.")
1278 (defvar gnus-info-nodes
1279 '((gnus-group-mode "(gnus)The Group Buffer")
1280 (gnus-summary-mode "(gnus)The Summary Buffer")
1281 (gnus-article-mode "(gnus)The Article Buffer"))
1282 "Assoc list of major modes and related Info nodes.")
1284 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1285 "The location of the (ding) Gnus documentation group.")
1287 (defvar gnus-group-buffer "*Group*")
1288 (defvar gnus-summary-buffer "*Summary*")
1289 (defvar gnus-article-buffer "*Article*")
1290 (defvar gnus-server-buffer "*Server*")
1292 (defvar gnus-work-buffer " *gnus work*")
1294 (defvar gnus-buffer-list nil
1295 "Gnus buffers that should be killed on exit.")
1297 (defvar gnus-server-alist nil
1298 "List of available servers.")
1300 (defvar gnus-variable-list
1301 '(gnus-newsrc-options gnus-newsrc-options-n
1302 gnus-newsrc-last-checked-date
1303 gnus-newsrc-alist gnus-server-alist
1304 gnus-killed-list gnus-zombie-list)
1305 "Gnus variables saved in the quick startup file.")
1307 (defvar gnus-overload-functions
1308 '((news-inews gnus-inews-news "rnewspost")
1309 (caesar-region gnus-caesar-region "rnews"))
1310 "Functions overloaded by gnus.
1311 It is a list of `(original overload &optional file)'.")
1313 (defvar gnus-newsrc-options nil
1314 "Options line in the .newsrc file.")
1316 (defvar gnus-newsrc-options-n nil
1317 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1319 (defvar gnus-newsrc-last-checked-date nil
1320 "Date Gnus last asked server for new newsgroups.")
1322 (defvar gnus-newsrc-alist nil
1323 "Assoc list of read articles.
1324 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1326 (defvar gnus-newsrc-hashtb nil
1327 "Hashtable of gnus-newsrc-alist.")
1329 (defvar gnus-killed-list nil
1330 "List of killed newsgroups.")
1332 (defvar gnus-killed-hashtb nil
1333 "Hash table equivalent of gnus-killed-list.")
1335 (defvar gnus-zombie-list nil
1336 "List of almost dead newsgroups.")
1338 (defvar gnus-description-hashtb nil
1339 "Descriptions of newsgroups.")
1341 (defvar gnus-list-of-killed-groups nil
1342 "List of newsgroups that have recently been killed by the user.")
1344 (defvar gnus-active-hashtb nil
1345 "Hashtable of active articles.")
1347 (defvar gnus-moderated-list nil
1348 "List of moderated newsgroups.")
1350 (defvar gnus-group-marked nil)
1352 (defvar gnus-current-startup-file nil
1353 "Startup file for the current host.")
1355 (defvar gnus-last-search-regexp nil
1356 "Default regexp for article search command.")
1358 (defvar gnus-last-shell-command nil
1359 "Default shell command on article.")
1361 (defvar gnus-current-select-method nil
1362 "The current method for selecting a newsgroup.")
1364 (defvar gnus-have-all-newsgroups nil)
1366 (defvar gnus-article-internal-prepare-hook nil)
1368 (defvar gnus-newsgroup-name nil)
1369 (defvar gnus-newsgroup-begin nil)
1370 (defvar gnus-newsgroup-end nil)
1371 (defvar gnus-newsgroup-last-rmail nil)
1372 (defvar gnus-newsgroup-last-mail nil)
1373 (defvar gnus-newsgroup-last-folder nil)
1374 (defvar gnus-newsgroup-last-file nil)
1375 (defvar gnus-newsgroup-auto-expire nil)
1376 (defvar gnus-newsgroup-active nil)
1378 (defvar gnus-newsgroup-unreads nil
1379 "List of unread articles in the current newsgroup.")
1381 (defvar gnus-newsgroup-unselected nil
1382 "List of unselected unread articles in the current newsgroup.")
1384 (defvar gnus-newsgroup-marked nil
1385 "List of ticked articles in the current newsgroup (a subset of unread art).")
1387 (defvar gnus-newsgroup-killed nil
1388 "List of ranges of articles that have been through the scoring process.")
1390 (defvar gnus-newsgroup-kill-headers nil)
1392 (defvar gnus-newsgroup-replied nil
1393 "List of articles that have been replied to in the current newsgroup.")
1395 (defvar gnus-newsgroup-expirable nil
1396 "List of articles in the current newsgroup that can be expired.")
1398 (defvar gnus-newsgroup-processable nil
1399 "List of articles in the current newsgroup that can be processed.")
1401 (defvar gnus-newsgroup-bookmarks nil
1402 "List of articles in the current newsgroup that have bookmarks.")
1404 (defvar gnus-newsgroup-dormant nil
1405 "List of dormant articles in the current newsgroup.")
1407 (defvar gnus-newsgroup-scored nil
1408 "List of scored articles in the current newsgroup.")
1410 (defvar gnus-newsgroup-headers nil
1411 "List of article headers in the current newsgroup.")
1412 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1414 (defvar gnus-newsgroup-ancient nil
1415 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1417 (defvar gnus-current-article nil)
1418 (defvar gnus-article-current nil)
1419 (defvar gnus-current-headers nil)
1420 (defvar gnus-have-all-headers nil)
1421 (defvar gnus-last-article nil)
1422 (defvar gnus-newsgroup-history nil)
1423 (defvar gnus-current-kill-article nil)
1425 ;; Save window configuration.
1426 (defvar gnus-prev-winconf nil)
1429 (defvar gnus-summary-line-format-spec nil)
1430 (defvar gnus-summary-dummy-line-format-spec nil)
1431 (defvar gnus-group-line-format-spec nil)
1432 (defvar gnus-summary-mode-line-format-spec nil)
1433 (defvar gnus-article-mode-line-format-spec nil)
1434 (defvar gnus-group-mode-line-format-spec nil)
1435 (defvar gnus-summary-mark-positions nil)
1437 (defvar gnus-summary-expunge-below nil)
1438 (defvar gnus-reffed-article-number nil)
1440 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1441 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1443 (defconst gnus-summary-local-variables
1444 '(gnus-newsgroup-name
1445 gnus-newsgroup-begin gnus-newsgroup-end
1446 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1447 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1448 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1449 gnus-newsgroup-unselected gnus-newsgroup-marked
1450 gnus-newsgroup-replied gnus-newsgroup-expirable
1451 gnus-newsgroup-processable gnus-newsgroup-killed
1452 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1453 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1454 gnus-current-article gnus-current-headers gnus-have-all-headers
1455 gnus-last-article gnus-article-internal-prepare-hook
1456 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1457 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1458 gnus-newsgroup-threads gnus-newsgroup-async
1459 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1460 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1461 gnus-newsgroup-history gnus-newsgroup-ancient
1462 gnus-newsgroup-adaptive)
1463 "Variables that are buffer-local to the summary buffers.")
1465 (defconst gnus-bug-message
1466 "Sending a bug report to the Gnus Towers.
1467 ========================================
1469 The buffer below is a mail buffer. When you press `C-c C-c', it will
1470 be sent to the Gnus Bug Exterminators.
1472 At the bottom of the buffer you'll see lots of variable settings.
1473 Please do not delete those. They will tell the Bug People what your
1474 environment is, so that it will be easier to locate the bugs.
1476 If you have found a bug that makes Emacs go \"beep\", set
1477 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1478 and include the backtrace in your bug report.
1480 Please describe the bug in annoying, painstaking detail.
1482 Thank you for your help in stamping out bugs.
1485 ;;; End of variables.
1487 ;; Define some autoload functions Gnus might use.
1491 (autoload 'metamail-buffer "metamail")
1492 (autoload 'Info-goto-node "info")
1493 (autoload 'hexl-hex-string-to-integer "hexl")
1495 (autoload 'pp-to-string "pp")
1496 (autoload 'pp-eval-expression "pp")
1497 (autoload 'mail-extract-address-components "mail-extr")
1499 (autoload 'nnmail-split-fancy "nnmail")
1502 (autoload 'timezone-make-date-arpa-standard "timezone")
1503 (autoload 'timezone-fix-time "timezone")
1504 (autoload 'timezone-make-sortable-date "timezone")
1505 (autoload 'timezone-make-time-string "timezone")
1508 (autoload 'mail-position-on-field "sendmail")
1509 (autoload 'mail-setup "sendmail")
1510 (autoload 'rmail-output "rmailout")
1511 (autoload 'news-mail-other-window "rnewspost")
1512 (autoload 'news-reply-yank-original "rnewspost")
1513 (autoload 'news-caesar-buffer-body "rnewspost")
1514 (autoload 'rmail-insert-rmail-file-header "rmail")
1515 (autoload 'rmail-count-new-messages "rmail")
1516 (autoload 'rmail-show-message "rmail")
1519 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1520 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1521 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1522 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1523 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1524 (autoload 'gnus-Folder-save-name "gnus-mh")
1525 (autoload 'gnus-folder-save-name "gnus-mh")
1528 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1529 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1530 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1531 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1532 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1533 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1534 (autoload 'gnus-summary-highlight-line "gnus-vis")
1535 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1538 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1539 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1540 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1541 (autoload 'gnus-article-hide "gnus-vis" nil t)
1542 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1543 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1544 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1545 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1546 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1547 (autoload 'gnus-article-add-button "gnus-vis")
1550 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1551 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1552 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1555 (autoload 'gnus-kill "gnus-kill")
1556 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1557 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1558 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1559 (autoload 'gnus-execute "gnus-kill")
1560 (autoload 'gnus-expunge "gnus-kill")
1563 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1564 (autoload 'gnus-cache-save-buffers "gnus-cache")
1565 (autoload 'gnus-cache-possibly-remove-article "gnus-cache")
1566 (autoload 'gnus-cache-request-article "gnus-cache")
1567 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1568 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1569 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1572 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1573 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1574 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1575 (autoload 'gnus-score-save "gnus-score")
1576 (autoload 'gnus-score-headers "gnus-score")
1577 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1578 (autoload 'gnus-score-adaptive "gnus-score")
1579 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1580 (autoload 'gnus-possibly-score-headers "gnus-score")
1581 (autoload 'gnus-score-find-trace "gnus-score")
1584 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1585 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1586 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1587 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1588 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1589 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1590 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1591 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1592 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1593 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1594 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1595 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1596 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1597 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1598 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1599 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1600 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1601 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1602 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1603 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1604 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1605 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1608 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1609 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1610 (autoload 'gnus-group-mail "gnus-msg" nil t)
1611 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1612 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1613 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1614 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1615 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1616 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1617 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1618 (autoload 'gnus-post-news "gnus-msg" nil t)
1619 (autoload 'gnus-inews-news "gnus-msg" nil t)
1620 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1621 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1622 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1623 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1624 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1625 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1626 (autoload 'gnus-mail-yank-original "gnus-msg")
1627 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1628 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1629 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1630 (autoload 'gnus-article-mail-with-original "gnus-msg")
1631 (autoload 'gnus-article-mail "gnus-msg")
1634 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1635 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1636 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1637 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1638 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1639 (autoload 'gnus-yank-article "gnus-vm" nil t)
1645 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1646 ;; If you want the cursor to go somewhere else, set these two
1647 ;; functions in some startup hook to whatever you want.
1648 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1649 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1651 ;;; Various macros and substs.
1653 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1654 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1655 (` (let ((GnusStartBufferWindow (selected-window)))
1658 (pop-to-buffer (, buffer))
1660 (select-window GnusStartBufferWindow)))))
1662 (defmacro gnus-gethash (string hashtable)
1663 "Get hash value of STRING in HASHTABLE."
1664 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1665 ;;(` (abbrev-expansion (, string) (, hashtable)))
1666 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1668 (defmacro gnus-sethash (string value hashtable)
1669 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1670 ;; We cannot use define-abbrev since it only accepts string as value.
1671 ;; (set (intern string hashtable) value))
1672 (` (set (intern (, string) (, hashtable)) (, value))))
1674 (defsubst gnus-buffer-substring (beg end)
1675 (buffer-substring (match-beginning beg) (match-end end)))
1677 (defsubst gnus-simplify-subject-re (subject)
1678 "Remove \"Re:\" from subject lines."
1679 (let ((case-fold-search t))
1680 (if (string-match "^re: *" subject)
1681 (substring subject (match-end 0))
1684 (defsubst gnus-goto-char (point)
1685 (and point (goto-char point)))
1687 (defmacro gnus-buffer-exists-p (buffer)
1689 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1692 (defmacro gnus-kill-buffer (buffer)
1693 (` (if (gnus-buffer-exists-p (, buffer))
1694 (kill-buffer (, buffer)))))
1696 (defsubst gnus-point-at-bol ()
1697 "Return point at the beginning of line."
1704 (defsubst gnus-point-at-eol ()
1705 "Return point at the beginning of line."
1712 ;; Delete the current line (and the next N lines.);
1713 (defmacro gnus-delete-line (&optional n)
1714 (` (delete-region (progn (beginning-of-line) (point))
1715 (progn (forward-line (, (or n 1))) (point)))))
1717 ;;; Load the compatability functions.
1723 ;;; Gnus Utility Functions
1726 (defun gnus-extract-address-components (from)
1728 ;; First find the address - the thing with the @ in it. This may
1729 ;; not be accurate in mail addresses, but does the trick most of
1730 ;; the time in news messages.
1731 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1732 (setq address (substring from (match-beginning 0) (match-end 0))))
1733 ;; Then we check whether the "name <address>" format is used.
1735 (string-match (concat "<" (regexp-quote address) ">") from)
1736 (and (setq name (substring from 0 (1- (match-beginning 0))))
1737 ;; Strip any quotes from the name.
1738 (string-match "\".*\"" name)
1739 (setq name (substring name 1 (1- (match-end 0))))))
1740 ;; If not, then "address (name)" is used.
1742 (and (string-match "(.+)" from)
1743 (setq name (substring from (1+ (match-beginning 0))
1744 (1- (match-end 0))))))
1745 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1746 (list (or name from) (or address from))))
1748 (defun gnus-fetch-field (field)
1749 "Return the value of the header FIELD of current article."
1752 (let ((case-fold-search t))
1753 (gnus-narrow-to-headers)
1754 (mail-fetch-field field)))))
1756 (defun gnus-goto-colon ()
1758 (search-forward ":" (gnus-point-at-eol) t))
1760 (defun gnus-narrow-to-headers ()
1764 (goto-char (point-min))
1765 (if (search-forward "\n\n" nil t)
1769 (defun gnus-update-format-specifications ()
1770 (gnus-make-thread-indent-array)
1771 (setq gnus-summary-line-format-spec
1773 gnus-summary-line-format gnus-summary-line-format-alist))
1774 (gnus-update-summary-mark-positions)
1775 (setq gnus-summary-dummy-line-format-spec
1776 (gnus-parse-format gnus-summary-dummy-line-format
1777 gnus-summary-dummy-line-format-alist))
1778 (setq gnus-group-line-format-spec
1780 gnus-group-line-format
1781 gnus-group-line-format-alist))
1782 (if (and (string-match "%D" gnus-group-line-format)
1783 (not gnus-description-hashtb)
1784 gnus-read-active-file)
1785 (gnus-read-descriptions-file))
1786 (setq gnus-summary-mode-line-format-spec
1787 (gnus-parse-format gnus-summary-mode-line-format
1788 gnus-summary-mode-line-format-alist))
1789 (setq gnus-article-mode-line-format-spec
1790 (gnus-parse-format gnus-article-mode-line-format
1791 gnus-summary-mode-line-format-alist))
1792 (setq gnus-group-mode-line-format-spec
1793 (gnus-parse-format gnus-group-mode-line-format
1794 gnus-group-mode-line-format-alist)))
1796 (defun gnus-update-summary-mark-positions ()
1798 (let ((gnus-replied-mark 129)
1799 (gnus-score-below-mark 130)
1800 (gnus-score-over-mark 130)
1803 (gnus-set-work-buffer)
1804 (gnus-summary-insert-line
1805 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1806 (goto-char (point-min))
1807 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1809 (goto-char (point-min))
1810 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1811 (- (point) 2))) pos))
1812 (goto-char (point-min))
1813 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1814 (- (point) 2))) pos))
1815 (setq gnus-summary-mark-positions pos))))
1817 (defun gnus-format-max-width (form length)
1818 (let* ((val (eval form))
1819 (valstr (if (numberp val) (int-to-string val) val)))
1820 (if (> (length valstr) length)
1821 (substring valstr 0 length)
1824 (defun gnus-set-mouse-face (string)
1825 ;; Set mouse face property on STRING.
1826 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1829 (defun gnus-parse-format (format spec-alist)
1830 ;; This function parses the FORMAT string with the help of the
1831 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1832 ;; string. If the FORMAT string contains the specifiers %( and %)
1833 ;; the text between them will have the mouse-face text property.
1834 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1835 (if (and gnus-visual gnus-mouse-face)
1836 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1837 (button (substring format (match-beginning 2) (match-end 2)))
1838 (post (substring format (match-beginning 3) (match-end 3))))
1840 (gnus-parse-simple-format pre spec-alist)
1841 (list 'gnus-set-mouse-face
1842 (gnus-parse-simple-format button spec-alist))
1843 (gnus-parse-simple-format post spec-alist)))
1844 (gnus-parse-simple-format
1845 (concat (substring format (match-beginning 1) (match-end 1))
1846 (substring format (match-beginning 2) (match-end 2))
1847 (substring format (match-beginning 3) (match-end 3)))
1849 (gnus-parse-simple-format format spec-alist)))
1851 (defun gnus-parse-simple-format (format spec-alist)
1852 ;; This function parses the FORMAT string with the help of the
1853 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1854 ;; string. The list will consist of the symbol `format', a format
1855 ;; specification string, and a list of forms depending on the
1858 spec flist fstring b newspec max-width elem beg)
1860 (gnus-set-work-buffer)
1862 (goto-char (point-min))
1863 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1864 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1866 ;; First check if there are any specs that look anything like
1867 ;; "%12,12A", ie. with a "max width specification". These have
1868 ;; to be treated specially.
1869 (if (setq beg (match-beginning 1))
1872 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1874 (setq beg (match-beginning 2)))
1875 ;; Find the specification from `spec-alist'.
1876 (if (not (setq elem (cdr (assq spec spec-alist))))
1877 (setq elem '("*" ?s)))
1878 ;; Treat user defined format specifiers specially
1879 (and (eq (car elem) 'user-defined)
1882 (list (intern (concat "gnus-user-format-function-"
1888 (delete-region (match-beginning 3) (match-end 3)))
1889 (if (not (zerop max-width))
1890 (let ((el (car elem)))
1891 (cond ((= (car (cdr elem)) ?c)
1892 (setq el (list 'char-to-string el)))
1893 ((= (car (cdr elem)) ?d)
1894 (numberp el) (setq el (list 'int-to-string el))))
1895 (setq flist (cons (list 'gnus-format-max-width el max-width)
1898 (setq flist (cons (car elem) flist))
1899 (setq newspec (car (cdr elem))))
1900 ;; Remove the old specification (and possibly a ",12" string).
1901 (delete-region beg (match-end 2))
1902 ;; Insert the new specification.
1905 (setq fstring (buffer-substring 1 (point-max))))
1906 (cons 'format (cons fstring (nreverse flist)))))
1908 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1909 (defun gnus-read-init-file ()
1911 (or (and (file-exists-p gnus-init-file)
1912 ;; Don't try to load a directory.
1913 (not (file-directory-p gnus-init-file)))
1914 (file-exists-p (concat gnus-init-file ".el"))
1915 (file-exists-p (concat gnus-init-file ".elc")))
1916 (load gnus-init-file nil t)))
1918 (defun gnus-set-work-buffer ()
1919 (if (get-buffer gnus-work-buffer)
1921 (set-buffer gnus-work-buffer)
1923 (set-buffer (get-buffer-create gnus-work-buffer))
1924 (kill-all-local-variables)
1925 (buffer-disable-undo (current-buffer))
1926 (gnus-add-current-to-buffer-list)))
1928 ;; Article file names when saving.
1930 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1931 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1932 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1933 Otherwise, it is like ~/News/news/group/num."
1936 (concat (if (gnus-use-long-file-name 'not-save)
1937 (gnus-capitalize-newsgroup newsgroup)
1938 (gnus-newsgroup-directory-form newsgroup))
1939 "/" (int-to-string (header-number headers)))
1940 (or gnus-article-save-directory "~/News"))))
1942 (string-equal (file-name-directory default)
1943 (file-name-directory last-file))
1944 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1946 (or last-file default))))
1948 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1949 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1950 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1951 Otherwise, it is like ~/News/news/group/num."
1954 (concat (if (gnus-use-long-file-name 'not-save)
1956 (gnus-newsgroup-directory-form newsgroup))
1957 "/" (int-to-string (header-number headers)))
1958 (or gnus-article-save-directory "~/News"))))
1960 (string-equal (file-name-directory default)
1961 (file-name-directory last-file))
1962 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1964 (or last-file default))))
1966 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1967 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1968 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1969 Otherwise, it is like ~/News/news/group/news."
1972 (if (gnus-use-long-file-name 'not-save)
1973 (gnus-capitalize-newsgroup newsgroup)
1974 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1975 (or gnus-article-save-directory "~/News"))))
1977 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1978 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1979 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1980 Otherwise, it is like ~/News/news/group/news."
1983 (if (gnus-use-long-file-name 'not-save)
1985 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1986 (or gnus-article-save-directory "~/News"))))
1988 ;; For subscribing new newsgroup
1990 (defun gnus-subscribe-hierarchical-interactive (groups)
1991 (let ((groups (sort groups 'string<))
1992 prefixes prefix start rest ans group starts)
1994 (setq prefixes (list "^"))
1995 (while (and groups prefixes)
1996 (while (not (string-match (car prefixes) (car groups)))
1997 (setq prefixes (cdr prefixes)))
1998 (setq prefix (car prefixes))
1999 (setq start (1- (length prefix)))
2000 (if (and (string-match "[^\\.]\\." (car groups) start)
2003 (concat "^" (substring (car groups) 0 (match-end 0))))
2004 (string-match prefix (car (cdr groups))))
2006 (setq prefixes (cons prefix prefixes))
2007 (message "Descend hierarchy %s? ([y]nsq): "
2008 (substring prefix 1 (1- (length prefix))))
2009 (setq ans (read-char))
2012 (string-match prefix
2013 (setq group (car groups))))
2014 (setq gnus-killed-list
2015 (cons group gnus-killed-list))
2016 (gnus-sethash group group gnus-killed-hashtb)
2017 (setq groups (cdr groups)))
2018 (setq starts (cdr starts)))
2021 (string-match prefix
2022 (setq group (car groups))))
2023 (gnus-sethash group group gnus-killed-hashtb)
2024 (gnus-subscribe-alphabetically (car groups))
2025 (setq groups (cdr groups)))
2026 (setq starts (cdr starts)))
2029 (setq group (car groups))
2030 (setq gnus-killed-list (cons group gnus-killed-list))
2031 (gnus-sethash group group gnus-killed-hashtb)
2032 (setq groups (cdr groups))))
2034 (message "Subscribe %s? ([n]yq)" (car groups))
2035 (setq ans (read-char))
2036 (setq group (car groups))
2038 (gnus-subscribe-alphabetically (car groups))
2039 (gnus-sethash group group gnus-killed-hashtb))
2042 (setq group (car groups))
2043 (setq gnus-killed-list (cons group gnus-killed-list))
2044 (gnus-sethash group group gnus-killed-hashtb)
2045 (setq groups (cdr groups))))
2047 (setq gnus-killed-list (cons group gnus-killed-list))
2048 (gnus-sethash group group gnus-killed-hashtb)))
2049 (setq groups (cdr groups)))))))
2051 (defun gnus-subscribe-randomly (newsgroup)
2052 "Subscribe new NEWSGROUP by making it the first newsgroup."
2053 (gnus-subscribe-newsgroup newsgroup))
2055 (defun gnus-subscribe-alphabetically (newgroup)
2056 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2057 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2058 (let ((groups (cdr gnus-newsrc-alist))
2060 (while (and (not before) groups)
2061 (if (string< newgroup (car (car groups)))
2062 (setq before (car (car groups)))
2063 (setq groups (cdr groups))))
2064 (gnus-subscribe-newsgroup newgroup before)))
2066 (defun gnus-subscribe-hierarchically (newgroup)
2067 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2068 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2070 (set-buffer (find-file-noselect gnus-current-startup-file))
2071 (let ((groupkey newgroup)
2073 (while (and (not before) groupkey)
2074 (goto-char (point-min))
2076 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2077 (while (and (re-search-forward groupkey-re nil t)
2079 (setq before (buffer-substring
2080 (match-beginning 1) (match-end 1)))
2081 (string< before newgroup)))))
2082 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2084 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2085 (substring groupkey (match-beginning 1) (match-end 1)))))
2086 (gnus-subscribe-newsgroup newgroup before))))
2088 (defun gnus-subscribe-interactively (newsgroup)
2089 "Subscribe new NEWSGROUP interactively.
2090 It is inserted in hierarchical newsgroup order if subscribed. If not,
2092 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2093 (gnus-subscribe-hierarchically newsgroup)
2094 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2096 (defun gnus-subscribe-zombies (newsgroup)
2097 "Make new NEWSGROUP a zombie group."
2098 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2100 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2101 "Subscribe new NEWSGROUP.
2102 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2103 the first newsgroup."
2104 ;; We subscribe the group by changing its level to `subscribed'.
2105 (gnus-group-change-level
2106 newsgroup gnus-level-default-subscribed
2107 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2108 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2112 (defun gnus-newsgroup-directory-form (newsgroup)
2113 "Make hierarchical directory name from NEWSGROUP name."
2114 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2115 (len (length newsgroup))
2117 ;; If this is a foreign group, we don't want to translate the
2119 (if (setq idx (string-match ":" newsgroup))
2120 (aset newsgroup idx ?/)
2122 ;; Replace all occurrences of `.' with `/'.
2124 (if (= (aref newsgroup idx) ?.)
2125 (aset newsgroup idx ?/))
2126 (setq idx (1+ idx)))
2129 (defun gnus-make-directory (dir)
2130 "Make DIRECTORY recursively."
2131 (let* ((dir (expand-file-name dir default-directory))
2133 (if (string-match "/$" dir)
2134 (setq dir (substring dir 0 (match-beginning 0))))
2135 (while (not (file-exists-p dir))
2136 (setq dirs (cons dir dirs))
2137 (string-match "/[^/]+$" dir)
2138 (setq dir (substring dir 0 (match-beginning 0))))
2140 (make-directory (car dirs))
2141 (setq dirs (cdr dirs)))))
2143 (defun gnus-capitalize-newsgroup (newsgroup)
2144 "Capitalize NEWSGROUP name."
2145 (and (not (zerop (length newsgroup)))
2146 (concat (char-to-string (upcase (aref newsgroup 0)))
2147 (substring newsgroup 1))))
2151 (defun gnus-simplify-subject (subject &optional re-only)
2152 "Remove `Re:' and words in parentheses.
2153 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2154 (let ((case-fold-search t)) ;Ignore case.
2155 ;; Remove `Re:' and `Re^N:'.
2156 (if (string-match "^re:[ \t]*" subject)
2157 (setq subject (substring subject (match-end 0))))
2158 ;; Remove words in parentheses from end.
2160 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2161 (setq subject (substring subject 0 (match-beginning 0)))))
2162 ;; Return subject string.
2165 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2167 (defun gnus-simplify-subject-fuzzy (subject)
2168 (let ((case-fold-search t))
2170 (gnus-set-work-buffer)
2172 (gnus-simplify-buffer-fuzzy)
2175 (defun gnus-simplify-buffer-fuzzy ()
2176 (goto-char (point-min))
2177 (while (re-search-forward "^[ \t]*re:[ \t]*" nil t)
2178 (replace-match "" t t))
2179 (goto-char (point-min))
2180 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2181 (replace-match "" t t))
2182 (goto-char (point-min))
2183 (while (re-search-forward "[ \t]+" nil t)
2184 (replace-match " " t t))
2185 (goto-char (point-min))
2186 (while (re-search-forward "[ \t]+$" nil t)
2187 (replace-match "" t t))
2188 (goto-char (point-min))
2189 (while (re-search-forward "^[ \t]+" nil t)
2190 (replace-match "" t t)))
2192 ;; Add the current buffer to the list of buffers to be killed on exit.
2193 (defun gnus-add-current-to-buffer-list ()
2194 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2196 (defun gnus-string> (s1 s2)
2197 (not (or (string< s1 s2)
2200 ;; Functions accessing headers.
2201 ;; Functions are more convenient than macros in some cases.
2203 (defun gnus-header-number (header)
2204 (header-number header))
2206 (defun gnus-header-subject (header)
2207 (header-subject header))
2209 (defun gnus-header-from (header)
2210 (header-from header))
2212 (defun gnus-header-xref (header)
2213 (header-xref header))
2215 (defun gnus-header-lines (header)
2216 (header-lines header))
2218 (defun gnus-header-date (header)
2219 (header-date header))
2221 (defun gnus-header-id (header)
2224 (defun gnus-header-references (header)
2225 (header-references header))
2227 ;;; General various misc type functions.
2229 (defun gnus-clear-system ()
2230 "Clear all variables and buffers."
2231 ;; Clear Gnus variables.
2232 (let ((variables gnus-variable-list))
2234 (set (car variables) nil)
2235 (setq variables (cdr variables))))
2236 ;; Clear other internal variables.
2237 (setq gnus-list-of-killed-groups nil
2238 gnus-have-read-active-file nil
2239 gnus-newsrc-alist nil
2240 gnus-newsrc-hashtb nil
2241 gnus-killed-list nil
2242 gnus-zombie-list nil
2243 gnus-killed-hashtb nil
2244 gnus-active-hashtb nil
2245 gnus-moderated-list nil
2246 gnus-description-hashtb nil
2247 gnus-newsgroup-headers nil
2248 gnus-newsgroup-headers-hashtb-by-number nil
2249 gnus-newsgroup-name nil
2250 gnus-server-alist nil
2251 gnus-current-select-method nil)
2252 ;; Reset any score variables.
2253 (and (boundp 'gnus-score-cache)
2254 (set 'gnus-score-cache nil))
2255 (and (boundp 'gnus-internal-global-score-files)
2256 (set 'gnus-internal-global-score-files nil))
2257 ;; Kill the startup file.
2258 (and gnus-current-startup-file
2259 (get-file-buffer gnus-current-startup-file)
2260 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2261 ;; Save any cache buffers.
2262 (and gnus-use-cache (gnus-cache-save-buffers))
2263 ;; Clear the dribble buffer.
2264 (gnus-dribble-clear)
2265 ;; Kill global KILL file buffer.
2266 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2267 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2268 (gnus-kill-buffer nntp-server-buffer)
2269 ;; Kill Gnus buffers.
2270 (while gnus-buffer-list
2271 (gnus-kill-buffer (car gnus-buffer-list))
2272 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2274 (defun gnus-windows-old-to-new (setting)
2275 (if (symbolp setting)
2277 (cond ((eq setting 'SelectArticle)
2279 ((eq setting 'SelectSubject)
2281 ((eq setting 'SelectNewsgroup)
2284 (if (or (listp setting)
2285 (not (and gnus-window-configuration
2286 (memq setting '(group summary article)))))
2288 (let* ((setting (if (eq setting 'group)
2289 (if (assq 'newsgroup gnus-window-configuration)
2291 'newsgroups) setting))
2292 (elem (car (cdr (assq setting gnus-window-configuration))))
2293 (total (apply '+ elem))
2294 (types '(group summary article))
2295 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2300 (or (zerop (nth i elem))
2302 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2303 (setq out (cons (if (eq pbuf (nth i types))
2304 (vector (nth i types) perc 'point)
2305 (vector (nth i types) perc))
2308 (list (nreverse out)))))
2310 (defun gnus-configure-windows (setting)
2311 (setq setting (gnus-windows-old-to-new setting))
2312 (let ((r (if (symbolp setting)
2313 (cdr (assq setting gnus-buffer-configuration))
2315 (in-buf (current-buffer))
2316 rule val window w height hor ohor heights sub jump-buffer
2318 (or r (error "No such setting: %s" setting))
2320 ;; Either remove all windows or just remove all Gnus windows.
2321 (if gnus-use-full-window
2322 (delete-other-windows)
2323 (gnus-remove-some-windows)
2324 (switch-to-buffer nntp-server-buffer))
2330 ;; We have to do the (possible) horizontal splitting before the
2332 (if (and (listp (car hor))
2333 (eq (car (car hor)) 'horizontal))
2335 (split-window nil (- (frame-width)
2336 (floor (* (frame-width) (nth 1 (car hor)))))
2338 (setq hor (cdr hor))))
2340 ;; Go through the rules and eval the elements that are to be
2343 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2345 ;; Expand short buffer name.
2346 (setq w (aref val 0))
2347 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2349 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2351 (setq ohor (cons val ohor))))
2352 (setq hor (cdr hor)))
2353 (setq rule (cons (nreverse ohor) rule))
2355 (setq rule (nreverse rule))
2357 ;; We tally the window sizes.
2358 (setq total (window-height))
2360 (setq hor (car rule))
2361 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2362 (setq hor (cdr hor)))
2365 (setq rel (aref (car hor) 1)
2367 (cond ((and (floatp rel) (= 1.0 rel))
2372 (max (floor (* total rel)) 4)))
2374 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2376 (setq heights (nreverse heights)
2379 ;; We then go through these heighs and create windows for them.
2381 (setq height (car heights)
2382 heights (cdr heights))
2384 (setq height (- total sub)))
2386 (split-window nil height))
2387 (setq to-buf (aref (car hor) 0))
2392 (symbol-value (aref (car hor) 0)))
2394 (aref (car hor) 0))))
2395 (and (> (length (car hor)) 2)
2396 (eq (aref (car hor) 2) 'point)
2397 (setq jump-buffer (current-buffer)))
2399 (setq hor (cdr hor)))
2401 (setq rule (cdr rule)))
2403 ;; Finally, we pop to the buffer that's supposed to have point.
2404 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2406 (pop-to-buffer jump-buffer)
2409 (defun gnus-remove-some-windows ()
2410 (let ((buffers gnus-window-to-buffer)
2414 (setq buf (cdr (car buffers)))
2416 (setq buf (and (boundp buf) (symbol-value buf))))
2418 (get-buffer-window buf)
2423 (switch-to-buffer nntp-server-buffer)
2425 (delete-window (get-buffer-window buf)))))
2426 (setq buffers (cdr buffers)))
2427 (set-buffer nntp-server-buffer)))
2429 (defun gnus-version ()
2430 "Version numbers of this version of Gnus."
2432 (let ((methods gnus-valid-select-methods)
2435 ;; Go through all the legal select methods and add their version
2436 ;; numbers to the total version string. Only the backends that are
2437 ;; currently in use will have their message numbers taken into
2440 (setq meth (intern (concat (car (car methods)) "-version")))
2442 (stringp (symbol-value meth))
2443 (setq mess (concat mess "; " (symbol-value meth))))
2444 (setq methods (cdr methods)))
2445 (gnus-message 2 mess)))
2447 (defun gnus-info-find-node ()
2448 "Find Info documentation of Gnus."
2450 ;; Enlarge info window if needed.
2451 (let ((mode major-mode))
2452 (gnus-configure-windows 'info)
2453 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2456 "Send a bug report to the Gnus maintainers."
2458 (let ((winconf (current-window-configuration)))
2459 (delete-other-windows)
2460 (switch-to-buffer "*Gnus Bug Help*")
2462 (insert gnus-bug-message)
2463 (goto-char (point-min))
2464 (pop-to-buffer "*Gnus Bug*")
2467 (mail-setup gnus-maintainer nil nil nil nil nil)
2468 (make-local-variable 'gnus-prev-winconf)
2469 (setq gnus-prev-winconf winconf)
2470 (goto-char (point-min))
2471 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2473 (insert (format "%s\n%s\n\n\n\n\n" (gnus-version) (emacs-version)))
2476 (goto-char (- b 3)))
2479 (defun gnus-debug ()
2480 "Attemps to go through the Gnus source file and report what variables have been changed.
2481 The source file has to be in the Emacs load path."
2483 (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el"))
2484 file dirs expr olist)
2486 (set-buffer (get-buffer-create " *gnus bug info*"))
2487 (buffer-disable-undo (current-buffer))
2488 (message "Please wait while we snoop your variables...")
2492 (setq dirs load-path)
2494 (if (or (not (car dirs))
2495 (not (stringp (car dirs)))
2497 (setq file (concat (file-name-as-directory
2498 (car dirs)) (car files))))))
2499 (setq dirs (cdr dirs))
2501 (insert-file-contents file)
2502 (goto-char (point-min))
2503 (or (re-search-forward "^;;* Internal variables" nil t)
2504 (error "Malformed sources in file %s" file))
2505 (narrow-to-region (point-min) (point))
2506 (goto-char (point-min))
2507 (while (setq expr (condition-case ()
2508 (read (current-buffer)) (error nil)))
2509 (and (eq (car expr) 'defvar)
2510 (stringp (nth 3 expr))
2511 (or (not (boundp (nth 1 expr)))
2512 (not (equal (eval (nth 2 expr))
2513 (symbol-value (nth 1 expr)))))
2514 (setq olist (cons (nth 1 expr) olist))))))
2515 (setq files (cdr files)))
2516 (kill-buffer (current-buffer)))
2517 (insert "------------------- Environment follows -------------------\n\n")
2519 (if (boundp (car olist))
2520 (insert "(setq " (symbol-name (car olist)) " '"
2521 (prin1-to-string (symbol-value (car olist))) ")\n")
2522 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
2523 (setq olist (cdr olist)))
2526 (defun gnus-overload-functions (&optional overloads)
2527 "Overload functions specified by optional argument OVERLOADS.
2528 If nothing is specified, use the variable gnus-overload-functions."
2530 (overloads (or overloads gnus-overload-functions)))
2532 (setq defs (car overloads))
2533 (setq overloads (cdr overloads))
2534 ;; Load file before overloading function if necessary. Make
2535 ;; sure we cannot use `require' always.
2536 (and (not (fboundp (car defs)))
2537 (car (cdr (cdr defs)))
2538 (load (car (cdr (cdr defs))) nil 'nomessage))
2539 (fset (car defs) (car (cdr defs))))))
2541 (defun gnus-replace-chars-in-string (string from to)
2542 "Replace characters in STRING from FROM to TO."
2543 (let ((string (substring string 0)) ;Copy string.
2544 (len (length string))
2546 ;; Replace all occurrences of FROM with TO.
2548 (if (= (aref string idx) from)
2549 (aset string idx to))
2550 (setq idx (1+ idx)))
2553 (defun gnus-days-between (date1 date2)
2554 ;; Return the number of days between date1 and date2.
2555 (- (gnus-day-number date1) (gnus-day-number date2)))
2557 (defun gnus-day-number (date)
2558 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2559 (timezone-parse-date date))))
2560 (timezone-absolute-from-gregorian
2561 (nth 1 dat) (nth 2 dat) (car dat))))
2563 ;; Returns a floating point number that says how many seconds have
2564 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2565 (defun gnus-seconds-since-epoch (date)
2566 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2567 (timezone-parse-date date)))
2568 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2569 (timezone-parse-time
2570 (aref (timezone-parse-date date) 3))))
2571 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2572 (timezone-parse-date "Jan 1 12:00:00 1970")))
2573 (tday (- (timezone-absolute-from-gregorian
2574 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2575 (timezone-absolute-from-gregorian
2576 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2578 (* (nth 1 ttime) 60)
2579 (* 1.0 (nth 0 ttime) 60 60)
2580 (* 1.0 tday 60 60 24))))
2582 (defun gnus-file-newer-than (file date)
2583 (let ((fdate (nth 5 (file-attributes file))))
2584 (or (> (car fdate) (car date))
2585 (and (= (car fdate) (car date))
2586 (> (nth 1 fdate) (nth 1 date))))))
2588 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2590 (defun gnus-y-or-n-p (prompt)
2595 (defun gnus-yes-or-no-p (prompt)
2597 (yes-or-no-p prompt)
2600 ;; Check whether to use long file names.
2601 (defun gnus-use-long-file-name (symbol)
2602 ;; The variable has to be set...
2603 (and gnus-use-long-file-name
2604 ;; If it isn't a list, then we return t.
2605 (or (not (listp gnus-use-long-file-name))
2606 ;; If it is a list, and the list contains `symbol', we
2608 (not (memq symbol gnus-use-long-file-name)))))
2610 ;; I suspect there's a better way, but I haven't taken the time to do
2611 ;; it yet. -erik selberg@cs.washington.edu
2612 (defun gnus-dd-mmm (messy-date)
2613 "Return a string like DD-MMM from a big messy string"
2614 (let ((datevec (timezone-parse-date messy-date)))
2616 (or (aref datevec 2) "??")
2619 (nth (1- (string-to-number (aref datevec 1)))
2620 timezone-months-assoc))
2623 ;; Make a hash table (default and minimum size is 255).
2624 ;; Optional argument HASHSIZE specifies the table size.
2625 (defun gnus-make-hashtable (&optional hashsize)
2626 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2628 ;; Make a number that is suitable for hashing; bigger than MIN and one
2630 (defun gnus-create-hash-size (min)
2636 ;; Show message if message has a lower level than `gnus-verbose'.
2637 ;; Guide-line for numbers:
2638 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2639 ;; for things that take a long time, 7 - not very important messages
2640 ;; on stuff, 9 - messages inside loops.
2641 (defun gnus-message (level &rest args)
2642 (if (<= level gnus-verbose)
2643 (apply 'message args)
2644 ;; We have to do this format thingie here even if the result isn't
2645 ;; shown - the return value has to be the same as the return value
2647 (apply 'format args)))
2649 ;; Generate a unique new group name.
2650 (defun gnus-generate-new-group-name (leaf)
2653 (while (gnus-gethash name gnus-newsrc-hashtb)
2654 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2657 ;;; List and range functions
2659 (defun gnus-last-element (list)
2660 "Return last element of LIST."
2662 (setq list (cdr list)))
2665 (defun gnus-copy-sequence (list)
2666 "Do a complete, total copy of a list."
2667 (if (and (consp list) (not (consp (cdr list))))
2668 (cons (car list) (cdr list))
2669 (mapcar (lambda (elem) (if (consp elem)
2670 (if (consp (cdr elem))
2671 (gnus-copy-sequence elem)
2672 (cons (car elem) (cdr elem)))
2676 (defun gnus-set-difference (list1 list2)
2677 "Return a list of elements of LIST1 that do not appear in LIST2."
2678 (let ((list1 (copy-sequence list1)))
2680 (setq list1 (delq (car list2) list1))
2681 (setq list2 (cdr list2)))
2684 (defun gnus-sorted-complement (list1 list2)
2685 "Return a list of elements of LIST1 that do not appear in LIST2.
2686 Both lists have to be sorted over <."
2688 (if (or (null list1) (null list2))
2690 (while (and list1 list2)
2691 (cond ((= (car list1) (car list2))
2692 (setq list1 (cdr list1)
2694 ((< (car list1) (car list2))
2695 (setq out (cons (car list1) out))
2696 (setq list1 (cdr list1)))
2698 (setq out (cons (car list2) out))
2699 (setq list2 (cdr list2)))))
2700 (nconc (nreverse out) (or list1 list2)))))
2702 (defun gnus-intersection (list1 list2)
2705 (if (memq (car list2) list1)
2706 (setq result (cons (car list2) result)))
2707 (setq list2 (cdr list2)))
2710 (defun gnus-sorted-intersection (list1 list2)
2711 ;; LIST1 and LIST2 have to be sorted over <.
2713 (while (and list1 list2)
2714 (cond ((= (car list1) (car list2))
2715 (setq out (cons (car list1) out)
2718 ((< (car list1) (car list2))
2719 (setq list1 (cdr list1)))
2721 (setq list2 (cdr list2)))))
2724 (defun gnus-set-sorted-intersection (list1 list2)
2725 ;; LIST1 and LIST2 have to be sorted over <.
2726 ;; This function modifies LIST1.
2727 (let* ((top (cons nil list1))
2729 (while (and list1 list2)
2730 (cond ((= (car list1) (car list2))
2734 ((< (car list1) (car list2))
2735 (setcdr prev (cdr list1))
2736 (setq list1 (cdr list1)))
2738 (setq list2 (cdr list2)))))
2742 (defun gnus-compress-sequence (numbers &optional always-list)
2743 "Convert list of numbers to a list of ranges or a single range.
2744 If ALWAYS-LIST is non-nil, this function will always release a list of
2746 (let* ((first (car numbers))
2747 (last (car numbers))
2751 (if (not (listp (cdr numbers)))
2754 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2755 ((= (1+ last) (car numbers)) ;Still in sequence
2756 (setq last (car numbers)))
2757 (t ;End of one sequence
2759 (cons (if (= first last) first
2760 (cons first last)) result))
2761 (setq first (car numbers))
2762 (setq last (car numbers))))
2763 (setq numbers (cdr numbers)))
2764 (if (and (not always-list) (null result))
2765 (if (= first last) (list first) (cons first last))
2766 (nreverse (cons (if (= first last) first (cons first last))
2769 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2770 (defun gnus-uncompress-range (ranges)
2771 "Expand a list of ranges into a list of numbers.
2772 RANGES is either a single range on the form `(num . num)' or a list of
2774 (let (first last result)
2778 ((not (listp (cdr ranges)))
2779 (setq first (car ranges))
2780 (setq last (cdr ranges))
2781 (while (<= first last)
2782 (setq result (cons first result))
2783 (setq first (1+ first)))
2787 (if (atom (car ranges))
2788 (if (numberp (car ranges))
2789 (setq result (cons (car ranges) result)))
2790 (setq first (car (car ranges)))
2791 (setq last (cdr (car ranges)))
2792 (while (<= first last)
2793 (setq result (cons first result))
2794 (setq first (1+ first))))
2795 (setq ranges (cdr ranges)))
2796 (nreverse result)))))
2798 (defun gnus-add-to-range (ranges list)
2799 "Return a list of ranges that has all articles from both RANGES and LIST.
2800 Note: LIST has to be sorted over `<'."
2802 (gnus-compress-sequence list t)
2803 (setq list (copy-sequence list))
2804 (or (listp (cdr ranges))
2805 (setq ranges (list ranges)))
2807 ilist lowest highest temp)
2808 (while (and ranges list)
2810 (setq lowest (or (and (atom (car ranges)) (car ranges))
2811 (car (car ranges))))
2812 (while (and list (cdr list) (< (car (cdr list)) lowest))
2813 (setq list (cdr list)))
2814 (if (< (car ilist) lowest)
2817 (setq list (cdr list))
2819 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2820 (setq highest (or (and (atom (car ranges)) (car ranges))
2821 (cdr (car ranges))))
2822 (while (and list (<= (car list) highest))
2823 (setq list (cdr list)))
2824 (setq ranges (cdr ranges)))
2826 (setq out (nconc (gnus-compress-sequence list t) out)))
2827 (setq out (sort out (lambda (r1 r2)
2828 (< (or (and (atom r1) r1) (car r1))
2829 (or (and (atom r2) r2) (car r2))))))
2832 (if (atom (car ranges))
2834 (if (atom (car (cdr ranges)))
2835 (if (= (1+ (car ranges)) (car (cdr ranges)))
2837 (setcar ranges (cons (car ranges)
2838 (car (cdr ranges))))
2839 (setcdr ranges (cdr (cdr ranges)))))
2840 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2842 (setcar (car (cdr ranges)) (car ranges))
2843 (setcar ranges (car (cdr ranges)))
2844 (setcdr ranges (cdr (cdr ranges)))))))
2846 (if (atom (car (cdr ranges)))
2847 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2849 (setcdr (car ranges) (car (cdr ranges)))
2850 (setcdr ranges (cdr (cdr ranges)))))
2851 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2853 (setcdr (car ranges) (cdr (car (cdr ranges))))
2854 (setcdr ranges (cdr (cdr ranges))))))))
2855 (setq ranges (cdr ranges)))
2858 (defun gnus-remove-from-range (ranges list)
2859 "Return a list of ranges that has all articles from LIST removed from RANGES.
2860 Note: LIST has to be sorted over `<'."
2861 ;; !!! This function shouldn't look like this, but I've got a headache.
2862 (gnus-compress-sequence
2863 (gnus-sorted-complement
2864 (gnus-uncompress-range ranges) list)))
2866 (defun gnus-member-of-range (number ranges)
2867 (if (not (listp (cdr ranges)))
2868 (and (>= number (car ranges))
2869 (<= number (cdr ranges)))
2872 (if (numberp (car ranges))
2873 (>= number (car ranges))
2874 (>= number (car (car ranges))))
2876 (if (if (numberp (car ranges))
2877 (= number (car ranges))
2878 (and (>= number (car (car ranges)))
2879 (<= number (cdr (car ranges)))))
2880 (setq not-stop nil))
2881 (setq ranges (cdr ranges)))
2889 (defvar gnus-group-mode-map nil)
2890 (defvar gnus-group-group-map nil)
2891 (defvar gnus-group-mark-map nil)
2892 (defvar gnus-group-list-map nil)
2893 (defvar gnus-group-sub-map nil)
2894 (put 'gnus-group-mode 'mode-class 'special)
2896 (if gnus-group-mode-map
2898 (setq gnus-group-mode-map (make-keymap))
2899 (suppress-keymap gnus-group-mode-map)
2900 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2901 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2902 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2903 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2904 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2905 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2906 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2907 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2908 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2909 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2910 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2911 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2912 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2913 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2914 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2915 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2916 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2917 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2918 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2919 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2920 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2921 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2922 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2923 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2924 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2925 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2926 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2927 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2928 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2929 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2930 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2931 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2932 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2933 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2934 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2935 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2936 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2937 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2938 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2939 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2940 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2941 (define-key gnus-group-mode-map "V" 'gnus-version)
2942 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2943 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2944 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2945 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2946 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2947 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2948 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2949 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2950 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
2951 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2952 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
2953 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
2954 (define-key gnus-group-mode-map ">" 'end-of-buffer)
2955 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
2956 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
2958 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
2959 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
2960 (define-prefix-command 'gnus-group-mark-map)
2961 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
2962 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
2963 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
2964 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
2966 (define-prefix-command 'gnus-group-group-map)
2967 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
2968 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
2969 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
2970 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
2971 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
2972 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
2973 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
2974 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
2975 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
2976 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
2977 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
2978 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
2979 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
2981 (define-prefix-command 'gnus-group-list-map)
2982 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
2983 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2984 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2985 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2986 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2987 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2988 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2989 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2990 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2992 (define-prefix-command 'gnus-group-sub-map)
2993 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2994 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2995 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2996 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2997 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2998 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2999 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3000 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3002 (defun gnus-group-mode ()
3003 "Major mode for reading news.
3005 All normal editing commands are switched off.
3006 \\<gnus-group-mode-map>
3007 The group buffer lists (some of) the groups available. For instance,
3008 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3009 lists all zombie groups.
3011 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3012 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3014 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3016 The following commands are available:
3018 \\{gnus-group-mode-map}"
3020 (if gnus-visual (gnus-group-make-menu-bar))
3021 (kill-all-local-variables)
3022 (setq mode-line-modified "-- ")
3023 (make-local-variable 'mode-line-format)
3024 (setq mode-line-format (copy-sequence mode-line-format))
3025 (and (equal (nth 3 mode-line-format) " ")
3026 (setcar (nthcdr 3 mode-line-format) ""))
3027 (setq major-mode 'gnus-group-mode)
3028 (setq mode-name "Group")
3029 (gnus-group-set-mode-line)
3030 (setq mode-line-process nil)
3031 (use-local-map gnus-group-mode-map)
3032 (buffer-disable-undo (current-buffer))
3033 (setq truncate-lines t)
3034 (setq buffer-read-only t)
3035 (run-hooks 'gnus-group-mode-hook))
3037 (defun gnus-mouse-pick-group (e)
3040 (gnus-group-read-group nil))
3043 (defun gnus-no-server (&optional arg)
3045 If ARG is a positive number, Gnus will use that as the
3046 startup level. If ARG is nil, Gnus will be started at level 2.
3047 If ARG is non-nil and not a positive number, Gnus will
3048 prompt the user for the name of an NNTP server to use.
3049 As opposed to `gnus', this command will not connect to the local server."
3051 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3053 (defalias '\(ding\) 'gnus)
3056 (defun gnus (&optional arg dont-connect)
3058 If ARG is non-nil and a positive number, Gnus will use that as the
3059 startup level. If ARG is non-nil and not a positive number, Gnus will
3060 prompt the user for the name of an NNTP server to use."
3062 (if (get-buffer gnus-group-buffer)
3064 (switch-to-buffer gnus-group-buffer)
3065 (gnus-group-get-new-news))
3067 (nnheader-init-server-buffer)
3068 (gnus-read-init-file)
3069 (let ((level (and arg (numberp arg) (> arg 0) arg))
3073 (gnus-group-setup-buffer)
3076 (gnus-start-news-server (and arg (not level))))))
3077 (if (and (not dont-connect)
3080 (run-hooks 'gnus-startup-hook)
3081 ;; NNTP server is successfully open.
3082 (gnus-update-format-specifications)
3083 (gnus-summary-make-display-table)
3084 (let ((buffer-read-only nil))
3086 (if (not gnus-inhibit-startup-message)
3088 (gnus-group-startup-message)
3090 (gnus-setup-news nil level)
3091 (and gnus-use-dribble-file (gnus-dribble-open))
3092 (gnus-group-list-groups level)
3093 (gnus-configure-windows 'group))))))
3095 (defun gnus-group-startup-message (&optional x y)
3096 "Insert startup message in current buffer."
3097 ;; Insert the message.
3114 ;; And then hack it.
3115 ;; 18 is the longest line.
3116 (indent-rigidly (point-min) (point-max)
3117 (/ (max (- (window-width) (or x 28)) 0) 2))
3118 (goto-char (point-min))
3119 ;; +4 is fuzzy factor.
3120 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
3122 (defun gnus-group-setup-buffer ()
3123 (or (get-buffer gnus-group-buffer)
3125 (switch-to-buffer gnus-group-buffer)
3126 (gnus-add-current-to-buffer-list)
3128 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3130 (defun gnus-group-list-groups (level &optional unread)
3131 "List newsgroups with level LEVEL or lower that have unread alticles.
3132 Default is all subscribed groups.
3133 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3134 (interactive (list (and current-prefix-arg
3135 (prefix-numeric-value current-prefix-arg))))
3136 (if gnus-group-use-permanent-levels
3138 (setq gnus-group-default-list-level
3139 (or level gnus-group-default-list-level))
3140 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3141 (setq level (or level gnus-group-default-list-level
3142 gnus-level-subscribed)))
3143 (gnus-group-setup-buffer) ;May call from out of group buffer
3144 (let ((case-fold-search nil)
3145 (group (gnus-group-group-name)))
3146 (funcall gnus-group-prepare-function level unread nil)
3147 (if (zerop (buffer-size))
3148 (gnus-message 5 gnus-no-groups-message)
3149 (goto-char (point-min))
3151 ;; Go to the first group with unread articles.
3152 (gnus-group-search-forward nil nil nil t)
3153 ;; Find the right group to put point on. If the current group
3154 ;; has disapeared in the new listing, try to find the next
3155 ;; one. If no next one can be found, just leave point at the
3156 ;; first newsgroup in the buffer.
3157 (if (not (gnus-goto-char
3158 (text-property-any (point-min) (point-max)
3159 'gnus-group (intern group))))
3160 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3162 (not (gnus-goto-char
3164 (point-min) (point-max) 'gnus-group
3165 (intern (car (car newsrc)))))))
3166 (setq newsrc (cdr newsrc)))
3167 (or newsrc (progn (goto-char (point-max))
3168 (forward-line -1))))))
3169 ;; Adjust cursor point.
3170 (gnus-group-position-cursor))))
3172 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3173 "List all newsgroups with unread articles of level LEVEL or lower.
3174 If ALL is non-nil, list groups that have no unread articles.
3175 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3176 If REGEXP, only list groups matching REGEXP."
3177 (set-buffer gnus-group-buffer)
3178 (let ((buffer-read-only nil)
3179 (newsrc (cdr gnus-newsrc-alist))
3180 (lowest (or lowest 1))
3181 info clevel unread group)
3183 (if (< lowest gnus-level-zombie)
3184 ;; List living groups.
3186 (setq info (car newsrc)
3189 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3190 (and unread ; This group might be bogus
3192 (string-match regexp group))
3193 (<= (setq clevel (car (cdr info))) level)
3195 (or all ; We list all groups?
3196 (eq unread t) ; We list unactivated groups
3197 (> unread 0) ; We list groups with unread articles
3198 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3199 (gnus-group-insert-group-line
3200 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3202 ;; List dead groups.
3203 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3204 (gnus-group-prepare-flat-list-dead
3205 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3206 gnus-level-zombie ?Z
3208 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3209 (gnus-group-prepare-flat-list-dead
3210 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3211 gnus-level-killed ?K regexp))
3213 (gnus-group-set-mode-line)
3214 (setq gnus-have-all-newsgroups all)
3215 (run-hooks 'gnus-group-prepare-hook)))
3217 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3218 ;; List zombies and killed lists somehwat faster, which was
3219 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3220 ;; this by ignoring the group format specification altogether.
3223 (setq group (car groups)
3224 groups (cdr groups))
3225 (if (or (not regexp)
3226 (string-match regexp group))
3229 (insert (format " %c *: %s\n" mark group))
3230 (add-text-properties
3232 (list 'gnus-group (intern group)
3234 'gnus-level level)))))))
3236 (defun gnus-group-real-name (group)
3237 "Find the real name of a foreign newsgroup."
3238 (if (string-match ":[^:]+$" group)
3239 (substring group (1+ (match-beginning 0)))
3242 (defun gnus-group-prefixed-name (group method)
3243 "Return the whole name from GROUP and METHOD."
3244 (and (stringp method) (setq method (gnus-server-to-method method)))
3245 (concat (format "%s" (car method))
3247 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3248 (not (string= (nth 1 method) "")))
3249 (concat "+" (nth 1 method)))
3252 (defun gnus-group-real-prefix (group)
3253 "Return the prefix of the current group name."
3254 (if (string-match "^[^:]+:" group)
3255 (substring group 0 (match-end 0))
3258 (defun gnus-group-method-name (group)
3259 "Return the method used for selecting GROUP."
3260 (let ((prefix (gnus-group-real-prefix group)))
3261 (if (equal prefix "")
3263 (if (string-match "^[^\\+]+\\+" prefix)
3264 (list (intern (substring prefix 0 (1- (match-end 0))))
3265 (substring prefix (match-end 0) (1- (length prefix))))
3266 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3268 (defun gnus-group-foreign-p (group)
3269 "Return nil if GROUP is native, non-nil if it is foreign."
3270 (string-match ":" group))
3272 (defun gnus-group-set-info (info &optional method-only-group part)
3273 (let* ((entry (gnus-gethash
3274 (or method-only-group (car info)) gnus-newsrc-hashtb))
3276 (info (if method-only-group (nth 2 entry) info)))
3277 (if (not method-only-group)
3280 (error "Trying to change non-existant group %s" method-only-group))
3281 ;; We have recevied parts of the actual group info - either the
3282 ;; select method or the group parameters. We first check
3283 ;; whether we have to extend the info, and if so, do that.
3284 (let ((len (length info))
3285 (total (if (eq part 'method) 5 6)))
3287 (setcdr (nthcdr (1- len) info)
3288 (make-list (- total len) nil)))
3289 ;; Then we enter the new info.
3290 (setcar (nthcdr (1- total) info) part-info)))
3291 ;; We uncompress some lists of marked articles.
3293 (if (not (setq marked (nth 3 info)))
3296 (or (eq 'score (car (car marked)))
3297 (eq 'bookmark (car (car marked)))
3298 (eq 'killed (car (car marked)))
3299 (setcdr (car marked)
3300 (gnus-uncompress-range (cdr (car marked)))))
3301 (setq marked (cdr marked)))))
3304 ;; This is a new group, so we just create it.
3306 (set-buffer gnus-group-buffer)
3308 ;; It's a foreign group...
3309 (gnus-group-make-group
3310 (gnus-group-real-name (car info))
3311 (prin1-to-string (car (nth 4 info)))
3312 (nth 1 (nth 4 info)))
3313 ;; It's a native group.
3314 (gnus-group-make-group
3316 (prin1-to-string (car gnus-select-method))
3317 (nth 1 gnus-select-method)))
3318 (gnus-message 6 "Note: New group created")
3320 (gnus-gethash (gnus-group-prefixed-name
3321 (gnus-group-real-name (car info))
3322 (or (nth 4 info) gnus-select-method))
3323 gnus-newsrc-hashtb))))
3324 ;; Whether it was a new group or not, we now have the entry, so we
3325 ;; can do the update.
3328 (setcar (nthcdr 2 entry) info)
3329 (if (and (not (eq (car entry) t))
3330 (gnus-gethash (car info) gnus-active-hashtb))
3331 (let ((marked (nth 3 info)))
3333 (max 0 (- (length (gnus-list-of-unread-articles
3335 (length (cdr (assq 'tick marked)))
3336 (length (cdr (assq 'dormant marked)))))))))
3337 (error "No such group: %s" (car info)))))
3339 (defun gnus-group-set-method-info (group select-method)
3340 (gnus-group-set-info select-method group 'method))
3342 (defun gnus-group-set-params-info (group params)
3343 (gnus-group-set-info params group 'params))
3345 (defun gnus-group-update-group-line ()
3346 "This function updates the current line in the newsgroup buffer and
3347 moves the point to the colon."
3348 (let* ((buffer-read-only nil)
3349 (group (gnus-group-group-name))
3350 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3353 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3356 (delete-region (point) (progn (forward-line 1) (point)))
3357 (gnus-group-insert-group-line-info group)
3359 (gnus-group-position-cursor)))
3361 (defun gnus-group-insert-group-line-info (group)
3362 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3366 (setq info (nth 2 entry))
3367 (gnus-group-insert-group-line
3368 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3369 (setq active (gnus-gethash group gnus-active-hashtb))
3370 (gnus-group-insert-group-line
3371 nil group (if (member group gnus-zombie-list) gnus-level-zombie
3373 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3375 (defun gnus-group-insert-group-line (gformat group level marked number method)
3376 (let* ((gformat (or gformat gnus-group-line-format-spec))
3377 (active (gnus-gethash group gnus-active-hashtb))
3378 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3379 (number-of-dormant (length (cdr (assq 'dormant marked))))
3380 (number-of-ticked (length (cdr (assq 'tick marked))))
3381 (number-of-ticked-and-dormant
3382 (+ number-of-ticked number-of-dormant))
3383 (number-of-unread-unticked
3384 (if (numberp number) (int-to-string (max 0 number))
3387 (if (numberp number)
3388 (max 0 (- number-total number))
3390 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3391 ((<= level gnus-level-unsubscribed) ?U)
3392 ((= level gnus-level-zombie) ?Z)
3394 (qualified-group (gnus-group-real-name group))
3395 (newsgroup-description
3396 (if gnus-description-hashtb
3397 (or (gnus-gethash group gnus-description-hashtb) "")
3399 (moderated (if (member group gnus-moderated-list) ?m ? ))
3400 (moderated-string (if (eq moderated ?m) "(m)" ""))
3401 (method (gnus-server-get-method group method))
3402 (news-server (or (car (cdr method)) ""))
3403 (news-method (or (car method) ""))
3405 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3409 (> number-of-ticked 0))
3411 (number (if (eq number t) "*" (+ number number-of-dormant
3413 (buffer-read-only nil)
3418 (insert (eval gformat))
3420 (add-text-properties
3421 b (1+ b) (list 'gnus-group (intern group)
3422 'gnus-unread (if (numberp number)
3423 (string-to-int number-of-unread-unticked)
3426 'gnus-level level))))
3428 (defun gnus-group-update-group (group &optional visible-only)
3429 "Update newsgroup info of GROUP.
3430 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3432 (set-buffer gnus-group-buffer)
3433 (let ((buffer-read-only nil)
3435 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3438 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3440 ;; Buffer may be narrowed.
3443 ;; Search a line to modify. If the buffer is large, the search
3444 ;; takes long time. In most cases, current point is on the line
3445 ;; we are looking for. So, first of all, check current line.
3448 (eq (get-text-property (point) 'gnus-group)
3453 (point-min) (point-max) 'gnus-group (intern group)))))
3454 ;; GROUP is listed in current buffer. So, delete old line.
3458 (delete-region (point) (progn (forward-line 1) (point))))
3459 ;; No such line in the buffer, find out where it's supposed to
3460 ;; go, and insert it there (or at the end of the buffer).
3461 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3463 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3469 (point-min) (point-max)
3470 'gnus-group (intern (car (car entry)))))))
3471 (setq entry (cdr entry)))
3472 (if entry (forward-line 1)
3473 (goto-char (point-max)))))))
3474 (if (or visible (not visible-only))
3475 (gnus-group-insert-group-line-info group))
3476 (gnus-group-set-mode-line))))
3478 (defun gnus-group-set-mode-line ()
3479 (if (memq 'group gnus-updated-mode-lines)
3480 (let* ((gformat (or gnus-group-mode-line-format-spec
3481 (setq gnus-group-mode-line-format-spec
3483 gnus-group-mode-line-format
3484 gnus-group-mode-line-format-alist))))
3485 (news-server (car (cdr gnus-select-method)))
3486 (news-method (car gnus-select-method))
3488 (mode-string (eval gformat)))
3489 (setq mode-string (eval gformat))
3490 (if (> (length mode-string) max-len)
3491 (setq mode-string (substring mode-string 0 (- max-len 4))))
3492 (setq mode-line-buffer-identification mode-string)
3493 (set-buffer-modified-p t))))
3495 (defun gnus-group-group-name ()
3496 "Get the name of the newsgroup on the current line."
3497 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3498 (and group (symbol-name group))))
3500 (defun gnus-group-group-level ()
3501 "Get the level of the newsgroup on the current line."
3502 (get-text-property (gnus-point-at-bol) 'gnus-level))
3504 (defun gnus-group-search-forward (&optional backward all level first-too)
3505 "Find the next newsgroup with unread articles.
3506 If BACKWARD is non-nil, find the previous newsgroup instead.
3507 If ALL is non-nil, just find any newsgroup.
3508 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3510 If FIRST-TOO, the current line is also eligeble as a target."
3511 (let ((way (if backward -1 1))
3515 (if (and backward (progn (beginning-of-line)) (bobp))
3517 (or first-too (forward-line way))
3525 (get-text-property (point) 'gnus-unread)))
3526 (or (eq unread t) (and unread (> unread 0))))
3527 (let ((lev (get-text-property
3528 (point) 'gnus-level)))
3529 (and lev (<= (get-text-property
3530 (point) 'gnus-level)
3531 gnus-level-subscribed)))))
3533 (let ((lev (get-text-property (point) 'gnus-level)))
3534 (if (and lev (<= lev level))
3539 (setq pos (point))))
3541 (zerop (forward-line way)))))
3543 (progn (gnus-group-position-cursor) t)
3544 (if pos (goto-char pos) (goto-char beg))
3547 ;;; Gnus group mode commands
3551 (defun gnus-group-mark-group (n &optional unmark)
3552 "Mark the current group."
3554 (let ((buffer-read-only nil)
3558 (setq group (gnus-group-group-name))
3566 (setq gnus-group-marked (delete group gnus-group-marked)))
3568 (setq gnus-group-marked (cons group gnus-group-marked)))
3570 (zerop (gnus-group-next-group 1)))
3572 (gnus-summary-position-cursor)
3575 (defun gnus-group-unmark-group (n)
3576 "Remove the mark from the current group."
3578 (gnus-group-mark-group n 'unmark))
3580 (defun gnus-group-mark-region (unmark beg end)
3581 "Mark all groups between point and mark.
3582 If UNMARK, remove the mark instead."
3583 (interactive "P\nr")
3584 (let ((num (count-lines beg end)))
3587 (- num (gnus-group-mark-group num unmark)))))
3589 (defun gnus-group-remove-mark (group)
3590 (and (gnus-group-goto-group group)
3592 (gnus-group-mark-group 1 'unmark))))
3594 ;; Return a list of groups to work on. Take into consideration N (the
3595 ;; prefix) and the list of marked groups.
3596 (defun gnus-group-process-prefix (n)
3598 (setq n (prefix-numeric-value n))
3599 ;; There is a prefix, so we return a list of the N next
3601 (let ((way (if (< n 0) -1 1))
3606 (setq group (gnus-group-group-name)))
3607 (setq groups (cons group groups))
3609 (forward-line way)))
3612 ;; No prefix, but a list of marked articles.
3613 (reverse gnus-group-marked))
3615 ;; Neither marked articles or a prefix, so we return the
3617 (let ((group (gnus-group-group-name)))
3618 (and group (list group))))))
3620 ;; Selecting groups.
3622 (defun gnus-group-read-group (all &optional no-article group)
3623 "Read news in this newsgroup.
3624 If argument ALL is non-nil, already read articles become readable.
3625 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3627 (let ((group (or group (gnus-group-group-name)))
3628 number active marked entry)
3629 (or group (error "No group on current line"))
3631 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3632 ;; This group might be a dead group. In that case we have to get
3633 ;; the number of unread articles from `gnus-active-hashtb'.
3635 (setq number (car entry))
3636 (if (setq active (gnus-gethash group gnus-active-hashtb))
3637 (setq number (- (1+ (cdr active)) (car active)))))
3638 (gnus-summary-read-group
3639 group (or all (and (numberp number)
3640 (zerop (+ number (length (cdr (assq 'tick marked)))
3641 (length (cdr (assq 'dormant marked)))))))
3644 (defun gnus-group-select-group (all)
3645 "Select this newsgroup.
3646 No article is selected automatically.
3647 If argument ALL is non-nil, already read articles become readable."
3649 (gnus-group-read-group all t))
3651 ;; Enter a group that is not in the group buffer. Non-nil is returned
3652 ;; if selection was successful.
3653 (defun gnus-group-read-ephemeral-group
3654 (group method &optional activate quit-config)
3655 (let ((group (if (gnus-group-foreign-p group) group
3656 (gnus-group-prefixed-name group method))))
3659 (list t nil (list group gnus-level-default-subscribed nil nil
3663 (if quit-config quit-config
3664 (cons (current-buffer) 'summary)))))))
3666 (set-buffer gnus-group-buffer)
3667 (or (gnus-server-opened method)
3668 (gnus-open-server method)
3669 (error "Unable to contact server: %s" (gnus-status-message method)))
3670 (if activate (gnus-request-group group))
3672 (gnus-group-read-group t t group)
3675 (not (equal major-mode 'gnus-group-mode))))
3677 (defun gnus-group-jump-to-group (group)
3678 "Jump to newsgroup GROUP."
3679 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3680 (not (not gnus-read-active-file)))))
3682 (if (equal group "")
3683 (error "empty group name"))
3685 (let ((b (text-property-any (point-min) (point-max)
3686 'gnus-group (intern group))))
3688 ;; Either go to the line in the group buffer...
3690 ;; ... or insert the line.
3692 (gnus-gethash group gnus-active-hashtb)
3693 (gnus-activate-newsgroup group)
3694 (error "%s error: %s" group (gnus-status-message group)))
3696 (gnus-group-update-group group)
3697 (goto-char (text-property-any (point-min) (point-max)
3698 'gnus-group (intern group)))))
3699 ;; Adjust cursor point.
3700 (gnus-group-position-cursor))
3702 (defun gnus-group-goto-group (group)
3703 "Goto to newsgroup GROUP."
3704 (let ((b (text-property-any (point-min) (point-max)
3705 'gnus-group (intern group))))
3706 (and b (goto-char b))))
3708 (defun gnus-group-next-group (n)
3709 "Go to next N'th newsgroup.
3710 If N is negative, search backward instead.
3711 Returns the difference between N and the number of skips actually
3714 (gnus-group-next-unread-group n t))
3716 (defun gnus-group-next-unread-group (n &optional all level)
3717 "Go to next N'th unread newsgroup.
3718 If N is negative, search backward instead.
3719 If ALL is non-nil, choose any newsgroup, unread or not.
3720 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3721 such group can be found, the next group with a level higher than
3723 Returns the difference between N and the number of skips actually
3726 (let ((backward (< n 0))
3729 (gnus-group-search-forward
3730 backward (or (not gnus-group-goto-unread) all) level))
3732 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3733 (if level " on this level or higher" "")))
3736 (defun gnus-group-prev-group (n)
3737 "Go to previous N'th newsgroup.
3738 Returns the difference between N and the number of skips actually
3741 (gnus-group-next-unread-group (- n) t))
3743 (defun gnus-group-prev-unread-group (n)
3744 "Go to previous N'th unread newsgroup.
3745 Returns the difference between N and the number of skips actually
3748 (gnus-group-next-unread-group (- n)))
3750 (defun gnus-group-next-unread-group-same-level (n)
3751 "Go to next N'th unread newsgroup on the same level.
3752 If N is negative, search backward instead.
3753 Returns the difference between N and the number of skips actually
3756 (gnus-group-next-unread-group n t (gnus-group-group-level))
3757 (gnus-group-position-cursor))
3759 (defun gnus-group-prev-unread-group-same-level (n)
3760 "Go to next N'th unread newsgroup on the same level.
3761 Returns the difference between N and the number of skips actually
3764 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3765 (gnus-group-position-cursor))
3767 (defun gnus-group-best-unread-group (&optional exclude-group)
3768 "Go to the group with the highest level.
3769 If EXCLUDE-GROUP, do not go to that group."
3771 (goto-char (point-min))
3774 (while (setq unread (get-text-property (point) 'gnus-unread))
3775 (if (and (numberp unread) (> unread 0))
3777 (or best-point (setq best-point (point)))
3778 (if (and (< (get-text-property (point) 'gnus-level) best)
3779 (or (not exclude-group)
3780 (not (equal exclude-group (gnus-group-group-name)))))
3782 (setq best (get-text-property (point) 'gnus-level))
3783 (setq best-point (point))))))
3785 (if best-point (goto-char best-point))
3786 (gnus-summary-position-cursor)
3787 (and best-point (gnus-group-group-name))))
3789 (defun gnus-group-first-unread-group ()
3790 "Go to the first group with unread articles."
3792 (goto-char (point-min))
3793 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3794 (gnus-group-next-unread-group 1))
3795 (gnus-group-position-cursor))
3797 (defun gnus-group-enter-server-mode ()
3798 "Jump to the server buffer."
3800 (gnus-server-setup-buffer)
3801 (gnus-configure-windows 'server)
3802 (gnus-server-prepare))
3804 (defun gnus-group-make-group (name method &optional address)
3805 "Add a new newsgroup.
3806 The user will be prompted for a NAME, for a select METHOD, and an
3810 (read-string "Group name: ")
3813 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3815 (if (assoc method gnus-valid-select-methods)
3817 (if (memq 'prompt-address
3818 (assoc method gnus-valid-select-methods))
3819 (read-string "Address: ")
3821 (list method nil)))))
3823 (let* ((meth (if address (list (intern method) address) method))
3824 (nname (gnus-group-prefixed-name name meth))
3826 (and (gnus-gethash nname gnus-newsrc-hashtb)
3827 (error "Group %s already exists" nname))
3828 (gnus-group-change-level
3829 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3830 gnus-level-default-subscribed gnus-level-killed
3831 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3832 gnus-newsrc-hashtb) t)
3833 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3835 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3836 (gnus-group-insert-group-line-info nname)
3838 (and (gnus-check-backend-function 'request-create-group nname)
3839 (gnus-request-create-group nname))))
3841 (defun gnus-group-edit-group (group &optional part)
3842 "Edit the group on the current line."
3843 (interactive (list (gnus-group-group-name)))
3844 (let ((done-func '(lambda ()
3845 "Exit editing mode and update the information."
3847 (gnus-group-edit-group-done 'part 'group)))
3848 (part (or part 'info))
3849 (winconf (current-window-configuration))
3851 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3852 (error "No group on current line"))
3853 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3854 (gnus-configure-windows 'edit-group)
3855 (gnus-add-current-to-buffer-list)
3857 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3858 (use-local-map (copy-keymap emacs-lisp-mode-map))
3859 (local-set-key "\C-c\C-c" done-func)
3860 (make-local-variable 'gnus-prev-winconf)
3861 (setq gnus-prev-winconf winconf)
3862 ;; We modify the func to let it know what part it is editing.
3863 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3864 (setcar (cdr (cdr (nth 4 done-func))) group)
3869 ";; Type `C-c C-c' after editing the select method.\n\n")
3871 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3873 ";; Type `C-c C-c' after editing the group info.\n\n")))
3874 (let ((cinfo (gnus-copy-sequence info))
3876 (if (not (setq marked (nth 3 cinfo)))
3879 (or (eq 'score (car (car marked)))
3880 (eq 'bookmark (car (car marked)))
3881 (eq 'killed (car (car marked)))
3882 (setcdr (car marked)
3883 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3884 (setq marked (cdr marked))))
3887 (cond ((eq part 'method)
3888 (or (nth 4 info) "native"))
3895 (defun gnus-group-edit-group-method (group)
3896 "Edit the select method of GROUP."
3897 (interactive (list (gnus-group-group-name)))
3898 (gnus-group-edit-group group 'method))
3900 (defun gnus-group-edit-group-parameters (group)
3901 "Edit the group parameters of GROUP."
3902 (interactive (list (gnus-group-group-name)))
3903 (gnus-group-edit-group group 'params))
3905 (defun gnus-group-edit-group-done (part group)
3906 "Get info from buffer, update variables and jump to the group buffer."
3907 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3908 (goto-char (point-min))
3909 (let ((form (read (current-buffer)))
3910 (winconf gnus-prev-winconf))
3912 (gnus-group-set-info form)
3913 (gnus-group-set-info form group part))
3914 (kill-buffer (current-buffer))
3915 (and winconf (set-window-configuration winconf))
3916 (set-buffer gnus-group-buffer)
3917 (gnus-group-update-group (gnus-group-group-name))
3918 (gnus-group-position-cursor)))
3920 (defun gnus-group-make-help-group ()
3921 "Create the (ding) Gnus documentation group."
3923 (let ((path load-path))
3924 (and (gnus-gethash (setq name (gnus-group-prefixed-name
3925 "gnus-help" '(nndoc "gnus-help")))
3927 (error "Documentation group already exists"))
3929 (not (file-exists-p (concat (file-name-as-directory (car path))
3931 (setq path (cdr path)))
3932 (or path (error "Couldn't find doc group"))
3933 (gnus-group-make-group
3934 (gnus-group-real-name name)
3936 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
3937 (list 'nndoc-article-type 'mbox))))
3938 (gnus-group-position-cursor))
3940 (defun gnus-group-make-doc-group (file type)
3941 "Create a group that uses a single file as the source."
3943 (list (read-file-name "File name: ")
3947 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
3948 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
3949 ((= char ?b) 'babyl)
3950 ((= char ?d) 'digest)
3951 (t (setq mess "%c unknown. " char)
3954 (let* ((file (expand-file-name file))
3955 (name (gnus-generate-new-group-name
3956 (gnus-group-prefixed-name
3957 (file-name-nondirectory file) '(nndoc "")))))
3958 (gnus-group-make-group
3959 (gnus-group-real-name name)
3961 (list 'nndoc-address file)
3962 (list 'nndoc-article-type type)))))
3964 (defun gnus-group-make-archive-group ()
3965 "Create the (ding) Gnus archive group."
3967 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3969 (error "Archive group already exists"))
3970 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3971 (gnus-group-position-cursor))
3973 (defun gnus-group-make-directory-group (dir)
3974 "Create an nndir group.
3975 The user will be prompted for a directory. The contents of this
3976 directory will be used as a newsgroup. The directory should contain
3977 mail messages or news articles in files that have numeric names."
3979 (list (read-file-name "Create group from directory: ")))
3980 (or (file-exists-p dir) (error "No such directory"))
3981 (or (file-directory-p dir) (error "Not a directory"))
3982 (gnus-group-make-group dir "nndir" dir)
3983 (gnus-group-position-cursor))
3985 (defun gnus-group-make-kiboze-group (group address scores)
3986 "Create an nnkiboze group.
3987 The user will be prompted for a name, a regexp to match groups, and
3988 score file entries for articles to include in the group."
3991 (read-string "nnkiboze group name: ")
3992 (read-string "Source groups (regexp): ")
3993 (let ((headers (mapcar (lambda (group) (list group))
3994 '("subject" "from" "number" "date" "message-id"
3995 "references" "chars" "lines" "xref")))
3996 scores header regexp regexps)
3997 (while (not (equal "" (setq header (completing-read
3998 "Match on header: " headers nil t))))
4000 (while (not (equal "" (setq regexp (read-string
4001 (format "Match on %s (string): "
4003 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4004 (setq scores (cons (cons header regexps) scores)))
4006 (gnus-group-make-group group "nnkiboze" address)
4008 (gnus-set-work-buffer)
4009 (let (emacs-lisp-mode-hook)
4010 (pp scores (current-buffer)))
4011 (write-region (point-min) (point-max)
4012 (concat (or gnus-kill-files-directory "~/News")
4013 "nnkiboze:" group "." gnus-score-file-suffix)))
4014 (gnus-group-position-cursor))
4016 (defun gnus-group-add-to-virtual (n vgroup)
4017 "Add the current group to a virtual group."
4019 (list current-prefix-arg
4020 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4022 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4023 (error "%s is not an nnvirtual group" vgroup))
4024 (let* ((groups (gnus-group-process-prefix n))
4025 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4026 (setcar (cdr method)
4028 (nth 1 method) "\\|"
4031 (gnus-group-remove-mark s)
4032 (concat "\\(^" (regexp-quote s) "$\\)"))
4034 (gnus-group-position-cursor))
4036 (defun gnus-group-make-empty-virtual (group)
4037 "Create a new, fresh, empty virtual group."
4038 (interactive "sCreate new, empty virtual group: ")
4039 (let* ((method (list 'nnvirtual ""))
4040 (pgroup (gnus-group-prefixed-name group method)))
4041 ;; Check whether it exists already.
4042 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4043 (error "Group %s already exists." pgroup))
4044 ;; Subscribe the new group after the group on the current line.
4045 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4046 (gnus-group-update-group pgroup)
4048 (gnus-group-position-cursor)))
4050 (defun gnus-group-enter-directory (dir)
4051 "Enter an ephemeral nneething group."
4052 (interactive "DDirectory to read: ")
4053 (let* ((method (list 'nneething dir))
4054 (leaf (gnus-group-prefixed-name
4055 (file-name-nondirectory (directory-file-name dir))
4057 (name (gnus-generate-new-group-name leaf))
4059 (let ((nneething-read-only t))
4060 (or (gnus-group-read-ephemeral-group
4062 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4064 (error "Couldn't enter %s" dir)))))
4066 ;; Group sorting commands
4067 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4069 (defun gnus-group-sort-groups ()
4070 "Sort the group buffer using `gnus-group-sort-function'."
4072 (setq gnus-newsrc-alist
4073 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4074 (gnus-make-hashtable-from-newsrc-alist)
4075 (gnus-group-list-groups nil))
4077 (defun gnus-group-sort-by-alphabet (info1 info2)
4078 (string< (car info1) (car info2)))
4080 (defun gnus-group-sort-by-unread (info1 info2)
4081 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4082 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4083 (< (or (and (numberp n1) n1) 0)
4084 (or (and (numberp n2) n2) 0))))
4086 (defun gnus-group-sort-by-level (info1 info2)
4087 (< (nth 1 info1) (nth 1 info2)))
4089 ;; Group catching up.
4091 (defun gnus-group-catchup-current (n &optional all)
4092 "Mark all articles not marked as unread in current newsgroup as read.
4093 If prefix argument N is numeric, the ARG next newsgroups will be
4094 caught up. If ALL is non-nil, marked articles will also be marked as
4095 read. Cross references (Xref: header) of articles are ignored.
4096 The difference between N and actual number of newsgroups that were
4097 caught up is returned."
4099 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4103 "Do you really want to mark all articles as read? "
4104 "Mark all unread articles as read? "))))
4106 (let ((groups (gnus-group-process-prefix n))
4109 (gnus-group-remove-mark (car groups))
4110 (if (not (gnus-group-goto-group (car groups)))
4112 (gnus-group-catchup (car groups) all)
4113 (gnus-group-update-group-line))
4114 (setq groups (cdr groups)))
4115 (gnus-group-next-unread-group 1)
4118 (defun gnus-group-catchup-current-all (n)
4119 "Mark all articles in current newsgroup as read.
4120 Cross references (Xref: header) of articles are ignored."
4122 (gnus-group-catchup-current n 'all))
4124 (defun gnus-group-catchup (group &optional all)
4125 "Mark all articles in GROUP as read.
4126 If ALL is non-nil, all articles are marked as read.
4127 The return value is the number of articles that were marked as read,
4128 or nil if no action could be taken."
4129 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4131 (marked (nth 3 (nth 2 entry)))
4133 (if (not (numberp (car entry)))
4134 (gnus-message 1 "Can't catch up; non-active group")
4135 ;; Do the updating only if the newsgroup isn't killed.
4138 (setq ticked (if all nil (cdr (assq 'tick marked))))
4139 (gnus-update-read-articles group ticked nil ticked)
4140 (if (and all marked)
4141 (setcar (nthcdr 3 (nth 2 entry))
4142 (delq (assq 'dormant marked) marked))))))
4145 (defun gnus-group-expire-articles (n)
4146 "Expire all expirable articles in the current newsgroup."
4148 (let ((groups (gnus-group-process-prefix n))
4150 (or groups (error "No groups to expire"))
4152 (setq group (car groups)
4153 groups (cdr groups))
4154 (gnus-group-remove-mark group)
4155 (if (not (gnus-check-backend-function 'request-expire-articles group))
4157 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4158 (expirable (if (memq 'total-expire (nth 5 info))
4159 (cons nil (gnus-list-of-read-articles group))
4160 (assq 'expire (nth 3 info)))))
4163 (gnus-request-expire-articles
4164 (cdr expirable) group))))))))
4166 (defun gnus-group-expire-all-groups ()
4167 "Expire all expirable articles in all newsgroups."
4169 (gnus-message 5 "Expiring...")
4170 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4171 (cdr gnus-newsrc-alist))))
4172 (gnus-group-expire-articles nil))
4173 (gnus-message 5 "Expiring...done"))
4175 (defun gnus-group-set-current-level (n level)
4176 "Set the level of the next N groups to LEVEL."
4177 (interactive "P\nnLevel: ")
4178 (or (and (>= level 1) (<= level gnus-level-killed))
4179 (error "Illegal level: %d" level))
4180 (let ((groups (gnus-group-process-prefix n))
4183 (setq group (car groups)
4184 groups (cdr groups))
4185 (gnus-group-remove-mark group)
4186 (gnus-message 6 "Changed level of %s from %d to %d"
4187 group (gnus-group-group-level) level)
4188 (gnus-group-change-level group level
4189 (gnus-group-group-level))
4190 (gnus-group-update-group-line)))
4191 (gnus-group-position-cursor))
4193 (defun gnus-group-unsubscribe-current-group (arg)
4194 "Toggle subscribe from/to unsubscribe current group."
4196 (let ((group (gnus-group-group-name)))
4197 (or group (error "No newsgroup on current line"))
4198 (or arg (setq arg (if (<= (gnus-group-group-level) gnus-level-subscribed)
4199 gnus-level-default-unsubscribed
4200 gnus-level-default-subscribed)))
4201 (gnus-group-unsubscribe-group group arg)
4202 (gnus-group-next-group 1)))
4204 (defun gnus-group-unsubscribe-group (group &optional level)
4205 "Toggle subscribe from/to unsubscribe GROUP.
4206 New newsgroup is added to .newsrc automatically."
4208 (list (completing-read "Group: " gnus-active-hashtb nil
4209 gnus-have-read-active-file)))
4210 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4212 ;; Toggle subscription flag.
4213 (gnus-group-change-level
4214 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4215 gnus-level-subscribed)
4216 (1+ gnus-level-subscribed)
4217 gnus-level-default-subscribed)))
4218 (gnus-group-update-group group))
4219 ((and (stringp group)
4220 (or (not gnus-have-read-active-file)
4221 (gnus-gethash group gnus-active-hashtb)))
4222 ;; Add new newsgroup.
4223 (gnus-group-change-level
4225 (if level level gnus-level-default-subscribed)
4226 (or (and (member group gnus-zombie-list)
4229 (and (gnus-group-group-name)
4230 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4231 (gnus-group-update-group group))
4232 (t (error "No such newsgroup: %s" group)))
4233 (gnus-group-position-cursor)))
4235 (defun gnus-group-transpose-groups (n)
4236 "Move the current newsgroup up N places.
4237 If given a negative prefix, move down instead. The difference between
4238 N and the number of steps taken is retured."
4240 (or (gnus-group-group-name)
4241 (error "No group on current line"))
4242 (gnus-group-kill-group 1)
4244 (forward-line (- n))
4245 (gnus-group-yank-group)
4246 (gnus-group-position-cursor)))
4248 (defun gnus-group-kill-all-zombies ()
4249 "Kill all zombie newsgroups."
4251 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4252 (setq gnus-zombie-list nil)
4253 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4254 (goto-char (point-min))
4255 (gnus-group-position-cursor))
4257 (defun gnus-group-kill-region (begin end)
4258 "Kill newsgroups in current region (excluding current point).
4259 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4262 ;; Exclude a line where current point is on.
4276 (beginning-of-line) ;Important when LINES < 1
4277 (gnus-group-kill-group lines)))
4279 (defun gnus-group-kill-group (n)
4280 "The the next N groups.
4281 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4282 However, only groups that were alive can be yanked; already killed
4283 groups or zombie groups can't be yanked.
4284 The return value is the name of the (last) group that was killed."
4286 (let ((buffer-read-only nil)
4287 (groups (gnus-group-process-prefix n))
4290 (setq group (car groups)
4291 groups (cdr groups))
4292 (gnus-group-remove-mark group)
4293 (setq level (gnus-group-group-level))
4295 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4296 (setq gnus-list-of-killed-groups
4297 (cons (cons (car entry) (nth 2 entry))
4298 gnus-list-of-killed-groups)))
4299 (gnus-group-change-level
4300 (if entry entry group) gnus-level-killed (if entry nil level)))
4301 (gnus-group-position-cursor)
4304 (defun gnus-group-yank-group (&optional arg)
4305 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4306 inserting it before the current newsgroup. The numeric ARG specifies
4307 how many newsgroups are to be yanked. The name of the (last)
4308 newsgroup yanked is returned."
4310 (if (not arg) (setq arg 1))
4311 (let (info group prev)
4312 (while (>= (setq arg (1- arg)) 0)
4313 (if (not (setq info (car gnus-list-of-killed-groups)))
4314 (error "No more newsgroups to yank"))
4315 (setq group (nth 2 info))
4316 ;; Find which newsgroup to insert this one before - search
4317 ;; backward until something suitable is found. If there are no
4318 ;; other newsgroups in this buffer, just make this newsgroup the
4320 (setq prev (gnus-group-group-name))
4321 (gnus-group-change-level
4322 info (nth 2 info) gnus-level-killed
4323 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4325 (gnus-group-insert-group-line-info (nth 1 info))
4326 (setq gnus-list-of-killed-groups
4327 (cdr gnus-list-of-killed-groups)))
4329 (gnus-group-position-cursor)
4332 (defun gnus-group-list-all-groups (arg)
4333 "List all newsgroups with level ARG or lower.
4334 Default is gnus-level-unsubscribed, which lists all subscribed and most
4335 unsubscribed groups."
4337 (setq arg (or arg gnus-level-unsubscribed))
4338 (gnus-group-list-groups arg t))
4340 (defun gnus-group-list-killed ()
4341 "List all killed newsgroups in the group buffer."
4343 (if (not gnus-killed-list)
4344 (gnus-message 6 "No killed groups")
4345 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4346 (goto-char (point-min)))
4347 (gnus-group-position-cursor))
4349 (defun gnus-group-list-zombies ()
4350 "List all zombie newsgroups in the group buffer."
4352 (if (not gnus-zombie-list)
4353 (gnus-message 6 "No zombie groups")
4354 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4355 (goto-char (point-min)))
4356 (gnus-group-position-cursor))
4358 (defun gnus-group-get-new-news (&optional arg)
4359 "Get newly arrived articles.
4360 If ARG is non-nil, it should be a number between one and nine to
4361 specify which levels you are interested in re-scanning."
4363 (run-hooks 'gnus-get-new-news-hook)
4365 (if gnus-group-use-permanent-levels
4367 (setq gnus-group-default-list-level level)
4368 (setq level (or gnus-group-default-list-level
4369 gnus-level-subscribed))))
4370 (if (and gnus-read-active-file (not level))
4372 (gnus-read-active-file)
4373 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
4374 (let ((gnus-read-active-file nil))
4375 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))))
4376 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels level)
4377 gnus-group-default-list-level
4378 gnus-level-subscribed)
4379 gnus-have-all-newsgroups)))
4381 (defun gnus-group-get-new-news-this-group (n)
4382 "Check for newly arrived news in the current group (and the N-1 next groups).
4383 The difference between N and the number of newsgroup checked is returned.
4384 If N is negative, this group and the N-1 previous groups will be checked."
4386 (let* ((groups (gnus-group-process-prefix n))
4387 (ret (if (numberp n) (- n (length groups)) 0))
4388 (w-p (window-start))
4391 (setq group (car groups)
4392 groups (cdr groups))
4393 (gnus-group-remove-mark group)
4394 (or (gnus-get-new-news-in-group group)
4397 (message "%s error: %s" group (gnus-status-message group))
4399 ;; !!! I don't know why the buffer scrolls forward when updating
4400 ;; the first line in the group buffer, but it does. So we set the
4401 ;; window start forcibly.
4402 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4404 (gnus-summary-position-cursor)
4407 (defun gnus-get-new-news-in-group (group)
4409 (gnus-activate-newsgroup group)
4411 (gnus-get-unread-articles-in-group
4412 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4413 (gnus-gethash group gnus-active-hashtb))
4414 (gnus-group-update-group-line)
4417 (defun gnus-group-fetch-faq (group)
4418 "Fetch the FAQ for the current group."
4419 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4420 (or group (error "No group name given"))
4421 (let ((file (concat gnus-group-faq-directory group)))
4422 (if (not (file-exists-p file))
4423 (error "No such file: %s" file)
4426 (defun gnus-group-describe-group (force &optional group)
4427 "Display a description of the current newsgroup."
4429 (and force (setq gnus-description-hashtb nil))
4430 (let ((group (or group (gnus-group-group-name)))
4432 (or group (error "No group name given"))
4433 (and (or gnus-description-hashtb
4434 (setq desc (gnus-group-get-description group))
4435 (gnus-read-descriptions-file))
4437 (or desc (gnus-gethash group gnus-description-hashtb)
4438 "No description available")))))
4440 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4441 (defun gnus-group-describe-all-groups (force)
4442 "Pop up a buffer with descriptons of all newsgroups."
4444 (and force (setq gnus-description-hashtb nil))
4445 (if (not (or gnus-description-hashtb
4446 (gnus-read-descriptions-file)))
4447 (error "Couldn't request descriptions file"))
4448 (let ((buffer-read-only nil)
4454 (insert (format " *: %-20s %s\n" (symbol-name group)
4455 (symbol-value group)))
4456 (add-text-properties
4457 b (1+ b) (list 'gnus-group group
4458 'gnus-unread t 'gnus-marked nil
4459 'gnus-level (1+ gnus-level-subscribed))))
4460 gnus-description-hashtb)
4461 (goto-char (point-min))
4462 (gnus-group-position-cursor)))
4464 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4465 (defun gnus-group-apropos (regexp &optional search-description)
4466 "List all newsgroups that have names that match a regexp."
4467 (interactive "sGnus apropos (regexp): ")
4469 (obuf (current-buffer))
4471 ;; Go through all newsgroups that are known to Gnus.
4474 (and (string-match regexp (symbol-name group))
4475 (setq groups (cons (symbol-name group) groups))))
4477 ;; Go through all descriptions that are known to Gnus.
4478 (if search-description
4481 (and (string-match regexp (symbol-value group))
4482 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4483 (setq groups (cons (symbol-name group) groups))))
4484 gnus-description-hashtb))
4486 (gnus-message 3 "No groups matched \"%s\"." regexp)
4487 ;; Print out all the groups.
4489 (pop-to-buffer "*Gnus Help*")
4490 (buffer-disable-undo (current-buffer))
4492 (setq groups (sort groups 'string<))
4494 ;; Groups may be entered twice into the list of groups.
4495 (if (not (string= (car groups) prev))
4497 (insert (setq prev (car groups)) "\n")
4498 (if (and gnus-description-hashtb
4499 (setq des (gnus-gethash (car groups)
4500 gnus-description-hashtb)))
4501 (insert " " des "\n"))))
4502 (setq groups (cdr groups)))
4503 (goto-char (point-min))))
4504 (pop-to-buffer obuf)))
4506 (defun gnus-group-description-apropos (regexp)
4507 "List all newsgroups that have names or desccriptions that match a regexp."
4508 (interactive "sGnus description apropos (regexp): ")
4509 (if (not (or gnus-description-hashtb
4510 (gnus-read-descriptions-file)))
4511 (error "Couldn't request descriptions file"))
4512 (gnus-group-apropos regexp t))
4514 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4515 (defun gnus-group-list-matching (level regexp &optional all lowest)
4516 "List all groups with unread articles that match REGEXP.
4517 If the prefix LEVEL is non-nil, it should be a number that says which
4518 level to cut off listing groups.
4519 If ALL, also list groups with no unread articles.
4520 If LOWEST, don't list groups with level lower than LOWEST."
4521 (interactive "P\nsList newsgroups matching: ")
4522 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4523 all (or lowest 1) regexp)
4524 (goto-char (point-min))
4525 (gnus-group-position-cursor))
4527 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4528 "List all groups that match REGEXP.
4529 If the prefix LEVEL is non-nil, it should be a number that says which
4530 level to cut off listing groups.
4531 If LOWEST, don't list groups with level lower than LOWEST."
4532 (interactive "P\nsList newsgroups matching: ")
4533 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4535 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4536 (defun gnus-group-save-newsrc ()
4537 "Save the Gnus startup files."
4539 (gnus-save-newsrc-file))
4541 (defun gnus-group-restart (&optional arg)
4542 "Force Gnus to read the .newsrc file."
4544 (gnus-save-newsrc-file)
4545 (gnus-setup-news 'force)
4546 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4548 (defun gnus-group-read-init-file ()
4549 "Read the Gnus elisp init file."
4551 (gnus-read-init-file))
4553 (defun gnus-group-check-bogus-groups ()
4554 "Check bogus newsgroups."
4556 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4557 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4559 (defun gnus-group-edit-global-kill (article &optional group)
4560 "Edit the global kill file.
4561 If GROUP, edit that local kill file instead."
4563 (setq gnus-current-kill-article article)
4564 (gnus-kill-file-edit-file group)
4566 (substitute-command-keys
4567 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4569 (defun gnus-group-edit-local-kill (article group)
4570 "Edit a local kill file."
4571 (interactive (list nil (gnus-group-group-name)))
4572 (gnus-group-edit-global-kill article group))
4574 (defun gnus-group-force-update ()
4575 "Update `.newsrc' file."
4577 (gnus-save-newsrc-file))
4579 (defun gnus-group-suspend ()
4580 "Suspend the current Gnus session.
4581 In fact, cleanup buffers except for group mode buffer.
4582 The hook gnus-suspend-gnus-hook is called before actually suspending."
4584 (run-hooks 'gnus-suspend-gnus-hook)
4585 ;; Kill Gnus buffers except for group mode buffer.
4586 (let ((group-buf (get-buffer gnus-group-buffer)))
4587 ;; Do this on a separate list in case the user does a ^G before we finish
4588 (let ((gnus-buffer-list
4589 (delq group-buf (delq gnus-dribble-buffer
4590 (append gnus-buffer-list nil)))))
4591 (while gnus-buffer-list
4592 (gnus-kill-buffer (car gnus-buffer-list))
4593 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4596 (setq gnus-buffer-list (list group-buf))
4597 (bury-buffer group-buf)
4598 (delete-windows-on group-buf t)))))
4600 (defun gnus-group-clear-dribble ()
4601 "Clear all information from the dribble buffer."
4603 (gnus-dribble-clear))
4605 (defun gnus-group-exit ()
4606 "Quit reading news after updating .newsrc.eld and .newsrc.
4607 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4609 (if (or noninteractive ;For gnus-batch-kill
4610 (zerop (buffer-size)) ;No news is good news.
4611 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4612 (not gnus-interactive-exit) ;Without confirmation
4614 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4616 (run-hooks 'gnus-exit-gnus-hook)
4617 (gnus-save-newsrc-file)
4618 (gnus-offer-save-summaries)
4619 (gnus-close-backends)
4620 (gnus-clear-system))))
4622 (defun gnus-close-backends ()
4623 ;; Send a close request to all backends that support such a request.
4624 (let ((methods gnus-valid-select-methods)
4627 (if (fboundp (setq func (intern (concat (car (car methods))
4628 "-request-close"))))
4630 (setq methods (cdr methods)))))
4632 (defun gnus-group-quit ()
4633 "Quit reading news without updating .newsrc.eld or .newsrc.
4634 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4636 (if (or noninteractive ;For gnus-batch-kill
4637 (zerop (buffer-size))
4638 (not (gnus-server-opened gnus-select-method))
4640 (not gnus-current-startup-file)
4642 (format "Quit reading news without saving %s? "
4643 (file-name-nondirectory gnus-current-startup-file))))
4645 (run-hooks 'gnus-exit-gnus-hook)
4647 (gnus-close-backends)
4648 (gnus-clear-system))))
4650 (defun gnus-offer-save-summaries ()
4651 (let ((buffers (buffer-list)))
4655 ;; We look for buffers with "Summary" in the name.
4656 (string-match "Summary" (or (buffer-name (car buffers)) ""))
4658 (set-buffer (car buffers))
4659 ;; We check that this is, indeed, a summary buffer.
4660 (eq major-mode 'gnus-summary-mode))
4661 ;; We ask the user whether she wants to save the info.
4663 (format "Update summary buffer %s? " (buffer-name)))
4664 ;; We do it by simply exiting.
4665 (gnus-summary-exit))
4666 (setq buffers (cdr buffers))))))
4668 (defun gnus-group-describe-briefly ()
4669 "Give a one line description of the group mode commands."
4672 (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")))
4674 (defun gnus-group-browse-foreign-server (method)
4675 "Browse a foreign news server.
4676 If called interactively, this function will ask for a select method
4677 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4678 If not, METHOD should be a list where the first element is the method
4679 and the second element is the address."
4681 (list (let ((how (completing-read
4683 (append gnus-valid-select-methods gnus-server-alist)
4685 ;; We either got a backend name or a virtual server name.
4686 ;; If the first, we also need an address.
4687 (if (assoc how gnus-valid-select-methods)
4689 ;; Suggested by mapjph@bath.ac.uk.
4692 (mapcar (lambda (server) (list server))
4693 gnus-secondary-servers)))
4694 ;; We got a server name, so we find the method.
4695 (gnus-server-to-method how)))))
4696 (gnus-browse-foreign-server method))
4700 ;;; Browse Server Mode
4703 (defvar gnus-browse-mode-hook nil)
4704 (defvar gnus-browse-mode-map nil)
4705 (put 'gnus-browse-mode 'mode-class 'special)
4707 (if gnus-browse-mode-map
4709 (setq gnus-browse-mode-map (make-keymap))
4710 (suppress-keymap gnus-browse-mode-map)
4711 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4712 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
4713 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4714 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4715 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4716 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4717 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4718 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4719 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4720 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
4721 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4722 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4723 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4724 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4725 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4726 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4727 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4728 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4731 (defvar gnus-browse-current-method nil)
4732 (defvar gnus-browse-return-buffer nil)
4734 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4736 (defun gnus-browse-foreign-server (method &optional return-buffer)
4737 (setq gnus-browse-current-method method)
4738 (setq gnus-browse-return-buffer return-buffer)
4739 (let ((gnus-select-method method)
4741 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4742 (or (gnus-server-opened method)
4743 (gnus-open-server method)
4744 (error "Unable to contact server: %s" (gnus-status-message method)))
4745 (or (gnus-request-list method)
4746 (error "Couldn't request list: %s" (gnus-status-message method)))
4747 (get-buffer-create gnus-browse-buffer)
4748 (gnus-add-current-to-buffer-list)
4749 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4750 (gnus-configure-windows 'browse)
4751 (buffer-disable-undo (current-buffer))
4752 (let ((buffer-read-only nil))
4755 (setq mode-line-buffer-identification
4757 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4759 (set-buffer nntp-server-buffer)
4760 (let ((cur (current-buffer)))
4761 (goto-char (point-min))
4762 (or (string= gnus-ignored-newsgroups "")
4763 (delete-matching-lines gnus-ignored-newsgroups))
4764 (while (re-search-forward
4765 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4766 (goto-char (match-end 1))
4767 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4769 (max 0 (- (1+ (read cur)) (read cur))))
4771 (setq groups (sort groups
4773 (string< (car l1) (car l2)))))
4774 (let ((buffer-read-only nil))
4776 (setq group (car groups))
4778 (format "K%7d: %s\n" (cdr group) (car group)))
4779 (setq groups (cdr groups))))
4780 (switch-to-buffer (current-buffer))
4781 (goto-char (point-min))
4782 (gnus-group-position-cursor)))
4784 (defun gnus-browse-mode ()
4785 "Major mode for browsing a foreign server.
4787 All normal editing commands are switched off.
4789 \\<gnus-browse-mode-map>
4790 The only things you can do in this buffer is
4792 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
4793 The group will be inserted into the group buffer upon exit from this
4796 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
4798 3) `\\[gnus-browse-exit]' to return to the group buffer."
4800 (kill-all-local-variables)
4801 (if gnus-visual (gnus-browse-make-menu-bar))
4802 (setq mode-line-modified "-- ")
4803 (make-local-variable 'mode-line-format)
4804 (setq mode-line-format (copy-sequence mode-line-format))
4805 (and (equal (nth 3 mode-line-format) " ")
4806 (setcar (nthcdr 3 mode-line-format) ""))
4807 (setq major-mode 'gnus-browse-mode)
4808 (setq mode-name "Browse Server")
4809 (setq mode-line-process nil)
4810 (use-local-map gnus-browse-mode-map)
4811 (buffer-disable-undo (current-buffer))
4812 (setq truncate-lines t)
4813 (setq buffer-read-only t)
4814 (run-hooks 'gnus-browse-mode-hook))
4816 (defun gnus-browse-read-group (&optional no-article)
4817 "Enter the group at the current line."
4819 (let ((group (gnus-browse-group-name)))
4820 (or (gnus-group-read-ephemeral-group
4821 group gnus-browse-current-method nil
4822 (cons (current-buffer) 'browse))
4823 (error "Couldn't enter %s" group))))
4825 (defun gnus-browse-select-group ()
4826 "Select the current group."
4828 (gnus-browse-read-group 'no))
4830 (defun gnus-browse-next-group (n)
4831 "Go to the next group."
4835 (gnus-group-position-cursor)))
4837 (defun gnus-browse-prev-group (n)
4838 "Go to the next group."
4840 (gnus-browse-next-group (- n)))
4842 (defun gnus-browse-unsubscribe-current-group (arg)
4843 "(Un)subscribe to the next ARG groups."
4846 (error "No group at current line."))
4847 (let ((ward (if (< arg 0) -1 1))
4849 (while (and (> arg 0)
4851 (gnus-browse-unsubscribe-group)
4852 (zerop (gnus-browse-next-group ward)))
4853 (setq arg (1- arg)))
4854 (gnus-group-position-cursor)
4855 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
4858 (defun gnus-browse-group-name ()
4861 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
4863 (gnus-group-prefixed-name
4864 (buffer-substring (match-beginning 1) (match-end 1))
4865 gnus-browse-current-method))))
4867 (defun gnus-browse-unsubscribe-group ()
4869 (buffer-read-only nil)
4873 (if (= (following-char) ?K) (setq sub t))
4874 (setq group (gnus-browse-group-name))
4879 (gnus-group-change-level
4880 (list t group gnus-level-default-subscribed
4881 nil nil gnus-browse-current-method)
4882 gnus-level-default-subscribed gnus-level-killed
4883 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
4886 (gnus-group-change-level
4887 group gnus-level-killed gnus-level-default-subscribed)
4891 (defun gnus-browse-exit ()
4892 "Quit browsing and return to the group buffer."
4894 (if (eq major-mode 'gnus-browse-mode)
4895 (kill-buffer (current-buffer)))
4896 (if gnus-browse-return-buffer
4897 (gnus-configure-windows 'server)
4898 (gnus-configure-windows 'group)))
4900 (defun gnus-browse-describe-briefly ()
4901 "Give a one line description of the group mode commands."
4904 (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")))
4908 ;;; Gnus summary mode
4911 (defvar gnus-summary-mode-map nil)
4912 (defvar gnus-summary-mark-map nil)
4913 (defvar gnus-summary-mscore-map nil)
4914 (defvar gnus-summary-article-map nil)
4915 (defvar gnus-summary-thread-map nil)
4916 (defvar gnus-summary-goto-map nil)
4917 (defvar gnus-summary-exit-map nil)
4918 (defvar gnus-summary-various-map nil)
4919 (defvar gnus-summary-interest-map nil)
4920 (defvar gnus-summary-sort-map nil)
4921 (defvar gnus-summary-backend-map nil)
4922 (defvar gnus-summary-save-map nil)
4923 (defvar gnus-summary-wash-map nil)
4924 (defvar gnus-summary-help-map nil)
4926 (put 'gnus-summary-mode 'mode-class 'special)
4928 (if gnus-summary-mode-map
4930 (setq gnus-summary-mode-map (make-keymap))
4931 (suppress-keymap gnus-summary-mode-map)
4933 ;; Non-orthogonal keys
4935 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4936 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4937 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4938 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4939 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4940 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4941 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4942 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4943 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4944 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4945 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4946 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4947 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4948 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4949 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4950 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4951 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4952 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4953 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4954 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4955 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4956 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4957 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4958 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4959 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4960 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4961 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4962 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4963 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4964 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4965 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4966 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4967 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4968 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4969 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4970 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4971 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4972 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4973 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4974 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4975 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4976 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4977 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4978 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4979 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4980 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4981 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4982 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4983 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4984 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4985 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4986 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4987 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4988 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4989 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4990 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4991 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4992 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4993 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4994 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4995 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4996 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4997 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4998 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4999 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5000 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5001 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5002 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5003 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5004 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5005 (define-key gnus-summary-mode-map "V" 'gnus-version)
5006 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5007 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5008 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5009 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5010 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5011 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5012 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5013 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5014 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5015 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5016 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5017 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5018 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5019 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5020 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5021 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5024 ;; Sort of orthogonal keymap
5025 (define-prefix-command 'gnus-summary-mark-map)
5026 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5027 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5028 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5029 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5030 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5031 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5032 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5033 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5034 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5035 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5036 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5037 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5038 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5039 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5040 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5041 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5042 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5043 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5044 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5045 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5046 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5047 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5048 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5049 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5051 (define-prefix-command 'gnus-summary-mscore-map)
5052 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
5053 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5054 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5055 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5056 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5058 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
5060 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5062 (define-prefix-command 'gnus-summary-goto-map)
5063 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5064 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5065 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5066 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5067 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5068 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5069 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5070 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5071 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5072 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5073 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5074 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5075 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5076 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5079 (define-prefix-command 'gnus-summary-thread-map)
5080 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5081 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5082 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5083 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5084 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5085 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5086 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5087 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5088 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5089 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5090 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5091 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5092 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5093 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5096 (define-prefix-command 'gnus-summary-exit-map)
5097 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5098 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5099 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5100 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5101 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5102 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5103 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5104 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5105 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5106 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5107 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5110 (define-prefix-command 'gnus-summary-article-map)
5111 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5112 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5113 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5114 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5115 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5116 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5117 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5118 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5119 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5120 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5121 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5122 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5123 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
5124 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
5125 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5126 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
5127 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
5128 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5131 (define-prefix-command 'gnus-summary-wash-map)
5132 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5133 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
5134 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
5135 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
5136 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5137 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5138 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
5139 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5140 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5141 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
5142 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
5143 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
5145 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
5146 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
5147 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
5148 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
5149 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
5150 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5153 (define-prefix-command 'gnus-summary-help-map)
5154 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5155 (define-key gnus-summary-help-map "v" 'gnus-version)
5156 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5157 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5158 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5159 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5162 (define-prefix-command 'gnus-summary-backend-map)
5163 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5164 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5165 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5166 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5167 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5168 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5169 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5170 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5171 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5174 (define-prefix-command 'gnus-summary-save-map)
5175 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5176 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5177 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5178 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5179 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5180 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5181 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5182 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5184 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5186 (define-prefix-command 'gnus-summary-various-map)
5187 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
5188 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
5189 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5190 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5191 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5192 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5193 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5194 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5195 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
5196 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5197 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5199 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
5201 (define-prefix-command 'gnus-summary-sort-map)
5202 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5203 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5204 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5205 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5206 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5207 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5209 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5210 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5216 (defun gnus-summary-mode ()
5217 "Major mode for reading articles.
5219 All normal editing commands are switched off.
5220 \\<gnus-summary-mode-map>
5221 Each line in this buffer represents one article. To read an
5222 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5223 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5226 You can also post articles and send mail from this buffer. To
5227 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5228 of an article, type `\\[gnus-summary-reply]'.
5230 There are approx. one gazillion commands you can execute in this
5231 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5233 The following commands are available:
5235 \\{gnus-summary-mode-map}"
5237 (if gnus-visual (gnus-summary-make-menu-bar))
5238 (kill-all-local-variables)
5239 (let ((locals gnus-summary-local-variables))
5241 (if (consp (car locals))
5243 (make-local-variable (car (car locals)))
5244 (set (car (car locals)) (eval (cdr (car locals)))))
5245 (make-local-variable (car locals))
5246 (set (car locals) nil))
5247 (setq locals (cdr locals))))
5248 (gnus-make-thread-indent-array)
5249 (gnus-update-format-specifications)
5250 (setq mode-line-modified "-- ")
5251 (make-local-variable 'mode-line-format)
5252 (setq mode-line-format (copy-sequence mode-line-format))
5253 (and (equal (nth 3 mode-line-format) " ")
5254 (setcar (nthcdr 3 mode-line-format) ""))
5255 (setq major-mode 'gnus-summary-mode)
5256 (setq mode-name "Summary")
5257 (make-local-variable 'minor-mode-alist)
5258 (use-local-map gnus-summary-mode-map)
5259 (buffer-disable-undo (current-buffer))
5260 (setq buffer-read-only t) ;Disable modification
5261 (setq truncate-lines t)
5262 (setq selective-display t)
5263 (setq selective-display-ellipses t) ;Display `...'
5264 (setq buffer-display-table gnus-summary-display-table)
5265 (run-hooks 'gnus-summary-mode-hook))
5267 (defun gnus-summary-make-display-table ()
5268 ;; Change the display table. Odd characters have a tendency to mess
5269 ;; up nicely formatted displays - we make all possible glyphs
5270 ;; display only a single character.
5272 ;; We start from the standard display table, if any.
5273 (setq gnus-summary-display-table
5274 (or (copy-sequence standard-display-table)
5275 (make-display-table)))
5276 ;; Nix out all the control chars...
5278 (while (>= (setq i (1- i)) 0)
5279 (aset gnus-summary-display-table i [??])))
5280 ;; ... but not newline, of course.
5281 (aset gnus-summary-display-table ?\n nil)
5282 ;; We nix out any glyphs over 126 that are not set already.
5284 (while (>= (setq i (1- i)) 127)
5285 ;; Only modify if the entry is nil.
5286 (or (aref gnus-summary-display-table i)
5287 (aset gnus-summary-display-table i [??])))))
5289 (defun gnus-summary-clear-local-variables ()
5290 (let ((locals gnus-summary-local-variables))
5292 (if (consp (car locals))
5293 (and (vectorp (car (car locals)))
5294 (set (car (car locals)) nil))
5295 (and (vectorp (car locals))
5296 (set (car locals) nil)))
5297 (setq locals (cdr locals)))))
5299 (defun gnus-mouse-pick-article (e)
5302 (gnus-summary-next-page nil t))
5304 (defun gnus-summary-setup-buffer (group)
5305 "Initialize summary buffer."
5306 (let ((buffer (concat "*Summary " group "*")))
5307 (if (get-buffer buffer)
5310 (not gnus-newsgroup-threads))
5311 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5312 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5313 (gnus-add-current-to-buffer-list)
5315 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5316 (setq gnus-newsgroup-name group)
5319 (defun gnus-set-global-variables ()
5320 ;; Set the global equivalents of the summary buffer-local variables
5321 ;; to the latest values they had. These reflect the summary buffer
5322 ;; that was in action when the last article was fetched.
5323 (if (eq major-mode 'gnus-summary-mode)
5325 (setq gnus-summary-buffer (current-buffer))
5326 (let ((name gnus-newsgroup-name)
5327 (marked gnus-newsgroup-marked)
5328 (unread gnus-newsgroup-unreads)
5329 (headers gnus-current-headers)
5330 (score-file gnus-current-score-file))
5332 (set-buffer gnus-group-buffer)
5333 (setq gnus-newsgroup-name name)
5334 (setq gnus-newsgroup-marked marked)
5335 (setq gnus-newsgroup-unreads unread)
5336 (setq gnus-current-headers headers)
5337 (setq gnus-current-score-file score-file))))))
5339 (defun gnus-summary-insert-dummy-line (sformat subject number)
5341 (setq sformat gnus-summary-dummy-line-format-spec))
5345 (insert (eval sformat))
5346 (add-text-properties
5348 (list 'gnus-number number
5349 'gnus-mark gnus-dummy-mark
5352 (defvar gnus-thread-indent-array nil)
5353 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5354 (defun gnus-make-thread-indent-array ()
5356 (if (and gnus-thread-indent-array
5357 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5359 (setq gnus-thread-indent-array (make-vector 201 "")
5360 gnus-thread-indent-array-level gnus-thread-indent-level)
5362 (aset gnus-thread-indent-array n
5363 (make-string (* n gnus-thread-indent-level) ? ))
5366 (defun gnus-summary-insert-line
5367 (sformat header level current unread replied expirable subject-or-nil
5368 &optional dummy score)
5369 (or sformat (setq sformat gnus-summary-line-format-spec))
5370 (let* ((indentation (aref gnus-thread-indent-array level))
5371 (lines (header-lines header))
5372 (score (or score gnus-summary-default-score 0))
5373 (score-char (if (or (null gnus-summary-default-score)
5374 (= score gnus-summary-default-score)) ?
5375 (if (< score gnus-summary-default-score)
5376 gnus-score-below-mark gnus-score-over-mark)))
5377 (replied (if replied gnus-replied-mark ? ))
5378 (from (header-from header))
5379 (name-address (funcall gnus-extract-address-components from))
5380 (address (car (cdr name-address)))
5381 (name (or (car name-address) (car (cdr name-address))))
5382 (subject (header-subject header))
5383 (number (header-number header))
5384 (opening-bracket (if dummy ?\< ?\[))
5385 (closing-bracket (if dummy ?\> ?\]))
5386 (buffer-read-only nil)
5387 (b (progn (beginning-of-line) (point))))
5388 (or (numberp lines) (setq lines 0))
5389 (insert (eval sformat))
5390 (add-text-properties
5391 b (1+ b) (list 'gnus-number number
5392 'gnus-mark (or unread gnus-unread-mark)
5393 'gnus-level level))))
5395 (defun gnus-summary-update-line (&optional dont-update)
5396 ;; Update summary line after change.
5397 (or (not gnus-summary-default-score)
5398 gnus-summary-inhibit-highlight
5399 (let ((gnus-summary-inhibit-highlight t)
5400 (article (gnus-summary-article-number)))
5403 (if (and gnus-summary-mark-below
5404 (< (gnus-summary-article-score)
5405 gnus-summary-mark-below))
5406 (and (not (memq article gnus-newsgroup-marked))
5407 (not (memq article gnus-newsgroup-dormant))
5408 (memq article gnus-newsgroup-unreads)
5409 (gnus-summary-mark-article nil gnus-low-score-mark))
5410 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5411 (gnus-summary-mark-article nil gnus-unread-mark))))
5413 (run-hooks 'gnus-summary-update-hook))))))
5415 (defun gnus-summary-update-lines (&optional beg end)
5416 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5417 (let ((beg (or beg (point-min)))
5418 (end (or end (point-max))))
5420 (set-buffer gnus-summary-buffer)
5422 (while (and (not (eobp)) (< (point) end))
5423 (gnus-summary-update-line)
5424 (forward-line 1)))))
5426 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5427 ;; Sum up all elements (and sub-elements) in a list.
5431 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5434 (if (> number 1) gnus-not-empty-thread-mark
5435 gnus-empty-thread-mark)
5438 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5439 "Start reading news in newsgroup GROUP.
5440 If SHOW-ALL is non-nil, already read articles are also listed.
5441 If NO-ARTICLE is non-nil, no article is selected initially."
5442 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5443 (let* ((new-group (gnus-summary-setup-buffer group))
5444 (did-select (and new-group (gnus-select-newsgroup group show-all)))
5445 (method (car (gnus-find-method-for-group group))))
5448 (gnus-set-global-variables)
5449 (gnus-kill-buffer kill-buffer)
5450 (gnus-configure-windows 'summary)
5451 (gnus-set-mode-line 'summary)
5452 (gnus-summary-position-cursor)
5456 (and (eq major-mode 'gnus-summary-mode)
5457 (not (equal (current-buffer) kill-buffer))
5459 (kill-buffer (current-buffer))
5460 (set-buffer gnus-group-buffer)
5461 (gnus-group-next-unread-group 1)))
5462 (message "Can't select group")
5464 ((eq did-select 'quit)
5465 (and (eq major-mode 'gnus-summary-mode)
5466 (not (equal (current-buffer) kill-buffer))
5467 (kill-buffer (current-buffer)))
5468 (gnus-kill-buffer kill-buffer)
5469 (gnus-configure-windows 'group)
5470 (gnus-group-next-unread-group 1)
5473 (gnus-set-global-variables)
5474 ;; Save the active value in effect when the group was entered.
5475 (setq gnus-newsgroup-active
5477 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5478 ;; You can change the subjects in this hook.
5479 (run-hooks 'gnus-select-group-hook)
5480 ;; Do score processing.
5481 (and gnus-use-scoring (gnus-possibly-score-headers))
5482 ;; Update the format specifiers.
5483 (gnus-update-format-specifications)
5484 ;; Generate the summary buffer.
5485 (gnus-summary-prepare)
5486 (if (zerop (buffer-size))
5487 (cond (gnus-newsgroup-dormant
5488 (gnus-summary-show-all-dormant))
5489 ((and gnus-newsgroup-scored show-all)
5490 (gnus-summary-show-all-expunged))))
5491 ;; Function `gnus-apply-kill-file' must be called in this hook.
5492 (run-hooks 'gnus-apply-kill-hook)
5493 (if (zerop (buffer-size))
5495 ;; This newsgroup is empty.
5496 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5497 (gnus-message 6 "No unread news")
5498 (gnus-kill-buffer kill-buffer)
5502 ;; (let ((gnus-summary-buffer kill-buffer))
5503 ;; (gnus-configure-windows 'group))))
5504 ;; Hide conversation thread subtrees. We cannot do this in
5505 ;; gnus-summary-prepare-hook since kill processing may not
5506 ;; work with hidden articles.
5507 (and gnus-show-threads
5508 gnus-thread-hide-subtree
5509 (gnus-summary-hide-all-threads))
5510 ;; Show first unread article if requested.
5511 (goto-char (point-min))
5512 (if (and (not no-article)
5513 gnus-auto-select-first
5514 (gnus-summary-first-unread-article))
5516 (gnus-configure-windows 'summary))
5517 (gnus-set-mode-line 'summary)
5518 (gnus-summary-position-cursor)
5519 ;; If in async mode, we send some info to the backend.
5520 (and gnus-newsgroup-async
5521 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5522 (gnus-request-asynchronous
5524 (if (and gnus-asynchronous-article-function
5525 (fboundp gnus-asynchronous-article-function))
5526 (funcall gnus-asynchronous-article-function
5527 gnus-newsgroup-threads)
5528 gnus-newsgroup-threads)))
5529 (gnus-kill-buffer kill-buffer)
5530 (if (not (get-buffer-window gnus-group-buffer))
5532 (let ((obuf (current-buffer)))
5533 (set-buffer gnus-group-buffer)
5534 (and (gnus-group-goto-group group)
5536 (set-buffer obuf))))
5539 (defun gnus-summary-prepare ()
5540 ;; Generate the summary buffer.
5541 (let ((buffer-read-only nil))
5543 (gnus-summary-prepare-threads
5544 (if gnus-show-threads
5545 (gnus-gather-threads
5547 (if (and gnus-summary-expunge-below
5548 (not gnus-fetch-old-headers))
5549 (gnus-make-threads-and-expunge)
5550 (gnus-make-threads))))
5551 gnus-newsgroup-headers)
5553 ;; Erase header retrieval message.
5554 (gnus-summary-update-lines)
5556 ;; Remove the final newline.
5557 ;;(goto-char (point-max))
5559 ;; Call hooks for modifying summary buffer.
5560 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5561 (goto-char (point-min))
5562 (run-hooks 'gnus-summary-prepare-hook)))
5564 (defun gnus-subject-equal (s1 s2)
5566 ((numberp gnus-summary-gather-subject-limit)
5567 (string= (if (> (length s1) gnus-summary-gather-subject-limit)
5568 (substring s1 0 gnus-summary-gather-subject-limit)
5570 (if (> (length s2) gnus-summary-gather-subject-limit)
5571 (substring s2 0 gnus-summary-gather-subject-limit)
5573 ((eq 'fuzzy gnus-summary-gather-subject-limit)
5574 (string= (gnus-simplify-subject-fuzzy s1)
5575 (gnus-simplify-subject-fuzzy s2)))
5579 (defun gnus-gather-threads (threads)
5580 "Gather threads that have lost their roots."
5581 (if (not gnus-summary-make-false-root)
5583 (let ((hashtb (gnus-make-hashtable 1023))
5586 thread subject hthread whole-subject)
5589 (setq subject (header-subject (car (car threads)))))
5590 (if gnus-summary-gather-subject-limit
5591 (or (and (numberp gnus-summary-gather-subject-limit)
5592 (> (length subject) gnus-summary-gather-subject-limit)
5594 (substring subject 0
5595 gnus-summary-gather-subject-limit)))
5596 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5597 (setq subject (gnus-simplify-subject-fuzzy subject))))
5598 (setq subject (gnus-simplify-subject-re subject)))
5600 (gnus-gethash subject hashtb))
5602 (or (stringp (car (car hthread)))
5603 (setcar hthread (list whole-subject (car hthread))))
5604 (setcdr (car hthread) (nconc (cdr (car hthread))
5605 (list (car threads))))
5606 (setcdr prev (cdr threads))
5607 (setq threads prev))
5608 (gnus-sethash subject threads hashtb))
5610 (setq threads (cdr threads)))
5613 (defun gnus-make-threads ()
5614 ;; This function takes the dependencies already made by
5615 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5616 ;; through the dependecies in the hash table and finds all the
5617 ;; roots. Roots do not refer back to any valid articles.
5619 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5620 (gnus-build-old-threads))
5623 (if (not (car (symbol-value refs)))
5624 (setq roots (append (cdr (symbol-value refs)) roots))
5625 ;; Ok, these refer back to valid articles, but if
5626 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5627 ;; the root has the same subject as its children. The children
5628 ;; that do not are made into roots and removed from the list
5630 (or gnus-thread-ignore-subject
5631 (let* ((prev (symbol-value refs))
5632 (subject (gnus-simplify-subject-re
5633 (header-subject (car prev))))
5634 (headers (cdr prev)))
5636 (if (not (string= subject
5637 (gnus-simplify-subject-re
5638 (header-subject (car headers)))))
5640 (setq roots (cons (car headers) roots))
5641 (setcdr prev (cdr headers)))
5642 (setq prev headers))
5643 (setq headers (cdr headers)))))))
5644 gnus-newsgroup-dependencies)
5646 (mapcar 'gnus-trim-thread
5648 (mapcar 'gnus-cut-thread
5649 (mapcar 'gnus-make-sub-thread roots))))))
5651 (defun gnus-make-threads-and-expunge ()
5652 ;; This function takes the dependencies already made by
5653 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5654 ;; through the dependecies in the hash table and finds all the
5655 ;; roots. Roots do not refer back to any valid articles.
5656 (let ((default (or gnus-summary-default-score 0))
5657 (below gnus-summary-expunge-below)
5659 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5660 (gnus-build-old-threads))
5663 (if (not (car (symbol-value refs)))
5664 ;; These articles do not refer back to any other articles -
5666 (let ((headers (cdr (symbol-value refs))))
5667 ;; We weed out the low-scored articles.
5669 (if (not (< (or (cdr (assq (header-number (car headers))
5670 gnus-newsgroup-scored)) default)
5673 (setq roots (cons (car headers) roots))
5674 ;; It is below, so we mark it as read.
5675 (setq gnus-newsgroup-unreads
5676 (delq (header-number (car headers))
5677 gnus-newsgroup-unreads)))
5678 (setq headers (cdr headers))))
5679 ;; Ok, these refer back to valid articles, but if
5680 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5681 ;; the root has the same subject as its children. The children
5682 ;; that do not are made into roots and removed from the list
5684 (or gnus-thread-ignore-subject
5685 (let* ((prev (symbol-value refs))
5686 (subject (gnus-simplify-subject-re
5687 (header-subject (car prev))))
5688 (headers (cdr prev)))
5690 (if (not (string= subject
5691 (gnus-simplify-subject-re
5692 (header-subject (car headers)))))
5694 (if (not (< (or (cdr (assq (header-number (car headers))
5695 gnus-newsgroup-scored))
5697 (setq roots (cons (car headers) roots))
5698 (setq gnus-newsgroup-unreads
5699 (delq (header-number (car headers))
5700 gnus-newsgroup-unreads)))
5701 (setcdr prev (cdr headers)))
5702 (setq prev headers))
5703 (setq headers (cdr headers)))))
5704 ;; If this article is expunged, some of the children might be
5706 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
5707 gnus-newsgroup-scored)) default)
5709 (let* ((prev (symbol-value refs))
5710 (headers (cdr prev)))
5712 (setq article (header-number (car headers)))
5713 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5715 (progn (setq roots (cons (car headers) roots))
5716 (setq prev headers))
5717 (setq gnus-newsgroup-unreads
5718 (delq article gnus-newsgroup-unreads))
5719 (setcdr prev (cdr headers)))
5720 (setq headers (cdr headers))))
5721 ;; It was not expunged, but we look at expunged children.
5722 (let* ((prev (symbol-value refs))
5723 (headers (cdr prev))
5726 (setq article (header-number (car headers)))
5727 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5730 (setq gnus-newsgroup-unreads
5731 (delq article gnus-newsgroup-unreads))
5732 (setcdr prev (cdr headers)))
5733 (setq headers (cdr headers)))))))
5734 gnus-newsgroup-dependencies)
5736 (mapcar 'gnus-trim-thread
5738 (mapcar 'gnus-cut-thread
5739 (mapcar 'gnus-make-sub-thread roots))))))
5741 (defun gnus-cut-thread (thread)
5742 ;; Remove leaf dormant or ancient articles from THREAD.
5743 (let ((head (car thread))
5744 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5745 (if (and (null tail)
5746 (let ((number (header-number head)))
5747 (or (memq number gnus-newsgroup-ancient)
5748 (memq number gnus-newsgroup-dormant)
5749 (and gnus-summary-expunge-below
5750 (eq gnus-fetch-old-headers 'some)
5751 (< (or (cdr (assq number gnus-newsgroup-scored))
5752 gnus-summary-default-score 0)
5753 gnus-summary-expunge-below)
5755 (setq gnus-newsgroup-unreads
5756 (delq number gnus-newsgroup-unreads))
5759 (list (cons head tail)))))
5761 (defun gnus-trim-thread (thread)
5762 ;; Remove root ancient articles with only one child from THREAD.
5763 (if (and (eq gnus-fetch-old-headers 'some)
5764 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5765 (= (length thread) 2))
5766 (gnus-trim-thread (nth 1 thread))
5769 (defun gnus-make-sub-thread (root)
5770 ;; This function makes a sub-tree for a node in the tree.
5771 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5772 gnus-newsgroup-dependencies)))))
5773 (cons root (mapcar 'gnus-make-sub-thread children))))
5775 (defun gnus-build-old-threads ()
5776 ;; Look at all the articles that refer back to old articles, and
5777 ;; fetch the headers for the articles that aren't there. This will
5778 ;; build complete threads - if the roots haven't been expired by the
5783 (if (not (car (symbol-value refs)))
5785 (setq heads (cdr (symbol-value refs)))
5787 (if (not (memq (header-number (car heads))
5788 gnus-newsgroup-dormant))
5790 (setq id (symbol-name refs))
5791 (while (and (setq id (gnus-build-get-header id))
5792 (not (car (gnus-gethash
5793 id gnus-newsgroup-dependencies)))))
5795 (setq heads (cdr heads)))))))
5796 gnus-newsgroup-dependencies)))
5798 (defun gnus-build-get-header (id)
5799 ;; Look through the buffer of NOV lines and find the header to
5800 ;; ID. Enter this line into the dependencies hash table, and return
5801 ;; the id of the parent article (if any).
5802 (let ((deps gnus-newsgroup-dependencies)
5806 (set-buffer nntp-server-buffer)
5807 (goto-char (point-min))
5808 (while (and (not found) (search-forward id nil t))
5810 (setq found (looking-at
5811 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5812 (regexp-quote id))))
5813 (or found (beginning-of-line 2)))
5818 (setq header (gnus-nov-parse-line
5819 (read (current-buffer)) deps))
5820 (setq ref (header-references header))
5821 (string-match "\\(<[^>]+>\\) *$" ref)
5822 (substring ref (match-beginning 1) (match-end 1))))))
5824 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5825 gnus-newsgroup-ancient (cons (header-number header)
5826 gnus-newsgroup-ancient))))))
5828 ;; Re-build the thread containing ID.
5829 (defun gnus-rebuild-thread (id)
5830 (let ((dep gnus-newsgroup-dependencies)
5831 (buffer-read-only nil)
5832 parent headers refs thread art)
5833 (while (and id (setq headers
5834 (car (setq art (gnus-gethash (downcase id) dep)))))
5836 (setq id (and (setq refs (header-references headers))
5837 (string-match "\\(<[^>]+>\\) *$" refs)
5838 (substring refs (match-beginning 1) (match-end 1)))))
5839 (setq thread (gnus-make-sub-thread (car parent)))
5840 (gnus-rebuild-remove-articles thread)
5841 (let ((beg (point)))
5842 (gnus-summary-prepare-threads (list thread) 0)
5843 (gnus-summary-update-lines beg (point)))))
5845 ;; Delete all lines in the summary buffer that correspond to articles
5847 (defun gnus-rebuild-remove-articles (thread)
5848 (and (gnus-summary-goto-subject (header-number (car thread)))
5850 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
5852 (defun gnus-sort-threads (threads)
5853 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5854 (let ((fun gnus-thread-sort-functions))
5856 (setq threads (sort threads (car fun))
5860 (defun gnus-thread-header (thread)
5861 ;; Return header of first article in THREAD.
5863 (if (stringp (car thread))
5864 (car (car (cdr thread)))
5868 (defun gnus-thread-sort-by-number (h1 h2)
5869 "Sort threads by root article number."
5870 (let ((h1 (gnus-thread-header h1))
5871 (h2 (gnus-thread-header h2)))
5872 (< (header-number h1) (header-number h2))))
5874 (defun gnus-thread-sort-by-author (h1 h2)
5875 "Sort threads by root author."
5876 (let ((h1 (gnus-thread-header h1))
5877 (h2 (gnus-thread-header h2)))
5879 (let ((extract (funcall
5880 gnus-extract-address-components (header-from h1))))
5881 (or (car extract) (cdr extract)))
5882 (let ((extract (funcall
5883 gnus-extract-address-components (header-from h2))))
5884 (or (car extract) (cdr extract))))))
5886 (defun gnus-thread-sort-by-subject (h1 h2)
5887 "Sort threads by root subject."
5888 (let ((h1 (gnus-thread-header h1))
5889 (h2 (gnus-thread-header h2)))
5891 (downcase (gnus-simplify-subject (header-subject h1)))
5892 (downcase (gnus-simplify-subject (header-subject h2))))))
5894 (defun gnus-thread-sort-by-date (h1 h2)
5895 "Sort threads by root article date."
5896 (let ((h1 (gnus-thread-header h1))
5897 (h2 (gnus-thread-header h2)))
5899 (gnus-sortable-date (header-date h1))
5900 (gnus-sortable-date (header-date h2)))))
5902 (defun gnus-thread-sort-by-score (h1 h2)
5903 "Sort threads by root article score.
5904 Unscored articles will be counted as havin a score of zero."
5905 (let ((h1 (gnus-thread-header h1))
5906 (h2 (gnus-thread-header h2)))
5907 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5908 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5909 (> (or (cdr s1) gnus-summary-default-score 0)
5910 (or (cdr s2) gnus-summary-default-score 0)))))
5912 (defun gnus-thread-sort-by-total-score (h1 h2)
5913 "Sort threads by the sum of all scores in the thread.
5914 Unscored articles will be counted as havin a score of zero."
5915 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5917 (defun gnus-thread-total-score (thread)
5918 ;; This function find the total score of THREAD.
5920 (if (stringp (car thread))
5921 (apply gnus-thread-score-function 0
5922 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5923 (gnus-thread-total-score-1 thread))
5924 (gnus-thread-total-score-1 (list thread))))
5926 (defun gnus-thread-total-score-1 (root)
5927 ;; This function find the total score of the thread below ROOT.
5928 (setq root (car root))
5929 (apply gnus-thread-score-function
5930 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5931 gnus-summary-default-score 0)
5932 (mapcar 'gnus-thread-total-score
5933 (cdr (gnus-gethash (downcase (header-id root))
5934 gnus-newsgroup-dependencies)))))
5936 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5937 (defvar gnus-tmp-prev-subject "")
5938 (defvar gnus-tmp-adopt-thread nil)
5940 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5941 (defun gnus-summary-prepare-threads
5942 (threads level &optional not-child no-subject cull)
5943 "Prepare summary buffer from THREADS and indentation LEVEL.
5944 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5945 or a straight list of headers."
5946 (let (thread header number subject clevel)
5948 (setq thread (car threads)
5949 threads (cdr threads))
5950 ;; If `thread' is a cons, hierarchical threads are used. If not,
5951 ;; `thread' is the header.
5953 (setq header (car thread))
5954 (setq header thread)
5956 (or (memq (setq number (header-number header))
5957 gnus-newsgroup-dormant)
5958 (and gnus-summary-expunge-below
5959 (< (or (cdr (assq number gnus-newsgroup-scored))
5960 gnus-summary-default-score 0)
5961 gnus-summary-expunge-below)))
5964 (setq gnus-newsgroup-unreads
5965 (delq number gnus-newsgroup-unreads)))))
5968 ;; The header is a dummy root.
5969 (cond ((eq gnus-summary-make-false-root 'adopt)
5970 ;; We let the first article adopt the rest.
5971 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
5972 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5973 (setq thread (cdr (cdr thread)))
5975 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5976 (setq thread (cdr thread))))
5977 ((eq gnus-summary-make-false-root 'dummy)
5978 ;; We output a dummy root.
5979 (gnus-summary-insert-dummy-line
5980 nil header (header-number (car (car (cdr thread)))))
5982 ((eq gnus-summary-make-false-root 'empty)
5983 ;; We print the articles with empty subject fields.
5984 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
5985 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5986 (setq thread (cdr (cdr thread)))
5988 (gnus-summary-prepare-threads
5989 (list (car thread)) 0 nil
5990 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5992 (gnus-simplify-subject-re
5993 (header-subject (car (car thread))))
5994 (gnus-simplify-subject-re header))))))
5995 (setq thread (cdr thread))))
5997 ;; We do not make a root for the gathered
5998 ;; sub-threads at all.
6000 ;; Print the sub-threads.
6001 (and (consp thread) (cdr thread)
6002 (gnus-summary-prepare-threads (cdr thread) clevel)))
6003 ;; The header is a real article.
6005 (setq number (header-number header)
6006 subject (header-subject header))
6007 (and gnus-newsgroup-async
6008 (setq gnus-newsgroup-threads
6009 (cons (cons (header-number header)
6010 (header-lines header)) gnus-newsgroup-threads)))
6011 (gnus-summary-insert-line
6012 nil header level nil
6013 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6014 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6015 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6016 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6017 (t gnus-ancient-mark))
6018 (memq number gnus-newsgroup-replied)
6019 (memq number gnus-newsgroup-expirable)
6021 gnus-summary-same-subject
6022 (if (or (zerop level)
6023 (and gnus-thread-ignore-subject
6025 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6026 (gnus-simplify-subject-re subject)))))
6028 gnus-summary-same-subject))
6030 (cdr (assq number gnus-newsgroup-scored)))
6031 (setq gnus-tmp-prev-subject subject)
6032 ;; Recursively print subthreads.
6033 (and (consp thread) (cdr thread)
6034 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
6036 (defun gnus-select-newsgroup (group &optional read-all)
6037 "Select newsgroup GROUP.
6038 If READ-ALL is non-nil, all articles in the group are selected."
6039 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6040 (info (nth 2 entry))
6041 articles header-marks)
6042 (gnus-check-news-server
6043 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6045 (or (gnus-server-opened gnus-current-select-method)
6046 (gnus-open-server gnus-current-select-method)
6047 (error "Couldn't open server"))
6049 (or (and (eq (car entry) t)
6050 (gnus-activate-newsgroup (car info)))
6051 (gnus-request-group group t)
6053 (kill-buffer (current-buffer))
6054 (error "Couldn't request group %s: %s"
6055 group (gnus-status-message group))))
6057 (setq gnus-newsgroup-name group)
6058 (setq gnus-newsgroup-unselected nil)
6059 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6061 (and gnus-asynchronous
6062 (gnus-check-backend-function
6063 'request-asynchronous gnus-newsgroup-name)
6064 (setq gnus-newsgroup-async
6065 (gnus-request-asynchronous gnus-newsgroup-name)))
6067 (setq articles (gnus-articles-to-read group read-all))
6071 (gnus-message 3 "Couldn't select newsgroup")
6073 ((eq articles 0) nil)
6075 ;; Init the dependencies hash table.
6076 (setq gnus-newsgroup-dependencies
6077 (gnus-make-hashtable (length articles)))
6078 ;; Retrieve the headers and read them in.
6079 (setq gnus-newsgroup-headers
6080 (if (eq 'nov (setq gnus-headers-retrieved-by
6081 (gnus-retrieve-headers
6082 (if gnus-fetch-old-headers
6083 (cons 1 articles) articles)
6084 gnus-newsgroup-name)))
6086 (gnus-get-newsgroup-headers-xover articles))
6087 (gnus-get-newsgroup-headers)))
6088 ;; If we were to fetch old headers, but the backend didn't
6089 ;; support XOVER, then it is possible we fetched one article
6090 ;; that we shouldn't have. If that's the case, we pop it off the
6092 (and (not (eq gnus-headers-retrieved-by 'nov))
6093 gnus-fetch-old-headers
6094 gnus-newsgroup-headers
6095 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
6096 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
6097 ;; Remove cancelled articles from the list of unread articles.
6098 (setq gnus-newsgroup-unreads
6099 (gnus-set-sorted-intersection
6100 gnus-newsgroup-unreads
6101 (mapcar (lambda (headers) (header-number headers))
6102 gnus-newsgroup-headers)))
6103 ;; Adjust and set lists of article marks.
6106 (gnus-adjust-marked-articles info)
6107 (setq gnus-newsgroup-marked
6108 (cdr (assq 'tick (setq marked (nth 3 info)))))
6109 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
6110 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
6111 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
6112 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
6113 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
6114 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
6115 (setq gnus-newsgroup-processable nil)))
6116 ;; Check whether auto-expire is to be done in this group.
6117 (setq gnus-newsgroup-auto-expire
6118 (or (and (stringp gnus-auto-expirable-newsgroups)
6119 (string-match gnus-auto-expirable-newsgroups group))
6120 (memq 'auto-expire (nth 5 info))))
6121 ;; First and last article in this newsgroup.
6122 (and gnus-newsgroup-headers
6123 (setq gnus-newsgroup-begin
6124 (header-number (car gnus-newsgroup-headers)))
6125 (setq gnus-newsgroup-end
6126 (header-number (gnus-last-element gnus-newsgroup-headers))))
6127 (setq gnus-reffed-article-number -1)
6128 ;; GROUP is successfully selected.
6129 (or gnus-newsgroup-headers t)))))
6131 (defun gnus-articles-to-read (group read-all)
6132 ;; Find out what articles the user wants to read.
6134 ;; Select all articles if `read-all' is non-nil, or if all the
6135 ;; unread articles are dormant articles.
6136 (if (or (and read-all (not (numberp read-all)))
6137 (= (length gnus-newsgroup-unreads)
6138 (length gnus-newsgroup-dormant)))
6139 (gnus-uncompress-range
6140 (gnus-gethash group gnus-active-hashtb))
6141 gnus-newsgroup-unreads))
6142 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6143 (scored (length scored-list))
6144 (number (length articles))
6145 (marked (+ (length gnus-newsgroup-marked)
6146 (length gnus-newsgroup-dormant)))
6153 (cond ((and (or (<= scored marked)
6155 (numberp gnus-large-newsgroup)
6156 (> number gnus-large-newsgroup))
6160 "How many articles from %s (default %d): "
6161 gnus-newsgroup-name number))))
6162 (if (string-equal input "")
6164 ((and (> scored marked) (< scored number))
6168 "%s %s (%d scored, %d total): "
6169 "How many articles from"
6170 group scored number))))
6171 (if (string-equal input "")
6176 (setq select (if (stringp select) (string-to-number select) select))
6177 (if (or (null select) (zerop select))
6179 (if (and (not (zerop scored)) (<= (abs select) scored))
6181 (setq articles (sort scored-list '<))
6182 (setq number (length articles)))
6183 (setq articles (copy-sequence articles)))
6185 (setq total-articles articles)
6187 (if (< (abs select) number)
6189 ;; Select the N oldest articles.
6190 (setcdr (nthcdr (1- (abs select)) articles) nil)
6191 ;; Select the N most recent articles.
6192 (setq articles (nthcdr (- number select) articles))))
6193 (setq gnus-newsgroup-unselected
6194 (gnus-sorted-intersection
6195 gnus-newsgroup-unreads
6196 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6199 (defun gnus-killed-articles (killed articles)
6202 (if (inline (gnus-member-of-range (car articles) killed))
6203 (setq out (cons (car articles) out)))
6204 (setq articles (cdr articles)))
6207 (defun gnus-adjust-marked-articles (info &optional active)
6208 "Remove all marked articles that are no longer legal."
6209 (let ((marked-lists (nth 3 info))
6210 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6212 ;; There are many types of marked articles.
6214 (setq m (cdr (setq prev (car marked-lists))))
6215 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6216 ;; Make sure that all ticked articles are a subset of the
6217 ;; unread/unselected articles.
6219 (if (or (memq (car m) gnus-newsgroup-unreads)
6220 (memq (car m) gnus-newsgroup-unselected))
6222 (setcdr prev (cdr m)))
6224 ((eq 'score (car prev))
6225 ;; Scored articles should be a subset of
6226 ;; unread/unselected articles.
6228 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6229 (memq (car (car m)) gnus-newsgroup-unreads))
6231 (setcdr prev (cdr m)))
6233 ((eq 'bookmark (car prev))
6234 ;; Bookmarks should be a subset of active articles.
6236 (if (< (car (car m)) (car active))
6237 (setcdr prev (cdr m))
6240 ((eq 'killed (car prev))
6241 ;; Articles that have been through the kill process are
6242 ;; to be a subset of active articles.
6243 (while (and m (< (or (and (numberp (car m)) (car m))
6246 (setcdr prev (cdr m))
6248 (if (and m (< (or (and (numberp (car m)) (car m))
6251 (setcar (if (numberp (car m)) m (car m)) (car active))))
6252 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6253 ;; The replied and expirable articles have to be articles
6256 (if (< (car m) (car active))
6257 (setcdr prev (cdr m))
6260 (setq marked-lists (cdr marked-lists)))
6261 ;; Remove all lists that are empty.
6262 (setq marked-lists (nth 3 info))
6265 (while (= 1 (length (car marked-lists)))
6266 (setq marked-lists (cdr marked-lists)))
6267 (setq m (cdr (setq prev marked-lists)))
6269 (if (= 1 (length (car m)))
6270 (setcdr prev (cdr m))
6273 (setcar (nthcdr 3 info) marked-lists)))
6274 ;; Finally, if there are no marked lists at all left, and if there
6275 ;; are no elements after the lists in the info list, we just chop
6276 ;; the info list off before the marked lists.
6277 (and (null marked-lists)
6278 (not (nthcdr 4 info))
6279 (setcdr (nthcdr 2 info) nil)))
6282 (defun gnus-set-marked-articles
6283 (info ticked replied expirable killed dormant bookmark score)
6284 "Enter the various lists of marked articles into the newsgroup info list."
6286 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6287 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6288 (and expirable (setq newmarked (cons (cons 'expire expirable)
6290 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6291 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6292 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6294 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6297 (setcar (nthcdr 3 info) newmarked)
6298 (if (not (nthcdr 4 info))
6299 (setcdr (nthcdr 2 info) nil)
6300 (setcar (nthcdr 3 info) nil)))
6302 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
6304 (defun gnus-add-marked-articles (group type articles &optional info force)
6305 ;; Add ARTICLES of TYPE to the info of GROUP.
6306 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6307 ;; add, but replace marked articles of TYPE with ARTICLES.
6308 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6311 (and (not (setq marked (nthcdr 3 info)))
6312 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6313 (and (not (setq m (assq type (car marked))))
6314 (setcar marked (cons (cons type articles) (car marked))))
6317 (nconc m articles)))))
6319 (defun gnus-set-mode-line (where)
6320 "This function sets the mode line of the article or summary buffers.
6321 If WHERE is `summary', the summary mode line format will be used."
6322 (if (memq where gnus-updated-mode-lines)
6325 (set-buffer gnus-summary-buffer)
6326 (let* ((mformat (if (eq where 'article)
6327 gnus-article-mode-line-format-spec
6328 gnus-summary-mode-line-format-spec))
6329 (group-name gnus-newsgroup-name)
6330 (article-number (or gnus-current-article 0))
6331 (unread (- (length gnus-newsgroup-unreads)
6332 (length gnus-newsgroup-dormant)))
6333 (unread-and-unticked
6334 (- unread (length gnus-newsgroup-marked)))
6335 (unselected (length gnus-newsgroup-unselected))
6336 (unread-and-unselected
6337 (cond ((and (zerop unread-and-unticked)
6338 (zerop unselected)) "")
6340 (format "{%d more}" unread-and-unticked))
6341 (t (format "{%d(+%d) more}"
6342 unread-and-unticked unselected))))
6344 (if gnus-current-headers
6345 (header-subject gnus-current-headers) ""))
6346 (max-len (and gnus-mode-non-string-length
6347 (- (frame-width) gnus-mode-non-string-length)))
6348 header) ;; passed as argument to any user-format-funcs
6349 (setq mode-string (eval mformat))
6350 (or (numberp max-len)
6351 (setq max-len (length mode-string)))
6352 (if (< max-len 4) (setq max-len 4))
6353 (if (> (length mode-string) max-len)
6355 (concat (substring mode-string 0 (- max-len 3))
6357 (setq mode-string (format (format "%%-%ds" max-len)
6359 (setq mode-line-buffer-identification mode-string)
6360 (set-buffer-modified-p t))))
6362 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6363 "Go through the HEADERS list and add all Xrefs to a hash table.
6364 The resulting hash table is returned, or nil if no Xrefs were found."
6365 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6367 (gnus-group-foreign-p from-newsgroup)
6369 (assoc (symbol-name (car from-method))
6370 gnus-valid-select-methods))))
6371 (gnus-group-real-prefix from-newsgroup)))
6372 (xref-hashtb (make-vector 63 0))
6373 start group entry number xrefs header)
6375 (setq header (car headers))
6376 (if (and (setq xrefs (header-xref header))
6377 (not (memq (header-number header) unreads)))
6380 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6381 (setq start (match-end 0))
6382 (setq group (concat prefix (substring xrefs (match-beginning 1)
6385 (string-to-int (substring xrefs (match-beginning 2)
6387 (if (setq entry (gnus-gethash group xref-hashtb))
6388 (setcdr entry (cons number (cdr entry)))
6389 (gnus-sethash group (cons number nil) xref-hashtb)))))
6390 (setq headers (cdr headers)))
6391 (if start xref-hashtb nil)))
6393 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6394 "Look through all the headers and mark the Xrefs as read."
6395 (let ((virtual (memq 'virtual
6396 (assoc (symbol-name (car (gnus-find-method-for-group
6398 gnus-valid-select-methods)))
6399 name entry read info xref-hashtb idlist active num range exps method
6402 (set-buffer gnus-group-buffer)
6403 (if (setq xref-hashtb
6404 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6407 (if (string= from-newsgroup (setq name (symbol-name group)))
6409 (setq idlist (symbol-value group))
6410 ;; Dead groups are not updated.
6412 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6414 (if (stringp (setq nth4 (nth 4 info)))
6415 (setq nth4 (gnus-server-to-method nth4))))
6416 ;; Only do the xrefs if the group has the same
6417 ;; select method as the group we have just read.
6418 (or (gnus-methods-equal-p
6419 nth4 (gnus-find-method-for-group from-newsgroup))
6422 (setq method (gnus-find-method-for-group
6424 (and (equal (car nth4) (car method))
6425 (equal (nth 1 nth4) (nth 1 method))))
6426 gnus-use-cross-reference
6427 (or (not (eq gnus-use-cross-reference t))
6429 ;; Only do cross-references on subscribed
6430 ;; groups, if that is what is wanted.
6431 (<= (nth 1 info) gnus-level-subscribed)))
6434 ;; Set the new list of read articles in this group.
6435 (setq active (gnus-gethash name gnus-active-hashtb))
6436 ;; First peel off all illegal article numbers.
6439 (ticked (cdr (assq 'tick (nth 3 info))))
6440 (dormant (cdr (assq 'dormant (nth 3 info))))
6445 (if (or (> id (cdr active))
6449 (setq idlist (delq id idlist)))
6450 (and (memq id expirable)
6451 (setq exps (cons id exps)))
6452 (setq ids (cdr ids)))))
6453 ;; Update expirable articles.
6454 (gnus-add-marked-articles nil 'expirable exps info)
6458 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6459 (setcar (nthcdr 2 info)
6463 (setq idlist (sort idlist '<)))))
6464 ;; Then we have to re-compute how many unread
6465 ;; articles there are in this group.
6470 (setq num (- (1+ (cdr active)) (car active))))
6471 ((not (listp (cdr range)))
6472 (setq num (- (cdr active) (- (1+ (cdr range))
6476 (if (numberp (car range))
6478 (setq num (+ num (- (1+ (cdr (car range)))
6479 (car (car range))))))
6480 (setq range (cdr range)))
6481 (setq num (- (cdr active) num))))
6482 ;; Update the number of unread articles.
6486 (length (cdr (assq 'tick (nth 3 info))))
6488 (cdr (assq 'dormant (nth 3 info)))))))
6489 ;; Update the group buffer.
6490 (gnus-group-update-group name t)))))))
6493 (defun gnus-methods-equal-p (m1 m2)
6494 (let ((m1 (or m1 gnus-select-method))
6495 (m2 (or m2 gnus-select-method)))
6497 (and (eq (car m1) (car m2))
6498 (or (not (memq 'address (assoc (symbol-name (car m1))
6499 gnus-valid-select-methods)))
6500 (equal (nth 1 m1) (nth 1 m2)))))))
6502 (defsubst gnus-header-value ()
6503 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6505 (defvar gnus-newsgroup-none-id 0)
6507 (defun gnus-get-newsgroup-headers ()
6508 (setq gnus-article-internal-prepare-hook nil)
6509 (let ((cur nntp-server-buffer)
6510 (dependencies gnus-newsgroup-dependencies)
6511 headers char article id dep end)
6513 (set-buffer nntp-server-buffer)
6514 (goto-char (point-min))
6515 ;; Search to the beginning of the next header. Error messages
6516 ;; do not begin with 2 or 3.
6517 (while (re-search-forward "^[23][0-9]+ " nil t)
6518 (let ((header (make-vector 9 nil))
6519 (c (following-char))
6520 (case-fold-search t)
6522 from subject in-reply-to references ref)
6528 (header-set-number header (setq article (read cur)))
6529 ;; This implementation of this function, with nine
6530 ;; search-forwards instead of the one re-search-forward and
6531 ;; a case (which basically was the old function) is actually
6532 ;; about twice as fast, even though it looks messier. You
6533 ;; can't have everything, I guess. Speed and elegance
6534 ;; doesn't always come hand in hand.
6536 (narrow-to-region (point) (or (save-excursion
6537 (search-forward "\n.\n" nil t))
6539 (if (search-forward "\nfrom: " nil t)
6540 (header-set-from header (gnus-header-value))
6541 (header-set-from header "(nobody)"))
6543 (if (search-forward "\nsubject: " nil t)
6544 (header-set-subject header (gnus-header-value))
6545 (header-set-subject header "(none)"))
6547 (and (search-forward "\nxref: " nil t)
6548 (header-set-xref header (gnus-header-value)))
6550 (or (numberp (and (search-forward "\nlines: " nil t)
6551 (header-set-lines header (read cur))))
6552 (header-set-lines header 0))
6554 (and (search-forward "\ndate: " nil t)
6555 (header-set-date header (gnus-header-value)))
6557 (if (search-forward "\nmessage-id: " nil t)
6558 (header-set-id header (setq id (gnus-header-value)))
6559 ;; If there was no message-id, we just fake one to make
6560 ;; subsequent routines simpler.
6563 (setq id (concat "none+"
6565 (setq gnus-newsgroup-none-id
6566 (1+ gnus-newsgroup-none-id)))))))
6568 (if (search-forward "\nreferences: " nil t)
6570 (header-set-references header (gnus-header-value))
6571 (setq end (match-end 0))
6578 (search-backward ">" end t)
6581 (search-backward "<" end t)
6583 ;; Get the references from the in-reply-to header if there
6584 ;; ware no references and the in-reply-to header looks
6586 (if (and (search-forward "\nin-reply-to: " nil t)
6587 (setq in-reply-to (gnus-header-value))
6588 (string-match "<[^>]+>" in-reply-to))
6590 (header-set-references
6592 (setq ref (substring in-reply-to (match-beginning 0)
6594 (setq ref (downcase ref)))
6596 ;; We do some threading while we read the headers. The
6597 ;; message-id and the last reference are both entered into
6598 ;; the same hash table. Some tippy-toeing around has to be
6599 ;; done in case an article has arrived before the article
6600 ;; which it refers to.
6601 (if (boundp (setq dep (intern (downcase id) dependencies)))
6602 (if (car (symbol-value dep))
6603 ;; An article with this Message-ID has already
6604 ;; been seen, so we ignore this one, except we add
6605 ;; any additional Xrefs (in case the two articles
6606 ;; came from different servers.
6609 (car (symbol-value dep))
6610 (concat (or (header-xref (car (symbol-value dep))) "")
6611 (or (header-xref header) "")))
6613 (setcar (symbol-value dep) header))
6614 (set dep (list header)))
6617 (if (boundp (setq dep (intern ref dependencies)))
6618 (setcdr (symbol-value dep)
6619 (cons header (cdr (symbol-value dep))))
6620 (set dep (list nil header)))
6621 (setq headers (cons header headers))))
6622 (goto-char (point-max))))))
6623 (nreverse headers)))
6625 ;; The following macros and functions were written by Felix Lee
6626 ;; <flee@cse.psu.edu>.
6628 (defmacro gnus-nov-read-integer ()
6630 (if (= (following-char) ?\t)
6632 (let ((num (condition-case nil (read buffer) (error nil))))
6633 (if (numberp num) num 0)))
6634 (or (eobp) (forward-char 1))))
6636 (defmacro gnus-nov-skip-field ()
6637 '(search-forward "\t" eol 'move))
6639 (defmacro gnus-nov-field ()
6640 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6642 ;; Goes through the xover lines and returns a list of vectors
6643 (defun gnus-get-newsgroup-headers-xover (sequence)
6644 "Parse the news overview data in the server buffer, and return a
6645 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6646 ;; Get the Xref when the users reads the articles since most/some
6647 ;; NNTP servers do not include Xrefs when using XOVER.
6648 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6649 (let ((cur nntp-server-buffer)
6650 (dependencies gnus-newsgroup-dependencies)
6652 number headers header)
6654 (set-buffer nntp-server-buffer)
6655 (goto-char (point-min))
6656 (while (and sequence (not (eobp)))
6657 (setq number (read cur))
6658 (while (and sequence (< (car sequence) number))
6659 (setq sequence (cdr sequence)))
6661 (eq number (car sequence))
6663 (setq sequence (cdr sequence))
6665 (inline (gnus-nov-parse-line number dependencies)))
6666 (setq headers (cons header headers)))))
6668 (setq headers (nreverse headers)))
6671 ;; This function has to be called with point after the article number
6672 ;; on the beginning of the line.
6673 (defun gnus-nov-parse-line (number dependencies)
6675 (eol (gnus-point-at-eol))
6676 (buffer (current-buffer))
6679 ;; overview: [num subject from date id refs chars lines misc]
6680 (narrow-to-region (point) eol)
6687 (gnus-nov-field) ; subject
6688 (gnus-nov-field) ; from
6689 (gnus-nov-field) ; date
6690 (setq id (or (gnus-nov-field)
6693 (setq none (1+ none)))))) ; id
6696 (let ((beg (point)))
6697 (search-forward "\t" eol)
6698 (if (search-backward ">" beg t)
6704 (search-backward "<" beg t)
6707 (gnus-nov-field)) ; refs
6708 (gnus-nov-read-integer) ; chars
6709 (gnus-nov-read-integer) ; lines
6710 (if (= (following-char) ?\n)
6712 (gnus-nov-field)) ; misc
6716 (message "Strange nov line.")
6722 ;; We build the thread tree.
6724 (if (boundp (setq dep (intern (downcase id) dependencies)))
6725 (if (car (symbol-value dep))
6726 ;; An article with this Message-ID has already been seen,
6727 ;; so we ignore this one, except we add any additional
6728 ;; Xrefs (in case the two articles came from different
6732 (car (symbol-value dep))
6733 (concat (or (header-xref (car (symbol-value dep))) "")
6734 (or (header-xref header) "")))
6736 (setcar (symbol-value dep) header))
6737 (set dep (list header))))
6740 (if (boundp (setq dep (intern (or ref "none")
6742 (setcdr (symbol-value dep)
6743 (cons header (cdr (symbol-value dep))))
6744 (set dep (list nil header)))))
6747 (defun gnus-article-get-xrefs ()
6748 "Fill in the Xref value in `gnus-current-headers', if necessary.
6749 This is meant to be called in `gnus-article-internal-prepare-hook'."
6750 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6751 gnus-current-headers)))
6752 (or (not gnus-use-cross-reference)
6753 (and (header-xref headers)
6754 (not (string= (header-xref headers) "")))
6755 (let ((case-fold-search t)
6758 (gnus-narrow-to-headers)
6759 (goto-char (point-min))
6760 (if (or (and (eq (downcase (following-char)) ?x)
6761 (looking-at "Xref:"))
6762 (search-forward "\nXref:" nil t))
6764 (goto-char (1+ (match-end 0)))
6765 (setq xref (buffer-substring (point)
6766 (progn (end-of-line) (point))))
6767 (header-set-xref headers xref))))))))
6769 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6770 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6772 ;; Return a header specified by a NUMBER.
6773 (defun gnus-get-header-by-number (number)
6775 (set-buffer gnus-summary-buffer)
6776 (or gnus-newsgroup-headers-hashtb-by-number
6777 (gnus-make-headers-hashtable-by-number))
6778 (gnus-gethash (int-to-string number)
6779 gnus-newsgroup-headers-hashtb-by-number)))
6781 (defun gnus-make-headers-hashtable-by-number ()
6782 "Make hashtable for the variable gnus-newsgroup-headers by number."
6784 (set-buffer gnus-summary-buffer)
6785 (let ((headers gnus-newsgroup-headers)
6787 (setq gnus-newsgroup-headers-hashtb-by-number
6788 (gnus-make-hashtable (length headers)))
6790 (setq header (car headers))
6791 (gnus-sethash (int-to-string (header-number header))
6792 header gnus-newsgroup-headers-hashtb-by-number)
6793 (setq headers (cdr headers))))))
6795 (defun gnus-more-header-backward ()
6796 "Find new header backward."
6797 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6798 (artnum gnus-newsgroup-begin)
6800 (while (and (not header)
6802 (setq artnum (1- artnum))
6803 (setq header (gnus-read-header artnum)))
6806 (defun gnus-more-header-forward (&optional backward)
6807 "Find new header forward.
6808 If BACKWARD, find new header backward instead."
6810 (gnus-more-header-backward)
6811 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6812 (artnum gnus-newsgroup-end)
6814 (while (and (not header)
6816 (setq artnum (1+ artnum))
6817 (setq header (gnus-read-header artnum)))
6820 (defun gnus-extend-newsgroup (header &optional backward)
6821 "Extend newsgroup selection with HEADER.
6822 Optional argument BACKWARD means extend toward backward."
6824 (let ((artnum (header-number header)))
6825 (setq gnus-newsgroup-headers
6827 (cons header gnus-newsgroup-headers)
6828 (nconc gnus-newsgroup-headers (list header))))
6829 (setq gnus-newsgroup-unselected
6830 (delq artnum gnus-newsgroup-unselected))
6831 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6832 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6834 (defun gnus-summary-work-articles (n)
6835 "Return a list of articles to be worked upon. The prefix argument,
6836 the list of process marked articles, and the current article will be
6837 taken into consideration."
6839 (if (and n (numberp n))
6840 (let ((backward (< n 0))
6844 (setq articles (cons (gnus-summary-article-number)
6846 (gnus-summary-search-forward nil nil backward))
6848 (sort articles (function <)))
6849 (or (reverse gnus-newsgroup-processable)
6850 (list (gnus-summary-article-number))))))
6852 (defun gnus-summary-search-group (&optional backward use-level)
6853 "Search for next unread newsgroup.
6854 If optional argument BACKWARD is non-nil, search backward instead."
6856 (set-buffer gnus-group-buffer)
6858 ;; We don't want to alter current point of group mode buffer.
6859 (if (gnus-group-search-forward
6861 (if use-level (gnus-group-group-level) nil))
6862 (gnus-group-group-name)))))
6864 (defun gnus-summary-best-group (&optional exclude-group)
6865 "Find the name of the best unread group.
6866 If EXCLUDE-GROUP, do not go to this group."
6868 (set-buffer gnus-group-buffer)
6870 (gnus-group-best-unread-group exclude-group))))
6872 (defun gnus-summary-search-subject (&optional backward unread subject)
6873 "Search for article forward.
6874 If BACKWARD is non-nil, search backward.
6875 If UNREAD is non-nil, only unread articles are selected.
6876 If SUBJECT is non-nil, the article which has the same subject will be
6878 (let ((func (if backward 'previous-single-property-change
6879 'next-single-property-change))
6884 (and gnus-summary-check-current unread
6885 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
6889 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6892 (setq pos (funcall func (point) 'gnus-number))
6893 (goto-char (if backward (1- pos) pos))
6897 (eq (get-text-property (point) 'gnus-mark)
6900 (equal (gnus-simplify-subject-re subject)
6901 (gnus-simplify-subject-re
6902 (gnus-summary-subject-string)))))))
6903 (if backward (if (bobp) nil (forward-char -1) t)
6904 (if (eobp) nil (forward-char 1) t)))))
6906 (progn (goto-char beg) nil)
6908 (get-text-property (point) 'gnus-number)
6909 (gnus-summary-position-cursor)))))
6911 (defun gnus-summary-search-forward (&optional unread subject backward)
6912 "Search for article forward.
6913 If UNREAD is non-nil, only unread articles are selected.
6914 If SUBJECT is non-nil, the article which has the same subject will be
6916 If BACKWARD is non-nil, the search will be performed backwards instead."
6917 (gnus-summary-search-subject backward unread subject))
6919 (defun gnus-summary-search-backward (&optional unread subject)
6920 "Search for article backward.
6921 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6922 If 2nd optional argument SUBJECT is non-nil, the article which has
6923 the same subject will be searched for."
6924 (gnus-summary-search-forward unread subject t))
6926 (defun gnus-summary-article-number (&optional number-or-nil)
6927 "The article number of the article on the current line.
6928 If there isn's an article number here, then we return the current
6930 (let* ((number (get-text-property (gnus-point-at-bol) 'gnus-number)))
6931 (if number-or-nil number (or number gnus-current-article))))
6933 (defun gnus-summary-thread-level ()
6934 "The thread level of the article on the current line."
6935 (or (get-text-property (gnus-point-at-bol) 'gnus-level)
6938 (defun gnus-summary-pseudo-article ()
6939 "The thread level of the article on the current line."
6940 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
6942 (defun gnus-summary-article-mark ()
6943 "The mark on the current line."
6944 (get-text-property (gnus-point-at-bol) 'gnus-mark))
6946 (defun gnus-summary-subject-string ()
6947 "Return current subject string or nil if nothing."
6948 (let ((article (gnus-summary-article-number))
6951 (setq header (gnus-get-header-by-number article))
6953 (header-subject header))))
6955 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6956 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6957 (defun gnus-summary-article-score ()
6958 "Return current article score."
6959 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6960 gnus-summary-default-score 0))
6962 ;; Written by Sudish Joseph <joseph@cis.ohio-state.edu>.
6964 (defun gnus-summary-recenter ()
6965 "Center point in the summary window.
6966 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6967 displayed, no centering will be performed."
6968 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6969 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6970 (let* ((top (cond ((< (window-height) 4) 0)
6971 ((< (window-height) 6) 1)
6973 (height (1- (window-height)))
6974 (bottom (save-excursion (goto-char (point-max))
6975 (forward-line (- height))
6977 (window (get-buffer-window (current-buffer))))
6979 ;; The user has to want it,
6980 gnus-auto-center-summary
6981 ;; the article buffer must be displayed,
6982 (get-buffer-window gnus-article-buffer)
6983 ;; Set the window start to either `bottom', which is the biggest
6984 ;; possible valid number, or the second line from the top,
6985 ;; whichever is the least.
6987 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
6989 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6990 (defun gnus-short-group-name (group &optional levels)
6991 "Collapse GROUP name LEVELS."
6992 (let* ((name "") (foreign "") (depth -1) (skip 1)
6995 (while (string-match "\\." group skip)
6996 (setq skip (match-end 0)
6999 (if (string-match ":" group)
7000 (setq foreign (substring group 0 (match-end 0))
7001 group (substring group (match-end 0))))
7003 (if (and (string-match "\\." group) (> levels 0))
7004 (setq name (concat name (substring group 0 1))
7005 group (substring group (match-end 0))
7007 name (concat name "."))
7008 (setq name (concat foreign name group)
7012 (defun gnus-summary-jump-to-group (newsgroup)
7013 "Move point to NEWSGROUP in group mode buffer."
7014 ;; Keep update point of group mode buffer if visible.
7015 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7016 (save-window-excursion
7017 ;; Take care of tree window mode.
7018 (if (get-buffer-window gnus-group-buffer)
7019 (pop-to-buffer gnus-group-buffer))
7020 (gnus-group-jump-to-group newsgroup))
7022 ;; Take care of tree window mode.
7023 (if (get-buffer-window gnus-group-buffer)
7024 (pop-to-buffer gnus-group-buffer)
7025 (set-buffer gnus-group-buffer))
7026 (gnus-group-jump-to-group newsgroup))))
7028 ;; This function returns a list of article numbers based on the
7029 ;; difference between the ranges of read articles in this group and
7030 ;; the range of active articles.
7031 (defun gnus-list-of-unread-articles (group)
7032 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7033 (active (gnus-gethash group gnus-active-hashtb))
7035 unread first nlast unread)
7036 ;; If none are read, then all are unread.
7038 (setq first (car active))
7039 ;; If the range of read articles is a single range, then the
7040 ;; first unread article is the article after the last read
7041 ;; article. Sounds logical, doesn't it?
7042 (if (not (listp (cdr read)))
7043 (setq first (1+ (cdr read)))
7044 ;; `read' is a list of ranges.
7045 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7046 (car (car read)))) 1)
7050 (while (< first nlast)
7051 (setq unread (cons first unread))
7052 (setq first (1+ first))))
7053 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7054 (setq nlast (if (atom (car (cdr read)))
7056 (car (car (cdr read)))))
7057 (setq read (cdr read)))))
7058 ;; And add the last unread articles.
7059 (while (<= first last)
7060 (setq unread (cons first unread))
7061 (setq first (1+ first)))
7062 ;; Return the list of unread articles.
7065 (defun gnus-list-of-read-articles (group)
7066 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7067 (active (gnus-gethash group gnus-active-hashtb)))
7069 (gnus-sorted-complement
7070 (gnus-uncompress-range active)
7071 (gnus-list-of-unread-articles group)))))
7073 ;; Various summary commands
7075 (defun gnus-summary-universal-argument ()
7076 "Perform any operation on all articles marked with the process mark."
7078 (gnus-set-global-variables)
7079 (let ((articles (reverse gnus-newsgroup-processable))
7081 (or articles (error "No articles marked"))
7082 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7083 (error "Undefined key"))
7085 (gnus-summary-goto-subject (car articles))
7086 (command-execute func)
7087 (gnus-summary-remove-process-mark (car articles))
7088 (setq articles (cdr articles)))))
7090 (defun gnus-summary-toggle-truncation (arg)
7091 "Toggle truncation of summary lines.
7092 With arg, turn line truncation on iff arg is positive."
7094 (setq truncate-lines
7095 (if (null arg) (not truncate-lines)
7096 (> (prefix-numeric-value arg) 0)))
7099 (defun gnus-summary-reselect-current-group (all)
7100 "Once exit and then reselect the current newsgroup.
7101 The prefix argument ALL means to select all articles."
7103 (gnus-set-global-variables)
7104 (let ((current-subject (gnus-summary-article-number))
7105 (group gnus-newsgroup-name))
7106 (setq gnus-newsgroup-threads nil)
7107 (gnus-summary-exit t)
7108 ;; We have to adjust the point of group mode buffer because the
7109 ;; current point was moved to the next unread newsgroup by
7111 (gnus-summary-jump-to-group group)
7112 (gnus-group-read-group all t)
7113 (gnus-summary-goto-subject current-subject)))
7115 (defun gnus-summary-rescan-group (all)
7116 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7118 (gnus-set-global-variables)
7119 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7120 (let ((group gnus-newsgroup-name))
7122 (gnus-summary-jump-to-group group)
7124 (set-buffer gnus-group-buffer)
7125 (gnus-group-get-new-news-this-group 1))
7126 (gnus-summary-jump-to-group group)
7127 (gnus-group-read-group all)))
7129 (defun gnus-summary-update-info ()
7130 (let* ((group gnus-newsgroup-name)
7131 (method (car (gnus-find-method-for-group group))))
7132 (if gnus-newsgroup-kill-headers
7133 (setq gnus-newsgroup-killed
7134 (gnus-compress-sequence
7136 (gnus-set-sorted-intersection
7137 (gnus-uncompress-range gnus-newsgroup-killed)
7138 (setq gnus-newsgroup-unselected
7139 (sort gnus-newsgroup-unselected '<)))
7140 (setq gnus-newsgroup-unreads
7141 (sort gnus-newsgroup-unreads '<))) t)))
7142 (or (listp (cdr gnus-newsgroup-killed))
7143 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7145 (headers gnus-newsgroup-headers))
7146 (gnus-close-group group)
7147 (run-hooks 'gnus-exit-group-hook)
7148 (gnus-update-read-articles
7149 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7150 gnus-newsgroup-marked
7151 t gnus-newsgroup-replied gnus-newsgroup-expirable
7152 gnus-newsgroup-killed gnus-newsgroup-dormant
7153 gnus-newsgroup-bookmarks
7154 (and gnus-save-score gnus-newsgroup-scored))
7155 (and gnus-use-cross-reference
7156 (gnus-mark-xrefs-as-read
7157 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7158 ;; Do adaptive scoring, and possibly save score files.
7159 (and gnus-newsgroup-adaptive
7160 (gnus-score-adaptive))
7161 (and gnus-use-scoring
7162 (fboundp 'gnus-score-save)
7163 (funcall 'gnus-score-save))
7164 ;; Do not switch windows but change the buffer to work.
7165 (set-buffer gnus-group-buffer)
7166 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7167 (gnus-group-update-group group)))))
7169 (defun gnus-summary-exit (&optional temporary)
7170 "Exit reading current newsgroup, and then return to group selection mode.
7171 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7173 (gnus-set-global-variables)
7174 (gnus-kill-save-kill-buffer)
7175 (let* ((group gnus-newsgroup-name)
7176 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7177 gnus-newsgroup-name))))
7179 (method (car (gnus-find-method-for-group group)))
7180 (buf (current-buffer)))
7181 (gnus-summary-update-info) ; Make all changes in this group permanent.
7182 ;; Make sure where I was, and go to next newsgroup.
7185 (gnus-group-jump-to-group group)
7186 (gnus-group-next-unread-group 1)))
7189 ;; We set all buffer-local variables to nil. It is unclear why
7190 ;; this is needed, but if we don't, buffer-local variables are
7191 ;; not garbage-collected, it seems. This would the lead to en
7192 ;; ever-growing Emacs.
7194 (gnus-summary-clear-local-variables)
7195 ;; We clear the global counterparts of the buffer-local
7196 ;; variables as well, just to be on the safe side.
7197 (gnus-configure-windows 'group)
7198 (gnus-summary-clear-local-variables)
7199 ;; Return to group mode buffer.
7200 (if (eq mode 'gnus-summary-mode)
7201 (gnus-kill-buffer buf))
7202 (if (get-buffer gnus-article-buffer)
7203 (bury-buffer gnus-article-buffer))
7204 (setq gnus-current-select-method gnus-select-method)
7205 (pop-to-buffer gnus-group-buffer)
7206 (if (not quit-config)
7208 (gnus-group-jump-to-group group)
7209 (gnus-group-next-unread-group 1))
7210 (if (not (buffer-name (car quit-config)))
7211 (gnus-configure-windows 'group)
7212 (set-buffer (car quit-config))
7213 (and (eq major-mode 'gnus-summary-mode)
7214 (gnus-set-global-variables))
7215 (gnus-configure-windows (cdr quit-config)))))))
7217 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7218 (defun gnus-summary-exit-no-update (&optional no-questions)
7219 "Quit reading current newsgroup without updating read article info."
7221 (let* ((group gnus-newsgroup-name)
7222 (quit-config (nth 1 (assoc 'quit-config
7223 (gnus-find-method-for-group group)))))
7224 (if (or no-questions
7226 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7228 (gnus-close-group group)
7229 (gnus-summary-clear-local-variables)
7230 (set-buffer gnus-group-buffer)
7231 (gnus-summary-clear-local-variables)
7232 ;; Return to group selection mode.
7233 (gnus-configure-windows 'group)
7234 (if (get-buffer gnus-summary-buffer)
7235 (kill-buffer gnus-summary-buffer))
7236 (if (get-buffer gnus-article-buffer)
7237 (bury-buffer gnus-article-buffer))
7238 (if (equal (gnus-group-group-name) group)
7239 (gnus-group-next-unread-group 1))
7242 (if (not (buffer-name (car quit-config)))
7243 (gnus-configure-windows 'group)
7244 (set-buffer (car quit-config))
7245 (and (eq major-mode 'gnus-summary-mode)
7246 (gnus-set-global-variables))
7247 (gnus-configure-windows (cdr quit-config)))))))))
7249 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7250 (defun gnus-summary-fetch-faq (group)
7251 "Fetch the FAQ for the current group."
7252 (interactive (list gnus-newsgroup-name))
7253 (gnus-configure-windows 'summary-faq)
7254 (find-file (concat gnus-group-faq-directory group)))
7256 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7257 (defun gnus-summary-describe-group (force)
7258 "Describe the current newsgroup."
7260 (gnus-group-describe-group force gnus-newsgroup-name))
7262 (defun gnus-summary-describe-briefly ()
7263 "Describe summary mode commands briefly."
7266 (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")))
7268 ;; Walking around group mode buffer from summary mode.
7270 (defun gnus-summary-next-group (&optional no-article group backward)
7271 "Exit current newsgroup and then select next unread newsgroup.
7272 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7273 If BACKWARD, go to previous group instead."
7275 (gnus-set-global-variables)
7276 (let ((ingroup gnus-newsgroup-name)
7277 (sumbuf (current-buffer))
7279 (gnus-summary-exit t) ;Update all information.
7281 (or (and (numberp (setq num (car (gnus-gethash
7282 group gnus-newsrc-hashtb))))
7286 (gnus-group-jump-to-group group)
7288 (gnus-group-jump-to-group ingroup))
7289 (gnus-summary-search-group backward)
7290 (let ((group (or group (gnus-summary-search-group backward)))
7291 (buf gnus-summary-buffer))
7293 (gnus-summary-exit-no-update t)
7294 (gnus-message 5 "Selecting %s..." group)
7295 ;; We are now in group mode buffer.
7296 ;; Make sure group mode buffer point is on GROUP.
7297 (gnus-group-jump-to-group group)
7298 (if (not (eq gnus-auto-select-next 'quietly))
7300 (gnus-summary-read-group group nil no-article buf)
7301 (and (string= gnus-newsgroup-name ingroup)
7302 (bufferp sumbuf) (buffer-name sumbuf)
7304 (set-buffer (setq gnus-summary-buffer sumbuf))
7305 (gnus-summary-exit-no-update t))))
7306 (let ((prevgroup group))
7307 (gnus-summary-read-group group nil no-article buf)
7308 (while (and (string= gnus-newsgroup-name ingroup)
7310 (buffer-name sumbuf)
7311 (not (string= prevgroup (gnus-group-group-name))))
7312 (set-buffer gnus-group-buffer)
7313 (gnus-summary-read-group
7314 (setq prevgroup (gnus-group-group-name))
7315 nil no-article buf))
7316 (and (string= prevgroup (gnus-group-group-name))
7317 ;; We have reached the final group in the group
7321 (gnus-summary-exit)))))))))
7323 (defun gnus-summary-prev-group (no-article)
7324 "Exit current newsgroup and then select previous unread newsgroup.
7325 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7327 (gnus-summary-next-group no-article nil t))
7329 ;; Walking around summary lines.
7331 (defun gnus-summary-first-subject (unread)
7332 "Go to the first unread subject.
7333 If UNREAD is non-nil, go to the first unread article.
7334 Returns nil if there are no unread articles."
7337 (if (or (not unread)
7340 (point-min) (point-max) 'gnus-mark gnus-unread-mark)))
7342 ;; If there are no unread articles.
7343 (gnus-message 3 "No more unread articles")
7345 (gnus-summary-position-cursor)))
7347 (defun gnus-summary-next-subject (n &optional unread dont-display)
7348 "Go to next N'th summary line.
7349 If N is negative, go to the previous N'th subject line.
7350 If UNREAD is non-nil, only unread articles are selected.
7351 The difference between N and the actual number of steps taken is
7354 (let ((backward (< n 0))
7357 (gnus-summary-search-forward unread nil backward))
7359 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7360 (if unread " unread" "")))
7363 (gnus-summary-recenter)
7364 (gnus-summary-position-cursor)))
7367 (defun gnus-summary-next-unread-subject (n)
7368 "Go to next N'th unread summary line."
7370 (gnus-summary-next-subject n t))
7372 (defun gnus-summary-prev-subject (n &optional unread)
7373 "Go to previous N'th summary line.
7374 If optional argument UNREAD is non-nil, only unread article is selected."
7376 (gnus-summary-next-subject (- n) unread))
7378 (defun gnus-summary-prev-unread-subject (n)
7379 "Go to previous N'th unread summary line."
7381 (gnus-summary-next-subject (- n) t))
7383 (defun gnus-summary-goto-subject (article)
7384 "Go the subject line of ARTICLE."
7388 (completing-read "Article number: "
7392 (int-to-string (header-number headers))))
7393 gnus-newsgroup-headers)
7394 nil 'require-match))))
7395 (or article (error "No article number"))
7397 (gnus-goto-char (text-property-any (point-min) (point-max)
7398 'gnus-number article))
7399 (gnus-summary-show-thread)
7400 ;; Skip dummy articles.
7401 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7408 (gnus-summary-position-cursor))))
7410 ;; Walking around summary lines with displaying articles.
7412 (defun gnus-summary-expand-window ()
7413 "Expand summary window to show headers full window."
7415 (gnus-set-global-variables)
7416 (gnus-configure-windows 'summary))
7418 (defun gnus-summary-display-article (article &optional all-header)
7419 "Display ARTICLE in article buffer."
7420 (gnus-set-global-variables)
7423 (gnus-article-prepare article all-header)
7424 (gnus-summary-show-thread)
7425 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7428 (gnus-summary-position-cursor)))
7429 (run-hooks 'gnus-select-article-hook)
7430 (gnus-summary-recenter)
7431 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
7433 (gnus-summary-goto-subject article)
7434 ;; Successfully display article.
7435 (gnus-summary-update-line)
7436 (gnus-article-set-window-start
7437 (cdr (assq article gnus-newsgroup-bookmarks)))
7440 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7441 "Select the current article.
7442 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7443 non-nil, the article will be re-fetched even if it already present in
7444 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7446 (and (not pseudo) (gnus-summary-pseudo-article)
7447 (error "This is a pseudo-article."))
7448 (let ((article (or article (gnus-summary-article-number)))
7449 (all-headers (not (not all-headers))) ;Must be T or NIL.
7453 (set-buffer gnus-summary-buffer)
7454 (if (or (null gnus-current-article)
7455 (null gnus-article-current)
7456 (not (eq article (cdr gnus-article-current)))
7457 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7459 ;; The requested article is different from the current article.
7461 (gnus-summary-display-article article all-headers)
7463 (if all-headers (gnus-article-show-all-headers))
7466 (gnus-article-set-window-start
7467 (cdr (assq article gnus-newsgroup-bookmarks)))))))
7469 (defun gnus-summary-set-current-mark (&optional current-mark)
7470 "Obsolete function."
7473 (defun gnus-summary-next-article (unread &optional subject backward)
7474 "Select the next article.
7475 If UNREAD, only unread articles are selected.
7476 If SUBJECT, only articles with SUBJECT are selected.
7477 If BACKWARD, the previous article is selected instead of the next."
7479 (let ((opoint (point))
7480 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
7483 ;; Is there such an article?
7484 ((gnus-summary-display-article
7485 (gnus-summary-search-forward unread subject backward))
7486 (gnus-summary-position-cursor))
7487 ;; If not, we try the first unread, if that is wanted.
7489 gnus-auto-select-same
7490 (gnus-summary-first-unread-article))
7491 (gnus-message 6 "Wrapped"))
7492 ;; Try to get next/previous article not displayed in this group.
7493 ((and gnus-auto-extend-newsgroup
7494 (not unread) (not subject)
7495 (setq header (gnus-more-header-forward backward)))
7496 (gnus-extend-newsgroup header backward)
7497 (let ((buffer-read-only nil))
7498 (goto-char (if backward (point-min) (point-max)))
7499 (gnus-summary-prepare-threads (list header) 0))
7500 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7501 gnus-newsgroup-end)))
7502 ;; Go to next/previous group.
7504 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7505 (gnus-summary-jump-to-group gnus-newsgroup-name))
7506 (let ((cmd (aref (this-command-keys) 0))
7508 (if (eq gnus-keep-same-level 'best)
7509 (gnus-summary-best-group gnus-newsgroup-name)
7510 (gnus-summary-search-group backward gnus-keep-same-level))))
7511 ;; Keep just the event type of CMD.
7512 (and (listp cmd) (setq cmd (car cmd)))
7513 ;; Select next unread newsgroup automagically.
7515 ((not gnus-auto-select-next)
7516 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7517 ((eq gnus-auto-select-next 'quietly)
7519 (if (assoc 'quit-config (gnus-find-method-for-group
7520 gnus-newsgroup-name))
7522 (gnus-message 7 "No more%s articles (%s)..."
7523 (if unread " unread" "")
7524 (if group (concat "selecting " group)
7526 (gnus-summary-next-group nil group backward)))
7528 (let ((keystrokes '(?\C-n ?\C-p))
7530 (while (or (null key) (memq key keystrokes))
7532 7 "No more%s articles%s" (if unread " unread" "")
7533 (if (and group (not (assoc 'quit-config
7534 (gnus-find-method-for-group
7535 gnus-newsgroup-name))))
7536 (format " (Type %s for %s [%s])"
7537 (single-key-description cmd) group
7538 (car (gnus-gethash group gnus-newsrc-hashtb)))
7539 (format " (Type %s to exit %s)"
7540 (single-key-description cmd)
7541 gnus-newsgroup-name)))
7542 ;; Confirm auto selection.
7543 (let* ((event (read-event)))
7544 (setq key (if (listp event) (car event) event))
7545 (if (member key keystrokes)
7546 (let ((obuf (current-buffer)))
7547 (switch-to-buffer gnus-group-buffer)
7548 (gnus-group-jump-to-group group)
7549 (execute-kbd-macro (char-to-string key))
7550 (setq group (gnus-group-group-name))
7551 (switch-to-buffer obuf)))))
7553 (if (or (not group) (assoc 'quit-config
7554 (gnus-find-method-for-group
7555 gnus-newsgroup-name)))
7557 (gnus-summary-next-group nil group backward))
7558 (setq unread-command-events (list key)))))))))))
7560 (defun gnus-summary-next-unread-article ()
7561 "Select unread article after current one."
7563 (gnus-summary-next-article t (and gnus-auto-select-same
7564 (gnus-summary-subject-string))))
7566 (defun gnus-summary-prev-article (unread &optional subject)
7567 "Select the article after the current one.
7568 If UNREAD is non-nil, only unread articles are selected."
7570 (gnus-summary-next-article unread subject t))
7572 (defun gnus-summary-prev-unread-article ()
7573 "Select unred article before current one."
7575 (gnus-summary-prev-article t (and gnus-auto-select-same
7576 (gnus-summary-subject-string))))
7578 (defun gnus-summary-next-page (lines &optional circular)
7579 "Show next page of selected article.
7580 If end of article, select next article.
7581 Argument LINES specifies lines to be scrolled up.
7582 If CIRCULAR is non-nil, go to the start of the article instead of
7583 instead of selecting the next article when reaching the end of the
7586 (setq gnus-summary-buffer (current-buffer))
7587 (gnus-set-global-variables)
7588 (let ((article (gnus-summary-article-number))
7590 (gnus-configure-windows 'article)
7591 (if (or (null gnus-current-article)
7592 (null gnus-article-current)
7593 (/= article (cdr gnus-article-current))
7594 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7595 ;; Selected subject is different from current article's.
7596 (gnus-summary-display-article article)
7597 (gnus-eval-in-buffer-window
7599 (setq endp (gnus-article-next-page lines)))
7602 (gnus-summary-beginning-of-article))
7604 (gnus-message 3 "End of message"))
7606 (gnus-summary-next-unread-article)))))
7607 (gnus-summary-recenter)
7608 (gnus-summary-position-cursor)))
7610 (defun gnus-summary-prev-page (lines)
7611 "Show previous page of selected article.
7612 Argument LINES specifies lines to be scrolled down."
7614 (gnus-set-global-variables)
7615 (let ((article (gnus-summary-article-number)))
7616 (gnus-configure-windows 'article)
7617 (if (or (null gnus-current-article)
7618 (null gnus-article-current)
7619 (/= article (cdr gnus-article-current))
7620 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7621 ;; Selected subject is different from current article's.
7622 (gnus-summary-display-article article)
7623 (gnus-summary-recenter)
7624 (gnus-eval-in-buffer-window gnus-article-buffer
7625 (gnus-article-prev-page lines))))
7626 (gnus-summary-position-cursor))
7628 (defun gnus-summary-scroll-up (lines)
7629 "Scroll up (or down) one line current article.
7630 Argument LINES specifies lines to be scrolled up (or down if negative)."
7632 (gnus-set-global-variables)
7633 (or (gnus-summary-select-article nil nil 'pseudo)
7634 (gnus-eval-in-buffer-window
7637 (if (gnus-article-next-page lines)
7638 (gnus-message 3 "End of message")))
7640 (gnus-article-prev-page (- lines))))))
7641 (gnus-summary-recenter)
7642 (gnus-summary-position-cursor))
7644 (defun gnus-summary-next-same-subject ()
7645 "Select next article which has the same subject as current one."
7647 (gnus-set-global-variables)
7648 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7650 (defun gnus-summary-prev-same-subject ()
7651 "Select previous article which has the same subject as current one."
7653 (gnus-set-global-variables)
7654 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7656 (defun gnus-summary-next-unread-same-subject ()
7657 "Select next unread article which has the same subject as current one."
7659 (gnus-set-global-variables)
7660 (gnus-summary-next-article t (gnus-summary-subject-string)))
7662 (defun gnus-summary-prev-unread-same-subject ()
7663 "Select previous unread article which has the same subject as current one."
7665 (gnus-set-global-variables)
7666 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7668 (defun gnus-summary-first-unread-article ()
7669 "Select the first unread article.
7670 Return nil if there are no unread articles."
7672 (gnus-set-global-variables)
7674 (if (gnus-summary-first-subject t)
7675 (gnus-summary-display-article (gnus-summary-article-number)))
7676 (gnus-summary-position-cursor)))
7678 (defun gnus-summary-best-unread-article ()
7679 "Select the unread article with the highest score."
7681 (gnus-set-global-variables)
7682 (let ((scored gnus-newsgroup-scored)
7686 (or (> best (cdr (car scored)))
7687 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7688 (not (memq art gnus-newsgroup-marked))
7689 (not (memq art gnus-newsgroup-dormant))
7690 (if (= best (cdr (car scored)))
7691 (setq article (min art article))
7693 (setq best (cdr (car scored))))))
7694 (setq scored (cdr scored)))
7696 (gnus-summary-goto-article article)
7697 (gnus-summary-first-unread-article))
7698 (gnus-summary-position-cursor)))
7700 (defun gnus-summary-goto-article (article &optional all-headers)
7701 "Fetch ARTICLE and display it if it exists.
7702 If ALL-HEADERS is non-nil, no header lines are hidden."
7708 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7709 gnus-newsgroup-headers)
7710 nil 'require-match))))
7712 (and (gnus-summary-goto-subject article)
7713 (gnus-summary-display-article article all-headers))
7714 (gnus-summary-position-cursor)))
7716 (defun gnus-summary-goto-last-article ()
7717 "Go to the last article."
7720 (and gnus-last-article
7721 (gnus-summary-goto-article gnus-last-article))
7722 (gnus-summary-position-cursor)))
7724 (defun gnus-summary-pop-article (number)
7725 "Pop one article off the history and go to the previous.
7726 NUMBER articles will be popped off."
7729 (setq gnus-newsgroup-history
7730 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7732 (gnus-summary-goto-article (car to))
7733 (error "Article history empty")))
7734 (gnus-summary-position-cursor))
7736 ;; Summary article oriented commands
7738 (defun gnus-summary-refer-parent-article (n)
7739 "Refer parent article N times.
7740 The difference between N and the number of articles fetched is returned."
7742 (gnus-set-global-variables)
7746 (let ((ref (header-references (gnus-get-header-by-number
7747 (gnus-summary-article-number)))))
7748 (if (and ref (not (equal ref ""))
7749 (string-match "<[^<>]*>[ \t]*$" ref))
7750 (gnus-summary-refer-article
7751 (substring ref (match-beginning 0) (match-end 0))))))
7754 (gnus-message 1 "No references in article or expired article."))
7755 (gnus-summary-position-cursor)
7758 (defun gnus-summary-refer-article (message-id)
7759 "Refer article specified by MESSAGE-ID.
7760 NOTE: This command only works with newsgroups that use real or simulated NNTP."
7761 (interactive "sMessage-ID: ")
7762 (if (or (not (stringp message-id))
7763 (zerop (length message-id)))
7765 ;; Construct the correct Message-ID if necessary.
7766 ;; Suggested by tale@pawl.rpi.edu.
7767 (or (string-match "^<" message-id)
7768 (setq message-id (concat "<" message-id)))
7769 (or (string-match ">$" message-id)
7770 (setq message-id (concat message-id ">")))
7771 (let ((header (car (gnus-gethash (downcase message-id)
7772 gnus-newsgroup-dependencies))))
7774 (or (gnus-summary-goto-article (header-number header))
7775 ;; The header has been read, but the article had been
7776 ;; expunged, so we insert it again.
7778 (gnus-summary-insert-line
7779 nil header 0 nil gnus-read-mark nil nil
7780 (header-subject header))
7782 (header-number header)))
7783 (let ((gnus-override-method gnus-refer-article-method)
7784 (gnus-ancient-mark gnus-read-mark)
7786 (and gnus-refer-article-method
7787 (or (gnus-server-opened gnus-refer-article-method)
7788 (gnus-open-server gnus-refer-article-method)))
7789 (if (gnus-article-prepare
7790 message-id nil (gnus-read-header message-id))
7792 (setq number (header-number gnus-current-headers))
7793 (gnus-rebuild-thread message-id)
7794 (gnus-summary-goto-subject number)
7795 (gnus-article-set-window-start
7796 (cdr (assq number gnus-newsgroup-bookmarks)))
7798 (gnus-message 1 "No such references")
7801 (defun gnus-summary-enter-digest-group ()
7802 "Enter a digest group based on the current article."
7804 (gnus-set-global-variables)
7805 (gnus-summary-select-article)
7806 ;; We do not want a narrowed article.
7807 (gnus-summary-stop-page-breaking)
7808 (let ((name (format "%s-%d"
7809 (gnus-group-prefixed-name
7810 gnus-newsgroup-name (list 'nndoc ""))
7811 gnus-current-article))
7812 (buf (current-buffer)))
7813 (if (gnus-group-read-ephemeral-group
7814 name (list 'nndoc name
7815 (list 'nndoc-address (get-buffer gnus-article-buffer))
7816 '(nndoc-article-type digest))
7819 (switch-to-buffer buf)
7820 (gnus-set-global-variables)
7821 (gnus-configure-windows 'summary)
7822 (gnus-message 3 "Article not a digest?"))))
7824 (defun gnus-summary-isearch-article ()
7825 "Do incremental search forward on current article."
7827 (gnus-set-global-variables)
7828 (gnus-summary-select-article)
7829 (gnus-eval-in-buffer-window
7830 gnus-article-buffer (isearch-forward)))
7832 (defun gnus-summary-search-article-forward (regexp)
7833 "Search for an article containing REGEXP forward.
7834 gnus-select-article-hook is not called during the search."
7837 (concat "Search forward (regexp): "
7838 (if gnus-last-search-regexp
7839 (concat "(default " gnus-last-search-regexp ") "))))))
7840 (gnus-set-global-variables)
7841 (if (string-equal regexp "")
7842 (setq regexp (or gnus-last-search-regexp ""))
7843 (setq gnus-last-search-regexp regexp))
7844 (if (gnus-summary-search-article regexp nil)
7845 (gnus-eval-in-buffer-window
7848 (error "Search failed: \"%s\"" regexp)))
7850 (defun gnus-summary-search-article-backward (regexp)
7851 "Search for an article containing REGEXP backward.
7852 gnus-select-article-hook is not called during the search."
7855 (concat "Search backward (regexp): "
7856 (if gnus-last-search-regexp
7857 (concat "(default " gnus-last-search-regexp ") "))))))
7858 (gnus-set-global-variables)
7859 (if (string-equal regexp "")
7860 (setq regexp (or gnus-last-search-regexp ""))
7861 (setq gnus-last-search-regexp regexp))
7862 (if (gnus-summary-search-article regexp t)
7863 (gnus-eval-in-buffer-window
7866 (error "Search failed: \"%s\"" regexp)))
7868 (defun gnus-summary-search-article (regexp &optional backward)
7869 "Search for an article containing REGEXP.
7870 Optional argument BACKWARD means do search for backward.
7871 gnus-select-article-hook is not called during the search."
7872 (let ((gnus-select-article-hook nil) ;Disable hook.
7873 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7876 (function re-search-backward) (function re-search-forward)))
7879 ;; Hidden thread subtrees must be searched for ,too.
7880 (gnus-summary-show-all-threads)
7881 (if (eobp) (forward-line -1))
7882 ;; First of all, search current article.
7883 ;; We don't want to read article again from NNTP server nor reset
7885 (gnus-summary-select-article)
7886 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7887 (setq last gnus-current-article)
7888 (gnus-eval-in-buffer-window gnus-article-buffer
7891 ;; Begin search from current point.
7892 (setq found (funcall re-search regexp nil t))))
7893 ;; Then search next articles.
7894 (while (and (not found)
7895 (gnus-summary-display-article
7896 (gnus-summary-search-subject backward nil nil)))
7897 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7898 (gnus-eval-in-buffer-window gnus-article-buffer
7901 (goto-char (if backward (point-max) (point-min)))
7902 (setq found (funcall re-search regexp nil t)))))
7904 ;; Adjust article pointer.
7905 (or (eq last gnus-current-article)
7906 (setq gnus-last-article last))
7907 ;; Return T if found such article.
7910 (defun gnus-summary-execute-command (header regexp command &optional backward)
7911 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7912 If HEADER is an empty string (or nil), the match is done on the entire
7913 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7915 (list (let ((completion-ignore-case t))
7918 (mapcar (lambda (string) (list string))
7919 '("Number" "Subject" "From" "Lines" "Date"
7920 "Message-ID" "Xref" "References"))
7921 nil 'require-match))
7922 (read-string "Regexp: ")
7923 (read-key-sequence "Command: ")
7924 current-prefix-arg))
7925 (gnus-set-global-variables)
7926 ;; Hidden thread subtrees must be searched as well.
7927 (gnus-summary-show-all-threads)
7928 ;; We don't want to change current point nor window configuration.
7930 (save-window-excursion
7931 (gnus-message 6 "Executing %s..." (key-description command))
7932 ;; We'd like to execute COMMAND interactively so as to give arguments.
7933 (gnus-execute header regexp
7935 (call-interactively '(, (key-binding command)))))
7937 (gnus-message 6 "Executing %s...done" (key-description command)))))
7939 (defun gnus-summary-beginning-of-article ()
7940 "Scroll the article back to the beginning."
7942 (gnus-set-global-variables)
7943 (gnus-summary-select-article)
7944 (gnus-eval-in-buffer-window
7947 (goto-char (point-min))
7948 (and gnus-break-pages (gnus-narrow-to-page))))
7950 (defun gnus-summary-end-of-article ()
7951 "Scroll to the end of the article."
7953 (gnus-set-global-variables)
7954 (gnus-summary-select-article)
7955 (gnus-eval-in-buffer-window
7958 (goto-char (point-max))
7959 (and gnus-break-pages (gnus-narrow-to-page))))
7961 (defun gnus-summary-show-article ()
7962 "Force re-fetching of the current article."
7964 (gnus-set-global-variables)
7965 (gnus-summary-select-article gnus-have-all-headers t))
7967 (defun gnus-summary-toggle-header (arg)
7968 "Show the headers if they are hidden, or hide them if they are shown.
7969 If ARG is a positive number, show the entire header.
7970 If ARG is a negative number, hide the unwanted header lines."
7972 (gnus-set-global-variables)
7974 (set-buffer gnus-article-buffer)
7975 (let ((buffer-read-only nil))
7977 (if (> arg 0) (remove-text-properties (point-min) (point-max)
7978 gnus-hidden-properties)
7979 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7980 (if (text-property-any (point-min) (point-max) 'invisible t)
7981 (remove-text-properties (point-min) (point-max)
7982 gnus-hidden-properties)
7983 (let ((gnus-have-all-headers nil))
7984 (run-hooks 'gnus-article-display-hook))))
7985 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
7987 (defun gnus-summary-show-all-headers ()
7988 "Make all header lines visible."
7990 (gnus-set-global-variables)
7991 (gnus-article-show-all-headers))
7993 (defun gnus-summary-toggle-mime (arg)
7994 "Toggle MIME processing.
7995 If ARG is a positive number, turn MIME processing on."
7997 (gnus-set-global-variables)
7998 (setq gnus-show-mime
7999 (if (null arg) (not gnus-show-mime)
8000 (> (prefix-numeric-value arg) 0)))
8001 (gnus-summary-select-article t 'force))
8003 (defun gnus-summary-caesar-message (rotnum)
8004 "Caesar rotates all letters of current message by 13/47 places.
8005 With prefix arg, specifies the number of places to rotate each letter forward.
8006 Caesar rotates Japanese letters by 47 places in any case."
8008 (gnus-set-global-variables)
8009 (gnus-summary-select-article)
8010 (let ((mail-header-separator "")) ; !!! Is this necessary?
8011 (gnus-overload-functions)
8012 (gnus-eval-in-buffer-window
8016 ;; We don't want to jump to the beginning of the message.
8017 ;; `save-excursion' does not do its job.
8018 (move-to-window-line 0)
8019 (let ((last (point)))
8020 (news-caesar-buffer-body rotnum)
8024 (defun gnus-summary-stop-page-breaking ()
8025 "Stop page breaking in the current article."
8027 (gnus-set-global-variables)
8028 (gnus-summary-select-article)
8029 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8031 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8033 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
8034 "Move the current article to a different newsgroup.
8035 If N is a positive number, move the N next articles.
8036 If N is a negative number, move the N previous articles.
8037 If N is nil and any articles have been marked with the process mark,
8038 move those articles instead.
8039 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8040 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8041 re-spool using this method.
8042 For this function to work, both the current newsgroup and the
8043 newsgroup that you want to move to have to support the `request-move'
8044 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8046 (gnus-set-global-variables)
8047 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8048 (error "The current newsgroup does not support article moving"))
8049 (let ((articles (gnus-summary-work-articles n))
8050 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8052 (if (and (not to-newsgroup) (not select-method))
8055 (format "Where do you want to move %s? %s"
8056 (if (> (length articles) 1)
8057 (format "these %d articles" (length articles))
8059 (if gnus-current-move-group
8060 (format "(%s default) " gnus-current-move-group)
8062 gnus-active-hashtb nil nil prefix)))
8065 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8066 (setq to-newsgroup (or gnus-current-move-group "")))
8067 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8068 (gnus-activate-newsgroup to-newsgroup)
8069 (error "No such group: %s" to-newsgroup))
8070 (setq gnus-current-move-group to-newsgroup)))
8071 (or (gnus-check-backend-function 'request-accept-article
8072 (or select-method to-newsgroup))
8073 (error "%s does not support article moving" to-newsgroup))
8074 (gnus-message 6 "Moving to %s: %s..."
8075 (or select-method to-newsgroup) articles)
8078 (gnus-request-move-article
8079 (car articles) ; Article to move
8080 gnus-newsgroup-name ; From newsgrouo
8081 (nth 1 (gnus-find-method-for-group
8082 gnus-newsgroup-name)) ; Server
8083 (list 'gnus-request-accept-article
8085 (list 'quote select-method)
8087 (not (cdr articles))) ; Accept form
8088 (not (cdr articles)))) ; Only save nov last time
8089 (let* ((buffer-read-only nil)
8092 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8094 (gnus-group-prefixed-name
8096 (if select-method (list select-method "")
8097 (gnus-find-method-for-group to-newsgroup)))
8098 gnus-newsrc-hashtb)))
8099 (info (nth 2 entry))
8100 (article (car articles))
8101 (marked (nth 3 info)))
8102 (gnus-summary-goto-subject article)
8104 (delete-region (point)
8105 (progn (forward-line 1) (point)))
8106 (if (not (memq article gnus-newsgroup-unreads))
8107 (setcar (cdr (cdr info))
8108 (gnus-add-to-range (nth 2 info)
8109 (list (cdr art-group)))))
8110 ;; Copy any marks over to the new group.
8111 (let ((marks '((tick . gnus-newsgroup-marked)
8112 (dormant . gnus-newsgroup-dormant)
8113 (expire . gnus-newsgroup-expirable)
8114 (bookmark . gnus-newsgroup-bookmarks)
8115 ; (score . gnus-newsgroup-scored)
8116 (reply . gnus-newsgroup-replied)))
8117 (to-article (cdr art-group)))
8119 (if (memq article (symbol-value (cdr (car marks))))
8120 (gnus-add-marked-articles
8121 (car info) (car (car marks)) (list to-article) info))
8122 (setq marks (cdr marks))))
8123 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8124 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8125 (setq gnus-newsgroup-dormant
8126 (delq article gnus-newsgroup-dormant)))
8127 (gnus-message 1 "Couldn't move article %s" (car articles)))
8128 (gnus-summary-remove-process-mark (car articles))
8129 (setq articles (cdr articles)))))
8131 (defun gnus-summary-respool-article (n &optional respool-method)
8132 "Respool the current article.
8133 The article will be squeezed through the mail spooling process again,
8134 which means that it will be put in some mail newsgroup or other
8135 depending on `nnmail-split-methods'.
8136 If N is a positive number, respool the N next articles.
8137 If N is a negative number, respool the N previous articles.
8138 If N is nil and any articles have been marked with the process mark,
8139 respool those articles instead.
8141 Respooling can be done both from mail groups and \"real\" newsgroups.
8142 In the former case, the articles in question will be moved from the
8143 current group into whatever groups they are destined to. In the
8144 latter case, they will be copied into the relevant groups."
8146 (gnus-set-global-variables)
8147 (let ((respool-methods (gnus-methods-using 'respool))
8149 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8151 (setq respool-method
8153 "What method do you want to use when respooling? "
8154 respool-methods nil t methname)))
8155 (or (string= respool-method "")
8156 (if (assoc (symbol-name
8157 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8159 (gnus-summary-move-article n nil (intern respool-method))
8160 (gnus-summary-copy-article n nil (intern respool-method))))))
8162 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8163 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
8164 "Move the current article to a different newsgroup.
8165 If N is a positive number, move the N next articles.
8166 If N is a negative number, move the N previous articles.
8167 If N is nil and any articles have been marked with the process mark,
8168 move those articles instead.
8169 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8170 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8171 re-spool using this method.
8172 For this function to work, the newsgroup that you want to move to have
8173 to support the `request-move' and `request-accept'
8174 functions. (Ie. mail newsgroups at present.)"
8176 (gnus-set-global-variables)
8177 (let ((articles (gnus-summary-work-articles n))
8178 (copy-buf (get-buffer-create "*copy work*"))
8179 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8181 (buffer-disable-undo copy-buf)
8182 (if (and (not to-newsgroup) (not select-method))
8185 (format "Where do you want to copy %s? %s"
8186 (if (> (length articles) 1)
8187 (format "these %d articles" (length articles))
8189 (if gnus-current-move-group
8190 (format "(%s default) " gnus-current-move-group)
8192 gnus-active-hashtb nil nil prefix)))
8195 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8196 (setq to-newsgroup (or gnus-current-move-group "")))
8197 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8198 (gnus-activate-newsgroup to-newsgroup)
8199 (error "No such group: %s" to-newsgroup))
8200 (setq gnus-current-move-group to-newsgroup)))
8201 (or (gnus-check-backend-function 'request-accept-article
8202 (or select-method to-newsgroup))
8203 (error "%s does not support article copying" to-newsgroup))
8204 (gnus-message 6 "Copying to %s: %s..."
8205 (or select-method to-newsgroup) articles)
8209 (set-buffer copy-buf)
8210 (gnus-request-article-this-buffer
8211 (car articles) gnus-newsgroup-name)
8212 (gnus-request-accept-article
8213 (if select-method (quote select-method) to-newsgroup)
8214 (not (cdr articles)))))
8217 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8219 (gnus-group-prefixed-name
8221 (if select-method (list select-method "")
8222 (gnus-find-method-for-group to-newsgroup)))
8223 gnus-newsrc-hashtb)))
8224 (info (nth 2 entry))
8225 (article (car articles))
8226 (marked (nth 3 info)))
8227 (if (not (memq article gnus-newsgroup-unreads))
8228 (setcar (cdr (cdr info))
8229 (gnus-add-to-range (nth 2 info)
8230 (list (cdr art-group)))))
8231 ;; Copy any marks over to the new group.
8232 (let ((marks '((tick . gnus-newsgroup-marked)
8233 (dormant . gnus-newsgroup-dormant)
8234 (expire . gnus-newsgroup-expirable)
8235 (bookmark . gnus-newsgroup-bookmarks)
8236 ; (score . gnus-newsgroup-scored)
8237 (reply . gnus-newsgroup-replied)))
8238 (to-article (cdr art-group)))
8240 (if (memq article (symbol-value (cdr (car marks))))
8241 (gnus-add-marked-articles
8242 (car info) (car (car marks)) (list to-article) info))
8243 (setq marks (cdr marks)))))
8244 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8245 (gnus-summary-remove-process-mark (car articles))
8246 (setq articles (cdr articles)))
8247 (kill-buffer copy-buf)))
8249 (defun gnus-summary-import-article (file)
8250 "Import a random file into a mail newsgroup."
8251 (interactive "fImport file: ")
8252 (let ((group gnus-newsgroup-name)
8254 (or (gnus-check-backend-function 'request-accept-article group)
8255 (error "%s does not support article importing" group))
8256 (or (file-readable-p file)
8257 (not (file-regular-p file))
8258 (error "Can't read %s" file))
8260 (set-buffer (get-buffer-create " *import file*"))
8261 (buffer-disable-undo (current-buffer))
8263 (insert-file-contents file)
8264 (goto-char (point-min))
8265 (if (nnheader-article-p)
8267 (setq atts (file-attributes file))
8268 (insert "From: " (read-string "From: ") "\n"
8269 "Subject: " (read-string "Subject: ") "\n"
8270 "Date: " (current-time-string (nth 5 atts)) "\n"
8271 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8272 (gnus-request-accept-article group t)
8273 (kill-buffer (current-buffer)))))
8275 (defun gnus-summary-expire-articles ()
8276 "Expire all articles that are marked as expirable in the current group."
8278 (if (and gnus-newsgroup-expirable
8279 (gnus-check-backend-function
8280 'request-expire-articles gnus-newsgroup-name))
8281 (let ((expirable gnus-newsgroup-expirable))
8282 ;; The list of articles that weren't expired is returned.
8283 (setq gnus-newsgroup-expirable
8284 (gnus-request-expire-articles gnus-newsgroup-expirable
8285 gnus-newsgroup-name))
8286 ;; We go through the old list of expirable, and mark all
8287 ;; really expired articles as non-existant.
8289 (or (memq (car expirable) gnus-newsgroup-expirable)
8290 (gnus-summary-mark-as-read (car expirable) "%"))
8291 (setq expirable (cdr expirable))))))
8293 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8294 (defun gnus-summary-delete-article (n)
8295 "Delete the N next (mail) articles.
8296 This command actually deletes articles. This is not a marking
8297 command. The article will disappear forever from you life, never to
8299 If N is negative, delete backwards.
8300 If N is nil and articles have been marked with the process mark,
8301 delete these instead."
8303 (or (gnus-check-backend-function 'request-expire-articles
8304 gnus-newsgroup-name)
8305 (error "The current newsgroup does not support article deletion."))
8306 ;; Compute the list of articles to delete.
8307 (let ((articles (gnus-summary-work-articles n))
8309 (if (and gnus-novice-user
8311 (format "Do you really want to delete %s forever? "
8312 (if (> (length articles) 1) "these articles"
8315 ;; Delete the articles.
8316 (setq not-deleted (gnus-request-expire-articles
8317 articles gnus-newsgroup-name 'force))
8319 (gnus-summary-remove-process-mark (car articles))
8320 ;; The backend might not have been able to delete the article
8322 (or (memq (car articles) not-deleted)
8323 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
8324 (setq articles (cdr articles))))
8325 (gnus-summary-position-cursor)
8328 (defun gnus-summary-edit-article ()
8329 "Enter into a buffer and edit the current article.
8330 This will have permanent effect only in mail groups."
8332 (or (gnus-check-backend-function
8333 'request-replace-article gnus-newsgroup-name)
8334 (error "The current newsgroup does not support article editing."))
8335 (gnus-summary-select-article t)
8337 (gnus-message 6 "C-c C-c to end edits")
8338 (setq buffer-read-only nil)
8340 (use-local-map (copy-keymap (current-local-map)))
8341 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8342 (goto-char (point-min))
8343 (search-forward "\n\n" nil t))
8345 (defun gnus-summary-edit-article-done ()
8346 "Make edits to the current article permanent."
8348 (if (not (gnus-request-replace-article
8349 (cdr gnus-article-current) (car gnus-article-current)
8351 (error "Couldn't replace article.")
8353 (use-local-map gnus-article-mode-map)
8354 (setq buffer-read-only t)
8355 (pop-to-buffer gnus-summary-buffer)))
8357 (defun gnus-summary-fancy-query ()
8358 "Query where the fancy respool algorithm would put this article."
8360 (gnus-summary-select-article)
8362 (set-buffer gnus-article-buffer)
8364 (goto-char (point-min))
8365 (search-forward "\n\n")
8366 (narrow-to-region (point-min) (point))
8367 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8369 ;; Summary score commands.
8371 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8373 (defun gnus-summary-raise-score (n)
8374 "Raise the score of the current article by N."
8376 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8378 (defun gnus-summary-lower-score (n)
8379 "Lower the score of the current article by N."
8381 (gnus-summary-raise-score (- n)))
8383 (defun gnus-summary-set-score (n)
8384 "Set the score of the current article to N."
8386 ;; Skip dummy header line.
8388 (gnus-summary-show-thread)
8389 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8391 (let ((buffer-read-only nil))
8393 (gnus-summary-update-mark
8394 (if (= n (or gnus-summary-default-score 0)) ?
8395 (if (< n (or gnus-summary-default-score 0))
8396 gnus-score-below-mark gnus-score-over-mark)) 'score))
8397 (let* ((article (gnus-summary-article-number))
8398 (score (assq article gnus-newsgroup-scored)))
8399 (if score (setcdr score n)
8400 (setq gnus-newsgroup-scored
8401 (cons (cons article n) gnus-newsgroup-scored))))
8402 (gnus-summary-update-line)))
8404 (defun gnus-summary-current-score ()
8405 "Return the score of the current article."
8407 (message "%s" (gnus-summary-article-score)))
8409 ;; Summary marking commands.
8411 (defun gnus-summary-raise-same-subject-and-select (score)
8412 "Raise articles which has the same subject with SCORE and select the next."
8414 (let ((subject (gnus-summary-subject-string)))
8415 (gnus-summary-raise-score score)
8416 (while (gnus-summary-search-subject nil nil subject)
8417 (gnus-summary-raise-score score))
8418 (gnus-summary-next-article t)))
8420 (defun gnus-summary-raise-same-subject (score)
8421 "Raise articles which has the same subject with SCORE."
8423 (let ((subject (gnus-summary-subject-string)))
8424 (gnus-summary-raise-score score)
8425 (while (gnus-summary-search-subject nil nil subject)
8426 (gnus-summary-raise-score score))
8427 (gnus-summary-next-subject 1 t)))
8429 (defun gnus-score-default (level)
8430 (if level (prefix-numeric-value level)
8431 gnus-score-interactive-default-score))
8433 (defun gnus-summary-raise-thread (score)
8434 "Raise articles under current thread with SCORE."
8436 (setq score (1- (gnus-score-default score)))
8439 (let ((level (gnus-summary-thread-level)))
8440 (gnus-summary-raise-score score)
8441 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8442 (> (gnus-summary-thread-level) level))
8443 (gnus-summary-raise-score score))
8445 (let ((gnus-summary-check-current t))
8446 (or (zerop (gnus-summary-next-subject 1 t))
8448 (gnus-summary-recenter)
8449 (gnus-summary-position-cursor)
8450 (gnus-set-mode-line 'summary))
8452 (defun gnus-summary-lower-same-subject-and-select (score)
8453 "Raise articles which has the same subject with SCORE and select the next."
8455 (gnus-summary-raise-same-subject-and-select (- score)))
8457 (defun gnus-summary-lower-same-subject (score)
8458 "Raise articles which has the same subject with SCORE."
8460 (gnus-summary-raise-same-subject (- score)))
8462 (defun gnus-summary-lower-thread (score)
8463 "Raise articles under current thread with SCORE."
8465 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8467 (defun gnus-summary-kill-same-subject-and-select (unmark)
8468 "Mark articles which has the same subject as read, and then select the next.
8469 If UNMARK is positive, remove any kind of mark.
8470 If UNMARK is negative, tick articles."
8473 (setq unmark (prefix-numeric-value unmark)))
8475 (gnus-summary-mark-same-subject
8476 (gnus-summary-subject-string) unmark)))
8477 ;; Select next unread article. If auto-select-same mode, should
8478 ;; select the first unread article.
8479 (gnus-summary-next-article t (and gnus-auto-select-same
8480 (gnus-summary-subject-string)))
8481 (gnus-message 7 "%d articles are marked as %s"
8482 count (if unmark "unread" "read"))))
8484 (defun gnus-summary-kill-same-subject (unmark)
8485 "Mark articles which has the same subject as read.
8486 If UNMARK is positive, remove any kind of mark.
8487 If UNMARK is negative, tick articles."
8490 (setq unmark (prefix-numeric-value unmark)))
8492 (gnus-summary-mark-same-subject
8493 (gnus-summary-subject-string) unmark)))
8494 ;; If marked as read, go to next unread subject.
8496 ;; Go to next unread subject.
8497 (gnus-summary-next-subject 1 t))
8498 (gnus-message 7 "%d articles are marked as %s"
8499 count (if unmark "unread" "read"))))
8501 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8502 "Mark articles with same SUBJECT as read, and return marked number.
8503 If optional argument UNMARK is positive, remove any kinds of marks.
8504 If optional argument UNMARK is negative, mark articles as unread instead."
8507 (cond ((null unmark)
8508 (gnus-summary-mark-as-read nil gnus-killed-mark))
8510 (gnus-summary-tick-article nil t))
8512 (gnus-summary-tick-article)))
8514 (gnus-summary-search-forward nil subject))
8515 (cond ((null unmark)
8516 (gnus-summary-mark-as-read nil gnus-killed-mark))
8518 (gnus-summary-tick-article nil t))
8520 (gnus-summary-tick-article)))
8521 (setq count (1+ count))))
8522 ;; Hide killed thread subtrees. Does not work properly always.
8523 ;;(and (null unmark)
8524 ;; gnus-thread-hide-killed
8525 ;; (gnus-summary-hide-thread))
8526 ;; Return number of articles marked as read.
8529 (defun gnus-summary-mark-as-processable (n &optional unmark)
8530 "Set the process mark on the next N articles.
8531 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8532 the process mark instead. The difference between N and the actual
8533 number of articles marked is returned."
8535 (let ((backward (< n 0))
8540 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8541 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8542 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8544 (if (/= 0 n) (gnus-message 7 "No more articles"))
8545 (gnus-summary-recenter)
8546 (gnus-summary-position-cursor)
8549 (defun gnus-summary-unmark-as-processable (n)
8550 "Remove the process mark from the next N articles.
8551 If N is negative, mark backward instead. The difference between N and
8552 the actual number of articles marked is returned."
8554 (gnus-summary-mark-as-processable n t))
8556 (defun gnus-summary-unmark-all-processable ()
8557 "Remove the process mark from all articles."
8560 (while gnus-newsgroup-processable
8561 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8562 (gnus-summary-position-cursor))
8564 (defun gnus-summary-mark-as-expirable (n)
8565 "Mark N articles forward as expirable.
8566 If N is negative, mark backward instead. The difference between N and
8567 the actual number of articles marked is returned."
8569 (gnus-summary-mark-forward n gnus-expirable-mark))
8571 (defun gnus-summary-mark-article-as-replied (article)
8572 "Mark ARTICLE replied and update the summary line."
8573 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8574 (let ((buffer-read-only nil))
8575 (if (gnus-summary-goto-subject article)
8577 (gnus-summary-update-mark gnus-replied-mark 'replied)
8580 (defun gnus-summary-set-bookmark (article)
8581 "Set a bookmark in current article."
8582 (interactive (list (gnus-summary-article-number)))
8583 (if (or (not (get-buffer gnus-article-buffer))
8584 (not gnus-current-article)
8585 (not gnus-article-current)
8586 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8587 (error "No current article selected"))
8588 ;; Remove old bookmark, if one exists.
8589 (let ((old (assq article gnus-newsgroup-bookmarks)))
8590 (if old (setq gnus-newsgroup-bookmarks
8591 (delq old gnus-newsgroup-bookmarks))))
8592 ;; Set the new bookmark, which is on the form
8593 ;; (article-number . line-number-in-body).
8594 (setq gnus-newsgroup-bookmarks
8598 (set-buffer gnus-article-buffer)
8602 (goto-char (point-min))
8603 (search-forward "\n\n" nil t)
8606 gnus-newsgroup-bookmarks))
8607 (gnus-message 6 "A bookmark has been added to the current article."))
8609 (defun gnus-summary-remove-bookmark (article)
8610 "Remove the bookmark from the current article."
8611 (interactive (list (gnus-summary-article-number)))
8612 ;; Remove old bookmark, if one exists.
8613 (let ((old (assq article gnus-newsgroup-bookmarks)))
8616 (setq gnus-newsgroup-bookmarks
8617 (delq old gnus-newsgroup-bookmarks))
8618 (gnus-message 6 "Removed bookmark."))
8619 (gnus-message 6 "No bookmark in current article."))))
8621 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8622 (defun gnus-summary-mark-as-dormant (n)
8623 "Mark N articles forward as dormant.
8624 If N is negative, mark backward instead. The difference between N and
8625 the actual number of articles marked is returned."
8627 (gnus-summary-mark-forward n gnus-dormant-mark))
8629 (defun gnus-summary-set-process-mark (article)
8630 "Set the process mark on ARTICLE and update the summary line."
8631 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8632 (let ((buffer-read-only nil))
8633 (if (gnus-summary-goto-subject article)
8635 (gnus-summary-show-thread)
8636 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8638 (gnus-summary-update-mark gnus-process-mark 'replied)
8641 (defun gnus-summary-remove-process-mark (article)
8642 "Remove the process mark from ARTICLE and update the summary line."
8643 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8644 (let ((buffer-read-only nil))
8645 (if (gnus-summary-goto-subject article)
8647 (gnus-summary-show-thread)
8648 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8650 (gnus-summary-update-mark ? 'replied)
8651 (if (memq article gnus-newsgroup-replied)
8652 (gnus-summary-update-mark gnus-replied-mark 'replied))
8655 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8656 "Mark N articles as read forwards.
8657 If N is negative, mark backwards instead.
8658 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8660 The difference between N and the actual number of articles marked is
8663 (gnus-set-global-variables)
8664 (let ((backward (< n 0))
8666 (mark (or mark gnus-del-mark)))
8668 (gnus-summary-mark-article nil mark no-expire)
8669 (zerop (gnus-summary-next-subject
8670 (if backward -1 1) gnus-summary-goto-unread t)))
8672 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8673 (gnus-summary-recenter)
8674 (gnus-summary-position-cursor)
8675 (gnus-set-mode-line 'summary)
8678 (defun gnus-summary-mark-article (&optional article mark no-expire)
8679 "Mark ARTICLE with MARK.
8680 MARK can be any character.
8681 Five MARK strings are reserved: ? (unread),
8682 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8683 If MARK is nil, then the default character ?D is used.
8684 If ARTICLE is nil, then the article on the current line will be
8686 ;; If no mark is given, then we check auto-expiring.
8687 (and (not no-expire)
8688 gnus-newsgroup-auto-expire
8690 (and (numberp mark) (or (= mark gnus-killed-mark)
8691 (= mark gnus-del-mark)
8692 (= mark gnus-catchup-mark)
8693 (= mark gnus-low-score-mark)
8694 (= mark gnus-read-mark))))
8695 (setq mark gnus-expirable-mark))
8696 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8697 (article (or article (gnus-summary-article-number))))
8698 (if (or (= mark gnus-unread-mark)
8699 (= mark gnus-ticked-mark)
8700 (= mark gnus-dormant-mark))
8701 (gnus-mark-article-as-unread article mark)
8702 (gnus-mark-article-as-read article mark))
8704 ;; See whether the article is to be put in the cache.
8707 (gnus-cache-possibly-enter-article
8708 gnus-newsgroup-name article
8709 (gnus-get-header-by-number article)
8710 (= mark gnus-ticked-mark)
8711 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8713 (if (gnus-summary-goto-subject article)
8714 (let ((buffer-read-only nil))
8715 (gnus-summary-show-thread)
8716 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8719 (gnus-summary-update-mark mark 'unread)
8722 (defun gnus-summary-update-mark (mark type)
8724 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8728 (forward-char forward)
8729 (setq plist (text-properties-at (point)))
8732 (and plist (add-text-properties (1- (point)) (point) plist))
8733 (and (eq type 'unread)
8734 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
8735 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8737 (defun gnus-mark-article-as-read (article &optional mark)
8738 "Enter ARTICLE in the pertinent lists and remove it from others."
8739 ;; Make the article expirable.
8740 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
8741 (if (= mark gnus-expirable-mark)
8742 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8743 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8744 ;; Remove from unread and marked lists.
8745 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8746 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8747 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))))
8749 (defun gnus-mark-article-as-unread (article &optional mark)
8750 "Enter ARTICLE in the pertinent lists and remove it from others."
8751 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8752 ;; Add to unread list.
8753 (or (memq article gnus-newsgroup-unreads)
8754 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
8755 ;; If CLEAR-MARK is non-nil, the article must be removed from mark
8756 ;; lists. Otherwise, it must be added to the list.
8757 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8758 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8759 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8760 (if (= mark gnus-ticked-mark)
8761 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
8762 (if (= mark gnus-dormant-mark)
8763 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
8765 (defalias 'gnus-summary-mark-as-unread-forward
8766 'gnus-summary-tick-article-forward)
8767 (make-obsolete 'gnus-summary-mark-as-unread-forward
8768 'gnus-summary-tick-article-forward)
8769 (defun gnus-summary-tick-article-forward (n)
8770 "Tick N articles forwards.
8771 If N is negative, tick backwards instead.
8772 The difference between N and the number of articles ticked is returned."
8774 (gnus-summary-mark-forward n gnus-ticked-mark))
8776 (defalias 'gnus-summary-mark-as-unread-backward
8777 'gnus-summary-tick-article-backward)
8778 (make-obsolete 'gnus-summary-mark-as-unread-backward
8779 'gnus-summary-tick-article-backward)
8780 (defun gnus-summary-tick-article-backward (n)
8781 "Tick N articles backwards.
8782 The difference between N and the number of articles ticked is returned."
8784 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8786 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8787 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8788 (defun gnus-summary-tick-article (&optional article clear-mark)
8789 "Mark current article as unread.
8790 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8791 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8792 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8795 (defun gnus-summary-mark-as-read-forward (n)
8796 "Mark N articles as read forwards.
8797 If N is negative, mark backwards instead.
8798 The difference between N and the actual number of articles marked is
8801 (gnus-summary-mark-forward n gnus-del-mark t))
8803 (defun gnus-summary-mark-as-read-backward (n)
8804 "Mark the N articles as read backwards.
8805 The difference between N and the actual number of articles marked is
8808 (gnus-summary-mark-forward (- n) gnus-del-mark t))
8810 (defun gnus-summary-mark-as-read (&optional article mark)
8811 "Mark current article as read.
8812 ARTICLE specifies the article to be marked as read.
8813 MARK specifies a string to be inserted at the beginning of the line."
8814 (gnus-summary-mark-article article mark))
8816 (defun gnus-summary-clear-mark-forward (n)
8817 "Clear marks from N articles forward.
8818 If N is negative, clear backward instead.
8819 The difference between N and the number of marks cleared is returned."
8821 (gnus-summary-mark-forward n gnus-unread-mark))
8823 (defun gnus-summary-clear-mark-backward (n)
8824 "Clear marks from N articles backward.
8825 The difference between N and the number of marks cleared is returned."
8827 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8829 (defun gnus-summary-mark-unread-as-read ()
8830 "Intended to be used by `gnus-summary-mark-article-hook'."
8831 (or (memq gnus-current-article gnus-newsgroup-marked)
8832 (memq gnus-current-article gnus-newsgroup-dormant)
8833 (memq gnus-current-article gnus-newsgroup-expirable)
8834 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8836 (defun gnus-summary-mark-region-as-read (point mark all)
8837 "Mark all unread articles between point and mark as read.
8838 If given a prefix, mark all articles between point and mark as read,
8839 even ticked and dormant ones."
8840 (interactive "r\nP")
8850 (not (memq (gnus-summary-article-number)
8851 gnus-newsgroup-marked))
8852 (not (memq (gnus-summary-article-number)
8853 gnus-newsgroup-dormant))))
8854 (gnus-summary-mark-article
8855 (gnus-summary-article-number) gnus-del-mark))
8857 (zerop (forward-line 1))))))
8859 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8860 (defalias 'gnus-summary-delete-marked-as-read
8861 'gnus-summary-remove-lines-marked-as-read)
8862 (make-obsolete 'gnus-summary-delete-marked-as-read
8863 'gnus-summary-remove-lines-marked-as-read)
8864 (defun gnus-summary-remove-lines-marked-as-read ()
8865 "Remove lines that are marked as read."
8867 (gnus-summary-remove-lines-marked-with
8869 (lambda (char) (char-to-string (symbol-value char)))
8870 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
8871 gnus-killed-mark gnus-kill-file-mark
8872 gnus-low-score-mark gnus-expirable-mark)
8875 (defalias 'gnus-summary-delete-marked-with
8876 'gnus-summary-remove-lines-marked-with)
8877 (make-obsolete 'gnus-summary-delete-marked-with
8878 'gnus-summary-remove-lines-marked-with)
8879 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8880 (defun gnus-summary-remove-lines-marked-with (marks)
8881 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8882 (interactive "sMarks: ")
8883 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8884 (gnus-set-global-variables)
8885 (let ((buffer-read-only nil)
8886 (marks (concat "^[" marks "]")))
8887 (goto-char (point-min))
8888 (if gnus-newsgroup-adaptive
8889 (gnus-score-remove-lines-adaptive marks)
8890 (while (re-search-forward marks nil t)
8891 (gnus-delete-line)))
8892 ;; If we use dummy roots, we have to do an additional sweep over
8894 (if (not (eq gnus-summary-make-false-root 'dummy))
8896 (goto-char (point-min))
8897 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
8898 (while (re-search-forward marks nil t)
8899 (if (gnus-subject-equal
8900 (gnus-summary-subject-string)
8903 (gnus-summary-subject-string)))
8906 (gnus-delete-line))))))
8907 (or (zerop (buffer-size))
8909 (gnus-summary-prev-subject 1)
8910 (gnus-summary-position-cursor)))
8912 (defun gnus-summary-expunge-below (score)
8913 "Remove articles with score less than SCORE."
8915 (gnus-set-global-variables)
8916 (setq score (if score
8917 (prefix-numeric-value score)
8918 (or gnus-summary-default-score 0)))
8920 (set-buffer gnus-summary-buffer)
8921 (goto-char (point-min))
8922 (let ((buffer-read-only nil)
8925 (if (< (gnus-summary-article-score) score)
8929 (delete-region beg (point)))
8932 (or (zerop (buffer-size))
8934 (gnus-summary-prev-subject 1)
8935 (gnus-summary-position-cursor))))))
8937 (defun gnus-summary-mark-below (score mark)
8938 "Mark articles with score less than SCORE with MARK."
8939 (interactive "P\ncMark: ")
8940 (gnus-set-global-variables)
8941 (setq score (if score
8942 (prefix-numeric-value score)
8943 (or gnus-summary-default-score 0)))
8945 (set-buffer gnus-summary-buffer)
8946 (goto-char (point-min))
8948 (and (< (gnus-summary-article-score) score)
8949 (gnus-summary-mark-article nil mark))
8952 (defun gnus-summary-kill-below (score)
8953 "Mark articles with score below SCORE as read."
8955 (gnus-summary-mark-below score gnus-killed-mark))
8957 (defun gnus-summary-clear-above (score)
8958 "Clear all marks from articles with score above SCORE."
8960 (gnus-summary-mark-above score gnus-unread-mark))
8962 (defun gnus-summary-tick-above (score)
8963 "Tick all articles with score above SCORE."
8965 (gnus-summary-mark-above score gnus-ticked-mark))
8967 (defun gnus-summary-mark-above (score mark)
8968 "Mark articles with score over SCORE with MARK."
8969 (interactive "P\ncMark: ")
8970 (setq score (if score
8971 (prefix-numeric-value score)
8972 (or gnus-summary-default-score 0)))
8974 (set-buffer gnus-summary-buffer)
8975 (goto-char (point-min))
8977 (if (> (gnus-summary-article-score) score)
8979 (gnus-summary-mark-article nil mark)
8981 (forward-line 1)))))
8983 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8984 (defun gnus-summary-show-all-expunged ()
8985 "Display all the hidden articles that were expunged for low scores."
8987 (let ((buffer-read-only nil))
8988 (let ((scored gnus-newsgroup-scored)
8991 (or (gnus-summary-goto-subject (car (car scored)))
8992 (and (setq h (gnus-get-header-by-number (car (car scored))))
8993 (< (cdr (car scored)) gnus-summary-expunge-below)
8994 (setq headers (cons h headers))))
8995 (setq scored (cdr scored)))
8996 (or headers (error "No expunged articles hidden."))
8997 (goto-char (point-min))
8999 (gnus-summary-update-lines
9002 (gnus-summary-prepare-threads (nreverse headers) 0)
9004 (goto-char (point-min))
9005 (gnus-summary-position-cursor)))
9007 (defun gnus-summary-show-all-dormant ()
9008 "Display all the hidden articles that are marked as dormant."
9010 (let ((buffer-read-only nil))
9011 (goto-char (point-min))
9012 (let ((dormant gnus-newsgroup-dormant)
9015 (or (gnus-summary-goto-subject (car dormant))
9016 (and (setq h (gnus-get-header-by-number (car dormant)))
9017 (setq headers (cons h headers))))
9018 (setq dormant (cdr dormant)))
9019 (or headers (error "No dormant articles hidden."))
9021 (gnus-summary-update-lines
9024 (gnus-summary-prepare-threads (nreverse headers) 0)
9026 (goto-char (point-min))
9027 (gnus-summary-position-cursor)))
9029 (defun gnus-summary-hide-all-dormant ()
9030 "Hide all dormant articles."
9032 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9033 (gnus-summary-position-cursor))
9035 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
9036 "Mark all articles not marked as unread in this newsgroup as read.
9037 If prefix argument ALL is non-nil, all articles are marked as read.
9038 If QUIETLY is non-nil, no questions will be asked.
9039 If TO-HERE is non-nil, it should be a point in the buffer. All
9040 articles before this point will be marked as read.
9041 The number of articles marked as read is returned."
9045 (not gnus-interactive-catchup) ;Without confirmation?
9049 "Mark absolutely all articles as read? "
9050 "Mark all unread articles as read? ")))
9052 (not gnus-newsgroup-adaptive)
9053 (not gnus-newsgroup-auto-expire))
9055 (and all (setq gnus-newsgroup-marked nil
9056 gnus-newsgroup-dormant nil))
9057 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))
9058 (let ((unreads (length gnus-newsgroup-unreads)))
9059 (if (gnus-summary-first-subject (not all))
9060 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
9061 (if to-here (< (point) to-here) t)
9062 (gnus-summary-search-subject nil (not all)))))
9063 (- unreads (length gnus-newsgroup-unreads))
9065 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9066 (gnus-summary-position-cursor)))
9068 (defun gnus-summary-catchup-to-here (&optional all)
9069 "Mark all unticked articles before the current one as read.
9070 If ALL is non-nil, also mark ticked and dormant articles as read."
9073 (gnus-summary-catchup all t (point))
9074 (gnus-set-mode-line 'summary)
9075 (gnus-summary-position-cursor))
9077 (defun gnus-summary-catchup-all (&optional quietly)
9078 "Mark all articles in this newsgroup as read."
9080 (gnus-summary-catchup t quietly))
9082 (defun gnus-summary-catchup-and-exit (all &optional quietly)
9083 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9084 If prefix argument ALL is non-nil, all articles are marked as read."
9086 (gnus-summary-catchup all quietly nil 'fast)
9087 ;; Select next newsgroup or exit.
9088 (if (eq gnus-auto-select-next 'quietly)
9089 (gnus-summary-next-group nil)
9090 (gnus-summary-exit)))
9092 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9093 "Mark all articles in this newsgroup as read, and then exit."
9095 (gnus-summary-catchup-and-exit t quietly))
9097 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9098 (defun gnus-summary-catchup-and-goto-next-group (all)
9099 "Mark all articles in this group as read and select the next group.
9100 If given a prefix, mark all articles, unread as well as ticked, as
9103 (gnus-summary-catchup all)
9104 (gnus-summary-next-group))
9106 ;; Thread-based commands.
9108 (defun gnus-summary-toggle-threads (arg)
9109 "Toggle showing conversation threads.
9110 If ARG is positive number, turn showing conversation threads on."
9112 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9113 (setq gnus-show-threads
9114 (if (null arg) (not gnus-show-threads)
9115 (> (prefix-numeric-value arg) 0)))
9116 (gnus-summary-prepare)
9117 (gnus-summary-goto-subject current)
9118 (gnus-summary-position-cursor)))
9120 (defun gnus-summary-show-all-threads ()
9124 (let ((buffer-read-only nil))
9125 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9126 (gnus-summary-position-cursor))
9128 (defun gnus-summary-show-thread ()
9129 "Show thread subtrees.
9130 Returns nil if no thread was there to be shown."
9134 (let ((buffer-read-only nil)
9135 ;; first goto end then to beg, to have point at beg after let
9136 (end (progn (end-of-line) (point)))
9137 (beg (progn (beginning-of-line) (point))))
9139 ;; Any hidden lines here?
9140 (search-forward "\r" end t)
9141 (subst-char-in-region beg end ?\^M ?\n t))))
9142 (gnus-summary-position-cursor)))
9144 (defun gnus-summary-hide-all-threads ()
9145 "Hide all thread subtrees."
9148 (goto-char (point-min))
9149 (gnus-summary-hide-thread)
9150 (while (and (not (eobp)) (zerop (forward-line 1)))
9151 (gnus-summary-hide-thread)))
9152 (gnus-summary-position-cursor))
9154 (defun gnus-summary-hide-thread ()
9155 "Hide thread subtrees.
9156 Returns nil if no threads were there to be hidden."
9158 (let ((buffer-read-only nil)
9160 (level (gnus-summary-thread-level))
9162 ;; Go forward until either the buffer ends or the subthread
9166 (while (and (zerop (forward-line 1))
9167 (> (gnus-summary-thread-level) level))
9172 (search-backward "\n" start t))
9173 (subst-char-in-region start end ?\n ?\^M t)
9174 (forward-line -1)))))
9176 (defun gnus-summary-go-to-next-thread (&optional previous)
9177 "Go to the same level (or less) next thread.
9178 If PREVIOUS is non-nil, go to previous thread instead.
9179 Return the article number moved to, or nil if moving was impossible."
9180 (let ((level (gnus-summary-thread-level))
9181 (article (gnus-summary-article-number)))
9183 (while (and (zerop (gnus-summary-prev-subject 1))
9184 (> (gnus-summary-thread-level) level)))
9185 (while (and (zerop (gnus-summary-next-subject 1))
9186 (> (gnus-summary-thread-level) level))))
9187 (gnus-summary-recenter)
9188 (gnus-summary-position-cursor)
9189 (let ((oart (gnus-summary-article-number)))
9190 (and (/= oart article) oart))))
9192 (defun gnus-summary-next-thread (n)
9193 "Go to the same level next N'th thread.
9194 If N is negative, search backward instead.
9195 Returns the difference between N and the number of skips actually
9198 (let ((backward (< n 0))
9201 (gnus-summary-go-to-next-thread backward))
9203 (gnus-summary-position-cursor)
9204 (if (/= 0 n) (gnus-message 7 "No more threads"))
9207 (defun gnus-summary-prev-thread (n)
9208 "Go to the same level previous N'th thread.
9209 Returns the difference between N and the number of skips actually
9212 (gnus-summary-next-thread (- n)))
9214 (defun gnus-summary-go-down-thread (&optional same)
9215 "Go down one level in the current thread.
9216 If SAME is non-nil, also move to articles of the same level."
9217 (let ((level (gnus-summary-thread-level))
9219 (if (and (zerop (forward-line 1))
9220 (> (gnus-summary-thread-level) level))
9225 (defun gnus-summary-go-up-thread ()
9226 "Go up one level in the current thread."
9227 (let ((level (gnus-summary-thread-level))
9229 (while (and (zerop (forward-line -1))
9230 (>= (gnus-summary-thread-level) level)))
9231 (if (>= (gnus-summary-thread-level) level)
9237 (defun gnus-summary-down-thread (n)
9238 "Go down thread N steps.
9239 If N is negative, go up instead.
9240 Returns the difference between N and how many steps down that were
9246 (if up (gnus-summary-go-up-thread)
9247 (gnus-summary-go-down-thread)))
9249 (gnus-summary-position-cursor)
9250 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9253 (defun gnus-summary-up-thread (n)
9254 "Go up thread N steps.
9255 If N is negative, go up instead.
9256 Returns the difference between N and how many steps down that were
9259 (gnus-summary-down-thread (- n)))
9261 (defun gnus-summary-kill-thread (unmark)
9262 "Mark articles under current thread as read.
9263 If the prefix argument is positive, remove any kinds of marks.
9264 If the prefix argument is negative, tick articles instead."
9267 (setq unmark (prefix-numeric-value unmark)))
9269 (level (gnus-summary-thread-level)))
9272 ;; Mark the article...
9273 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
9274 ((> unmark 0) (gnus-summary-tick-article nil t))
9275 (t (gnus-summary-tick-article)))
9276 ;; ...and go forward until either the buffer ends or the subtree
9278 (if (not (and (zerop (forward-line 1))
9279 (> (gnus-summary-thread-level) level)))
9280 (setq killing nil))))
9281 ;; Hide killed subtrees.
9283 gnus-thread-hide-killed
9284 (gnus-summary-hide-thread))
9285 ;; If marked as read, go to next unread subject.
9287 ;; Go to next unread subject.
9288 (gnus-summary-next-subject 1 t)))
9289 (gnus-set-mode-line 'summary))
9291 ;; Summary sorting commands
9293 (defun gnus-summary-sort-by-number (&optional reverse)
9294 "Sort summary buffer by article number.
9295 Argument REVERSE means reverse order."
9298 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9300 (defun gnus-summary-sort-by-author (&optional reverse)
9301 "Sort summary buffer by author name alphabetically.
9302 If case-fold-search is non-nil, case of letters is ignored.
9303 Argument REVERSE means reverse order."
9308 (let ((extract (funcall
9309 gnus-extract-address-components
9310 (header-from (gnus-get-header-by-number
9311 (gnus-summary-article-number))))))
9312 (or (car extract) (cdr extract))))
9313 'gnus-thread-sort-by-author)
9316 (defun gnus-summary-sort-by-subject (&optional reverse)
9317 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9318 If case-fold-search is non-nil, case of letters is ignored.
9319 Argument REVERSE means reverse order."
9324 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9325 'gnus-thread-sort-by-subject)
9328 (defun gnus-summary-sort-by-date (&optional reverse)
9329 "Sort summary buffer by date.
9330 Argument REVERSE means reverse order."
9337 (gnus-get-header-by-number (gnus-summary-article-number)))))
9338 'gnus-thread-sort-by-date)
9341 (defun gnus-summary-sort-by-score (&optional reverse)
9342 "Sort summary buffer by score.
9343 Argument REVERSE means reverse order."
9346 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9349 (defvar gnus-summary-already-sorted nil)
9350 (defun gnus-summary-sort (predicate reverse)
9351 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9352 (if gnus-summary-already-sorted
9354 (let (buffer-read-only)
9355 (if (not gnus-show-threads)
9357 (goto-char (point-min))
9358 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9359 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9360 (gnus-summary-prepare-hook nil)
9361 (gnus-summary-already-sorted nil))
9362 (gnus-summary-prepare)
9363 (and gnus-show-threads
9364 gnus-thread-hide-subtree
9365 (gnus-summary-hide-all-threads)))))))
9367 (defun gnus-sortable-date (date)
9368 "Make sortable string by string-lessp from DATE.
9369 Timezone package is used."
9370 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9371 (year (aref date 0))
9372 (month (aref date 1))
9373 (day (aref date 2)))
9374 (timezone-make-sortable-date
9376 (timezone-make-time-string
9377 (aref date 3) (aref date 4) (aref date 5)))))
9380 ;; Summary saving commands.
9382 (defun gnus-summary-save-article (n)
9383 "Save the current article using the default saver function.
9384 If N is a positive number, save the N next articles.
9385 If N is a negative number, save the N previous articles.
9386 If N is nil and any articles have been marked with the process mark,
9387 save those articles instead.
9388 The variable `gnus-default-article-saver' specifies the saver function."
9390 (let ((articles (gnus-summary-work-articles n)))
9392 (let ((header (gnus-get-header-by-number (car articles))))
9393 (if (vectorp header)
9395 (gnus-summary-select-article t nil nil (car articles))
9396 (or gnus-save-all-headers
9397 (gnus-article-hide-headers t))
9398 ;; Remove any X-Gnus lines.
9401 (set-buffer gnus-article-buffer)
9402 (let ((buffer-read-only nil))
9403 (goto-char (point-min))
9404 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9406 (while (re-search-forward "^X-Gnus" nil t)
9408 (delete-region (point)
9409 (progn (forward-line 1) (point))))
9412 (if gnus-default-article-saver
9413 (funcall gnus-default-article-saver)
9414 (error "No default saver is defined."))))
9415 (if (assq 'name header)
9416 (gnus-copy-file (cdr (assq 'name header)))
9417 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9418 (gnus-summary-remove-process-mark (car articles))
9419 (setq articles (cdr articles)))
9420 (gnus-summary-position-cursor)
9423 (defun gnus-summary-pipe-output (arg)
9424 "Pipe the current article to a subprocess.
9425 If N is a positive number, pipe the N next articles.
9426 If N is a negative number, pipe the N previous articles.
9427 If N is nil and any articles have been marked with the process mark,
9428 pipe those articles instead."
9430 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9431 (gnus-summary-save-article arg)))
9433 (defun gnus-summary-save-article-mail (arg)
9434 "Append the current article to an mail file.
9435 If N is a positive number, save the N next articles.
9436 If N is a negative number, save the N previous articles.
9437 If N is nil and any articles have been marked with the process mark,
9438 save those articles instead."
9440 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9441 (gnus-summary-save-article arg)))
9443 (defun gnus-summary-save-article-rmail (arg)
9444 "Append the current article to an rmail file.
9445 If N is a positive number, save the N next articles.
9446 If N is a negative number, save the N previous articles.
9447 If N is nil and any articles have been marked with the process mark,
9448 save those articles instead."
9450 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9451 (gnus-summary-save-article arg)))
9453 (defun gnus-summary-save-article-file (arg)
9454 "Append the current article to a file.
9455 If N is a positive number, save the N next articles.
9456 If N is a negative number, save the N previous articles.
9457 If N is nil and any articles have been marked with the process mark,
9458 save those articles instead."
9460 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9461 (gnus-summary-save-article arg)))
9463 (defun gnus-read-save-file-name (prompt default-name)
9464 (let ((methods gnus-split-methods)
9466 (if (not gnus-split-methods)
9469 (set-buffer gnus-article-buffer)
9470 (gnus-narrow-to-headers)
9472 (goto-char (point-min))
9473 (and (condition-case ()
9474 (re-search-forward (car (car methods)) nil t)
9476 (setq split-name (cons (nth 1 (car methods)) split-name)))
9477 (setq methods (cdr methods)))
9479 (cond ((null split-name)
9481 (concat prompt " (default "
9482 (file-name-nondirectory default-name) ") ")
9483 (file-name-directory default-name)
9485 ((= 1 (length split-name))
9487 (concat prompt " (default " (car split-name) ") ")
9488 gnus-article-save-directory
9489 (concat gnus-article-save-directory (car split-name))))
9491 (setq split-name (mapcar (lambda (el) (list el))
9492 (nreverse split-name)))
9493 (let ((result (completing-read
9495 split-name nil nil)))
9496 (concat gnus-article-save-directory
9497 (if (string= result "")
9498 (car (car split-name))
9501 (defun gnus-summary-save-in-rmail (&optional filename)
9502 "Append this article to Rmail file.
9503 Optional argument FILENAME specifies file name.
9504 Directory to save to is default to `gnus-article-save-directory' which
9505 is initialized from the SAVEDIR environment variable."
9508 (funcall gnus-rmail-save-name gnus-newsgroup-name
9509 gnus-current-headers gnus-newsgroup-last-rmail)))
9511 (setq filename (gnus-read-save-file-name
9512 "Save in rmail file:" default-name)))
9513 (gnus-make-directory (file-name-directory filename))
9514 (gnus-eval-in-buffer-window
9519 (gnus-output-to-rmail filename))))
9520 ;; Remember the directory name to save articles.
9521 (setq gnus-newsgroup-last-rmail filename)))
9523 (defun gnus-summary-save-in-mail (&optional filename)
9524 "Append this article to Unix mail file.
9525 Optional argument FILENAME specifies file name.
9526 Directory to save to is default to `gnus-article-save-directory' which
9527 is initialized from the SAVEDIR environment variable."
9530 (funcall gnus-mail-save-name gnus-newsgroup-name
9531 gnus-current-headers gnus-newsgroup-last-mail)))
9533 (setq filename (gnus-read-save-file-name
9534 "Save in Unix mail file:" default-name)))
9536 (expand-file-name filename
9538 (file-name-directory default-name))))
9539 (gnus-make-directory (file-name-directory filename))
9540 (gnus-eval-in-buffer-window
9545 (if (and (file-readable-p filename) (rmail-file-p filename))
9546 (gnus-output-to-rmail filename)
9547 (rmail-output filename 1 t t)))))
9548 ;; Remember the directory name to save articles.
9549 (setq gnus-newsgroup-last-mail filename)))
9551 (defun gnus-summary-save-in-file (&optional filename)
9552 "Append this article to file.
9553 Optional argument FILENAME specifies file name.
9554 Directory to save to is default to `gnus-article-save-directory' which
9555 is initialized from the SAVEDIR environment variable."
9558 (funcall gnus-file-save-name gnus-newsgroup-name
9559 gnus-current-headers gnus-newsgroup-last-file)))
9561 (setq filename (gnus-read-save-file-name
9562 "Save in file:" default-name)))
9563 (gnus-make-directory (file-name-directory filename))
9564 (gnus-eval-in-buffer-window
9569 (gnus-output-to-file filename))))
9570 ;; Remember the directory name to save articles.
9571 (setq gnus-newsgroup-last-file filename)))
9573 (defun gnus-summary-save-in-pipe (&optional command)
9574 "Pipe this article to subprocess."
9576 (let ((command (read-string "Shell command on article: "
9577 gnus-last-shell-command)))
9578 (if (string-equal command "")
9579 (setq command gnus-last-shell-command))
9580 (gnus-eval-in-buffer-window
9584 (shell-command-on-region (point-min) (point-max) command nil)))
9585 (setq gnus-last-shell-command command)))
9587 ;; Summary extract commands
9589 (defun gnus-summary-insert-pseudos (pslist)
9590 (let ((buffer-read-only nil)
9591 (article (gnus-summary-article-number))
9593 (or (gnus-summary-goto-subject article)
9594 (error (format "No such article: %d" article)))
9595 (or gnus-newsgroup-headers-hashtb-by-number
9596 (gnus-make-headers-hashtable-by-number))
9597 (gnus-summary-position-cursor)
9598 ;; If all commands are to be bunched up on one line, we collect
9600 (if gnus-view-pseudos-separately
9602 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9605 (setq action (cdr (assq 'action (car ps))))
9606 (setq files (list (cdr (assq 'name (car ps)))))
9607 (while (and ps (cdr ps)
9608 (string= (or action "1")
9609 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9610 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9611 (setcdr ps (cdr (cdr ps))))
9614 (if (not (string-match "%s" action))
9615 (setq files (cons " " files)))
9616 (setq files (cons " " files))
9617 (and (assq 'execute (car ps))
9618 (setcdr (assq 'execute (car ps))
9619 (funcall (if (string-match "%s" action)
9622 (mapconcat (lambda (f) f) files " ")))))
9623 (setq ps (cdr ps)))))
9624 (if gnus-view-pseudos
9626 (and (assq 'execute (car pslist))
9627 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9628 (eq gnus-view-pseudos 'not-confirm)))
9629 (setq pslist (cdr pslist)))
9632 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9633 (gnus-summary-article-number)))
9636 (insert " " (file-name-nondirectory
9637 (cdr (assq 'name (car pslist))))
9638 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9639 (add-text-properties
9640 b (1+ b) (list 'gnus-number gnus-reffed-article-number
9641 'gnus-mark gnus-unread-mark
9643 'gnus-pseudo (car pslist)))
9645 (gnus-sethash (int-to-string gnus-reffed-article-number)
9646 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9647 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9648 (setq pslist (cdr pslist)))))))
9650 (defun gnus-pseudos< (p1 p2)
9651 (let ((c1 (cdr (assq 'action p1)))
9652 (c2 (cdr (assq 'action p2))))
9653 (and c1 c2 (string< c1 c2))))
9655 (defun gnus-request-pseudo-article (props)
9656 (cond ((assq 'execute props)
9657 (gnus-execute-command (cdr (assq 'execute props)))))
9658 (let ((gnus-current-article (gnus-summary-article-number)))
9659 (run-hooks 'gnus-mark-article-hook)))
9661 (defun gnus-execute-command (command &optional automatic)
9663 (gnus-article-setup-buffer)
9664 (set-buffer gnus-article-buffer)
9665 (let ((command (if automatic command (read-string "Command: " command)))
9666 (buffer-read-only nil))
9668 (insert "$ " command "\n\n")
9669 (if gnus-view-pseudo-asynchronously
9670 (start-process "gnus-execute" nil "sh" "-c" command)
9671 (call-process "sh" nil t nil "-c" command)))))
9673 (defun gnus-copy-file (file &optional to)
9676 (list (read-file-name "Copy file: " default-directory)
9677 (read-file-name "Copy file to: " default-directory)))
9678 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9679 (and (file-directory-p to)
9680 (setq to (concat (file-name-as-directory to)
9681 (file-name-nondirectory file))))
9682 (copy-file file to))
9684 ;; Summary kill commands.
9686 (defun gnus-summary-edit-global-kill (article)
9687 "Edit the \"global\" kill file."
9688 (interactive (list (gnus-summary-article-number)))
9689 (gnus-group-edit-global-kill article))
9691 (defun gnus-summary-edit-local-kill ()
9692 "Edit a local kill file applied to the current newsgroup."
9694 (setq gnus-current-headers
9696 (int-to-string (gnus-summary-article-number))
9697 gnus-newsgroup-headers-hashtb-by-number))
9698 (gnus-set-global-variables)
9699 (gnus-group-edit-local-kill
9700 (gnus-summary-article-number) gnus-newsgroup-name))
9704 ;;; Gnus article mode
9707 (put 'gnus-article-mode 'mode-class 'special)
9709 (if gnus-article-mode-map
9711 (setq gnus-article-mode-map (make-keymap))
9712 (suppress-keymap gnus-article-mode-map)
9713 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9714 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9715 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9716 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9717 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9718 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9719 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9720 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9721 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
9722 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
9723 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
9725 ;; Duplicate almost all summary keystrokes in the article mode map.
9727 (list "#" "\M-#" "\C-c\M-#" "n" "p"
9728 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9729 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9730 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k""x" "X"
9731 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9733 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "M"
9736 (define-key gnus-article-mode-map (car commands)
9737 'gnus-article-summary-command)
9738 (setq commands (cdr commands))))
9740 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F")))
9742 (define-key gnus-article-mode-map (car commands)
9743 'gnus-article-summary-command-nosave)
9744 (setq commands (cdr commands)))))
9747 (defun gnus-article-mode ()
9748 "Major mode for displaying an article.
9750 All normal editing commands are switched off.
9752 The following commands are available:
9754 \\<gnus-article-mode-map>
9755 \\[gnus-article-next-page]\t Scroll the article one page forwards
9756 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9757 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9758 \\[gnus-article-show-summary]\t Display the summary buffer
9759 \\[gnus-article-mail]\t Send a reply to the address near point
9760 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9761 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9762 \\[gnus-info-find-node]\t Go to the Gnus info node"
9764 (if gnus-visual (gnus-article-make-menu-bar))
9765 (kill-all-local-variables)
9766 (setq mode-line-modified "-- ")
9767 (make-local-variable 'mode-line-format)
9768 (setq mode-line-format (copy-sequence mode-line-format))
9769 (and (equal (nth 3 mode-line-format) " ")
9770 (setcar (nthcdr 3 mode-line-format) ""))
9771 (setq mode-name "Article")
9772 (setq major-mode 'gnus-article-mode)
9773 (make-local-variable 'minor-mode-alist)
9774 (or (assq 'gnus-show-mime minor-mode-alist)
9775 (setq minor-mode-alist
9776 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9777 (use-local-map gnus-article-mode-map)
9778 (make-local-variable 'page-delimiter)
9779 (setq page-delimiter gnus-page-delimiter)
9780 (buffer-disable-undo (current-buffer))
9781 (setq buffer-read-only t) ;Disable modification
9782 (run-hooks 'gnus-article-mode-hook))
9784 (defun gnus-article-setup-buffer ()
9785 "Initialize article mode buffer."
9786 (if (get-buffer gnus-article-buffer)
9788 (set-buffer gnus-article-buffer)
9789 (or (eq major-mode 'gnus-article-mode)
9790 (gnus-article-mode)))
9792 (set-buffer (get-buffer-create gnus-article-buffer))
9793 (gnus-add-current-to-buffer-list)
9794 (gnus-article-mode))))
9796 ;; Set article window start at LINE, where LINE is the number of lines
9797 ;; from the head of the article.
9798 (defun gnus-article-set-window-start (&optional line)
9800 (get-buffer-window gnus-article-buffer)
9802 (set-buffer gnus-article-buffer)
9803 (goto-char (point-min))
9806 (gnus-message 6 "Moved to bookmark")
9807 (search-forward "\n\n" nil t)
9811 (defun gnus-request-article-this-buffer (article group)
9812 "Get an article and insert it into this buffer."
9813 (setq group (or group gnus-newsgroup-name))
9815 ;; Open server if it has closed.
9816 (gnus-check-news-server (gnus-find-method-for-group group))
9818 ;; Using `gnus-request-article' directly will insert the article into
9819 ;; `nntp-server-buffer' - so we'll save some time by not having to
9820 ;; copy it from the server buffer into the article buffer.
9822 ;; We only request an article by message-id when we do not have the
9823 ;; headers for it, so we'll have to get those.
9824 (and (stringp article)
9825 (let ((gnus-override-method gnus-refer-article-method))
9826 (gnus-read-header article)))
9828 ;; If the article number is negative, that means that this article
9829 ;; doesn't belong in this newsgroup (possibly), so we find its
9830 ;; message-id and request it by id instead of number.
9831 (if (not (numberp article))
9834 (set-buffer gnus-summary-buffer)
9835 (let ((header (gnus-get-header-by-number article)))
9837 (if (vectorp header)
9838 ;; It's a real article.
9839 (setq article (header-id header))
9840 ;; It is an extracted pseudo-article.
9841 (setq article 'pseudo)
9842 (gnus-request-pseudo-article header)))
9844 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9845 (if (not (eq (car method) 'nneething))
9847 (let ((dir (concat (file-name-as-directory (nth 1 method))
9848 (header-subject header))))
9849 (if (file-directory-p dir)
9851 (setq article 'nneething)
9852 (gnus-group-enter-directory dir)))))))))
9855 (if (and gnus-use-cache
9857 (gnus-cache-request-article article group))
9859 ;; Get the article and into the article buffer.
9860 (if (or (stringp article) (numberp article))
9863 (let ((gnus-override-method
9864 (and (stringp article) gnus-refer-article-method)))
9865 (and (gnus-request-article article group (current-buffer))
9869 (defun gnus-read-header (id)
9870 "Read the headers of article ID and enter them into the Gnus system."
9871 (or gnus-newsgroup-headers-hashtb-by-number
9872 (gnus-make-headers-hashtable-by-number))
9874 (if (not (setq header
9875 (car (if (let ((gnus-nov-is-evil t))
9876 (gnus-retrieve-headers
9877 (list id) gnus-newsgroup-name))
9878 (gnus-get-newsgroup-headers)))))
9881 (header-set-number header gnus-reffed-article-number))
9882 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9883 (gnus-sethash (int-to-string (header-number header)) header
9884 gnus-newsgroup-headers-hashtb-by-number)
9886 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9887 (setq gnus-current-headers header)
9890 (defun gnus-article-prepare (article &optional all-headers header)
9891 "Prepare ARTICLE in article mode buffer.
9892 ARTICLE should either be an article number or a Message-ID.
9893 If ARTICLE is an id, HEADER should be the article headers.
9894 If ALL-HEADERS is non-nil, no headers are hidden."
9896 ;; Make sure we start in a summary buffer.
9897 (or (eq major-mode 'gnus-summary-mode)
9898 (set-buffer gnus-summary-buffer))
9899 (setq gnus-summary-buffer (current-buffer))
9900 ;; Make sure the connection to the server is alive.
9901 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9903 (gnus-check-news-server
9904 (gnus-find-method-for-group gnus-newsgroup-name))
9905 (gnus-request-group gnus-newsgroup-name t)))
9906 (or gnus-newsgroup-headers-hashtb-by-number
9907 (gnus-make-headers-hashtable-by-number))
9908 (let* ((article (if header (header-number header) article))
9909 (summary-buffer (current-buffer))
9910 (internal-hook gnus-article-internal-prepare-hook)
9911 (group gnus-newsgroup-name)
9914 (gnus-article-setup-buffer)
9915 (set-buffer gnus-article-buffer)
9916 (if (not (setq result (let ((buffer-read-only nil))
9917 (gnus-request-article-this-buffer
9919 ;; There is no such article.
9922 (set-buffer gnus-summary-buffer)
9923 (setq gnus-current-article 0)
9924 (and (numberp article)
9925 (gnus-summary-mark-as-read article gnus-canceled-mark))
9926 (gnus-message 1 "No such article (may be canceled)")
9927 (and (numberp article)
9928 (setq gnus-current-article article))
9930 (and (numberp article)
9931 (setq gnus-article-current
9932 (cons gnus-newsgroup-name article)))
9934 (if (or (eq result 'pseudo) (eq result 'nneething))
9937 (set-buffer summary-buffer)
9938 (setq gnus-last-article gnus-current-article
9939 gnus-newsgroup-history (cons gnus-current-article
9940 gnus-newsgroup-history)
9941 gnus-current-article 0
9942 gnus-current-headers nil
9943 gnus-article-current nil)
9944 (if (eq result 'nneething)
9945 (gnus-configure-windows 'summary)
9946 (gnus-configure-windows 'article))
9947 (gnus-set-global-variables))
9948 (gnus-set-mode-line 'article))
9949 ;; The result from the `request' was an actual article -
9950 ;; or at least some text that is now displayed in the
9952 (if (and (numberp article)
9953 (not (eq article gnus-current-article)))
9954 ;; Seems like a new article has been selected.
9955 ;; `gnus-current-article' must be an article number.
9957 (set-buffer summary-buffer)
9958 (setq gnus-last-article gnus-current-article
9959 gnus-newsgroup-history (cons gnus-current-article
9960 gnus-newsgroup-history)
9961 gnus-current-article article
9962 gnus-current-headers
9963 (gnus-get-header-by-number gnus-current-article)
9964 gnus-article-current
9965 (cons gnus-newsgroup-name gnus-current-article))
9966 (gnus-summary-show-thread)
9967 (run-hooks 'gnus-mark-article-hook)
9968 (gnus-set-mode-line 'summary)
9970 (run-hooks 'gnus-visual-mark-article-hook))
9971 ;; Set the global newsgroup variables here.
9972 ;; Suggested by Jim Sisolak
9973 ;; <sisolak@trans4.neep.wisc.edu>.
9974 (gnus-set-global-variables)
9976 (gnus-cache-possibly-enter-article
9978 (gnus-get-header-by-number article)
9979 (memq article gnus-newsgroup-marked)
9980 (memq article gnus-newsgroup-dormant)
9981 (memq article gnus-newsgroup-unreads)))))
9982 ;; gnus-have-all-headers must be either T or NIL.
9983 (setq gnus-have-all-headers
9984 (not (not (or all-headers gnus-show-all-headers))))
9985 ;; Hooks for getting information from the article.
9986 ;; This hook must be called before being narrowed.
9987 (let (buffer-read-only)
9988 (run-hooks 'internal-hook)
9989 (run-hooks 'gnus-article-prepare-hook)
9990 ;; Decode MIME message.
9991 (if (and gnus-show-mime
9992 (gnus-fetch-field "Mime-Version"))
9993 (funcall gnus-show-mime-method))
9994 ;; Perform the article display hooks.
9995 (run-hooks 'gnus-article-display-hook))
9997 (goto-char (point-min))
9998 (and gnus-break-pages (gnus-narrow-to-page))
9999 (gnus-set-mode-line 'article)
10000 (gnus-configure-windows 'article)
10001 (goto-char (point-min))
10004 (defun gnus-article-show-all-headers ()
10005 "Show all article headers in article mode buffer."
10007 (gnus-article-setup-buffer)
10008 (set-buffer gnus-article-buffer)
10009 (let ((buffer-read-only nil))
10010 (remove-text-properties (point-min) (point-max)
10011 gnus-hidden-properties))))
10013 (defun gnus-article-hide-headers-if-wanted ()
10014 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10015 Provided for backwards compatability."
10016 (or gnus-have-all-headers
10017 (gnus-article-hide-headers)))
10019 (defun gnus-article-hide-headers (&optional delete)
10020 "Hide unwanted headers and possibly sort them as well."
10023 (set-buffer gnus-article-buffer)
10025 (let ((sorted gnus-sorted-header-list)
10026 (buffer-read-only nil)
10027 want want-list beg want-l)
10028 ;; First we narrow to just the headers.
10030 (goto-char (point-min))
10031 ;; Hide any "From " lines at the beginning of (mail) articles.
10032 (while (looking-at "From ")
10035 (add-text-properties (point-min) (point) gnus-hidden-properties))
10036 ;; Then treat the rest of the header lines.
10039 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10040 ;; Then we use the two regular expressions
10041 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10042 ;; select which header lines is to remain visible in the
10044 (goto-char (point-min))
10045 (while (re-search-forward "^[^ \t]*:" nil t)
10046 (beginning-of-line)
10047 ;; We add the headers we want to keep to a list and delete
10048 ;; them from the buffer.
10049 (if (or (and (stringp gnus-visible-headers)
10050 (looking-at gnus-visible-headers))
10051 (and (not (stringp gnus-visible-headers))
10052 (stringp gnus-ignored-headers)
10053 (not (looking-at gnus-ignored-headers))))
10057 ;; Be sure to get multi-line headers...
10058 (re-search-forward "^[^ \t]*:" nil t)
10059 (beginning-of-line)
10061 (cons (buffer-substring beg (point)) want-list))
10062 (delete-region beg (point))
10065 ;; Next we perform the sorting by looking at
10066 ;; `gnus-sorted-header-list'.
10067 (goto-char (point-min))
10068 (while (and sorted want-list)
10069 (setq want-l want-list)
10071 (not (string-match (car sorted) (car want-l))))
10072 (setq want-l (cdr want-l)))
10075 (insert (car want-l))
10076 (setq want-list (delq (car want-l) want-list))))
10077 (setq sorted (cdr sorted)))
10078 ;; Any headers that were not matched by the sorted list we
10079 ;; just tack on the end of the visible header list.
10081 (insert (car want-list))
10082 (setq want-list (cdr want-list)))
10083 ;; And finally we make the unwanted headers invisible.
10085 (delete-region (point) (point-max))
10086 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10087 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10089 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10090 (defun gnus-article-treat-overstrike ()
10091 "Translate overstrikes into bold text."
10094 (set-buffer gnus-article-buffer)
10095 (let ((buffer-read-only nil))
10096 (while (search-forward "\b" nil t)
10097 (let ((next (following-char))
10098 (previous (char-after (- (point) 2))))
10099 (cond ((eq next previous)
10100 (delete-region (- (point) 2) (point))
10101 (put-text-property (point) (1+ (point))
10104 (delete-region (1- (point)) (1+ (point)))
10105 (put-text-property (1- (point)) (point)
10108 (delete-region (- (point) 2) (point))
10109 (put-text-property (point) (1+ (point))
10110 'face 'underline))))))))
10112 (defun gnus-article-word-wrap ()
10113 "Format too long lines."
10116 (set-buffer gnus-article-buffer)
10117 (let ((buffer-read-only nil))
10118 (goto-char (point-min))
10119 (search-forward "\n\n" nil t)
10121 (let ((paragraph-start "^\\W"))
10122 (while (not (eobp))
10123 (and (>= (current-column) (min fill-column (window-width)))
10124 (/= (preceding-char) ?:)
10125 (fill-paragraph nil))
10126 (end-of-line 2))))))
10128 (defun gnus-article-remove-cr ()
10129 "Remove carriage returns from an article."
10132 (set-buffer gnus-article-buffer)
10133 (let ((buffer-read-only nil))
10134 (goto-char (point-min))
10135 (while (search-forward "\r" nil t)
10136 (replace-match "" t t)))))
10138 (defun gnus-article-display-x-face (&optional force)
10139 "Look for an X-Face header and display it if present."
10140 (interactive (list 'force))
10142 (set-buffer gnus-article-buffer)
10143 (let ((inhibit-point-motion-hooks t)
10144 (case-fold-search nil))
10146 (goto-char (point-min))
10147 (search-forward "\n\n")
10148 (narrow-to-region (point-min) (point))
10149 (goto-char (point-min))
10150 (if (or (not gnus-article-x-face-command)
10152 (or (not gnus-article-x-face-too-ugly)
10153 (string-match gnus-article-x-face-too-ugly
10154 (mail-fetch-field "from"))))
10156 (goto-char (point-min))
10157 (not (re-search-forward "^X-Face: " nil t))))
10159 (let ((beg (point))
10160 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
10161 (if (symbolp gnus-article-x-face-command)
10162 (and (or (fboundp gnus-article-x-face-command)
10163 (error "%s is not a function"
10164 gnus-article-x-face-command))
10165 (funcall gnus-article-x-face-command beg end))
10166 (call-process-region beg end "sh" nil 0 nil
10167 "-c" gnus-article-x-face-command))))))))
10169 (defun gnus-article-de-quoted-unreadable (&optional force)
10170 "Do a naïve translation of a quoted-printable-encoded article.
10171 This is in no way, shape or form meant as a replacement for real MIME
10172 processing, but is simply a stop-gap measure until MIME support is
10174 If FORCE, decode the article whether it is marked as quoted-printable
10176 (interactive (list 'force))
10178 (set-buffer gnus-article-buffer)
10179 (let ((case-fold-search t)
10180 (buffer-read-only nil)
10181 (type (gnus-fetch-field "content-transfer-encoding")))
10182 (if (or force (and type (string-match "quoted-printable" type)))
10184 (goto-char (point-min))
10185 (search-forward "\n\n" nil 'move)
10186 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
10188 (defun gnus-mime-decode-quoted-printable (from to)
10189 ;; Decode quoted-printable from region between FROM and TO.
10192 (while (search-forward "=" to t)
10193 (cond ((eq (following-char) ?\n)
10196 ((looking-at "[0-9A-F][0-9A-F]")
10198 (insert (hexl-hex-string-to-integer
10199 (buffer-substring (point) (+ 2 (point)))))
10201 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
10203 (defun gnus-article-date-ut (&optional type)
10204 "Convert DATE date to universal time in the current article.
10205 If TYPE is `local', convert to local time; if it is `lapsed', output
10206 how much time has lapsed since DATE."
10207 (interactive (list 'ut))
10208 (let ((date (header-date (or gnus-current-headers
10209 (gnus-get-header-by-number
10210 (gnus-summary-article-number))"")))
10211 (date-regexp "^Date: \\|^X-Sent: "))
10215 (set-buffer gnus-article-buffer)
10216 (let ((buffer-read-only nil))
10217 (goto-char (point-min))
10218 (if (and (re-search-forward date-regexp nil t)
10220 (beginning-of-line)
10221 (looking-at date-regexp)))
10222 (delete-region (gnus-point-at-bol)
10223 (progn (end-of-line) (1+ (point))))
10224 (goto-char (point-min))
10225 (goto-char (- (search-forward "\n\n") 2)))
10229 (concat "Date: " (timezone-make-date-arpa-standard date) "\n"))
10231 (concat "Date: " (timezone-make-date-arpa-standard date nil "UT")
10234 (let* ((sec (- (gnus-seconds-since-epoch
10235 (timezone-make-date-arpa-standard
10236 (current-time-string) (current-time-zone) "UT"))
10237 (gnus-seconds-since-epoch
10238 (timezone-make-date-arpa-standard date nil "UT"))))
10239 (units (list (cons 'year (* 365.25 24 60 60))
10240 (cons 'week (* 7 24 60 60))
10241 (cons 'day (* 24 60 60))
10242 (cons 'hour (* 60 60))
10250 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
10252 (setq sec (- sec (* num (cdr unit))))
10254 (concat (if prev ", " "") (int-to-string (floor num))
10255 " " (symbol-name (car unit))
10256 (if (> num 1) "s" ""))
10261 (error "Unknown conversion type: %s" type)))))))))
10263 (defun gnus-article-date-local ()
10264 "Convert the current article date to the local timezone."
10266 (gnus-article-date-ut 'local))
10268 (defun gnus-article-date-lapsed ()
10269 "Convert the current article date to time lapsed since it was sent."
10271 (gnus-article-date-ut 'lapsed))
10273 (defun gnus-article-maybe-highlight ()
10274 (if gnus-visual (gnus-article-highlight)))
10278 (defun gnus-output-to-rmail (file-name)
10279 "Append the current article to an Rmail file named FILE-NAME."
10281 ;; Most of these codes are borrowed from rmailout.el.
10282 (setq file-name (expand-file-name file-name))
10283 (setq rmail-default-rmail-file file-name)
10284 (let ((artbuf (current-buffer))
10285 (tmpbuf (get-buffer-create " *Gnus-output*")))
10287 (or (get-file-buffer file-name)
10288 (file-exists-p file-name)
10289 (if (gnus-yes-or-no-p
10290 (concat "\"" file-name "\" does not exist, create it? "))
10291 (let ((file-buffer (create-file-buffer file-name)))
10293 (set-buffer file-buffer)
10294 (rmail-insert-rmail-file-header)
10295 (let ((require-final-newline nil))
10296 (write-region (point-min) (point-max) file-name t 1)))
10297 (kill-buffer file-buffer))
10298 (error "Output file does not exist")))
10299 (set-buffer tmpbuf)
10300 (buffer-disable-undo (current-buffer))
10302 (insert-buffer-substring artbuf)
10303 (gnus-convert-article-to-rmail)
10304 ;; Decide whether to append to a file or to an Emacs buffer.
10305 (let ((outbuf (get-file-buffer file-name)))
10307 (append-to-file (point-min) (point-max) file-name)
10308 ;; File has been visited, in buffer OUTBUF.
10309 (set-buffer outbuf)
10310 (let ((buffer-read-only nil)
10311 (msg (and (boundp 'rmail-current-message)
10312 (symbol-value 'rmail-current-message))))
10313 ;; If MSG is non-nil, buffer is in RMAIL mode.
10316 (narrow-to-region (point-max) (point-max))))
10317 (insert-buffer-substring tmpbuf)
10320 (goto-char (point-min))
10322 (search-backward "\^_")
10323 (narrow-to-region (point) (point-max))
10324 (goto-char (1+ (point-min)))
10325 (rmail-count-new-messages t)
10326 (rmail-show-message msg)))))))
10327 (kill-buffer tmpbuf)))
10329 (defun gnus-output-to-file (file-name)
10330 "Append the current article to a file named FILE-NAME."
10331 (setq file-name (expand-file-name file-name))
10332 (let ((artbuf (current-buffer))
10333 (tmpbuf (get-buffer-create " *Gnus-output*")))
10335 (set-buffer tmpbuf)
10336 (buffer-disable-undo (current-buffer))
10338 (insert-buffer-substring artbuf)
10339 ;; Append newline at end of the buffer as separator, and then
10340 ;; save it to file.
10341 (goto-char (point-max))
10343 (append-to-file (point-min) (point-max) file-name))
10344 (kill-buffer tmpbuf)))
10346 (defun gnus-convert-article-to-rmail ()
10347 "Convert article in current buffer to Rmail message format."
10348 (let ((buffer-read-only nil))
10349 ;; Convert article directly into Babyl format.
10350 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10351 (goto-char (point-min))
10352 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10353 (while (search-forward "\n\^_" nil t) ;single char
10354 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10355 (goto-char (point-max))
10358 (defun gnus-narrow-to-page (&optional arg)
10359 "Make text outside current page invisible except for page delimiter.
10360 A numeric arg specifies to move forward or backward by that many pages,
10361 thus showing a page other than the one point was originally in."
10363 (setq arg (if arg (prefix-numeric-value arg) 0))
10365 (forward-page -1) ;Beginning of current page.
10370 (forward-page (1- arg))))
10371 ;; Find the end of the page.
10373 ;; If we stopped due to end of buffer, stay there.
10374 ;; If we stopped after a page delimiter, put end of restriction
10375 ;; at the beginning of that line.
10376 ;; These are commented out.
10377 ;; (if (save-excursion (beginning-of-line)
10378 ;; (looking-at page-delimiter))
10379 ;; (beginning-of-line))
10380 (narrow-to-region (point)
10382 ;; Find the top of the page.
10384 ;; If we found beginning of buffer, stay there.
10385 ;; If extra text follows page delimiter on same line,
10387 ;; Otherwise, show text starting with following line.
10388 (if (and (eolp) (not (bobp)))
10392 (defun gnus-gmt-to-local ()
10393 "Rewrite Date header described in GMT to local in current buffer.
10394 Intended to be used with gnus-article-prepare-hook."
10398 (goto-char (point-min))
10399 (narrow-to-region (point-min)
10400 (progn (search-forward "\n\n" nil 'move) (point)))
10401 (goto-char (point-min))
10402 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10403 (let ((buffer-read-only nil)
10404 (date (buffer-substring (match-beginning 1) (match-end 1))))
10405 (delete-region (match-beginning 1) (match-end 1))
10407 (timezone-make-date-arpa-standard
10408 date nil (current-time-zone))))))))
10411 ;; Article mode commands
10413 (defun gnus-article-next-page (lines)
10414 "Show next page of current article.
10415 If end of article, return non-nil. Otherwise return nil.
10416 Argument LINES specifies lines to be scrolled up."
10418 (move-to-window-line -1)
10419 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10420 (if (save-excursion
10422 (and (pos-visible-in-window-p) ;Not continuation line.
10424 ;; Nothing in this page.
10425 (if (or (not gnus-break-pages)
10428 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10430 (gnus-narrow-to-page 1) ;Go to next page.
10432 ;; More in this page.
10436 ;; Long lines may cause an end-of-buffer error.
10437 (goto-char (point-max))))
10440 (defun gnus-article-prev-page (lines)
10441 "Show previous page of current article.
10442 Argument LINES specifies lines to be scrolled down."
10444 (move-to-window-line 0)
10445 (if (and gnus-break-pages
10447 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10449 (gnus-narrow-to-page -1) ;Go to previous page.
10450 (goto-char (point-max))
10452 (scroll-down lines)))
10454 (defun gnus-article-refer-article ()
10455 "Read article specified by message-id around point."
10457 (search-forward ">" nil t) ;Move point to end of "<....>".
10458 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10460 (buffer-substring (match-beginning 1) (match-end 1))))
10461 (set-buffer gnus-summary-buffer)
10462 (gnus-summary-refer-article message-id))
10463 (error "No references around point")))
10465 (defun gnus-article-show-summary ()
10466 "Reconfigure windows to show summary buffer."
10468 (gnus-configure-windows 'article)
10469 (gnus-summary-goto-subject gnus-current-article))
10471 (defun gnus-article-describe-briefly ()
10472 "Describe article mode commands briefly."
10475 (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")))
10477 (defun gnus-article-summary-command ()
10478 "Execute the last keystroke in the summary buffer."
10480 (let ((obuf (current-buffer))
10481 (owin (current-window-configuration))
10483 (switch-to-buffer gnus-summary-buffer 'norecord)
10484 (setq func (lookup-key (current-local-map) (this-command-keys)))
10485 (call-interactively func)
10487 (let ((npoint (point)))
10488 (set-window-configuration owin)
10489 (set-window-start (get-buffer-window (current-buffer)) (point)))))
10491 (defun gnus-article-summary-command-nosave ()
10492 "Execute the last keystroke in the summary buffer."
10494 (let ((obuf (current-buffer))
10495 (owin (current-window-configuration))
10497 (switch-to-buffer gnus-summary-buffer 'norecord)
10498 (setq func (lookup-key (current-local-map) (this-command-keys)))
10499 (call-interactively func)))
10501 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
10502 ;; Modified by tower@prep Nov 86
10503 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
10505 (defun gnus-caesar-region (&optional n)
10506 "Caesar rotation of region by N, default 13, for decrypting netnews.
10507 ROT47 will be performed for Japanese text in any case."
10508 (interactive (if current-prefix-arg ; Was there a prefix arg?
10509 (list (prefix-numeric-value current-prefix-arg))
10511 (cond ((not (numberp n)) (setq n 13))
10512 (t (setq n (mod n 26)))) ;canonicalize N
10513 (if (not (zerop n)) ; no action needed for a rot of 0
10515 (if (or (not (boundp 'caesar-translate-table))
10516 (not caesar-translate-table)
10517 (/= (aref caesar-translate-table ?a) (+ ?a n)))
10519 (lower "abcdefghijklmnopqrstuvwxyz")
10521 (gnus-message 9 "Building caesar-translate-table...")
10522 (setq caesar-translate-table (make-vector 256 0))
10524 (aset caesar-translate-table i i)
10526 (setq lower (concat lower lower)
10527 upper (upcase lower)
10530 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
10531 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
10533 ;; ROT47 for Japanese text.
10534 ;; Thanks to ichikawa@flab.fujitsu.junet.
10536 (let ((t1 (logior ?O 128))
10537 (t2 (logior ?! 128))
10538 (t3 (logior ?~ 128)))
10540 (aset caesar-translate-table i
10541 (let ((v (aref caesar-translate-table i)))
10542 (if (<= v t1) (if (< v t2) v (+ v 47))
10543 (if (<= v t3) (- v 47) v))))
10545 (gnus-message 9 "Building caesar-translate-table...done")))
10546 (let ((from (region-beginning))
10549 (setq str (buffer-substring from to))
10550 (setq len (length str))
10552 (aset str i (aref caesar-translate-table (aref str i)))
10555 (delete-region from to)
10559 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10562 (defalias 'gnus-batch-kill 'gnus-batch-score)
10564 (defun gnus-batch-score ()
10565 "Run batched scoring.
10566 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10567 Newsgroups is a list of strings in Bnews format. If you want to score
10568 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10569 score the alt hierarchy, you'd say \"!alt.all\"."
10572 (gnus-newsrc-parse-options
10573 (apply (function concat)
10574 (mapcar (lambda (g) (concat g " "))
10575 command-line-args-left))))
10576 (gnus-expert-user t)
10577 (nnmail-spool-file nil)
10578 (gnus-use-dribble-file nil)
10579 (yes (car yes-and-no))
10580 (no (cdr yes-and-no))
10581 group subscribed newsrc entry
10582 ;; Disable verbose message.
10583 gnus-novice-user gnus-large-newsgroup)
10584 ;; Eat all arguments.
10585 (setq command-line-args-left nil)
10588 ;; Apply kills to specified newsgroups in command line arguments.
10589 (setq newsrc (cdr gnus-newsrc-alist))
10591 (setq group (car (car newsrc)))
10592 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10593 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10595 (or (eq (car entry) t)
10596 (not (zerop (car entry)))))
10597 (if yes (string-match yes group) t)
10598 (or (null no) (not (string-match no group))))
10600 (gnus-summary-read-group group nil t)
10601 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10602 (gnus-summary-exit))))
10603 (setq newsrc (cdr newsrc)))
10605 (switch-to-buffer gnus-group-buffer)
10606 (gnus-group-save-newsrc)))
10608 (defun gnus-apply-kill-file ()
10609 "Apply a kill file to the current newsgroup.
10610 Returns the number of articles marked as read."
10611 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10612 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10613 (gnus-apply-kill-file-internal)
10616 (defun gnus-kill-save-kill-buffer ()
10618 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10619 (if (get-file-buffer file)
10621 (set-buffer (get-file-buffer file))
10622 (and (buffer-modified-p) (save-buffer))
10623 (kill-buffer (current-buffer)))))))
10625 (defvar gnus-kill-file-name "KILL"
10626 "Suffix of the kill files.")
10628 (defun gnus-newsgroup-kill-file (newsgroup)
10629 "Return the name of a kill file name for NEWSGROUP.
10630 If NEWSGROUP is nil, return the global kill file name instead."
10631 (cond ((or (null newsgroup)
10632 (string-equal newsgroup ""))
10633 ;; The global KILL file is placed at top of the directory.
10634 (expand-file-name gnus-kill-file-name
10635 (or gnus-kill-files-directory "~/News")))
10636 ((gnus-use-long-file-name 'not-kill)
10637 ;; Append ".KILL" to newsgroup name.
10638 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10639 (or gnus-kill-files-directory "~/News")))
10641 ;; Place "KILL" under the hierarchical directory.
10642 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10643 "/" gnus-kill-file-name)
10644 (or gnus-kill-files-directory "~/News")))))
10651 (defvar gnus-dribble-ignore nil)
10653 (defun gnus-dribble-file-name ()
10654 (concat gnus-startup-file "-dribble"))
10656 (defun gnus-dribble-open ()
10659 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10660 (buffer-disable-undo (current-buffer))
10661 (bury-buffer gnus-dribble-buffer)
10663 (goto-char (point-max))))
10665 (defun gnus-dribble-enter (string)
10666 (if (and (not gnus-dribble-ignore)
10667 gnus-dribble-buffer
10668 (buffer-name gnus-dribble-buffer))
10669 (let ((obuf (current-buffer)))
10670 (set-buffer gnus-dribble-buffer)
10671 (insert string "\n")
10672 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10673 (set-buffer obuf))))
10675 (defun gnus-dribble-read-file ()
10676 (let ((dribble-file (gnus-dribble-file-name)))
10678 (set-buffer (setq gnus-dribble-buffer
10680 (file-name-nondirectory dribble-file))))
10681 (gnus-add-current-to-buffer-list)
10683 (set-visited-file-name dribble-file)
10684 (buffer-disable-undo (current-buffer))
10685 (bury-buffer (current-buffer))
10686 (set-buffer-modified-p nil)
10687 (let ((auto (make-auto-save-file-name))
10688 (gnus-dribble-ignore t))
10689 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10691 (if (file-newer-than-file-p auto dribble-file)
10692 (setq dribble-file auto))
10693 (insert-file-contents dribble-file)
10694 (if (not (zerop (buffer-size)))
10695 (set-buffer-modified-p t))
10697 "Auto-save file exists. Do you want to read it? ")
10699 (gnus-message 5 "Reading %s..." dribble-file)
10700 (eval-current-buffer)
10701 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
10703 (defun gnus-dribble-delete-file ()
10704 (if (file-exists-p (gnus-dribble-file-name))
10705 (delete-file (gnus-dribble-file-name)))
10706 (if gnus-dribble-buffer
10708 (set-buffer gnus-dribble-buffer)
10709 (let ((auto (make-auto-save-file-name)))
10710 (if (file-exists-p auto)
10711 (delete-file auto))
10713 (set-buffer-modified-p nil)))))
10715 (defun gnus-dribble-save ()
10716 (if (and gnus-dribble-buffer
10717 (buffer-name gnus-dribble-buffer))
10719 (set-buffer gnus-dribble-buffer)
10722 (defun gnus-dribble-clear ()
10724 (if (gnus-buffer-exists-p gnus-dribble-buffer)
10726 (set-buffer gnus-dribble-buffer)
10728 (set-buffer-modified-p nil)
10729 (setq buffer-saved-size (buffer-size))))))
10732 ;;; Server Communication
10735 ;; All the Gnus backends have the same interface, and should return
10736 ;; data in a similar format. Below is an overview of what functions
10737 ;; these packages must supply and what results they should return.
10741 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
10744 ;; Functions for the imaginary backend `choke':
10746 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
10747 ;; Should return all headers for all ARTICLES, or return NOV lines for
10750 ;; `choke-request-group GROUP &optional SERVER DISCARD'
10751 ;; Switch to GROUP. If DISCARD is nil, active information on the group
10752 ;; must be returned.
10754 ;; `choke-close-group GROUP &optional SERVER'
10755 ;; Close group. Most backends won't have to do anything with this
10756 ;; call, but it is an opportunity to clean up, if that is needed. It
10757 ;; is called when Gnus exits a group.
10759 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
10760 ;; Return ARTICLE, which is either an article number or
10761 ;; message-id. Note that not all backends can return articles based on
10764 ;; `choke-request-list SERVER'
10765 ;; Return a list of all newsgroups on SERVER.
10767 ;; `choke-request-list-newsgroups SERVER'
10768 ;; Return a list of descriptions of all newsgroups on SERVER.
10770 ;; `choke-request-newgroups DATE &optional SERVER'
10771 ;; Return a list of all groups that have arrived after DATE on
10772 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
10773 ;; always check whether the groups are old or not. Backends that do
10774 ;; not store date information may just return the entire list of
10775 ;; groups, although this might not be a good idea in general.
10777 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
10778 ;; Should return a buffer that is suitable for "posting". nnspool and
10779 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
10780 ;; buffer. This function should fill out the appropriate headers.
10782 ;; `choke-request-post &optional SERVER'
10783 ;; Function that will be called from a buffer to be posted.
10785 ;; `choke-open-server SERVER &optional ARGUMENT'
10786 ;; Open a connection to SERVER.
10788 ;; `choke-close-server &optional SERVER'
10789 ;; Close the connection to SERVER.
10791 ;; `choke-server-opened &optional SERVER'
10792 ;; Whether the conenction to SERVER is opened or not.
10794 ;; `choke-server-status &optional SERVER'
10795 ;; Should return a status string (not in the nntp buffer, but as the
10796 ;; result of the function).
10798 ;; `choke-retrieve-groups GROUPS &optional SERVER'
10799 ;; Optional function for retrieving active file info on all groups in
10800 ;; GROUPS. Two return formats are supported: The normal active file
10801 ;; format, and a list of GROUP lines. This function should return (as
10802 ;; a function value) either `active' or `group', depending on what
10803 ;; format it returns.
10805 ;; The following functions are optional and apply only to backends
10806 ;; that are able to control the contents of their groups totally
10807 ;; (ie. mail backends.) Backends that aren't able to do that
10808 ;; shouldn't define these functions at all. Gnus will check for their
10809 ;; presence before attempting to call them.
10811 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
10812 ;; Should expire (according to some aging scheme) all ARTICLES. Most
10813 ;; backends will not be able to expire articles. Should return a list
10814 ;; of all articles that were not expired.
10816 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
10817 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
10818 ;; Removes any information it has added to the article (extra headers,
10819 ;; whatever - make it as clean as possible), and then passes the
10820 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
10821 ;; function described below. If the ACCEPT-FORM returns a non-nil
10822 ;; value, the article should then be deleted. If LAST is nil, that
10823 ;; means that there will be further calls to this function. This might
10824 ;; be taken as an advice not to save buffers/internal variables just
10825 ;; yet, but wait until the last call to speed things up.
10827 ;; `choke-request-accept-article GROUP &optional LAST'
10828 ;; The contents of the current buffer will be put into GROUP. There
10829 ;; should, of course, be an article in the current buffer. This
10830 ;; function is normally only called by the function described above,
10831 ;; and LAST works the same way as in that function.
10833 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
10834 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
10835 ;; This provides an easy interface for allowing editing of
10836 ;; articles. Note that even headers may be edited, so the backend has
10837 ;; to update any tables (nov buffers, etc) that it maintains after
10838 ;; replacing the article.
10840 ;; `choke-request-create-group GROUP &optional SERVER'
10841 ;; Create GROUP on SERVER. This might be a new, empty group, or it
10842 ;; might be a group that already exists, but hasn't been registered
10845 ;; All these functions must return nil if they couldn't service the
10846 ;; request. If the optional arguments are not supplied, some "current"
10847 ;; or "default" values should be used. In short, one should emulate an
10848 ;; NNTP server, in a way.
10850 ;; If you want to write a new backend, you just have to supply the
10851 ;; functions listed above. In addition, you must enter the new backend
10852 ;; into the list of valid select methods:
10853 ;; (setq gnus-valid-select-methods
10854 ;; (cons '("choke" mail) gnus-valid-select-methods))
10855 ;; The first element in this list is the name of the backend. Other
10856 ;; elemnets may be `mail' (for mail groups), `post' (for news
10857 ;; groups), `none' (neither), `respool' (for groups that can control
10858 ;; their contents).
10860 (defun gnus-start-news-server (&optional confirm)
10861 "Open a method for getting news.
10862 If CONFIRM is non-nil, the user will be asked for an NNTP server."
10864 (if gnus-current-select-method
10865 ;; Stream is already opened.
10867 ;; Open NNTP server.
10868 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
10871 ;; Read server name with completion.
10872 (setq gnus-nntp-server
10873 (completing-read "NNTP server: "
10874 (mapcar (lambda (server) (list server))
10875 (cons (list gnus-nntp-server)
10876 gnus-secondary-servers))
10877 nil nil gnus-nntp-server))))
10879 (if (and gnus-nntp-server
10880 (stringp gnus-nntp-server)
10881 (not (string= gnus-nntp-server "")))
10882 (setq gnus-select-method
10883 (cond ((or (string= gnus-nntp-server "")
10884 (string= gnus-nntp-server "::"))
10885 (list 'nnspool (system-name)))
10886 ((string-match "^:" gnus-nntp-server)
10887 (list 'nnmh gnus-nntp-server
10888 (list 'nnmh-directory
10889 (file-name-as-directory
10891 (concat "~/" (substring
10892 gnus-nntp-server 1)))))
10893 (list 'nnmh-get-new-mail nil)))
10895 (list 'nntp gnus-nntp-server)))))
10897 (setq how (car gnus-select-method))
10898 (setq where (car (cdr gnus-select-method)))
10899 (cond ((eq how 'nnspool)
10901 (gnus-message 5 "Looking up local news spool..."))
10904 (gnus-message 5 "Looking up mh spool..."))
10907 (setq gnus-current-select-method gnus-select-method)
10908 (run-hooks 'gnus-open-server-hook)
10910 ;; gnus-open-server-hook might have opened it
10911 (gnus-server-opened gnus-select-method)
10912 (gnus-open-server gnus-select-method)
10915 "%s server on %s can't be opened. Continue? "
10916 (car gnus-select-method) (nth 1 gnus-select-method)))
10918 (gnus-message 1 "Couldn't open server on %s"
10919 (nth 1 gnus-select-method))
10923 (defun gnus-check-news-server (&optional method)
10924 "If the news server is down, start it up again."
10925 (let ((method (if method method gnus-select-method)))
10926 (and (stringp method)
10927 (setq method (gnus-server-to-method method)))
10928 (if (gnus-server-opened method)
10929 ;; Stream is already opened.
10932 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
10933 (run-hooks 'gnus-open-server-hook)
10934 (or (gnus-server-opened method)
10935 (gnus-open-server method))
10938 (defun gnus-nntp-message (&optional message)
10939 "Check the status of the NNTP server.
10940 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
10941 is returned insted of the status string."
10942 (let ((status (gnus-status-message (gnus-find-method-for-group
10943 gnus-newsgroup-name)))
10944 (message (or message "")))
10945 (if (and (stringp status) (> (length status) 0))
10948 (defun gnus-get-function (method function)
10949 (and (stringp method)
10950 (setq method (gnus-server-to-method method)))
10951 (let ((func (intern (format "%s-%s" (car method) function))))
10952 (if (not (fboundp func))
10954 (require (car method))
10955 (if (not (fboundp func))
10956 (error "No such function: %s" func))))
10959 ;;; Interface functions to the backends.
10961 (defun gnus-open-server (method)
10962 (funcall (gnus-get-function method 'open-server)
10963 (nth 1 method) (nthcdr 2 method)))
10965 (defun gnus-close-server (method)
10966 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
10968 (defun gnus-request-list (method)
10969 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
10971 (defun gnus-request-list-newsgroups (method)
10972 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
10974 (defun gnus-request-newgroups (date method)
10975 (funcall (gnus-get-function method 'request-newgroups)
10976 date (nth 1 method)))
10978 (defun gnus-server-opened (method)
10979 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
10981 (defun gnus-status-message (method)
10982 (let ((method (if (stringp method) (gnus-find-method-for-group method)
10984 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
10986 (defun gnus-request-group (group &optional dont-check)
10987 (let ((method (gnus-find-method-for-group group)))
10988 ; (and t (message "%s GROUP %s" (car method) group))
10989 (funcall (gnus-get-function method 'request-group)
10990 (gnus-group-real-name group) (nth 1 method) dont-check)))
10992 (defun gnus-request-asynchronous (group &optional articles)
10993 (let ((method (gnus-find-method-for-group group)))
10994 (funcall (gnus-get-function method 'request-asynchronous)
10995 (gnus-group-real-name group) (nth 1 method) articles)))
10997 (defun gnus-list-active-group (group)
10998 (let ((method (gnus-find-method-for-group group))
10999 (func 'list-active-group))
11000 (and (gnus-check-backend-function func group)
11001 (funcall (gnus-get-function method func)
11002 (gnus-group-real-name group) (nth 1 method)))))
11004 (defun gnus-request-group-description (group)
11005 (let ((method (gnus-find-method-for-group group))
11006 (func 'request-group-description))
11007 (and (gnus-check-backend-function func group)
11008 (funcall (gnus-get-function method func)
11009 (gnus-group-real-name group) (nth 1 method)))))
11011 (defun gnus-close-group (group)
11012 (let ((method (gnus-find-method-for-group group)))
11013 (funcall (gnus-get-function method 'close-group)
11014 (gnus-group-real-name group) (nth 1 method))))
11016 (defun gnus-retrieve-headers (articles group)
11017 (let ((method (gnus-find-method-for-group group)))
11019 (gnus-cache-retrieve-headers articles group)
11020 (funcall (gnus-get-function method 'retrieve-headers)
11021 articles (gnus-group-real-name group) (nth 1 method)))))
11023 (defun gnus-retrieve-groups (groups method)
11024 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11026 (defun gnus-request-article (article group &optional buffer)
11027 (let ((method (gnus-find-method-for-group group)))
11028 (funcall (gnus-get-function method 'request-article)
11029 article (gnus-group-real-name group) (nth 1 method) buffer)))
11031 (defun gnus-request-head (article group)
11032 (let ((method (gnus-find-method-for-group group)))
11033 (funcall (gnus-get-function method 'request-head)
11034 article (gnus-group-real-name group) (nth 1 method))))
11036 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11037 (defun gnus-request-post-buffer (post group subject header artbuf
11038 info follow-to respect-poster)
11039 (let* ((info (or info (and group (nth 2 (gnus-gethash
11040 group gnus-newsrc-hashtb)))))
11042 (if (and gnus-post-method
11043 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11045 (format "%s" (car (gnus-find-method-for-group
11046 gnus-newsgroup-name)))
11047 gnus-valid-select-methods)))
11049 (gnus-find-method-for-group gnus-newsgroup-name))))
11050 (or (gnus-server-opened method)
11051 (gnus-open-server method)
11052 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11053 (let ((mail-self-blind nil)
11054 (mail-archive-file-name nil))
11055 (funcall (gnus-get-function method 'request-post-buffer)
11056 post group subject header artbuf info follow-to
11059 (defun gnus-request-post (method &optional force)
11060 (and (stringp method)
11061 (setq method (gnus-server-to-method method)))
11062 (and (not force) gnus-post-method
11063 (memq 'post (assoc (format "%s" (car method))
11064 gnus-valid-select-methods))
11065 (setq method gnus-post-method))
11066 (funcall (gnus-get-function method 'request-post)
11069 (defun gnus-request-expire-articles (articles group &optional force)
11070 (let ((method (gnus-find-method-for-group group)))
11071 (funcall (gnus-get-function method 'request-expire-articles)
11072 articles (gnus-group-real-name group) (nth 1 method)
11075 (defun gnus-request-move-article
11076 (article group server accept-function &optional last)
11077 (let ((method (gnus-find-method-for-group group)))
11078 (funcall (gnus-get-function method 'request-move-article)
11079 article (gnus-group-real-name group)
11080 (nth 1 method) accept-function last)))
11082 (defun gnus-request-accept-article (group &optional last)
11083 (let ((func (if (symbolp group) group
11084 (car (gnus-find-method-for-group group)))))
11085 (funcall (intern (format "%s-request-accept-article" func))
11086 (if (stringp group) (gnus-group-real-name group) group)
11089 (defun gnus-request-replace-article (article group buffer)
11090 (let ((func (car (gnus-find-method-for-group group))))
11091 (funcall (intern (format "%s-request-replace-article" func))
11092 article (gnus-group-real-name group) buffer)))
11094 (defun gnus-request-create-group (group)
11095 (let ((method (gnus-find-method-for-group group)))
11096 (funcall (gnus-get-function method 'request-create-group)
11097 (gnus-group-real-name group) (nth 1 method))))
11099 (defun gnus-member-of-valid (symbol group)
11100 (memq symbol (assoc
11101 (format "%s" (car (gnus-find-method-for-group group)))
11102 gnus-valid-select-methods)))
11104 (defun gnus-find-method-for-group (group &optional info)
11105 (or gnus-override-method
11107 gnus-select-method)
11108 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11111 (not (setq method (nth 4 info))))
11112 (setq method gnus-select-method)
11114 (cond ((stringp method)
11115 (gnus-server-to-method method))
11116 ((stringp (car method))
11117 (gnus-server-extend-method group method))
11120 (gnus-server-add-address method))))
11122 (defun gnus-check-backend-function (func group)
11123 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11125 (fboundp (intern (format "%s-%s" method func)))))
11127 (defun gnus-methods-using (method)
11128 (let ((valids gnus-valid-select-methods)
11131 (if (memq method (car valids))
11132 (setq outs (cons (car valids) outs)))
11133 (setq valids (cdr valids)))
11137 ;;; Active & Newsrc File Handling
11140 ;; Newsrc related functions.
11141 ;; Gnus internal format of gnus-newsrc-alist:
11142 ;; (("alt.general" 3 (1 . 1))
11143 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11144 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11145 ;; The first item is the group name; the second is the subscription
11146 ;; level; the third is either a range of a list of ranges of read
11147 ;; articles, the optional fourth element is a list of marked articles,
11148 ;; the optional fifth element is the select method.
11150 ;; Gnus internal format of gnus-newsrc-hashtb:
11151 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11152 ;; This is the entry for "alt.misc". The first element is the number
11153 ;; of unread articles in "alt.misc". The cdr of this entry is the
11154 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11155 ;; trivial to remove or add new elements into gnus-newsrc-alist
11156 ;; without scanning the entire list. So, to get the actual information
11157 ;; of "alt.misc", you'd say something like
11158 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11160 ;; Gnus internal format of gnus-active-hashtb:
11164 ;; The only element in each entry in this hash table is a range of
11165 ;; (possibly) available articles. (Articles in this range may have
11166 ;; been expired or cancelled.)
11168 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11169 ;; ("alt.misc" "alt.test" "alt.general" ...)
11171 (defun gnus-setup-news (&optional rawfile level)
11172 "Setup news information.
11173 If RAWFILE is non-nil, the .newsrc file will also be read.
11174 If LEVEL is non-nil, the news will be set up at level LEVEL."
11175 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
11176 ;; Clear some variables to re-initialize news information.
11177 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
11179 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11180 (if init (gnus-read-newsrc-file rawfile))
11182 ;; Read the active file and create `gnus-active-hashtb'.
11183 ;; If `gnus-read-active-file' is nil, then we just create an empty
11184 ;; hash table. The partial filling out of the hash table will be
11185 ;; done in `gnus-get-unread-articles'.
11186 (if (and gnus-read-active-file
11188 (gnus-server-opened gnus-select-method))
11189 (gnus-read-active-file)
11190 (setq gnus-active-hashtb (make-vector 4095 0)))
11192 (and init gnus-use-dribble-file (gnus-dribble-read-file))
11194 ;; Find the number of unread articles in each non-dead group.
11195 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
11196 ;; Find new newsgroups and treat them.
11197 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
11198 (gnus-server-opened gnus-select-method))
11199 (gnus-find-new-newsgroups))
11200 (if (and init gnus-check-bogus-newsgroups
11201 gnus-read-active-file (not level)
11202 (gnus-server-opened gnus-select-method))
11203 (gnus-check-bogus-newsgroups))))
11205 (defun gnus-find-new-newsgroups ()
11206 "Search for new newsgroups and add them.
11207 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11208 The `-n' option line from .newsrc is respected."
11210 (or (gnus-check-first-time-used)
11211 (if (or (consp gnus-check-new-newsgroups)
11212 (eq gnus-check-new-newsgroups 'ask-server))
11213 (gnus-ask-server-for-new-groups)
11215 group new-newsgroups)
11216 (or gnus-have-read-active-file (gnus-read-active-file))
11217 (setq gnus-newsrc-last-checked-date (current-time-string))
11218 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11219 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11220 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11223 (setq group (symbol-name sym))
11224 (if (or (gnus-gethash group gnus-killed-hashtb)
11225 (gnus-gethash group gnus-newsrc-hashtb))
11227 (let ((do-sub (gnus-matches-options-n group)))
11228 (cond ((eq do-sub 'subscribe)
11229 (setq groups (1+ groups))
11230 (gnus-sethash group group gnus-killed-hashtb)
11232 gnus-subscribe-options-newsgroup-method group))
11233 ((eq do-sub 'ignore)
11236 (setq groups (1+ groups))
11237 (gnus-sethash group group gnus-killed-hashtb)
11238 (if gnus-subscribe-hierarchical-interactive
11239 (setq new-newsgroups (cons group new-newsgroups))
11240 (funcall gnus-subscribe-newsgroup-method group)))))))
11241 gnus-active-hashtb)
11243 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11244 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11246 (gnus-message 6 "%d new newsgroup%s arrived."
11247 groups (if (> groups 1) "s have" " has")))))))
11249 (defun gnus-matches-options-n (group)
11250 ;; Returns `subscribe' if the group is to be uncoditionally
11251 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
11252 ;; no match for the group.
11254 ;; First we check the two user variables.
11256 ((and gnus-options-subscribe
11257 (string-match gnus-options-not-subscribe group))
11259 ((and gnus-options-not-subscribe
11260 (string-match gnus-options-subscribe group))
11262 ;; Then we go through the list that was retrieved from the .newsrc
11263 ;; file. This list has elements on the form
11264 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11265 ;; is in the reverse order of the options line) is returned.
11267 (let ((regs gnus-newsrc-options-n))
11269 (not (string-match (car (car regs)) group)))
11270 (setq regs (cdr regs)))
11271 (and regs (cdr (car regs)))))))
11273 (defun gnus-ask-server-for-new-groups ()
11274 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11275 (methods (cons gnus-select-method
11277 (and (consp gnus-check-new-newsgroups)
11278 gnus-check-new-newsgroups)
11279 gnus-secondary-select-methods)))
11281 (new-date (current-time-string))
11282 hashtb group new-newsgroups got-new)
11283 ;; Go thorugh both primary and secondary select methods and
11284 ;; request new newsgroups.
11286 (if (gnus-request-newgroups date (car methods))
11289 (or hashtb (setq hashtb (gnus-make-hashtable
11290 (count-lines (point-min) (point-max)))))
11291 (set-buffer nntp-server-buffer)
11292 ;; Enter all the new groups in a hashtable.
11293 (gnus-active-to-gnus-format (car methods) hashtb)))
11294 (setq methods (cdr methods)))
11295 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11296 ;; Now all new groups from all select methods are in `hashtb'.
11298 (lambda (group-sym)
11299 (setq group (symbol-name group-sym))
11300 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11301 (member group gnus-zombie-list)
11302 (member group gnus-killed-list))
11303 ;; The group is already known.
11305 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
11306 (let ((do-sub (gnus-matches-options-n group)))
11307 (cond ((eq do-sub 'subscribe)
11308 (setq groups (1+ groups))
11309 (gnus-sethash group group gnus-killed-hashtb)
11311 gnus-subscribe-options-newsgroup-method group))
11312 ((eq do-sub 'ignore)
11315 (setq groups (1+ groups))
11316 (gnus-sethash group group gnus-killed-hashtb)
11317 (if gnus-subscribe-hierarchical-interactive
11318 (setq new-newsgroups (cons group new-newsgroups))
11319 (funcall gnus-subscribe-newsgroup-method group)))))))
11322 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11323 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11325 (gnus-message 6 "%d new newsgroup%s arrived."
11326 groups (if (> groups 1) "s have" " has")))
11329 (defun gnus-check-first-time-used ()
11330 (if (or (> (length gnus-newsrc-alist) 1)
11331 (file-exists-p gnus-startup-file)
11332 (file-exists-p (concat gnus-startup-file ".el"))
11333 (file-exists-p (concat gnus-startup-file ".eld")))
11335 (gnus-message 6 "First time user; subscribing you to default groups")
11336 (or gnus-have-read-active-file (gnus-read-active-file))
11337 (setq gnus-newsrc-last-checked-date (current-time-string))
11338 (let ((groups gnus-default-subscribed-newsgroups)
11342 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11345 (setq group (symbol-name sym))
11346 (let ((do-sub (gnus-matches-options-n group)))
11347 (cond ((eq do-sub 'subscribe)
11348 (gnus-sethash group group gnus-killed-hashtb)
11350 gnus-subscribe-options-newsgroup-method group))
11351 ((eq do-sub 'ignore)
11354 (setq gnus-killed-list (cons group gnus-killed-list))))))
11355 gnus-active-hashtb)
11357 (if (gnus-gethash (car groups) gnus-active-hashtb)
11358 (gnus-group-change-level
11359 (car groups) gnus-level-default-subscribed gnus-level-killed))
11360 (setq groups (cdr groups)))
11361 (gnus-group-make-help-group)
11362 (and gnus-novice-user
11363 (gnus-message 7 "`A k' to list killed groups"))))))
11365 (defun gnus-subscribe-group (group previous &optional method)
11366 (gnus-group-change-level
11368 (list t group gnus-level-default-subscribed nil nil method)
11370 gnus-level-default-subscribed gnus-level-killed previous t))
11372 ;; `gnus-group-change-level' is the fundamental function for changing
11373 ;; subscription levels of newsgroups. This might mean just changing
11374 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11375 ;; again, which subscribes/unsubscribes a group, which is equally
11376 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11377 ;; from 8-9 to 1-7 means that you remove the group from the list of
11378 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11379 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11380 ;; which is trivial.
11381 ;; ENTRY can either be a string (newsgroup name) or a list (if
11382 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11383 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11385 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11386 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11388 (defun gnus-group-change-level (entry level &optional oldlevel
11389 previous fromkilled)
11390 (let ((pinfo entry)
11391 group info active num)
11392 ;; Glean what info we can from the arguments
11394 (if fromkilled (setq group (nth 1 entry))
11395 (setq group (car (nth 2 entry))))
11396 (setq group entry))
11397 (if (and (stringp entry)
11399 (< oldlevel gnus-level-zombie))
11400 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11401 (if (and (not oldlevel)
11403 (setq oldlevel (car (cdr (nth 2 entry)))))
11404 (if (stringp previous)
11405 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11407 (gnus-dribble-enter
11408 (format "(gnus-group-change-level %S %S %S %S %S)"
11409 group level oldlevel (car (nth 2 previous)) fromkilled))
11411 ;; Then we remove the newgroup from any old structures, if needed.
11412 ;; If the group was killed, we remove it from the killed or zombie
11413 ;; list. If not, and it is in fact going to be killed, we remove
11414 ;; it from the newsrc hash table and assoc.
11415 (cond ((>= oldlevel gnus-level-zombie)
11416 (if (= oldlevel gnus-level-zombie)
11417 (setq gnus-zombie-list (delete group gnus-zombie-list))
11418 (setq gnus-killed-list (delete group gnus-killed-list))))
11420 (if (>= level gnus-level-zombie)
11422 (gnus-sethash (car (nth 2 entry))
11423 nil gnus-newsrc-hashtb)
11425 (setcdr (gnus-gethash (car (nth 3 entry))
11426 gnus-newsrc-hashtb)
11428 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11430 ;; Finally we enter (if needed) the list where it is supposed to
11431 ;; go, and change the subscription level. If it is to be killed,
11432 ;; we enter it into the killed or zombie list.
11433 (cond ((>= level gnus-level-zombie)
11434 ;; Remove from the hash table.
11435 (gnus-sethash group nil gnus-newsrc-hashtb)
11436 (or (gnus-group-foreign-p group)
11437 ;; We do not enter foreign groups into the list of dead
11439 (if (= level gnus-level-zombie)
11440 (setq gnus-zombie-list (cons group gnus-zombie-list))
11441 (setq gnus-killed-list (cons group gnus-killed-list)))))
11443 ;; If the list is to be entered into the newsrc assoc, and
11444 ;; it was killed, we have to create an entry in the newsrc
11445 ;; hashtb format and fix the pointers in the newsrc assoc.
11446 (if (>= oldlevel gnus-level-zombie)
11450 (setq info (cdr entry))
11451 (setq num (car entry)))
11452 (setq active (gnus-gethash group gnus-active-hashtb))
11453 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11454 ;; Check whether the group is foreign. If so, the
11455 ;; foreign select method has to be entered into the
11457 (let ((method (gnus-group-method-name group)))
11458 (if (eq method gnus-select-method)
11459 (setq info (list group level nil))
11460 (setq info (list group level nil nil method)))))
11463 (let ((p gnus-newsrc-alist))
11464 (while (cdr (cdr p))
11467 (setq entry (cons info (cdr (cdr previous))))
11470 (setcdr (cdr previous) entry)
11471 (gnus-sethash group (cons num (cdr previous))
11472 gnus-newsrc-hashtb))
11473 (setcdr previous entry)
11474 (gnus-sethash group (cons num previous)
11475 gnus-newsrc-hashtb))
11477 (setcdr (gnus-gethash (car (car (cdr entry)))
11478 gnus-newsrc-hashtb)
11480 ;; It was alive, and it is going to stay alive, so we
11481 ;; just change the level and don't change any pointers or
11482 ;; hash table entries.
11483 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11485 (defun gnus-kill-newsgroup (newsgroup)
11486 "Obsolete function. Kills a newsgroup."
11487 (gnus-group-change-level
11488 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11490 (defun gnus-check-bogus-newsgroups (&optional confirm)
11491 "Remove bogus newsgroups.
11492 If CONFIRM is non-nil, the user has to confirm the deletion of every
11494 (let ((newsrc (cdr gnus-newsrc-alist))
11496 (gnus-message 5 "Checking bogus newsgroups...")
11497 (or gnus-have-read-active-file (gnus-read-active-file))
11498 ;; Find all bogus newsgroup that are subscribed.
11500 (setq group (car (car newsrc)))
11501 (if (or (gnus-gethash group gnus-active-hashtb)
11502 (nth 4 (car newsrc))
11504 (not (gnus-y-or-n-p
11505 (format "Remove bogus newsgroup: %s " group)))))
11506 ;; Active newsgroup.
11508 ;; Found a bogus newsgroup.
11509 (setq bogus (cons group bogus)))
11510 (setq newsrc (cdr newsrc)))
11511 ;; Remove all bogus subscribed groups by first killing them, and
11512 ;; then removing them from the list of killed groups.
11514 (gnus-group-change-level
11515 (gnus-gethash (car bogus) gnus-newsrc-hashtb) gnus-level-killed)
11516 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
11517 (setq bogus (cdr bogus)))
11518 ;; Then we remove all bogus groups from the list of killed and
11519 ;; zombie groups. They are are removed without confirmation.
11520 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11523 (setq killed (symbol-value (car dead-lists)))
11525 (setq group (car killed))
11526 (or (gnus-gethash group gnus-active-hashtb)
11527 ;; The group is bogus.
11528 (set (car dead-lists)
11529 (delete group (symbol-value (car dead-lists)))))
11530 (setq killed (cdr killed)))
11531 (setq dead-lists (cdr dead-lists))))
11532 (gnus-message 5 "Checking bogus newsgroups...done")))
11534 (defun gnus-check-duplicate-killed-groups ()
11535 "Remove duplicates from the list of killed groups."
11537 (let ((killed gnus-killed-list))
11539 (gnus-message 9 "%d" (length killed))
11540 (setcdr killed (delete (car killed) (cdr killed)))
11541 (setq killed (cdr killed)))))
11543 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11544 ;; and compute how many unread articles there are in each group.
11545 (defun gnus-get-unread-articles (&optional level)
11546 (let* ((newsrc (cdr gnus-newsrc-alist))
11547 (conditional level)
11548 (level (or level (1+ gnus-level-subscribed)))
11549 info group active virtuals method)
11550 (gnus-message 5 "Checking new news...")
11552 (setq info (car newsrc))
11553 (setq group (car info))
11554 (setq active (gnus-gethash group gnus-active-hashtb))
11556 ;; Check newsgroups. If the user doesn't want to check them, or
11557 ;; they can't be checked (for instance, if the news server can't
11558 ;; be reached) we just set the number of unread articles in this
11559 ;; newsgroup to t. This means that Gnus thinks that there are
11560 ;; unread articles, but it has no idea how many.
11561 (if (and (setq method (nth 4 info))
11562 (not (gnus-server-equal gnus-select-method
11563 (gnus-server-get-method nil method))))
11564 (if (or (and gnus-activate-foreign-newsgroups
11565 (not (numberp gnus-activate-foreign-newsgroups)))
11566 (and (numberp gnus-activate-foreign-newsgroups)
11567 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
11568 (<= (nth 1 info) level)))
11569 (if (eq (car (if (stringp method)
11570 (gnus-server-to-method method)
11571 (nth 4 info))) 'nnvirtual)
11572 (setq virtuals (cons info virtuals))
11573 (setq active (gnus-activate-newsgroup (car info)))))
11574 (if (and (not gnus-read-active-file)
11575 (<= (nth 1 info) level))
11577 (setq active (gnus-activate-newsgroup (car info))))))
11579 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
11580 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
11582 (gnus-get-unread-articles-in-group info active)
11583 ;; Close the groups as we look at them!
11584 (gnus-close-group group))
11585 (setq newsrc (cdr newsrc)))
11587 ;; Activate the virtual groups. This has to be done after all the
11589 ;; !!! If one virtual group contains another virtual group, even
11590 ;; doing it this way might cause problems.
11592 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11593 (gnus-get-unread-articles-in-group (car virtuals) active))
11594 (setq virtuals (cdr virtuals)))
11596 (gnus-message 5 "Checking new news...done")))
11598 ;; Create a hash table out of the newsrc alist. The `car's of the
11599 ;; alist elements are used as keys.
11600 (defun gnus-make-hashtable-from-newsrc-alist ()
11601 (let ((alist gnus-newsrc-alist)
11603 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11605 (setq prev (setq gnus-newsrc-alist
11606 (cons (list "dummy.group" 0 nil) alist))))
11608 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
11610 (setq alist (cdr alist)))))
11612 (defun gnus-make-hashtable-from-killed ()
11613 "Create a hash table from the killed and zombie lists."
11614 (let ((lists '(gnus-killed-list gnus-zombie-list))
11616 (setq gnus-killed-hashtb
11617 (gnus-make-hashtable
11618 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11620 (setq list (symbol-value (car lists)))
11621 (setq lists (cdr lists))
11623 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11624 (setq list (cdr list))))))
11626 (defun gnus-get-unread-articles-in-group (info active)
11627 (let* ((range (nth 2 info))
11629 (marked (nth 3 info))
11630 srange lowest group highest)
11631 ;; If a cache is present, we may have to alter the active info.
11632 (and gnus-use-cache
11633 (gnus-cache-possibly-alter-active (car info) active))
11634 ;; Modify the list of read articles according to what articles
11635 ;; are available; then tally the unread articles and add the
11636 ;; number to the group hash table entry.
11637 (cond ((zerop (cdr active))
11640 (setq num (- (1+ (cdr active)) (car active))))
11641 ((not (listp (cdr range)))
11642 ;; Fix a single (num . num) range according to the
11643 ;; active hash table.
11644 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
11645 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
11646 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
11647 ;; Compute number of unread articles.
11648 (setq num (max 0 (- (cdr active)
11649 (- (1+ (cdr range)) (car range))))))
11651 ;; The read list is a list of ranges. Fix them according to
11652 ;; the active hash table.
11653 ;; First peel off any elements that are below the lower
11655 (while (and (cdr range)
11657 (or (and (atom (car (cdr range))) (car (cdr range)))
11658 (car (car (cdr range))))))
11659 (if (numberp (car range))
11662 (or (and (numberp (car (cdr range)))
11664 (cdr (car (cdr range))))))
11665 (setcdr (car range)
11666 (or (and (numberp (nth 1 range)) (nth 1 range))
11667 (cdr (car (cdr range))))))
11668 (setcdr range (cdr (cdr range))))
11669 ;; Adjust the first element to be the same as the lower limit.
11670 (if (and (not (atom (car range)))
11671 (< (cdr (car range)) (car active)))
11672 (setcdr (car range) (1- (car active))))
11673 ;; Then we want to peel off any elements that are higher
11674 ;; than the upper active limit.
11675 (let ((srange range))
11676 ;; Go past all legal elements.
11677 (while (and (cdr srange)
11678 (<= (or (and (atom (car (cdr srange)))
11679 (car (cdr srange)))
11680 (car (car (cdr srange)))) (cdr active)))
11681 (setq srange (cdr srange)))
11683 ;; Nuke all remaining illegal elements.
11684 (setcdr srange nil))
11686 ;; Adjust the final element.
11687 (if (and (not (atom (car srange)))
11688 (> (cdr (car srange)) (cdr active)))
11689 (setcdr (car srange) (cdr active))))
11690 ;; Compute the number of unread articles.
11692 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
11693 (cdr (car range))))
11694 (or (and (atom (car range)) (car range))
11695 (car (car range))))))
11696 (setq range (cdr range)))
11697 (setq num (max 0 (- (cdr active) num)))))
11700 (and (assq 'tick marked)
11701 (inline (gnus-remove-illegal-marked-articles
11702 (assq 'tick marked) (nth 2 info))))
11703 (and (assq 'dormant marked)
11704 (inline (gnus-remove-illegal-marked-articles
11705 (assq 'dormant marked) (nth 2 info))))
11707 (gnus-gethash (car info) gnus-newsrc-hashtb)
11708 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
11709 (length (cdr (assq 'dormant marked)))))))))
11712 (defun gnus-remove-illegal-marked-articles (marked ranges)
11713 (let ((m (cdr marked)))
11714 ;; Make sure that all ticked articles are a subset of the unread
11717 (if (gnus-member-of-range (car m) ranges)
11718 (setcdr marked (cdr m))
11720 (setq m (cdr m)))))
11722 (defun gnus-activate-newsgroup (group)
11723 (let ((method (gnus-find-method-for-group group))
11725 (and (or (gnus-server-opened method) (gnus-open-server method))
11726 (gnus-request-group group)
11728 (set-buffer nntp-server-buffer)
11729 (goto-char (point-min))
11730 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
11732 (goto-char (match-beginning 1))
11734 group (setq active (cons (read (current-buffer))
11735 (read (current-buffer))))
11736 gnus-active-hashtb))
11739 (defun gnus-update-read-articles
11740 (group unread unselected ticked &optional domarks replied expirable killed
11741 dormant bookmark score)
11742 "Update the list of read and ticked articles in GROUP using the
11743 UNREAD and TICKED lists.
11744 Note: UNSELECTED has to be sorted over `<'.
11745 Returns whether the updating was successful."
11746 (let* ((active (or gnus-newsgroup-active
11747 (gnus-gethash group gnus-active-hashtb)))
11748 (entry (gnus-gethash group gnus-newsrc-hashtb))
11749 (number (car entry))
11750 (info (nth 2 entry))
11751 (marked (nth 3 info))
11753 (unread (sort (copy-sequence unread) (function <)))
11755 (if (or (not info) (not active))
11756 ;; There is no info on this group if it was, in fact,
11757 ;; killed. Gnus stores no information on killed groups, so
11758 ;; there's nothing to be done.
11759 ;; One could store the information somewhere temporarily,
11760 ;; perhaps... Hmmm...
11762 ;; Remove any negative articles numbers.
11763 (while (and unread (< (car unread) 0))
11764 (setq unread (cdr unread)))
11765 ;; Remove any expired article numbers
11766 (while (and unread (< (car unread) (car active)))
11767 (setq unread (cdr unread)))
11768 (while (and ticked (< (car ticked) (car active)))
11769 (setq ticked (cdr ticked)))
11770 (while (and dormant (< (car dormant) (car active)))
11771 (setq dormant (cdr dormant)))
11772 (setq unread (sort (append unselected unread) '<))
11773 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11774 (setcar entry (max 0 (- (length unread) (length ticked)
11775 (length dormant))))
11776 ;; Compute the ranges of read articles by looking at the list of
11777 ;; unread articles.
11779 (if (/= (car unread) prev)
11780 (setq read (cons (if (= prev (1- (car unread))) prev
11781 (cons prev (1- (car unread)))) read)))
11782 (setq prev (1+ (car unread)))
11783 (setq unread (cdr unread)))
11784 (if (<= prev (cdr active))
11785 (setq read (cons (cons prev (cdr active)) read)))
11786 ;; Enter this list into the group info.
11787 (setcar (cdr (cdr info))
11788 (if (> (length read) 1) (nreverse read) read))
11789 ;; Enter the list of ticked articles.
11790 (gnus-set-marked-articles
11792 (if domarks replied (cdr (assq 'reply marked)))
11793 (if domarks expirable (cdr (assq 'expire marked)))
11794 (if domarks killed (cdr (assq 'killed marked)))
11795 (if domarks dormant (cdr (assq 'dormant marked)))
11796 (if domarks bookmark (cdr (assq 'bookmark marked)))
11797 (if domarks score (cdr (assq 'score marked))))
11800 (defun gnus-make-articles-unread (group articles)
11801 "Mark ARTICLES in GROUP as unread."
11802 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
11803 (gnus-gethash (gnus-group-real-name group)
11804 gnus-newsrc-hashtb))))
11805 (ranges (nth 2 info))
11808 (and (gnus-member-of-range (car articles) ranges)
11809 (setq news (cons (car articles) news)))
11810 (setq articles (cdr articles)))
11813 (setcar (nthcdr 2 info)
11814 (gnus-remove-from-range (nth 2 info) (nreverse news)))
11815 (gnus-group-update-group group t))))
11817 (defun gnus-read-active-file ()
11818 "Get active file from NNTP server."
11819 (gnus-group-set-mode-line)
11820 (let ((methods (cons gnus-select-method gnus-secondary-select-methods))
11823 (setq gnus-have-read-active-file nil)
11825 (set-buffer nntp-server-buffer)
11827 (let* ((where (nth 1 (car methods)))
11828 (mesg (format "Reading active file%s via %s..."
11829 (if (and where (not (zerop (length where))))
11830 (concat " from " where) "")
11831 (car (car methods)))))
11832 (gnus-message 5 mesg)
11833 (gnus-check-news-server (car methods))
11835 ((and (eq gnus-read-active-file 'some)
11836 (gnus-check-backend-function
11837 'retrieve-groups (car (car methods))))
11838 (let ((newsrc (cdr gnus-newsrc-alist))
11841 (and (gnus-server-equal
11842 (gnus-find-method-for-group
11843 (car (car newsrc)) (car newsrc))
11844 (gnus-server-get-method nil (car methods)))
11845 (setq groups (cons (car (car newsrc)) groups)))
11846 (setq newsrc (cdr newsrc)))
11847 (setq list-type (gnus-retrieve-groups groups (car methods)))
11848 (cond ((not list-type)
11850 1 "Cannot read partial active file from %s server."
11851 (car (car methods)))
11854 ((eq list-type 'active)
11855 (gnus-active-to-gnus-format (and not-first (car methods)))
11856 (setq not-first t))
11858 (gnus-groups-to-gnus-format (and not-first (car methods)))
11859 (setq not-first t)))))
11861 (if (not (gnus-request-list (car methods)))
11863 (gnus-message 1 "Cannot read active file from %s server."
11864 (car (car methods)))
11866 (gnus-active-to-gnus-format
11867 (and gnus-have-read-active-file (car methods)))
11868 (setq gnus-have-read-active-file t)
11869 (gnus-message 5 "%s...done" mesg)))))
11870 (setq methods (cdr methods))))))
11872 ;; Read an active file and place the results in `gnus-active-hashtb'.
11873 (defun gnus-active-to-gnus-format (method &optional hashtb)
11874 (let ((cur (current-buffer))
11878 (setq gnus-active-hashtb
11879 (gnus-make-hashtable
11880 (count-lines (point-min) (point-max))))))))
11881 ;; Delete unnecessary lines.
11882 (goto-char (point-min))
11883 (while (search-forward "\nto." nil t)
11884 (delete-region (match-beginning 0) (progn (forward-line 1) (point))))
11885 (or (string= gnus-ignored-newsgroups "")
11887 (goto-char (point-min))
11888 (delete-matching-lines gnus-ignored-newsgroups)))
11889 (and method (not (eq method gnus-select-method))
11890 (let ((prefix (gnus-group-prefixed-name "" method)))
11891 (goto-char (point-min))
11892 (while (and (not (eobp))
11893 (null (insert prefix))
11894 (zerop (forward-line 1))))))
11895 (goto-char (point-min))
11896 ;; Store active file in hashtable.
11897 (goto-char (point-min))
11898 (if (string-match "%[oO]" gnus-group-line-format)
11899 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
11900 ;; If we want information on moderated groups, we use this
11902 (let* ((mod-hashtb (make-vector 7 0))
11903 (m (intern "m" mod-hashtb))
11905 (while (not (eobp))
11906 (condition-case nil
11908 (narrow-to-region (point) (gnus-point-at-eol))
11909 (setq group (let ((obarray hashtb)) (read cur)))
11910 (and (numberp (setq max (read cur)))
11911 (numberp (setq min (read cur)))
11912 (set group (cons min max)))
11913 ;; Enter moderated groups into a list.
11914 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
11915 (setq gnus-moderated-list
11916 (cons (symbol-name group) gnus-moderated-list))))
11920 ;; And if we do not care about moderation, we use this loop,
11921 ;; which is faster.
11922 (let (group max min)
11923 (while (not (eobp))
11926 (narrow-to-region (point) (gnus-point-at-eol))
11927 ;; group gets set to a symbol interned in the hash table
11929 (setq group (let ((obarray hashtb)) (read cur)))
11930 (and (numberp (setq max (read cur)))
11931 (numberp (setq min (read cur)))
11932 (set group (cons min max))))
11935 (gnus-message 3 "Warning - illegal active: %s"
11937 (gnus-point-at-bol) (gnus-point-at-eol)))
11940 (forward-line 1))))))
11942 (defun gnus-groups-to-gnus-format (method &optional hashtb)
11943 ;; Parse a "groups" active file.
11944 (let ((cur (current-buffer))
11948 (setq gnus-active-hashtb
11949 (gnus-make-hashtable
11950 (count-lines (point-min) (point-max)))))))
11951 (prefix (and method (not (eq method gnus-select-method))
11952 (gnus-group-prefixed-name "" method))))
11954 (goto-char (point-min))
11956 ;; We split this into to separate loops, one with the prefix
11957 ;; and one without to speed the reading up somewhat.
11959 (let (min max opoint)
11960 (while (not (eobp))
11961 (read cur) (read cur)
11962 (setq min (read cur)
11965 (skip-chars-forward " \t")
11968 (set (let ((obarray hashtb)) (read cur))
11971 (let (min max opoint)
11972 (while (not (eobp))
11973 (if (= (following-char) ?2)
11975 (read cur) (read cur)
11976 (setq min (read cur)
11978 (set (let ((obarray hashtb)) (read cur))
11980 (forward-line 1))))
11982 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
11984 (defun gnus-read-newsrc-file (&optional force)
11985 "Read startup file.
11986 If FORCE is non-nil, the .newsrc file is read."
11987 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
11988 ;; Reset variables that might be defined in the .newsrc.eld file.
11989 (let ((variables gnus-variable-list))
11991 (set (car variables) nil)
11992 (setq variables (cdr variables))))
11993 (let* ((newsrc-file gnus-current-startup-file)
11994 (quick-file (concat newsrc-file ".el")))
11996 ;; We always load the .newsrc.eld file. If always contains
11997 ;; much information that can not be gotten from the .newsrc
11998 ;; file (ticked articles, killed groups, foreign methods, etc.)
11999 (gnus-read-newsrc-el-file quick-file)
12002 (and (file-newer-than-file-p newsrc-file quick-file)
12003 (file-newer-than-file-p newsrc-file
12004 (concat quick-file "d")))
12005 (not gnus-newsrc-alist))
12006 ;; We read the .newsrc file. Note that if there if a
12007 ;; .newsrc.eld file exists, it has already been read, and
12008 ;; the `gnus-newsrc-hashtb' has been created. While reading
12009 ;; the .newsrc file, Gnus will only use the information it
12010 ;; can find there for changing the data already read -
12011 ;; ie. reading the .newsrc file will not trash the data
12012 ;; already read (except for read articles).
12014 (gnus-message 5 "Reading %s..." newsrc-file)
12015 (set-buffer (find-file-noselect newsrc-file))
12016 (buffer-disable-undo (current-buffer))
12017 (gnus-newsrc-to-gnus-format)
12018 (kill-buffer (current-buffer))
12019 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12021 (defun gnus-read-newsrc-el-file (file)
12022 (let ((ding-file (concat file "d")))
12023 ;; We always, always read the .eld file.
12024 (gnus-message 5 "Reading %s..." ding-file)
12025 (let (gnus-newsrc-assoc)
12026 (condition-case nil
12027 (load ding-file t t t)
12029 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12030 (let ((inhibit-quit t))
12031 (gnus-uncompress-newsrc-assoc))
12032 (gnus-make-hashtable-from-newsrc-alist)
12033 (if (not (file-newer-than-file-p file ding-file))
12035 ;; Old format quick file
12036 (gnus-message 5 "Reading %s..." file)
12037 ;; The .el file is newer than the .eld file, so we read that one
12039 (gnus-read-old-newsrc-el-file file))))
12041 ;; Parse the old-style quick startup file
12042 (defun gnus-read-old-newsrc-el-file (file)
12043 (let (newsrc killed marked group g m len info)
12045 (let ((gnus-killed-assoc nil)
12046 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12048 (condition-case nil
12051 (setq newsrc gnus-newsrc-assoc
12052 killed gnus-killed-assoc
12053 marked gnus-marked-assoc)))
12054 (setq gnus-newsrc-alist nil)
12056 (setq group (car newsrc))
12057 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12060 (setcar (nthcdr 2 info) (cdr (cdr group)))
12062 (if (nth 1 group) gnus-level-default-subscribed
12063 gnus-level-default-unsubscribed))
12064 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
12065 (setq gnus-newsrc-alist
12069 (if (nth 1 group) gnus-level-default-subscribed
12070 gnus-level-default-unsubscribed)
12071 (cdr (cdr group))))
12072 gnus-newsrc-alist)))
12073 (if (setq m (assoc (car group) marked))
12074 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12075 (setq newsrc (cdr newsrc)))
12076 (setq newsrc killed)
12078 (setcar newsrc (car (car newsrc)))
12079 (setq newsrc (cdr newsrc)))
12080 (setq gnus-killed-list killed))
12081 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
12082 (gnus-make-hashtable-from-newsrc-alist)))
12084 (defun gnus-make-newsrc-file (file)
12085 "Make server dependent file name by catenating FILE and server host name."
12086 (let* ((file (expand-file-name file nil))
12087 (real-file (concat file "-" (nth 1 gnus-select-method))))
12088 (if (file-exists-p real-file)
12091 (defun gnus-uncompress-newsrc-assoc ()
12092 ;; Uncompress all lists of marked articles in the newsrc assoc.
12093 (let ((newsrc gnus-newsrc-alist)
12096 (if (not (setq marked (nth 3 (car newsrc))))
12099 (or (eq 'score (car (car marked)))
12100 (eq 'bookmark (car (car marked)))
12101 (eq 'killed (car (car marked)))
12102 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12103 (setq marked (cdr marked))))
12104 (setq newsrc (cdr newsrc)))))
12106 (defun gnus-compress-newsrc-assoc ()
12107 ;; Compress all lists of marked articles in the newsrc assoc.
12108 (let ((newsrc gnus-newsrc-alist)
12111 (if (not (setq marked (nth 3 (car newsrc))))
12114 (or (eq 'score (car (car marked)))
12115 (eq 'bookmark (car (car marked)))
12116 (eq 'killed (car (car marked)))
12117 (setcdr (car marked)
12118 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
12119 (setq marked (cdr marked))))
12120 (setq newsrc (cdr newsrc)))))
12122 (defun gnus-newsrc-to-gnus-format ()
12123 (setq gnus-newsrc-options "")
12124 (or gnus-active-hashtb
12125 (setq gnus-active-hashtb (make-vector 4095 0)))
12126 (let ((buf (current-buffer))
12127 (already-read (> (length gnus-newsrc-alist) 1))
12128 group level subscribed info options-symbol newsrc
12130 (goto-char (point-min))
12131 ;; We intern the symbol `options' in the active hashtb so that we
12132 ;; can `eq' against it later.
12133 (setq options-symbol (intern "options" gnus-active-hashtb))
12135 (while (not (eobp))
12136 ;; We first read the first word on the line by narrowing and
12137 ;; then reading into `gnus-active-hashtb'. Most groups will
12138 ;; already exist in that hashtb, so this will save some string
12142 (progn (skip-chars-forward "^ \t!:\n") (point)))
12143 (goto-char (point-min))
12145 (and (/= (point-min) (point-max))
12146 (let ((obarray gnus-active-hashtb)) (read buf))))
12148 ;; Now, the symbol we have read is either `options' or a group
12149 ;; name. If it is an options line, we just add it to a string.
12151 ((eq symbol options-symbol)
12152 (setq gnus-newsrc-options
12153 ;; This concatting is quite inefficient, but since our
12154 ;; thorough studies show that approx 99.37% of all
12155 ;; .newsrc files only contain a single options line, we
12156 ;; don't give a damn, frankly, my dear.
12157 (concat gnus-newsrc-options
12159 (gnus-point-at-bol)
12160 ;; Options may continue on the next line.
12161 (or (and (re-search-forward "^[^ \t]" nil 'move)
12162 (progn (beginning-of-line) (point)))
12165 ;; It was a group name.
12166 (setq subscribed (= (following-char) ?:)
12167 group (symbol-name symbol)
12170 ;; If the line ends here, this is clearly a buggy line, so
12171 ;; we put point a the beginning of line and let the cond
12172 ;; below do the error handling.
12173 (beginning-of-line)
12174 ;; We skip to the beginning of the ranges.
12175 (skip-chars-forward "!: \t"))
12176 ;; We are now at the beginning of the list of read articles.
12177 ;; We read them range by range.
12180 ((looking-at "[0-9]+")
12181 ;; We narrow and read a number instead of buffer-substring/
12182 ;; string-to-int because it's faster. narrow/widen is
12183 ;; faster than save-restriction/narrow, and save-restriction
12184 ;; produces a garbage object.
12186 (narrow-to-region (match-beginning 0) (match-end 0))
12189 ;; If the next character is a dash, then this is a range.
12190 (if (= (following-char) ?-)
12192 ;; We read the upper bound of the range.
12194 (if (not (looking-at "[0-9]+"))
12195 ;; This is a buggy line, by we pretend that
12196 ;; it's kinda OK. Perhaps the user should be
12198 (setq reads (cons num1 reads))
12202 (narrow-to-region (match-beginning 0)
12207 ;; It was just a simple number, so we add it to the
12209 (setq reads (cons num1 reads)))
12210 ;; If the next char in ?\n, then we have reached the end
12211 ;; of the line and return nil.
12212 (/= (following-char) ?\n))
12213 ((= (following-char) ?\n)
12214 ;; End of line, so we end.
12217 ;; Not numbers and not eol, so this might be a buggy
12219 (or (eobp) ; If it was eob instead of ?\n, we allow it.
12221 ;; The line was buggy.
12223 (gnus-message 3 "Mangled line: %s"
12224 (buffer-substring (gnus-point-at-bol)
12225 (gnus-point-at-eol)))
12229 ;; Skip past ", ". Spaces are illegal in these ranges, but
12230 ;; we allow them, because it's a common mistake to put a
12231 ;; space after the comma.
12232 (skip-chars-forward ", "))
12234 ;; We have already read .newsrc.eld, so we gently update the
12235 ;; data in the hash table with the information we have just
12239 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12242 ;; There is an entry for this file in the alist.
12244 (setcar (nthcdr 2 info) (nreverse reads))
12245 ;; We update the level very gently. In fact, we
12246 ;; only change it if there's been a status change
12247 ;; from subscribed to unsubscribed, or vice versa.
12248 (setq level (nth 1 info))
12249 (cond ((and (<= level gnus-level-subscribed)
12251 (setq level (if reads
12252 gnus-level-default-unsubscribed
12253 (1+ gnus-level-default-unsubscribed))))
12254 ((and (> level gnus-level-subscribed) subscribed)
12255 (setq level gnus-level-default-subscribed)))
12256 (setcar (cdr info) level))
12257 ;; This is a new group.
12258 (setq info (list group
12260 gnus-level-default-subscribed
12262 (1+ gnus-level-subscribed)
12263 gnus-level-default-unsubscribed))
12264 (nreverse reads))))
12265 (setq newsrc (cons info newsrc))))
12266 (forward-line 1))))
12268 (setq newsrc (nreverse newsrc))
12270 (if (not already-read)
12272 ;; We now have two newsrc lists - `newsrc', which is what we
12273 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
12274 ;; what we've read from .newsrc.eld. We have to merge these
12275 ;; lists. We do this by "attaching" any (foreign) groups in the
12276 ;; gnus-newsrc-alist to the (native) group that precedes them.
12277 (let ((rc (cdr gnus-newsrc-alist))
12278 (prev gnus-newsrc-alist)
12281 (or (assoc (car (car rc)) newsrc)
12282 (if (setq entry (assoc (car (car prev)) newsrc))
12283 (setcdr (setq mentry (memq entry newsrc))
12284 (cons (car rc) (cdr mentry)))
12285 (setq newsrc (cons (car rc) newsrc))))
12289 (setq gnus-newsrc-alist newsrc)
12290 ;; We make the newsrc hashtb.
12291 (gnus-make-hashtable-from-newsrc-alist)
12293 ;; Finally, if we read some options lines, we parse them.
12294 (or (string= gnus-newsrc-options "")
12295 (gnus-newsrc-parse-options gnus-newsrc-options))
12298 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12299 ;; The return value will be a list on the form
12300 ;; ((regexp1 . ignore)
12301 ;; (regexp2 . subscribe)...)
12302 ;; When handling new newsgroups, groups that match a `ignore' regexp
12303 ;; will be ignored, and groups that match a `subscribe' regexp will be
12304 ;; subscribed. A line like
12305 ;; options -n !all rec.all
12306 ;; will lead to a list that looks like
12307 ;; (("^rec\\..+" . subscribe)
12308 ;; ("^.+" . ignore))
12309 ;; So all "rec.*" groups will be subscribed, while all the other
12310 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12311 ;; different from "options -n rec.all !all".
12312 (defun gnus-newsrc-parse-options (options)
12315 (gnus-set-work-buffer)
12316 (insert (regexp-quote options))
12317 ;; First we treat all continuation lines.
12318 (goto-char (point-min))
12319 (while (re-search-forward "\n[ \t]+" nil t)
12320 (replace-match " " t t))
12321 ;; Then we transform all "all"s into ".+"s.
12322 (goto-char (point-min))
12323 (while (re-search-forward "\\ball\\b" nil t)
12324 (replace-match ".+" t t))
12325 (goto-char (point-min))
12326 ;; We remove all other options than the "-n" ones.
12327 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12328 (replace-match " ")
12330 (goto-char (point-min))
12332 ;; We are only interested in "options -n" lines - we
12333 ;; ignore the other option lines.
12334 (while (re-search-forward "[ \t]-n" nil t)
12336 (or (save-excursion
12337 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12339 (gnus-point-at-eol)))
12340 ;; Search for all "words"...
12341 (while (re-search-forward "[^ \t,\n-]+" eol t)
12342 (if (= (char-after (match-beginning 0)) ?!)
12343 ;; If the word begins with a bang (!), this is a "not"
12344 ;; spec. We put this spec (minus the bang) and the
12345 ;; symbol `ignore' into the list.
12346 (setq out (cons (cons (concat
12347 "^" (buffer-substring
12348 (1+ (match-beginning 0))
12351 ;; There was no bang, so this is a "yes" spec.
12352 (setq out (cons (cons (concat
12353 "^" (buffer-substring (match-beginning 0)
12355 'subscribe) out)))))
12357 (setq gnus-newsrc-options-n out))))
12360 (defun gnus-save-newsrc-file ()
12361 "Save .newsrc file."
12362 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12363 ;; from the variable gnus-newsrc-alist.
12364 (and (or gnus-newsrc-alist gnus-killed-list)
12365 gnus-current-startup-file
12366 (let ((make-backup-files t)
12367 (version-control nil)
12368 (require-final-newline t)) ;Don't ask even if requested.
12369 ;; You can stop or change version control of backup file.
12370 ;; Suggested by jason@violet.berkeley.edu.
12371 (run-hooks 'gnus-save-newsrc-hook)
12373 (if (or (not gnus-dribble-buffer)
12374 (not (buffer-name gnus-dribble-buffer))
12375 (zerop (save-excursion
12376 (set-buffer gnus-dribble-buffer)
12378 (gnus-message 4 "(No changes need to be saved)")
12379 (if gnus-save-newsrc-file
12381 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12382 ;; Make backup file of master newsrc.
12383 (gnus-gnus-to-newsrc-format)
12384 (gnus-message 5 "Saving %s...done"
12385 gnus-current-startup-file)))
12386 ;; Quickly loadable .newsrc.
12387 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12388 (gnus-add-current-to-buffer-list)
12389 (buffer-disable-undo (current-buffer))
12391 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12392 (gnus-gnus-to-quick-newsrc-format)
12393 (write-region 1 (point-max)
12394 (concat gnus-current-startup-file ".eld")
12396 (kill-buffer (current-buffer))
12397 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
12398 (gnus-dribble-delete-file))))))
12400 (defun gnus-gnus-to-quick-newsrc-format ()
12401 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12402 (insert ";; (ding) Gnus startup file.\n")
12403 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12404 (insert ";; to read .newsrc.\n")
12405 (let ((variables gnus-variable-list)
12407 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12409 ;; insert lisp expressions.
12410 (gnus-compress-newsrc-assoc)
12412 (setq variable (car variables))
12413 (and (boundp variable)
12414 (symbol-value variable)
12415 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12416 (insert "(setq " (symbol-name variable) " '"
12417 (prin1-to-string (symbol-value variable))
12419 (setq variables (cdr variables)))
12420 (gnus-uncompress-newsrc-assoc)))
12423 (defun gnus-gnus-to-newsrc-format ()
12424 ;; Generate and save the .newsrc file.
12425 (let ((newsrc (cdr gnus-newsrc-alist))
12428 (set-buffer (create-file-buffer gnus-startup-file))
12429 (buffer-disable-undo (current-buffer))
12432 (if gnus-newsrc-options (insert gnus-newsrc-options))
12433 ;; Write subscribed and unsubscribed.
12435 (setq info (car newsrc))
12436 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12438 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12440 (if (setq ranges (nth 2 info))
12443 (if (not (listp (cdr ranges)))
12444 (if (= (car ranges) (cdr ranges))
12445 (insert (int-to-string (car ranges)))
12446 (insert (int-to-string (car ranges)) "-"
12447 (int-to-string (cdr ranges))))
12449 (setq range (car ranges)
12450 ranges (cdr ranges))
12451 (if (or (atom range) (= (car range) (cdr range)))
12452 (insert (int-to-string
12453 (or (and (atom range) range)
12455 (insert (int-to-string (car range)) "-"
12456 (int-to-string (cdr range))))
12457 (if ranges (insert ","))))))
12459 (setq newsrc (cdr newsrc)))
12460 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12461 (kill-buffer (current-buffer)))))
12463 (defun gnus-read-descriptions-file ()
12464 (gnus-message 5 "Reading descriptions file...")
12466 ((not (or (gnus-server-opened gnus-select-method)
12467 (gnus-open-server gnus-select-method)))
12468 (gnus-message 1 "Couldn't open server")
12470 ((not (gnus-request-list-newsgroups gnus-select-method))
12471 (gnus-message 1 "Couldn't read newsgroups descriptions")
12475 (setq gnus-description-hashtb
12476 (gnus-make-hashtable (length gnus-active-hashtb)))
12479 (set-buffer nntp-server-buffer)
12480 (goto-char (point-min))
12481 (if (or (search-forward "\n.\n" nil t)
12482 (goto-char (point-max)))
12484 (beginning-of-line)
12485 (narrow-to-region (point-min) (point))))
12486 (goto-char (point-min))
12487 (while (not (eobp))
12488 ;; If we get an error, we set group to 0, which is not a
12492 (let ((obarray gnus-description-hashtb))
12493 ;; Group is set to a symbol interned in this
12495 (read nntp-server-buffer))
12497 (skip-chars-forward " \t")
12498 ;; ... which leads to this line being effectively ignored.
12499 (and (symbolp group)
12500 (set group (buffer-substring
12501 (point) (progn (end-of-line) (point)))))
12502 (forward-line 1))))
12503 (gnus-message 5 "Reading descriptions file...done")
12506 (defun gnus-group-get-description (group)
12507 ;; Get the description of a group by sending XGTITLE to the server.
12508 (and (gnus-request-group-description group)
12510 (set-buffer nntp-server-buffer)
12511 (goto-char (point-min))
12512 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12513 (buffer-substring (match-beginning 1) (match-end 1))))))
12519 (defvar gnus-server-mode-hook nil
12520 "Hook run in `gnus-server-mode' buffers.")
12522 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12523 "Format of server lines.
12524 It works along the same lines as a normal formatting string,
12525 with some simple extensions.")
12527 (defvar gnus-server-mode-line-format "(ding) List of servers"
12528 "The format specification for the server mode line.")
12530 (defconst gnus-server-line-format-alist
12531 (list (list ?h 'how ?s)
12533 (list ?w 'where ?s)
12536 (defconst gnus-server-mode-line-format-alist
12537 (list (list ?S 'news-server ?s)
12538 (list ?M 'news-method ?s)
12539 (list ?u 'user-defined ?s)))
12541 (defvar gnus-server-line-format-spec nil)
12542 (defvar gnus-server-mode-line-format-spec nil)
12543 (defvar gnus-server-killed-servers nil)
12545 (defvar gnus-server-mode-map nil)
12546 (put 'gnus-server-mode 'mode-class 'special)
12548 (if gnus-server-mode-map
12550 (setq gnus-server-mode-map (make-sparse-keymap))
12551 (suppress-keymap gnus-server-mode-map)
12552 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12553 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12554 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12555 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12556 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12557 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12558 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12559 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12560 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12561 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12563 (defun gnus-server-mode ()
12564 "Major mode for listing and editing servers.
12566 All normal editing commands are switched off.
12567 \\<gnus-server-mode-map>
12569 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12571 The following commands are available:
12573 \\{gnus-server-mode-map}"
12575 (if gnus-visual (gnus-server-make-menu-bar))
12576 (kill-all-local-variables)
12577 (setq mode-line-modified "-- ")
12578 (make-local-variable 'mode-line-format)
12579 (setq mode-line-format (copy-sequence mode-line-format))
12580 (and (equal (nth 3 mode-line-format) " ")
12581 (setcar (nthcdr 3 mode-line-format) ""))
12582 (setq major-mode 'gnus-server-mode)
12583 (setq mode-name "Server")
12584 ; (gnus-group-set-mode-line)
12585 (setq mode-line-process nil)
12586 (use-local-map gnus-server-mode-map)
12587 (buffer-disable-undo (current-buffer))
12588 (setq truncate-lines t)
12589 (setq buffer-read-only t)
12590 (run-hooks 'gnus-server-mode-hook))
12592 (defun gnus-server-insert-server-line (sformat name method)
12593 (let* ((sformat (or sformat gnus-server-line-format-spec))
12595 (where (nth 1 method))
12597 (beginning-of-line)
12599 ;; Insert the text.
12600 (insert (eval sformat))
12601 (add-text-properties
12602 b (1+ b) (list 'gnus-server (intern name)))))
12604 (defun gnus-server-setup-buffer ()
12605 (if (get-buffer gnus-server-buffer)
12608 (set-buffer (get-buffer-create gnus-server-buffer))
12610 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
12612 (defun gnus-server-prepare ()
12613 (setq gnus-server-mode-line-format-spec
12614 (gnus-parse-format gnus-server-mode-line-format
12615 gnus-server-mode-line-format-alist))
12616 (setq gnus-server-line-format-spec
12617 (gnus-parse-format gnus-server-line-format
12618 gnus-server-line-format-alist))
12619 (let ((alist gnus-server-alist)
12620 (buffer-read-only nil))
12623 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
12624 (setq alist (cdr alist))))
12625 (goto-char (point-min))
12626 (gnus-server-position-cursor))
12628 (defun gnus-server-server-name ()
12629 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
12630 (and server (symbol-name server))))
12632 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
12634 (defconst gnus-server-edit-buffer "*Gnus edit server*")
12636 (defun gnus-server-update-server (server)
12638 (set-buffer gnus-server-buffer)
12639 (let ((buffer-read-only nil)
12640 (info (cdr (assoc server gnus-server-alist))))
12641 (gnus-dribble-enter
12642 (concat "(gnus-server-set-info \"" server "\" '"
12643 (prin1-to-string info) ")"))
12644 ;; Buffer may be narrowed.
12647 (if (gnus-server-goto-server server)
12648 (delete-region (progn (beginning-of-line) (point))
12649 (progn (forward-line 1) (point))))
12650 (let ((entry (assoc server gnus-server-alist)))
12651 (gnus-server-insert-server-line nil (car entry) (cdr entry))
12652 (gnus-server-position-cursor))))))
12654 (defun gnus-server-set-info (server info)
12655 ;; Enter a select method into the virtual server alist.
12656 (gnus-dribble-enter
12657 (concat "(gnus-server-set-info \"" server "\" '"
12658 (prin1-to-string info) ")"))
12659 (let* ((server (nth 1 info))
12660 (entry (assoc server gnus-server-alist)))
12661 (if entry (setcdr entry info)
12662 (setq gnus-server-alist
12663 (nconc gnus-server-alist (list (cons server info)))))))
12665 (defun gnus-server-to-method (server)
12666 ;; Map virtual server names to select methods.
12667 (or (and (equal server "native") gnus-select-method)
12668 (cdr (assoc server gnus-server-alist))))
12670 (defun gnus-server-extend-method (group method)
12671 ;; This function "extends" a virtual server. If the server is
12672 ;; "hello", and the select method is ("hello" (my-var "something"))
12673 ;; in the group "alt.alt", this will result in a new virtual server
12674 ;; called "helly+alt.alt".
12676 (gnus-copy-sequence
12677 (if (equal (car method) "native") gnus-select-method
12678 (cdr (assoc (car method) gnus-server-alist))))))
12679 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
12680 (nconc entry (cdr method))))
12682 (defun gnus-server-get-method (group method)
12683 ;; Input either a server name, and extended server name, or a
12684 ;; select method, and return a select method.
12685 (cond ((stringp method)
12686 (gnus-server-to-method method))
12687 ((stringp (car method))
12688 (gnus-server-extend-method group method))
12690 (gnus-server-add-address method))))
12692 (defun gnus-server-add-address (method)
12693 (let ((method-name (symbol-name (car method))))
12694 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
12695 (not (assq (intern (concat method-name "-address")) method)))
12696 (append method (list (list (intern (concat method-name "-address"))
12700 (defun gnus-server-equal (s1 s2)
12702 (and (= (length s1) (length s2))
12704 (while (and s1 (member (car s1) s2))
12705 (setq s1 (cdr s1)))
12708 ;;; Interactive server functions.
12710 (defun gnus-server-kill-server (server)
12711 "Kill the server on the current line."
12712 (interactive (list (gnus-server-server-name)))
12713 (or (gnus-server-goto-server server)
12714 (if server (error "No such server: %s" server)
12715 (error "No server on the current line")))
12716 (let ((buffer-read-only nil))
12717 (delete-region (progn (beginning-of-line) (point))
12718 (progn (forward-line 1) (point))))
12719 (setq gnus-server-killed-servers
12720 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
12721 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
12722 gnus-server-alist))
12723 (gnus-server-position-cursor))
12725 (defun gnus-server-yank-server ()
12726 "Yank the previously killed server."
12728 (or gnus-server-killed-servers
12729 (error "No killed servers to be yanked"))
12730 (let ((alist gnus-server-alist)
12731 (server (gnus-server-server-name))
12732 (killed (car gnus-server-killed-servers)))
12734 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
12735 (if (string= server (car (car gnus-server-alist)))
12736 (setq gnus-server-alist (cons killed gnus-server-alist))
12737 (while (and (cdr alist)
12738 (not (string= server (car (car (cdr alist))))))
12739 (setq alist (cdr alist)))
12740 (setcdr alist (cons killed (cdr alist)))))
12741 (gnus-server-update-server (car killed))
12742 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
12743 (gnus-server-position-cursor)))
12745 (defun gnus-server-exit ()
12746 "Return to the group buffer."
12748 (kill-buffer (current-buffer))
12749 (switch-to-buffer gnus-group-buffer))
12751 (defun gnus-server-list-servers ()
12752 "List all available servers."
12754 (let ((cur (gnus-server-server-name)))
12755 (gnus-server-prepare)
12756 (if cur (gnus-server-goto-server cur)
12757 (goto-char (point-max))
12759 (gnus-server-position-cursor)))
12761 (defun gnus-server-copy-server (from to)
12764 (or (gnus-server-server-name)
12765 (error "No server on the current line"))
12766 (read-string "Copy to: ")))
12767 (or from (error "No server on current line"))
12768 (or (and to (not (string= to ""))) (error "No name to copy to"))
12769 (and (assoc to gnus-server-alist) (error "%s already exists" to))
12770 (or (assoc from gnus-server-alist)
12771 (error "%s: no such server" from))
12772 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
12773 (setcar to-entry to)
12774 (setcar (nthcdr 2 to-entry) to)
12775 (setq gnus-server-killed-servers
12776 (cons to-entry gnus-server-killed-servers))
12777 (gnus-server-yank-server)))
12779 (defun gnus-server-add-server (how where)
12781 (list (intern (completing-read "Server method: "
12782 gnus-valid-select-methods nil t))
12783 (read-string "Server name: ")))
12784 (setq gnus-server-killed-servers
12785 (cons (list where how where) gnus-server-killed-servers))
12786 (gnus-server-yank-server))
12788 (defun gnus-server-goto-server (server)
12789 "Jump to a server line."
12791 (list (completing-read "Goto server: " gnus-server-alist nil t)))
12792 (let ((to (text-property-any (point-min) (point-max)
12793 'gnus-server (intern server))))
12797 (gnus-server-position-cursor)))))
12799 (defun gnus-server-edit-server (server)
12800 "Edit the server on the current line."
12801 (interactive (list (gnus-server-server-name)))
12803 (error "No server on current line"))
12804 (let ((winconf (current-window-configuration)))
12805 (get-buffer-create gnus-server-edit-buffer)
12806 (gnus-configure-windows 'edit-server)
12807 (gnus-add-current-to-buffer-list)
12809 (make-local-variable 'gnus-prev-winconf)
12810 (setq gnus-prev-winconf winconf)
12811 (use-local-map (copy-keymap (current-local-map)))
12812 (let ((done-func '(lambda ()
12813 "Exit editing mode and update the information."
12815 (gnus-server-edit-server-done 'group))))
12816 (setcar (cdr (nth 4 done-func)) server)
12817 (local-set-key "\C-c\C-c" done-func))
12819 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
12820 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
12822 (defun gnus-server-edit-server-done (server)
12824 (set-buffer (get-buffer-create gnus-server-edit-buffer))
12825 (goto-char (point-min))
12826 (let ((form (read (current-buffer)))
12827 (winconf gnus-prev-winconf))
12828 (gnus-server-set-info server form)
12829 (kill-buffer (current-buffer))
12830 (and winconf (set-window-configuration winconf))
12831 (set-buffer gnus-server-buffer)
12832 (gnus-server-update-server (gnus-server-server-name))
12833 (gnus-server-position-cursor)))
12835 (defun gnus-server-read-server (server)
12837 (interactive (list (gnus-server-server-name)))
12838 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
12840 (defun gnus-mouse-pick-server (e)
12842 (mouse-set-point e)
12843 (gnus-server-read-server (gnus-server-server-name)))
12846 ;;; entry points into gnus-score.el
12849 ;;; Finding score files.
12851 (defvar gnus-global-score-files nil
12852 "*List of global score files and directories.
12853 Set this variable if you want to use people's score files. One entry
12854 for each score file or each score file directory. Gnus will decide
12855 by itself what score files are applicable to which group.
12857 Say you want to use the single score file
12858 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
12859 score files in the \"/ftp.some-where:/pub/score\" directory.
12861 (setq gnus-global-score-files
12862 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
12863 \"/ftp.some-where:/pub/score\"))")
12865 (defun gnus-score-score-files (group)
12866 "Return a list of all possible score files."
12867 ;; Search and set any global score files.
12868 (and gnus-global-score-files
12869 (or gnus-internal-global-score-files
12870 (gnus-score-search-global-directories gnus-global-score-files)))
12871 ;; Fix the kill-file dir variable.
12872 (setq gnus-kill-files-directory
12873 (file-name-as-directory
12874 (or gnus-kill-files-directory "~/News/")))
12875 ;; If er can't read it, there's no score files.
12876 (if (not (file-readable-p (expand-file-name gnus-kill-files-directory)))
12877 (setq gnus-score-file-list nil)
12878 (if (gnus-use-long-file-name 'not-score)
12879 ;; We want long file names.
12880 (if (or (not gnus-score-file-list)
12881 (not (car gnus-score-file-list))
12882 (gnus-file-newer-than gnus-kill-files-directory
12883 (car gnus-score-file-list)))
12884 (setq gnus-score-file-list
12885 (cons (nth 5 (file-attributes gnus-kill-files-directory))
12888 gnus-kill-files-directory t
12889 (gnus-score-file-regexp))))))
12890 ;; We do not use long file names, so we have to do some
12891 ;; directory traversing.
12892 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
12893 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
12896 (setq dir (expand-file-name
12897 (concat gnus-kill-files-directory
12898 (gnus-replace-chars-in-string group ?. ?/))))
12899 (setq suffix (car suffixes)
12900 suffixes (cdr suffixes))
12901 (if (file-exists-p (concat dir "/" suffix))
12902 (setq files (cons (concat dir "/" suffix) files)))
12903 (while (>= (1+ (length dir)) mdir)
12904 (and (file-exists-p (concat dir "/all/" suffix))
12905 (setq files (cons (concat dir "/all/" suffix) files)))
12906 (string-match "/[^/]*$" dir)
12907 (setq dir (substring dir 0 (match-beginning 0)))))
12908 (setq gnus-score-file-list
12909 (cons nil (nreverse files)))))
12910 (cdr gnus-score-file-list)))
12912 (defun gnus-score-file-regexp ()
12913 (concat "\\(" gnus-score-file-suffix
12914 "\\|" gnus-adaptive-file-suffix "\\)$"))
12916 (defun gnus-score-find-bnews (group)
12917 "Return a list of score files for GROUP.
12918 The score files are those files in the ~/News directory which matches
12919 GROUP using BNews sys file syntax."
12920 (let* ((sfiles (append (gnus-score-score-files group)
12921 gnus-internal-global-score-files))
12922 (kill-dir (file-name-as-directory
12923 (expand-file-name gnus-kill-files-directory)))
12924 (klen (length kill-dir))
12925 ofiles not-match regexp)
12927 (set-buffer (get-buffer-create "*gnus score files*"))
12928 (buffer-disable-undo (current-buffer))
12929 ;; Go through all score file names and create regexp with them
12933 (insert (car sfiles))
12934 (goto-char (point-min))
12935 ;; First remove the suffix itself.
12936 (re-search-forward (concat "." (gnus-score-file-regexp)))
12937 (replace-match "" t t)
12938 (goto-char (point-min))
12939 (if (looking-at (regexp-quote kill-dir))
12940 ;; If the file name was just "SCORE", `klen' is one character
12942 (delete-char (min (1- (point-max)) klen))
12943 (goto-char (point-max))
12944 (search-backward "/")
12945 (delete-region (1+ (point)) (point-min)))
12946 ;; If short file names were used, we have to translate slashes.
12947 (goto-char (point-min))
12948 (while (search-forward "/" nil t)
12949 (replace-match "." t t))
12950 ;; Translate "all" to ".*".
12951 (while (search-forward "all" nil t)
12952 (replace-match ".*" t t))
12953 (goto-char (point-min))
12954 ;; Deal with "not."s.
12955 (if (looking-at "not.")
12958 (setq regexp (buffer-substring 5 (point-max))))
12959 (setq regexp (buffer-substring 1 (point-max)))
12960 (setq not-match nil))
12961 ;; Finally - if this resulting regexp matches the group name,
12962 ;; we add this score file to the list of score files
12963 ;; applicable to this group.
12964 (if (or (and not-match
12965 (not (string-match regexp group)))
12966 (and (not not-match)
12967 (string-match regexp group)))
12968 (setq ofiles (cons (car sfiles) ofiles)))
12969 (setq sfiles (cdr sfiles)))
12970 (kill-buffer (current-buffer))
12971 ;; Slight kludge here - the last score file returned should be
12972 ;; the local score file, whether it exists or not. This is so
12973 ;; that any score commands the user enters will go to the right
12974 ;; file, and not end up in some global score file.
12977 (if (gnus-use-long-file-name 'not-score)
12978 (concat gnus-kill-files-directory group "."
12979 gnus-score-file-suffix)
12980 (concat gnus-kill-files-directory
12981 (gnus-replace-chars-in-string group ?. ?/)
12982 "/" gnus-score-file-suffix)))))
12983 (and (member localscore ofiles)
12984 (delete localscore ofiles))
12985 (setq ofiles (cons localscore ofiles)))
12986 (nreverse ofiles))))
12988 (defun gnus-score-find-single (group)
12989 "Return list containing the score file for GROUP."
12990 (list (gnus-score-file-name group)))
12992 (defun gnus-score-find-hierarchical (group)
12993 "Return list of score files for GROUP.
12994 This includes the score file for the group and all its parents."
12995 (let ((all (copy-sequence '(nil)))
12997 (while (string-match "\\." group (1+ start))
12998 (setq start (match-beginning 0))
12999 (setq all (cons (substring group 0 start) all)))
13000 (setq all (cons group all))
13001 (mapcar 'gnus-score-file-name (nreverse all))))
13003 (defvar gnus-score-file-alist-cache nil)
13005 (defun gnus-score-find-alist (group)
13006 "Return list of score files for GROUP.
13007 The list is determined from the variable gnus-score-file-alist."
13008 (let ((alist gnus-score-file-multiple-match-alist)
13010 ;; if this group has been seen before, return the cached entry
13011 (if (setq score-files (assoc group gnus-score-file-alist-cache))
13012 (cdr score-files) ; ensures caching of groups with no matches
13013 ;; handle the multiple match alist
13015 (and (string-match (car (car alist)) group)
13017 (nconc score-files (cdr (car alist)))))
13018 (setq alist (cdr alist)))
13019 (setq alist gnus-score-file-single-match-alist)
13020 ;; handle the single match alist
13023 (and (string-match (car (car alist)) group)
13024 ;; progn used just in case ("regexp") has no files
13025 ;; and score-files is still nil. -sj
13026 ;; this can be construed as a "stop searching here" feature :>
13027 ;; and used to simplify regexps in the single-alist
13030 (nconc score-files (cdr (car alist))))
13031 (throw 'done nil)))
13032 (setq alist (cdr alist))))
13033 ;; cache the score files
13034 (setq gnus-score-file-alist-cache
13035 (cons (cons group score-files) gnus-score-file-alist-cache))
13039 (defun gnus-possibly-score-headers (&optional trace)
13040 (let ((func gnus-score-find-score-files-function)
13041 score-files scores)
13042 (and func (not (listp func))
13043 (setq func (list func)))
13044 ;; Go through all the functions for finding score files (or actual
13045 ;; scores) and add them to a list.
13046 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
13048 (and (symbolp (car func))
13049 (fboundp (car func))
13051 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
13052 (setq func (cdr func)))
13053 (if score-files (gnus-score-headers score-files trace))))
13055 (defun gnus-score-file-name (newsgroup &optional suffix)
13056 "Return the name of a score file for NEWSGROUP."
13057 (let ((suffix (or suffix gnus-score-file-suffix)))
13058 (cond ((or (null newsgroup)
13059 (string-equal newsgroup ""))
13060 ;; The global score file is placed at top of the directory.
13062 suffix (or gnus-kill-files-directory "~/News")))
13063 ((gnus-use-long-file-name 'not-score)
13064 ;; Append ".SCORE" to newsgroup name.
13065 (expand-file-name (concat newsgroup "." suffix)
13066 (or gnus-kill-files-directory "~/News")))
13068 ;; Place "SCORE" under the hierarchical directory.
13069 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13071 (or gnus-kill-files-directory "~/News"))))))
13073 (defun gnus-score-search-global-directories (files)
13074 "Scan all global score directories for score files."
13075 ;; Set the variable `gnus-internal-global-score-files' to all
13076 ;; available global score files.
13077 (interactive (list gnus-global-score-files))
13080 (if (string-match "/$" (car files))
13081 (setq out (nconc (directory-files
13083 (concat (gnus-score-file-regexp) "$"))))
13084 (setq out (cons (car files) out)))
13085 (setq files (cdr files)))
13086 (setq gnus-internal-global-score-files out)))
13088 ;; Allow redefinition of Gnus functions.
13090 (gnus-ems-redefine)
13094 ;;; gnus.el ends here