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 method (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 multiple 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 algorithm 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-summary-zcore-fuzz 0
541 "*Fuzziness factor for the zcore in the summary buffer.
542 Articles with scores closer than this to `gnus-summary-default-score'
543 will not be marked.")
545 (defvar gnus-simplify-subject-fuzzy-regexp nil
546 "*Regular expression that will be removed from subject strings if
547 fuzzy subject simplification is selected.")
549 (defvar gnus-group-default-list-level gnus-level-subscribed
550 "*Default listing level.
551 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
553 (defvar gnus-group-use-permanent-levels nil
554 "*If non-nil, once you set a level, Gnus will use this level.")
556 (defvar gnus-show-mime nil
557 "*If non-nil, do mime processing of articles.
558 The articles will simply be fed to the function given by
559 `gnus-show-mime-method'.")
561 (defvar gnus-strict-mime t
562 "*If nil, decode MIME header even if there is not Mime-Version field.")
564 (defvar gnus-show-mime-method (function metamail-buffer)
565 "*Function to process a MIME message.
566 The function is called from the article buffer.")
568 (defvar gnus-show-threads t
569 "*If non-nil, display threads in summary mode.")
571 (defvar gnus-thread-hide-subtree nil
572 "*If non-nil, hide all threads initially.
573 If threads are hidden, you have to run the command
574 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
575 to expose hidden threads.")
577 (defvar gnus-thread-hide-killed t
578 "*If non-nil, hide killed threads automatically.")
580 (defvar gnus-thread-ignore-subject nil
581 "*If non-nil, ignore subjects and do all threading based on the Reference header.
582 If nil, which is the default, articles that have different subjects
583 from their parents will start separate threads.")
585 (defvar gnus-thread-indent-level 4
586 "*Number that says how much each sub-thread should be indented.")
588 (defvar gnus-ignored-newsgroups ""
589 "*A regexp to match uninteresting newsgroups in the active file.
590 Any lines in the active file matching this regular expression are
591 removed from the newsgroup list before anything else is done to it,
592 thus making them effectively non-existent.")
594 (defvar gnus-ignored-headers
595 "^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:"
596 "*All headers that match this regexp will be hidden.
597 Also see `gnus-visible-headers'.")
599 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
600 "*All headers that do not match this regexp will be hidden.
601 Also see `gnus-ignored-headers'.")
603 (defvar gnus-sorted-header-list
604 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
605 "^Cc:" "^Date:" "^Organization:")
606 "*This variable is a list of regular expressions.
607 If it is non-nil, headers that match the regular expressions will
608 be placed first in the article buffer in the sequence specified by
611 (defvar gnus-show-all-headers nil
612 "*If non-nil, don't hide any headers.")
614 (defvar gnus-save-all-headers t
615 "*If non-nil, don't remove any headers before saving.")
617 (defvar gnus-inhibit-startup-message nil
618 "*If non-nil, the startup message will not be displayed.")
620 (defvar gnus-signature-separator "^-- *$"
621 "Regexp matching signature separator.")
623 (defvar gnus-auto-extend-newsgroup t
624 "*If non-nil, extend newsgroup forward and backward when requested.")
626 (defvar gnus-auto-select-first t
627 "*If non-nil, select the first unread article when entering a group.
628 If you want to prevent automatic selection of the first unread article
629 in some newsgroups, set the variable to nil in
630 `gnus-select-group-hook'.")
632 (defvar gnus-auto-select-next t
633 "*If non-nil, offer to go to the next group from the end of the previous.
634 If the value is t and the next newsgroup is empty, Gnus will exit
635 summary mode and go back to group mode. If the value is neither nil
636 nor t, Gnus will select the following unread newsgroup. In
637 particular, if the value is the symbol `quietly', the next unread
638 newsgroup will be selected without any confirmations.")
640 (defvar gnus-auto-select-same nil
641 "*If non-nil, select the next article with the same subject.")
643 (defvar gnus-summary-check-current nil
644 "*If non-nil, consider the current article when moving.
645 The \"unread\" movement commands will stay on the same line if the
646 current article is unread.")
648 (defvar gnus-auto-center-summary t
649 "*If non-nil, always center the current summary buffer.")
651 (defvar gnus-break-pages t
652 "*If non-nil, do page breaking on articles.
653 The page delimiter is specified by the `gnus-page-delimiter'
656 (defvar gnus-page-delimiter "^\^L"
657 "*Regexp describing what to use as article page delimiters.
658 The default value is \"^\^L\", which is a form linefeed at the
659 beginning of a line.")
661 (defvar gnus-use-full-window t
662 "*If non-nil, use the entire Emacs screen.")
664 (defvar gnus-window-configuration nil
665 "Obsolete variable. See `gnus-buffer-configuration'.")
667 (defvar gnus-buffer-configuration
668 '((group ([group 1.0 point]
669 (if gnus-carpal [group-carpal 4])))
670 (summary ([summary 1.0 point]
671 (if gnus-carpal [summary-carpal 4])))
672 (article ([summary 0.25 point]
673 (if gnus-carpal [summary-carpal 4])
675 (server ([server 1.0 point]
676 (if gnus-carpal [server-carpal 2])))
677 (browse ([browse 1.0 point]
678 (if gnus-carpal [browse-carpal 2])))
679 (group-mail ([mail 1.0 point]))
680 (summary-mail ([mail 1.0 point]))
681 (summary-reply ([article 0.5]
683 (info ([nil 1.0 point]))
684 (summary-faq ([summary 0.25]
686 (edit-group ([group 0.5]
687 [edit-group 1.0 point]))
688 (edit-server ([server 0.5]
689 [edit-server 1.0 point]))
690 (edit-score ([summary 0.25]
691 [edit-score 1.0 point]))
692 (post ([post 1.0 point]))
693 (reply ([article 0.5]
695 (mail-forward ([mail 1.0 point]))
696 (post-forward ([post 1.0 point]))
697 (reply-yank ([mail 1.0 point]))
698 (followup ([article 0.5]
700 (followup-yank ([post 1.0 point])))
701 "Window configuration for all possible Gnus buffers.
702 This variable is a list of lists. Each of these lists has a NAME and
703 a RULE. The NAMEs are commonsense names like `group', which names a
704 rule used when displaying the group buffer; `summary', which names a
705 rule for what happens when you enter a group and do not display an
706 article buffer; and so on. See the value of this variable for a
707 complete list of NAMEs.
709 Each RULE is a list of vectors. The first element in this vector is
710 the name of the buffer to be displayed; the second element is the
711 percentage of the screen this buffer is to occupy (a number in the
712 0.0-0.99 range); the optional third element is `point', which should
713 be present to denote which buffer point is to go to after making this
714 buffer configuration.")
716 (defvar gnus-window-to-buffer
717 '((group . gnus-group-buffer)
718 (summary . gnus-summary-buffer)
719 (article . gnus-article-buffer)
720 (server . gnus-server-buffer)
721 (browse . "*Gnus Browse Server*")
722 (edit-group . gnus-group-edit-buffer)
723 (edit-server . gnus-server-edit-buffer)
724 (group-carpal . gnus-carpal-group-buffer)
725 (summary-carpal . gnus-carpal-summary-buffer)
726 (server-carpal . gnus-carpal-server-buffer)
727 (browse-carpal . gnus-carpal-browse-buffer)
728 (edit-score . gnus-score-edit-buffer)
729 (mail . gnus-mail-buffer)
730 (post . gnus-post-news-buffer)
731 (faq . gnus-faq-buffer))
732 "Mapping from short symbols to buffer names or buffer variables.")
734 (defvar gnus-carpal nil
735 "*If non-nil, display clickable icons.")
737 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
738 "*Function called with a group name when new group is detected.
739 A few pre-made functions are supplied: `gnus-subscribe-randomly'
740 inserts new groups at the beginning of the list of groups;
741 `gnus-subscribe-alphabetically' inserts new groups in strict
742 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
743 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
746 ;; Suggested by a bug report by Hallvard B Furuseth.
747 ;; <h.b.furuseth@usit.uio.no>.
748 (defvar gnus-subscribe-options-newsgroup-method
749 (function gnus-subscribe-alphabetically)
750 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
751 If, for instance, you want to subscribe to all newsgroups in the
752 \"no\" and \"alt\" hierarchies, you'd put the following in your
755 options -n no.all alt.all
757 Gnus will the subscribe all new newsgroups in these hierarchies with
758 the subscription method in this variable.")
760 (defvar gnus-subscribe-hierarchical-interactive nil
761 "*If non-nil, Gnus will offer to subscribe hierarchically.
762 When a new hierarchy appears, Gnus will ask the user:
764 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
766 If the user pressed `d', Gnus will descend the hierarchy, `y' will
767 subscribe to all newsgroups in the hierarchy and `s' will skip this
768 hierarchy in its entirety.")
770 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
771 "*Function used for sorting the group buffer.
772 This function will be called with group info entries as the arguments
773 for the groups to be sorted. Pre-made functions include
774 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
775 `gnus-sort-by-level'")
777 ;; Mark variables suggested by Thomas Michanek
778 ;; <Thomas.Michanek@telelogic.se>.
779 (defvar gnus-unread-mark ?
780 "*Mark used for unread articles.")
781 (defvar gnus-ticked-mark ?!
782 "*Mark used for ticked articles.")
783 (defvar gnus-dormant-mark ??
784 "*Mark used for dormant articles.")
785 (defvar gnus-del-mark ?r
786 "*Mark used for del'd articles.")
787 (defvar gnus-read-mark ?R
788 "*Mark used for read articles.")
789 (defvar gnus-expirable-mark ?E
790 "*Mark used for expirable articles.")
791 (defvar gnus-killed-mark ?K
792 "*Mark used for killed articles.")
793 (defvar gnus-kill-file-mark ?X
794 "*Mark used for articles killed by kill files.")
795 (defvar gnus-low-score-mark ?Y
796 "*Mark used for articles with a low score.")
797 (defvar gnus-catchup-mark ?C
798 "*Mark used for articles that are caught up.")
799 (defvar gnus-replied-mark ?A
800 "*Mark used for articles that have been replied to.")
801 (defvar gnus-process-mark ?#
803 (defvar gnus-ancient-mark ?O
804 "*Mark used for ancient articles.")
805 (defvar gnus-canceled-mark ?G
806 "*Mark used for canceled articles.")
807 (defvar gnus-score-over-mark ?+
808 "*Score mark used for articles with high scores.")
809 (defvar gnus-score-below-mark ?-
810 "*Score mark used for articles with low scores.")
811 (defvar gnus-empty-thread-mark ?
812 "*There is no thread under the article.")
813 (defvar gnus-not-empty-thread-mark ?=
814 "*There is a thread under the article.")
815 (defvar gnus-dummy-mark ?Z
816 "*This is a dummy article.")
818 (defvar gnus-view-pseudo-asynchronously nil
819 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
821 (defvar gnus-view-pseudos nil
822 "*If `automatic', pseudo-articles will be viewed automatically.
823 If `not-confirm', pseudos will be viewed automatically, and the user
824 will not be asked to confirm the command.")
826 (defvar gnus-view-pseudos-separately t
827 "*If non-nil, one pseudo-article will be created for each file to be viewed.
828 If nil, all files that use the same viewing command will be given as a
829 list of parameters to that command.")
831 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
832 "*Format of group lines.
833 It works along the same lines as a normal formatting string,
834 with some simple extensions.
836 %M Only marked articles (character, \"*\" or \" \")
837 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
838 %L Level of subscribedness (integer)
839 %N Number of unread articles (integer)
840 %I Number of dormant articles (integer)
841 %i Number of ticked and dormant (integer)
842 %T Number of ticked articles (integer)
843 %R Number of read articles (integer)
844 %t Total number of articles (integer)
845 %y Number of unread, unticked articles (integer)
846 %G Group name (string)
847 %g Qualified group name (string)
848 %D Group description (string)
849 %s Select method (string)
850 %o Moderated group (char, \"m\")
851 %p Process mark (char)
852 %O Moderated group (string, \"(m)\" or \"\")
853 %n Select from where (string)
854 %z A string that look like `<%s:%n>' if a foreign select method is used
855 %u User defined specifier. The next character in the format string should
856 be a letter. Gnus will call the function gnus-user-format-function-X,
857 where X is the letter following %u. The function will be passed the
858 current header as argument. The function should return a string, which
859 will be inserted into the buffer just like information from any other
862 Text between %( and %) will be highlighted with `gnus-mouse-face' when
863 the mouse point move inside the area. There can only be one such area.
865 Note that this format specification is not always respected. For
866 reasons of efficiency, when listing killed groups, this specification
867 is ignored altogether. If the spec is changed considerably, your
868 output may end up looking strange when listing both alive and killed
871 If you use %o or %O, reading the active file will be slower and quite
872 a bit of extra memory will be used. %D will also worsen performance.
873 Also note that if you change the format specification to include any
874 of these specs, you must probably re-start Gnus to see them go into
877 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
878 "*The format specification of the lines in the summary buffer.
880 It works along the same lines as a normal formatting string,
881 with some simple extensions.
883 %N Article number, left padded with spaces (string)
885 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
886 %n Name of the poster (string)
887 %A Address of the poster (string)
888 %F Contents of the From: header (string)
889 %x Contents of the Xref: header (string)
890 %D Date of the article (string)
891 %d Date of the article (string) in DD-MMM format
892 %M Message-id of the article (string)
893 %r References of the article (string)
894 %c Number of characters in the article (integer)
895 %L Number of lines in the article (integer)
896 %I Indentation based on thread level (a string of spaces)
897 %T A string with two possible values: 80 spaces if the article
898 is on thread level two or larger and 0 spaces on level one
899 %R \"R\" if this article has been replied to, \" \" otherwise (character)
900 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
901 %[ Opening bracket (character, \"[\" or \"<\")
902 %] Closing bracket (character, \"]\" or \">\")
903 %> Spaces of length thread-level (string)
904 %< Spaces of length (- 20 thread-level) (string)
905 %i Article score (number)
906 %z Article zcore (character)
907 %t Number of articles under the current thread (number).
908 %e Whether the thread is empty or not (character).
909 %u User defined specifier. The next character in the format string should
910 be a letter. Gnus will call the function gnus-user-format-function-X,
911 where X is the letter following %u. The function will be passed the
912 current header as argument. The function should return a string, which
913 will be inserted into the summary just like information from any other
916 Text between %( and %) will be highlighted with `gnus-mouse-face'
917 when the mouse point is placed inside the area. There can only be one
920 The %U (status), %R (replied) and %z (zcore) specs have to be handled
921 with care. For reasons of efficiency, Gnus will compute what column
922 these characters will end up in, and \"hard-code\" that. This means that
923 it is illegal to have these specs after a variable-length spec. Well,
924 you might not be arrested, but your summary buffer will look strange,
927 The smart choice is to have these specs as for to the left as
930 This restriction may disappear in later versions of Gnus.")
932 (defvar gnus-summary-dummy-line-format "* : : %S\n"
933 "*The format specification for the dummy roots in the summary buffer.
934 It works along the same lines as a normal formatting string,
935 with some simple extensions.
939 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
940 "*The format specification for the summary mode line.")
942 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
943 "*The format specification for the article mode line.")
945 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
946 "*The format specification for the group mode line.")
948 (defvar gnus-valid-select-methods
949 '(("nntp" post address prompt-address)
951 ("nnvirtual" none virtual prompt-address)
952 ("nnmbox" mail respool)
953 ("nnml" mail respool)
954 ("nnmh" mail respool)
955 ("nndir" none prompt-address address)
956 ("nneething" none prompt-address)
958 ("nndoc" none prompt-address)
959 ("nnbabyl" mail respool)
960 ("nnkiboze" post virtual)
962 ("nnfolder" mail respool))
963 "An alist of valid select methods.
964 The first element of each list lists should be a string with the name
965 of the select method. The other elements may be be the category of
966 this method (ie. `post', `mail', `none' or whatever) or other
967 properties that this method has (like being respoolable).
968 If you implement a new select method, all you should have to change is
969 this variable. I think.")
971 (defvar gnus-updated-mode-lines '(group article summary)
972 "*List of buffers that should update their mode lines.
973 The list may contain the symbols `group', `article' and `summary'. If
974 the corresponding symbol is present, Gnus will keep that mode line
975 updated with information that may be pertinent.
976 If this variable is nil, screen refresh may be quicker.")
978 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
979 (defvar gnus-mode-non-string-length 21
980 "*Max length of mode-line non-string contents.
981 If this is nil, Gnus will take space as is needed, leaving the rest
982 of the modeline intact.")
984 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
985 (defvar gnus-display-type
987 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
988 (cond (display-resource (intern (downcase display-resource)))
989 ((x-display-color-p) 'color)
990 ((x-display-grayscale-p) 'grayscale)
993 "A symbol indicating the display Emacs is running under.
994 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
995 guesses this display attribute wrongly, either set this variable in
996 your `~/.emacs' or set the resource `Emacs.displayType' in your
997 `~/.Xdefaults'. See also `gnus-background-mode'.")
999 (defvar gnus-background-mode
1001 (let ((bg-resource (x-get-resource ".backgroundMode"
1003 (params (frame-parameters)))
1004 (cond (bg-resource (intern (downcase bg-resource)))
1005 ((< (apply '+ (x-color-values
1006 (cdr (assq 'background-color params))))
1007 (/ (apply '+ (x-color-values "white")) 3))
1011 "A symbol indicating the Emacs background brightness.
1012 The symbol should be one of `light' or `dark'.
1013 If Emacs guesses this frame attribute wrongly, either set this variable in
1014 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
1016 See also `gnus-display-type'.")
1018 (defvar gnus-mouse-face 'highlight
1019 "*Face used for mouse highlighting in Gnus.
1020 No mouse highlights will be done if `gnus-visual' is nil.")
1022 (defvar gnus-summary-mark-below nil
1023 "*Mark all articles with a score below this variable as read.
1024 This variable is local to each summary buffer and usually set by the
1027 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1028 "*List of functions used for sorting threads in the summary buffer.
1029 By default, threads are sorted by article number.
1031 Each function takes two threads and return non-nil if the first thread
1032 should be sorted before the other. If you use more than one function,
1033 the primary sort function should be the last.
1035 Ready-mady functions include `gnus-thread-sort-by-number',
1036 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1037 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1038 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1040 (defvar gnus-thread-score-function '+
1041 "*Function used for calculating the total score of a thread.
1043 The function is called with the scores of the article and each
1044 subthread and should then return the score of the thread.
1046 Some functions you can use are `+', `max', or `min'.")
1048 (defvar gnus-options-subscribe nil
1049 "*All new groups matching this regexp will be subscribed unconditionally.
1050 Note that this variable deals only with new newsgroups. This variable
1051 does not affect old newsgroups.")
1053 (defvar gnus-options-not-subscribe nil
1054 "*All new groups matching this regexp will be ignored.
1055 Note that this variable deals only with new newsgroups. This variable
1056 does not affect old (already subscribed) newsgroups.")
1058 (defvar gnus-auto-expirable-newsgroups nil
1059 "*Groups in which to automatically mark read articles as expirable.
1060 If non-nil, this should be a regexp that should match all groups in
1061 which to perform auto-expiry. This only makes sense for mail groups.")
1063 (defvar gnus-hidden-properties '(invisible t intangible t)
1064 "Property list to use for hiding text.")
1068 (defvar gnus-group-mode-hook nil
1069 "*A hook for Gnus group mode.")
1071 (defvar gnus-summary-mode-hook nil
1072 "*A hook for Gnus summary mode.
1073 This hook is run before any variables are set in the summary buffer.")
1075 (defvar gnus-article-mode-hook nil
1076 "*A hook for Gnus article mode.")
1078 (defun gnus-summary-exit-hook nil
1079 "*A hook called on exit from the summary buffer.
1080 It calls `gnus-summary-expire-articles' by default.")
1081 (add-hook 'gnus-summary-exit-hook 'gnus-summary-expire-articles)
1083 (defvar gnus-open-server-hook nil
1084 "*A hook called just before opening connection to the news server.")
1086 (defvar gnus-startup-hook nil
1087 "*A hook called at startup.
1088 This hook is called after Gnus is connected to the NNTP server.")
1090 (defvar gnus-get-new-news-hook nil
1091 "*A hook run just before Gnus checks for new news.")
1093 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1094 "*A function that is called to generate the group buffer.
1095 The function is called with three arguments: The first is a number;
1096 all group with a level less or equal to that number should be listed,
1097 if the second is non-nil, empty groups should also be displayed. If
1098 the third is non-nil, it is a number. No groups with a level lower
1099 than this number should be displayed.
1101 The only current function implemented is `gnus-group-prepare-flat'.")
1103 (defvar gnus-group-prepare-hook nil
1104 "*A hook called after the group buffer has been generated.
1105 If you want to modify the group buffer, you can use this hook.")
1107 (defvar gnus-summary-prepare-hook nil
1108 "*A hook called after the summary buffer has been generated.
1109 If you want to modify the summary buffer, you can use this hook.")
1111 (defvar gnus-article-prepare-hook nil
1112 "*A hook called after an article has been prepared in the article buffer.
1113 If you want to run a special decoding program like nkf, use this hook.")
1115 (defvar gnus-article-display-hook nil
1116 "*A hook called after the article is displayed in the article buffer.
1117 The hook is designed to change the contents of the article
1118 buffer. Typical functions that this hook may contain are
1119 `gnus-article-hide-headers' (hide selected headers),
1120 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1121 `gnus-article-hide-signature' (hide signature) and
1122 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1123 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1124 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1126 (defvar gnus-article-x-face-command
1127 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1128 "String or function to be executed to display an X-Face header.
1129 If it is a string, the command will be executed in a sub-shell
1130 asynchronously. The compressed face will be piped to this command.")
1132 (defvar gnus-article-x-face-too-ugly nil
1133 "Regexp matching posters whose face shouldn't be shown automatically.")
1135 (defvar gnus-select-group-hook nil
1136 "*A hook called when a newsgroup is selected.
1138 If you'd like to simplify subjects like the
1139 `gnus-summary-next-same-subject' command does, you can use the
1142 (setq gnus-select-group-hook
1145 (mapcar (lambda (header)
1148 (gnus-simplify-subject
1149 (header-subject header) 're-only)))
1150 gnus-newsgroup-headers))))")
1152 (defvar gnus-select-article-hook
1153 '(gnus-summary-show-thread)
1154 "*A hook called when an article is selected.
1155 The default hook shows conversation thread subtrees of the selected
1156 article automatically using `gnus-summary-show-thread'.")
1158 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1159 "*A hook called to apply kill files to a group.
1160 This hook is intended to apply a kill file to the selected newsgroup.
1161 The function `gnus-apply-kill-file' is called by default.
1163 Since a general kill file is too heavy to use only for a few
1164 newsgroups, I recommend you to use a lighter hook function. For
1165 example, if you'd like to apply a kill file to articles which contains
1166 a string `rmgroup' in subject in newsgroup `control', you can use the
1169 \(setq gnus-apply-kill-hook
1172 (cond ((string-match \"control\" gnus-newsgroup-name)
1173 (gnus-kill \"Subject\" \"rmgroup\")
1174 (gnus-expunge \"X\"))))))")
1176 (defvar gnus-visual-mark-article-hook
1177 (list 'gnus-highlight-selected-summary)
1178 "*Hook run after selecting an article in the summary buffer.
1179 It is meant to be used for highlighting the article in some way. It
1180 is not run if `gnus-visual' is nil.")
1182 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1183 "*A hook called after preparing body, but before preparing header headers.
1184 The default hook (`gnus-inews-insert-signature') inserts a signature
1185 file specified by the variable `gnus-signature-file'.")
1187 (defvar gnus-exit-group-hook nil
1188 "*A hook called when exiting (not quitting) summary mode.")
1190 (defvar gnus-suspend-gnus-hook nil
1191 "*A hook called when suspending (not exiting) Gnus.")
1193 (defvar gnus-exit-gnus-hook nil
1194 "*A hook called when exiting Gnus.")
1196 (defvar gnus-save-newsrc-hook nil
1197 "*A hook called when saving the newsrc file.")
1199 (defvar gnus-summary-update-hook
1200 (list 'gnus-summary-highlight-line)
1201 "*A hook called when a summary line is changed.
1202 The hook will not be called if `gnus-visual' is nil.
1204 The default function `gnus-summary-highlight-line' will
1205 highlight the line according to the `gnus-summary-highlight'
1208 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1209 "*A hook called when an article is selected for the first time.
1210 The hook is intended to mark an article as read (or unread)
1211 automatically when it is selected.")
1213 ;; Remove any hilit infestation.
1214 (add-hook 'gnus-startup-hook
1216 (remove-hook 'gnus-summary-prepare-hook
1217 'hilit-rehighlight-buffer-quietly)
1218 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1219 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1220 (remove-hook 'gnus-article-prepare-hook
1221 'hilit-rehighlight-buffer-quietly)))
1225 ;; Internal variables
1227 ;; Avoid highlighting in kill files.
1228 (defvar gnus-summary-inhibit-highlight nil)
1229 (defvar gnus-newsgroup-selected-overlay nil)
1231 (defvar gnus-article-mode-map nil)
1232 (defvar gnus-dribble-buffer nil)
1233 (defvar gnus-headers-retrieved-by nil)
1234 (defvar gnus-article-reply nil)
1235 (defvar gnus-override-method nil)
1236 (defvar gnus-article-check-size nil)
1238 (defvar gnus-current-score-file nil)
1239 (defvar gnus-internal-global-score-files nil)
1240 (defvar gnus-score-file-list nil)
1243 (defvar gnus-current-move-group nil)
1245 (defvar gnus-newsgroup-dependencies nil)
1246 (defvar gnus-newsgroup-threads nil)
1247 (defvar gnus-newsgroup-async nil)
1248 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1250 (defvar gnus-newsgroup-adaptive nil)
1252 (defvar gnus-summary-display-table nil)
1254 (defconst gnus-group-line-format-alist
1255 (list (list ?M 'marked ?c)
1256 (list ?S 'subscribed ?c)
1258 (list ?N 'number ?s)
1259 (list ?I 'number-of-dormant ?d)
1260 (list ?T 'number-of-ticked ?d)
1261 (list ?R 'number-of-read ?s)
1262 (list ?t 'number-total ?d)
1263 (list ?y 'number-of-unread-unticked ?s)
1264 (list ?i 'number-of-ticked-and-dormant ?d)
1266 (list ?G 'qualified-group ?s)
1267 (list ?D 'newsgroup-description ?s)
1268 (list ?o 'moderated ?c)
1269 (list ?O 'moderated-string ?s)
1270 (list ?p 'process-marked ?c)
1271 (list ?s 'news-server ?s)
1272 (list ?n 'news-method ?s)
1273 (list ?z 'news-method-string ?s)
1274 (list ?u 'user-defined ?s)))
1276 (defconst gnus-summary-line-format-alist
1277 (list (list ?N 'number ?d)
1278 (list ?S 'subject ?s)
1279 (list ?s 'subject-or-nil ?s)
1281 (list ?A 'address ?s)
1283 (list ?x (macroexpand '(header-xref header)) ?s)
1284 (list ?D (macroexpand '(header-date header)) ?s)
1285 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1286 (list ?M (macroexpand '(header-id header)) ?s)
1287 (list ?r (macroexpand '(header-references header)) ?s)
1288 (list ?c '(or (header-chars header) 0) ?d)
1290 (list ?I 'indentation ?s)
1291 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1292 (list ?R 'replied ?c)
1293 (list ?\[ 'opening-bracket ?c)
1294 (list ?\] 'closing-bracket ?c)
1295 (list ?\> '(make-string level ? ) ?s)
1296 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1298 (list ?z 'score-char ?c)
1299 (list ?U 'unread ?c)
1300 (list ?t '(gnus-summary-number-of-articles-in-thread
1301 (or (prog1 gnus-tmp-adopt-thread
1302 (setq gnus-tmp-adopt-thread nil))
1303 (if (boundp 'thread) (symbol-value 'thread)
1306 (list ?e '(gnus-summary-number-of-articles-in-thread
1307 (or gnus-tmp-adopt-thread
1308 (if (boundp 'thread) (symbol-value 'thread)
1311 (list ?u 'user-defined ?s))
1312 "An alist of format specifications that can appear in summary lines,
1313 and what variables they correspond with, along with the type of the
1314 variable (string, integer, character, etc).")
1316 (defconst gnus-summary-dummy-line-format-alist
1317 (list (list ?S 'subject ?s)
1318 (list ?N 'number ?d)
1319 (list ?u 'user-defined ?s)))
1321 (defconst gnus-summary-mode-line-format-alist
1322 (list (list ?G 'group-name ?s)
1323 (list ?g '(gnus-short-group-name group-name) ?s)
1324 (list ?A 'article-number ?d)
1325 (list ?Z 'unread-and-unselected ?s)
1326 (list ?V 'gnus-version ?s)
1327 (list ?U 'unread ?d)
1328 (list ?S 'subject ?s)
1329 (list ?e 'unselected ?d)
1330 (list ?u 'user-defined ?s)
1331 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1333 (defconst gnus-group-mode-line-format-alist
1334 (list (list ?S 'news-server ?s)
1335 (list ?M 'news-method ?s)
1336 (list ?u 'user-defined ?s)))
1338 (defvar gnus-have-read-active-file nil)
1340 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1341 "The mail address of the Gnus maintainers.")
1343 (defconst gnus-version "(ding) Gnus v0.96"
1344 "Version number for this version of Gnus.")
1346 (defvar gnus-info-nodes
1347 '((gnus-group-mode "(gnus)The Group Buffer")
1348 (gnus-summary-mode "(gnus)The Summary Buffer")
1349 (gnus-article-mode "(gnus)The Article Buffer"))
1350 "Assoc list of major modes and related Info nodes.")
1352 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1353 "The location of the (ding) Gnus documentation group.")
1355 (defvar gnus-group-buffer "*Group*")
1356 (defvar gnus-summary-buffer "*Summary*")
1357 (defvar gnus-article-buffer "*Article*")
1358 (defvar gnus-server-buffer "*Server*")
1360 (defvar gnus-work-buffer " *gnus work*")
1362 (defvar gnus-buffer-list nil
1363 "Gnus buffers that should be killed on exit.")
1365 (defvar gnus-server-alist nil
1366 "List of available servers.")
1368 (defvar gnus-variable-list
1369 '(gnus-newsrc-options gnus-newsrc-options-n
1370 gnus-newsrc-last-checked-date
1371 gnus-newsrc-alist gnus-server-alist
1372 gnus-killed-list gnus-zombie-list)
1373 "Gnus variables saved in the quick startup file.")
1375 (defvar gnus-overload-functions
1376 '((news-inews gnus-inews-news "rnewspost"))
1377 "Functions overloaded by gnus.
1378 It is a list of `(original overload &optional file)'.")
1380 (defvar gnus-newsrc-options nil
1381 "Options line in the .newsrc file.")
1383 (defvar gnus-newsrc-options-n nil
1384 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1386 (defvar gnus-newsrc-last-checked-date nil
1387 "Date Gnus last asked server for new newsgroups.")
1389 (defvar gnus-newsrc-alist nil
1390 "Assoc list of read articles.
1391 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1393 (defvar gnus-newsrc-hashtb nil
1394 "Hashtable of gnus-newsrc-alist.")
1396 (defvar gnus-killed-list nil
1397 "List of killed newsgroups.")
1399 (defvar gnus-killed-hashtb nil
1400 "Hash table equivalent of gnus-killed-list.")
1402 (defvar gnus-zombie-list nil
1403 "List of almost dead newsgroups.")
1405 (defvar gnus-description-hashtb nil
1406 "Descriptions of newsgroups.")
1408 (defvar gnus-list-of-killed-groups nil
1409 "List of newsgroups that have recently been killed by the user.")
1411 (defvar gnus-active-hashtb nil
1412 "Hashtable of active articles.")
1414 (defvar gnus-moderated-list nil
1415 "List of moderated newsgroups.")
1417 (defvar gnus-group-marked nil)
1419 (defvar gnus-current-startup-file nil
1420 "Startup file for the current host.")
1422 (defvar gnus-last-search-regexp nil
1423 "Default regexp for article search command.")
1425 (defvar gnus-last-shell-command nil
1426 "Default shell command on article.")
1428 (defvar gnus-current-select-method nil
1429 "The current method for selecting a newsgroup.")
1431 (defvar gnus-have-all-newsgroups nil)
1433 (defvar gnus-article-internal-prepare-hook nil)
1435 (defvar gnus-newsgroup-name nil)
1436 (defvar gnus-newsgroup-begin nil)
1437 (defvar gnus-newsgroup-end nil)
1438 (defvar gnus-newsgroup-last-rmail nil)
1439 (defvar gnus-newsgroup-last-mail nil)
1440 (defvar gnus-newsgroup-last-folder nil)
1441 (defvar gnus-newsgroup-last-file nil)
1442 (defvar gnus-newsgroup-auto-expire nil)
1443 (defvar gnus-newsgroup-active nil)
1445 (defvar gnus-newsgroup-unreads nil
1446 "List of unread articles in the current newsgroup.")
1448 (defvar gnus-newsgroup-unselected nil
1449 "List of unselected unread articles in the current newsgroup.")
1451 (defvar gnus-newsgroup-marked nil
1452 "List of ticked articles in the current newsgroup (a subset of unread art).")
1454 (defvar gnus-newsgroup-killed nil
1455 "List of ranges of articles that have been through the scoring process.")
1457 (defvar gnus-newsgroup-kill-headers nil)
1459 (defvar gnus-newsgroup-replied nil
1460 "List of articles that have been replied to in the current newsgroup.")
1462 (defvar gnus-newsgroup-expirable nil
1463 "List of articles in the current newsgroup that can be expired.")
1465 (defvar gnus-newsgroup-processable nil
1466 "List of articles in the current newsgroup that can be processed.")
1468 (defvar gnus-newsgroup-bookmarks nil
1469 "List of articles in the current newsgroup that have bookmarks.")
1471 (defvar gnus-newsgroup-dormant nil
1472 "List of dormant articles in the current newsgroup.")
1474 (defvar gnus-newsgroup-scored nil
1475 "List of scored articles in the current newsgroup.")
1477 (defvar gnus-newsgroup-headers nil
1478 "List of article headers in the current newsgroup.")
1479 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1481 (defvar gnus-newsgroup-ancient nil
1482 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1484 (defvar gnus-current-article nil)
1485 (defvar gnus-article-current nil)
1486 (defvar gnus-current-headers nil)
1487 (defvar gnus-have-all-headers nil)
1488 (defvar gnus-last-article nil)
1489 (defvar gnus-newsgroup-history nil)
1490 (defvar gnus-current-kill-article nil)
1492 ;; Save window configuration.
1493 (defvar gnus-prev-winconf nil)
1496 (defvar gnus-summary-line-format-spec nil)
1497 (defvar gnus-summary-dummy-line-format-spec nil)
1498 (defvar gnus-group-line-format-spec nil)
1499 (defvar gnus-summary-mode-line-format-spec nil)
1500 (defvar gnus-article-mode-line-format-spec nil)
1501 (defvar gnus-group-mode-line-format-spec nil)
1502 (defvar gnus-summary-mark-positions nil)
1504 (defvar gnus-summary-expunge-below nil)
1505 (defvar gnus-reffed-article-number nil)
1507 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1508 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1510 (defvar gnus-cache-removeable-articles nil)
1512 (defconst gnus-summary-local-variables
1513 '(gnus-newsgroup-name
1514 gnus-newsgroup-begin gnus-newsgroup-end
1515 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1516 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1517 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1518 gnus-newsgroup-unselected gnus-newsgroup-marked
1519 gnus-newsgroup-replied gnus-newsgroup-expirable
1520 gnus-newsgroup-processable gnus-newsgroup-killed
1521 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1522 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1523 gnus-current-article gnus-current-headers gnus-have-all-headers
1524 gnus-last-article gnus-article-internal-prepare-hook
1525 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1526 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1527 gnus-newsgroup-threads gnus-newsgroup-async
1528 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1529 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1530 gnus-newsgroup-history gnus-newsgroup-ancient
1531 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1532 gnus-cache-removeable-articles)
1533 "Variables that are buffer-local to the summary buffers.")
1535 (defconst gnus-bug-message
1536 "Sending a bug report to the Gnus Towers.
1537 ========================================
1539 The buffer below is a mail buffer. When you press `C-c C-c', it will
1540 be sent to the Gnus Bug Exterminators.
1542 At the bottom of the buffer you'll see lots of variable settings.
1543 Please do not delete those. They will tell the Bug People what your
1544 environment is, so that it will be easier to locate the bugs.
1546 If you have found a bug that makes Emacs go \"beep\", set
1547 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1548 and include the backtrace in your bug report.
1550 Please describe the bug in annoying, painstaking detail.
1552 Thank you for your help in stamping out bugs.
1555 ;;; End of variables.
1557 ;; Define some autoload functions Gnus might use.
1561 (autoload 'metamail-buffer "metamail")
1562 (autoload 'Info-goto-node "info")
1563 (autoload 'hexl-hex-string-to-integer "hexl")
1565 (autoload 'pp-to-string "pp")
1566 (autoload 'pp-eval-expression "pp")
1567 (autoload 'mail-extract-address-components "mail-extr")
1569 (autoload 'nnmail-split-fancy "nnmail")
1570 (autoload 'nnvirtual-catchup-group "nnvirtual")
1573 (autoload 'timezone-make-date-arpa-standard "timezone")
1574 (autoload 'timezone-fix-time "timezone")
1575 (autoload 'timezone-make-sortable-date "timezone")
1576 (autoload 'timezone-make-time-string "timezone")
1579 (autoload 'mail-position-on-field "sendmail")
1580 (autoload 'mail-setup "sendmail")
1581 (autoload 'rmail-output "rmailout")
1582 (autoload 'news-mail-other-window "rnewspost")
1583 (autoload 'news-reply-yank-original "rnewspost")
1584 (autoload 'news-caesar-buffer-body "rnewspost")
1585 (autoload 'rmail-insert-rmail-file-header "rmail")
1586 (autoload 'rmail-count-new-messages "rmail")
1587 (autoload 'rmail-show-message "rmail")
1590 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1591 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1592 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1593 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1594 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1595 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1596 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1599 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1600 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1601 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1602 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1603 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1604 (autoload 'gnus-Folder-save-name "gnus-mh")
1605 (autoload 'gnus-folder-save-name "gnus-mh")
1608 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1609 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1610 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1611 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1612 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1613 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1614 (autoload 'gnus-summary-highlight-line "gnus-vis")
1615 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1618 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1619 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1620 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1621 (autoload 'gnus-article-hide "gnus-vis" nil t)
1622 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1623 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1624 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1625 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1626 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1627 (autoload 'gnus-article-add-button "gnus-vis")
1630 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1631 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1632 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1635 (autoload 'gnus-kill "gnus-kill")
1636 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1637 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1638 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1639 (autoload 'gnus-execute "gnus-kill")
1640 (autoload 'gnus-expunge "gnus-kill")
1643 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1644 (autoload 'gnus-cache-save-buffers "gnus-cache")
1645 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1646 (autoload 'gnus-cache-request-article "gnus-cache")
1647 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1648 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1649 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1650 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1653 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1654 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1655 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1656 (autoload 'gnus-score-save "gnus-score")
1657 (autoload 'gnus-score-headers "gnus-score")
1658 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1659 (autoload 'gnus-score-adaptive "gnus-score")
1660 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1661 (autoload 'gnus-score-find-trace "gnus-score")
1664 (autoload 'gnus-score-customize "gnus-edit" nil t)
1667 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1668 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1669 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1670 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1671 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1672 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1673 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1674 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1675 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1676 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1677 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1678 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1679 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1680 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1681 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1682 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1683 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1684 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1685 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1686 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1687 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1688 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1691 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1692 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1693 (autoload 'gnus-group-mail "gnus-msg" nil t)
1694 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1695 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1696 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1697 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1698 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1699 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1700 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1701 (autoload 'gnus-post-news "gnus-msg" nil t)
1702 (autoload 'gnus-inews-news "gnus-msg" nil t)
1703 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1704 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1705 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1706 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1707 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1708 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1709 (autoload 'gnus-mail-yank-original "gnus-msg")
1710 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1711 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1712 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1713 (autoload 'gnus-article-mail-with-original "gnus-msg")
1714 (autoload 'gnus-article-mail "gnus-msg")
1715 (autoload 'gnus-bug "gnus-msg" nil t)
1718 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1719 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1720 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1721 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1722 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1723 (autoload 'gnus-yank-article "gnus-vm" nil t)
1729 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1730 ;; If you want the cursor to go somewhere else, set these two
1731 ;; functions in some startup hook to whatever you want.
1732 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1733 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1735 ;;; Various macros and substs.
1737 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1738 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1739 (` (let ((GnusStartBufferWindow (selected-window)))
1742 (pop-to-buffer (, buffer))
1744 (select-window GnusStartBufferWindow)))))
1746 (defmacro gnus-gethash (string hashtable)
1747 "Get hash value of STRING in HASHTABLE."
1748 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1749 ;;(` (abbrev-expansion (, string) (, hashtable)))
1750 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1752 (defmacro gnus-sethash (string value hashtable)
1753 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1754 ;; We cannot use define-abbrev since it only accepts string as value.
1755 ;; (set (intern string hashtable) value))
1756 (` (set (intern (, string) (, hashtable)) (, value))))
1758 (defsubst gnus-buffer-substring (beg end)
1759 (buffer-substring (match-beginning beg) (match-end end)))
1761 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1762 ;; function `substring' might cut on a middle of multi-octet
1765 (defun gnus-truncate-string (str width)
1766 (substring str 0 width))
1768 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1769 ;; to limit the length of a string. This function is necessary since
1770 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1771 (defsubst gnus-limit-string (str width)
1772 (if (> (length str) width)
1773 (substring str 0 width)
1776 (defsubst gnus-simplify-subject-re (subject)
1777 "Remove \"Re:\" from subject lines."
1778 (let ((case-fold-search t))
1779 (if (string-match "^re: *" subject)
1780 (substring subject (match-end 0))
1783 (defsubst gnus-goto-char (point)
1784 (and point (goto-char point)))
1786 (defmacro gnus-buffer-exists-p (buffer)
1788 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1791 (defmacro gnus-kill-buffer (buffer)
1792 (` (if (gnus-buffer-exists-p (, buffer))
1793 (kill-buffer (, buffer)))))
1795 (defsubst gnus-point-at-bol ()
1796 "Return point at the beginning of line."
1803 (defsubst gnus-point-at-eol ()
1804 "Return point at the beginning of line."
1811 ;; Delete the current line (and the next N lines.);
1812 (defmacro gnus-delete-line (&optional n)
1813 (` (delete-region (progn (beginning-of-line) (point))
1814 (progn (forward-line (, (or n 1))) (point)))))
1816 ;;; Load the compatability functions.
1822 ;;; Gnus Utility Functions
1825 (defun gnus-extract-address-components (from)
1827 ;; First find the address - the thing with the @ in it. This may
1828 ;; not be accurate in mail addresses, but does the trick most of
1829 ;; the time in news messages.
1830 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1831 (setq address (substring from (match-beginning 0) (match-end 0))))
1832 ;; Then we check whether the "name <address>" format is used.
1834 (string-match (concat "<" (regexp-quote address) ">") from)
1835 (and (setq name (substring from 0 (1- (match-beginning 0))))
1836 ;; Strip any quotes from the name.
1837 (string-match "\".*\"" name)
1838 (setq name (substring name 1 (1- (match-end 0))))))
1839 ;; If not, then "address (name)" is used.
1841 (and (string-match "(.+)" from)
1842 (setq name (substring from (1+ (match-beginning 0))
1843 (1- (match-end 0)))))
1844 (and (string-match "()" from)
1845 (setq name address))
1846 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1847 ;; XOVER might not support folded From headers.
1848 (and (string-match "(.*" from)
1849 (setq name (substring from (1+ (match-beginning 0))
1851 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1852 (list (or name from) (or address from))))
1854 (defun gnus-fetch-field (field)
1855 "Return the value of the header FIELD of current article."
1858 (let ((case-fold-search t))
1859 (gnus-narrow-to-headers)
1860 (mail-fetch-field field)))))
1862 (defun gnus-goto-colon ()
1864 (search-forward ":" (gnus-point-at-eol) t))
1866 (defun gnus-narrow-to-headers ()
1870 (goto-char (point-min))
1871 (if (search-forward "\n\n" nil t)
1875 (defun gnus-update-format-specifications ()
1876 (gnus-make-thread-indent-array)
1877 (setq gnus-summary-line-format-spec
1879 gnus-summary-line-format gnus-summary-line-format-alist))
1880 (gnus-update-summary-mark-positions)
1881 (setq gnus-summary-dummy-line-format-spec
1882 (gnus-parse-format gnus-summary-dummy-line-format
1883 gnus-summary-dummy-line-format-alist))
1884 (setq gnus-group-line-format-spec
1886 gnus-group-line-format
1887 gnus-group-line-format-alist))
1888 (if (and (string-match "%D" gnus-group-line-format)
1889 (not gnus-description-hashtb)
1890 gnus-read-active-file)
1891 (gnus-read-all-descriptions-files))
1892 (setq gnus-summary-mode-line-format-spec
1893 (gnus-parse-format gnus-summary-mode-line-format
1894 gnus-summary-mode-line-format-alist))
1895 (setq gnus-article-mode-line-format-spec
1896 (gnus-parse-format gnus-article-mode-line-format
1897 gnus-summary-mode-line-format-alist))
1898 (setq gnus-group-mode-line-format-spec
1899 (gnus-parse-format gnus-group-mode-line-format
1900 gnus-group-mode-line-format-alist)))
1902 (defun gnus-update-summary-mark-positions ()
1904 (let ((gnus-replied-mark 129)
1905 (gnus-score-below-mark 130)
1906 (gnus-score-over-mark 130)
1909 (gnus-set-work-buffer)
1910 (gnus-summary-insert-line
1911 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1912 (goto-char (point-min))
1913 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1915 (goto-char (point-min))
1916 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1917 (- (point) 2))) pos))
1918 (goto-char (point-min))
1919 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1920 (- (point) 2))) pos))
1921 (setq gnus-summary-mark-positions pos))))
1923 (defun gnus-format-max-width (form length)
1924 (let* ((val (eval form))
1925 (valstr (if (numberp val) (int-to-string val) val)))
1926 (gnus-limit-string valstr length)))
1928 (defun gnus-set-mouse-face (string)
1929 ;; Set mouse face property on STRING.
1930 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1933 (defun gnus-parse-format (format spec-alist)
1934 ;; This function parses the FORMAT string with the help of the
1935 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1936 ;; string. If the FORMAT string contains the specifiers %( and %)
1937 ;; the text between them will have the mouse-face text property.
1938 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1939 (if (and gnus-visual gnus-mouse-face)
1940 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1941 (button (substring format (match-beginning 2) (match-end 2)))
1942 (post (substring format (match-beginning 3) (match-end 3))))
1944 (gnus-parse-simple-format pre spec-alist)
1945 (list 'gnus-set-mouse-face
1946 (gnus-parse-simple-format button spec-alist))
1947 (gnus-parse-simple-format post spec-alist)))
1948 (gnus-parse-simple-format
1949 (concat (substring format (match-beginning 1) (match-end 1))
1950 (substring format (match-beginning 2) (match-end 2))
1951 (substring format (match-beginning 3) (match-end 3)))
1953 (gnus-parse-simple-format format spec-alist)))
1955 (defun gnus-parse-simple-format (format spec-alist)
1956 ;; This function parses the FORMAT string with the help of the
1957 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1958 ;; string. The list will consist of the symbol `format', a format
1959 ;; specification string, and a list of forms depending on the
1962 spec flist fstring newspec elem beg)
1964 (gnus-set-work-buffer)
1966 (goto-char (point-min))
1967 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1968 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1970 ;; First check if there are any specs that look anything like
1971 ;; "%12,12A", ie. with a "max width specification". These have
1972 ;; to be treated specially.
1973 (if (setq beg (match-beginning 1))
1976 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1978 (setq beg (match-beginning 2)))
1979 ;; Find the specification from `spec-alist'.
1980 (if (not (setq elem (cdr (assq spec spec-alist))))
1981 (setq elem '("*" ?s)))
1982 ;; Treat user defined format specifiers specially
1983 (and (eq (car elem) 'user-defined)
1986 (list (intern (concat "gnus-user-format-function-"
1992 (delete-region (match-beginning 3) (match-end 3)))
1993 (if (not (zerop max-width))
1994 (let ((el (car elem)))
1995 (cond ((= (car (cdr elem)) ?c)
1996 (setq el (list 'char-to-string el)))
1997 ((= (car (cdr elem)) ?d)
1998 (numberp el) (setq el (list 'int-to-string el))))
1999 (setq flist (cons (list 'gnus-format-max-width el max-width)
2002 (setq flist (cons (car elem) flist))
2003 (setq newspec (car (cdr elem))))
2004 ;; Remove the old specification (and possibly a ",12" string).
2005 (delete-region beg (match-end 2))
2006 ;; Insert the new specification.
2009 (setq fstring (buffer-substring 1 (point-max))))
2010 (cons 'format (cons fstring (nreverse flist)))))
2012 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2013 (defun gnus-read-init-file ()
2015 (or (and (file-exists-p gnus-init-file)
2016 ;; Don't try to load a directory.
2017 (not (file-directory-p gnus-init-file)))
2018 (file-exists-p (concat gnus-init-file ".el"))
2019 (file-exists-p (concat gnus-init-file ".elc")))
2020 (load gnus-init-file nil t)))
2022 (defun gnus-set-work-buffer ()
2023 (if (get-buffer gnus-work-buffer)
2025 (set-buffer gnus-work-buffer)
2027 (set-buffer (get-buffer-create gnus-work-buffer))
2028 (kill-all-local-variables)
2029 (buffer-disable-undo (current-buffer))
2030 (gnus-add-current-to-buffer-list)))
2032 ;; Article file names when saving.
2034 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2035 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2036 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2037 Otherwise, it is like ~/News/news/group/num."
2040 (concat (if (gnus-use-long-file-name 'not-save)
2041 (gnus-capitalize-newsgroup newsgroup)
2042 (gnus-newsgroup-directory-form newsgroup))
2043 "/" (int-to-string (header-number headers)))
2044 (or gnus-article-save-directory "~/News"))))
2046 (string-equal (file-name-directory default)
2047 (file-name-directory last-file))
2048 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2050 (or last-file default))))
2052 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2053 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2054 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2055 Otherwise, it is like ~/News/news/group/num."
2058 (concat (if (gnus-use-long-file-name 'not-save)
2060 (gnus-newsgroup-directory-form newsgroup))
2061 "/" (int-to-string (header-number headers)))
2062 (or gnus-article-save-directory "~/News"))))
2064 (string-equal (file-name-directory default)
2065 (file-name-directory last-file))
2066 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2068 (or last-file default))))
2070 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2071 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2072 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2073 Otherwise, it is like ~/News/news/group/news."
2076 (if (gnus-use-long-file-name 'not-save)
2077 (gnus-capitalize-newsgroup newsgroup)
2078 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2079 (or gnus-article-save-directory "~/News"))))
2081 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2082 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2083 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
2084 Otherwise, it is like ~/News/news/group/news."
2087 (if (gnus-use-long-file-name 'not-save)
2089 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2090 (or gnus-article-save-directory "~/News"))))
2092 ;; For subscribing new newsgroup
2094 (defun gnus-subscribe-hierarchical-interactive (groups)
2095 (let ((groups (sort groups 'string<))
2096 prefixes prefix start ans group starts)
2098 (setq prefixes (list "^"))
2099 (while (and groups prefixes)
2100 (while (not (string-match (car prefixes) (car groups)))
2101 (setq prefixes (cdr prefixes)))
2102 (setq prefix (car prefixes))
2103 (setq start (1- (length prefix)))
2104 (if (and (string-match "[^\\.]\\." (car groups) start)
2107 (concat "^" (substring (car groups) 0 (match-end 0))))
2108 (string-match prefix (car (cdr groups))))
2110 (setq prefixes (cons prefix prefixes))
2111 (message "Descend hierarchy %s? ([y]nsq): "
2112 (substring prefix 1 (1- (length prefix))))
2113 (setq ans (read-char))
2116 (string-match prefix
2117 (setq group (car groups))))
2118 (setq gnus-killed-list
2119 (cons group gnus-killed-list))
2120 (gnus-sethash group group gnus-killed-hashtb)
2121 (setq groups (cdr groups)))
2122 (setq starts (cdr starts)))
2125 (string-match prefix
2126 (setq group (car groups))))
2127 (gnus-sethash group group gnus-killed-hashtb)
2128 (gnus-subscribe-alphabetically (car groups))
2129 (setq groups (cdr groups)))
2130 (setq starts (cdr starts)))
2133 (setq group (car groups))
2134 (setq gnus-killed-list (cons group gnus-killed-list))
2135 (gnus-sethash group group gnus-killed-hashtb)
2136 (setq groups (cdr groups))))
2138 (message "Subscribe %s? ([n]yq)" (car groups))
2139 (setq ans (read-char))
2140 (setq group (car groups))
2142 (gnus-subscribe-alphabetically (car groups))
2143 (gnus-sethash group group gnus-killed-hashtb))
2146 (setq group (car groups))
2147 (setq gnus-killed-list (cons group gnus-killed-list))
2148 (gnus-sethash group group gnus-killed-hashtb)
2149 (setq groups (cdr groups))))
2151 (setq gnus-killed-list (cons group gnus-killed-list))
2152 (gnus-sethash group group gnus-killed-hashtb)))
2153 (setq groups (cdr groups)))))))
2155 (defun gnus-subscribe-randomly (newsgroup)
2156 "Subscribe new NEWSGROUP by making it the first newsgroup."
2157 (gnus-subscribe-newsgroup newsgroup))
2159 (defun gnus-subscribe-alphabetically (newgroup)
2160 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2161 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2162 (let ((groups (cdr gnus-newsrc-alist))
2164 (while (and (not before) groups)
2165 (if (string< newgroup (car (car groups)))
2166 (setq before (car (car groups)))
2167 (setq groups (cdr groups))))
2168 (gnus-subscribe-newsgroup newgroup before)))
2170 (defun gnus-subscribe-hierarchically (newgroup)
2171 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2172 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2174 (set-buffer (find-file-noselect gnus-current-startup-file))
2175 (let ((groupkey newgroup)
2177 (while (and (not before) groupkey)
2178 (goto-char (point-min))
2180 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2181 (while (and (re-search-forward groupkey-re nil t)
2183 (setq before (buffer-substring
2184 (match-beginning 1) (match-end 1)))
2185 (string< before newgroup)))))
2186 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2188 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2189 (substring groupkey (match-beginning 1) (match-end 1)))))
2190 (gnus-subscribe-newsgroup newgroup before))))
2192 (defun gnus-subscribe-interactively (newsgroup)
2193 "Subscribe new NEWSGROUP interactively.
2194 It is inserted in hierarchical newsgroup order if subscribed. If not,
2196 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2197 (gnus-subscribe-hierarchically newsgroup)
2198 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2200 (defun gnus-subscribe-zombies (newsgroup)
2201 "Make new NEWSGROUP a zombie group."
2202 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2204 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2205 "Subscribe new NEWSGROUP.
2206 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2207 the first newsgroup."
2208 ;; We subscribe the group by changing its level to `subscribed'.
2209 (gnus-group-change-level
2210 newsgroup gnus-level-default-subscribed
2211 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2212 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2216 (defun gnus-newsgroup-directory-form (newsgroup)
2217 "Make hierarchical directory name from NEWSGROUP name."
2218 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2219 (len (length newsgroup))
2221 ;; If this is a foreign group, we don't want to translate the
2223 (if (setq idx (string-match ":" newsgroup))
2224 (aset newsgroup idx ?/)
2226 ;; Replace all occurrences of `.' with `/'.
2228 (if (= (aref newsgroup idx) ?.)
2229 (aset newsgroup idx ?/))
2230 (setq idx (1+ idx)))
2233 (defun gnus-make-directory (dir)
2234 "Make DIRECTORY recursively."
2235 (let* ((dir (expand-file-name dir default-directory))
2237 (if (string-match "/$" dir)
2238 (setq dir (substring dir 0 (match-beginning 0))))
2239 (while (not (file-exists-p dir))
2240 (setq dirs (cons dir dirs))
2241 (string-match "/[^/]+$" dir)
2242 (setq dir (substring dir 0 (match-beginning 0))))
2244 (make-directory (car dirs))
2245 (setq dirs (cdr dirs)))))
2247 (defun gnus-capitalize-newsgroup (newsgroup)
2248 "Capitalize NEWSGROUP name."
2249 (and (not (zerop (length newsgroup)))
2250 (concat (char-to-string (upcase (aref newsgroup 0)))
2251 (substring newsgroup 1))))
2255 (defun gnus-simplify-subject (subject &optional re-only)
2256 "Remove `Re:' and words in parentheses.
2257 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2258 (let ((case-fold-search t)) ;Ignore case.
2259 ;; Remove `Re:' and `Re^N:'.
2260 (if (string-match "^re:[ \t]*" subject)
2261 (setq subject (substring subject (match-end 0))))
2262 ;; Remove words in parentheses from end.
2264 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2265 (setq subject (substring subject 0 (match-beginning 0)))))
2266 ;; Return subject string.
2269 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2271 (defun gnus-simplify-subject-fuzzy (subject)
2272 (let ((case-fold-search t))
2274 (gnus-set-work-buffer)
2276 (inline (gnus-simplify-buffer-fuzzy))
2279 (defun gnus-simplify-buffer-fuzzy ()
2280 (goto-char (point-min))
2281 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2282 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2284 (replace-match "" t t))
2285 (goto-char (point-min))
2286 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2287 (replace-match "" t t))
2288 (goto-char (point-min))
2289 (while (re-search-forward "[ \t]+" nil t)
2290 (replace-match " " t t))
2291 (goto-char (point-min))
2292 (while (re-search-forward "[ \t]+$" nil t)
2293 (replace-match "" t t))
2294 (goto-char (point-min))
2295 (while (re-search-forward "^[ \t]+" nil t)
2296 (replace-match "" t t))
2297 (if gnus-simplify-subject-fuzzy-regexp
2298 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2299 (replace-match "" t t)))
2302 ;; Add the current buffer to the list of buffers to be killed on exit.
2303 (defun gnus-add-current-to-buffer-list ()
2304 (or (memq (current-buffer) gnus-buffer-list)
2305 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2307 (defun gnus-string> (s1 s2)
2308 (not (or (string< s1 s2)
2311 ;; Functions accessing headers.
2312 ;; Functions are more convenient than macros in some cases.
2314 (defun gnus-header-number (header)
2315 (header-number header))
2317 (defun gnus-header-subject (header)
2318 (header-subject header))
2320 (defun gnus-header-from (header)
2321 (header-from header))
2323 (defun gnus-header-xref (header)
2324 (header-xref header))
2326 (defun gnus-header-lines (header)
2327 (header-lines header))
2329 (defun gnus-header-date (header)
2330 (header-date header))
2332 (defun gnus-header-id (header)
2335 (defun gnus-header-references (header)
2336 (header-references header))
2338 ;;; General various misc type functions.
2340 (defun gnus-clear-system ()
2341 "Clear all variables and buffers."
2342 ;; Clear Gnus variables.
2343 (let ((variables gnus-variable-list))
2345 (set (car variables) nil)
2346 (setq variables (cdr variables))))
2347 ;; Clear other internal variables.
2348 (setq gnus-list-of-killed-groups nil
2349 gnus-have-read-active-file nil
2350 gnus-newsrc-alist nil
2351 gnus-newsrc-hashtb nil
2352 gnus-killed-list nil
2353 gnus-zombie-list nil
2354 gnus-killed-hashtb nil
2355 gnus-active-hashtb nil
2356 gnus-moderated-list nil
2357 gnus-description-hashtb nil
2358 gnus-newsgroup-headers nil
2359 gnus-newsgroup-headers-hashtb-by-number nil
2360 gnus-newsgroup-name nil
2361 gnus-server-alist nil
2362 gnus-current-select-method nil)
2363 ;; Reset any score variables.
2364 (and (boundp 'gnus-score-cache)
2365 (set 'gnus-score-cache nil))
2366 (and (boundp 'gnus-internal-global-score-files)
2367 (set 'gnus-internal-global-score-files nil))
2368 ;; Kill the startup file.
2369 (and gnus-current-startup-file
2370 (get-file-buffer gnus-current-startup-file)
2371 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2372 ;; Save any cache buffers.
2373 (and gnus-use-cache (gnus-cache-save-buffers))
2374 ;; Clear the dribble buffer.
2375 (gnus-dribble-clear)
2376 ;; Kill global KILL file buffer.
2377 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2378 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2379 (gnus-kill-buffer nntp-server-buffer)
2380 ;; Kill Gnus buffers.
2381 (while gnus-buffer-list
2382 (gnus-kill-buffer (car gnus-buffer-list))
2383 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2385 (defun gnus-windows-old-to-new (setting)
2386 (if (symbolp setting)
2388 (cond ((eq setting 'SelectArticle)
2390 ((eq setting 'SelectSubject)
2392 ((eq setting 'SelectNewsgroup)
2395 (if (or (listp setting)
2396 (not (and gnus-window-configuration
2397 (memq setting '(group summary article)))))
2399 (let* ((setting (if (eq setting 'group)
2400 (if (assq 'newsgroup gnus-window-configuration)
2402 'newsgroups) setting))
2403 (elem (car (cdr (assq setting gnus-window-configuration))))
2404 (total (apply '+ elem))
2405 (types '(group summary article))
2406 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2411 (or (zerop (nth i elem))
2413 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2414 (setq out (cons (if (eq pbuf (nth i types))
2415 (vector (nth i types) perc 'point)
2416 (vector (nth i types) perc))
2419 (list (nreverse out)))))
2421 (defun gnus-add-configuration (conf)
2422 (setq gnus-buffer-configuration
2423 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2424 gnus-buffer-configuration))))
2426 (defun gnus-configure-windows (setting)
2427 (setq setting (gnus-windows-old-to-new setting))
2428 (let ((r (if (symbolp setting)
2429 (cdr (assq setting gnus-buffer-configuration))
2431 (in-buf (current-buffer))
2432 rule val w height hor ohor heights sub jump-buffer
2434 (or r (error "No such setting: %s" setting))
2436 ;; Either remove all windows or just remove all Gnus windows.
2437 (if gnus-use-full-window
2438 (delete-other-windows)
2439 (gnus-remove-some-windows)
2440 (switch-to-buffer nntp-server-buffer))
2446 ;; We have to do the (possible) horizontal splitting before the
2448 (if (and (listp (car hor))
2449 (eq (car (car hor)) 'horizontal))
2453 (if (integerp (nth 1 (car hor)))
2455 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2457 (setq hor (cdr hor))))
2459 ;; Go through the rules and eval the elements that are to be
2462 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2464 ;; Expand short buffer name.
2465 (setq w (aref val 0))
2466 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2468 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2470 (setq ohor (cons val ohor))))
2471 (setq hor (cdr hor)))
2472 (setq rule (cons (nreverse ohor) rule))
2474 (setq rule (nreverse rule))
2476 ;; We tally the window sizes.
2477 (setq total (window-height))
2479 (setq hor (car rule))
2480 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2481 (setq hor (cdr hor)))
2484 (setq rel (aref (car hor) 1)
2486 (cond ((and (floatp rel) (= 1.0 rel))
2491 (max (floor (* total rel)) 4)))
2493 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2495 (setq heights (nreverse heights)
2498 ;; We then go through these heighs and create windows for them.
2500 (setq height (car heights)
2501 heights (cdr heights))
2503 (setq height (- total sub)))
2505 (split-window nil height))
2506 (setq to-buf (aref (car hor) 0))
2511 (symbol-value (aref (car hor) 0)))
2513 (aref (car hor) 0))))
2514 (and (> (length (car hor)) 2)
2515 (eq (aref (car hor) 2) 'point)
2516 (setq jump-buffer (current-buffer)))
2518 (setq hor (cdr hor)))
2520 (setq rule (cdr rule)))
2522 ;; Finally, we pop to the buffer that's supposed to have point.
2523 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2525 (select-window (get-buffer-window jump-buffer))
2526 (set-buffer jump-buffer)))
2528 (defun gnus-remove-some-windows ()
2529 (let ((buffers gnus-window-to-buffer)
2533 ;; Remove windows on all known Gnus buffers.
2535 (setq buf (cdr (car buffers)))
2537 (setq buf (and (boundp buf) (symbol-value buf))))
2539 (get-buffer-window buf)
2544 (switch-to-buffer nntp-server-buffer)
2546 (delete-window (get-buffer-window buf)))))
2547 (setq buffers (cdr buffers)))
2548 ;; Remove windows on *all* summary buffers.
2549 (let ((buffers (buffer-list)))
2551 (if (and (string-match
2552 "^\\*Summary" (or (buffer-name (car buffers)) ""))
2553 (get-buffer-window (car buffers)))
2554 (delete-window (get-buffer-window (car buffers))))
2555 (setq buffers (cdr buffers)))))))
2557 (defun gnus-version ()
2558 "Version numbers of this version of Gnus."
2560 (let ((methods gnus-valid-select-methods)
2563 ;; Go through all the legal select methods and add their version
2564 ;; numbers to the total version string. Only the backends that are
2565 ;; currently in use will have their message numbers taken into
2568 (setq meth (intern (concat (car (car methods)) "-version")))
2570 (stringp (symbol-value meth))
2571 (setq mess (concat mess "; " (symbol-value meth))))
2572 (setq methods (cdr methods)))
2573 (gnus-message 2 mess)))
2575 (defun gnus-info-find-node ()
2576 "Find Info documentation of Gnus."
2578 ;; Enlarge info window if needed.
2579 (let ((mode major-mode))
2580 (gnus-configure-windows 'info)
2581 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2583 (defun gnus-overload-functions (&optional overloads)
2584 "Overload functions specified by optional argument OVERLOADS.
2585 If nothing is specified, use the variable gnus-overload-functions."
2587 (overloads (or overloads gnus-overload-functions)))
2589 (setq defs (car overloads))
2590 (setq overloads (cdr overloads))
2591 ;; Load file before overloading function if necessary. Make
2592 ;; sure we cannot use `require' always.
2593 (and (not (fboundp (car defs)))
2594 (car (cdr (cdr defs)))
2595 (load (car (cdr (cdr defs))) nil 'nomessage))
2596 (fset (car defs) (car (cdr defs))))))
2598 (defun gnus-replace-chars-in-string (string from to)
2599 "Replace characters in STRING from FROM to TO."
2600 (let ((string (substring string 0)) ;Copy string.
2601 (len (length string))
2603 ;; Replace all occurrences of FROM with TO.
2605 (if (= (aref string idx) from)
2606 (aset string idx to))
2607 (setq idx (1+ idx)))
2610 (defun gnus-days-between (date1 date2)
2611 ;; Return the number of days between date1 and date2.
2612 (- (gnus-day-number date1) (gnus-day-number date2)))
2614 (defun gnus-day-number (date)
2615 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2616 (timezone-parse-date date))))
2617 (timezone-absolute-from-gregorian
2618 (nth 1 dat) (nth 2 dat) (car dat))))
2620 ;; Returns a floating point number that says how many seconds have
2621 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2622 (defun gnus-seconds-since-epoch (date)
2623 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2624 (timezone-parse-date date)))
2625 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2626 (timezone-parse-time
2627 (aref (timezone-parse-date date) 3))))
2628 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2629 (timezone-parse-date "Jan 1 12:00:00 1970")))
2630 (tday (- (timezone-absolute-from-gregorian
2631 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2632 (timezone-absolute-from-gregorian
2633 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2635 (* (nth 1 ttime) 60)
2636 (* 1.0 (nth 0 ttime) 60 60)
2637 (* 1.0 tday 60 60 24))))
2639 (defun gnus-file-newer-than (file date)
2640 (let ((fdate (nth 5 (file-attributes file))))
2641 (or (> (car fdate) (car date))
2642 (and (= (car fdate) (car date))
2643 (> (nth 1 fdate) (nth 1 date))))))
2645 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2647 (defun gnus-y-or-n-p (prompt)
2652 (defun gnus-yes-or-no-p (prompt)
2654 (yes-or-no-p prompt)
2657 ;; Check whether to use long file names.
2658 (defun gnus-use-long-file-name (symbol)
2659 ;; The variable has to be set...
2660 (and gnus-use-long-file-name
2661 ;; If it isn't a list, then we return t.
2662 (or (not (listp gnus-use-long-file-name))
2663 ;; If it is a list, and the list contains `symbol', we
2665 (not (memq symbol gnus-use-long-file-name)))))
2667 ;; I suspect there's a better way, but I haven't taken the time to do
2668 ;; it yet. -erik selberg@cs.washington.edu
2669 (defun gnus-dd-mmm (messy-date)
2670 "Return a string like DD-MMM from a big messy string"
2671 (let ((datevec (timezone-parse-date messy-date)))
2673 (or (aref datevec 2) "??")
2676 (nth (1- (string-to-number (aref datevec 1)))
2677 timezone-months-assoc))
2680 ;; Make a hash table (default and minimum size is 255).
2681 ;; Optional argument HASHSIZE specifies the table size.
2682 (defun gnus-make-hashtable (&optional hashsize)
2683 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2685 ;; Make a number that is suitable for hashing; bigger than MIN and one
2687 (defun gnus-create-hash-size (min)
2693 ;; Show message if message has a lower level than `gnus-verbose'.
2694 ;; Guide-line for numbers:
2695 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2696 ;; for things that take a long time, 7 - not very important messages
2697 ;; on stuff, 9 - messages inside loops.
2698 (defun gnus-message (level &rest args)
2699 (if (<= level gnus-verbose)
2700 (apply 'message args)
2701 ;; We have to do this format thingie here even if the result isn't
2702 ;; shown - the return value has to be the same as the return value
2704 (apply 'format args)))
2706 ;; Generate a unique new group name.
2707 (defun gnus-generate-new-group-name (leaf)
2710 (while (gnus-gethash name gnus-newsrc-hashtb)
2711 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2714 (defun gnus-find-file-noselect (file &optional force)
2715 "Does vaguely the same as find-file-noselect. No hooks are run."
2717 (if (setq buf (get-file-buffer file))
2719 (setq buf (create-file-buffer file))
2726 (and (file-readable-p file)
2727 (insert-file-contents file))
2728 (set-visited-file-name file)
2729 (set-buffer-modified-p nil)
2730 (current-buffer)))))
2732 ;;; List and range functions
2734 (defun gnus-last-element (list)
2735 "Return last element of LIST."
2737 (setq list (cdr list)))
2740 (defun gnus-copy-sequence (list)
2741 "Do a complete, total copy of a list."
2742 (if (and (consp list) (not (consp (cdr list))))
2743 (cons (car list) (cdr list))
2744 (mapcar (lambda (elem) (if (consp elem)
2745 (if (consp (cdr elem))
2746 (gnus-copy-sequence elem)
2747 (cons (car elem) (cdr elem)))
2751 (defun gnus-set-difference (list1 list2)
2752 "Return a list of elements of LIST1 that do not appear in LIST2."
2753 (let ((list1 (copy-sequence list1)))
2755 (setq list1 (delq (car list2) list1))
2756 (setq list2 (cdr list2)))
2759 (defun gnus-sorted-complement (list1 list2)
2760 "Return a list of elements of LIST1 that do not appear in LIST2.
2761 Both lists have to be sorted over <."
2763 (if (or (null list1) (null list2))
2765 (while (and list1 list2)
2766 (cond ((= (car list1) (car list2))
2767 (setq list1 (cdr list1)
2769 ((< (car list1) (car list2))
2770 (setq out (cons (car list1) out))
2771 (setq list1 (cdr list1)))
2773 (setq out (cons (car list2) out))
2774 (setq list2 (cdr list2)))))
2775 (nconc (nreverse out) (or list1 list2)))))
2777 (defun gnus-intersection (list1 list2)
2780 (if (memq (car list2) list1)
2781 (setq result (cons (car list2) result)))
2782 (setq list2 (cdr list2)))
2785 (defun gnus-sorted-intersection (list1 list2)
2786 ;; LIST1 and LIST2 have to be sorted over <.
2788 (while (and list1 list2)
2789 (cond ((= (car list1) (car list2))
2790 (setq out (cons (car list1) out)
2793 ((< (car list1) (car list2))
2794 (setq list1 (cdr list1)))
2796 (setq list2 (cdr list2)))))
2799 (defun gnus-set-sorted-intersection (list1 list2)
2800 ;; LIST1 and LIST2 have to be sorted over <.
2801 ;; This function modifies LIST1.
2802 (let* ((top (cons nil list1))
2804 (while (and list1 list2)
2805 (cond ((= (car list1) (car list2))
2809 ((< (car list1) (car list2))
2810 (setcdr prev (cdr list1))
2811 (setq list1 (cdr list1)))
2813 (setq list2 (cdr list2)))))
2817 (defun gnus-compress-sequence (numbers &optional always-list)
2818 "Convert list of numbers to a list of ranges or a single range.
2819 If ALWAYS-LIST is non-nil, this function will always release a list of
2821 (let* ((first (car numbers))
2822 (last (car numbers))
2826 (if (not (listp (cdr numbers)))
2829 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2830 ((= (1+ last) (car numbers)) ;Still in sequence
2831 (setq last (car numbers)))
2832 (t ;End of one sequence
2834 (cons (if (= first last) first
2835 (cons first last)) result))
2836 (setq first (car numbers))
2837 (setq last (car numbers))))
2838 (setq numbers (cdr numbers)))
2839 (if (and (not always-list) (null result))
2840 (if (= first last) (list first) (cons first last))
2841 (nreverse (cons (if (= first last) first (cons first last))
2844 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2845 (defun gnus-uncompress-range (ranges)
2846 "Expand a list of ranges into a list of numbers.
2847 RANGES is either a single range on the form `(num . num)' or a list of
2849 (let (first last result)
2853 ((not (listp (cdr ranges)))
2854 (setq first (car ranges))
2855 (setq last (cdr ranges))
2856 (while (<= first last)
2857 (setq result (cons first result))
2858 (setq first (1+ first)))
2862 (if (atom (car ranges))
2863 (if (numberp (car ranges))
2864 (setq result (cons (car ranges) result)))
2865 (setq first (car (car ranges)))
2866 (setq last (cdr (car ranges)))
2867 (while (<= first last)
2868 (setq result (cons first result))
2869 (setq first (1+ first))))
2870 (setq ranges (cdr ranges)))
2871 (nreverse result)))))
2873 (defun gnus-add-to-range (ranges list)
2874 "Return a list of ranges that has all articles from both RANGES and LIST.
2875 Note: LIST has to be sorted over `<'."
2877 (gnus-compress-sequence list t)
2878 (setq list (copy-sequence list))
2879 (or (listp (cdr ranges))
2880 (setq ranges (list ranges)))
2882 ilist lowest highest temp)
2883 (while (and ranges list)
2885 (setq lowest (or (and (atom (car ranges)) (car ranges))
2886 (car (car ranges))))
2887 (while (and list (cdr list) (< (car (cdr list)) lowest))
2888 (setq list (cdr list)))
2889 (if (< (car ilist) lowest)
2892 (setq list (cdr list))
2894 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2895 (setq highest (or (and (atom (car ranges)) (car ranges))
2896 (cdr (car ranges))))
2897 (while (and list (<= (car list) highest))
2898 (setq list (cdr list)))
2899 (setq ranges (cdr ranges)))
2901 (setq out (nconc (gnus-compress-sequence list t) out)))
2902 (setq out (sort out (lambda (r1 r2)
2903 (< (or (and (atom r1) r1) (car r1))
2904 (or (and (atom r2) r2) (car r2))))))
2907 (if (atom (car ranges))
2909 (if (atom (car (cdr ranges)))
2910 (if (= (1+ (car ranges)) (car (cdr ranges)))
2912 (setcar ranges (cons (car ranges)
2913 (car (cdr ranges))))
2914 (setcdr ranges (cdr (cdr ranges)))))
2915 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2917 (setcar (car (cdr ranges)) (car ranges))
2918 (setcar ranges (car (cdr ranges)))
2919 (setcdr ranges (cdr (cdr ranges)))))))
2921 (if (atom (car (cdr ranges)))
2922 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2924 (setcdr (car ranges) (car (cdr ranges)))
2925 (setcdr ranges (cdr (cdr ranges)))))
2926 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2928 (setcdr (car ranges) (cdr (car (cdr ranges))))
2929 (setcdr ranges (cdr (cdr ranges))))))))
2930 (setq ranges (cdr ranges)))
2933 (defun gnus-remove-from-range (ranges list)
2934 "Return a list of ranges that has all articles from LIST removed from RANGES.
2935 Note: LIST has to be sorted over `<'."
2936 ;; !!! This function shouldn't look like this, but I've got a headache.
2937 (gnus-compress-sequence
2938 (gnus-sorted-complement
2939 (gnus-uncompress-range ranges) list)))
2941 (defun gnus-member-of-range (number ranges)
2942 (if (not (listp (cdr ranges)))
2943 (and (>= number (car ranges))
2944 (<= number (cdr ranges)))
2947 (if (numberp (car ranges))
2948 (>= number (car ranges))
2949 (>= number (car (car ranges))))
2951 (if (if (numberp (car ranges))
2952 (= number (car ranges))
2953 (and (>= number (car (car ranges)))
2954 (<= number (cdr (car ranges)))))
2955 (setq not-stop nil))
2956 (setq ranges (cdr ranges)))
2964 (defvar gnus-group-mode-map nil)
2965 (defvar gnus-group-group-map nil)
2966 (defvar gnus-group-mark-map nil)
2967 (defvar gnus-group-list-map nil)
2968 (defvar gnus-group-sub-map nil)
2969 (put 'gnus-group-mode 'mode-class 'special)
2971 (if gnus-group-mode-map
2973 (setq gnus-group-mode-map (make-keymap))
2974 (suppress-keymap gnus-group-mode-map)
2975 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2976 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2977 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2978 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2979 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2980 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2981 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2982 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2983 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2984 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2985 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2986 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2987 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2988 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2989 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2990 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2991 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2992 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2993 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2994 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2995 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2996 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2997 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2998 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2999 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3000 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3001 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3002 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3003 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3004 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3005 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3006 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3007 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3008 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3009 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3010 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3011 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3012 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3013 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3014 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3015 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3016 (define-key gnus-group-mode-map "V" 'gnus-version)
3017 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3018 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3019 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3020 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3021 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3022 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3023 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3024 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3025 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3026 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3027 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3028 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3029 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3030 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3031 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3033 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3034 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3035 (define-prefix-command 'gnus-group-mark-map)
3036 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3037 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3038 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3039 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3041 (define-prefix-command 'gnus-group-group-map)
3042 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3043 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3044 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3045 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3046 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3047 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3048 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3049 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3050 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3051 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3052 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3053 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3054 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3055 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3056 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3057 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3058 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3059 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3061 (define-prefix-command 'gnus-group-list-map)
3062 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3063 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3064 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3065 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3066 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3067 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3068 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3069 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3070 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3072 (define-prefix-command 'gnus-group-sub-map)
3073 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3074 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3075 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3076 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3077 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3078 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3079 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3080 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3082 (defun gnus-group-mode ()
3083 "Major mode for reading news.
3085 All normal editing commands are switched off.
3086 \\<gnus-group-mode-map>
3087 The group buffer lists (some of) the groups available. For instance,
3088 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3089 lists all zombie groups.
3091 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3092 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3094 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3096 The following commands are available:
3098 \\{gnus-group-mode-map}"
3100 (if gnus-visual (gnus-group-make-menu-bar))
3101 (kill-all-local-variables)
3102 (setq mode-line-modified "-- ")
3103 (make-local-variable 'mode-line-format)
3104 (setq mode-line-format (copy-sequence mode-line-format))
3105 (and (equal (nth 3 mode-line-format) " ")
3106 (setcar (nthcdr 3 mode-line-format) ""))
3107 (setq major-mode 'gnus-group-mode)
3108 (setq mode-name "Group")
3109 (gnus-group-set-mode-line)
3110 (setq mode-line-process nil)
3111 (use-local-map gnus-group-mode-map)
3112 (buffer-disable-undo (current-buffer))
3113 (setq truncate-lines t)
3114 (setq buffer-read-only t)
3115 (run-hooks 'gnus-group-mode-hook))
3117 (defun gnus-mouse-pick-group (e)
3120 (gnus-group-read-group nil))
3123 (defun gnus-no-server (&optional arg)
3125 If ARG is a positive number, Gnus will use that as the
3126 startup level. If ARG is nil, Gnus will be started at level 2.
3127 If ARG is non-nil and not a positive number, Gnus will
3128 prompt the user for the name of an NNTP server to use.
3129 As opposed to `gnus', this command will not connect to the local server."
3131 (setq gnus-group-use-permanent-levels t)
3132 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3134 (defalias '\(ding\) 'gnus)
3137 (defun gnus (&optional arg dont-connect)
3139 If ARG is non-nil and a positive number, Gnus will use that as the
3140 startup level. If ARG is non-nil and not a positive number, Gnus will
3141 prompt the user for the name of an NNTP server to use."
3143 (if (get-buffer gnus-group-buffer)
3145 (switch-to-buffer gnus-group-buffer)
3146 (gnus-group-get-new-news))
3148 (nnheader-init-server-buffer)
3149 (gnus-read-init-file)
3150 (let ((level (and arg (numberp arg) (> arg 0) arg))
3154 (gnus-group-setup-buffer)
3157 (gnus-start-news-server (and arg (not level))))))
3158 (if (and (not dont-connect)
3161 (run-hooks 'gnus-startup-hook)
3162 ;; NNTP server is successfully open.
3163 (gnus-update-format-specifications)
3164 (gnus-summary-make-display-table)
3165 (let ((buffer-read-only nil))
3167 (if (not gnus-inhibit-startup-message)
3169 (gnus-group-startup-message)
3171 (gnus-setup-news nil level)
3172 (and gnus-use-dribble-file (gnus-dribble-open))
3173 (gnus-group-list-groups level)
3174 (gnus-configure-windows 'group))))))
3176 (defun gnus-group-startup-message (&optional x y)
3177 "Insert startup message in current buffer."
3178 ;; Insert the message.
3194 ;; And then hack it.
3195 ;; 18 is the longest line.
3196 (indent-rigidly (point-min) (point-max)
3197 (/ (max (- (window-width) (or x 28)) 0) 2))
3198 (goto-char (point-min))
3199 ;; +4 is fuzzy factor.
3200 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3203 (goto-char (point-min))
3204 (search-forward "Praxis")
3205 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3206 (goto-char (point-min)))
3208 (defun gnus-group-setup-buffer ()
3209 (or (get-buffer gnus-group-buffer)
3211 (switch-to-buffer gnus-group-buffer)
3212 (gnus-add-current-to-buffer-list)
3214 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3216 (defun gnus-group-list-groups (level &optional unread)
3217 "List newsgroups with level LEVEL or lower that have unread articles.
3218 Default is all subscribed groups.
3219 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3220 (interactive (list (and current-prefix-arg
3221 (prefix-numeric-value current-prefix-arg))))
3222 (if gnus-group-use-permanent-levels
3224 (setq gnus-group-default-list-level
3225 (or level gnus-group-default-list-level))
3226 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3227 (setq level (or level gnus-group-default-list-level
3228 gnus-level-subscribed)))
3229 (gnus-group-setup-buffer) ;May call from out of group buffer
3230 (let ((case-fold-search nil)
3231 (group (gnus-group-group-name)))
3232 (funcall gnus-group-prepare-function level unread nil)
3233 (if (zerop (buffer-size))
3234 (gnus-message 5 gnus-no-groups-message)
3235 (goto-char (point-min))
3237 ;; Go to the first group with unread articles.
3238 (gnus-group-search-forward nil nil nil t)
3239 ;; Find the right group to put point on. If the current group
3240 ;; has disapeared in the new listing, try to find the next
3241 ;; one. If no next one can be found, just leave point at the
3242 ;; first newsgroup in the buffer.
3243 (if (not (gnus-goto-char
3244 (text-property-any (point-min) (point-max)
3245 'gnus-group (intern group))))
3246 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3248 (not (gnus-goto-char
3250 (point-min) (point-max) 'gnus-group
3251 (intern (car (car newsrc)))))))
3252 (setq newsrc (cdr newsrc)))
3253 (or newsrc (progn (goto-char (point-max))
3254 (forward-line -1))))))
3255 ;; Adjust cursor point.
3256 (gnus-group-position-cursor))))
3258 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3259 "List all newsgroups with unread articles of level LEVEL or lower.
3260 If ALL is non-nil, list groups that have no unread articles.
3261 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3262 If REGEXP, only list groups matching REGEXP."
3263 (set-buffer gnus-group-buffer)
3264 (let ((buffer-read-only nil)
3265 (newsrc (cdr gnus-newsrc-alist))
3266 (lowest (or lowest 1))
3267 info clevel unread group)
3269 (if (< lowest gnus-level-zombie)
3270 ;; List living groups.
3272 (setq info (car newsrc)
3275 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3276 (and unread ; This group might be bogus
3278 (string-match regexp group))
3279 (<= (setq clevel (car (cdr info))) level)
3281 (or all ; We list all groups?
3282 (eq unread t) ; We list unactivated groups
3283 (> unread 0) ; We list groups with unread articles
3284 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3285 (gnus-group-insert-group-line
3286 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3288 ;; List dead groups.
3289 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3290 (gnus-group-prepare-flat-list-dead
3291 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3292 gnus-level-zombie ?Z
3294 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3295 (gnus-group-prepare-flat-list-dead
3296 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3297 gnus-level-killed ?K regexp))
3299 (gnus-group-set-mode-line)
3300 (setq gnus-have-all-newsgroups all)
3301 (run-hooks 'gnus-group-prepare-hook)))
3303 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3304 ;; List zombies and killed lists somehwat faster, which was
3305 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3306 ;; this by ignoring the group format specification altogether.
3309 (setq group (car groups)
3310 groups (cdr groups))
3311 (if (or (not regexp)
3312 (string-match regexp group))
3315 (insert (format " %c *: %s\n" mark group))
3316 (add-text-properties
3318 (list 'gnus-group (intern group)
3320 'gnus-level level)))))))
3322 (defun gnus-group-real-name (group)
3323 "Find the real name of a foreign newsgroup."
3324 (if (string-match ":[^:]+$" group)
3325 (substring group (1+ (match-beginning 0)))
3328 (defun gnus-group-prefixed-name (group method)
3329 "Return the whole name from GROUP and METHOD."
3330 (and (stringp method) (setq method (gnus-server-to-method method)))
3331 (concat (format "%s" (car method))
3333 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3334 (not (string= (nth 1 method) "")))
3335 (concat "+" (nth 1 method)))
3338 (defun gnus-group-real-prefix (group)
3339 "Return the prefix of the current group name."
3340 (if (string-match "^[^:]+:" group)
3341 (substring group 0 (match-end 0))
3344 (defun gnus-group-method-name (group)
3345 "Return the method used for selecting GROUP."
3346 (let ((prefix (gnus-group-real-prefix group)))
3347 (if (equal prefix "")
3349 (if (string-match "^[^\\+]+\\+" prefix)
3350 (list (intern (substring prefix 0 (1- (match-end 0))))
3351 (substring prefix (match-end 0) (1- (length prefix))))
3352 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3354 (defun gnus-group-foreign-p (group)
3355 "Return nil if GROUP is native, non-nil if it is foreign."
3356 (string-match ":" group))
3358 (defun gnus-group-set-info (info &optional method-only-group part)
3359 (let* ((entry (gnus-gethash
3360 (or method-only-group (car info)) gnus-newsrc-hashtb))
3362 (info (if method-only-group (nth 2 entry) info)))
3363 (if (not method-only-group)
3366 (error "Trying to change non-existent group %s" method-only-group))
3367 ;; We have recevied parts of the actual group info - either the
3368 ;; select method or the group parameters. We first check
3369 ;; whether we have to extend the info, and if so, do that.
3370 (let ((len (length info))
3371 (total (if (eq part 'method) 5 6)))
3373 (setcdr (nthcdr (1- len) info)
3374 (make-list (- total len) nil)))
3375 ;; Then we enter the new info.
3376 (setcar (nthcdr (1- total) info) part-info)))
3377 ;; We uncompress some lists of marked articles.
3379 (if (not (setq marked (nth 3 info)))
3382 (or (eq 'score (car (car marked)))
3383 (eq 'bookmark (car (car marked)))
3384 (eq 'killed (car (car marked)))
3385 (setcdr (car marked)
3386 (gnus-uncompress-range (cdr (car marked)))))
3387 (setq marked (cdr marked)))))
3390 ;; This is a new group, so we just create it.
3392 (set-buffer gnus-group-buffer)
3394 ;; It's a foreign group...
3395 (gnus-group-make-group
3396 (gnus-group-real-name (car info))
3397 (prin1-to-string (car (nth 4 info)))
3398 (nth 1 (nth 4 info)))
3399 ;; It's a native group.
3400 (gnus-group-make-group
3402 (prin1-to-string (car gnus-select-method))
3403 (nth 1 gnus-select-method)))
3404 (gnus-message 6 "Note: New group created")
3406 (gnus-gethash (gnus-group-prefixed-name
3407 (gnus-group-real-name (car info))
3408 (or (nth 4 info) gnus-select-method))
3409 gnus-newsrc-hashtb))))
3410 ;; Whether it was a new group or not, we now have the entry, so we
3411 ;; can do the update.
3414 (setcar (nthcdr 2 entry) info)
3415 (if (and (not (eq (car entry) t))
3416 (gnus-gethash (car info) gnus-active-hashtb))
3417 (let ((marked (nth 3 info)))
3419 (max 0 (- (length (gnus-list-of-unread-articles
3421 (length (cdr (assq 'tick marked)))
3422 (length (cdr (assq 'dormant marked)))))))))
3423 (error "No such group: %s" (car info)))))
3425 (defun gnus-group-set-method-info (group select-method)
3426 (gnus-group-set-info select-method group 'method))
3428 (defun gnus-group-set-params-info (group params)
3429 (gnus-group-set-info params group 'params))
3431 (defun gnus-group-update-group-line ()
3432 "This function updates the current line in the newsgroup buffer and
3433 moves the point to the colon."
3434 (let* ((buffer-read-only nil)
3435 (group (gnus-group-group-name))
3436 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3439 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3442 (delete-region (point) (progn (forward-line 1) (point)))
3443 (gnus-group-insert-group-line-info group)
3445 (gnus-group-position-cursor)))
3447 (defun gnus-group-insert-group-line-info (group)
3448 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3452 (setq info (nth 2 entry))
3453 (gnus-group-insert-group-line
3454 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3455 (setq active (gnus-gethash group gnus-active-hashtb))
3456 (gnus-group-insert-group-line
3458 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3459 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3461 (defun gnus-group-insert-group-line (gformat group level marked number method)
3462 (let* ((gformat (or gformat gnus-group-line-format-spec))
3463 (active (gnus-gethash group gnus-active-hashtb))
3464 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3465 (number-of-dormant (length (cdr (assq 'dormant marked))))
3466 (number-of-ticked (length (cdr (assq 'tick marked))))
3467 (number-of-ticked-and-dormant
3468 (+ number-of-ticked number-of-dormant))
3469 (number-of-unread-unticked
3470 (if (numberp number) (int-to-string (max 0 number))
3473 (if (numberp number)
3474 (max 0 (- number-total number))
3476 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3477 ((<= level gnus-level-unsubscribed) ?U)
3478 ((= level gnus-level-zombie) ?Z)
3480 (qualified-group (gnus-group-real-name group))
3481 (newsgroup-description
3482 (if gnus-description-hashtb
3483 (or (gnus-gethash group gnus-description-hashtb) "")
3485 (moderated (if (member group gnus-moderated-list) ?m ? ))
3486 (moderated-string (if (eq moderated ?m) "(m)" ""))
3487 (method (gnus-server-get-method group method))
3488 (news-server (or (car (cdr method)) ""))
3489 (news-method (or (car method) ""))
3491 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3495 (> number-of-ticked 0))
3497 (number (if (eq number t) "*" (+ number number-of-dormant
3499 (process-marked (if (member qualified-group gnus-group-marked)
3500 gnus-process-mark ? ))
3501 (buffer-read-only nil)
3502 header ; passed as parameter to user-funcs.
3507 (insert (eval gformat))
3509 (add-text-properties
3510 b (1+ b) (list 'gnus-group (intern group)
3511 'gnus-unread (if (numberp number)
3512 (string-to-int number-of-unread-unticked)
3515 'gnus-level level))))
3517 (defun gnus-group-update-group (group &optional visible-only)
3518 "Update newsgroup info of GROUP.
3519 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3521 (set-buffer gnus-group-buffer)
3522 (let ((buffer-read-only nil)
3524 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3527 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3529 ;; Buffer may be narrowed.
3532 ;; Search a line to modify. If the buffer is large, the search
3533 ;; takes long time. In most cases, current point is on the line
3534 ;; we are looking for. So, first of all, check current line.
3537 (eq (get-text-property (point) 'gnus-group)
3542 (point-min) (point-max) 'gnus-group (intern group)))))
3543 ;; GROUP is listed in current buffer. So, delete old line.
3547 (delete-region (point) (progn (forward-line 1) (point))))
3548 ;; No such line in the buffer, find out where it's supposed to
3549 ;; go, and insert it there (or at the end of the buffer).
3550 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3553 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3559 (point-min) (point-max)
3560 'gnus-group (intern (car (car entry)))))))
3561 (setq entry (cdr entry)))
3562 (or entry (goto-char (point-max)))))))
3563 (if (or visible (not visible-only))
3564 (gnus-group-insert-group-line-info group))
3565 (gnus-group-set-mode-line))))
3567 (defun gnus-group-set-mode-line ()
3568 (if (memq 'group gnus-updated-mode-lines)
3569 (let* ((gformat (or gnus-group-mode-line-format-spec
3570 (setq gnus-group-mode-line-format-spec
3572 gnus-group-mode-line-format
3573 gnus-group-mode-line-format-alist))))
3574 (news-server (car (cdr gnus-select-method)))
3575 (news-method (car gnus-select-method))
3577 (mode-string (eval gformat)))
3578 (setq mode-string (eval gformat))
3579 (if (> (length mode-string) max-len)
3580 (setq mode-string (substring mode-string 0 (- max-len 4))))
3581 (setq mode-line-buffer-identification mode-string)
3582 (set-buffer-modified-p t))))
3584 (defun gnus-group-group-name ()
3585 "Get the name of the newsgroup on the current line."
3586 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3587 (and group (symbol-name group))))
3589 (defun gnus-group-group-level ()
3590 "Get the level of the newsgroup on the current line."
3591 (get-text-property (gnus-point-at-bol) 'gnus-level))
3593 (defun gnus-group-group-unread ()
3594 "Get the number of unread articles of the newsgroup on the current line."
3595 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3597 (defun gnus-group-search-forward (&optional backward all level first-too)
3598 "Find the next newsgroup with unread articles.
3599 If BACKWARD is non-nil, find the previous newsgroup instead.
3600 If ALL is non-nil, just find any newsgroup.
3601 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3603 If FIRST-TOO, the current line is also eligible as a target."
3604 (let ((way (if backward -1 1))
3605 (low gnus-level-killed)
3608 (if (and backward (progn (beginning-of-line)) (bobp))
3610 (or first-too (forward-line way))
3618 (get-text-property (point) 'gnus-unread)))
3619 (or (eq unread t) (and unread (> unread 0))))
3620 (setq lev (get-text-property (point)
3622 (<= lev gnus-level-subscribed)))
3624 (and (setq lev (get-text-property (point)
3633 (zerop (forward-line way)))))
3635 (progn (gnus-group-position-cursor) t)
3636 (goto-char (or pos beg))
3639 ;;; Gnus group mode commands
3643 (defun gnus-group-mark-group (n &optional unmark no-advance)
3644 "Mark the current group."
3646 (let ((buffer-read-only nil)
3650 (setq group (gnus-group-group-name))
3658 (setq gnus-group-marked (delete group gnus-group-marked)))
3660 (setq gnus-group-marked
3661 (cons group (delete group gnus-group-marked))))
3663 (or no-advance (zerop (gnus-group-next-group 1))))
3665 (gnus-summary-position-cursor)
3668 (defun gnus-group-unmark-group (n)
3669 "Remove the mark from the current group."
3671 (gnus-group-mark-group n 'unmark))
3673 (defun gnus-group-mark-region (unmark beg end)
3674 "Mark all groups between point and mark.
3675 If UNMARK, remove the mark instead."
3676 (interactive "P\nr")
3677 (let ((num (count-lines beg end)))
3680 (- num (gnus-group-mark-group num unmark)))))
3682 (defun gnus-group-remove-mark (group)
3683 (and (gnus-group-goto-group group)
3685 (gnus-group-mark-group 1 'unmark t))))
3687 ;; Return a list of groups to work on. Take into consideration N (the
3688 ;; prefix) and the list of marked groups.
3689 (defun gnus-group-process-prefix (n)
3691 (setq n (prefix-numeric-value n))
3692 ;; There is a prefix, so we return a list of the N next
3694 (let ((way (if (< n 0) -1 1))
3699 (setq group (gnus-group-group-name)))
3700 (setq groups (cons group groups))
3702 (forward-line way)))
3705 ;; No prefix, but a list of marked articles.
3706 (reverse gnus-group-marked))
3708 ;; Neither marked articles or a prefix, so we return the
3710 (let ((group (gnus-group-group-name)))
3711 (and group (list group))))))
3713 ;; Selecting groups.
3715 (defun gnus-group-read-group (all &optional no-article group)
3716 "Read news in this newsgroup.
3717 If argument ALL is non-nil, already read articles become readable.
3718 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3720 (let ((group (or group (gnus-group-group-name)))
3721 number active marked entry)
3722 (or group (error "No group on current line"))
3724 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3725 ;; This group might be a dead group. In that case we have to get
3726 ;; the number of unread articles from `gnus-active-hashtb'.
3728 (setq number (car entry))
3729 (if (setq active (gnus-gethash group gnus-active-hashtb))
3730 (setq number (- (1+ (cdr active)) (car active)))))
3731 (gnus-summary-read-group
3732 group (or all (and (numberp number)
3733 (zerop (+ number (length (cdr (assq 'tick marked)))
3734 (length (cdr (assq 'dormant marked)))))))
3737 (defun gnus-group-select-group (all)
3738 "Select this newsgroup.
3739 No article is selected automatically.
3740 If argument ALL is non-nil, already read articles become readable."
3742 (gnus-group-read-group all t))
3744 ;; Enter a group that is not in the group buffer. Non-nil is returned
3745 ;; if selection was successful.
3746 (defun gnus-group-read-ephemeral-group
3747 (group method &optional activate quit-config)
3748 (let ((group (if (gnus-group-foreign-p group) group
3749 (gnus-group-prefixed-name group method))))
3752 (list t nil (list group gnus-level-default-subscribed nil nil
3756 (if quit-config quit-config
3757 (cons (current-buffer) 'summary)))))))
3759 (set-buffer gnus-group-buffer)
3760 (or (gnus-server-opened method)
3761 (gnus-open-server method)
3762 (error "Unable to contact server: %s" (gnus-status-message method)))
3763 (if activate (or (gnus-request-group group)
3764 (error "Couldn't request group")))
3766 (gnus-group-read-group t t group)
3769 (not (equal major-mode 'gnus-group-mode))))
3771 (defun gnus-group-jump-to-group (group)
3772 "Jump to newsgroup GROUP."
3774 (list (completing-read
3775 "Group: " gnus-active-hashtb nil (not (not gnus-read-active-file)))))
3777 (if (equal group "")
3778 (error "Empty group name"))
3780 (let ((b (text-property-any
3781 (point-min) (point-max) 'gnus-group (intern group))))
3783 ;; Either go to the line in the group buffer...
3785 ;; ... or insert the line.
3787 (gnus-gethash group gnus-active-hashtb)
3788 (gnus-activate-newsgroup group)
3789 (error "%s error: %s" group (gnus-status-message group)))
3791 (gnus-group-update-group group)
3792 (goto-char (text-property-any
3793 (point-min) (point-max) 'gnus-group (intern group)))))
3794 ;; Adjust cursor point.
3795 (gnus-group-position-cursor))
3797 (defun gnus-group-goto-group (group)
3798 "Goto to newsgroup GROUP."
3799 (let ((b (text-property-any (point-min) (point-max)
3800 'gnus-group (intern group))))
3801 (and b (goto-char b))))
3803 (defun gnus-group-next-group (n)
3804 "Go to next N'th newsgroup.
3805 If N is negative, search backward instead.
3806 Returns the difference between N and the number of skips actually
3809 (gnus-group-next-unread-group n t))
3811 (defun gnus-group-next-unread-group (n &optional all level)
3812 "Go to next N'th unread newsgroup.
3813 If N is negative, search backward instead.
3814 If ALL is non-nil, choose any newsgroup, unread or not.
3815 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3816 such group can be found, the next group with a level higher than
3818 Returns the difference between N and the number of skips actually
3821 (let ((backward (< n 0))
3824 (gnus-group-search-forward
3825 backward (or (not gnus-group-goto-unread) all) level))
3827 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3828 (if level " on this level or higher" "")))
3831 (defun gnus-group-prev-group (n)
3832 "Go to previous N'th newsgroup.
3833 Returns the difference between N and the number of skips actually
3836 (gnus-group-next-unread-group (- n) t))
3838 (defun gnus-group-prev-unread-group (n)
3839 "Go to previous N'th unread newsgroup.
3840 Returns the difference between N and the number of skips actually
3843 (gnus-group-next-unread-group (- n)))
3845 (defun gnus-group-next-unread-group-same-level (n)
3846 "Go to next N'th unread newsgroup on the same level.
3847 If N is negative, search backward instead.
3848 Returns the difference between N and the number of skips actually
3851 (gnus-group-next-unread-group n t (gnus-group-group-level))
3852 (gnus-group-position-cursor))
3854 (defun gnus-group-prev-unread-group-same-level (n)
3855 "Go to next N'th unread newsgroup on the same level.
3856 Returns the difference between N and the number of skips actually
3859 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3860 (gnus-group-position-cursor))
3862 (defun gnus-group-best-unread-group (&optional exclude-group)
3863 "Go to the group with the highest level.
3864 If EXCLUDE-GROUP, do not go to that group."
3866 (goto-char (point-min))
3869 (while (setq unread (get-text-property (point) 'gnus-unread))
3870 (if (and (numberp unread) (> unread 0))
3872 (if (and (< (get-text-property (point) 'gnus-level) best)
3873 (or (not exclude-group)
3874 (not (equal exclude-group (gnus-group-group-name)))))
3876 (setq best (get-text-property (point) 'gnus-level))
3877 (setq best-point (point))))))
3879 (if best-point (goto-char best-point))
3880 (gnus-summary-position-cursor)
3881 (and best-point (gnus-group-group-name))))
3883 (defun gnus-group-first-unread-group ()
3884 "Go to the first group with unread articles."
3886 (goto-char (point-min))
3887 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3888 (gnus-group-next-unread-group 1))
3889 (gnus-group-position-cursor))
3891 (defun gnus-group-enter-server-mode ()
3892 "Jump to the server buffer."
3894 (gnus-server-setup-buffer)
3895 (gnus-configure-windows 'server)
3896 (gnus-server-prepare))
3898 (defun gnus-group-make-group (name method &optional address)
3899 "Add a new newsgroup.
3900 The user will be prompted for a NAME, for a select METHOD, and an
3904 (read-string "Group name: ")
3907 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3909 (if (assoc method gnus-valid-select-methods)
3911 (if (memq 'prompt-address
3912 (assoc method gnus-valid-select-methods))
3913 (read-string "Address: ")
3915 (list method nil)))))
3917 (let* ((meth (if address (list (intern method) address) method))
3918 (nname (gnus-group-prefixed-name name meth))
3920 (and (gnus-gethash nname gnus-newsrc-hashtb)
3921 (error "Group %s already exists" nname))
3922 (gnus-group-change-level
3923 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3924 gnus-level-default-subscribed gnus-level-killed
3925 (and (gnus-group-group-name)
3926 (gnus-gethash (gnus-group-group-name)
3927 gnus-newsrc-hashtb))
3929 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
3931 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3932 (gnus-group-insert-group-line-info nname)
3934 (if (assoc method gnus-valid-select-methods)
3935 (require (intern method)))
3936 (and (gnus-check-backend-function 'request-create-group nname)
3937 (gnus-request-create-group nname))))
3939 (defun gnus-group-edit-group (group &optional part)
3940 "Edit the group on the current line."
3941 (interactive (list (gnus-group-group-name)))
3942 (let ((done-func '(lambda ()
3943 "Exit editing mode and update the information."
3945 (gnus-group-edit-group-done 'part 'group)))
3946 (part (or part 'info))
3947 (winconf (current-window-configuration))
3949 (or group (error "No group on current line"))
3950 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3951 (error "Killed group; can't be edited"))
3952 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3953 (gnus-configure-windows 'edit-group)
3954 (gnus-add-current-to-buffer-list)
3956 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3957 (use-local-map (copy-keymap emacs-lisp-mode-map))
3958 (local-set-key "\C-c\C-c" done-func)
3959 (make-local-variable 'gnus-prev-winconf)
3960 (setq gnus-prev-winconf winconf)
3961 ;; We modify the func to let it know what part it is editing.
3962 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3963 (setcar (cdr (cdr (nth 4 done-func))) group)
3968 ";; Type `C-c C-c' after editing the select method.\n\n")
3970 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3972 ";; Type `C-c C-c' after editing the group info.\n\n")))
3973 (let ((cinfo (gnus-copy-sequence info))
3975 (if (not (setq marked (nth 3 cinfo)))
3978 (or (eq 'score (car (car marked)))
3979 (eq 'bookmark (car (car marked)))
3980 (eq 'killed (car (car marked)))
3981 (not (numberp (car (cdr (car marked)))))
3982 (setcdr (car marked)
3983 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3984 (setq marked (cdr marked))))
3987 (cond ((eq part 'method)
3988 (or (nth 4 info) "native"))
3995 (defun gnus-group-edit-group-method (group)
3996 "Edit the select method of GROUP."
3997 (interactive (list (gnus-group-group-name)))
3998 (gnus-group-edit-group group 'method))
4000 (defun gnus-group-edit-group-parameters (group)
4001 "Edit the group parameters of GROUP."
4002 (interactive (list (gnus-group-group-name)))
4003 (gnus-group-edit-group group 'params))
4005 (defun gnus-group-edit-group-done (part group)
4006 "Get info from buffer, update variables and jump to the group buffer."
4007 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4008 (goto-char (point-min))
4009 (let ((form (read (current-buffer)))
4010 (winconf gnus-prev-winconf))
4012 (gnus-group-set-info form)
4013 (gnus-group-set-info form group part))
4014 (kill-buffer (current-buffer))
4015 (and winconf (set-window-configuration winconf))
4016 (set-buffer gnus-group-buffer)
4017 (gnus-group-update-group (gnus-group-group-name))
4018 (gnus-group-position-cursor)))
4020 (defun gnus-group-make-help-group ()
4021 "Create the (ding) Gnus documentation group."
4023 (let ((path load-path)
4025 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4026 "gnus-help" '(nndoc "gnus-help")))
4028 (error "Documentation group already exists"))
4030 (not (file-exists-p (concat (file-name-as-directory (car path))
4032 (setq path (cdr path)))
4033 (or path (error "Couldn't find doc group"))
4034 (gnus-group-make-group
4035 (gnus-group-real-name name)
4037 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4038 (list 'nndoc-article-type 'mbox))))
4039 (gnus-group-position-cursor))
4041 (defun gnus-group-make-doc-group (file type)
4042 "Create a group that uses a single file as the source."
4044 (list (read-file-name "File name: ")
4048 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4049 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4050 ((= char ?b) 'babyl)
4051 ((= char ?d) 'digest)
4052 (t (setq err "%c unknown. " char)
4055 (let* ((file (expand-file-name file))
4056 (name (gnus-generate-new-group-name
4057 (gnus-group-prefixed-name
4058 (file-name-nondirectory file) '(nndoc "")))))
4059 (gnus-group-make-group
4060 (gnus-group-real-name name)
4062 (list 'nndoc-address file)
4063 (list 'nndoc-article-type type)))))
4065 (defun gnus-group-make-archive-group ()
4066 "Create the (ding) Gnus archive group."
4068 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
4070 (error "Archive group already exists"))
4071 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
4072 (gnus-group-position-cursor))
4074 (defun gnus-group-make-directory-group (dir)
4075 "Create an nndir group.
4076 The user will be prompted for a directory. The contents of this
4077 directory will be used as a newsgroup. The directory should contain
4078 mail messages or news articles in files that have numeric names."
4080 (list (read-file-name "Create group from directory: ")))
4081 (or (file-exists-p dir) (error "No such directory"))
4082 (or (file-directory-p dir) (error "Not a directory"))
4083 (gnus-group-make-group dir "nndir" dir)
4084 (gnus-group-position-cursor))
4086 (defun gnus-group-make-kiboze-group (group address scores)
4087 "Create an nnkiboze group.
4088 The user will be prompted for a name, a regexp to match groups, and
4089 score file entries for articles to include in the group."
4092 (read-string "nnkiboze group name: ")
4093 (read-string "Source groups (regexp): ")
4094 (let ((headers (mapcar (lambda (group) (list group))
4095 '("subject" "from" "number" "date" "message-id"
4096 "references" "chars" "lines" "xref")))
4097 scores header regexp regexps)
4098 (while (not (equal "" (setq header (completing-read
4099 "Match on header: " headers nil t))))
4101 (while (not (equal "" (setq regexp (read-string
4102 (format "Match on %s (string): "
4104 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4105 (setq scores (cons (cons header regexps) scores)))
4107 (gnus-group-make-group group "nnkiboze" address)
4109 (gnus-set-work-buffer)
4110 (let (emacs-lisp-mode-hook)
4111 (pp scores (current-buffer)))
4112 (write-region (point-min) (point-max)
4113 (concat (or gnus-kill-files-directory "~/News")
4114 "nnkiboze:" group "." gnus-score-file-suffix)))
4115 (gnus-group-position-cursor))
4117 (defun gnus-group-add-to-virtual (n vgroup)
4118 "Add the current group to a virtual group."
4120 (list current-prefix-arg
4121 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4123 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4124 (error "%s is not an nnvirtual group" vgroup))
4125 (let* ((groups (gnus-group-process-prefix n))
4126 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4127 (setcar (cdr method)
4129 (nth 1 method) "\\|"
4132 (gnus-group-remove-mark s)
4133 (concat "\\(^" (regexp-quote s) "$\\)"))
4135 (gnus-group-position-cursor))
4137 (defun gnus-group-make-empty-virtual (group)
4138 "Create a new, fresh, empty virtual group."
4139 (interactive "sCreate new, empty virtual group: ")
4140 (let* ((method (list 'nnvirtual "^$"))
4141 (pgroup (gnus-group-prefixed-name group method)))
4142 ;; Check whether it exists already.
4143 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4144 (error "Group %s already exists." pgroup))
4145 ;; Subscribe the new group after the group on the current line.
4146 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4147 (gnus-group-update-group pgroup)
4149 (gnus-group-position-cursor)))
4151 (defun gnus-group-enter-directory (dir)
4152 "Enter an ephemeral nneething group."
4153 (interactive "DDirectory to read: ")
4154 (let* ((method (list 'nneething dir))
4155 (leaf (gnus-group-prefixed-name
4156 (file-name-nondirectory (directory-file-name dir))
4158 (name (gnus-generate-new-group-name leaf)))
4159 (let ((nneething-read-only t))
4160 (or (gnus-group-read-ephemeral-group
4162 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4164 (error "Couldn't enter %s" dir)))))
4166 ;; Group sorting commands
4167 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4169 (defun gnus-group-sort-groups ()
4170 "Sort the group buffer using `gnus-group-sort-function'."
4172 (setq gnus-newsrc-alist
4173 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4174 (gnus-make-hashtable-from-newsrc-alist)
4175 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4177 (defun gnus-group-sort-by-alphabet (info1 info2)
4178 (string< (car info1) (car info2)))
4180 (defun gnus-group-sort-by-unread (info1 info2)
4181 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4182 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4183 (< (or (and (numberp n1) n1) 0)
4184 (or (and (numberp n2) n2) 0))))
4186 (defun gnus-group-sort-by-level (info1 info2)
4187 (< (nth 1 info1) (nth 1 info2)))
4189 ;; Group catching up.
4191 (defun gnus-group-catchup-current (n &optional all)
4192 "Mark all articles not marked as unread in current newsgroup as read.
4193 If prefix argument N is numeric, the ARG next newsgroups will be
4194 caught up. If ALL is non-nil, marked articles will also be marked as
4195 read. Cross references (Xref: header) of articles are ignored.
4196 The difference between N and actual number of newsgroups that were
4197 caught up is returned."
4199 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4203 "Do you really want to mark all articles as read? "
4204 "Mark all unread articles as read? "))))
4206 (let ((groups (gnus-group-process-prefix n))
4209 ;; Virtual groups have to be given special treatment.
4210 (let ((method (gnus-find-method-for-group (car groups))))
4211 (if (eq 'nnvirtual (car method))
4212 (nnvirtual-catchup-group
4213 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4214 (gnus-group-remove-mark (car groups))
4216 (gnus-group-goto-group (car groups))
4217 (gnus-group-catchup (car groups) all))
4218 (gnus-group-update-group-line)
4219 (setq ret (1+ ret)))
4220 (setq groups (cdr groups)))
4221 (gnus-group-next-unread-group 1)
4224 (defun gnus-group-catchup-current-all (n)
4225 "Mark all articles in current newsgroup as read.
4226 Cross references (Xref: header) of articles are ignored."
4228 (gnus-group-catchup-current n 'all))
4230 (defun gnus-group-catchup (group &optional all)
4231 "Mark all articles in GROUP as read.
4232 If ALL is non-nil, all articles are marked as read.
4233 The return value is the number of articles that were marked as read,
4234 or nil if no action could be taken."
4235 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4237 (marked (nth 3 (nth 2 entry))))
4238 (if (not (numberp (car entry)))
4239 (gnus-message 1 "Can't catch up; non-active group")
4240 ;; Do the updating only if the newsgroup isn't killed.
4243 (gnus-update-read-articles
4244 group (and (not all) (append (cdr (assq 'tick marked))
4245 (cdr (assq 'dormant marked))))
4246 nil (and (not all) (cdr (assq 'tick marked))))
4248 (setcar (nthcdr 3 (nth 2 entry))
4249 (delq (assq 'dormant marked)
4250 (nth 3 (nth 2 entry)))))))
4253 (defun gnus-group-expire-articles (n)
4254 "Expire all expirable articles in the current newsgroup."
4256 (let ((groups (gnus-group-process-prefix n))
4258 (or groups (error "No groups to expire"))
4260 (setq group (car groups)
4261 groups (cdr groups))
4262 (gnus-group-remove-mark group)
4263 (if (not (gnus-check-backend-function 'request-expire-articles group))
4265 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4266 (expirable (if (memq 'total-expire (nth 5 info))
4267 (cons nil (gnus-list-of-read-articles group))
4268 (assq 'expire (nth 3 info)))))
4271 (gnus-request-expire-articles
4272 (cdr expirable) group))))))))
4274 (defun gnus-group-expire-all-groups ()
4275 "Expire all expirable articles in all newsgroups."
4278 (gnus-message 5 "Expiring...")
4279 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4280 (cdr gnus-newsrc-alist))))
4281 (gnus-group-expire-articles nil)))
4282 (gnus-group-position-cursor)
4283 (gnus-message 5 "Expiring...done"))
4285 (defun gnus-group-set-current-level (n level)
4286 "Set the level of the next N groups to LEVEL."
4287 (interactive "P\nnLevel: ")
4288 (or (and (>= level 1) (<= level gnus-level-killed))
4289 (error "Illegal level: %d" level))
4290 (let ((groups (gnus-group-process-prefix n))
4293 (setq group (car groups)
4294 groups (cdr groups))
4295 (gnus-group-remove-mark group)
4296 (gnus-message 6 "Changed level of %s from %d to %d"
4297 group (gnus-group-group-level) level)
4298 (gnus-group-change-level group level
4299 (gnus-group-group-level))
4300 (gnus-group-update-group-line)))
4301 (gnus-group-position-cursor))
4303 (defun gnus-group-unsubscribe-current-group (n)
4304 "Toggle subscription of the current group.
4305 If given numerical prefix, toggle the N next groups."
4307 (let ((groups (gnus-group-process-prefix n))
4310 (setq group (car groups)
4311 groups (cdr groups))
4312 (gnus-group-remove-mark group)
4313 (gnus-group-unsubscribe-group
4314 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4315 gnus-level-default-unsubscribed
4316 gnus-level-default-subscribed))
4317 (gnus-group-update-group-line))
4318 (gnus-group-next-group 1)))
4320 (defun gnus-group-unsubscribe-group (group &optional level)
4321 "Toggle subscribe from/to unsubscribe GROUP.
4322 New newsgroup is added to .newsrc automatically."
4324 (list (completing-read "Group: " gnus-active-hashtb nil
4325 gnus-have-read-active-file)))
4326 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4328 ;; Toggle subscription flag.
4329 (gnus-group-change-level
4330 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4331 gnus-level-subscribed)
4332 (1+ gnus-level-subscribed)
4333 gnus-level-default-subscribed)))
4334 (gnus-group-update-group group))
4335 ((and (stringp group)
4336 (or (not gnus-have-read-active-file)
4337 (gnus-gethash group gnus-active-hashtb)))
4338 ;; Add new newsgroup.
4339 (gnus-group-change-level
4341 (if level level gnus-level-default-subscribed)
4342 (or (and (member group gnus-zombie-list)
4345 (and (gnus-group-group-name)
4346 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4347 (gnus-group-update-group group))
4348 (t (error "No such newsgroup: %s" group)))
4349 (gnus-group-position-cursor)))
4351 (defun gnus-group-transpose-groups (n)
4352 "Move the current newsgroup up N places.
4353 If given a negative prefix, move down instead. The difference between
4354 N and the number of steps taken is returned."
4356 (or (gnus-group-group-name)
4357 (error "No group on current line"))
4358 (gnus-group-kill-group 1)
4360 (forward-line (- n))
4361 (gnus-group-yank-group)
4362 (gnus-group-position-cursor)))
4364 (defun gnus-group-kill-all-zombies ()
4365 "Kill all zombie newsgroups."
4367 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4368 (setq gnus-zombie-list nil)
4369 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4370 (goto-char (point-min))
4371 (gnus-group-position-cursor))
4373 (defun gnus-group-kill-region (begin end)
4374 "Kill newsgroups in current region (excluding current point).
4375 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4390 (beginning-of-line) ;Important when LINES < 1
4391 (gnus-group-kill-group lines)))
4393 (defun gnus-group-kill-group (n)
4394 "The the next N groups.
4395 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4396 However, only groups that were alive can be yanked; already killed
4397 groups or zombie groups can't be yanked.
4398 The return value is the name of the (last) group that was killed."
4400 (let ((buffer-read-only nil)
4401 (groups (gnus-group-process-prefix n))
4404 (setq group (car groups)
4405 groups (cdr groups))
4406 (gnus-group-remove-mark group)
4407 (setq level (gnus-group-group-level))
4409 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4410 (setq gnus-list-of-killed-groups
4411 (cons (cons (car entry) (nth 2 entry))
4412 gnus-list-of-killed-groups)))
4413 (gnus-group-change-level
4414 (if entry entry group) gnus-level-killed (if entry nil level)))
4415 (gnus-group-position-cursor)
4418 (defun gnus-group-yank-group (&optional arg)
4419 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4420 inserting it before the current newsgroup. The numeric ARG specifies
4421 how many newsgroups are to be yanked. The name of the (last)
4422 newsgroup yanked is returned."
4424 (if (not arg) (setq arg 1))
4425 (let (info group prev)
4426 (while (>= (setq arg (1- arg)) 0)
4427 (if (not (setq info (car gnus-list-of-killed-groups)))
4428 (error "No more newsgroups to yank"))
4429 (setq group (nth 2 info))
4430 ;; Find which newsgroup to insert this one before - search
4431 ;; backward until something suitable is found. If there are no
4432 ;; other newsgroups in this buffer, just make this newsgroup the
4434 (setq prev (gnus-group-group-name))
4435 (gnus-group-change-level
4436 info (nth 2 info) gnus-level-killed
4437 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4439 (gnus-group-insert-group-line-info (nth 1 info))
4440 (setq gnus-list-of-killed-groups
4441 (cdr gnus-list-of-killed-groups)))
4443 (gnus-group-position-cursor)
4446 (defun gnus-group-list-all-groups (arg)
4447 "List all newsgroups with level ARG or lower.
4448 Default is gnus-level-unsubscribed, which lists all subscribed and most
4449 unsubscribed groups."
4451 (setq arg (or arg gnus-level-unsubscribed))
4452 (gnus-group-list-groups arg t))
4454 (defun gnus-group-list-killed ()
4455 "List all killed newsgroups in the group buffer."
4457 (if (not gnus-killed-list)
4458 (gnus-message 6 "No killed groups")
4459 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4460 (goto-char (point-min)))
4461 (gnus-group-position-cursor))
4463 (defun gnus-group-list-zombies ()
4464 "List all zombie newsgroups in the group buffer."
4466 (if (not gnus-zombie-list)
4467 (gnus-message 6 "No zombie groups")
4468 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4469 (goto-char (point-min)))
4470 (gnus-group-position-cursor))
4472 (defun gnus-group-get-new-news (&optional arg)
4473 "Get newly arrived articles.
4474 If ARG is non-nil, it should be a number between one and nine to
4475 specify which levels you are interested in re-scanning."
4477 (run-hooks 'gnus-get-new-news-hook)
4478 (if gnus-group-use-permanent-levels
4480 (setq gnus-group-default-list-level
4481 (or arg gnus-group-default-list-level
4482 gnus-level-subscribed))))
4483 (if (and gnus-read-active-file (not arg))
4485 (gnus-read-active-file)
4486 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4487 (let ((gnus-read-active-file nil)
4488 (gnus-have-read-active-file (not arg)))
4489 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4490 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels arg)
4491 gnus-group-default-list-level
4492 gnus-level-subscribed)
4493 gnus-have-all-newsgroups))
4495 (defun gnus-group-get-new-news-this-group (n)
4496 "Check for newly arrived news in the current group (and the N-1 next groups).
4497 The difference between N and the number of newsgroup checked is returned.
4498 If N is negative, this group and the N-1 previous groups will be checked."
4500 (let* ((groups (gnus-group-process-prefix n))
4501 (ret (if (numberp n) (- n (length groups)) 0))
4504 (setq group (car groups)
4505 groups (cdr groups))
4506 (gnus-group-remove-mark group)
4507 (or (gnus-get-new-news-in-group group)
4510 (message "%s error: %s" group (gnus-status-message group))
4512 ;; !!! I don't know why the buffer scrolls forward when updating
4513 ;; the first line in the group buffer, but it does. So we set the
4514 ;; window start forcibly.
4515 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4516 (gnus-group-next-unread-group 1 t)
4517 (gnus-summary-position-cursor)
4520 (defun gnus-get-new-news-in-group (group)
4522 (gnus-activate-newsgroup group)
4524 (gnus-get-unread-articles-in-group
4525 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4526 (gnus-gethash group gnus-active-hashtb))
4527 (gnus-group-update-group-line)
4530 (defun gnus-group-fetch-faq (group)
4531 "Fetch the FAQ for the current group."
4532 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4533 (or group (error "No group name given"))
4534 (let ((file (concat gnus-group-faq-directory group)))
4535 (if (not (file-exists-p file))
4536 (error "No such file: %s" file)
4539 (defun gnus-group-describe-group (force &optional group)
4540 "Display a description of the current newsgroup."
4541 (interactive (list current-prefix-arg (gnus-group-group-name)))
4542 (and force (setq gnus-description-hashtb nil))
4543 (let ((method (gnus-find-method-for-group group))
4545 (or group (error "No group name given"))
4546 (and (or (and gnus-description-hashtb
4547 ;; We check whether this group's method has been
4548 ;; queried for a description file.
4550 (gnus-group-prefixed-name "" method)
4551 gnus-description-hashtb))
4552 (setq desc (gnus-group-get-description group))
4553 (gnus-read-descriptions-file method))
4555 (or desc (gnus-gethash group gnus-description-hashtb)
4556 "No description available")))))
4558 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4559 (defun gnus-group-describe-all-groups (force)
4560 "Pop up a buffer with descriptions of all newsgroups."
4562 (and force (setq gnus-description-hashtb nil))
4563 (if (not (or gnus-description-hashtb
4564 (gnus-read-all-descriptions-files)))
4565 (error "Couldn't request descriptions file"))
4566 (let ((buffer-read-only nil)
4572 (insert (format " *: %-20s %s\n" (symbol-name group)
4573 (symbol-value group)))
4574 (add-text-properties
4575 b (1+ b) (list 'gnus-group group
4576 'gnus-unread t 'gnus-marked nil
4577 'gnus-level (1+ gnus-level-subscribed))))
4578 gnus-description-hashtb)
4579 (goto-char (point-min))
4580 (gnus-group-position-cursor)))
4582 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4583 (defun gnus-group-apropos (regexp &optional search-description)
4584 "List all newsgroups that have names that match a regexp."
4585 (interactive "sGnus apropos (regexp): ")
4587 (obuf (current-buffer))
4589 ;; Go through all newsgroups that are known to Gnus.
4592 (and (string-match regexp (symbol-name group))
4593 (setq groups (cons (symbol-name group) groups))))
4595 ;; Go through all descriptions that are known to Gnus.
4596 (if search-description
4599 (and (string-match regexp (symbol-value group))
4600 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4601 (setq groups (cons (symbol-name group) groups))))
4602 gnus-description-hashtb))
4604 (gnus-message 3 "No groups matched \"%s\"." regexp)
4605 ;; Print out all the groups.
4607 (pop-to-buffer "*Gnus Help*")
4608 (buffer-disable-undo (current-buffer))
4610 (setq groups (sort groups 'string<))
4612 ;; Groups may be entered twice into the list of groups.
4613 (if (not (string= (car groups) prev))
4615 (insert (setq prev (car groups)) "\n")
4616 (if (and gnus-description-hashtb
4617 (setq des (gnus-gethash (car groups)
4618 gnus-description-hashtb)))
4619 (insert " " des "\n"))))
4620 (setq groups (cdr groups)))
4621 (goto-char (point-min))))
4622 (pop-to-buffer obuf)))
4624 (defun gnus-group-description-apropos (regexp)
4625 "List all newsgroups that have names or descriptions that match a regexp."
4626 (interactive "sGnus description apropos (regexp): ")
4627 (if (not (or gnus-description-hashtb
4628 (gnus-read-all-descriptions-files)))
4629 (error "Couldn't request descriptions file"))
4630 (gnus-group-apropos regexp t))
4632 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4633 (defun gnus-group-list-matching (level regexp &optional all lowest)
4634 "List all groups with unread articles that match REGEXP.
4635 If the prefix LEVEL is non-nil, it should be a number that says which
4636 level to cut off listing groups.
4637 If ALL, also list groups with no unread articles.
4638 If LOWEST, don't list groups with level lower than LOWEST."
4639 (interactive "P\nsList newsgroups matching: ")
4640 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4641 all (or lowest 1) regexp)
4642 (goto-char (point-min))
4643 (gnus-group-position-cursor))
4645 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4646 "List all groups that match REGEXP.
4647 If the prefix LEVEL is non-nil, it should be a number that says which
4648 level to cut off listing groups.
4649 If LOWEST, don't list groups with level lower than LOWEST."
4650 (interactive "P\nsList newsgroups matching: ")
4651 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4653 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4654 (defun gnus-group-save-newsrc ()
4655 "Save the Gnus startup files."
4657 (gnus-save-newsrc-file))
4659 (defun gnus-group-restart (&optional arg)
4660 "Force Gnus to read the .newsrc file."
4662 (gnus-save-newsrc-file)
4663 (gnus-setup-news 'force)
4664 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4666 (defun gnus-group-read-init-file ()
4667 "Read the Gnus elisp init file."
4669 (gnus-read-init-file))
4671 (defun gnus-group-check-bogus-groups (silent)
4672 "Check bogus newsgroups.
4673 If given a prefix, don't ask for confirmation before removing a bogus
4676 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4677 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4679 (defun gnus-group-edit-global-kill (article &optional group)
4680 "Edit the global kill file.
4681 If GROUP, edit that local kill file instead."
4683 (setq gnus-current-kill-article article)
4684 (gnus-kill-file-edit-file group)
4686 (substitute-command-keys
4687 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4689 (defun gnus-group-edit-local-kill (article group)
4690 "Edit a local kill file."
4691 (interactive (list nil (gnus-group-group-name)))
4692 (gnus-group-edit-global-kill article group))
4694 (defun gnus-group-force-update ()
4695 "Update `.newsrc' file."
4697 (gnus-save-newsrc-file))
4699 (defun gnus-group-suspend ()
4700 "Suspend the current Gnus session.
4701 In fact, cleanup buffers except for group mode buffer.
4702 The hook gnus-suspend-gnus-hook is called before actually suspending."
4704 (run-hooks 'gnus-suspend-gnus-hook)
4705 ;; Kill Gnus buffers except for group mode buffer.
4706 (let ((group-buf (get-buffer gnus-group-buffer)))
4707 ;; Do this on a separate list in case the user does a ^G before we finish
4708 (let ((gnus-buffer-list
4709 (delq group-buf (delq gnus-dribble-buffer
4710 (append gnus-buffer-list nil)))))
4711 (while gnus-buffer-list
4712 (gnus-kill-buffer (car gnus-buffer-list))
4713 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4716 (setq gnus-buffer-list (list group-buf))
4717 (bury-buffer group-buf)
4718 (delete-windows-on group-buf t)))))
4720 (defun gnus-group-clear-dribble ()
4721 "Clear all information from the dribble buffer."
4723 (gnus-dribble-clear))
4725 (defun gnus-group-exit ()
4726 "Quit reading news after updating .newsrc.eld and .newsrc.
4727 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4729 (if (or noninteractive ;For gnus-batch-kill
4730 (zerop (buffer-size)) ;No news is good news.
4731 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4732 (not gnus-interactive-exit) ;Without confirmation
4734 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4736 (if gnus-use-full-window
4737 (delete-other-windows)
4738 (gnus-remove-some-windows))
4739 (run-hooks 'gnus-exit-gnus-hook)
4740 (gnus-offer-save-summaries)
4741 (gnus-save-newsrc-file)
4742 (gnus-close-backends)
4743 (gnus-clear-system))))
4745 (defun gnus-close-backends ()
4746 ;; Send a close request to all backends that support such a request.
4747 (let ((methods gnus-valid-select-methods)
4750 (if (fboundp (setq func (intern (concat (car (car methods))
4751 "-request-close"))))
4753 (setq methods (cdr methods)))))
4755 (defun gnus-group-quit ()
4756 "Quit reading news without updating .newsrc.eld or .newsrc.
4757 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4759 (if (or noninteractive ;For gnus-batch-kill
4760 (zerop (buffer-size))
4761 (not (gnus-server-opened gnus-select-method))
4763 (not gnus-current-startup-file)
4765 (format "Quit reading news without saving %s? "
4766 (file-name-nondirectory gnus-current-startup-file))))
4768 (run-hooks 'gnus-exit-gnus-hook)
4769 (if gnus-use-full-window
4770 (delete-other-windows)
4771 (gnus-remove-some-windows))
4773 (gnus-close-backends)
4774 (gnus-clear-system))))
4776 (defun gnus-offer-save-summaries ()
4777 (let ((buffers (buffer-list)))
4781 ;; We look for buffers with "Summary" in the name.
4782 (string-match "Summary" (or (buffer-name (car buffers)) ""))
4784 (set-buffer (car buffers))
4785 ;; We check that this is, indeed, a summary buffer.
4786 (eq major-mode 'gnus-summary-mode))
4787 ;; We ask the user whether she wants to save the info.
4789 (format "Update summary buffer %s? " (buffer-name)))
4790 ;; We do it by simply exiting.
4791 (gnus-summary-exit))
4792 (setq buffers (cdr buffers))))))
4794 (defun gnus-group-describe-briefly ()
4795 "Give a one line description of the group mode commands."
4798 (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")))
4800 (defun gnus-group-browse-foreign-server (method)
4801 "Browse a foreign news server.
4802 If called interactively, this function will ask for a select method
4803 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4804 If not, METHOD should be a list where the first element is the method
4805 and the second element is the address."
4807 (list (let ((how (completing-read
4809 (append gnus-valid-select-methods gnus-server-alist)
4811 ;; We either got a backend name or a virtual server name.
4812 ;; If the first, we also need an address.
4813 (if (assoc how gnus-valid-select-methods)
4815 ;; Suggested by mapjph@bath.ac.uk.
4818 (mapcar (lambda (server) (list server))
4819 gnus-secondary-servers)))
4820 ;; We got a server name, so we find the method.
4821 (gnus-server-to-method how)))))
4822 (gnus-browse-foreign-server method))
4826 ;;; Browse Server Mode
4829 (defvar gnus-browse-mode-hook nil)
4830 (defvar gnus-browse-mode-map nil)
4831 (put 'gnus-browse-mode 'mode-class 'special)
4833 (if gnus-browse-mode-map
4835 (setq gnus-browse-mode-map (make-keymap))
4836 (suppress-keymap gnus-browse-mode-map)
4837 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4838 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
4839 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4840 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4841 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4842 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4843 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4844 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4845 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4846 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
4847 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4848 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4849 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4850 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4851 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4852 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4853 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4854 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4857 (defvar gnus-browse-current-method nil)
4858 (defvar gnus-browse-return-buffer nil)
4860 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4862 (defun gnus-browse-foreign-server (method &optional return-buffer)
4863 (setq gnus-browse-current-method method)
4864 (setq gnus-browse-return-buffer return-buffer)
4865 (let ((gnus-select-method method)
4867 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4868 (or (gnus-server-opened method)
4869 (gnus-open-server method)
4870 (error "Unable to contact server: %s" (gnus-status-message method)))
4871 (or (gnus-request-list method)
4872 (error "Couldn't request list: %s" (gnus-status-message method)))
4873 (get-buffer-create gnus-browse-buffer)
4874 (gnus-add-current-to-buffer-list)
4875 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4876 (gnus-configure-windows 'browse)
4877 (buffer-disable-undo (current-buffer))
4878 (let ((buffer-read-only nil))
4881 (setq mode-line-buffer-identification
4883 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4885 (set-buffer nntp-server-buffer)
4886 (let ((cur (current-buffer)))
4887 (goto-char (point-min))
4888 (or (string= gnus-ignored-newsgroups "")
4889 (delete-matching-lines gnus-ignored-newsgroups))
4890 (while (re-search-forward
4891 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4892 (goto-char (match-end 1))
4893 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4895 (max 0 (- (1+ (read cur)) (read cur))))
4897 (setq groups (sort groups
4899 (string< (car l1) (car l2)))))
4900 (let ((buffer-read-only nil))
4902 (setq group (car groups))
4904 (format "K%7d: %s\n" (cdr group) (car group)))
4905 (setq groups (cdr groups))))
4906 (switch-to-buffer (current-buffer))
4907 (goto-char (point-min))
4908 (gnus-group-position-cursor)))
4910 (defun gnus-browse-mode ()
4911 "Major mode for browsing a foreign server.
4913 All normal editing commands are switched off.
4915 \\<gnus-browse-mode-map>
4916 The only things you can do in this buffer is
4918 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
4919 The group will be inserted into the group buffer upon exit from this
4922 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
4924 3) `\\[gnus-browse-exit]' to return to the group buffer."
4926 (kill-all-local-variables)
4927 (if gnus-visual (gnus-browse-make-menu-bar))
4928 (setq mode-line-modified "-- ")
4929 (make-local-variable 'mode-line-format)
4930 (setq mode-line-format (copy-sequence mode-line-format))
4931 (and (equal (nth 3 mode-line-format) " ")
4932 (setcar (nthcdr 3 mode-line-format) ""))
4933 (setq major-mode 'gnus-browse-mode)
4934 (setq mode-name "Browse Server")
4935 (setq mode-line-process nil)
4936 (use-local-map gnus-browse-mode-map)
4937 (buffer-disable-undo (current-buffer))
4938 (setq truncate-lines t)
4939 (setq buffer-read-only t)
4940 (run-hooks 'gnus-browse-mode-hook))
4942 (defun gnus-browse-read-group (&optional no-article)
4943 "Enter the group at the current line."
4945 (let ((group (gnus-browse-group-name)))
4946 (or (gnus-group-read-ephemeral-group
4947 group gnus-browse-current-method nil
4948 (cons (current-buffer) 'browse))
4949 (error "Couldn't enter %s" group))))
4951 (defun gnus-browse-select-group ()
4952 "Select the current group."
4954 (gnus-browse-read-group 'no))
4956 (defun gnus-browse-next-group (n)
4957 "Go to the next group."
4961 (gnus-group-position-cursor)))
4963 (defun gnus-browse-prev-group (n)
4964 "Go to the next group."
4966 (gnus-browse-next-group (- n)))
4968 (defun gnus-browse-unsubscribe-current-group (arg)
4969 "(Un)subscribe to the next ARG groups."
4972 (error "No group at current line."))
4973 (let ((ward (if (< arg 0) -1 1))
4975 (while (and (> arg 0)
4977 (gnus-browse-unsubscribe-group)
4978 (zerop (gnus-browse-next-group ward)))
4979 (setq arg (1- arg)))
4980 (gnus-group-position-cursor)
4981 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
4984 (defun gnus-browse-group-name ()
4987 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
4989 (gnus-group-prefixed-name
4990 (buffer-substring (match-beginning 1) (match-end 1))
4991 gnus-browse-current-method))))
4993 (defun gnus-browse-unsubscribe-group ()
4995 (buffer-read-only nil)
4999 (if (= (following-char) ?K) (setq sub t))
5000 (setq group (gnus-browse-group-name))
5005 (gnus-group-change-level
5006 (list t group gnus-level-default-subscribed
5007 nil nil gnus-browse-current-method)
5008 gnus-level-default-subscribed gnus-level-killed
5009 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
5012 (gnus-group-change-level
5013 group gnus-level-killed gnus-level-default-subscribed)
5017 (defun gnus-browse-exit ()
5018 "Quit browsing and return to the group buffer."
5020 (if (eq major-mode 'gnus-browse-mode)
5021 (kill-buffer (current-buffer)))
5022 (if gnus-browse-return-buffer
5023 (gnus-configure-windows 'server)
5024 (gnus-configure-windows 'group)
5025 (gnus-group-list-groups nil)))
5027 (defun gnus-browse-describe-briefly ()
5028 "Give a one line description of the group mode commands."
5031 (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")))
5035 ;;; Gnus summary mode
5038 (defvar gnus-summary-mode-map nil)
5039 (defvar gnus-summary-mark-map nil)
5040 (defvar gnus-summary-mscore-map nil)
5041 (defvar gnus-summary-article-map nil)
5042 (defvar gnus-summary-thread-map nil)
5043 (defvar gnus-summary-goto-map nil)
5044 (defvar gnus-summary-exit-map nil)
5045 (defvar gnus-summary-various-map nil)
5046 (defvar gnus-summary-interest-map nil)
5047 (defvar gnus-summary-sort-map nil)
5048 (defvar gnus-summary-backend-map nil)
5049 (defvar gnus-summary-save-map nil)
5050 (defvar gnus-summary-wash-map nil)
5051 (defvar gnus-summary-help-map nil)
5053 (put 'gnus-summary-mode 'mode-class 'special)
5055 (if gnus-summary-mode-map
5057 (setq gnus-summary-mode-map (make-keymap))
5058 (suppress-keymap gnus-summary-mode-map)
5060 ;; Non-orthogonal keys
5062 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5063 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5064 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5065 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5066 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5067 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5068 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5069 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5070 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5071 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5072 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5073 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5074 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5075 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5076 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5077 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5078 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5079 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5080 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5081 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5082 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5083 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5084 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5085 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5086 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5087 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5088 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5089 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5090 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5091 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5092 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5093 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5094 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5095 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5096 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5097 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5098 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5099 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5100 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5101 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5102 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5103 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5104 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5105 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5106 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5107 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5108 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5109 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5110 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5111 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5112 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5113 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5114 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5115 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5116 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5117 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5118 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5119 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5120 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5121 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5122 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5123 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5124 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5125 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5126 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5127 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5128 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5129 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5130 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5131 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5132 (define-key gnus-summary-mode-map "V" 'gnus-version)
5133 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5134 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5135 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5136 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5137 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5138 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5139 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5140 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5141 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5142 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5143 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5144 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5145 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5146 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5147 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5148 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5149 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5150 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5153 ;; Sort of orthogonal keymap
5154 (define-prefix-command 'gnus-summary-mark-map)
5155 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5156 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5157 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5158 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5159 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5160 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5161 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5162 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5163 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5164 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5165 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5166 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5167 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5168 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5169 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5170 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5171 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5172 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5173 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5174 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5175 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5176 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5177 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5178 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5180 (define-prefix-command 'gnus-summary-mscore-map)
5181 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
5182 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5183 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5184 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5185 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5187 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
5189 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5191 (define-prefix-command 'gnus-summary-goto-map)
5192 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5193 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5194 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5195 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5196 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5197 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5198 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5199 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5200 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5201 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5202 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5203 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5204 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5205 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5208 (define-prefix-command 'gnus-summary-thread-map)
5209 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5210 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5211 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5212 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5213 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5214 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5215 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5216 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5217 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5218 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5219 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5220 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5221 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5222 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5225 (define-prefix-command 'gnus-summary-exit-map)
5226 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5227 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5228 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5229 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5230 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5231 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5232 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5233 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5234 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5235 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5236 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5239 (define-prefix-command 'gnus-summary-article-map)
5240 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5241 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5242 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5243 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5244 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5245 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5246 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5247 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5248 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5249 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5250 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5251 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5252 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
5253 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
5254 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5255 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
5256 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
5257 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5260 (define-prefix-command 'gnus-summary-wash-map)
5261 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5262 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
5263 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
5264 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
5265 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5266 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5267 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
5268 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5269 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5270 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
5271 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
5272 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
5274 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
5275 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
5276 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
5277 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
5278 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
5279 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5282 (define-prefix-command 'gnus-summary-help-map)
5283 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5284 (define-key gnus-summary-help-map "v" 'gnus-version)
5285 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5286 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5287 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5288 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5291 (define-prefix-command 'gnus-summary-backend-map)
5292 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5293 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5294 (define-key gnus-summary-backend-map "\M-\C-e"
5295 'gnus-summary-expire-articles-now)
5296 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5297 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5298 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5299 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5300 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5301 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5302 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5305 (define-prefix-command 'gnus-summary-save-map)
5306 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5307 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5308 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5309 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5310 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5311 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5312 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5313 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5314 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5316 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5318 (define-prefix-command 'gnus-summary-various-map)
5319 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
5320 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
5321 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5322 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5323 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5324 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5325 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5326 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5327 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
5328 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5329 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5331 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
5333 (define-prefix-command 'gnus-summary-sort-map)
5334 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5335 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5336 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5337 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5338 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5339 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5341 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5342 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5348 (defun gnus-summary-mode (&optional group)
5349 "Major mode for reading articles.
5351 All normal editing commands are switched off.
5352 \\<gnus-summary-mode-map>
5353 Each line in this buffer represents one article. To read an
5354 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5355 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5358 You can also post articles and send mail from this buffer. To
5359 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5360 of an article, type `\\[gnus-summary-reply]'.
5362 There are approx. one gazillion commands you can execute in this
5363 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5365 The following commands are available:
5367 \\{gnus-summary-mode-map}"
5369 (if gnus-visual (gnus-summary-make-menu-bar))
5370 (kill-all-local-variables)
5371 (let ((locals gnus-summary-local-variables))
5373 (if (consp (car locals))
5375 (make-local-variable (car (car locals)))
5376 (set (car (car locals)) (eval (cdr (car locals)))))
5377 (make-local-variable (car locals))
5378 (set (car locals) nil))
5379 (setq locals (cdr locals))))
5380 (gnus-make-thread-indent-array)
5381 (gnus-update-format-specifications)
5382 (setq mode-line-modified "-- ")
5383 (make-local-variable 'mode-line-format)
5384 (setq mode-line-format (copy-sequence mode-line-format))
5385 (and (equal (nth 3 mode-line-format) " ")
5386 (setcar (nthcdr 3 mode-line-format) ""))
5387 (setq major-mode 'gnus-summary-mode)
5388 (setq mode-name "Summary")
5389 (make-local-variable 'minor-mode-alist)
5390 (use-local-map gnus-summary-mode-map)
5391 (buffer-disable-undo (current-buffer))
5392 (setq buffer-read-only t) ;Disable modification
5393 (setq truncate-lines t)
5394 (setq selective-display t)
5395 (setq selective-display-ellipses t) ;Display `...'
5396 (setq buffer-display-table gnus-summary-display-table)
5397 (setq gnus-newsgroup-name group)
5398 (run-hooks 'gnus-summary-mode-hook))
5400 (defun gnus-summary-make-display-table ()
5401 ;; Change the display table. Odd characters have a tendency to mess
5402 ;; up nicely formatted displays - we make all possible glyphs
5403 ;; display only a single character.
5405 ;; We start from the standard display table, if any.
5406 (setq gnus-summary-display-table
5407 (or (copy-sequence standard-display-table)
5408 (make-display-table)))
5409 ;; Nix out all the control chars...
5411 (while (>= (setq i (1- i)) 0)
5412 (aset gnus-summary-display-table i [??])))
5413 ;; ... but not newline and cr, of course. (cr is necessary for the
5414 ;; selective display).
5415 (aset gnus-summary-display-table ?\n nil)
5416 (aset gnus-summary-display-table ?\r nil)
5417 ;; We nix out any glyphs over 126 that are not set already.
5419 (while (>= (setq i (1- i)) 127)
5420 ;; Only modify if the entry is nil.
5421 (or (aref gnus-summary-display-table i)
5422 (aset gnus-summary-display-table i [??])))))
5424 (defun gnus-summary-clear-local-variables ()
5425 (let ((locals gnus-summary-local-variables))
5427 (if (consp (car locals))
5428 (and (vectorp (car (car locals)))
5429 (set (car (car locals)) nil))
5430 (and (vectorp (car locals))
5431 (set (car locals) nil)))
5432 (setq locals (cdr locals)))))
5434 (defun gnus-mouse-pick-article (e)
5437 (gnus-summary-next-page nil t))
5439 (defun gnus-summary-setup-buffer (group)
5440 "Initialize summary buffer."
5441 (let ((buffer (concat "*Summary " group "*")))
5442 (if (get-buffer buffer)
5445 (not gnus-newsgroup-begin))
5446 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5447 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5448 (gnus-add-current-to-buffer-list)
5449 (gnus-summary-mode group)
5450 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5451 (setq gnus-newsgroup-name group)
5454 (defun gnus-set-global-variables ()
5455 ;; Set the global equivalents of the summary buffer-local variables
5456 ;; to the latest values they had. These reflect the summary buffer
5457 ;; that was in action when the last article was fetched.
5458 (if (eq major-mode 'gnus-summary-mode)
5460 (setq gnus-summary-buffer (current-buffer))
5461 (let ((name gnus-newsgroup-name)
5462 (marked gnus-newsgroup-marked)
5463 (unread gnus-newsgroup-unreads)
5464 (headers gnus-current-headers)
5465 (score-file gnus-current-score-file))
5467 (set-buffer gnus-group-buffer)
5468 (setq gnus-newsgroup-name name)
5469 (setq gnus-newsgroup-marked marked)
5470 (setq gnus-newsgroup-unreads unread)
5471 (setq gnus-current-headers headers)
5472 (setq gnus-current-score-file score-file))))))
5474 (defun gnus-summary-insert-dummy-line (sformat subject number)
5476 (setq sformat gnus-summary-dummy-line-format-spec))
5480 (insert (eval sformat))
5481 (add-text-properties
5483 (list 'gnus-number number
5484 'gnus-mark gnus-dummy-mark
5487 (defvar gnus-thread-indent-array nil)
5488 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5489 (defun gnus-make-thread-indent-array ()
5491 (if (and gnus-thread-indent-array
5492 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5494 (setq gnus-thread-indent-array (make-vector 201 "")
5495 gnus-thread-indent-array-level gnus-thread-indent-level)
5497 (aset gnus-thread-indent-array n
5498 (make-string (* n gnus-thread-indent-level) ? ))
5501 (defun gnus-summary-insert-line
5502 (sformat header level current unread replied expirable subject-or-nil
5503 &optional dummy score)
5504 (or sformat (setq sformat gnus-summary-line-format-spec))
5505 (let* ((indentation (aref gnus-thread-indent-array level))
5506 (lines (header-lines header))
5507 (score (or score gnus-summary-default-score 0))
5509 (if (or (null gnus-summary-default-score)
5510 (<= (abs (- score gnus-summary-default-score))
5511 gnus-summary-zcore-fuzz)) ?
5512 (if (< score gnus-summary-default-score)
5513 gnus-score-below-mark gnus-score-over-mark)))
5514 (replied (if replied gnus-replied-mark ? ))
5515 (from (header-from header))
5516 (name-address (funcall gnus-extract-address-components from))
5517 (address (car (cdr name-address)))
5518 (name (or (car name-address) (car (cdr name-address))))
5519 (subject (header-subject header))
5520 (number (header-number header))
5521 (opening-bracket (if dummy ?\< ?\[))
5522 (closing-bracket (if dummy ?\> ?\]))
5523 (buffer-read-only nil)
5524 (b (progn (beginning-of-line) (point))))
5525 (or (numberp lines) (setq lines 0))
5526 (insert (eval sformat))
5527 (add-text-properties
5528 b (1+ b) (list 'gnus-number number
5529 'gnus-mark (or unread gnus-unread-mark)
5530 'gnus-level level))))
5532 (defun gnus-summary-update-line (&optional dont-update)
5533 ;; Update summary line after change.
5534 (or (not gnus-summary-default-score)
5535 gnus-summary-inhibit-highlight
5536 (let ((gnus-summary-inhibit-highlight t)
5537 (article (gnus-summary-article-number)))
5540 (if (and gnus-summary-mark-below
5541 (< (gnus-summary-article-score)
5542 gnus-summary-mark-below))
5543 (and (not (memq article gnus-newsgroup-marked))
5544 (not (memq article gnus-newsgroup-dormant))
5545 (memq article gnus-newsgroup-unreads)
5546 (gnus-summary-mark-article nil gnus-low-score-mark))
5547 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5548 (gnus-summary-mark-article nil gnus-unread-mark))))
5550 (run-hooks 'gnus-summary-update-hook))))))
5552 (defun gnus-summary-update-lines (&optional beg end)
5553 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5554 (let ((beg (or beg (point-min)))
5555 (end (or end (point-max))))
5557 (set-buffer gnus-summary-buffer)
5559 (while (and (not (eobp)) (< (point) end))
5560 (gnus-summary-update-line)
5561 (forward-line 1)))))
5563 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5564 ;; Sum up all elements (and sub-elements) in a list.
5568 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5571 (if (> number 1) gnus-not-empty-thread-mark
5572 gnus-empty-thread-mark)
5575 (defun gnus-summary-read-group
5576 (group &optional show-all no-article kill-buffer)
5577 "Start reading news in newsgroup GROUP.
5578 If SHOW-ALL is non-nil, already read articles are also listed.
5579 If NO-ARTICLE is non-nil, no article is selected initially."
5580 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5581 (let* ((new-group (gnus-summary-setup-buffer group))
5582 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5584 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5587 (gnus-set-global-variables)
5588 (gnus-kill-buffer kill-buffer)
5589 (gnus-configure-windows 'summary)
5590 (gnus-set-mode-line 'summary)
5591 (gnus-summary-position-cursor)
5595 (and (eq major-mode 'gnus-summary-mode)
5596 (not (equal (current-buffer) kill-buffer))
5598 (kill-buffer (current-buffer))
5599 (if (not quit-config)
5601 (set-buffer gnus-group-buffer)
5602 (gnus-group-jump-to-group group)
5603 (gnus-group-next-unread-group 1))
5604 (if (not (buffer-name (car quit-config)))
5605 (gnus-configure-windows 'group)
5606 (set-buffer (car quit-config))
5607 (and (eq major-mode 'gnus-summary-mode)
5608 (gnus-set-global-variables))
5609 (gnus-configure-windows (cdr quit-config))))))
5610 (message "Can't select group")
5612 ((eq did-select 'quit)
5613 (and (eq major-mode 'gnus-summary-mode)
5614 (not (equal (current-buffer) kill-buffer))
5615 (kill-buffer (current-buffer)))
5616 (gnus-kill-buffer kill-buffer)
5617 (if (not quit-config)
5619 (set-buffer gnus-group-buffer)
5620 (gnus-group-jump-to-group group)
5621 (gnus-group-next-unread-group 1)
5622 (gnus-configure-windows 'group))
5623 (if (not (buffer-name (car quit-config)))
5624 (gnus-configure-windows 'group)
5625 (set-buffer (car quit-config))
5626 (and (eq major-mode 'gnus-summary-mode)
5627 (gnus-set-global-variables))
5628 (gnus-configure-windows (cdr quit-config))))
5631 (gnus-set-global-variables)
5632 ;; Save the active value in effect when the group was entered.
5633 (setq gnus-newsgroup-active
5635 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5636 ;; You can change the subjects in this hook.
5637 (run-hooks 'gnus-select-group-hook)
5638 ;; Do score processing.
5639 (and gnus-use-scoring (gnus-possibly-score-headers))
5640 ;; Update the format specifiers.
5641 (gnus-update-format-specifications)
5642 ;; Generate the summary buffer.
5643 (gnus-summary-prepare)
5644 (if (zerop (buffer-size))
5645 (cond (gnus-newsgroup-dormant
5646 (gnus-summary-show-all-dormant))
5647 ((and gnus-newsgroup-scored show-all)
5648 (gnus-summary-show-all-expunged))))
5649 ;; Function `gnus-apply-kill-file' must be called in this hook.
5650 (run-hooks 'gnus-apply-kill-hook)
5651 (if (zerop (buffer-size))
5653 ;; This newsgroup is empty.
5654 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5655 (gnus-message 6 "No unread news")
5656 (gnus-kill-buffer kill-buffer)
5660 ;; (let ((gnus-summary-buffer kill-buffer))
5661 ;; (gnus-configure-windows 'group))))
5662 ;; Hide conversation thread subtrees. We cannot do this in
5663 ;; gnus-summary-prepare-hook since kill processing may not
5664 ;; work with hidden articles.
5665 (and gnus-show-threads
5666 gnus-thread-hide-subtree
5667 (gnus-summary-hide-all-threads))
5668 ;; Show first unread article if requested.
5669 (goto-char (point-min))
5670 (if (and (not no-article)
5671 gnus-auto-select-first
5672 (gnus-summary-first-unread-article))
5674 (gnus-configure-windows 'summary))
5675 (gnus-set-mode-line 'summary)
5676 (gnus-summary-position-cursor)
5677 ;; If in async mode, we send some info to the backend.
5678 (and gnus-newsgroup-async
5679 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5680 (gnus-request-asynchronous
5682 (if (and gnus-asynchronous-article-function
5683 (fboundp gnus-asynchronous-article-function))
5684 (funcall gnus-asynchronous-article-function
5685 gnus-newsgroup-threads)
5686 gnus-newsgroup-threads)))
5687 (gnus-kill-buffer kill-buffer)
5688 (if (not (get-buffer-window gnus-group-buffer))
5690 ;; gotta use windows, because recenter does wierd stuff if
5691 ;; the current buffer ain't the displayed window.
5692 (let ((owin (selected-window)))
5693 (select-window (get-buffer-window gnus-group-buffer))
5694 (and (gnus-group-goto-group group)
5696 (select-window owin))))
5699 (defun gnus-summary-prepare ()
5700 ;; Generate the summary buffer.
5701 (let ((buffer-read-only nil))
5703 (gnus-summary-prepare-threads
5704 (if gnus-show-threads
5705 (gnus-gather-threads
5707 (if (and gnus-summary-expunge-below
5708 (not gnus-fetch-old-headers))
5709 (gnus-make-threads-and-expunge)
5710 (gnus-make-threads))))
5711 gnus-newsgroup-headers)
5713 ;; Erase header retrieval message.
5714 (gnus-summary-update-lines)
5716 ;; Remove the final newline.
5717 ;;(goto-char (point-max))
5719 ;; Call hooks for modifying summary buffer.
5720 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5721 (goto-char (point-min))
5722 (run-hooks 'gnus-summary-prepare-hook)))
5724 (defun gnus-gather-threads (threads)
5725 "Gather threads that have lost their roots."
5726 (if (not gnus-summary-make-false-root)
5728 (let ((hashtb (gnus-make-hashtable 1023))
5731 subject hthread whole-subject)
5734 (setq subject (header-subject (car (car threads)))))
5735 (if gnus-summary-gather-subject-limit
5736 (or (and (numberp gnus-summary-gather-subject-limit)
5737 (> (length subject) gnus-summary-gather-subject-limit)
5739 (substring subject 0
5740 gnus-summary-gather-subject-limit)))
5741 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5742 (setq subject (gnus-simplify-subject-fuzzy subject))))
5743 (setq subject (gnus-simplify-subject-re subject)))
5745 (gnus-gethash subject hashtb))
5747 (or (stringp (car (car hthread)))
5748 (setcar hthread (list whole-subject (car hthread))))
5749 (setcdr (car hthread) (nconc (cdr (car hthread))
5750 (list (car threads))))
5751 (setcdr prev (cdr threads))
5752 (setq threads prev))
5753 (gnus-sethash subject threads hashtb))
5755 (setq threads (cdr threads)))
5758 (defun gnus-make-threads ()
5759 ;; This function takes the dependencies already made by
5760 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5761 ;; through the dependecies in the hash table and finds all the
5762 ;; roots. Roots do not refer back to any valid articles.
5764 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5765 (gnus-build-old-threads))
5768 (if (not (car (symbol-value refs)))
5769 (setq roots (append (cdr (symbol-value refs)) roots))
5770 ;; Ok, these refer back to valid articles, but if
5771 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5772 ;; the root has the same subject as its children. The children
5773 ;; that do not are made into roots and removed from the list
5775 (or gnus-thread-ignore-subject
5776 (let* ((prev (symbol-value refs))
5777 (subject (gnus-simplify-subject-re
5778 (header-subject (car prev))))
5779 (headers (cdr prev)))
5781 (if (not (string= subject
5782 (gnus-simplify-subject-re
5783 (header-subject (car headers)))))
5785 (setq roots (cons (car headers) roots))
5786 (setcdr prev (cdr headers)))
5787 (setq prev headers))
5788 (setq headers (cdr headers)))))))
5789 gnus-newsgroup-dependencies)
5791 (mapcar 'gnus-trim-thread
5793 (mapcar 'gnus-cut-thread
5794 (mapcar 'gnus-make-sub-thread roots))))))
5796 (defun gnus-make-threads-and-expunge ()
5797 ;; This function takes the dependencies already made by
5798 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5799 ;; through the dependecies in the hash table and finds all the
5800 ;; roots. Roots do not refer back to any valid articles.
5801 (let ((default (or gnus-summary-default-score 0))
5802 (below gnus-summary-expunge-below)
5804 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5805 (gnus-build-old-threads))
5808 (if (not (car (symbol-value refs)))
5809 ;; These articles do not refer back to any other articles -
5811 (let ((headers (cdr (symbol-value refs))))
5812 ;; We weed out the low-scored articles.
5814 (if (not (< (or (cdr (assq (header-number (car headers))
5815 gnus-newsgroup-scored)) default)
5818 (setq roots (cons (car headers) roots))
5819 ;; It is below, so we mark it as read.
5820 (setq gnus-newsgroup-unreads
5821 (delq (header-number (car headers))
5822 gnus-newsgroup-unreads)))
5823 (setq headers (cdr headers))))
5824 ;; Ok, these refer back to valid articles, but if
5825 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5826 ;; the root has the same subject as its children. The children
5827 ;; that do not are made into roots and removed from the list
5829 (or gnus-thread-ignore-subject
5830 (let* ((prev (symbol-value refs))
5831 (subject (gnus-simplify-subject-re
5832 (header-subject (car prev))))
5833 (headers (cdr prev)))
5835 (if (not (string= subject
5836 (gnus-simplify-subject-re
5837 (header-subject (car headers)))))
5839 (if (not (< (or (cdr (assq (header-number (car headers))
5840 gnus-newsgroup-scored))
5842 (setq roots (cons (car headers) roots))
5843 (setq gnus-newsgroup-unreads
5844 (delq (header-number (car headers))
5845 gnus-newsgroup-unreads)))
5846 (setcdr prev (cdr headers)))
5847 (setq prev headers))
5848 (setq headers (cdr headers)))))
5849 ;; If this article is expunged, some of the children might be
5851 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
5852 gnus-newsgroup-scored)) default)
5854 (let* ((prev (symbol-value refs))
5855 (headers (cdr prev)))
5857 (setq article (header-number (car headers)))
5858 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5860 (progn (setq roots (cons (car headers) roots))
5861 (setq prev headers))
5862 (setq gnus-newsgroup-unreads
5863 (delq article gnus-newsgroup-unreads))
5864 (setcdr prev (cdr headers)))
5865 (setq headers (cdr headers))))
5866 ;; It was not expunged, but we look at expunged children.
5867 (let* ((prev (symbol-value refs))
5868 (headers (cdr prev))
5871 (setq article (header-number (car headers)))
5872 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5875 (setq gnus-newsgroup-unreads
5876 (delq article gnus-newsgroup-unreads))
5877 (setcdr prev (cdr headers)))
5878 (setq headers (cdr headers)))))))
5879 gnus-newsgroup-dependencies)
5881 (mapcar 'gnus-trim-thread
5883 (mapcar 'gnus-cut-thread
5884 (mapcar 'gnus-make-sub-thread roots))))))
5886 (defun gnus-cut-thread (thread)
5887 ;; Remove leaf dormant or ancient articles from THREAD.
5888 (let ((head (car thread))
5889 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5890 (if (and (null tail)
5891 (let ((number (header-number head)))
5892 (or (memq number gnus-newsgroup-ancient)
5893 (memq number gnus-newsgroup-dormant)
5894 (and gnus-summary-expunge-below
5895 (eq gnus-fetch-old-headers 'some)
5896 (< (or (cdr (assq number gnus-newsgroup-scored))
5897 gnus-summary-default-score 0)
5898 gnus-summary-expunge-below)
5900 (setq gnus-newsgroup-unreads
5901 (delq number gnus-newsgroup-unreads))
5904 (list (cons head tail)))))
5906 (defun gnus-trim-thread (thread)
5907 ;; Remove root ancient articles with only one child from THREAD.
5908 (if (and (eq gnus-fetch-old-headers 'some)
5909 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5910 (= (length thread) 2))
5911 (gnus-trim-thread (nth 1 thread))
5914 (defun gnus-make-sub-thread (root)
5915 ;; This function makes a sub-tree for a node in the tree.
5916 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5917 gnus-newsgroup-dependencies)))))
5918 (cons root (mapcar 'gnus-make-sub-thread children))))
5920 (defun gnus-build-old-threads ()
5921 ;; Look at all the articles that refer back to old articles, and
5922 ;; fetch the headers for the articles that aren't there. This will
5923 ;; build complete threads - if the roots haven't been expired by the
5928 (if (not (car (symbol-value refs)))
5930 (setq heads (cdr (symbol-value refs)))
5932 (if (not (memq (header-number (car heads))
5933 gnus-newsgroup-dormant))
5935 (setq id (symbol-name refs))
5936 (while (and (setq id (gnus-build-get-header id))
5937 (not (car (gnus-gethash
5938 id gnus-newsgroup-dependencies)))))
5940 (setq heads (cdr heads)))))))
5941 gnus-newsgroup-dependencies)))
5943 (defun gnus-build-get-header (id)
5944 ;; Look through the buffer of NOV lines and find the header to
5945 ;; ID. Enter this line into the dependencies hash table, and return
5946 ;; the id of the parent article (if any).
5947 (let ((deps gnus-newsgroup-dependencies)
5951 (set-buffer nntp-server-buffer)
5952 (goto-char (point-min))
5953 (while (and (not found) (search-forward id nil t))
5955 (setq found (looking-at
5956 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5957 (regexp-quote id))))
5958 (or found (beginning-of-line 2)))
5963 (setq header (gnus-nov-parse-line
5964 (read (current-buffer)) deps))
5965 (setq ref (header-references header))
5966 (string-match "\\(<[^>]+>\\) *$" ref)
5967 (substring ref (match-beginning 1) (match-end 1))))))
5969 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5970 gnus-newsgroup-ancient (cons (header-number header)
5971 gnus-newsgroup-ancient))))))
5973 ;; Re-build the thread containing ID.
5974 (defun gnus-rebuild-thread (id)
5975 (let ((dep gnus-newsgroup-dependencies)
5976 (buffer-read-only nil)
5977 parent headers refs thread art)
5978 (while (and id (setq headers
5979 (car (setq art (gnus-gethash (downcase id) dep)))))
5981 (setq id (and (setq refs (header-references headers))
5982 (string-match "\\(<[^>]+>\\) *$" refs)
5983 (substring refs (match-beginning 1) (match-end 1)))))
5984 (setq thread (gnus-make-sub-thread (car parent)))
5985 (gnus-rebuild-remove-articles thread)
5986 (let ((beg (point)))
5987 (gnus-summary-prepare-threads (list thread) 0)
5988 (gnus-summary-update-lines beg (point)))))
5990 ;; Delete all lines in the summary buffer that correspond to articles
5992 (defun gnus-rebuild-remove-articles (thread)
5993 (and (gnus-summary-goto-subject (header-number (car thread)))
5995 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
5997 (defun gnus-sort-threads (threads)
5998 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5999 (let ((fun gnus-thread-sort-functions))
6001 (setq threads (sort threads (car fun))
6005 (defun gnus-thread-header (thread)
6006 ;; Return header of first article in THREAD.
6008 (if (stringp (car thread))
6009 (car (car (cdr thread)))
6013 (defun gnus-thread-sort-by-number (h1 h2)
6014 "Sort threads by root article number."
6015 (let ((h1 (gnus-thread-header h1))
6016 (h2 (gnus-thread-header h2)))
6017 (< (header-number h1) (header-number h2))))
6019 (defun gnus-thread-sort-by-author (h1 h2)
6020 "Sort threads by root author."
6021 (let ((h1 (gnus-thread-header h1))
6022 (h2 (gnus-thread-header h2)))
6024 (let ((extract (funcall
6025 gnus-extract-address-components (header-from h1))))
6026 (or (car extract) (cdr extract)))
6027 (let ((extract (funcall
6028 gnus-extract-address-components (header-from h2))))
6029 (or (car extract) (cdr extract))))))
6031 (defun gnus-thread-sort-by-subject (h1 h2)
6032 "Sort threads by root subject."
6033 (let ((h1 (gnus-thread-header h1))
6034 (h2 (gnus-thread-header h2)))
6036 (downcase (gnus-simplify-subject (header-subject h1)))
6037 (downcase (gnus-simplify-subject (header-subject h2))))))
6039 (defun gnus-thread-sort-by-date (h1 h2)
6040 "Sort threads by root article date."
6041 (let ((h1 (gnus-thread-header h1))
6042 (h2 (gnus-thread-header h2)))
6044 (gnus-sortable-date (header-date h1))
6045 (gnus-sortable-date (header-date h2)))))
6047 (defun gnus-thread-sort-by-score (h1 h2)
6048 "Sort threads by root article score.
6049 Unscored articles will be counted as having a score of zero."
6050 (let ((h1 (gnus-thread-header h1))
6051 (h2 (gnus-thread-header h2)))
6052 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
6053 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
6054 (> (or (cdr s1) gnus-summary-default-score 0)
6055 (or (cdr s2) gnus-summary-default-score 0)))))
6057 (defun gnus-thread-sort-by-total-score (h1 h2)
6058 "Sort threads by the sum of all scores in the thread.
6059 Unscored articles will be counted as having a score of zero."
6060 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6062 (defun gnus-thread-total-score (thread)
6063 ;; This function find the total score of THREAD.
6065 (if (stringp (car thread))
6066 (apply gnus-thread-score-function 0
6067 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6068 (gnus-thread-total-score-1 thread))
6069 (gnus-thread-total-score-1 (list thread))))
6071 (defun gnus-thread-total-score-1 (root)
6072 ;; This function find the total score of the thread below ROOT.
6073 (setq root (car root))
6074 (apply gnus-thread-score-function
6075 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
6076 gnus-summary-default-score 0)
6077 (mapcar 'gnus-thread-total-score
6078 (cdr (gnus-gethash (downcase (header-id root))
6079 gnus-newsgroup-dependencies)))))
6081 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6082 (defvar gnus-tmp-prev-subject "")
6083 (defvar gnus-tmp-adopt-thread nil)
6085 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
6086 (defun gnus-summary-prepare-threads
6087 (threads level &optional not-child no-subject cull)
6088 "Prepare summary buffer from THREADS and indentation LEVEL.
6089 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6090 or a straight list of headers."
6091 (let (thread header number subject clevel)
6093 (setq thread (car threads)
6094 threads (cdr threads))
6095 ;; If `thread' is a cons, hierarchical threads are used. If not,
6096 ;; `thread' is the header.
6098 (setq header (car thread))
6099 (setq header thread)
6101 (or (memq (setq number (header-number header))
6102 gnus-newsgroup-dormant)
6103 (and gnus-summary-expunge-below
6104 (< (or (cdr (assq number gnus-newsgroup-scored))
6105 gnus-summary-default-score 0)
6106 gnus-summary-expunge-below)))
6109 (setq gnus-newsgroup-unreads
6110 (delq number gnus-newsgroup-unreads)))))
6113 ;; The header is a dummy root.
6114 (cond ((eq gnus-summary-make-false-root 'adopt)
6115 ;; We let the first article adopt the rest.
6116 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
6117 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
6118 (setq thread (cdr (cdr thread)))
6120 (gnus-summary-prepare-threads (list (car thread)) 1 t)
6121 (setq thread (cdr thread))))
6122 ((eq gnus-summary-make-false-root 'dummy)
6123 ;; We output a dummy root.
6124 (gnus-summary-insert-dummy-line
6125 nil header (header-number (car (car (cdr thread)))))
6127 ((eq gnus-summary-make-false-root 'empty)
6128 ;; We print the articles with empty subject fields.
6129 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
6130 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
6131 (setq thread (cdr (cdr thread)))
6133 (gnus-summary-prepare-threads
6134 (list (car thread)) 0 nil
6135 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
6137 (gnus-simplify-subject-re
6138 (header-subject (car (car thread))))
6139 (gnus-simplify-subject-re header))))))
6140 (setq thread (cdr thread))))
6142 ;; We do not make a root for the gathered
6143 ;; sub-threads at all.
6145 ;; Print the sub-threads.
6146 (and (consp thread) (cdr thread)
6147 (gnus-summary-prepare-threads (cdr thread) clevel)))
6148 ;; The header is a real article.
6150 (setq number (header-number header)
6151 subject (header-subject header))
6152 (and gnus-newsgroup-async
6153 (setq gnus-newsgroup-threads
6154 (cons (cons (header-number header)
6155 (header-lines header)) gnus-newsgroup-threads)))
6156 (gnus-summary-insert-line
6157 nil header level nil
6158 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6159 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6160 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6161 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6162 (t gnus-ancient-mark))
6163 (memq number gnus-newsgroup-replied)
6164 (memq number gnus-newsgroup-expirable)
6166 gnus-summary-same-subject
6167 (if (or (zerop level)
6168 (and gnus-thread-ignore-subject
6170 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6171 (gnus-simplify-subject-re subject)))))
6173 gnus-summary-same-subject))
6175 (cdr (assq number gnus-newsgroup-scored)))
6176 (setq gnus-tmp-prev-subject subject)
6177 ;; Recursively print subthreads.
6178 (and (consp thread) (cdr thread)
6179 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
6181 (defun gnus-select-newsgroup (group &optional read-all)
6182 "Select newsgroup GROUP.
6183 If READ-ALL is non-nil, all articles in the group are selected."
6184 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6185 (info (nth 2 entry))
6187 (gnus-check-news-server
6188 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6190 (or (gnus-server-opened gnus-current-select-method)
6191 (gnus-open-server gnus-current-select-method)
6192 (error "Couldn't open server"))
6194 (or (and (eq (car entry) t)
6195 (gnus-activate-newsgroup (car info)))
6196 (gnus-request-group group t)
6198 (kill-buffer (current-buffer))
6199 (error "Couldn't request group %s: %s"
6200 group (gnus-status-message group))))
6202 (setq gnus-newsgroup-name group)
6203 (setq gnus-newsgroup-unselected nil)
6204 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6206 (and gnus-asynchronous
6207 (gnus-check-backend-function
6208 'request-asynchronous gnus-newsgroup-name)
6209 (setq gnus-newsgroup-async
6210 (gnus-request-asynchronous gnus-newsgroup-name)))
6212 (setq articles (gnus-articles-to-read group read-all))
6216 (gnus-message 3 "Couldn't select newsgroup")
6218 ((eq articles 0) nil)
6220 ;; Init the dependencies hash table.
6221 (setq gnus-newsgroup-dependencies
6222 (gnus-make-hashtable (length articles)))
6223 ;; Retrieve the headers and read them in.
6224 (setq gnus-newsgroup-headers
6225 (if (eq 'nov (setq gnus-headers-retrieved-by
6226 (gnus-retrieve-headers
6227 (if (and gnus-fetch-old-headers
6228 (not (eq 1 (car articles))))
6231 gnus-newsgroup-name)))
6233 (gnus-get-newsgroup-headers-xover articles))
6234 ;; If we were to fetch old headers, but the backend didn't
6235 ;; support XOVER, then it is possible we fetched one article
6236 ;; that we shouldn't have. If that's the case, we pop it off the
6238 (if (not gnus-fetch-old-headers)
6241 (set-buffer nntp-server-buffer)
6242 (goto-char (point-min))
6243 (and (looking-at "[0-9]+[ \t]+1[ \t]")
6246 (search-forward "\n.\n" nil t)))))
6247 (gnus-get-newsgroup-headers)))
6248 ;; Remove canceled articles from the list of unread articles.
6249 (setq gnus-newsgroup-unreads
6250 (gnus-set-sorted-intersection
6251 gnus-newsgroup-unreads
6252 (mapcar (lambda (headers) (header-number headers))
6253 gnus-newsgroup-headers)))
6254 ;; Adjust and set lists of article marks.
6257 (gnus-adjust-marked-articles info)
6258 (setq gnus-newsgroup-marked
6259 (cdr (assq 'tick (setq marked (nth 3 info)))))
6260 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
6261 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
6262 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
6263 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
6264 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
6265 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
6266 (setq gnus-newsgroup-processable nil)))
6267 ;; Check whether auto-expire is to be done in this group.
6268 (setq gnus-newsgroup-auto-expire
6269 (or (and (stringp gnus-auto-expirable-newsgroups)
6270 (string-match gnus-auto-expirable-newsgroups group))
6271 (memq 'auto-expire (nth 5 info))))
6272 ;; First and last article in this newsgroup.
6273 (and gnus-newsgroup-headers
6274 (setq gnus-newsgroup-begin
6275 (header-number (car gnus-newsgroup-headers)))
6276 (setq gnus-newsgroup-end
6277 (header-number (gnus-last-element gnus-newsgroup-headers))))
6278 (setq gnus-reffed-article-number -1)
6279 ;; GROUP is successfully selected.
6280 (or gnus-newsgroup-headers t)))))
6282 (defun gnus-articles-to-read (group read-all)
6283 ;; Find out what articles the user wants to read.
6285 ;; Select all articles if `read-all' is non-nil, or if all the
6286 ;; unread articles are dormant articles.
6287 (if (or (and read-all (not (numberp read-all)))
6288 (= (length gnus-newsgroup-unreads)
6289 (length gnus-newsgroup-dormant)))
6290 (gnus-uncompress-range
6291 (gnus-gethash group gnus-active-hashtb))
6292 gnus-newsgroup-unreads))
6293 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6294 (scored (length scored-list))
6295 (number (length articles))
6296 (marked (+ (length gnus-newsgroup-marked)
6297 (length gnus-newsgroup-dormant)))
6304 (cond ((and (or (<= scored marked)
6306 (numberp gnus-large-newsgroup)
6307 (> number gnus-large-newsgroup))
6311 "How many articles from %s (default %d): "
6312 gnus-newsgroup-name number))))
6313 (if (string-match "^[ \t]*$" input)
6315 ((and (> scored marked) (< scored number))
6319 "%s %s (%d scored, %d total): "
6320 "How many articles from"
6321 group scored number))))
6322 (if (string-match "^[ \t]*$" input)
6326 (setq select (if (stringp select) (string-to-number select) select))
6327 (if (or (null select) (zerop select))
6329 (if (and (not (zerop scored)) (<= (abs select) scored))
6331 (setq articles (sort scored-list '<))
6332 (setq number (length articles)))
6333 (setq articles (copy-sequence articles)))
6335 (if (< (abs select) number)
6337 ;; Select the N oldest articles.
6338 (setcdr (nthcdr (1- (abs select)) articles) nil)
6339 ;; Select the N most recent articles.
6340 (setq articles (nthcdr (- number select) articles))))
6341 (setq gnus-newsgroup-unselected
6342 (gnus-sorted-intersection
6343 gnus-newsgroup-unreads
6344 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6347 (defun gnus-killed-articles (killed articles)
6350 (if (inline (gnus-member-of-range (car articles) killed))
6351 (setq out (cons (car articles) out)))
6352 (setq articles (cdr articles)))
6355 (defun gnus-adjust-marked-articles (info &optional active)
6356 "Remove all marked articles that are no longer legal."
6357 (let ((marked-lists (nth 3 info))
6358 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6360 ;; There are many types of marked articles.
6362 (setq m (cdr (setq prev (car marked-lists))))
6363 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6364 ;; Make sure that all ticked articles are a subset of the
6365 ;; unread/unselected articles.
6367 (if (or (memq (car m) gnus-newsgroup-unreads)
6368 (memq (car m) gnus-newsgroup-unselected))
6370 (setcdr prev (cdr m)))
6372 ((eq 'score (car prev))
6373 ;; Scored articles should be a subset of
6374 ;; unread/unselected articles.
6376 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6377 (memq (car (car m)) gnus-newsgroup-unreads))
6379 (setcdr prev (cdr m)))
6381 ((eq 'bookmark (car prev))
6382 ;; Bookmarks should be a subset of active articles.
6384 (if (< (car (car m)) (car active))
6385 (setcdr prev (cdr m))
6388 ((eq 'killed (car prev))
6389 ;; Articles that have been through the kill process are
6390 ;; to be a subset of active articles.
6391 (while (and m (< (or (and (numberp (car m)) (car m))
6394 (setcdr prev (cdr m))
6396 (if (and m (< (or (and (numberp (car m)) (car m))
6399 (setcar (if (numberp (car m)) m (car m)) (car active))))
6400 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6401 ;; The replied and expirable articles have to be articles
6404 (if (< (car m) (car active))
6405 (setcdr prev (cdr m))
6408 (setq marked-lists (cdr marked-lists)))
6409 ;; Remove all lists that are empty.
6410 (setq marked-lists (nth 3 info))
6413 (while (= 1 (length (car marked-lists)))
6414 (setq marked-lists (cdr marked-lists)))
6415 (setq m (cdr (setq prev marked-lists)))
6417 (if (= 1 (length (car m)))
6418 (setcdr prev (cdr m))
6421 (setcar (nthcdr 3 info) marked-lists)))
6422 ;; Finally, if there are no marked lists at all left, and if there
6423 ;; are no elements after the lists in the info list, we just chop
6424 ;; the info list off before the marked lists.
6425 (and (null marked-lists)
6426 (not (nthcdr 4 info))
6427 (setcdr (nthcdr 2 info) nil)))
6430 (defun gnus-set-marked-articles
6431 (info ticked replied expirable killed dormant bookmark score)
6432 "Enter the various lists of marked articles into the newsgroup info list."
6434 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6435 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6436 (and expirable (setq newmarked (cons (cons 'expire expirable)
6438 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6439 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6440 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6442 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6445 (setcar (nthcdr 3 info) newmarked)
6446 (and (not newmarked)
6447 (not (nthcdr 4 info))
6448 (setcdr (nthcdr 2 info) nil)))
6450 (setcdr (nthcdr 2 info) (list newmarked))))))
6452 (defun gnus-add-marked-articles (group type articles &optional info force)
6453 ;; Add ARTICLES of TYPE to the info of GROUP.
6454 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6455 ;; add, but replace marked articles of TYPE with ARTICLES.
6456 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6459 (and (not (setq marked (nthcdr 3 info)))
6460 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6461 (and (not (setq m (assq type (car marked))))
6462 (setcar marked (cons (cons type articles) (car marked))))
6465 (nconc m articles)))))
6467 (defun gnus-set-mode-line (where)
6468 "This function sets the mode line of the article or summary buffers.
6469 If WHERE is `summary', the summary mode line format will be used."
6470 (if (memq where gnus-updated-mode-lines)
6473 (set-buffer gnus-summary-buffer)
6474 (let* ((mformat (if (eq where 'article)
6475 gnus-article-mode-line-format-spec
6476 gnus-summary-mode-line-format-spec))
6477 (group-name gnus-newsgroup-name)
6478 (article-number (or gnus-current-article 0))
6479 (unread (- (length gnus-newsgroup-unreads)
6480 (length gnus-newsgroup-dormant)))
6481 (unread-and-unticked
6482 (- unread (length gnus-newsgroup-marked)))
6483 (unselected (length gnus-newsgroup-unselected))
6484 (unread-and-unselected
6485 (cond ((and (zerop unread-and-unticked)
6486 (zerop unselected)) "")
6488 (format "{%d more}" unread-and-unticked))
6489 (t (format "{%d(+%d) more}"
6490 unread-and-unticked unselected))))
6492 (if gnus-current-headers
6493 (header-subject gnus-current-headers) ""))
6494 (max-len (and gnus-mode-non-string-length
6495 (- (frame-width) gnus-mode-non-string-length)))
6496 header) ;; passed as argument to any user-format-funcs
6497 (setq mode-string (eval mformat))
6498 (or (numberp max-len)
6499 (setq max-len (length mode-string)))
6500 (if (< max-len 4) (setq max-len 4))
6501 (if (> (length mode-string) max-len)
6502 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6503 ;; function `substring' might cut on a middle
6504 ;; of multi-octet character.
6506 (concat (gnus-truncate-string mode-string (- max-len 3))
6508 (setq mode-string (format (format "%%-%ds" max-len)
6510 (setq mode-line-buffer-identification mode-string)
6511 (set-buffer-modified-p t))))
6513 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6514 "Go through the HEADERS list and add all Xrefs to a hash table.
6515 The resulting hash table is returned, or nil if no Xrefs were found."
6516 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6518 (gnus-group-foreign-p from-newsgroup)
6520 (assoc (symbol-name (car from-method))
6521 gnus-valid-select-methods))))
6522 (gnus-group-real-prefix from-newsgroup)))
6523 (xref-hashtb (make-vector 63 0))
6524 start group entry number xrefs header)
6526 (setq header (car headers))
6527 (if (and (setq xrefs (header-xref header))
6528 (not (memq (header-number header) unreads)))
6531 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6532 (setq start (match-end 0))
6533 (setq group (concat prefix (substring xrefs (match-beginning 1)
6536 (string-to-int (substring xrefs (match-beginning 2)
6538 (if (setq entry (gnus-gethash group xref-hashtb))
6539 (setcdr entry (cons number (cdr entry)))
6540 (gnus-sethash group (cons number nil) xref-hashtb)))))
6541 (setq headers (cdr headers)))
6542 (if start xref-hashtb nil)))
6544 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6545 "Look through all the headers and mark the Xrefs as read."
6546 (let ((virtual (memq 'virtual
6547 (assoc (symbol-name (car (gnus-find-method-for-group
6549 gnus-valid-select-methods)))
6550 name entry info xref-hashtb idlist method
6553 (set-buffer gnus-group-buffer)
6554 (if (setq xref-hashtb
6555 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6558 (if (string= from-newsgroup (setq name (symbol-name group)))
6560 (setq idlist (symbol-value group))
6561 ;; Dead groups are not updated.
6563 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6565 (if (stringp (setq nth4 (nth 4 info)))
6566 (setq nth4 (gnus-server-to-method nth4))))
6567 ;; Only do the xrefs if the group has the same
6568 ;; select method as the group we have just read.
6569 (or (gnus-methods-equal-p
6570 nth4 (gnus-find-method-for-group from-newsgroup))
6573 (setq method (gnus-find-method-for-group
6575 (and (equal (car nth4) (car method))
6576 (equal (nth 1 nth4) (nth 1 method))))
6577 gnus-use-cross-reference
6578 (or (not (eq gnus-use-cross-reference t))
6580 ;; Only do cross-references on subscribed
6581 ;; groups, if that is what is wanted.
6582 (<= (nth 1 info) gnus-level-subscribed)))
6583 (gnus-group-make-articles-read name idlist expirable))))
6586 (defun gnus-group-make-articles-read (group articles expirable)
6588 (entry (gnus-gethash group gnus-newsrc-hashtb))
6589 (info (nth 2 entry))
6590 (active (gnus-gethash group gnus-active-hashtb))
6591 exps expirable range)
6592 ;; First peel off all illegal article numbers.
6594 (let ((ids articles)
6595 (ticked (cdr (assq 'tick (nth 3 info))))
6596 (dormant (cdr (assq 'dormant (nth 3 info))))
6601 (if (or (> id (cdr active))
6605 (setq articles (delq id articles)))
6606 (and (memq id expirable)
6607 (setq exps (cons id exps)))
6608 (setq ids (cdr ids)))))
6609 ;; Update expirable articles.
6610 (gnus-add-marked-articles nil 'expirable exps info)
6614 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6615 (setcar (nthcdr 2 info)
6619 (setq articles (sort articles '<)))))
6620 ;; Then we have to re-compute how many unread
6621 ;; articles there are in this group.
6626 (setq num (- (1+ (cdr active)) (car active))))
6627 ((not (listp (cdr range)))
6628 (setq num (- (cdr active) (- (1+ (cdr range))
6632 (if (numberp (car range))
6634 (setq num (+ num (- (1+ (cdr (car range)))
6635 (car (car range))))))
6636 (setq range (cdr range)))
6637 (setq num (- (cdr active) num))))
6638 ;; Update the number of unread articles.
6642 (length (cdr (assq 'tick (nth 3 info))))
6644 (cdr (assq 'dormant (nth 3 info)))))))
6645 ;; Update the group buffer.
6646 (gnus-group-update-group group t)))))
6648 (defun gnus-methods-equal-p (m1 m2)
6649 (let ((m1 (or m1 gnus-select-method))
6650 (m2 (or m2 gnus-select-method)))
6652 (and (eq (car m1) (car m2))
6653 (or (not (memq 'address (assoc (symbol-name (car m1))
6654 gnus-valid-select-methods)))
6655 (equal (nth 1 m1) (nth 1 m2)))))))
6657 (defsubst gnus-header-value ()
6658 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6660 (defvar gnus-newsgroup-none-id 0)
6662 (defun gnus-get-newsgroup-headers ()
6663 (setq gnus-article-internal-prepare-hook nil)
6664 (let ((cur nntp-server-buffer)
6665 (dependencies gnus-newsgroup-dependencies)
6666 headers id dep end ref)
6668 (set-buffer nntp-server-buffer)
6669 (goto-char (point-min))
6670 ;; Search to the beginning of the next header. Error messages
6671 ;; do not begin with 2 or 3.
6672 (while (re-search-forward "^[23][0-9]+ " nil t)
6673 (let ((header (make-vector 9 nil))
6674 (case-fold-search t)
6679 (header-set-number header (read cur))
6680 ;; This implementation of this function, with nine
6681 ;; search-forwards instead of the one re-search-forward and
6682 ;; a case (which basically was the old function) is actually
6683 ;; about twice as fast, even though it looks messier. You
6684 ;; can't have everything, I guess. Speed and elegance
6685 ;; doesn't always come hand in hand.
6687 (narrow-to-region (point) (or (save-excursion
6688 (search-forward "\n.\n" nil t))
6690 (if (search-forward "\nfrom: " nil t)
6691 (header-set-from header (gnus-header-value))
6692 (header-set-from header "(nobody)"))
6694 (if (search-forward "\nsubject: " nil t)
6695 (header-set-subject header (gnus-header-value))
6696 (header-set-subject header "(none)"))
6698 (and (search-forward "\nxref: " nil t)
6699 (header-set-xref header (gnus-header-value)))
6701 (or (numberp (and (search-forward "\nlines: " nil t)
6702 (header-set-lines header (read cur))))
6703 (header-set-lines header 0))
6705 (and (search-forward "\ndate: " nil t)
6706 (header-set-date header (gnus-header-value)))
6708 (if (search-forward "\nmessage-id: " nil t)
6709 (header-set-id header (setq id (gnus-header-value)))
6710 ;; If there was no message-id, we just fake one to make
6711 ;; subsequent routines simpler.
6714 (setq id (concat "none+"
6716 (setq gnus-newsgroup-none-id
6717 (1+ gnus-newsgroup-none-id)))))))
6719 (if (search-forward "\nreferences: " nil t)
6721 (header-set-references header (gnus-header-value))
6722 (setq end (match-end 0))
6729 (search-backward ">" end t)
6732 (search-backward "<" end t)
6734 ;; Get the references from the in-reply-to header if there
6735 ;; ware no references and the in-reply-to header looks
6737 (if (and (search-forward "\nin-reply-to: " nil t)
6738 (setq in-reply-to (gnus-header-value))
6739 (string-match "<[^>]+>" in-reply-to))
6741 (header-set-references
6743 (setq ref (substring in-reply-to (match-beginning 0)
6745 (setq ref (downcase ref)))
6747 ;; We do some threading while we read the headers. The
6748 ;; message-id and the last reference are both entered into
6749 ;; the same hash table. Some tippy-toeing around has to be
6750 ;; done in case an article has arrived before the article
6751 ;; which it refers to.
6752 (if (boundp (setq dep (intern (downcase id) dependencies)))
6753 (if (car (symbol-value dep))
6754 ;; An article with this Message-ID has already
6755 ;; been seen, so we ignore this one, except we add
6756 ;; any additional Xrefs (in case the two articles
6757 ;; came from different servers.
6760 (car (symbol-value dep))
6761 (concat (or (header-xref (car (symbol-value dep))) "")
6762 (or (header-xref header) "")))
6764 (setcar (symbol-value dep) header))
6765 (set dep (list header)))
6768 (if (boundp (setq dep (intern ref dependencies)))
6769 (setcdr (symbol-value dep)
6770 (cons header (cdr (symbol-value dep))))
6771 (set dep (list nil header)))
6772 (setq headers (cons header headers))))
6773 (goto-char (point-max))))))
6774 (nreverse headers)))
6776 ;; The following macros and functions were written by Felix Lee
6777 ;; <flee@cse.psu.edu>.
6779 (defmacro gnus-nov-read-integer ()
6781 (if (= (following-char) ?\t)
6783 (let ((num (condition-case nil (read buffer) (error nil))))
6784 (if (numberp num) num 0)))
6785 (or (eobp) (forward-char 1))))
6787 (defmacro gnus-nov-skip-field ()
6788 '(search-forward "\t" eol 'move))
6790 (defmacro gnus-nov-field ()
6791 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6793 ;; Goes through the xover lines and returns a list of vectors
6794 (defun gnus-get-newsgroup-headers-xover (sequence)
6795 "Parse the news overview data in the server buffer, and return a
6796 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6797 ;; Get the Xref when the users reads the articles since most/some
6798 ;; NNTP servers do not include Xrefs when using XOVER.
6799 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6800 (let ((cur nntp-server-buffer)
6801 (dependencies gnus-newsgroup-dependencies)
6802 number headers header)
6804 (set-buffer nntp-server-buffer)
6805 (goto-char (point-min))
6806 (while (and sequence (not (eobp)))
6807 (setq number (read cur))
6808 (while (and sequence (< (car sequence) number))
6809 (setq sequence (cdr sequence)))
6811 (eq number (car sequence))
6813 (setq sequence (cdr sequence))
6815 (inline (gnus-nov-parse-line number dependencies)))
6816 (setq headers (cons header headers)))))
6818 (setq headers (nreverse headers)))
6821 ;; This function has to be called with point after the article number
6822 ;; on the beginning of the line.
6823 (defun gnus-nov-parse-line (number dependencies)
6825 (eol (gnus-point-at-eol))
6826 (buffer (current-buffer))
6829 ;; overview: [num subject from date id refs chars lines misc]
6830 (narrow-to-region (point) eol)
6837 (gnus-nov-field) ; subject
6838 (gnus-nov-field) ; from
6839 (gnus-nov-field) ; date
6840 (setq id (or (gnus-nov-field)
6843 (setq none (1+ none)))))) ; id
6846 (let ((beg (point)))
6847 (search-forward "\t" eol)
6848 (if (search-backward ">" beg t)
6854 (search-backward "<" beg t)
6857 (gnus-nov-field)) ; refs
6858 (gnus-nov-read-integer) ; chars
6859 (gnus-nov-read-integer) ; lines
6860 (if (= (following-char) ?\n)
6862 (gnus-nov-field)) ; misc
6866 (message "Strange nov line.")
6872 ;; We build the thread tree.
6874 (if (boundp (setq dep (intern (downcase id) dependencies)))
6875 (if (car (symbol-value dep))
6876 ;; An article with this Message-ID has already been seen,
6877 ;; so we ignore this one, except we add any additional
6878 ;; Xrefs (in case the two articles came from different
6882 (car (symbol-value dep))
6883 (concat (or (header-xref (car (symbol-value dep))) "")
6884 (or (header-xref header) "")))
6886 (setcar (symbol-value dep) header))
6887 (set dep (list header))))
6890 (if (boundp (setq dep (intern (or ref "none")
6892 (setcdr (symbol-value dep)
6893 (cons header (cdr (symbol-value dep))))
6894 (set dep (list nil header)))))
6897 (defun gnus-article-get-xrefs ()
6898 "Fill in the Xref value in `gnus-current-headers', if necessary.
6899 This is meant to be called in `gnus-article-internal-prepare-hook'."
6900 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6901 gnus-current-headers)))
6902 (or (not gnus-use-cross-reference)
6904 (and (header-xref headers)
6905 (not (string= (header-xref headers) "")))
6906 (let ((case-fold-search t)
6909 (gnus-narrow-to-headers)
6910 (goto-char (point-min))
6911 (if (or (and (eq (downcase (following-char)) ?x)
6912 (looking-at "Xref:"))
6913 (search-forward "\nXref:" nil t))
6915 (goto-char (1+ (match-end 0)))
6916 (setq xref (buffer-substring (point)
6917 (progn (end-of-line) (point))))
6918 (header-set-xref headers xref))))))))
6920 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6921 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6923 ;; Return a header specified by a NUMBER.
6924 (defun gnus-get-header-by-number (number)
6926 (set-buffer gnus-summary-buffer)
6927 (or gnus-newsgroup-headers-hashtb-by-number
6928 (gnus-make-headers-hashtable-by-number))
6929 (gnus-gethash (int-to-string number)
6930 gnus-newsgroup-headers-hashtb-by-number)))
6932 (defun gnus-make-headers-hashtable-by-number ()
6933 "Make hashtable for the variable gnus-newsgroup-headers by number."
6935 (set-buffer gnus-summary-buffer)
6936 (let ((headers gnus-newsgroup-headers)
6938 (setq gnus-newsgroup-headers-hashtb-by-number
6939 (gnus-make-hashtable (length headers)))
6941 (setq header (car headers))
6942 (gnus-sethash (int-to-string (header-number header))
6943 header gnus-newsgroup-headers-hashtb-by-number)
6944 (setq headers (cdr headers))))))
6946 (defun gnus-more-header-backward ()
6947 "Find new header backward."
6948 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6949 (artnum gnus-newsgroup-begin)
6951 (while (and (not header)
6953 (setq artnum (1- artnum))
6954 (setq header (gnus-read-header artnum)))
6957 (defun gnus-more-header-forward (&optional backward)
6958 "Find new header forward.
6959 If BACKWARD, find new header backward instead."
6961 (gnus-more-header-backward)
6962 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6963 (artnum gnus-newsgroup-end)
6965 (while (and (not header)
6967 (setq artnum (1+ artnum))
6968 (setq header (gnus-read-header artnum)))
6971 (defun gnus-extend-newsgroup (header &optional backward)
6972 "Extend newsgroup selection with HEADER.
6973 Optional argument BACKWARD means extend toward backward."
6975 (let ((artnum (header-number header)))
6976 (setq gnus-newsgroup-headers
6978 (cons header gnus-newsgroup-headers)
6979 (nconc gnus-newsgroup-headers (list header))))
6980 (setq gnus-newsgroup-unselected
6981 (delq artnum gnus-newsgroup-unselected))
6982 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6983 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6985 (defun gnus-summary-work-articles (n)
6986 "Return a list of articles to be worked upon. The prefix argument,
6987 the list of process marked articles, and the current article will be
6988 taken into consideration."
6990 (if (and n (numberp n))
6991 (let ((backward (< n 0))
6995 (setq articles (cons (gnus-summary-article-number)
6997 (gnus-summary-search-forward nil nil backward))
6999 (sort articles (function <)))
7000 (or (reverse gnus-newsgroup-processable)
7001 (list (gnus-summary-article-number))))))
7003 (defun gnus-summary-search-group (&optional backward use-level)
7004 "Search for next unread newsgroup.
7005 If optional argument BACKWARD is non-nil, search backward instead."
7007 (set-buffer gnus-group-buffer)
7008 (if (gnus-group-search-forward
7009 backward nil (if use-level (gnus-group-group-level) nil))
7010 (gnus-group-group-name))))
7012 (defun gnus-summary-best-group (&optional exclude-group)
7013 "Find the name of the best unread group.
7014 If EXCLUDE-GROUP, do not go to this group."
7016 (set-buffer gnus-group-buffer)
7018 (gnus-group-best-unread-group exclude-group))))
7020 (defun gnus-summary-search-subject (&optional backward unread subject)
7021 "Search for article forward.
7022 If BACKWARD is non-nil, search backward.
7023 If UNREAD is non-nil, only unread articles are selected.
7024 If SUBJECT is non-nil, the article which has the same subject will be
7026 (let ((func (if backward 'previous-single-property-change
7027 'next-single-property-change))
7032 (and gnus-summary-check-current unread
7033 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7037 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7040 (setq pos (funcall func (point) 'gnus-number))
7041 (goto-char (if backward (1- pos) pos))
7045 (eq (get-text-property (point) 'gnus-mark)
7048 (and (setq psubject (gnus-summary-subject-string))
7049 (gnus-subject-equal subject psubject))))))
7050 (if backward (if (bobp) nil (forward-char -1) t)
7051 (if (eobp) nil (forward-char 1) t)))))
7053 (progn (goto-char beg) nil)
7055 (get-text-property (point) 'gnus-number)
7056 (gnus-summary-position-cursor)))))
7058 (defun gnus-subject-equal (s1 s2)
7060 ((null gnus-summary-gather-subject-limit)
7061 (equal (gnus-simplify-subject-re s1)
7062 (gnus-simplify-subject-re s2)))
7063 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7064 (equal (gnus-simplify-subject-fuzzy s1)
7065 (gnus-simplify-subject-fuzzy s2)))
7066 ((numberp gnus-summary-gather-subject-limit)
7067 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7068 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7072 (defun gnus-summary-search-forward (&optional unread subject backward)
7073 "Search for article forward.
7074 If UNREAD is non-nil, only unread articles are selected.
7075 If SUBJECT is non-nil, the article which has the same subject will be
7077 If BACKWARD is non-nil, the search will be performed backwards instead."
7078 (gnus-summary-search-subject backward unread subject))
7080 (defun gnus-summary-search-backward (&optional unread subject)
7081 "Search for article backward.
7082 If 1st optional argument UNREAD is non-nil, only unread article is selected.
7083 If 2nd optional argument SUBJECT is non-nil, the article which has
7084 the same subject will be searched for."
7085 (gnus-summary-search-forward unread subject t))
7087 (defun gnus-summary-article-number (&optional number-or-nil)
7088 "The article number of the article on the current line.
7089 If there isn's an article number here, then we return the current
7091 (let* ((number (get-text-property (gnus-point-at-bol) 'gnus-number)))
7092 (if number-or-nil number (or number gnus-current-article))))
7094 (defun gnus-summary-thread-level ()
7095 "The thread level of the article on the current line."
7096 (or (get-text-property (gnus-point-at-bol) 'gnus-level)
7099 (defun gnus-summary-pseudo-article ()
7100 "The thread level of the article on the current line."
7101 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7103 (defun gnus-summary-article-mark ()
7104 "The mark on the current line."
7105 (get-text-property (gnus-point-at-bol) 'gnus-mark))
7107 (defun gnus-summary-subject-string ()
7108 "Return current subject string or nil if nothing."
7109 (let ((article (gnus-summary-article-number))
7112 (setq header (gnus-get-header-by-number article))
7114 (header-subject header))))
7116 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7117 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7118 (defun gnus-summary-article-score ()
7119 "Return current article score."
7120 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7121 gnus-summary-default-score 0))
7123 (defun gnus-summary-recenter ()
7124 "Center point in the summary window.
7125 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7126 displayed, no centering will be performed."
7127 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7128 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7129 (let* ((top (cond ((< (window-height) 4) 0)
7130 ((< (window-height) 7) 1)
7132 (height (1- (window-height)))
7133 (bottom (save-excursion (goto-char (point-max))
7134 (forward-line (- height))
7136 (window (get-buffer-window (current-buffer))))
7138 ;; The user has to want it,
7139 gnus-auto-center-summary
7140 ;; the article buffer must be displayed,
7141 (get-buffer-window gnus-article-buffer)
7142 ;; Set the window start to either `bottom', which is the biggest
7143 ;; possible valid number, or the second line from the top,
7144 ;; whichever is the least.
7146 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7148 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7149 (defun gnus-short-group-name (group &optional levels)
7150 "Collapse GROUP name LEVELS."
7151 (let* ((name "") (foreign "") (depth -1) (skip 1)
7154 (while (string-match "\\." group skip)
7155 (setq skip (match-end 0)
7158 (if (string-match ":" group)
7159 (setq foreign (substring group 0 (match-end 0))
7160 group (substring group (match-end 0))))
7162 (if (and (string-match "\\." group) (> levels 0))
7163 (setq name (concat name (substring group 0 1))
7164 group (substring group (match-end 0))
7166 name (concat name "."))
7167 (setq name (concat foreign name group)
7171 (defun gnus-summary-jump-to-group (newsgroup)
7172 "Move point to NEWSGROUP in group mode buffer."
7173 ;; Keep update point of group mode buffer if visible.
7174 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7175 (save-window-excursion
7176 ;; Take care of tree window mode.
7177 (if (get-buffer-window gnus-group-buffer)
7178 (pop-to-buffer gnus-group-buffer))
7179 (gnus-group-jump-to-group newsgroup))
7181 ;; Take care of tree window mode.
7182 (if (get-buffer-window gnus-group-buffer)
7183 (pop-to-buffer gnus-group-buffer)
7184 (set-buffer gnus-group-buffer))
7185 (gnus-group-jump-to-group newsgroup))))
7187 ;; This function returns a list of article numbers based on the
7188 ;; difference between the ranges of read articles in this group and
7189 ;; the range of active articles.
7190 (defun gnus-list-of-unread-articles (group)
7191 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7192 (active (gnus-gethash group gnus-active-hashtb))
7195 ;; If none are read, then all are unread.
7197 (setq first (car active))
7198 ;; If the range of read articles is a single range, then the
7199 ;; first unread article is the article after the last read
7200 ;; article. Sounds logical, doesn't it?
7201 (if (not (listp (cdr read)))
7202 (setq first (1+ (cdr read)))
7203 ;; `read' is a list of ranges.
7204 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7205 (car (car read)))) 1)
7209 (while (< first nlast)
7210 (setq unread (cons first unread))
7211 (setq first (1+ first))))
7212 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7213 (setq nlast (if (atom (car (cdr read)))
7215 (car (car (cdr read)))))
7216 (setq read (cdr read)))))
7217 ;; And add the last unread articles.
7218 (while (<= first last)
7219 (setq unread (cons first unread))
7220 (setq first (1+ first)))
7221 ;; Return the list of unread articles.
7224 (defun gnus-list-of-read-articles (group)
7225 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7226 (active (gnus-gethash group gnus-active-hashtb)))
7228 (gnus-sorted-complement
7229 (gnus-uncompress-range active)
7230 (gnus-list-of-unread-articles group)))))
7232 ;; Various summary commands
7234 (defun gnus-summary-universal-argument ()
7235 "Perform any operation on all articles marked with the process mark."
7237 (gnus-set-global-variables)
7238 (let ((articles (reverse gnus-newsgroup-processable))
7240 (or articles (error "No articles marked"))
7241 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7242 (error "Undefined key"))
7244 (gnus-summary-goto-subject (car articles))
7245 (command-execute func)
7246 (gnus-summary-remove-process-mark (car articles))
7247 (setq articles (cdr articles)))))
7249 (defun gnus-summary-toggle-truncation (arg)
7250 "Toggle truncation of summary lines.
7251 With arg, turn line truncation on iff arg is positive."
7253 (setq truncate-lines
7254 (if (null arg) (not truncate-lines)
7255 (> (prefix-numeric-value arg) 0)))
7258 (defun gnus-summary-reselect-current-group (all)
7259 "Once exit and then reselect the current newsgroup.
7260 The prefix argument ALL means to select all articles."
7262 (gnus-set-global-variables)
7263 (let ((current-subject (gnus-summary-article-number))
7264 (group gnus-newsgroup-name))
7265 (setq gnus-newsgroup-begin nil)
7266 (gnus-summary-exit t)
7267 ;; We have to adjust the point of group mode buffer because the
7268 ;; current point was moved to the next unread newsgroup by
7270 (gnus-summary-jump-to-group group)
7271 (gnus-group-read-group all t)
7272 (gnus-summary-goto-subject current-subject)))
7274 (defun gnus-summary-rescan-group (all)
7275 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7277 (gnus-set-global-variables)
7278 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7279 (let ((group gnus-newsgroup-name))
7281 (gnus-summary-jump-to-group group)
7283 (set-buffer gnus-group-buffer)
7284 (gnus-group-get-new-news-this-group 1))
7285 (gnus-summary-jump-to-group group)
7286 (gnus-group-read-group all)))
7288 (defun gnus-summary-update-info ()
7289 (let* ((group gnus-newsgroup-name))
7290 (if gnus-newsgroup-kill-headers
7291 (setq gnus-newsgroup-killed
7292 (gnus-compress-sequence
7294 (gnus-set-sorted-intersection
7295 (gnus-uncompress-range gnus-newsgroup-killed)
7296 (setq gnus-newsgroup-unselected
7297 (sort gnus-newsgroup-unselected '<)))
7298 (setq gnus-newsgroup-unreads
7299 (sort gnus-newsgroup-unreads '<))) t)))
7300 (or (listp (cdr gnus-newsgroup-killed))
7301 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7302 (let ((headers gnus-newsgroup-headers))
7303 (gnus-close-group group)
7304 (run-hooks 'gnus-exit-group-hook)
7305 (gnus-update-read-articles
7306 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7307 gnus-newsgroup-marked
7308 t gnus-newsgroup-replied gnus-newsgroup-expirable
7309 gnus-newsgroup-killed gnus-newsgroup-dormant
7310 gnus-newsgroup-bookmarks
7311 (and gnus-save-score gnus-newsgroup-scored))
7312 (and gnus-use-cross-reference
7313 (gnus-mark-xrefs-as-read
7314 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7315 ;; Do adaptive scoring, and possibly save score files.
7316 (and gnus-newsgroup-adaptive
7317 (gnus-score-adaptive))
7318 (and gnus-use-scoring
7319 (fboundp 'gnus-score-save)
7320 (funcall 'gnus-score-save))
7321 ;; Do not switch windows but change the buffer to work.
7322 (set-buffer gnus-group-buffer)
7323 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7324 (gnus-group-update-group group)))))
7326 (defun gnus-summary-exit (&optional temporary)
7327 "Exit reading current newsgroup, and then return to group selection mode.
7328 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7330 (gnus-set-global-variables)
7331 (gnus-kill-save-kill-buffer)
7332 (let* ((group gnus-newsgroup-name)
7333 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7334 gnus-newsgroup-name))))
7336 (buf (current-buffer)))
7337 (run-hooks 'gnus-summary-exit-hook)
7338 (gnus-summary-update-info) ; Make all changes in this group permanent.
7340 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7341 ;; Make sure where I was, and go to next newsgroup.
7342 (set-buffer gnus-group-buffer)
7345 (gnus-group-jump-to-group group)
7346 (gnus-group-next-unread-group 1)))
7349 ;; We set all buffer-local variables to nil. It is unclear why
7350 ;; this is needed, but if we don't, buffer-local variables are
7351 ;; not garbage-collected, it seems. This would the lead to en
7352 ;; ever-growing Emacs.
7354 (gnus-summary-clear-local-variables)
7355 ;; We clear the global counterparts of the buffer-local
7356 ;; variables as well, just to be on the safe side.
7357 (gnus-configure-windows 'group)
7358 (gnus-summary-clear-local-variables)
7359 ;; Return to group mode buffer.
7360 (if (eq mode 'gnus-summary-mode)
7361 (gnus-kill-buffer buf))
7362 (if (get-buffer gnus-article-buffer)
7363 (bury-buffer gnus-article-buffer))
7364 (setq gnus-current-select-method gnus-select-method)
7365 (pop-to-buffer gnus-group-buffer)
7366 (if (not quit-config)
7368 (gnus-group-jump-to-group group)
7369 (gnus-group-next-unread-group 1))
7370 (if (not (buffer-name (car quit-config)))
7371 (gnus-configure-windows 'group)
7372 (set-buffer (car quit-config))
7373 (and (eq major-mode 'gnus-summary-mode)
7374 (gnus-set-global-variables))
7375 (gnus-configure-windows (cdr quit-config)))))))
7377 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7378 (defun gnus-summary-exit-no-update (&optional no-questions)
7379 "Quit reading current newsgroup without updating read article info."
7381 (gnus-set-global-variables)
7382 (let* ((group gnus-newsgroup-name)
7383 (quit-config (nth 1 (assoc 'quit-config
7384 (gnus-find-method-for-group group)))))
7385 (if (or no-questions
7387 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7389 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7390 (gnus-close-group group)
7391 (gnus-summary-clear-local-variables)
7392 (set-buffer gnus-group-buffer)
7393 (gnus-summary-clear-local-variables)
7394 ;; Return to group selection mode.
7395 (gnus-configure-windows 'group)
7396 (if (get-buffer gnus-summary-buffer)
7397 (kill-buffer gnus-summary-buffer))
7398 (if (get-buffer gnus-article-buffer)
7399 (bury-buffer gnus-article-buffer))
7400 (if (equal (gnus-group-group-name) group)
7401 (gnus-group-next-unread-group 1))
7404 (if (not (buffer-name (car quit-config)))
7405 (gnus-configure-windows 'group)
7406 (set-buffer (car quit-config))
7407 (and (eq major-mode 'gnus-summary-mode)
7408 (gnus-set-global-variables))
7409 (gnus-configure-windows (cdr quit-config)))))))))
7411 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7412 (defun gnus-summary-fetch-faq (group)
7413 "Fetch the FAQ for the current group."
7414 (interactive (list gnus-newsgroup-name))
7415 (let ((gnus-faq-buffer
7416 (find-file (concat gnus-group-faq-directory
7417 (gnus-group-real-name group)))))
7418 (and gnus-faq-buffer (gnus-configure-windows 'summary-faq))))
7420 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7421 (defun gnus-summary-describe-group (force)
7422 "Describe the current newsgroup."
7424 (gnus-group-describe-group force gnus-newsgroup-name))
7426 (defun gnus-summary-describe-briefly ()
7427 "Describe summary mode commands briefly."
7430 (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")))
7432 ;; Walking around group mode buffer from summary mode.
7434 (defun gnus-summary-next-group (&optional no-article target-group backward)
7435 "Exit current newsgroup and then select next unread newsgroup.
7436 If prefix argument NO-ARTICLE is non-nil, no article is selected
7437 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7438 previous group instead."
7440 (gnus-set-global-variables)
7441 (let ((current-group gnus-newsgroup-name)
7442 (current-buffer (current-buffer))
7444 ;; First we semi-exit this group to update Xrefs and all variables.
7445 ;; We can't do a real exit, because the window conf must remain
7446 ;; the same in case the user is prompted for info, and we don't
7447 ;; want the window conf to change before that...
7448 (gnus-summary-exit t)
7449 (while (not entered)
7450 ;; Then we find what group we are supposed to enter.
7451 (set-buffer gnus-group-buffer)
7452 (gnus-group-jump-to-group current-group)
7455 (if (eq gnus-keep-same-level 'best)
7456 (gnus-summary-best-group gnus-newsgroup-name)
7457 (gnus-summary-search-group backward gnus-keep-same-level))))
7458 (if (not target-group)
7459 ;; There are no further groups, so we return to the group
7462 (gnus-message 5 "Returning to the group buffer")
7464 (set-buffer current-buffer)
7465 (gnus-summary-exit))
7466 ;; We try to enter the target group.
7467 (gnus-group-jump-to-group target-group)
7468 (let ((unreads (gnus-group-group-unread)))
7469 (if (and (or (eq t unreads)
7470 (and unreads (not (zerop unreads))))
7471 (gnus-summary-read-group
7472 target-group nil no-article current-buffer))
7474 (setq current-group target-group
7475 target-group nil)))))))
7477 (defun gnus-summary-next-group-old (&optional no-article group backward)
7478 "Exit current newsgroup and then select next unread newsgroup.
7479 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7480 If BACKWARD, go to previous group instead."
7482 (gnus-set-global-variables)
7483 (let ((ingroup gnus-newsgroup-name)
7484 (sumbuf (current-buffer))
7486 (set-buffer gnus-group-buffer)
7488 (or (and (numberp (setq num (car (gnus-gethash
7489 group gnus-newsrc-hashtb))))
7493 (gnus-group-jump-to-group group)
7495 (gnus-group-jump-to-group ingroup))
7496 (gnus-summary-search-group backward)
7497 (let ((group (or group (gnus-summary-search-group backward))))
7499 (gnus-summary-exit t) ;Update all information.
7501 (gnus-summary-exit-no-update t)
7502 (gnus-group-jump-to-group ingroup)
7503 (setq group (gnus-summary-search-group backward))
7504 (gnus-message 5 "Selecting %s..." group)
7505 (set-buffer gnus-group-buffer)
7506 ;; We are now in group mode buffer.
7507 ;; Make sure group mode buffer point is on GROUP.
7508 (gnus-group-jump-to-group group)
7509 (if (not (eq gnus-auto-select-next 'quietly))
7511 (gnus-summary-read-group group nil no-article sumbuf)
7512 (and (string= gnus-newsgroup-name ingroup)
7513 (bufferp sumbuf) (buffer-name sumbuf)
7515 (set-buffer (setq gnus-summary-buffer sumbuf))
7516 (gnus-summary-exit-no-update t))))
7517 (let ((prevgroup group))
7518 (gnus-group-jump-to-group ingroup)
7519 (setq group (gnus-summary-search-group backward))
7520 (gnus-summary-read-group group nil no-article sumbuf)
7521 (while (and (string= gnus-newsgroup-name ingroup)
7523 (buffer-name sumbuf)
7524 (not (string= prevgroup (gnus-group-group-name))))
7525 (set-buffer gnus-group-buffer)
7526 (gnus-summary-read-group
7527 (setq prevgroup (gnus-group-group-name))
7528 nil no-article sumbuf))
7529 (and (string= prevgroup (gnus-group-group-name))
7530 ;; We have reached the final group in the group
7533 (if (buffer-name sumbuf)
7536 (gnus-summary-exit)))))))))))
7538 (defun gnus-summary-prev-group (no-article)
7539 "Exit current newsgroup and then select previous unread newsgroup.
7540 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7542 (gnus-summary-next-group no-article nil t))
7544 ;; Walking around summary lines.
7546 (defun gnus-summary-first-subject (unread)
7547 "Go to the first unread subject.
7548 If UNREAD is non-nil, go to the first unread article.
7549 Returns nil if there are no unread articles."
7553 (goto-char (point-min)))
7556 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7559 ;; There are no unread articles.
7560 (gnus-message 3 "No more unread articles")
7562 (gnus-summary-position-cursor)))
7564 (defun gnus-summary-next-subject (n &optional unread dont-display)
7565 "Go to next N'th summary line.
7566 If N is negative, go to the previous N'th subject line.
7567 If UNREAD is non-nil, only unread articles are selected.
7568 The difference between N and the actual number of steps taken is
7571 (let ((backward (< n 0))
7574 (gnus-summary-search-forward unread nil backward))
7576 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7577 (if unread " unread" "")))
7580 (gnus-summary-recenter)
7581 (gnus-summary-position-cursor)))
7584 (defun gnus-summary-next-unread-subject (n)
7585 "Go to next N'th unread summary line."
7587 (gnus-summary-next-subject n t))
7589 (defun gnus-summary-prev-subject (n &optional unread)
7590 "Go to previous N'th summary line.
7591 If optional argument UNREAD is non-nil, only unread article is selected."
7593 (gnus-summary-next-subject (- n) unread))
7595 (defun gnus-summary-prev-unread-subject (n)
7596 "Go to previous N'th unread summary line."
7598 (gnus-summary-next-subject (- n) t))
7600 (defun gnus-summary-goto-subject (article)
7601 "Go the subject line of ARTICLE."
7605 (completing-read "Article number: "
7609 (int-to-string (header-number headers))))
7610 gnus-newsgroup-headers)
7611 nil 'require-match))))
7612 (or article (error "No article number"))
7614 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
7615 'gnus-number article)))
7617 (gnus-summary-show-thread)
7618 ;; Skip dummy articles.
7619 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7626 (gnus-summary-position-cursor)))))
7628 ;; Walking around summary lines with displaying articles.
7630 (defun gnus-summary-expand-window ()
7631 "Make the summary buffer take up the entire Emacs frame."
7633 (gnus-set-global-variables)
7634 (gnus-configure-windows 'summary))
7636 (defun gnus-summary-display-article (article &optional all-header)
7637 "Display ARTICLE in article buffer."
7638 (gnus-set-global-variables)
7642 (gnus-article-prepare article all-header)
7643 (gnus-summary-show-thread)
7644 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7647 (gnus-summary-position-cursor)))
7648 (run-hooks 'gnus-select-article-hook)
7649 (gnus-summary-recenter)
7650 (gnus-summary-goto-subject article)
7651 ;; Successfully display article.
7652 (gnus-summary-update-line)
7653 (gnus-article-set-window-start
7654 (cdr (assq article gnus-newsgroup-bookmarks)))
7657 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7658 "Select the current article.
7659 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7660 non-nil, the article will be re-fetched even if it already present in
7661 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7663 (and (not pseudo) (gnus-summary-pseudo-article)
7664 (error "This is a pseudo-article."))
7665 (let ((article (or article (gnus-summary-article-number)))
7666 (all-headers (not (not all-headers))) ;Must be T or NIL.
7670 (set-buffer gnus-summary-buffer)
7671 (if (or (null gnus-current-article)
7672 (null gnus-article-current)
7673 (null (get-buffer gnus-article-buffer))
7674 (not (eq article (cdr gnus-article-current)))
7675 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7677 ;; The requested article is different from the current article.
7679 (gnus-summary-display-article article all-headers)
7681 (if (or all-headers gnus-show-all-headers)
7682 (gnus-article-show-all-headers))
7685 (gnus-article-set-window-start
7686 (cdr (assq article gnus-newsgroup-bookmarks)))))))
7688 (defun gnus-summary-set-current-mark (&optional current-mark)
7689 "Obsolete function."
7692 (defun gnus-summary-next-article (unread &optional subject backward)
7693 "Select the next article.
7694 If UNREAD, only unread articles are selected.
7695 If SUBJECT, only articles with SUBJECT are selected.
7696 If BACKWARD, the previous article is selected instead of the next."
7698 (gnus-set-global-variables)
7701 ;; Is there such an article?
7702 ((gnus-summary-display-article
7703 (gnus-summary-search-forward unread subject backward))
7704 (gnus-summary-position-cursor))
7705 ;; If not, we try the first unread, if that is wanted.
7707 gnus-auto-select-same
7708 (gnus-summary-first-unread-article))
7709 (gnus-message 6 "Wrapped"))
7710 ;; Try to get next/previous article not displayed in this group.
7711 ((and gnus-auto-extend-newsgroup
7712 (not unread) (not subject)
7713 (setq header (gnus-more-header-forward backward)))
7714 (gnus-extend-newsgroup header backward)
7715 (let ((buffer-read-only nil))
7716 (goto-char (if backward (point-min) (point-max)))
7717 (gnus-summary-prepare-threads (list header) 0))
7718 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7719 gnus-newsgroup-end)))
7720 ;; Go to next/previous group.
7722 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7723 (gnus-summary-jump-to-group gnus-newsgroup-name))
7724 (let ((cmd (aref (this-command-keys) 0))
7726 (if (eq gnus-keep-same-level 'best)
7727 (gnus-summary-best-group gnus-newsgroup-name)
7728 (gnus-summary-search-group backward gnus-keep-same-level))))
7729 ;; For some reason, the group window gets selected. We change
7731 (select-window (get-buffer-window (current-buffer)))
7732 ;; Keep just the event type of CMD.
7733 (and (listp cmd) (setq cmd (car cmd)))
7734 ;; Select next unread newsgroup automagically.
7736 ((not gnus-auto-select-next)
7737 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7738 ((eq gnus-auto-select-next 'quietly)
7740 (if (assoc 'quit-config (gnus-find-method-for-group
7741 gnus-newsgroup-name))
7743 (gnus-message 7 "No more%s articles (%s)..."
7744 (if unread " unread" "")
7745 (if group (concat "selecting " group)
7747 (gnus-summary-next-group nil group backward)))
7749 (let ((keystrokes '(?\C-n ?\C-p))
7751 (while (or (null key) (memq key keystrokes))
7753 7 "No more%s articles%s" (if unread " unread" "")
7754 (if (and group (not (assoc 'quit-config
7755 (gnus-find-method-for-group
7756 gnus-newsgroup-name))))
7757 (format " (Type %s for %s [%s])"
7758 (single-key-description cmd) group
7759 (car (gnus-gethash group gnus-newsrc-hashtb)))
7760 (format " (Type %s to exit %s)"
7761 (single-key-description cmd)
7762 gnus-newsgroup-name)))
7763 ;; Confirm auto selection.
7764 (let* ((event (read-event)))
7765 (setq key (if (listp event) (car event) event))
7766 (if (memq key keystrokes)
7767 (let ((obuf (current-buffer)))
7768 (switch-to-buffer gnus-group-buffer)
7769 (gnus-group-jump-to-group group)
7770 (execute-kbd-macro (char-to-string key))
7771 (setq group (gnus-group-group-name))
7772 (switch-to-buffer obuf)))))
7774 (if (or (not group) (assoc 'quit-config
7775 (gnus-find-method-for-group
7776 gnus-newsgroup-name)))
7778 (gnus-summary-next-group nil group backward))
7779 (setq unread-command-events (list key)))))))))))
7781 (defun gnus-summary-next-unread-article ()
7782 "Select unread article after current one."
7784 (gnus-summary-next-article t (and gnus-auto-select-same
7785 (gnus-summary-subject-string))))
7787 (defun gnus-summary-prev-article (unread &optional subject)
7788 "Select the article after the current one.
7789 If UNREAD is non-nil, only unread articles are selected."
7791 (gnus-summary-next-article unread subject t))
7793 (defun gnus-summary-prev-unread-article ()
7794 "Select unred article before current one."
7796 (gnus-summary-prev-article t (and gnus-auto-select-same
7797 (gnus-summary-subject-string))))
7799 (defun gnus-summary-next-page (lines &optional circular)
7800 "Show next page of selected article.
7801 If end of article, select next article.
7802 Argument LINES specifies lines to be scrolled up.
7803 If CIRCULAR is non-nil, go to the start of the article instead of
7804 instead of selecting the next article when reaching the end of the
7807 (setq gnus-summary-buffer (current-buffer))
7808 (gnus-set-global-variables)
7809 (let ((article (gnus-summary-article-number))
7811 (gnus-configure-windows 'article)
7812 (if (or (null gnus-current-article)
7813 (null gnus-article-current)
7814 (/= article (cdr gnus-article-current))
7815 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7816 ;; Selected subject is different from current article's.
7817 (gnus-summary-display-article article)
7818 (gnus-eval-in-buffer-window
7820 (setq endp (gnus-article-next-page lines)))
7823 (gnus-summary-beginning-of-article))
7825 (gnus-message 3 "End of message"))
7827 (gnus-summary-next-unread-article)))))
7828 (gnus-summary-recenter)
7829 (gnus-summary-position-cursor)))
7831 (defun gnus-summary-prev-page (lines)
7832 "Show previous page of selected article.
7833 Argument LINES specifies lines to be scrolled down."
7835 (gnus-set-global-variables)
7836 (let ((article (gnus-summary-article-number)))
7837 (gnus-configure-windows 'article)
7838 (if (or (null gnus-current-article)
7839 (null gnus-article-current)
7840 (/= article (cdr gnus-article-current))
7841 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7842 ;; Selected subject is different from current article's.
7843 (gnus-summary-display-article article)
7844 (gnus-summary-recenter)
7845 (gnus-eval-in-buffer-window gnus-article-buffer
7846 (gnus-article-prev-page lines))))
7847 (gnus-summary-position-cursor))
7849 (defun gnus-summary-scroll-up (lines)
7850 "Scroll up (or down) one line current article.
7851 Argument LINES specifies lines to be scrolled up (or down if negative)."
7853 (gnus-set-global-variables)
7854 (gnus-configure-windows 'article)
7855 (or (gnus-summary-select-article nil nil 'pseudo)
7856 (gnus-eval-in-buffer-window
7859 (if (gnus-article-next-page lines)
7860 (gnus-message 3 "End of message")))
7862 (gnus-article-prev-page (- lines))))))
7863 (gnus-summary-recenter)
7864 (gnus-summary-position-cursor))
7866 (defun gnus-summary-next-same-subject ()
7867 "Select next article which has the same subject as current one."
7869 (gnus-set-global-variables)
7870 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7872 (defun gnus-summary-prev-same-subject ()
7873 "Select previous article which has the same subject as current one."
7875 (gnus-set-global-variables)
7876 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7878 (defun gnus-summary-next-unread-same-subject ()
7879 "Select next unread article which has the same subject as current one."
7881 (gnus-set-global-variables)
7882 (gnus-summary-next-article t (gnus-summary-subject-string)))
7884 (defun gnus-summary-prev-unread-same-subject ()
7885 "Select previous unread article which has the same subject as current one."
7887 (gnus-set-global-variables)
7888 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7890 (defun gnus-summary-first-unread-article ()
7891 "Select the first unread article.
7892 Return nil if there are no unread articles."
7894 (gnus-set-global-variables)
7896 (if (gnus-summary-first-subject t)
7897 (gnus-summary-display-article (gnus-summary-article-number)))
7898 (gnus-summary-position-cursor)))
7900 (defun gnus-summary-best-unread-article ()
7901 "Select the unread article with the highest score."
7903 (gnus-set-global-variables)
7904 (let ((scored gnus-newsgroup-scored)
7908 (or (> best (cdr (car scored)))
7909 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7910 (not (memq art gnus-newsgroup-marked))
7911 (not (memq art gnus-newsgroup-dormant))
7912 (if (= best (cdr (car scored)))
7913 (setq article (min art article))
7915 (setq best (cdr (car scored))))))
7916 (setq scored (cdr scored)))
7918 (gnus-summary-goto-article article)
7919 (gnus-summary-first-unread-article))
7920 (gnus-summary-position-cursor)))
7922 (defun gnus-summary-goto-article (article &optional all-headers)
7923 "Fetch ARTICLE and display it if it exists.
7924 If ALL-HEADERS is non-nil, no header lines are hidden."
7930 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7931 gnus-newsgroup-headers)
7932 nil 'require-match))))
7934 (and (gnus-summary-goto-subject article)
7935 (gnus-summary-display-article article all-headers))
7936 (gnus-summary-position-cursor)))
7938 (defun gnus-summary-goto-last-article ()
7939 "Go to the previously read article."
7942 (and gnus-last-article
7943 (gnus-summary-goto-article gnus-last-article))
7944 (gnus-summary-position-cursor)))
7946 (defun gnus-summary-pop-article (number)
7947 "Pop one article off the history and go to the previous.
7948 NUMBER articles will be popped off."
7951 (setq gnus-newsgroup-history
7952 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7954 (gnus-summary-goto-article (car to))
7955 (error "Article history empty")))
7956 (gnus-summary-position-cursor))
7958 ;; Summary article oriented commands
7960 (defun gnus-summary-refer-parent-article (n)
7961 "Refer parent article N times.
7962 The difference between N and the number of articles fetched is returned."
7964 (gnus-set-global-variables)
7968 (let ((ref (header-references (gnus-get-header-by-number
7969 (gnus-summary-article-number)))))
7970 (if (and ref (not (equal ref ""))
7971 (string-match "<[^<>]*>[ \t]*$" ref))
7972 (gnus-summary-refer-article
7973 (substring ref (match-beginning 0) (match-end 0)))
7974 (gnus-message 1 "No references in article %d"
7975 (gnus-summary-article-number))
7978 (gnus-summary-position-cursor)
7981 (defun gnus-summary-refer-article (message-id)
7982 "Refer article specified by MESSAGE-ID.
7983 NOTE: This command only works with newsgroups that use real or simulated NNTP."
7984 (interactive "sMessage-ID: ")
7985 (if (or (not (stringp message-id))
7986 (zerop (length message-id)))
7988 ;; Construct the correct Message-ID if necessary.
7989 ;; Suggested by tale@pawl.rpi.edu.
7990 (or (string-match "^<" message-id)
7991 (setq message-id (concat "<" message-id)))
7992 (or (string-match ">$" message-id)
7993 (setq message-id (concat message-id ">")))
7994 (let ((header (car (gnus-gethash (downcase message-id)
7995 gnus-newsgroup-dependencies))))
7997 (or (gnus-summary-goto-article (header-number header))
7998 ;; The header has been read, but the article had been
7999 ;; expunged, so we insert it again.
8001 (gnus-summary-insert-line
8002 nil header 0 nil gnus-read-mark nil nil
8003 (header-subject header))
8005 (header-number header)))
8006 (let ((gnus-override-method gnus-refer-article-method)
8007 (gnus-ancient-mark gnus-read-mark)
8008 (tmp-point (window-start
8009 (get-buffer-window gnus-article-buffer)))
8011 (and gnus-refer-article-method
8012 (or (gnus-server-opened gnus-refer-article-method)
8013 (gnus-open-server gnus-refer-article-method)))
8014 ;; Save the old article buffer.
8016 (set-buffer gnus-article-buffer)
8017 (gnus-kill-buffer " *temp Article*")
8018 (setq tmp-buf (rename-buffer " *temp Article*")))
8020 (if (gnus-article-prepare
8021 message-id nil (gnus-read-header message-id))
8023 (setq number (header-number gnus-current-headers))
8024 (gnus-rebuild-thread message-id)
8025 (gnus-summary-goto-subject number)
8026 (gnus-summary-recenter)
8027 (gnus-article-set-window-start
8028 (cdr (assq number gnus-newsgroup-bookmarks)))
8030 ;; We restore the old article buffer.
8032 (kill-buffer gnus-article-buffer)
8033 (set-buffer tmp-buf)
8034 (rename-buffer gnus-article-buffer)
8035 (let ((buffer-read-only nil))
8037 (set-window-start (get-buffer-window (current-buffer))
8038 tmp-point)))))))))))
8040 (defun gnus-summary-enter-digest-group ()
8041 "Enter a digest group based on the current article."
8043 (gnus-set-global-variables)
8044 (gnus-summary-select-article)
8045 ;; We do not want a narrowed article.
8046 (gnus-summary-stop-page-breaking)
8047 (let ((name (format "%s-%d"
8048 (gnus-group-prefixed-name
8049 gnus-newsgroup-name (list 'nndoc ""))
8050 gnus-current-article))
8051 (ogroup gnus-newsgroup-name)
8052 (buf (current-buffer)))
8053 (if (gnus-group-read-ephemeral-group
8054 name (list 'nndoc name
8055 (list 'nndoc-address (get-buffer gnus-article-buffer))
8056 '(nndoc-article-type digest))
8058 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8059 (list (list (cons 'to-group ogroup))))
8060 (switch-to-buffer buf)
8061 (gnus-set-global-variables)
8062 (gnus-configure-windows 'summary)
8063 (gnus-message 3 "Article not a digest?"))))
8065 (defun gnus-summary-isearch-article ()
8066 "Do incremental search forward on current article."
8068 (gnus-set-global-variables)
8069 (gnus-summary-select-article)
8070 (gnus-eval-in-buffer-window
8071 gnus-article-buffer (isearch-forward)))
8073 (defun gnus-summary-search-article-forward (regexp &optional backward)
8074 "Search for an article containing REGEXP forward.
8075 If BACKWARD, search backward instead."
8078 (format "Search article %s (regexp%s): "
8079 (if current-prefix-arg "backward" "forward")
8080 (if gnus-last-search-regexp
8081 (concat ", default " gnus-last-search-regexp)
8083 current-prefix-arg))
8084 (gnus-set-global-variables)
8085 (if (string-equal regexp "")
8086 (setq regexp (or gnus-last-search-regexp ""))
8087 (setq gnus-last-search-regexp regexp))
8088 (if (gnus-summary-search-article regexp backward)
8089 (gnus-article-set-window-start
8090 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8091 (error "Search failed: \"%s\"" regexp)))
8093 (defun gnus-summary-search-article-backward (regexp)
8094 "Search for an article containing REGEXP backward."
8097 (format "Search article backward (regexp%s): "
8098 (if gnus-last-search-regexp
8099 (concat ", default " gnus-last-search-regexp)
8101 (gnus-summary-search-article-forward regexp 'backward))
8103 (defun gnus-summary-search-article (regexp &optional backward)
8104 "Search for an article containing REGEXP.
8105 Optional argument BACKWARD means do search for backward.
8106 gnus-select-article-hook is not called during the search."
8107 (let ((gnus-select-article-hook nil) ;Disable hook.
8108 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8111 (function re-search-backward) (function re-search-forward)))
8114 ;; Hidden thread subtrees must be searched for ,too.
8115 (gnus-summary-show-all-threads)
8116 (if (eobp) (forward-line -1))
8117 ;; First of all, search current article.
8118 ;; We don't want to read article again from NNTP server nor reset
8120 (gnus-summary-select-article)
8121 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8122 (setq last gnus-current-article)
8123 (gnus-eval-in-buffer-window gnus-article-buffer
8126 ;; Begin search from current point.
8127 (setq found (funcall re-search regexp nil t))))
8128 ;; Then search next articles.
8129 (while (and (not found)
8130 (gnus-summary-display-article
8131 (gnus-summary-search-subject backward nil nil)))
8132 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8133 (gnus-eval-in-buffer-window gnus-article-buffer
8136 (goto-char (if backward (point-max) (point-min)))
8137 (setq found (funcall re-search regexp nil t)))))
8139 ;; Adjust article pointer.
8140 (or (eq last gnus-current-article)
8141 (setq gnus-last-article last))
8142 ;; Return T if found such article.
8145 (defun gnus-summary-execute-command (header regexp command &optional backward)
8146 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8147 If HEADER is an empty string (or nil), the match is done on the entire
8148 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8150 (list (let ((completion-ignore-case t))
8153 (mapcar (lambda (string) (list string))
8154 '("Number" "Subject" "From" "Lines" "Date"
8155 "Message-ID" "Xref" "References"))
8156 nil 'require-match))
8157 (read-string "Regexp: ")
8158 (read-key-sequence "Command: ")
8159 current-prefix-arg))
8160 (gnus-set-global-variables)
8161 ;; Hidden thread subtrees must be searched as well.
8162 (gnus-summary-show-all-threads)
8163 ;; We don't want to change current point nor window configuration.
8165 (save-window-excursion
8166 (gnus-message 6 "Executing %s..." (key-description command))
8167 ;; We'd like to execute COMMAND interactively so as to give arguments.
8168 (gnus-execute header regexp
8170 (call-interactively '(, (key-binding command)))))
8172 (gnus-message 6 "Executing %s...done" (key-description command)))))
8174 (defun gnus-summary-beginning-of-article ()
8175 "Scroll the article back to the beginning."
8177 (gnus-set-global-variables)
8178 (gnus-summary-select-article)
8179 (gnus-configure-windows 'article)
8180 (gnus-eval-in-buffer-window
8183 (goto-char (point-min))
8184 (and gnus-break-pages (gnus-narrow-to-page))))
8186 (defun gnus-summary-end-of-article ()
8187 "Scroll to the end of the article."
8189 (gnus-set-global-variables)
8190 (gnus-summary-select-article)
8191 (gnus-configure-windows 'article)
8192 (gnus-eval-in-buffer-window
8195 (goto-char (point-max))
8196 (and gnus-break-pages (gnus-narrow-to-page))))
8198 (defun gnus-summary-show-article (no-refetch)
8199 "Force re-fetching of the current article.
8200 If the prefix argument NO-REFETCH is non-nil, no actual refetch will
8201 be performed. The current article will simply be redisplayed."
8203 (gnus-set-global-variables)
8204 (if (not no-refetch)
8205 (gnus-summary-select-article gnus-have-all-headers t)
8206 (or gnus-current-article
8207 (error "There is no current article"))
8208 (gnus-summary-goto-subject gnus-current-article)
8209 (gnus-configure-windows 'article)
8210 (gnus-summary-position-cursor)))
8212 (defun gnus-summary-verbose-headers (arg)
8213 "Toggle permanent full header display.
8214 If ARG is a positive number, turn header display on.
8215 If ARG is a negative number, turn header display off."
8217 (gnus-set-global-variables)
8218 (gnus-summary-toggle-header arg)
8219 (setq gnus-have-all-headers
8220 (cond ((or (not (numberp arg))
8222 (not gnus-have-all-headers))
8226 (defun gnus-summary-toggle-header (arg)
8227 "Show the headers if they are hidden, or hide them if they are shown.
8228 If ARG is a positive number, show the entire header.
8229 If ARG is a negative number, hide the unwanted header lines."
8231 (gnus-set-global-variables)
8233 (set-buffer gnus-article-buffer)
8234 (let ((buffer-read-only nil))
8236 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8237 gnus-hidden-properties)
8238 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8239 (if (text-property-any (point-min) (point-max) 'invisible t)
8240 (remove-text-properties (point-min) (point-max)
8241 gnus-hidden-properties)
8242 (let ((gnus-have-all-headers nil))
8243 (run-hooks 'gnus-article-display-hook))))
8244 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8246 (defun gnus-summary-show-all-headers ()
8247 "Make all header lines visible."
8249 (gnus-set-global-variables)
8250 (gnus-article-show-all-headers))
8252 (defun gnus-summary-toggle-mime (arg)
8253 "Toggle MIME processing.
8254 If ARG is a positive number, turn MIME processing on."
8256 (gnus-set-global-variables)
8257 (setq gnus-show-mime
8258 (if (null arg) (not gnus-show-mime)
8259 (> (prefix-numeric-value arg) 0)))
8260 (gnus-summary-select-article t 'force))
8262 (defun gnus-summary-caesar-message (arg)
8263 "Caesar rotate the current article by 13.
8264 The numerical prefix specifies how manu places to rotate each letter
8267 (gnus-set-global-variables)
8268 (gnus-summary-select-article)
8269 (let ((mail-header-separator ""))
8270 (gnus-eval-in-buffer-window
8274 (let ((last (point)))
8275 (news-caesar-buffer-body arg)
8279 (defun gnus-summary-stop-page-breaking ()
8280 "Stop page breaking in the current article."
8282 (gnus-set-global-variables)
8283 (gnus-summary-select-article)
8284 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8286 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8288 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
8289 "Move the current article to a different newsgroup.
8290 If N is a positive number, move the N next articles.
8291 If N is a negative number, move the N previous articles.
8292 If N is nil and any articles have been marked with the process mark,
8293 move those articles instead.
8294 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8295 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8296 re-spool using this method.
8297 For this function to work, both the current newsgroup and the
8298 newsgroup that you want to move to have to support the `request-move'
8299 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8301 (gnus-set-global-variables)
8302 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8303 (error "The current newsgroup does not support article moving"))
8304 (let ((articles (gnus-summary-work-articles n))
8305 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8306 art-group to-method sel-met)
8307 (if (and (not to-newsgroup) (not select-method))
8310 (format "Where do you want to move %s? %s"
8311 (if (> (length articles) 1)
8312 (format "these %d articles" (length articles))
8314 (if gnus-current-move-group
8315 (format "(%s default) " gnus-current-move-group)
8317 gnus-active-hashtb nil nil prefix)))
8320 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8321 (setq to-newsgroup (or gnus-current-move-group "")))
8322 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8323 (gnus-activate-newsgroup to-newsgroup)
8324 (error "No such group: %s" to-newsgroup))
8325 (setq gnus-current-move-group to-newsgroup)))
8326 (setq to-method (if select-method (list select-method "")
8327 (gnus-find-method-for-group to-newsgroup)))
8328 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8329 (error "%s does not support article copying" (car to-method)))
8330 (or (gnus-server-opened to-method)
8331 (gnus-open-server to-method)
8332 (error "Can't open server %s" (car to-method)))
8333 (gnus-message 6 "Moving to %s: %s..."
8334 (or select-method to-newsgroup) articles)
8337 (gnus-request-move-article
8338 (car articles) ; Article to move
8339 gnus-newsgroup-name ; From newsgrouo
8340 (nth 1 (gnus-find-method-for-group
8341 gnus-newsgroup-name)) ; Server
8342 (list 'gnus-request-accept-article
8344 (list 'quote select-method)
8346 (not (cdr articles))) ; Accept form
8347 (not (cdr articles)))) ; Only save nov last time
8348 (let* ((buffer-read-only nil)
8351 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8353 (gnus-group-prefixed-name
8355 (if select-method (list select-method "")
8356 (gnus-find-method-for-group to-newsgroup)))
8357 gnus-newsrc-hashtb)))
8358 (info (nth 2 entry))
8359 (article (car articles)))
8360 (gnus-summary-goto-subject article)
8362 (delete-region (point)
8363 (progn (forward-line 1) (point)))
8364 (if (not (memq article gnus-newsgroup-unreads))
8365 (setcar (cdr (cdr info))
8366 (gnus-add-to-range (nth 2 info)
8367 (list (cdr art-group)))))
8368 ;; Copy any marks over to the new group.
8369 (let ((marks '((tick . gnus-newsgroup-marked)
8370 (dormant . gnus-newsgroup-dormant)
8371 (expire . gnus-newsgroup-expirable)
8372 (bookmark . gnus-newsgroup-bookmarks)
8373 ; (score . gnus-newsgroup-scored)
8374 (reply . gnus-newsgroup-replied)))
8375 (to-article (cdr art-group)))
8377 (if (memq article (symbol-value (cdr (car marks))))
8378 (gnus-add-marked-articles
8379 (car info) (car (car marks)) (list to-article) info))
8380 (setq marks (cdr marks))))
8381 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8382 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8383 (setq gnus-newsgroup-dormant
8384 (delq article gnus-newsgroup-dormant)))
8385 (gnus-message 1 "Couldn't move article %s" (car articles)))
8386 (gnus-summary-remove-process-mark (car articles))
8387 (setq articles (cdr articles)))))
8389 (defun gnus-summary-respool-article (n &optional respool-method)
8390 "Respool the current article.
8391 The article will be squeezed through the mail spooling process again,
8392 which means that it will be put in some mail newsgroup or other
8393 depending on `nnmail-split-methods'.
8394 If N is a positive number, respool the N next articles.
8395 If N is a negative number, respool the N previous articles.
8396 If N is nil and any articles have been marked with the process mark,
8397 respool those articles instead.
8399 Respooling can be done both from mail groups and \"real\" newsgroups.
8400 In the former case, the articles in question will be moved from the
8401 current group into whatever groups they are destined to. In the
8402 latter case, they will be copied into the relevant groups."
8404 (gnus-set-global-variables)
8405 (let ((respool-methods (gnus-methods-using 'respool))
8407 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8409 (setq respool-method
8411 "What method do you want to use when respooling? "
8412 respool-methods nil t methname)))
8413 (or (string= respool-method "")
8414 (if (assoc (symbol-name
8415 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8417 (gnus-summary-move-article n nil (intern respool-method))
8418 (gnus-summary-copy-article n nil (intern respool-method))))))
8420 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8421 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
8422 "Move the current article to a different newsgroup.
8423 If N is a positive number, move the N next articles.
8424 If N is a negative number, move the N previous articles.
8425 If N is nil and any articles have been marked with the process mark,
8426 move those articles instead.
8427 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8428 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8429 re-spool using this method.
8430 For this function to work, the newsgroup that you want to move to have
8431 to support the `request-move' and `request-accept'
8432 functions. (Ie. mail newsgroups at present.)"
8434 (gnus-set-global-variables)
8435 (let ((articles (gnus-summary-work-articles n))
8436 (copy-buf (get-buffer-create "*copy work*"))
8437 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8438 art-group to-method)
8439 (buffer-disable-undo copy-buf)
8440 (if (and (not to-newsgroup) (not select-method))
8443 (format "Where do you want to copy %s? %s"
8444 (if (> (length articles) 1)
8445 (format "these %d articles" (length articles))
8447 (if gnus-current-move-group
8448 (format "(%s default) " gnus-current-move-group)
8450 gnus-active-hashtb nil nil prefix)))
8453 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8454 (setq to-newsgroup (or gnus-current-move-group "")))
8455 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8456 (gnus-activate-newsgroup to-newsgroup)
8457 (error "No such group: %s" to-newsgroup))
8458 (setq gnus-current-move-group to-newsgroup)))
8459 (setq to-method (if select-method (list select-method "")
8460 (gnus-find-method-for-group to-newsgroup)))
8461 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8462 (error "%s does not support article copying" (car to-method)))
8463 (or (gnus-server-opened to-method)
8464 (gnus-open-server to-method)
8465 (error "Can't open server %s" (car to-method)))
8466 (gnus-message 6 "Copying to %s: %s..."
8467 (or select-method to-newsgroup) articles)
8471 (set-buffer copy-buf)
8472 (gnus-request-article-this-buffer
8473 (car articles) gnus-newsgroup-name)
8474 (gnus-request-accept-article
8475 (if select-method (quote select-method) to-newsgroup)
8476 (not (cdr articles)))))
8479 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8481 (gnus-group-prefixed-name
8483 (if select-method (list select-method "")
8484 (gnus-find-method-for-group to-newsgroup)))
8485 gnus-newsrc-hashtb)))
8486 (info (nth 2 entry))
8487 (article (car articles)))
8488 (if (not (memq article gnus-newsgroup-unreads))
8489 (setcar (cdr (cdr info))
8490 (gnus-add-to-range (nth 2 info)
8491 (list (cdr art-group)))))
8492 ;; Copy any marks over to the new group.
8493 (let ((marks '((tick . gnus-newsgroup-marked)
8494 (dormant . gnus-newsgroup-dormant)
8495 (expire . gnus-newsgroup-expirable)
8496 (bookmark . gnus-newsgroup-bookmarks)
8497 ; (score . gnus-newsgroup-scored)
8498 (reply . gnus-newsgroup-replied)))
8499 (to-article (cdr art-group)))
8501 (if (memq article (symbol-value (cdr (car marks))))
8502 (gnus-add-marked-articles
8503 (car info) (car (car marks)) (list to-article) info))
8504 (setq marks (cdr marks)))))
8505 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8506 (gnus-summary-remove-process-mark (car articles))
8507 (setq articles (cdr articles)))
8508 (kill-buffer copy-buf)))
8510 (defun gnus-summary-import-article (file)
8511 "Import a random file into a mail newsgroup."
8512 (interactive "fImport file: ")
8513 (let ((group gnus-newsgroup-name)
8515 (or (gnus-check-backend-function 'request-accept-article group)
8516 (error "%s does not support article importing" group))
8517 (or (file-readable-p file)
8518 (not (file-regular-p file))
8519 (error "Can't read %s" file))
8521 (set-buffer (get-buffer-create " *import file*"))
8522 (buffer-disable-undo (current-buffer))
8524 (insert-file-contents file)
8525 (goto-char (point-min))
8526 (if (nnheader-article-p)
8528 (setq atts (file-attributes file))
8529 (insert "From: " (read-string "From: ") "\n"
8530 "Subject: " (read-string "Subject: ") "\n"
8531 "Date: " (current-time-string (nth 5 atts)) "\n"
8532 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8533 (gnus-request-accept-article group t)
8534 (kill-buffer (current-buffer)))))
8536 (defun gnus-summary-expire-articles ()
8537 "Expire all articles that are marked as expirable in the current group."
8539 (if (and gnus-newsgroup-expirable
8540 (gnus-check-backend-function
8541 'request-expire-articles gnus-newsgroup-name))
8542 (let ((expirable gnus-newsgroup-expirable))
8543 (gnus-message 6 "Expiring articles...")
8544 ;; The list of articles that weren't expired is returned.
8545 (setq gnus-newsgroup-expirable
8546 (gnus-request-expire-articles gnus-newsgroup-expirable
8547 gnus-newsgroup-name))
8548 ;; We go through the old list of expirable, and mark all
8549 ;; really expired articles as non-existent.
8551 (or (memq (car expirable) gnus-newsgroup-expirable)
8552 (gnus-summary-mark-as-read (car expirable) gnus-canceled-mark))
8553 (setq expirable (cdr expirable)))
8554 (gnus-message 6 "Expiring articles...done"))))
8557 (defun gnus-summary-expire-articles-now ()
8558 "Expunge all expirable articles in the current group.
8559 This means that *all* articles that are marked as expirable will be
8560 deleted forever, right now."
8562 (or gnus-expert-user
8564 "Are you really, really, really sure you want to expunge? ")
8566 (let ((nnmail-expiry-wait -1)
8567 (nnmail-expiry-wait-function nil))
8568 (gnus-summary-expire-articles)))
8570 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8571 (defun gnus-summary-delete-article (n)
8572 "Delete the N next (mail) articles.
8573 This command actually deletes articles. This is not a marking
8574 command. The article will disappear forever from you life, never to
8576 If N is negative, delete backwards.
8577 If N is nil and articles have been marked with the process mark,
8578 delete these instead."
8580 (or (gnus-check-backend-function 'request-expire-articles
8581 gnus-newsgroup-name)
8582 (error "The current newsgroup does not support article deletion."))
8583 ;; Compute the list of articles to delete.
8584 (let ((articles (gnus-summary-work-articles n))
8586 (if (and gnus-novice-user
8588 (format "Do you really want to delete %s forever? "
8589 (if (> (length articles) 1) "these articles"
8592 ;; Delete the articles.
8593 (setq not-deleted (gnus-request-expire-articles
8594 articles gnus-newsgroup-name 'force))
8596 (gnus-summary-remove-process-mark (car articles))
8597 ;; The backend might not have been able to delete the article
8599 (or (memq (car articles) not-deleted)
8600 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
8601 (setq articles (cdr articles))))
8602 (gnus-summary-position-cursor)
8605 (defun gnus-summary-edit-article ()
8606 "Enter into a buffer and edit the current article.
8607 This will have permanent effect only in mail groups."
8609 (or (gnus-check-backend-function
8610 'request-replace-article gnus-newsgroup-name)
8611 (error "The current newsgroup does not support article editing."))
8612 (gnus-summary-select-article t)
8613 (gnus-configure-windows 'article)
8614 (select-window (get-buffer-window gnus-article-buffer))
8615 (gnus-message 6 "C-c C-c to end edits")
8616 (setq buffer-read-only nil)
8618 (use-local-map (copy-keymap (current-local-map)))
8619 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8620 (buffer-enable-undo)
8621 (goto-char (point-min))
8622 (search-forward "\n\n" nil t))
8624 (defun gnus-summary-edit-article-done ()
8625 "Make edits to the current article permanent."
8627 (if (not (gnus-request-replace-article
8628 (cdr gnus-article-current) (car gnus-article-current)
8630 (error "Couldn't replace article.")
8632 (use-local-map gnus-article-mode-map)
8633 (setq buffer-read-only t)
8634 (buffer-disable-undo (current-buffer))
8635 (pop-to-buffer gnus-summary-buffer)))
8637 (defun gnus-summary-fancy-query ()
8638 "Query where the fancy respool algorithm would put this article."
8640 (gnus-summary-select-article)
8642 (set-buffer gnus-article-buffer)
8644 (goto-char (point-min))
8645 (search-forward "\n\n")
8646 (narrow-to-region (point-min) (point))
8647 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8649 ;; Summary score commands.
8651 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8653 (defun gnus-summary-raise-score (n)
8654 "Raise the score of the current article by N."
8656 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8658 (defun gnus-summary-lower-score (n)
8659 "Lower the score of the current article by N."
8661 (gnus-summary-raise-score (- n)))
8663 (defun gnus-summary-set-score (n)
8664 "Set the score of the current article to N."
8666 ;; Skip dummy header line.
8668 (gnus-summary-show-thread)
8669 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8671 (let ((buffer-read-only nil))
8673 (gnus-summary-update-mark
8674 (if (= n (or gnus-summary-default-score 0)) ?
8675 (if (< n (or gnus-summary-default-score 0))
8676 gnus-score-below-mark gnus-score-over-mark)) 'score))
8677 (let* ((article (gnus-summary-article-number))
8678 (score (assq article gnus-newsgroup-scored)))
8679 (if score (setcdr score n)
8680 (setq gnus-newsgroup-scored
8681 (cons (cons article n) gnus-newsgroup-scored))))
8682 (gnus-summary-update-line)))
8684 (defun gnus-summary-current-score ()
8685 "Return the score of the current article."
8687 (message "%s" (gnus-summary-article-score)))
8689 ;; Summary marking commands.
8691 (defun gnus-summary-raise-same-subject-and-select (score)
8692 "Raise articles which has the same subject with SCORE and select the next."
8694 (let ((subject (gnus-summary-subject-string)))
8695 (gnus-summary-raise-score score)
8696 (while (gnus-summary-search-subject nil nil subject)
8697 (gnus-summary-raise-score score))
8698 (gnus-summary-next-article t)))
8700 (defun gnus-summary-raise-same-subject (score)
8701 "Raise articles which has the same subject with SCORE."
8703 (let ((subject (gnus-summary-subject-string)))
8704 (gnus-summary-raise-score score)
8705 (while (gnus-summary-search-subject nil nil subject)
8706 (gnus-summary-raise-score score))
8707 (gnus-summary-next-subject 1 t)))
8709 (defun gnus-score-default (level)
8710 (if level (prefix-numeric-value level)
8711 gnus-score-interactive-default-score))
8713 (defun gnus-summary-raise-thread (score)
8714 "Raise the score of the articles in the current thread with SCORE."
8716 (setq score (1- (gnus-score-default score)))
8719 (let ((level (gnus-summary-thread-level)))
8720 (gnus-summary-raise-score score)
8721 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8722 (> (gnus-summary-thread-level) level))
8723 (gnus-summary-raise-score score))
8725 (let ((gnus-summary-check-current t))
8726 (or (zerop (gnus-summary-next-subject 1 t))
8728 (gnus-summary-recenter)
8729 (gnus-summary-position-cursor)
8730 (gnus-set-mode-line 'summary))
8732 (defun gnus-summary-lower-same-subject-and-select (score)
8733 "Raise articles which has the same subject with SCORE and select the next."
8735 (gnus-summary-raise-same-subject-and-select (- score)))
8737 (defun gnus-summary-lower-same-subject (score)
8738 "Raise articles which has the same subject with SCORE."
8740 (gnus-summary-raise-same-subject (- score)))
8742 (defun gnus-summary-lower-thread (score)
8743 "Lower score of articles in the current thread with SCORE."
8745 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8747 (defun gnus-summary-kill-same-subject-and-select (unmark)
8748 "Mark articles which has the same subject as read, and then select the next.
8749 If UNMARK is positive, remove any kind of mark.
8750 If UNMARK is negative, tick articles."
8753 (setq unmark (prefix-numeric-value unmark)))
8755 (gnus-summary-mark-same-subject
8756 (gnus-summary-subject-string) unmark)))
8757 ;; Select next unread article. If auto-select-same mode, should
8758 ;; select the first unread article.
8759 (gnus-summary-next-article t (and gnus-auto-select-same
8760 (gnus-summary-subject-string)))
8761 (gnus-message 7 "%d articles are marked as %s"
8762 count (if unmark "unread" "read"))))
8764 (defun gnus-summary-kill-same-subject (unmark)
8765 "Mark articles which has the same subject as read.
8766 If UNMARK is positive, remove any kind of mark.
8767 If UNMARK is negative, tick articles."
8770 (setq unmark (prefix-numeric-value unmark)))
8772 (gnus-summary-mark-same-subject
8773 (gnus-summary-subject-string) unmark)))
8774 ;; If marked as read, go to next unread subject.
8776 ;; Go to next unread subject.
8777 (gnus-summary-next-subject 1 t))
8778 (gnus-message 7 "%d articles are marked as %s"
8779 count (if unmark "unread" "read"))))
8781 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8782 "Mark articles with same SUBJECT as read, and return marked number.
8783 If optional argument UNMARK is positive, remove any kinds of marks.
8784 If optional argument UNMARK is negative, mark articles as unread instead."
8787 (cond ((null unmark)
8788 (gnus-summary-mark-as-read nil gnus-killed-mark))
8790 (gnus-summary-tick-article nil t))
8792 (gnus-summary-tick-article)))
8794 (gnus-summary-search-forward nil subject))
8795 (cond ((null unmark)
8796 (gnus-summary-mark-as-read nil gnus-killed-mark))
8798 (gnus-summary-tick-article nil t))
8800 (gnus-summary-tick-article)))
8801 (setq count (1+ count))))
8802 ;; Hide killed thread subtrees. Does not work properly always.
8803 ;;(and (null unmark)
8804 ;; gnus-thread-hide-killed
8805 ;; (gnus-summary-hide-thread))
8806 ;; Return number of articles marked as read.
8809 (defun gnus-summary-mark-as-processable (n &optional unmark)
8810 "Set the process mark on the next N articles.
8811 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8812 the process mark instead. The difference between N and the actual
8813 number of articles marked is returned."
8815 (let ((backward (< n 0))
8820 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8821 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8822 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8824 (if (/= 0 n) (gnus-message 7 "No more articles"))
8825 (gnus-summary-recenter)
8826 (gnus-summary-position-cursor)
8829 (defun gnus-summary-unmark-as-processable (n)
8830 "Remove the process mark from the next N articles.
8831 If N is negative, mark backward instead. The difference between N and
8832 the actual number of articles marked is returned."
8834 (gnus-summary-mark-as-processable n t))
8836 (defun gnus-summary-unmark-all-processable ()
8837 "Remove the process mark from all articles."
8840 (while gnus-newsgroup-processable
8841 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8842 (gnus-summary-position-cursor))
8844 (defun gnus-summary-mark-as-expirable (n)
8845 "Mark N articles forward as expirable.
8846 If N is negative, mark backward instead. The difference between N and
8847 the actual number of articles marked is returned."
8849 (gnus-summary-mark-forward n gnus-expirable-mark))
8851 (defun gnus-summary-mark-article-as-replied (article)
8852 "Mark ARTICLE replied and update the summary line."
8853 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8854 (let ((buffer-read-only nil))
8855 (if (gnus-summary-goto-subject article)
8857 (gnus-summary-update-mark gnus-replied-mark 'replied)
8860 (defun gnus-summary-set-bookmark (article)
8861 "Set a bookmark in current article."
8862 (interactive (list (gnus-summary-article-number)))
8863 (if (or (not (get-buffer gnus-article-buffer))
8864 (not gnus-current-article)
8865 (not gnus-article-current)
8866 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8867 (error "No current article selected"))
8868 ;; Remove old bookmark, if one exists.
8869 (let ((old (assq article gnus-newsgroup-bookmarks)))
8870 (if old (setq gnus-newsgroup-bookmarks
8871 (delq old gnus-newsgroup-bookmarks))))
8872 ;; Set the new bookmark, which is on the form
8873 ;; (article-number . line-number-in-body).
8874 (setq gnus-newsgroup-bookmarks
8878 (set-buffer gnus-article-buffer)
8882 (goto-char (point-min))
8883 (search-forward "\n\n" nil t)
8886 gnus-newsgroup-bookmarks))
8887 (gnus-message 6 "A bookmark has been added to the current article."))
8889 (defun gnus-summary-remove-bookmark (article)
8890 "Remove the bookmark from the current article."
8891 (interactive (list (gnus-summary-article-number)))
8892 ;; Remove old bookmark, if one exists.
8893 (let ((old (assq article gnus-newsgroup-bookmarks)))
8896 (setq gnus-newsgroup-bookmarks
8897 (delq old gnus-newsgroup-bookmarks))
8898 (gnus-message 6 "Removed bookmark."))
8899 (gnus-message 6 "No bookmark in current article."))))
8901 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8902 (defun gnus-summary-mark-as-dormant (n)
8903 "Mark N articles forward as dormant.
8904 If N is negative, mark backward instead. The difference between N and
8905 the actual number of articles marked is returned."
8907 (gnus-summary-mark-forward n gnus-dormant-mark))
8909 (defun gnus-summary-set-process-mark (article)
8910 "Set the process mark on ARTICLE and update the summary line."
8911 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8912 (let ((buffer-read-only nil))
8913 (if (gnus-summary-goto-subject article)
8915 (gnus-summary-show-thread)
8916 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8918 (gnus-summary-update-mark gnus-process-mark 'replied)
8921 (defun gnus-summary-remove-process-mark (article)
8922 "Remove the process mark from ARTICLE and update the summary line."
8923 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8924 (let ((buffer-read-only nil))
8925 (if (gnus-summary-goto-subject article)
8927 (gnus-summary-show-thread)
8928 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8930 (gnus-summary-update-mark ? 'replied)
8931 (if (memq article gnus-newsgroup-replied)
8932 (gnus-summary-update-mark gnus-replied-mark 'replied))
8935 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8936 "Mark N articles as read forwards.
8937 If N is negative, mark backwards instead.
8938 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8940 The difference between N and the actual number of articles marked is
8943 (gnus-set-global-variables)
8944 (let ((backward (< n 0))
8946 (mark (or mark gnus-del-mark)))
8948 (gnus-summary-mark-article nil mark no-expire)
8949 (zerop (gnus-summary-next-subject
8950 (if backward -1 1) gnus-summary-goto-unread t)))
8952 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8953 (gnus-summary-recenter)
8954 (gnus-summary-position-cursor)
8955 (gnus-set-mode-line 'summary)
8958 (defun gnus-summary-mark-article (&optional article mark no-expire)
8959 "Mark ARTICLE with MARK.
8960 MARK can be any character.
8961 Five MARK strings are reserved: ? (unread),
8962 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8963 If MARK is nil, then the default character ?D is used.
8964 If ARTICLE is nil, then the article on the current line will be
8966 ;; If no mark is given, then we check auto-expiring.
8967 (and (not no-expire)
8968 gnus-newsgroup-auto-expire
8971 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
8972 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
8973 (= mark gnus-read-mark))))
8974 (setq mark gnus-expirable-mark))
8975 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8976 (article (or article (gnus-summary-article-number))))
8977 (or article (error "No article on current line"))
8978 (if (or (= mark gnus-unread-mark)
8979 (= mark gnus-ticked-mark)
8980 (= mark gnus-dormant-mark))
8981 (gnus-mark-article-as-unread article mark)
8982 (gnus-mark-article-as-read article mark))
8984 ;; See whether the article is to be put in the cache.
8986 (not (= mark gnus-canceled-mark))
8988 (gnus-cache-possibly-enter-article
8989 gnus-newsgroup-name article
8990 (gnus-get-header-by-number article)
8991 (= mark gnus-ticked-mark)
8992 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8994 (if (gnus-summary-goto-subject article)
8995 (let ((buffer-read-only nil))
8996 (gnus-summary-show-thread)
8997 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9000 (gnus-summary-update-mark mark 'unread)
9003 (defun gnus-summary-update-mark (mark type)
9005 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9009 (forward-char forward)
9010 (setq plist (text-properties-at (point)))
9013 (and plist (add-text-properties (1- (point)) (point) plist))
9014 (and (eq type 'unread)
9015 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9016 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9018 (defun gnus-mark-article-as-read (article &optional mark)
9019 "Enter ARTICLE in the pertinent lists and remove it from others."
9020 ;; Make the article expirable.
9021 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
9022 (if (= mark gnus-expirable-mark)
9023 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9024 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9025 ;; Remove from unread and marked lists.
9026 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9027 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9028 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9029 ;; Possibly remove from cache, if that is used.
9030 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9032 (defun gnus-mark-article-as-unread (article &optional mark)
9033 "Enter ARTICLE in the pertinent lists and remove it from others."
9034 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
9035 ;; Add to unread list.
9036 (or (memq article gnus-newsgroup-unreads)
9037 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9038 ;; If CLEAR-MARK is non-nil, the article must be removed from mark
9039 ;; lists. Otherwise, it must be added to the list.
9040 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9041 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9042 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9043 (if (= mark gnus-ticked-mark)
9044 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9045 (if (= mark gnus-dormant-mark)
9046 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9048 (defalias 'gnus-summary-mark-as-unread-forward
9049 'gnus-summary-tick-article-forward)
9050 (make-obsolete 'gnus-summary-mark-as-unread-forward
9051 'gnus-summary-tick-article-forward)
9052 (defun gnus-summary-tick-article-forward (n)
9053 "Tick N articles forwards.
9054 If N is negative, tick backwards instead.
9055 The difference between N and the number of articles ticked is returned."
9057 (gnus-summary-mark-forward n gnus-ticked-mark))
9059 (defalias 'gnus-summary-mark-as-unread-backward
9060 'gnus-summary-tick-article-backward)
9061 (make-obsolete 'gnus-summary-mark-as-unread-backward
9062 'gnus-summary-tick-article-backward)
9063 (defun gnus-summary-tick-article-backward (n)
9064 "Tick N articles backwards.
9065 The difference between N and the number of articles ticked is returned."
9067 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9069 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9070 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9071 (defun gnus-summary-tick-article (&optional article clear-mark)
9072 "Mark current article as unread.
9073 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9074 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9075 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9078 (defun gnus-summary-mark-as-read-forward (n)
9079 "Mark N articles as read forwards.
9080 If N is negative, mark backwards instead.
9081 The difference between N and the actual number of articles marked is
9084 (gnus-summary-mark-forward n gnus-del-mark t))
9086 (defun gnus-summary-mark-as-read-backward (n)
9087 "Mark the N articles as read backwards.
9088 The difference between N and the actual number of articles marked is
9091 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9093 (defun gnus-summary-mark-as-read (&optional article mark)
9094 "Mark current article as read.
9095 ARTICLE specifies the article to be marked as read.
9096 MARK specifies a string to be inserted at the beginning of the line."
9097 (gnus-summary-mark-article article mark))
9099 (defun gnus-summary-clear-mark-forward (n)
9100 "Clear marks from N articles forward.
9101 If N is negative, clear backward instead.
9102 The difference between N and the number of marks cleared is returned."
9104 (gnus-summary-mark-forward n gnus-unread-mark))
9106 (defun gnus-summary-clear-mark-backward (n)
9107 "Clear marks from N articles backward.
9108 The difference between N and the number of marks cleared is returned."
9110 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9112 (defun gnus-summary-mark-unread-as-read ()
9113 "Intended to be used by `gnus-summary-mark-article-hook'."
9114 (or (memq gnus-current-article gnus-newsgroup-marked)
9115 (memq gnus-current-article gnus-newsgroup-dormant)
9116 (memq gnus-current-article gnus-newsgroup-expirable)
9117 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
9119 (defun gnus-summary-mark-region-as-read (point mark all)
9120 "Mark all unread articles between point and mark as read.
9121 If given a prefix, mark all articles between point and mark as read,
9122 even ticked and dormant ones."
9123 (interactive "r\nP")
9133 (not (memq (gnus-summary-article-number)
9134 gnus-newsgroup-marked))
9135 (not (memq (gnus-summary-article-number)
9136 gnus-newsgroup-dormant))))
9137 (gnus-summary-mark-article
9138 (gnus-summary-article-number) gnus-del-mark))
9140 (zerop (forward-line 1))))))
9142 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9143 (defalias 'gnus-summary-delete-marked-as-read
9144 'gnus-summary-remove-lines-marked-as-read)
9145 (make-obsolete 'gnus-summary-delete-marked-as-read
9146 'gnus-summary-remove-lines-marked-as-read)
9147 (defun gnus-summary-remove-lines-marked-as-read ()
9148 "Remove lines that are marked as read."
9150 (gnus-summary-remove-lines-marked-with
9152 (lambda (char) (char-to-string (symbol-value char)))
9153 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9154 gnus-killed-mark gnus-kill-file-mark
9155 gnus-low-score-mark gnus-expirable-mark
9159 (defalias 'gnus-summary-delete-marked-with
9160 'gnus-summary-remove-lines-marked-with)
9161 (make-obsolete 'gnus-summary-delete-marked-with
9162 'gnus-summary-remove-lines-marked-with)
9163 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9164 (defun gnus-summary-remove-lines-marked-with (marks)
9165 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9166 (interactive "sMarks: ")
9167 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9168 (gnus-set-global-variables)
9169 (let ((buffer-read-only nil)
9170 (marks (concat "^[" marks "]")))
9171 (goto-char (point-min))
9172 (if gnus-newsgroup-adaptive
9173 (gnus-score-remove-lines-adaptive marks)
9174 (while (re-search-forward marks nil t)
9175 (gnus-delete-line)))
9176 ;; If we use dummy roots, we have to do an additional sweep over
9178 (if (not (eq gnus-summary-make-false-root 'dummy))
9180 (goto-char (point-min))
9181 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9182 (while (re-search-forward marks nil t)
9183 (if (gnus-subject-equal
9184 (gnus-summary-subject-string)
9187 (gnus-summary-subject-string)))
9190 (gnus-delete-line)))))
9191 (or (zerop (buffer-size))
9193 (gnus-summary-prev-subject 1)
9194 (gnus-summary-position-cursor))))
9196 (defun gnus-summary-expunge-below (score)
9197 "Remove articles with score less than SCORE."
9199 (gnus-set-global-variables)
9200 (setq score (if score
9201 (prefix-numeric-value score)
9202 (or gnus-summary-default-score 0)))
9204 (set-buffer gnus-summary-buffer)
9205 (goto-char (point-min))
9206 (let ((buffer-read-only nil)
9209 (if (< (gnus-summary-article-score) score)
9213 (delete-region beg (point)))
9216 (or (zerop (buffer-size))
9218 (gnus-summary-prev-subject 1)
9219 (gnus-summary-position-cursor))))))
9221 (defun gnus-summary-mark-below (score mark)
9222 "Mark articles with score less than SCORE with MARK."
9223 (interactive "P\ncMark: ")
9224 (gnus-set-global-variables)
9225 (setq score (if score
9226 (prefix-numeric-value score)
9227 (or gnus-summary-default-score 0)))
9229 (set-buffer gnus-summary-buffer)
9230 (goto-char (point-min))
9232 (and (< (gnus-summary-article-score) score)
9233 (gnus-summary-mark-article nil mark))
9236 (defun gnus-summary-kill-below (score)
9237 "Mark articles with score below SCORE as read."
9239 (gnus-summary-mark-below score gnus-killed-mark))
9241 (defun gnus-summary-clear-above (score)
9242 "Clear all marks from articles with score above SCORE."
9244 (gnus-summary-mark-above score gnus-unread-mark))
9246 (defun gnus-summary-tick-above (score)
9247 "Tick all articles with score above SCORE."
9249 (gnus-summary-mark-above score gnus-ticked-mark))
9251 (defun gnus-summary-mark-above (score mark)
9252 "Mark articles with score over SCORE with MARK."
9253 (interactive "P\ncMark: ")
9254 (setq score (if score
9255 (prefix-numeric-value score)
9256 (or gnus-summary-default-score 0)))
9258 (set-buffer gnus-summary-buffer)
9259 (goto-char (point-min))
9261 (if (> (gnus-summary-article-score) score)
9263 (gnus-summary-mark-article nil mark)
9265 (forward-line 1)))))
9267 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9268 (defun gnus-summary-show-all-expunged ()
9269 "Display all the hidden articles that were expunged for low scores."
9271 (let ((buffer-read-only nil))
9272 (let ((scored gnus-newsgroup-scored)
9275 (or (gnus-summary-goto-subject (car (car scored)))
9276 (and (setq h (gnus-get-header-by-number (car (car scored))))
9277 (< (cdr (car scored)) gnus-summary-expunge-below)
9278 (setq headers (cons h headers))))
9279 (setq scored (cdr scored)))
9280 (or headers (error "No expunged articles hidden."))
9281 (goto-char (point-min))
9283 (gnus-summary-update-lines
9286 (gnus-summary-prepare-threads (nreverse headers) 0)
9288 (goto-char (point-min))
9289 (gnus-summary-position-cursor)))
9291 (defun gnus-summary-show-all-dormant ()
9292 "Display all the hidden articles that are marked as dormant."
9294 (let ((buffer-read-only nil))
9295 (let ((dormant gnus-newsgroup-dormant)
9298 (or (gnus-summary-goto-subject (car dormant))
9299 (and (setq h (gnus-get-header-by-number (car dormant)))
9300 (setq headers (cons h headers))))
9301 (setq dormant (cdr dormant)))
9302 (or headers (error "No dormant articles hidden."))
9303 (goto-char (point-min))
9305 (gnus-summary-update-lines
9308 (gnus-summary-prepare-threads (nreverse headers) 0)
9310 (goto-char (point-min))
9311 (gnus-summary-position-cursor)))
9313 (defun gnus-summary-hide-all-dormant ()
9314 "Hide all dormant articles."
9316 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9317 (gnus-summary-position-cursor))
9319 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
9320 "Mark all articles not marked as unread in this newsgroup as read.
9321 If prefix argument ALL is non-nil, all articles are marked as read.
9322 If QUIETLY is non-nil, no questions will be asked.
9323 If TO-HERE is non-nil, it should be a point in the buffer. All
9324 articles before this point will be marked as read.
9325 The number of articles marked as read is returned."
9329 (not gnus-interactive-catchup) ;Without confirmation?
9333 "Mark absolutely all articles as read? "
9334 "Mark all unread articles as read? ")))
9336 (not gnus-newsgroup-adaptive)
9337 (not gnus-newsgroup-auto-expire))
9339 (and all (setq gnus-newsgroup-marked nil
9340 gnus-newsgroup-dormant nil))
9341 (setq gnus-newsgroup-unreads
9342 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9343 ;; We actually mark all articles as canceled, which we
9344 ;; have to do when using auto-expiry or adaptive scoring.
9345 (let ((unreads (length gnus-newsgroup-unreads)))
9346 (if (gnus-summary-first-subject (not all))
9347 (while (and (if to-here (< (point) to-here) t)
9348 (gnus-summary-mark-as-read nil gnus-catchup-mark)
9349 (gnus-summary-search-subject nil (not all)))))
9350 (- unreads (length gnus-newsgroup-unreads))
9352 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9353 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9354 (if (and (not to-here) (eq 'nnvirtual (car method)))
9355 (nnvirtual-catchup-group
9356 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9357 (gnus-summary-position-cursor)))
9359 (defun gnus-summary-catchup-to-here (&optional all)
9360 "Mark all unticked articles before the current one as read.
9361 If ALL is non-nil, also mark ticked and dormant articles as read."
9364 (and (zerop (forward-line -1))
9367 (gnus-summary-catchup all t (point))
9368 (gnus-set-mode-line 'summary))))
9369 (gnus-summary-position-cursor))
9371 (defun gnus-summary-catchup-all (&optional quietly)
9372 "Mark all articles in this newsgroup as read."
9374 (gnus-summary-catchup t quietly))
9376 (defun gnus-summary-catchup-and-exit (all &optional quietly)
9377 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9378 If prefix argument ALL is non-nil, all articles are marked as read."
9380 (gnus-summary-catchup all quietly nil 'fast)
9381 ;; Select next newsgroup or exit.
9382 (if (eq gnus-auto-select-next 'quietly)
9383 (gnus-summary-next-group nil)
9384 (gnus-summary-exit)))
9386 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9387 "Mark all articles in this newsgroup as read, and then exit."
9389 (gnus-summary-catchup-and-exit t quietly))
9391 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9392 (defun gnus-summary-catchup-and-goto-next-group (all)
9393 "Mark all articles in this group as read and select the next group.
9394 If given a prefix, mark all articles, unread as well as ticked, as
9397 (gnus-summary-catchup all)
9398 (gnus-summary-next-group))
9400 ;; Thread-based commands.
9402 (defun gnus-summary-toggle-threads (arg)
9403 "Toggle showing conversation threads.
9404 If ARG is positive number, turn showing conversation threads on."
9406 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9407 (setq gnus-show-threads
9408 (if (null arg) (not gnus-show-threads)
9409 (> (prefix-numeric-value arg) 0)))
9410 (gnus-summary-prepare)
9411 (gnus-summary-goto-subject current)
9412 (gnus-summary-position-cursor)))
9414 (defun gnus-summary-show-all-threads ()
9418 (let ((buffer-read-only nil))
9419 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9420 (gnus-summary-position-cursor))
9422 (defun gnus-summary-show-thread ()
9423 "Show thread subtrees.
9424 Returns nil if no thread was there to be shown."
9428 (let ((buffer-read-only nil)
9429 ;; first goto end then to beg, to have point at beg after let
9430 (end (progn (end-of-line) (point)))
9431 (beg (progn (beginning-of-line) (point))))
9433 ;; Any hidden lines here?
9434 (search-forward "\r" end t)
9435 (subst-char-in-region beg end ?\^M ?\n t))))
9436 (gnus-summary-position-cursor)))
9438 (defun gnus-summary-hide-all-threads ()
9439 "Hide all thread subtrees."
9442 (goto-char (point-min))
9443 (gnus-summary-hide-thread)
9444 (while (and (not (eobp)) (zerop (forward-line 1)))
9445 (gnus-summary-hide-thread)))
9446 (gnus-summary-position-cursor))
9448 (defun gnus-summary-hide-thread ()
9449 "Hide thread subtrees.
9450 Returns nil if no threads were there to be hidden."
9452 (let ((buffer-read-only nil)
9454 (level (gnus-summary-thread-level))
9456 ;; Go forward until either the buffer ends or the subthread
9460 (while (and (zerop (forward-line 1))
9461 (> (gnus-summary-thread-level) level))
9466 (search-backward "\n" start t))
9467 (subst-char-in-region start end ?\n ?\^M t)
9468 (forward-line -1)))))
9470 (defun gnus-summary-go-to-next-thread (&optional previous)
9471 "Go to the same level (or less) next thread.
9472 If PREVIOUS is non-nil, go to previous thread instead.
9473 Return the article number moved to, or nil if moving was impossible."
9474 (let ((level (gnus-summary-thread-level))
9475 (article (gnus-summary-article-number)))
9477 (while (and (zerop (forward-line -1))
9478 (> (gnus-summary-thread-level) level)))
9479 (while (and (save-excursion
9482 (zerop (forward-line 1))
9483 (> (gnus-summary-thread-level) level))))
9484 (gnus-summary-recenter)
9485 (gnus-summary-position-cursor)
9486 (let ((oart (gnus-summary-article-number)))
9487 (and (/= oart article) oart))))
9489 (defun gnus-summary-next-thread (n)
9490 "Go to the same level next N'th thread.
9491 If N is negative, search backward instead.
9492 Returns the difference between N and the number of skips actually
9495 (let ((backward (< n 0))
9498 (gnus-summary-go-to-next-thread backward))
9500 (gnus-summary-position-cursor)
9501 (if (/= 0 n) (gnus-message 7 "No more threads"))
9504 (defun gnus-summary-prev-thread (n)
9505 "Go to the same level previous N'th thread.
9506 Returns the difference between N and the number of skips actually
9509 (gnus-summary-next-thread (- n)))
9511 (defun gnus-summary-go-down-thread (&optional same)
9512 "Go down one level in the current thread.
9513 If SAME is non-nil, also move to articles of the same level."
9514 (let ((level (gnus-summary-thread-level))
9516 (if (and (zerop (forward-line 1))
9517 (> (gnus-summary-thread-level) level))
9522 (defun gnus-summary-go-up-thread ()
9523 "Go up one level in the current thread."
9524 (let ((level (gnus-summary-thread-level))
9526 (while (and (zerop (forward-line -1))
9527 (>= (gnus-summary-thread-level) level)))
9528 (if (>= (gnus-summary-thread-level) level)
9534 (defun gnus-summary-down-thread (n)
9535 "Go down thread N steps.
9536 If N is negative, go up instead.
9537 Returns the difference between N and how many steps down that were
9543 (if up (gnus-summary-go-up-thread)
9544 (gnus-summary-go-down-thread)))
9546 (gnus-summary-position-cursor)
9547 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9550 (defun gnus-summary-up-thread (n)
9551 "Go up thread N steps.
9552 If N is negative, go up instead.
9553 Returns the difference between N and how many steps down that were
9556 (gnus-summary-down-thread (- n)))
9558 (defun gnus-summary-kill-thread (unmark)
9559 "Mark articles under current thread as read.
9560 If the prefix argument is positive, remove any kinds of marks.
9561 If the prefix argument is negative, tick articles instead."
9564 (setq unmark (prefix-numeric-value unmark)))
9566 (level (gnus-summary-thread-level)))
9569 ;; Mark the article...
9570 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
9571 ((> unmark 0) (gnus-summary-tick-article nil t))
9572 (t (gnus-summary-tick-article)))
9573 ;; ...and go forward until either the buffer ends or the subtree
9575 (if (not (and (zerop (forward-line 1))
9576 (> (gnus-summary-thread-level) level)))
9577 (setq killing nil))))
9578 ;; Hide killed subtrees.
9580 gnus-thread-hide-killed
9581 (gnus-summary-hide-thread))
9582 ;; If marked as read, go to next unread subject.
9584 ;; Go to next unread subject.
9585 (gnus-summary-next-subject 1 t)))
9586 (gnus-set-mode-line 'summary))
9588 ;; Summary sorting commands
9590 (defun gnus-summary-sort-by-number (&optional reverse)
9591 "Sort summary buffer by article number.
9592 Argument REVERSE means reverse order."
9595 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9597 (defun gnus-summary-sort-by-author (&optional reverse)
9598 "Sort summary buffer by author name alphabetically.
9599 If case-fold-search is non-nil, case of letters is ignored.
9600 Argument REVERSE means reverse order."
9605 (let ((extract (funcall
9606 gnus-extract-address-components
9607 (header-from (gnus-get-header-by-number
9608 (gnus-summary-article-number))))))
9609 (or (car extract) (cdr extract))))
9610 'gnus-thread-sort-by-author)
9613 (defun gnus-summary-sort-by-subject (&optional reverse)
9614 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9615 If case-fold-search is non-nil, case of letters is ignored.
9616 Argument REVERSE means reverse order."
9621 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9622 'gnus-thread-sort-by-subject)
9625 (defun gnus-summary-sort-by-date (&optional reverse)
9626 "Sort summary buffer by date.
9627 Argument REVERSE means reverse order."
9634 (gnus-get-header-by-number (gnus-summary-article-number)))))
9635 'gnus-thread-sort-by-date)
9638 (defun gnus-summary-sort-by-score (&optional reverse)
9639 "Sort summary buffer by score.
9640 Argument REVERSE means reverse order."
9643 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9646 (defvar gnus-summary-already-sorted nil)
9647 (defun gnus-summary-sort (predicate reverse)
9648 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9649 (if gnus-summary-already-sorted
9651 (let (buffer-read-only)
9652 (if (not gnus-show-threads)
9654 (goto-char (point-min))
9655 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9656 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9657 (gnus-summary-prepare-hook nil)
9658 (gnus-summary-already-sorted nil))
9659 (gnus-summary-prepare)
9660 (and gnus-show-threads
9661 gnus-thread-hide-subtree
9662 (gnus-summary-hide-all-threads))
9663 ;; If in async mode, we send some info to the backend.
9664 (and gnus-newsgroup-async
9665 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
9666 (gnus-request-asynchronous
9668 (if (and gnus-asynchronous-article-function
9669 (fboundp gnus-asynchronous-article-function))
9670 (funcall gnus-asynchronous-article-function
9671 gnus-newsgroup-threads)))))))))
9674 (defun gnus-sortable-date (date)
9675 "Make sortable string by string-lessp from DATE.
9676 Timezone package is used."
9677 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9678 (year (aref date 0))
9679 (month (aref date 1))
9680 (day (aref date 2)))
9681 (timezone-make-sortable-date
9683 (timezone-make-time-string
9684 (aref date 3) (aref date 4) (aref date 5)))))
9687 ;; Summary saving commands.
9689 (defun gnus-summary-save-article (n)
9690 "Save the current article using the default saver function.
9691 If N is a positive number, save the N next articles.
9692 If N is a negative number, save the N previous articles.
9693 If N is nil and any articles have been marked with the process mark,
9694 save those articles instead.
9695 The variable `gnus-default-article-saver' specifies the saver function."
9697 (let ((articles (gnus-summary-work-articles n)))
9699 (let ((header (gnus-get-header-by-number (car articles))))
9700 (if (vectorp header)
9702 (gnus-summary-select-article t nil nil (car articles))
9703 (or gnus-save-all-headers
9704 (gnus-article-hide-headers t))
9705 ;; Remove any X-Gnus lines.
9708 (set-buffer gnus-article-buffer)
9709 (let ((buffer-read-only nil))
9710 (goto-char (point-min))
9711 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9713 (while (re-search-forward "^X-Gnus" nil t)
9715 (delete-region (point)
9716 (progn (forward-line 1) (point))))
9719 (if gnus-default-article-saver
9720 (funcall gnus-default-article-saver)
9721 (error "No default saver is defined."))))
9722 (if (assq 'name header)
9723 (gnus-copy-file (cdr (assq 'name header)))
9724 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9725 (gnus-summary-remove-process-mark (car articles))
9726 (setq articles (cdr articles)))
9727 (gnus-summary-position-cursor)
9730 (defun gnus-summary-pipe-output (arg)
9731 "Pipe the current article to a subprocess.
9732 If N is a positive number, pipe the N next articles.
9733 If N is a negative number, pipe the N previous articles.
9734 If N is nil and any articles have been marked with the process mark,
9735 pipe those articles instead."
9737 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9738 (gnus-summary-save-article arg)))
9740 (defun gnus-summary-save-article-mail (arg)
9741 "Append the current article to an mail file.
9742 If N is a positive number, save the N next articles.
9743 If N is a negative number, save the N previous articles.
9744 If N is nil and any articles have been marked with the process mark,
9745 save those articles instead."
9747 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9748 (gnus-summary-save-article arg)))
9750 (defun gnus-summary-save-article-rmail (arg)
9751 "Append the current article to an rmail file.
9752 If N is a positive number, save the N next articles.
9753 If N is a negative number, save the N previous articles.
9754 If N is nil and any articles have been marked with the process mark,
9755 save those articles instead."
9757 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9758 (gnus-summary-save-article arg)))
9760 (defun gnus-summary-save-article-file (arg)
9761 "Append the current article to a file.
9762 If N is a positive number, save the N next articles.
9763 If N is a negative number, save the N previous articles.
9764 If N is nil and any articles have been marked with the process mark,
9765 save those articles instead."
9767 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9768 (gnus-summary-save-article arg)))
9770 (defun gnus-read-save-file-name (prompt default-name)
9771 (let ((methods gnus-split-methods)
9773 (if (not gnus-split-methods)
9776 (set-buffer gnus-article-buffer)
9777 (gnus-narrow-to-headers)
9779 (goto-char (point-min))
9780 (and (condition-case ()
9781 (re-search-forward (car (car methods)) nil t)
9783 (setq split-name (cons (nth 1 (car methods)) split-name)))
9784 (setq methods (cdr methods)))
9786 (cond ((null split-name)
9788 (concat prompt " (default "
9789 (file-name-nondirectory default-name) ") ")
9790 (file-name-directory default-name)
9792 ((= 1 (length split-name))
9794 (concat prompt " (default " (car split-name) ") ")
9795 gnus-article-save-directory
9796 (concat gnus-article-save-directory (car split-name))))
9798 (setq split-name (mapcar (lambda (el) (list el))
9799 (nreverse split-name)))
9800 (let ((result (completing-read
9802 split-name nil nil)))
9803 (concat gnus-article-save-directory
9804 (if (string= result "")
9805 (car (car split-name))
9808 (defun gnus-summary-save-in-rmail (&optional filename)
9809 "Append this article to Rmail file.
9810 Optional argument FILENAME specifies file name.
9811 Directory to save to is default to `gnus-article-save-directory' which
9812 is initialized from the SAVEDIR environment variable."
9815 (funcall gnus-rmail-save-name gnus-newsgroup-name
9816 gnus-current-headers gnus-newsgroup-last-rmail)))
9818 (setq filename (gnus-read-save-file-name
9819 "Save in rmail file:" default-name)))
9820 (gnus-make-directory (file-name-directory filename))
9821 (gnus-eval-in-buffer-window
9826 (gnus-output-to-rmail filename))))
9827 ;; Remember the directory name to save articles.
9828 (setq gnus-newsgroup-last-rmail filename)))
9830 (defun gnus-summary-save-in-mail (&optional filename)
9831 "Append this article to Unix mail file.
9832 Optional argument FILENAME specifies file name.
9833 Directory to save to is default to `gnus-article-save-directory' which
9834 is initialized from the SAVEDIR environment variable."
9837 (funcall gnus-mail-save-name gnus-newsgroup-name
9838 gnus-current-headers gnus-newsgroup-last-mail)))
9840 (setq filename (gnus-read-save-file-name
9841 "Save in Unix mail file:" default-name)))
9843 (expand-file-name filename
9845 (file-name-directory default-name))))
9846 (gnus-make-directory (file-name-directory filename))
9847 (gnus-eval-in-buffer-window
9852 (if (and (file-readable-p filename) (rmail-file-p filename))
9853 (gnus-output-to-rmail filename)
9854 (rmail-output filename 1 t t)))))
9855 ;; Remember the directory name to save articles.
9856 (setq gnus-newsgroup-last-mail filename)))
9858 (defun gnus-summary-save-in-file (&optional filename)
9859 "Append this article to file.
9860 Optional argument FILENAME specifies file name.
9861 Directory to save to is default to `gnus-article-save-directory' which
9862 is initialized from the SAVEDIR environment variable."
9865 (funcall gnus-file-save-name gnus-newsgroup-name
9866 gnus-current-headers gnus-newsgroup-last-file)))
9868 (setq filename (gnus-read-save-file-name
9869 "Save in file:" default-name)))
9870 (gnus-make-directory (file-name-directory filename))
9871 (gnus-eval-in-buffer-window
9876 (gnus-output-to-file filename))))
9877 ;; Remember the directory name to save articles.
9878 (setq gnus-newsgroup-last-file filename)))
9880 (defun gnus-summary-save-in-pipe (&optional command)
9881 "Pipe this article to subprocess."
9883 (let ((command (read-string "Shell command on article: "
9884 gnus-last-shell-command)))
9885 (if (string-equal command "")
9886 (setq command gnus-last-shell-command))
9887 (gnus-eval-in-buffer-window
9891 (shell-command-on-region (point-min) (point-max) command nil)))
9892 (setq gnus-last-shell-command command)))
9894 ;; Summary extract commands
9896 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9897 (let ((buffer-read-only nil)
9898 (article (gnus-summary-article-number))
9900 (or (gnus-summary-goto-subject article)
9901 (error (format "No such article: %d" article)))
9902 (or gnus-newsgroup-headers-hashtb-by-number
9903 (gnus-make-headers-hashtable-by-number))
9904 (gnus-summary-position-cursor)
9905 ;; If all commands are to be bunched up on one line, we collect
9907 (if gnus-view-pseudos-separately
9909 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9912 (setq action (cdr (assq 'action (car ps))))
9913 (setq files (list (cdr (assq 'name (car ps)))))
9914 (while (and ps (cdr ps)
9915 (string= (or action "1")
9916 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9917 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9918 (setcdr ps (cdr (cdr ps))))
9921 (if (not (string-match "%s" action))
9922 (setq files (cons " " files)))
9923 (setq files (cons " " files))
9924 (and (assq 'execute (car ps))
9925 (setcdr (assq 'execute (car ps))
9926 (funcall (if (string-match "%s" action)
9929 (mapconcat (lambda (f) f) files " ")))))
9930 (setq ps (cdr ps)))))
9931 (if (and gnus-view-pseudos (not not-view))
9933 (and (assq 'execute (car pslist))
9934 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9935 (eq gnus-view-pseudos 'not-confirm)))
9936 (setq pslist (cdr pslist)))
9939 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9940 (gnus-summary-article-number)))
9943 (insert " " (file-name-nondirectory
9944 (cdr (assq 'name (car pslist))))
9945 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9946 (add-text-properties
9947 b (1+ b) (list 'gnus-number gnus-reffed-article-number
9948 'gnus-mark gnus-unread-mark
9950 'gnus-pseudo (car pslist)))
9952 (gnus-sethash (int-to-string gnus-reffed-article-number)
9953 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9954 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9955 (setq pslist (cdr pslist)))))))
9957 (defun gnus-pseudos< (p1 p2)
9958 (let ((c1 (cdr (assq 'action p1)))
9959 (c2 (cdr (assq 'action p2))))
9960 (and c1 c2 (string< c1 c2))))
9962 (defun gnus-request-pseudo-article (props)
9963 (cond ((assq 'execute props)
9964 (gnus-execute-command (cdr (assq 'execute props)))))
9965 (let ((gnus-current-article (gnus-summary-article-number)))
9966 (run-hooks 'gnus-mark-article-hook)))
9968 (defun gnus-execute-command (command &optional automatic)
9970 (gnus-article-setup-buffer)
9971 (set-buffer gnus-article-buffer)
9972 (let ((command (if automatic command (read-string "Command: " command)))
9973 (buffer-read-only nil))
9975 (insert "$ " command "\n\n")
9976 (if gnus-view-pseudo-asynchronously
9977 (start-process "gnus-execute" nil "sh" "-c" command)
9978 (call-process "sh" nil t nil "-c" command)))))
9980 (defun gnus-copy-file (file &optional to)
9983 (list (read-file-name "Copy file: " default-directory)
9984 (read-file-name "Copy file to: " default-directory)))
9985 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9986 (and (file-directory-p to)
9987 (setq to (concat (file-name-as-directory to)
9988 (file-name-nondirectory file))))
9989 (copy-file file to))
9991 ;; Summary kill commands.
9993 (defun gnus-summary-edit-global-kill (article)
9994 "Edit the \"global\" kill file."
9995 (interactive (list (gnus-summary-article-number)))
9996 (gnus-group-edit-global-kill article))
9998 (defun gnus-summary-edit-local-kill ()
9999 "Edit a local kill file applied to the current newsgroup."
10001 (setq gnus-current-headers
10003 (int-to-string (gnus-summary-article-number))
10004 gnus-newsgroup-headers-hashtb-by-number))
10005 (gnus-set-global-variables)
10006 (gnus-group-edit-local-kill
10007 (gnus-summary-article-number) gnus-newsgroup-name))
10011 ;;; Gnus article mode
10014 (put 'gnus-article-mode 'mode-class 'special)
10016 (if gnus-article-mode-map
10018 (setq gnus-article-mode-map (make-keymap))
10019 (suppress-keymap gnus-article-mode-map)
10020 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10021 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10022 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10023 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10024 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10025 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10026 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10027 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10028 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10029 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10030 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10031 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10033 ;; Duplicate almost all summary keystrokes in the article mode map.
10036 " " "\177" "p" "N" "P" "\M-\C-n" "\M-\C-p"
10037 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j" "^" "\M-^"
10038 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10039 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10040 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10041 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10042 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10043 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10044 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10045 "\C-c\C-i" "x" "X" "s" "t" "g" "?" "l"
10046 "\C-c\C-v\C-v" "\C-d" "v"
10047 ;; "Mt" "M!" "Md" "Mr"
10048 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10049 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10050 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10051 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10052 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10053 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10054 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10055 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10056 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10057 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10058 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10061 (define-key gnus-article-mode-map (car commands)
10062 'gnus-article-summary-command)
10063 (setq commands (cdr commands))))
10065 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10066 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10069 (define-key gnus-article-mode-map (car commands)
10070 'gnus-article-summary-command-nosave)
10071 (setq commands (cdr commands)))))
10074 (defun gnus-article-mode ()
10075 "Major mode for displaying an article.
10077 All normal editing commands are switched off.
10079 The following commands are available:
10081 \\<gnus-article-mode-map>
10082 \\[gnus-article-next-page]\t Scroll the article one page forwards
10083 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10084 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10085 \\[gnus-article-show-summary]\t Display the summary buffer
10086 \\[gnus-article-mail]\t Send a reply to the address near point
10087 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10088 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10089 \\[gnus-info-find-node]\t Go to the Gnus info node"
10091 (if gnus-visual (gnus-article-make-menu-bar))
10092 (kill-all-local-variables)
10093 (setq mode-line-modified "-- ")
10094 (make-local-variable 'mode-line-format)
10095 (setq mode-line-format (copy-sequence mode-line-format))
10096 (and (equal (nth 3 mode-line-format) " ")
10097 (setcar (nthcdr 3 mode-line-format) ""))
10098 (setq mode-name "Article")
10099 (setq major-mode 'gnus-article-mode)
10100 (make-local-variable 'minor-mode-alist)
10101 (or (assq 'gnus-show-mime minor-mode-alist)
10102 (setq minor-mode-alist
10103 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10104 (use-local-map gnus-article-mode-map)
10105 (make-local-variable 'page-delimiter)
10106 (setq page-delimiter gnus-page-delimiter)
10107 (buffer-disable-undo (current-buffer))
10108 (setq buffer-read-only t) ;Disable modification
10109 (run-hooks 'gnus-article-mode-hook))
10111 (defun gnus-article-setup-buffer ()
10112 "Initialize article mode buffer."
10113 (if (get-buffer gnus-article-buffer)
10115 (set-buffer gnus-article-buffer)
10116 (buffer-disable-undo (current-buffer))
10117 (setq buffer-read-only t)
10118 (gnus-add-current-to-buffer-list)
10119 (or (eq major-mode 'gnus-article-mode)
10120 (gnus-article-mode)))
10122 (set-buffer (get-buffer-create gnus-article-buffer))
10123 (gnus-add-current-to-buffer-list)
10124 (gnus-article-mode))))
10126 ;; Set article window start at LINE, where LINE is the number of lines
10127 ;; from the head of the article.
10128 (defun gnus-article-set-window-start (&optional line)
10130 (get-buffer-window gnus-article-buffer)
10132 (set-buffer gnus-article-buffer)
10133 (goto-char (point-min))
10136 (gnus-message 6 "Moved to bookmark")
10137 (search-forward "\n\n" nil t)
10138 (forward-line line)
10141 (defun gnus-request-article-this-buffer (article group)
10142 "Get an article and insert it into this buffer."
10143 (setq group (or group gnus-newsgroup-name))
10145 ;; Open server if it has closed.
10146 (gnus-check-news-server (gnus-find-method-for-group group))
10148 ;; Using `gnus-request-article' directly will insert the article into
10149 ;; `nntp-server-buffer' - so we'll save some time by not having to
10150 ;; copy it from the server buffer into the article buffer.
10152 ;; We only request an article by message-id when we do not have the
10153 ;; headers for it, so we'll have to get those.
10154 (and (stringp article)
10155 (let ((gnus-override-method gnus-refer-article-method))
10156 (gnus-read-header article)))
10158 ;; If the article number is negative, that means that this article
10159 ;; doesn't belong in this newsgroup (possibly), so we find its
10160 ;; message-id and request it by id instead of number.
10161 (if (not (numberp article))
10164 (set-buffer gnus-summary-buffer)
10165 (let ((header (gnus-get-header-by-number article)))
10167 (if (vectorp header)
10168 ;; It's a real article.
10169 (setq article (header-id header))
10170 ;; It is an extracted pseudo-article.
10171 (setq article 'pseudo)
10172 (gnus-request-pseudo-article header)))
10174 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10175 (if (not (eq (car method) 'nneething))
10177 (let ((dir (concat (file-name-as-directory (nth 1 method))
10178 (header-subject header))))
10179 (if (file-directory-p dir)
10181 (setq article 'nneething)
10182 (gnus-group-enter-directory dir)))))))))
10184 ;; Check the cache.
10185 (if (and gnus-use-cache
10187 (gnus-cache-request-article article group))
10189 ;; Get the article and into the article buffer.
10190 (if (or (stringp article) (numberp article))
10193 (let ((gnus-override-method
10194 (and (stringp article) gnus-refer-article-method)))
10195 (and (gnus-request-article article group (current-buffer))
10199 (defun gnus-read-header (id)
10200 "Read the headers of article ID and enter them into the Gnus system."
10201 (or gnus-newsgroup-headers-hashtb-by-number
10202 (gnus-make-headers-hashtable-by-number))
10204 (if (not (setq header
10205 (car (if (let ((gnus-nov-is-evil t))
10206 (gnus-retrieve-headers
10207 (list id) gnus-newsgroup-name))
10208 (gnus-get-newsgroup-headers)))))
10211 (header-set-number header gnus-reffed-article-number))
10212 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10213 (gnus-sethash (int-to-string (header-number header)) header
10214 gnus-newsgroup-headers-hashtb-by-number)
10216 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10217 (setq gnus-current-headers header)
10220 (defun gnus-article-prepare (article &optional all-headers header)
10221 "Prepare ARTICLE in article mode buffer.
10222 ARTICLE should either be an article number or a Message-ID.
10223 If ARTICLE is an id, HEADER should be the article headers.
10224 If ALL-HEADERS is non-nil, no headers are hidden."
10226 ;; Make sure we start in a summary buffer.
10227 (or (eq major-mode 'gnus-summary-mode)
10228 (set-buffer gnus-summary-buffer))
10229 (setq gnus-summary-buffer (current-buffer))
10230 ;; Make sure the connection to the server is alive.
10231 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10233 (gnus-check-news-server
10234 (gnus-find-method-for-group gnus-newsgroup-name))
10235 (gnus-request-group gnus-newsgroup-name t)))
10236 (or gnus-newsgroup-headers-hashtb-by-number
10237 (gnus-make-headers-hashtable-by-number))
10238 (let* ((article (if header (header-number header) article))
10239 (summary-buffer (current-buffer))
10240 (internal-hook gnus-article-internal-prepare-hook)
10241 (group gnus-newsgroup-name)
10244 (gnus-article-setup-buffer)
10245 (set-buffer gnus-article-buffer)
10246 (if (not (setq result (let ((buffer-read-only nil))
10247 (gnus-request-article-this-buffer
10249 ;; There is no such article.
10251 (if (not (numberp article))
10253 (setq gnus-article-current
10254 (cons gnus-newsgroup-name article))
10255 (set-buffer gnus-summary-buffer)
10256 (setq gnus-current-article article)
10257 (gnus-summary-mark-as-read article gnus-canceled-mark))
10258 (gnus-message 1 "No such article (may be canceled)")
10261 (if (or (eq result 'pseudo) (eq result 'nneething))
10264 (set-buffer summary-buffer)
10265 (setq gnus-last-article gnus-current-article
10266 gnus-newsgroup-history (cons gnus-current-article
10267 gnus-newsgroup-history)
10268 gnus-current-article 0
10269 gnus-current-headers nil
10270 gnus-article-current nil)
10271 (if (eq result 'nneething)
10272 (gnus-configure-windows 'summary)
10273 (gnus-configure-windows 'article))
10274 (gnus-set-global-variables))
10275 (gnus-set-mode-line 'article))
10276 ;; The result from the `request' was an actual article -
10277 ;; or at least some text that is now displayed in the
10279 (if (and (numberp article)
10280 (not (eq article gnus-current-article)))
10281 ;; Seems like a new article has been selected.
10282 ;; `gnus-current-article' must be an article number.
10284 (set-buffer summary-buffer)
10285 (setq gnus-last-article gnus-current-article
10286 gnus-newsgroup-history (cons gnus-current-article
10287 gnus-newsgroup-history)
10288 gnus-current-article article
10289 gnus-current-headers
10290 (gnus-get-header-by-number gnus-current-article)
10291 gnus-article-current
10292 (cons gnus-newsgroup-name gnus-current-article))
10293 (gnus-summary-show-thread)
10294 (run-hooks 'gnus-mark-article-hook)
10295 (gnus-set-mode-line 'summary)
10297 (run-hooks 'gnus-visual-mark-article-hook))
10298 ;; Set the global newsgroup variables here.
10299 ;; Suggested by Jim Sisolak
10300 ;; <sisolak@trans4.neep.wisc.edu>.
10301 (gnus-set-global-variables)
10302 (setq gnus-have-all-headers
10303 (or all-headers gnus-show-all-headers))
10304 (and gnus-use-cache
10305 (gnus-cache-possibly-enter-article
10307 (gnus-get-header-by-number article)
10308 (memq article gnus-newsgroup-marked)
10309 (memq article gnus-newsgroup-dormant)
10310 (memq article gnus-newsgroup-unreads)))))
10311 ;; Hooks for getting information from the article.
10312 ;; This hook must be called before being narrowed.
10313 (let (buffer-read-only)
10314 (run-hooks 'internal-hook)
10315 (run-hooks 'gnus-article-prepare-hook)
10316 ;; Decode MIME message.
10317 (if (and gnus-show-mime
10318 (or (not gnus-strict-mime)
10319 (gnus-fetch-field "Mime-Version")))
10320 (funcall gnus-show-mime-method))
10321 ;; Perform the article display hooks.
10322 (run-hooks 'gnus-article-display-hook))
10324 (goto-char (point-min))
10325 (and gnus-break-pages (gnus-narrow-to-page))
10326 (gnus-set-mode-line 'article)
10327 (gnus-configure-windows 'article)
10328 (goto-char (point-min))
10331 (defun gnus-article-show-all-headers ()
10332 "Show all article headers in article mode buffer."
10334 (gnus-article-setup-buffer)
10335 (set-buffer gnus-article-buffer)
10336 (let ((buffer-read-only nil))
10337 (remove-text-properties (point-min) (point-max)
10338 gnus-hidden-properties))))
10340 (defun gnus-article-hide-headers-if-wanted ()
10341 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10342 Provided for backwards compatability."
10343 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10344 (gnus-article-hide-headers)))
10346 (defun gnus-article-hide-headers (&optional delete)
10347 "Hide unwanted headers and possibly sort them as well."
10350 (set-buffer gnus-article-buffer)
10352 (let ((sorted gnus-sorted-header-list)
10353 (buffer-read-only nil)
10354 want-list beg want-l)
10355 ;; First we narrow to just the headers.
10357 (goto-char (point-min))
10358 ;; Hide any "From " lines at the beginning of (mail) articles.
10359 (while (looking-at "From ")
10362 (add-text-properties (point-min) (point) gnus-hidden-properties))
10363 ;; Then treat the rest of the header lines.
10366 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10367 ;; Then we use the two regular expressions
10368 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10369 ;; select which header lines is to remain visible in the
10371 (goto-char (point-min))
10372 (while (re-search-forward "^[^ \t]*:" nil t)
10373 (beginning-of-line)
10374 ;; We add the headers we want to keep to a list and delete
10375 ;; them from the buffer.
10376 (if (or (and (stringp gnus-visible-headers)
10377 (looking-at gnus-visible-headers))
10378 (and (not (stringp gnus-visible-headers))
10379 (stringp gnus-ignored-headers)
10380 (not (looking-at gnus-ignored-headers))))
10384 ;; Be sure to get multi-line headers...
10385 (re-search-forward "^[^ \t]*:" nil t)
10386 (beginning-of-line)
10388 (cons (buffer-substring beg (point)) want-list))
10389 (delete-region beg (point))
10392 ;; Next we perform the sorting by looking at
10393 ;; `gnus-sorted-header-list'.
10394 (goto-char (point-min))
10395 (while (and sorted want-list)
10396 (setq want-l want-list)
10398 (not (string-match (car sorted) (car want-l))))
10399 (setq want-l (cdr want-l)))
10402 (insert (car want-l))
10403 (setq want-list (delq (car want-l) want-list))))
10404 (setq sorted (cdr sorted)))
10405 ;; Any headers that were not matched by the sorted list we
10406 ;; just tack on the end of the visible header list.
10408 (insert (car want-list))
10409 (setq want-list (cdr want-list)))
10410 ;; And finally we make the unwanted headers invisible.
10412 (delete-region (point) (point-max))
10413 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10414 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10416 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10417 (defun gnus-article-treat-overstrike ()
10418 "Translate overstrikes into bold text."
10421 (set-buffer gnus-article-buffer)
10422 (let ((buffer-read-only nil))
10423 (while (search-forward "\b" nil t)
10424 (let ((next (following-char))
10425 (previous (char-after (- (point) 2))))
10426 (cond ((eq next previous)
10427 (delete-region (- (point) 2) (point))
10428 (put-text-property (point) (1+ (point))
10431 (delete-region (1- (point)) (1+ (point)))
10432 (put-text-property (1- (point)) (point)
10435 (delete-region (- (point) 2) (point))
10436 (put-text-property (point) (1+ (point))
10437 'face 'underline))))))))
10439 (defun gnus-article-word-wrap ()
10440 "Format too long lines."
10443 (set-buffer gnus-article-buffer)
10444 (let ((buffer-read-only nil))
10445 (goto-char (point-min))
10446 (search-forward "\n\n" nil t)
10448 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
10449 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
10450 (adaptive-fill-mode t))
10451 (while (not (eobp))
10452 (and (>= (current-column) (min fill-column (window-width)))
10453 (/= (preceding-char) ?:)
10454 (fill-paragraph nil))
10455 (end-of-line 2))))))
10457 (defun gnus-article-remove-cr ()
10458 "Remove carriage returns from an article."
10461 (set-buffer gnus-article-buffer)
10462 (let ((buffer-read-only nil))
10463 (goto-char (point-min))
10464 (while (search-forward "\r" nil t)
10465 (replace-match "" t t)))))
10467 (defun gnus-article-display-x-face (&optional force)
10468 "Look for an X-Face header and display it if present."
10469 (interactive (list 'force))
10471 (set-buffer gnus-article-buffer)
10472 (let ((inhibit-point-motion-hooks t)
10473 (case-fold-search nil))
10475 (goto-char (point-min))
10476 (search-forward "\n\n")
10477 (narrow-to-region (point-min) (point))
10478 (goto-char (point-min))
10479 (if (or (not gnus-article-x-face-command)
10481 (or (not gnus-article-x-face-too-ugly)
10482 (string-match gnus-article-x-face-too-ugly
10483 (mail-fetch-field "from"))))
10485 (goto-char (point-min))
10486 (not (re-search-forward "^X-Face: " nil t))))
10488 (let ((beg (point))
10489 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
10490 (if (symbolp gnus-article-x-face-command)
10491 (and (or (fboundp gnus-article-x-face-command)
10492 (error "%s is not a function"
10493 gnus-article-x-face-command))
10494 (funcall gnus-article-x-face-command beg end))
10495 (call-process-region beg end "sh" nil 0 nil
10496 "-c" gnus-article-x-face-command))))))))
10498 (defun gnus-article-de-quoted-unreadable (&optional force)
10499 "Do a naïve translation of a quoted-printable-encoded article.
10500 This is in no way, shape or form meant as a replacement for real MIME
10501 processing, but is simply a stop-gap measure until MIME support is
10503 If FORCE, decode the article whether it is marked as quoted-printable
10505 (interactive (list 'force))
10507 (set-buffer gnus-article-buffer)
10508 (let ((case-fold-search t)
10509 (buffer-read-only nil)
10510 (type (gnus-fetch-field "content-transfer-encoding")))
10511 (if (or force (and type (string-match "quoted-printable" type)))
10513 (goto-char (point-min))
10514 (search-forward "\n\n" nil 'move)
10515 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
10517 (defun gnus-mime-decode-quoted-printable (from to)
10518 ;; Decode quoted-printable from region between FROM and TO.
10521 (while (search-forward "=" to t)
10522 (cond ((eq (following-char) ?\n)
10525 ((looking-at "[0-9A-F][0-9A-F]")
10527 (insert (hexl-hex-string-to-integer
10528 (buffer-substring (point) (+ 2 (point)))))
10530 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
10532 (defvar gnus-article-time-units
10533 (list (cons 'year (* 365.25 24 60 60))
10534 (cons 'week (* 7 24 60 60))
10535 (cons 'day (* 24 60 60))
10536 (cons 'hour (* 60 60))
10540 (defun gnus-article-date-ut (&optional type)
10541 "Convert DATE date to universal time in the current article.
10542 If TYPE is `local', convert to local time; if it is `lapsed', output
10543 how much time has lapsed since DATE."
10544 (interactive (list 'ut))
10545 (let ((date (header-date (or gnus-current-headers
10546 (gnus-get-header-by-number
10547 (gnus-summary-article-number))"")))
10548 (date-regexp "^Date: \\|^X-Sent: "))
10553 (set-buffer gnus-article-buffer)
10554 (let ((buffer-read-only nil))
10555 (goto-char (point-min))
10556 (if (and (re-search-forward date-regexp nil t)
10558 (beginning-of-line)
10559 (looking-at date-regexp)))
10560 (delete-region (gnus-point-at-bol)
10561 (progn (end-of-line) (1+ (point))))
10562 (goto-char (point-min))
10563 (goto-char (- (search-forward "\n\n") 2)))
10567 (concat "Date: " (condition-case ()
10568 (timezone-make-date-arpa-standard date)
10574 (timezone-make-date-arpa-standard date nil "UT")
10578 ;; If the date is seriously mangled, the timezone
10579 ;; functions are liable to bug out, so we condition-case
10580 ;; the entire thing.
10581 (let* ((sec (condition-case ()
10582 (max (- (gnus-seconds-since-epoch
10583 (timezone-make-date-arpa-standard
10584 (current-time-string)
10585 (current-time-zone) "UT"))
10586 (gnus-seconds-since-epoch
10587 (timezone-make-date-arpa-standard
10596 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
10598 (setq sec (- sec (* num (cdr unit))))
10600 (concat (if prev ", " "") (int-to-string (floor num))
10601 " " (symbol-name (car unit))
10602 (if (> num 1) "s" ""))
10604 gnus-article-time-units "")
10607 (error "Unknown conversion type: %s" type)))))))))
10609 (defun gnus-article-date-local ()
10610 "Convert the current article date to the local timezone."
10612 (gnus-article-date-ut 'local))
10614 (defun gnus-article-date-lapsed ()
10615 "Convert the current article date to time lapsed since it was sent."
10617 (gnus-article-date-ut 'lapsed))
10619 (defun gnus-article-maybe-highlight ()
10620 (if gnus-visual (gnus-article-highlight)))
10624 (defun gnus-output-to-rmail (file-name)
10625 "Append the current article to an Rmail file named FILE-NAME."
10627 ;; Most of these codes are borrowed from rmailout.el.
10628 (setq file-name (expand-file-name file-name))
10629 (setq rmail-default-rmail-file file-name)
10630 (let ((artbuf (current-buffer))
10631 (tmpbuf (get-buffer-create " *Gnus-output*")))
10633 (or (get-file-buffer file-name)
10634 (file-exists-p file-name)
10635 (if (gnus-yes-or-no-p
10636 (concat "\"" file-name "\" does not exist, create it? "))
10637 (let ((file-buffer (create-file-buffer file-name)))
10639 (set-buffer file-buffer)
10640 (rmail-insert-rmail-file-header)
10641 (let ((require-final-newline nil))
10642 (write-region (point-min) (point-max) file-name t 1)))
10643 (kill-buffer file-buffer))
10644 (error "Output file does not exist")))
10645 (set-buffer tmpbuf)
10646 (buffer-disable-undo (current-buffer))
10648 (insert-buffer-substring artbuf)
10649 (gnus-convert-article-to-rmail)
10650 ;; Decide whether to append to a file or to an Emacs buffer.
10651 (let ((outbuf (get-file-buffer file-name)))
10653 (append-to-file (point-min) (point-max) file-name)
10654 ;; File has been visited, in buffer OUTBUF.
10655 (set-buffer outbuf)
10656 (let ((buffer-read-only nil)
10657 (msg (and (boundp 'rmail-current-message)
10658 (symbol-value 'rmail-current-message))))
10659 ;; If MSG is non-nil, buffer is in RMAIL mode.
10662 (narrow-to-region (point-max) (point-max))))
10663 (insert-buffer-substring tmpbuf)
10666 (goto-char (point-min))
10668 (search-backward "\^_")
10669 (narrow-to-region (point) (point-max))
10670 (goto-char (1+ (point-min)))
10671 (rmail-count-new-messages t)
10672 (rmail-show-message msg)))))))
10673 (kill-buffer tmpbuf)))
10675 (defun gnus-output-to-file (file-name)
10676 "Append the current article to a file named FILE-NAME."
10677 (setq file-name (expand-file-name file-name))
10678 (let ((artbuf (current-buffer))
10679 (tmpbuf (get-buffer-create " *Gnus-output*")))
10681 (set-buffer tmpbuf)
10682 (buffer-disable-undo (current-buffer))
10684 (insert-buffer-substring artbuf)
10685 ;; Append newline at end of the buffer as separator, and then
10686 ;; save it to file.
10687 (goto-char (point-max))
10689 (append-to-file (point-min) (point-max) file-name))
10690 (kill-buffer tmpbuf)))
10692 (defun gnus-convert-article-to-rmail ()
10693 "Convert article in current buffer to Rmail message format."
10694 (let ((buffer-read-only nil))
10695 ;; Convert article directly into Babyl format.
10696 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10697 (goto-char (point-min))
10698 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10699 (while (search-forward "\n\^_" nil t) ;single char
10700 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10701 (goto-char (point-max))
10704 (defun gnus-narrow-to-page (&optional arg)
10705 "Make text outside current page invisible except for page delimiter.
10706 A numeric arg specifies to move forward or backward by that many pages,
10707 thus showing a page other than the one point was originally in."
10709 (setq arg (if arg (prefix-numeric-value arg) 0))
10711 (forward-page -1) ;Beginning of current page.
10716 (forward-page (1- arg))))
10717 ;; Find the end of the page.
10719 ;; If we stopped due to end of buffer, stay there.
10720 ;; If we stopped after a page delimiter, put end of restriction
10721 ;; at the beginning of that line.
10722 ;; These are commented out.
10723 ;; (if (save-excursion (beginning-of-line)
10724 ;; (looking-at page-delimiter))
10725 ;; (beginning-of-line))
10726 (narrow-to-region (point)
10728 ;; Find the top of the page.
10730 ;; If we found beginning of buffer, stay there.
10731 ;; If extra text follows page delimiter on same line,
10733 ;; Otherwise, show text starting with following line.
10734 (if (and (eolp) (not (bobp)))
10738 (defun gnus-gmt-to-local ()
10739 "Rewrite Date header described in GMT to local in current buffer.
10740 Intended to be used with gnus-article-prepare-hook."
10744 (goto-char (point-min))
10745 (narrow-to-region (point-min)
10746 (progn (search-forward "\n\n" nil 'move) (point)))
10747 (goto-char (point-min))
10748 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10749 (let ((buffer-read-only nil)
10750 (date (buffer-substring-no-properties
10751 (match-beginning 1) (match-end 1))))
10752 (delete-region (match-beginning 1) (match-end 1))
10754 (timezone-make-date-arpa-standard
10755 date nil (current-time-zone))))))))
10758 ;; Article mode commands
10760 (defun gnus-article-next-page (lines)
10761 "Show next page of current article.
10762 If end of article, return non-nil. Otherwise return nil.
10763 Argument LINES specifies lines to be scrolled up."
10765 (move-to-window-line -1)
10766 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10767 (if (save-excursion
10769 (and (pos-visible-in-window-p) ;Not continuation line.
10771 ;; Nothing in this page.
10772 (if (or (not gnus-break-pages)
10775 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10777 (gnus-narrow-to-page 1) ;Go to next page.
10779 ;; More in this page.
10783 ;; Long lines may cause an end-of-buffer error.
10784 (goto-char (point-max))))
10787 (defun gnus-article-prev-page (lines)
10788 "Show previous page of current article.
10789 Argument LINES specifies lines to be scrolled down."
10791 (move-to-window-line 0)
10792 (if (and gnus-break-pages
10794 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10796 (gnus-narrow-to-page -1) ;Go to previous page.
10797 (goto-char (point-max))
10799 (scroll-down lines)))
10801 (defun gnus-article-refer-article ()
10802 "Read article specified by message-id around point."
10804 (search-forward ">" nil t) ;Move point to end of "<....>".
10805 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10807 (buffer-substring (match-beginning 1) (match-end 1))))
10808 (set-buffer gnus-summary-buffer)
10809 (gnus-summary-refer-article message-id))
10810 (error "No references around point")))
10812 (defun gnus-article-show-summary ()
10813 "Reconfigure windows to show summary buffer."
10815 (gnus-configure-windows 'article)
10816 (gnus-summary-goto-subject gnus-current-article))
10818 (defun gnus-article-describe-briefly ()
10819 "Describe article mode commands briefly."
10822 (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")))
10824 (defun gnus-article-summary-command ()
10825 "Execute the last keystroke in the summary buffer."
10827 (let ((obuf (current-buffer))
10828 (owin (current-window-configuration))
10830 (switch-to-buffer gnus-summary-buffer 'norecord)
10831 (setq func (lookup-key (current-local-map) (this-command-keys)))
10832 (call-interactively func)
10834 (set-window-configuration owin)
10835 (set-window-start (get-buffer-window (current-buffer)) (point))))
10837 (defun gnus-article-summary-command-nosave ()
10838 "Execute the last keystroke in the summary buffer."
10841 (pop-to-buffer gnus-summary-buffer 'norecord)
10842 (setq func (lookup-key (current-local-map) (this-command-keys)))
10843 (call-interactively func)))
10846 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10849 (defalias 'gnus-batch-kill 'gnus-batch-score)
10851 (defun gnus-batch-score ()
10852 "Run batched scoring.
10853 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10854 Newsgroups is a list of strings in Bnews format. If you want to score
10855 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10856 score the alt hierarchy, you'd say \"!alt.all\"."
10859 (gnus-newsrc-parse-options
10860 (apply (function concat)
10861 (mapcar (lambda (g) (concat g " "))
10862 command-line-args-left))))
10863 (gnus-expert-user t)
10864 (nnmail-spool-file nil)
10865 (gnus-use-dribble-file nil)
10866 (yes (car yes-and-no))
10867 (no (cdr yes-and-no))
10869 ;; Disable verbose message.
10870 gnus-novice-user gnus-large-newsgroup)
10871 ;; Eat all arguments.
10872 (setq command-line-args-left nil)
10875 ;; Apply kills to specified newsgroups in command line arguments.
10876 (setq newsrc (cdr gnus-newsrc-alist))
10878 (setq group (car (car newsrc)))
10879 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10880 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10882 (or (eq (car entry) t)
10883 (not (zerop (car entry)))))
10884 (if yes (string-match yes group) t)
10885 (or (null no) (not (string-match no group))))
10887 (gnus-summary-read-group group nil t)
10888 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10889 (gnus-summary-exit))))
10890 (setq newsrc (cdr newsrc)))
10892 (switch-to-buffer gnus-group-buffer)
10893 (gnus-group-save-newsrc)))
10895 (defun gnus-apply-kill-file ()
10896 "Apply a kill file to the current newsgroup.
10897 Returns the number of articles marked as read."
10898 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10899 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10900 (gnus-apply-kill-file-internal)
10903 (defun gnus-kill-save-kill-buffer ()
10905 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10906 (if (get-file-buffer file)
10908 (set-buffer (get-file-buffer file))
10909 (and (buffer-modified-p) (save-buffer))
10910 (kill-buffer (current-buffer)))))))
10912 (defvar gnus-kill-file-name "KILL"
10913 "Suffix of the kill files.")
10915 (defun gnus-newsgroup-kill-file (newsgroup)
10916 "Return the name of a kill file name for NEWSGROUP.
10917 If NEWSGROUP is nil, return the global kill file name instead."
10918 (cond ((or (null newsgroup)
10919 (string-equal newsgroup ""))
10920 ;; The global KILL file is placed at top of the directory.
10921 (expand-file-name gnus-kill-file-name
10922 (or gnus-kill-files-directory "~/News")))
10923 ((gnus-use-long-file-name 'not-kill)
10924 ;; Append ".KILL" to newsgroup name.
10925 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10926 (or gnus-kill-files-directory "~/News")))
10928 ;; Place "KILL" under the hierarchical directory.
10929 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10930 "/" gnus-kill-file-name)
10931 (or gnus-kill-files-directory "~/News")))))
10938 (defvar gnus-dribble-ignore nil)
10940 (defun gnus-dribble-file-name ()
10941 (concat gnus-startup-file "-dribble"))
10943 (defun gnus-dribble-open ()
10946 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10947 (buffer-disable-undo (current-buffer))
10948 (bury-buffer gnus-dribble-buffer)
10950 (goto-char (point-max))))
10952 (defun gnus-dribble-enter (string)
10953 (if (and (not gnus-dribble-ignore)
10954 gnus-dribble-buffer
10955 (buffer-name gnus-dribble-buffer))
10956 (let ((obuf (current-buffer)))
10957 (set-buffer gnus-dribble-buffer)
10958 (insert string "\n")
10959 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10960 (set-buffer obuf))))
10962 (defun gnus-dribble-read-file ()
10963 (let ((dribble-file (gnus-dribble-file-name)))
10965 (set-buffer (setq gnus-dribble-buffer
10967 (file-name-nondirectory dribble-file))))
10968 (gnus-add-current-to-buffer-list)
10970 (set-visited-file-name dribble-file)
10971 (buffer-disable-undo (current-buffer))
10972 (bury-buffer (current-buffer))
10973 (set-buffer-modified-p nil)
10974 (let ((auto (make-auto-save-file-name))
10975 (gnus-dribble-ignore t))
10976 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10978 (if (file-newer-than-file-p auto dribble-file)
10979 (setq dribble-file auto))
10980 (insert-file-contents dribble-file)
10981 (if (not (zerop (buffer-size)))
10982 (set-buffer-modified-p t))
10984 "Auto-save file exists. Do you want to read it? ")
10986 (gnus-message 5 "Reading %s..." dribble-file)
10987 (eval-buffer (current-buffer))
10988 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
10990 (defun gnus-dribble-delete-file ()
10991 (if (file-exists-p (gnus-dribble-file-name))
10992 (delete-file (gnus-dribble-file-name)))
10993 (if gnus-dribble-buffer
10995 (set-buffer gnus-dribble-buffer)
10996 (let ((auto (make-auto-save-file-name)))
10997 (if (file-exists-p auto)
10998 (delete-file auto))
11000 (set-buffer-modified-p nil)))))
11002 (defun gnus-dribble-save ()
11003 (if (and gnus-dribble-buffer
11004 (buffer-name gnus-dribble-buffer))
11006 (set-buffer gnus-dribble-buffer)
11009 (defun gnus-dribble-clear ()
11011 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11013 (set-buffer gnus-dribble-buffer)
11015 (set-buffer-modified-p nil)
11016 (setq buffer-saved-size (buffer-size))))))
11019 ;;; Server Communication
11022 ;; All the Gnus backends have the same interface, and should return
11023 ;; data in a similar format. Below is an overview of what functions
11024 ;; these packages must supply and what results they should return.
11028 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11031 ;; Functions for the imaginary backend `choke':
11033 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11034 ;; Should return all headers for all ARTICLES, or return NOV lines for
11037 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11038 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11039 ;; must be returned.
11041 ;; `choke-close-group GROUP &optional SERVER'
11042 ;; Close group. Most backends won't have to do anything with this
11043 ;; call, but it is an opportunity to clean up, if that is needed. It
11044 ;; is called when Gnus exits a group.
11046 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11047 ;; Return ARTICLE, which is either an article number or
11048 ;; message-id. Note that not all backends can return articles based on
11051 ;; `choke-request-list SERVER'
11052 ;; Return a list of all newsgroups on SERVER.
11054 ;; `choke-request-list-newsgroups SERVER'
11055 ;; Return a list of descriptions of all newsgroups on SERVER.
11057 ;; `choke-request-newgroups DATE &optional SERVER'
11058 ;; Return a list of all groups that have arrived after DATE on
11059 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11060 ;; always check whether the groups are old or not. Backends that do
11061 ;; not store date information may just return the entire list of
11062 ;; groups, although this might not be a good idea in general.
11064 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11065 ;; Should return a buffer that is suitable for "posting". nnspool and
11066 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11067 ;; buffer. This function should fill out the appropriate headers.
11069 ;; `choke-request-post &optional SERVER'
11070 ;; Function that will be called from a buffer to be posted.
11072 ;; `choke-open-server SERVER &optional ARGUMENT'
11073 ;; Open a connection to SERVER.
11075 ;; `choke-close-server &optional SERVER'
11076 ;; Close the connection to SERVER.
11078 ;; `choke-server-opened &optional SERVER'
11079 ;; Whether the conenction to SERVER is opened or not.
11081 ;; `choke-server-status &optional SERVER'
11082 ;; Should return a status string (not in the nntp buffer, but as the
11083 ;; result of the function).
11085 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11086 ;; Optional function for retrieving active file info on all groups in
11087 ;; GROUPS. Two return formats are supported: The normal active file
11088 ;; format, and a list of GROUP lines. This function should return (as
11089 ;; a function value) either `active' or `group', depending on what
11090 ;; format it returns.
11092 ;; The following functions are optional and apply only to backends
11093 ;; that are able to control the contents of their groups totally
11094 ;; (ie. mail backends.) Backends that aren't able to do that
11095 ;; shouldn't define these functions at all. Gnus will check for their
11096 ;; presence before attempting to call them.
11098 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11099 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11100 ;; backends will not be able to expire articles. Should return a list
11101 ;; of all articles that were not expired.
11103 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11104 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11105 ;; Removes any information it has added to the article (extra headers,
11106 ;; whatever - make it as clean as possible), and then passes the
11107 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11108 ;; function described below. If the ACCEPT-FORM returns a non-nil
11109 ;; value, the article should then be deleted. If LAST is nil, that
11110 ;; means that there will be further calls to this function. This might
11111 ;; be taken as an advice not to save buffers/internal variables just
11112 ;; yet, but wait until the last call to speed things up.
11114 ;; `choke-request-accept-article GROUP &optional LAST'
11115 ;; The contents of the current buffer will be put into GROUP. There
11116 ;; should, of course, be an article in the current buffer. This
11117 ;; function is normally only called by the function described above,
11118 ;; and LAST works the same way as in that function.
11120 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11121 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11122 ;; This provides an easy interface for allowing editing of
11123 ;; articles. Note that even headers may be edited, so the backend has
11124 ;; to update any tables (nov buffers, etc) that it maintains after
11125 ;; replacing the article.
11127 ;; `choke-request-create-group GROUP &optional SERVER'
11128 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11129 ;; might be a group that already exists, but hasn't been registered
11132 ;; All these functions must return nil if they couldn't service the
11133 ;; request. If the optional arguments are not supplied, some "current"
11134 ;; or "default" values should be used. In short, one should emulate an
11135 ;; NNTP server, in a way.
11137 ;; If you want to write a new backend, you just have to supply the
11138 ;; functions listed above. In addition, you must enter the new backend
11139 ;; into the list of valid select methods:
11140 ;; (setq gnus-valid-select-methods
11141 ;; (cons '("choke" mail) gnus-valid-select-methods))
11142 ;; The first element in this list is the name of the backend. Other
11143 ;; elemnets may be `mail' (for mail groups), `post' (for news
11144 ;; groups), `none' (neither), `respool' (for groups that can control
11145 ;; their contents).
11147 (defun gnus-start-news-server (&optional confirm)
11148 "Open a method for getting news.
11149 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11151 (if gnus-current-select-method
11152 ;; Stream is already opened.
11154 ;; Open NNTP server.
11155 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11158 ;; Read server name with completion.
11159 (setq gnus-nntp-server
11160 (completing-read "NNTP server: "
11161 (mapcar (lambda (server) (list server))
11162 (cons (list gnus-nntp-server)
11163 gnus-secondary-servers))
11164 nil nil gnus-nntp-server))))
11166 (if (and gnus-nntp-server
11167 (stringp gnus-nntp-server)
11168 (not (string= gnus-nntp-server "")))
11169 (setq gnus-select-method
11170 (cond ((or (string= gnus-nntp-server "")
11171 (string= gnus-nntp-server "::"))
11172 (list 'nnspool (system-name)))
11173 ((string-match "^:" gnus-nntp-server)
11174 (list 'nnmh gnus-nntp-server
11175 (list 'nnmh-directory
11176 (file-name-as-directory
11178 (concat "~/" (substring
11179 gnus-nntp-server 1)))))
11180 (list 'nnmh-get-new-mail nil)))
11182 (list 'nntp gnus-nntp-server)))))
11184 (setq how (car gnus-select-method))
11185 (cond ((eq how 'nnspool)
11187 (gnus-message 5 "Looking up local news spool..."))
11190 (gnus-message 5 "Looking up mh spool..."))
11193 (setq gnus-current-select-method gnus-select-method)
11194 (run-hooks 'gnus-open-server-hook)
11196 ;; gnus-open-server-hook might have opened it
11197 (gnus-server-opened gnus-select-method)
11198 (gnus-open-server gnus-select-method)
11201 "%s server on %s can't be opened. Continue? "
11202 (car gnus-select-method) (nth 1 gnus-select-method)))
11204 (gnus-message 1 "Couldn't open server on %s"
11205 (nth 1 gnus-select-method))
11209 (defun gnus-check-news-server (&optional method)
11210 "If the news server is down, start it up again."
11211 (let ((method (if method method gnus-select-method)))
11212 (and (stringp method)
11213 (setq method (gnus-server-to-method method)))
11214 (if (gnus-server-opened method)
11215 ;; Stream is already opened.
11218 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11219 (run-hooks 'gnus-open-server-hook)
11220 (or (gnus-server-opened method)
11221 (gnus-open-server method))
11224 (defun gnus-nntp-message (&optional message)
11225 "Check the status of the NNTP server.
11226 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11227 is returned insted of the status string."
11228 (let ((status (gnus-status-message (gnus-find-method-for-group
11229 gnus-newsgroup-name)))
11230 (message (or message "")))
11231 (if (and (stringp status) (> (length status) 0))
11234 (defun gnus-get-function (method function)
11235 (and (stringp method)
11236 (setq method (gnus-server-to-method method)))
11237 (let ((func (intern (format "%s-%s" (car method) function))))
11238 (if (not (fboundp func))
11240 (require (car method))
11241 (if (not (fboundp func))
11242 (error "No such function: %s" func))))
11245 ;;; Interface functions to the backends.
11247 (defun gnus-open-server (method)
11248 (funcall (gnus-get-function method 'open-server)
11249 (nth 1 method) (nthcdr 2 method)))
11251 (defun gnus-close-server (method)
11252 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11254 (defun gnus-request-list (method)
11255 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11257 (defun gnus-request-list-newsgroups (method)
11258 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11260 (defun gnus-request-newgroups (date method)
11261 (funcall (gnus-get-function method 'request-newgroups)
11262 date (nth 1 method)))
11264 (defun gnus-server-opened (method)
11265 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11267 (defun gnus-status-message (method)
11268 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11270 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11272 (defun gnus-request-group (group &optional dont-check)
11273 (let ((method (gnus-find-method-for-group group)))
11274 ; (and t (message "%s GROUP %s" (car method) group))
11275 (funcall (gnus-get-function method 'request-group)
11276 (gnus-group-real-name group) (nth 1 method) dont-check)))
11278 (defun gnus-request-asynchronous (group &optional articles)
11279 (let ((method (gnus-find-method-for-group group)))
11280 (funcall (gnus-get-function method 'request-asynchronous)
11281 (gnus-group-real-name group) (nth 1 method) articles)))
11283 (defun gnus-list-active-group (group)
11284 (let ((method (gnus-find-method-for-group group))
11285 (func 'list-active-group))
11286 (and (gnus-check-backend-function func group)
11287 (funcall (gnus-get-function method func)
11288 (gnus-group-real-name group) (nth 1 method)))))
11290 (defun gnus-request-group-description (group)
11291 (let ((method (gnus-find-method-for-group group))
11292 (func 'request-group-description))
11293 (and (gnus-check-backend-function func group)
11294 (funcall (gnus-get-function method func)
11295 (gnus-group-real-name group) (nth 1 method)))))
11297 (defun gnus-close-group (group)
11298 (let ((method (gnus-find-method-for-group group)))
11299 (funcall (gnus-get-function method 'close-group)
11300 (gnus-group-real-name group) (nth 1 method))))
11302 (defun gnus-retrieve-headers (articles group)
11303 (let ((method (gnus-find-method-for-group group)))
11304 (if (and gnus-use-cache (numberp (car articles)))
11305 (gnus-cache-retrieve-headers articles group)
11306 (funcall (gnus-get-function method 'retrieve-headers)
11307 articles (gnus-group-real-name group) (nth 1 method)))))
11309 (defun gnus-retrieve-groups (groups method)
11310 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11312 (defun gnus-request-article (article group &optional buffer)
11313 (let ((method (gnus-find-method-for-group group)))
11314 (funcall (gnus-get-function method 'request-article)
11315 article (gnus-group-real-name group) (nth 1 method) buffer)))
11317 (defun gnus-request-head (article group)
11318 (let ((method (gnus-find-method-for-group group)))
11319 (funcall (gnus-get-function method 'request-head)
11320 article (gnus-group-real-name group) (nth 1 method))))
11322 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11323 (defun gnus-request-post-buffer (post group subject header artbuf
11324 info follow-to respect-poster)
11325 (let* ((info (or info (and group (nth 2 (gnus-gethash
11326 group gnus-newsrc-hashtb)))))
11328 (if (and gnus-post-method
11329 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11331 (format "%s" (car (gnus-find-method-for-group
11332 gnus-newsgroup-name)))
11333 gnus-valid-select-methods)))
11335 (gnus-find-method-for-group gnus-newsgroup-name))))
11336 (or (gnus-server-opened method)
11337 (gnus-open-server method)
11338 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11339 (let ((mail-self-blind nil)
11340 (mail-archive-file-name nil))
11341 (funcall (gnus-get-function method 'request-post-buffer)
11342 post group subject header artbuf info follow-to
11345 (defun gnus-request-post (method &optional force)
11346 (and (stringp method)
11347 (setq method (gnus-server-to-method method)))
11348 (and (not force) gnus-post-method
11349 (memq 'post (assoc (format "%s" (car method))
11350 gnus-valid-select-methods))
11351 (setq method gnus-post-method))
11352 (funcall (gnus-get-function method 'request-post)
11355 (defun gnus-request-expire-articles (articles group &optional force)
11356 (let ((method (gnus-find-method-for-group group)))
11357 (funcall (gnus-get-function method 'request-expire-articles)
11358 articles (gnus-group-real-name group) (nth 1 method)
11361 (defun gnus-request-move-article
11362 (article group server accept-function &optional last)
11363 (let ((method (gnus-find-method-for-group group)))
11364 (funcall (gnus-get-function method 'request-move-article)
11365 article (gnus-group-real-name group)
11366 (nth 1 method) accept-function last)))
11368 (defun gnus-request-accept-article (group &optional last)
11369 (let ((func (if (symbolp group) group
11370 (car (gnus-find-method-for-group group)))))
11371 (funcall (intern (format "%s-request-accept-article" func))
11372 (if (stringp group) (gnus-group-real-name group) group)
11375 (defun gnus-request-replace-article (article group buffer)
11376 (let ((func (car (gnus-find-method-for-group group))))
11377 (funcall (intern (format "%s-request-replace-article" func))
11378 article (gnus-group-real-name group) buffer)))
11380 (defun gnus-request-create-group (group)
11381 (let ((method (gnus-find-method-for-group group)))
11382 (funcall (gnus-get-function method 'request-create-group)
11383 (gnus-group-real-name group) (nth 1 method))))
11385 (defun gnus-member-of-valid (symbol group)
11386 (memq symbol (assoc
11387 (format "%s" (car (gnus-find-method-for-group group)))
11388 gnus-valid-select-methods)))
11390 (defsubst gnus-secondary-method-p (method)
11391 (member method gnus-secondary-select-methods))
11393 (defun gnus-find-method-for-group (group &optional info)
11394 (or gnus-override-method
11396 gnus-select-method)
11397 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11400 (not (setq method (nth 4 info))))
11401 (setq method gnus-select-method)
11403 (cond ((stringp method)
11404 (gnus-server-to-method method))
11405 ((stringp (car method))
11406 (gnus-server-extend-method group method))
11409 (gnus-server-add-address method))))
11411 (defun gnus-check-backend-function (func group)
11412 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11414 (fboundp (intern (format "%s-%s" method func)))))
11416 (defun gnus-methods-using (method)
11417 (let ((valids gnus-valid-select-methods)
11420 (if (memq method (car valids))
11421 (setq outs (cons (car valids) outs)))
11422 (setq valids (cdr valids)))
11426 ;;; Active & Newsrc File Handling
11429 ;; Newsrc related functions.
11430 ;; Gnus internal format of gnus-newsrc-alist:
11431 ;; (("alt.general" 3 (1 . 1))
11432 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11433 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11434 ;; The first item is the group name; the second is the subscription
11435 ;; level; the third is either a range of a list of ranges of read
11436 ;; articles, the optional fourth element is a list of marked articles,
11437 ;; the optional fifth element is the select method.
11439 ;; Gnus internal format of gnus-newsrc-hashtb:
11440 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11441 ;; This is the entry for "alt.misc". The first element is the number
11442 ;; of unread articles in "alt.misc". The cdr of this entry is the
11443 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11444 ;; trivial to remove or add new elements into gnus-newsrc-alist
11445 ;; without scanning the entire list. So, to get the actual information
11446 ;; of "alt.misc", you'd say something like
11447 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11449 ;; Gnus internal format of gnus-active-hashtb:
11453 ;; The only element in each entry in this hash table is a range of
11454 ;; (possibly) available articles. (Articles in this range may have
11455 ;; been expired or canceled.)
11457 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11458 ;; ("alt.misc" "alt.test" "alt.general" ...)
11460 (defun gnus-setup-news (&optional rawfile level)
11461 "Setup news information.
11462 If RAWFILE is non-nil, the .newsrc file will also be read.
11463 If LEVEL is non-nil, the news will be set up at level LEVEL."
11464 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
11465 ;; Clear some variables to re-initialize news information.
11466 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
11468 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11469 (if init (gnus-read-newsrc-file rawfile))
11471 ;; Read the active file and create `gnus-active-hashtb'.
11472 ;; If `gnus-read-active-file' is nil, then we just create an empty
11473 ;; hash table. The partial filling out of the hash table will be
11474 ;; done in `gnus-get-unread-articles'.
11475 (if (and gnus-read-active-file
11477 (gnus-read-active-file)
11478 (setq gnus-active-hashtb (make-vector 4095 0)))
11480 (and init gnus-use-dribble-file (gnus-dribble-read-file))
11482 ;; Find the number of unread articles in each non-dead group.
11483 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
11484 ;; Find new newsgroups and treat them.
11485 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
11486 (gnus-server-opened gnus-select-method))
11487 (gnus-find-new-newsgroups))
11488 (if (and init gnus-check-bogus-newsgroups
11489 gnus-read-active-file (not level)
11490 (gnus-server-opened gnus-select-method))
11491 (gnus-check-bogus-newsgroups))))
11493 (defun gnus-find-new-newsgroups ()
11494 "Search for new newsgroups and add them.
11495 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11496 The `-n' option line from .newsrc is respected."
11498 (or (gnus-check-first-time-used)
11499 (if (or (consp gnus-check-new-newsgroups)
11500 (eq gnus-check-new-newsgroups 'ask-server))
11501 (gnus-ask-server-for-new-groups)
11503 group new-newsgroups)
11504 (or gnus-have-read-active-file (gnus-read-active-file))
11505 (setq gnus-newsrc-last-checked-date (current-time-string))
11506 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11507 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11508 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11511 (setq group (symbol-name sym))
11512 (if (or (gnus-gethash group gnus-killed-hashtb)
11513 (gnus-gethash group gnus-newsrc-hashtb))
11515 (let ((do-sub (gnus-matches-options-n group)))
11516 (cond ((eq do-sub 'subscribe)
11517 (setq groups (1+ groups))
11518 (gnus-sethash group group gnus-killed-hashtb)
11520 gnus-subscribe-options-newsgroup-method group))
11521 ((eq do-sub 'ignore)
11524 (setq groups (1+ groups))
11525 (gnus-sethash group group gnus-killed-hashtb)
11526 (if gnus-subscribe-hierarchical-interactive
11527 (setq new-newsgroups (cons group new-newsgroups))
11528 (funcall gnus-subscribe-newsgroup-method group)))))))
11529 gnus-active-hashtb)
11531 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11532 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11534 (gnus-message 6 "%d new newsgroup%s arrived."
11535 groups (if (> groups 1) "s have" " has")))))))
11537 (defun gnus-matches-options-n (group)
11538 ;; Returns `subscribe' if the group is to be uncoditionally
11539 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
11540 ;; no match for the group.
11542 ;; First we check the two user variables.
11544 ((and gnus-options-subscribe
11545 (string-match gnus-options-subscribe group))
11547 ((and gnus-options-not-subscribe
11548 (string-match gnus-options-not-subscribe group))
11550 ;; Then we go through the list that was retrieved from the .newsrc
11551 ;; file. This list has elements on the form
11552 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11553 ;; is in the reverse order of the options line) is returned.
11555 (let ((regs gnus-newsrc-options-n))
11557 (not (string-match (car (car regs)) group)))
11558 (setq regs (cdr regs)))
11559 (and regs (cdr (car regs)))))))
11561 (defun gnus-ask-server-for-new-groups ()
11562 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11563 (methods (cons gnus-select-method
11565 (and (consp gnus-check-new-newsgroups)
11566 gnus-check-new-newsgroups)
11567 gnus-secondary-select-methods)))
11569 (new-date (current-time-string))
11570 hashtb group new-newsgroups got-new)
11571 ;; Go thorugh both primary and secondary select methods and
11572 ;; request new newsgroups.
11574 (and (or (gnus-server-opened (car methods))
11575 (gnus-open-server (car methods)))
11576 (gnus-request-newgroups date (car methods))
11579 (set-buffer nntp-server-buffer)
11580 (or hashtb (setq hashtb (gnus-make-hashtable
11581 (count-lines (point-min) (point-max)))))
11582 ;; Enter all the new groups in a hashtable.
11583 (gnus-active-to-gnus-format (car methods) hashtb 'ignore)))
11584 (setq methods (cdr methods)))
11585 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11586 ;; Now all new groups from all select methods are in `hashtb'.
11588 (lambda (group-sym)
11589 (setq group (symbol-name group-sym))
11590 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11591 (member group gnus-zombie-list)
11592 (member group gnus-killed-list))
11593 ;; The group is already known.
11595 (and (symbol-value group-sym)
11596 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
11597 (let ((do-sub (gnus-matches-options-n group)))
11598 (cond ((eq do-sub 'subscribe)
11599 (setq groups (1+ groups))
11600 (gnus-sethash group group gnus-killed-hashtb)
11602 gnus-subscribe-options-newsgroup-method group))
11603 ((eq do-sub 'ignore)
11606 (setq groups (1+ groups))
11607 (gnus-sethash group group gnus-killed-hashtb)
11608 (if gnus-subscribe-hierarchical-interactive
11609 (setq new-newsgroups (cons group new-newsgroups))
11610 (funcall gnus-subscribe-newsgroup-method group)))))))
11613 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11614 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11616 (gnus-message 6 "%d new newsgroup%s arrived."
11617 groups (if (> groups 1) "s have" " has")))
11620 (defun gnus-check-first-time-used ()
11621 (if (or (> (length gnus-newsrc-alist) 1)
11622 (file-exists-p gnus-startup-file)
11623 (file-exists-p (concat gnus-startup-file ".el"))
11624 (file-exists-p (concat gnus-startup-file ".eld")))
11626 (gnus-message 6 "First time user; subscribing you to default groups")
11627 (or gnus-have-read-active-file (gnus-read-active-file))
11628 (setq gnus-newsrc-last-checked-date (current-time-string))
11629 (let ((groups gnus-default-subscribed-newsgroups)
11633 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11636 (setq group (symbol-name sym))
11637 (let ((do-sub (gnus-matches-options-n group)))
11638 (cond ((eq do-sub 'subscribe)
11639 (gnus-sethash group group gnus-killed-hashtb)
11641 gnus-subscribe-options-newsgroup-method group))
11642 ((eq do-sub 'ignore)
11645 (setq gnus-killed-list (cons group gnus-killed-list))))))
11646 gnus-active-hashtb)
11648 (if (gnus-gethash (car groups) gnus-active-hashtb)
11649 (gnus-group-change-level
11650 (car groups) gnus-level-default-subscribed gnus-level-killed))
11651 (setq groups (cdr groups)))
11652 (gnus-group-make-help-group)
11653 (and gnus-novice-user
11654 (gnus-message 7 "`A k' to list killed groups"))))))
11656 (defun gnus-subscribe-group (group previous &optional method)
11657 (gnus-group-change-level
11659 (list t group gnus-level-default-subscribed nil nil method)
11661 gnus-level-default-subscribed gnus-level-killed previous t))
11663 ;; `gnus-group-change-level' is the fundamental function for changing
11664 ;; subscription levels of newsgroups. This might mean just changing
11665 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11666 ;; again, which subscribes/unsubscribes a group, which is equally
11667 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11668 ;; from 8-9 to 1-7 means that you remove the group from the list of
11669 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11670 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11671 ;; which is trivial.
11672 ;; ENTRY can either be a string (newsgroup name) or a list (if
11673 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11674 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11676 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11677 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11679 (defun gnus-group-change-level (entry level &optional oldlevel
11680 previous fromkilled)
11681 (let (group info active num)
11682 ;; Glean what info we can from the arguments
11684 (if fromkilled (setq group (nth 1 entry))
11685 (setq group (car (nth 2 entry))))
11686 (setq group entry))
11687 (if (and (stringp entry)
11689 (< oldlevel gnus-level-zombie))
11690 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11691 (if (and (not oldlevel)
11693 (setq oldlevel (car (cdr (nth 2 entry)))))
11694 (if (stringp previous)
11695 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11697 (gnus-dribble-enter
11698 (format "(gnus-group-change-level %S %S %S %S %S)"
11699 group level oldlevel (car (nth 2 previous)) fromkilled))
11701 ;; Then we remove the newgroup from any old structures, if needed.
11702 ;; If the group was killed, we remove it from the killed or zombie
11703 ;; list. If not, and it is in fact going to be killed, we remove
11704 ;; it from the newsrc hash table and assoc.
11705 (cond ((>= oldlevel gnus-level-zombie)
11706 (if (= oldlevel gnus-level-zombie)
11707 (setq gnus-zombie-list (delete group gnus-zombie-list))
11708 (setq gnus-killed-list (delete group gnus-killed-list))))
11710 (if (>= level gnus-level-zombie)
11712 (gnus-sethash (car (nth 2 entry))
11713 nil gnus-newsrc-hashtb)
11715 (setcdr (gnus-gethash (car (nth 3 entry))
11716 gnus-newsrc-hashtb)
11718 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11720 ;; Finally we enter (if needed) the list where it is supposed to
11721 ;; go, and change the subscription level. If it is to be killed,
11722 ;; we enter it into the killed or zombie list.
11723 (cond ((>= level gnus-level-zombie)
11724 ;; Remove from the hash table.
11725 (gnus-sethash group nil gnus-newsrc-hashtb)
11726 (or (gnus-group-foreign-p group)
11727 ;; We do not enter foreign groups into the list of dead
11729 (if (= level gnus-level-zombie)
11730 (setq gnus-zombie-list (cons group gnus-zombie-list))
11731 (setq gnus-killed-list (cons group gnus-killed-list)))))
11733 ;; If the list is to be entered into the newsrc assoc, and
11734 ;; it was killed, we have to create an entry in the newsrc
11735 ;; hashtb format and fix the pointers in the newsrc assoc.
11736 (if (>= oldlevel gnus-level-zombie)
11740 (setq info (cdr entry))
11741 (setq num (car entry)))
11742 (setq active (gnus-gethash group gnus-active-hashtb))
11743 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11744 ;; Check whether the group is foreign. If so, the
11745 ;; foreign select method has to be entered into the
11747 (let ((method (gnus-group-method-name group)))
11748 (if (eq method gnus-select-method)
11749 (setq info (list group level nil))
11750 (setq info (list group level nil nil method)))))
11753 (let ((p gnus-newsrc-alist))
11754 (while (cdr (cdr p))
11757 (setq entry (cons info (cdr (cdr previous))))
11760 (setcdr (cdr previous) entry)
11761 (gnus-sethash group (cons num (cdr previous))
11762 gnus-newsrc-hashtb))
11763 (setcdr previous entry)
11764 (gnus-sethash group (cons num previous)
11765 gnus-newsrc-hashtb))
11767 (setcdr (gnus-gethash (car (car (cdr entry)))
11768 gnus-newsrc-hashtb)
11770 ;; It was alive, and it is going to stay alive, so we
11771 ;; just change the level and don't change any pointers or
11772 ;; hash table entries.
11773 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11775 (defun gnus-kill-newsgroup (newsgroup)
11776 "Obsolete function. Kills a newsgroup."
11777 (gnus-group-change-level
11778 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11780 (defun gnus-check-bogus-newsgroups (&optional confirm)
11781 "Remove bogus newsgroups.
11782 If CONFIRM is non-nil, the user has to confirm the deletion of every
11784 (let ((newsrc (cdr gnus-newsrc-alist))
11786 (gnus-message 5 "Checking bogus newsgroups...")
11787 (or gnus-have-read-active-file (gnus-read-active-file))
11788 ;; Find all bogus newsgroup that are subscribed.
11790 (setq group (car (car newsrc)))
11791 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
11792 (nth 4 (car newsrc)) ; Foreign
11794 (not (gnus-y-or-n-p
11795 (format "Remove bogus newsgroup: %s " group)))))
11798 ;; Found a bogus newsgroup.
11799 (setq bogus (cons group bogus)))
11800 (setq newsrc (cdr newsrc)))
11801 ;; Remove all bogus subscribed groups by first killing them, and
11802 ;; then removing them from the list of killed groups.
11804 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
11806 (gnus-group-change-level entry gnus-level-killed)
11807 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
11808 (setq bogus (cdr bogus)))
11809 ;; Then we remove all bogus groups from the list of killed and
11810 ;; zombie groups. They are are removed without confirmation.
11811 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11814 (setq killed (symbol-value (car dead-lists)))
11816 (setq group (car killed))
11817 (or (gnus-gethash group gnus-active-hashtb)
11818 ;; The group is bogus.
11819 (set (car dead-lists)
11820 (delete group (symbol-value (car dead-lists)))))
11821 (setq killed (cdr killed)))
11822 (setq dead-lists (cdr dead-lists))))
11823 (gnus-message 5 "Checking bogus newsgroups...done")))
11825 (defun gnus-check-duplicate-killed-groups ()
11826 "Remove duplicates from the list of killed groups."
11828 (let ((killed gnus-killed-list))
11830 (gnus-message 9 "%d" (length killed))
11831 (setcdr killed (delete (car killed) (cdr killed)))
11832 (setq killed (cdr killed)))))
11834 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11835 ;; and compute how many unread articles there are in each group.
11836 (defun gnus-get-unread-articles (&optional level)
11837 (let* ((newsrc (cdr gnus-newsrc-alist))
11838 (level (or level (1+ gnus-level-subscribed)))
11841 (cond ((and gnus-activate-foreign-newsgroups
11842 (not (numberp gnus-activate-foreign-newsgroups)))
11843 (1+ gnus-level-subscribed))
11844 ((numberp gnus-activate-foreign-newsgroups)
11845 gnus-activate-foreign-newsgroups)
11848 info group active virtuals method)
11849 (gnus-message 5 "Checking new news...")
11852 (setq info (car newsrc)
11854 active (gnus-gethash group gnus-active-hashtb))
11856 ;; Check newsgroups. If the user doesn't want to check them, or
11857 ;; they can't be checked (for instance, if the news server can't
11858 ;; be reached) we just set the number of unread articles in this
11859 ;; newsgroup to t. This means that Gnus thinks that there are
11860 ;; unread articles, but it has no idea how many.
11861 (if (and (setq method (nth 4 info))
11862 (not (gnus-server-equal gnus-select-method
11863 (gnus-server-get-method nil method)))
11864 (not (gnus-secondary-method-p method)))
11865 ;; These groups are foreign. Check the level.
11866 (if (<= (nth 1 info) foreign-level)
11867 (if (eq (car (if (stringp method)
11868 (gnus-server-to-method method)
11869 (nth 4 info))) 'nnvirtual)
11870 ;; We have to activate the virtual groups after all
11871 ;; the others, so we just pop them on a list for
11873 (setq virtuals (cons info virtuals))
11874 (and (setq active (gnus-activate-newsgroup (car info)))
11875 ;; Close the groups as we look at them!
11876 (gnus-close-group group))))
11878 ;; These groups are native or secondary.
11879 (if (and (not gnus-have-read-active-file)
11880 (<= (nth 1 info) level))
11881 (setq active (gnus-activate-newsgroup (car info)))))
11884 (gnus-get-unread-articles-in-group info active)
11885 ;; The group couldn't be reached, so we nix out the number of
11886 ;; unread articles and stuff.
11887 (gnus-sethash group nil gnus-active-hashtb)
11888 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
11890 (setq newsrc (cdr newsrc)))
11892 ;; Activate the virtual groups. This has to be done after all the
11894 ;; !!! If one virtual group contains another virtual group, even
11895 ;; doing it this way might cause problems.
11897 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11898 (gnus-get-unread-articles-in-group (car virtuals) active))
11899 (setq virtuals (cdr virtuals)))
11901 (gnus-message 5 "Checking new news...done")))
11903 ;; Create a hash table out of the newsrc alist. The `car's of the
11904 ;; alist elements are used as keys.
11905 (defun gnus-make-hashtable-from-newsrc-alist ()
11906 (let ((alist gnus-newsrc-alist)
11907 (ohashtb gnus-newsrc-hashtb)
11909 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11911 (setq prev (setq gnus-newsrc-alist
11912 (if (equal (car (car gnus-newsrc-alist))
11915 (cons (list "dummy.group" 0 nil) alist)))))
11917 (gnus-sethash (car (car alist))
11918 (cons (and ohashtb (car (gnus-gethash
11919 (car (car alist)) ohashtb)))
11920 prev) gnus-newsrc-hashtb)
11922 alist (cdr alist)))))
11924 (defun gnus-make-hashtable-from-killed ()
11925 "Create a hash table from the killed and zombie lists."
11926 (let ((lists '(gnus-killed-list gnus-zombie-list))
11928 (setq gnus-killed-hashtb
11929 (gnus-make-hashtable
11930 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11932 (setq list (symbol-value (car lists)))
11933 (setq lists (cdr lists))
11935 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11936 (setq list (cdr list))))))
11938 (defun gnus-get-unread-articles-in-group (info active)
11939 (let* ((range (nth 2 info))
11941 (marked (nth 3 info)))
11942 ;; If a cache is present, we may have to alter the active info.
11943 (and gnus-use-cache
11944 (gnus-cache-possibly-alter-active (car info) active))
11945 ;; Modify the list of read articles according to what articles
11946 ;; are available; then tally the unread articles and add the
11947 ;; number to the group hash table entry.
11948 (cond ((zerop (cdr active))
11951 (setq num (- (1+ (cdr active)) (car active))))
11952 ((not (listp (cdr range)))
11953 ;; Fix a single (num . num) range according to the
11954 ;; active hash table.
11955 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
11956 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
11957 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
11958 ;; Compute number of unread articles.
11959 (setq num (max 0 (- (cdr active)
11960 (- (1+ (cdr range)) (car range))))))
11962 ;; The read list is a list of ranges. Fix them according to
11963 ;; the active hash table.
11964 ;; First peel off any elements that are below the lower
11966 (while (and (cdr range)
11968 (or (and (atom (car (cdr range))) (car (cdr range)))
11969 (car (car (cdr range))))))
11970 (if (numberp (car range))
11973 (or (and (numberp (car (cdr range)))
11975 (cdr (car (cdr range))))))
11976 (setcdr (car range)
11977 (or (and (numberp (nth 1 range)) (nth 1 range))
11978 (cdr (car (cdr range))))))
11979 (setcdr range (cdr (cdr range))))
11980 ;; Adjust the first element to be the same as the lower limit.
11981 (if (and (not (atom (car range)))
11982 (< (cdr (car range)) (car active)))
11983 (setcdr (car range) (1- (car active))))
11984 ;; Then we want to peel off any elements that are higher
11985 ;; than the upper active limit.
11986 (let ((srange range))
11987 ;; Go past all legal elements.
11988 (while (and (cdr srange)
11989 (<= (or (and (atom (car (cdr srange)))
11990 (car (cdr srange)))
11991 (car (car (cdr srange)))) (cdr active)))
11992 (setq srange (cdr srange)))
11994 ;; Nuke all remaining illegal elements.
11995 (setcdr srange nil))
11997 ;; Adjust the final element.
11998 (if (and (not (atom (car srange)))
11999 (> (cdr (car srange)) (cdr active)))
12000 (setcdr (car srange) (cdr active))))
12001 ;; Compute the number of unread articles.
12003 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12004 (cdr (car range))))
12005 (or (and (atom (car range)) (car range))
12006 (car (car range))))))
12007 (setq range (cdr range)))
12008 (setq num (max 0 (- (cdr active) num)))))
12011 (and (assq 'tick marked)
12012 (inline (gnus-remove-illegal-marked-articles
12013 (assq 'tick marked) (nth 2 info))))
12014 (and (assq 'dormant marked)
12015 (inline (gnus-remove-illegal-marked-articles
12016 (assq 'dormant marked) (nth 2 info))))
12018 (gnus-gethash (car info) gnus-newsrc-hashtb)
12019 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12020 (length (cdr (assq 'dormant marked)))))))))
12023 (defun gnus-remove-illegal-marked-articles (marked ranges)
12024 (let ((m (cdr marked)))
12025 ;; Make sure that all ticked articles are a subset of the unread
12028 (if (gnus-member-of-range (car m) ranges)
12029 (setcdr marked (cdr m))
12031 (setq m (cdr m)))))
12033 (defun gnus-activate-newsgroup (group)
12034 (let ((method (gnus-find-method-for-group group))
12036 (and (or (gnus-server-opened method) (gnus-open-server method))
12037 (gnus-request-group group)
12039 (set-buffer nntp-server-buffer)
12040 (goto-char (point-min))
12041 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12043 (goto-char (match-beginning 1))
12045 group (setq active (cons (read (current-buffer))
12046 (read (current-buffer))))
12047 gnus-active-hashtb))
12050 (defun gnus-update-read-articles
12051 (group unread unselected ticked &optional domarks replied expirable killed
12052 dormant bookmark score)
12053 "Update the list of read and ticked articles in GROUP using the
12054 UNREAD and TICKED lists.
12055 Note: UNSELECTED has to be sorted over `<'.
12056 Returns whether the updating was successful."
12057 (let* ((active (or gnus-newsgroup-active
12058 (gnus-gethash group gnus-active-hashtb)))
12059 (entry (gnus-gethash group gnus-newsrc-hashtb))
12060 (info (nth 2 entry))
12061 (marked (nth 3 info))
12063 (unread (sort (copy-sequence unread) (function <)))
12065 (if (or (not info) (not active))
12066 ;; There is no info on this group if it was, in fact,
12067 ;; killed. Gnus stores no information on killed groups, so
12068 ;; there's nothing to be done.
12069 ;; One could store the information somewhere temporarily,
12070 ;; perhaps... Hmmm...
12072 ;; Remove any negative articles numbers.
12073 (while (and unread (< (car unread) 0))
12074 (setq unread (cdr unread)))
12075 ;; Remove any expired article numbers
12076 (while (and unread (< (car unread) (car active)))
12077 (setq unread (cdr unread)))
12078 (while (and ticked (< (car ticked) (car active)))
12079 (setq ticked (cdr ticked)))
12080 (while (and dormant (< (car dormant) (car active)))
12081 (setq dormant (cdr dormant)))
12082 (setq unread (sort (append unselected unread) '<))
12083 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12084 (setcar entry (max 0 (- (length unread) (length ticked)
12085 (length dormant))))
12086 ;; Compute the ranges of read articles by looking at the list of
12087 ;; unread articles.
12089 (if (/= (car unread) prev)
12090 (setq read (cons (if (= prev (1- (car unread))) prev
12091 (cons prev (1- (car unread)))) read)))
12092 (setq prev (1+ (car unread)))
12093 (setq unread (cdr unread)))
12094 (if (<= prev (cdr active))
12095 (setq read (cons (cons prev (cdr active)) read)))
12096 ;; Enter this list into the group info.
12097 (setcar (cdr (cdr info))
12098 (if (> (length read) 1) (nreverse read) read))
12099 ;; Enter the list of ticked articles.
12100 (gnus-set-marked-articles
12102 (if domarks replied (cdr (assq 'reply marked)))
12103 (if domarks expirable (cdr (assq 'expire marked)))
12104 (if domarks killed (cdr (assq 'killed marked)))
12105 (if domarks dormant (cdr (assq 'dormant marked)))
12106 (if domarks bookmark (cdr (assq 'bookmark marked)))
12107 (if domarks score (cdr (assq 'score marked))))
12110 (defun gnus-make-articles-unread (group articles)
12111 "Mark ARTICLES in GROUP as unread."
12112 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12113 (gnus-gethash (gnus-group-real-name group)
12114 gnus-newsrc-hashtb))))
12115 (ranges (nth 2 info))
12118 (and (gnus-member-of-range (car articles) ranges)
12119 (setq news (cons (car articles) news)))
12120 (setq articles (cdr articles)))
12123 (setcar (nthcdr 2 info)
12124 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12125 (gnus-group-update-group group t))))
12127 ;; Get the active file(s) from the backend(s).
12128 (defun gnus-read-active-file ()
12129 (gnus-group-set-mode-line)
12130 (let ((methods (if (or (gnus-server-opened gnus-select-method)
12131 (gnus-open-server gnus-select-method))
12132 ;; The native server is available.
12133 (cons gnus-select-method gnus-secondary-select-methods)
12134 ;; The native server is down, so we just do the
12136 gnus-secondary-select-methods))
12138 (setq gnus-have-read-active-file nil)
12140 (set-buffer nntp-server-buffer)
12142 (let* ((where (nth 1 (car methods)))
12143 (mesg (format "Reading active file%s via %s..."
12144 (if (and where (not (zerop (length where))))
12145 (concat " from " where) "")
12146 (car (car methods)))))
12147 (gnus-message 5 mesg)
12148 (gnus-check-news-server (car methods))
12150 ((and (eq gnus-read-active-file 'some)
12151 (gnus-check-backend-function
12152 'retrieve-groups (car (car methods))))
12153 (let ((newsrc (cdr gnus-newsrc-alist))
12156 (and (gnus-server-equal
12157 (gnus-find-method-for-group
12158 (car (car newsrc)) (car newsrc))
12159 (gnus-server-get-method nil (car methods)))
12160 (setq groups (cons (car (car newsrc)) groups)))
12161 (setq newsrc (cdr newsrc)))
12162 (setq list-type (gnus-retrieve-groups groups (car methods)))
12163 (cond ((not list-type)
12165 1 "Cannot read partial active file from %s server."
12166 (car (car methods)))
12169 ((eq list-type 'active)
12170 (gnus-active-to-gnus-format (car methods)))
12172 (gnus-groups-to-gnus-format (car methods))))))
12174 (if (not (gnus-request-list (car methods)))
12176 (gnus-message 1 "Cannot read active file from %s server."
12177 (car (car methods)))
12179 (gnus-active-to-gnus-format (car methods))
12180 (setq gnus-have-read-active-file t)
12181 (gnus-message 5 "%sdone" mesg)))))
12182 (setq methods (cdr methods))))))
12184 ;; Read an active file and place the results in `gnus-active-hashtb'.
12185 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12186 (let ((cur (current-buffer))
12188 (if (and gnus-active-hashtb
12189 (not (equal method gnus-select-method)))
12191 (setq gnus-active-hashtb
12192 (if (equal method gnus-select-method)
12193 (gnus-make-hashtable
12194 (count-lines (point-min) (point-max)))
12195 (gnus-make-hashtable 4096)))))))
12196 ;; Delete unnecessary lines.
12197 (goto-char (point-min))
12198 (while (search-forward "\nto." nil t)
12199 (delete-region (1+ (match-beginning 0))
12200 (progn (forward-line 1) (point))))
12201 (or (string= gnus-ignored-newsgroups "")
12203 (goto-char (point-min))
12204 (delete-matching-lines gnus-ignored-newsgroups)))
12205 ;; If these are groups from a foreign select method, we insert the
12206 ;; group prefix in front of the group names.
12207 (and method (not (eq method gnus-select-method))
12208 (let ((prefix (gnus-group-prefixed-name "" method)))
12209 (goto-char (point-min))
12210 (while (and (not (eobp))
12211 (progn (insert prefix)
12212 (zerop (forward-line 1)))))))
12213 (goto-char (point-min))
12214 ;; Store active file in hashtable.
12215 (goto-char (point-min))
12216 (if (string-match "%[oO]" gnus-group-line-format)
12217 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12218 ;; If we want information on moderated groups, we use this
12220 (let* ((mod-hashtb (make-vector 7 0))
12221 (m (intern "m" mod-hashtb))
12223 (while (not (eobp))
12224 (condition-case nil
12226 (narrow-to-region (point) (gnus-point-at-eol))
12227 (setq group (let ((obarray hashtb)) (read cur)))
12228 (if (and (numberp (setq max (read cur)))
12229 (numberp (setq min (read cur))))
12230 (set group (cons min max))
12232 ;; Enter moderated groups into a list.
12233 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12234 (setq gnus-moderated-list
12235 (cons (symbol-name group) gnus-moderated-list))))
12239 ;; And if we do not care about moderation, we use this loop,
12240 ;; which is faster.
12241 (let (group max min)
12242 (while (not (eobp))
12245 (narrow-to-region (point) (gnus-point-at-eol))
12246 ;; group gets set to a symbol interned in the hash table
12248 (setq group (let ((obarray hashtb)) (read cur)))
12249 (if (and (numberp (setq max (read cur)))
12250 (numberp (setq min (read cur))))
12251 (set group (cons min max))
12258 (gnus-message 3 "Warning - illegal active: %s"
12260 (gnus-point-at-bol) (gnus-point-at-eol)))
12263 (forward-line 1))))))
12265 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12266 ;; Parse a "groups" active file.
12267 (let ((cur (current-buffer))
12271 (setq gnus-active-hashtb
12272 (gnus-make-hashtable
12273 (count-lines (point-min) (point-max)))))))
12274 (prefix (and method (not (eq method gnus-select-method))
12275 (gnus-group-prefixed-name "" method))))
12277 (goto-char (point-min))
12279 ;; We split this into to separate loops, one with the prefix
12280 ;; and one without to speed the reading up somewhat.
12282 (let (min max opoint)
12283 (while (not (eobp))
12284 (read cur) (read cur)
12285 (setq min (read cur)
12288 (skip-chars-forward " \t")
12291 (set (let ((obarray hashtb)) (read cur))
12295 (while (not (eobp))
12296 (if (= (following-char) ?2)
12298 (read cur) (read cur)
12299 (setq min (read cur)
12301 (set (let ((obarray hashtb)) (read cur))
12303 (forward-line 1))))
12305 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
12307 (defun gnus-read-newsrc-file (&optional force)
12308 "Read startup file.
12309 If FORCE is non-nil, the .newsrc file is read."
12310 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12311 ;; Reset variables that might be defined in the .newsrc.eld file.
12312 (let ((variables gnus-variable-list))
12314 (set (car variables) nil)
12315 (setq variables (cdr variables))))
12316 (let* ((newsrc-file gnus-current-startup-file)
12317 (quick-file (concat newsrc-file ".el")))
12319 ;; We always load the .newsrc.eld file. If always contains
12320 ;; much information that can not be gotten from the .newsrc
12321 ;; file (ticked articles, killed groups, foreign methods, etc.)
12322 (gnus-read-newsrc-el-file quick-file)
12325 (and (file-newer-than-file-p newsrc-file quick-file)
12326 (file-newer-than-file-p newsrc-file
12327 (concat quick-file "d")))
12328 (not gnus-newsrc-alist))
12329 ;; We read the .newsrc file. Note that if there if a
12330 ;; .newsrc.eld file exists, it has already been read, and
12331 ;; the `gnus-newsrc-hashtb' has been created. While reading
12332 ;; the .newsrc file, Gnus will only use the information it
12333 ;; can find there for changing the data already read -
12334 ;; ie. reading the .newsrc file will not trash the data
12335 ;; already read (except for read articles).
12337 (gnus-message 5 "Reading %s..." newsrc-file)
12338 (set-buffer (find-file-noselect newsrc-file))
12339 (buffer-disable-undo (current-buffer))
12340 (gnus-newsrc-to-gnus-format)
12341 (kill-buffer (current-buffer))
12342 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12344 (defun gnus-read-newsrc-el-file (file)
12345 (let ((ding-file (concat file "d")))
12346 ;; We always, always read the .eld file.
12347 (gnus-message 5 "Reading %s..." ding-file)
12348 (let (gnus-newsrc-assoc)
12349 (condition-case nil
12350 (load ding-file t t t)
12352 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12353 (let ((inhibit-quit t))
12354 (gnus-uncompress-newsrc-alist))
12355 (gnus-make-hashtable-from-newsrc-alist)
12356 (if (not (file-newer-than-file-p file ding-file))
12358 ;; Old format quick file
12359 (gnus-message 5 "Reading %s..." file)
12360 ;; The .el file is newer than the .eld file, so we read that one
12362 (gnus-read-old-newsrc-el-file file))))
12364 ;; Parse the old-style quick startup file
12365 (defun gnus-read-old-newsrc-el-file (file)
12366 (let (newsrc killed marked group m)
12368 (let ((gnus-killed-assoc nil)
12369 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12371 (condition-case nil
12374 (setq newsrc gnus-newsrc-assoc
12375 killed gnus-killed-assoc
12376 marked gnus-marked-assoc)))
12377 (setq gnus-newsrc-alist nil)
12379 (setq group (car newsrc))
12380 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12383 (setcar (nthcdr 2 info) (cdr (cdr group)))
12385 (if (nth 1 group) gnus-level-default-subscribed
12386 gnus-level-default-unsubscribed))
12387 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
12388 (setq gnus-newsrc-alist
12392 (if (nth 1 group) gnus-level-default-subscribed
12393 gnus-level-default-unsubscribed)
12394 (cdr (cdr group))))
12395 gnus-newsrc-alist)))
12396 (if (setq m (assoc (car group) marked))
12397 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12398 (setq newsrc (cdr newsrc)))
12399 (setq newsrc killed)
12401 (setcar newsrc (car (car newsrc)))
12402 (setq newsrc (cdr newsrc)))
12403 (setq gnus-killed-list killed))
12404 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
12405 (gnus-make-hashtable-from-newsrc-alist)))
12407 (defun gnus-make-newsrc-file (file)
12408 "Make server dependent file name by catenating FILE and server host name."
12409 (let* ((file (expand-file-name file nil))
12410 (real-file (concat file "-" (nth 1 gnus-select-method))))
12411 (if (file-exists-p real-file)
12414 (defun gnus-uncompress-newsrc-alist ()
12415 ;; Uncompress all lists of marked articles in the newsrc assoc.
12416 (let ((newsrc gnus-newsrc-alist)
12419 (if (not (setq marked (nth 3 (car newsrc))))
12422 (or (eq 'score (car (car marked)))
12423 (eq 'bookmark (car (car marked)))
12424 (eq 'killed (car (car marked)))
12425 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12426 (setq marked (cdr marked))))
12427 (setq newsrc (cdr newsrc)))))
12429 (defun gnus-compress-newsrc-alist ()
12430 ;; Compress all lists of marked articles in the newsrc assoc.
12431 (let ((newsrc gnus-newsrc-alist)
12434 (if (not (setq marked (nth 3 (car newsrc))))
12437 (or (eq 'score (car (car marked)))
12438 (eq 'bookmark (car (car marked)))
12439 (eq 'killed (car (car marked)))
12440 (setcdr (car marked)
12442 (gnus-compress-sequence
12443 (sort (cdr (car marked)) '<) t)
12444 (error (cdr (car marked))))))
12445 (setq marked (cdr marked))))
12446 (setq newsrc (cdr newsrc)))))
12448 (defun gnus-newsrc-to-gnus-format ()
12449 (setq gnus-newsrc-options "")
12450 (setq gnus-newsrc-options-n nil)
12452 (or gnus-active-hashtb
12453 (setq gnus-active-hashtb (make-vector 4095 0)))
12454 (let ((buf (current-buffer))
12455 (already-read (> (length gnus-newsrc-alist) 1))
12456 group subscribed options-symbol newsrc
12458 (goto-char (point-min))
12459 ;; We intern the symbol `options' in the active hashtb so that we
12460 ;; can `eq' against it later.
12461 (setq options-symbol (intern "options" gnus-active-hashtb))
12463 (while (not (eobp))
12464 ;; We first read the first word on the line by narrowing and
12465 ;; then reading into `gnus-active-hashtb'. Most groups will
12466 ;; already exist in that hashtb, so this will save some string
12470 (progn (skip-chars-forward "^ \t!:\n") (point)))
12471 (goto-char (point-min))
12473 (and (/= (point-min) (point-max))
12474 (let ((obarray gnus-active-hashtb)) (read buf))))
12476 ;; Now, the symbol we have read is either `options' or a group
12477 ;; name. If it is an options line, we just add it to a string.
12479 ((eq symbol options-symbol)
12480 (setq gnus-newsrc-options
12481 ;; This concatting is quite inefficient, but since our
12482 ;; thorough studies show that approx 99.37% of all
12483 ;; .newsrc files only contain a single options line, we
12484 ;; don't give a damn, frankly, my dear.
12485 (concat gnus-newsrc-options
12487 (gnus-point-at-bol)
12488 ;; Options may continue on the next line.
12489 (or (and (re-search-forward "^[^ \t]" nil 'move)
12490 (progn (beginning-of-line) (point)))
12493 ;; It was a group name.
12494 (setq subscribed (= (following-char) ?:)
12495 group (symbol-name symbol)
12498 ;; If the line ends here, this is clearly a buggy line, so
12499 ;; we put point a the beginning of line and let the cond
12500 ;; below do the error handling.
12501 (beginning-of-line)
12502 ;; We skip to the beginning of the ranges.
12503 (skip-chars-forward "!: \t"))
12504 ;; We are now at the beginning of the list of read articles.
12505 ;; We read them range by range.
12508 ((looking-at "[0-9]+")
12509 ;; We narrow and read a number instead of buffer-substring/
12510 ;; string-to-int because it's faster. narrow/widen is
12511 ;; faster than save-restriction/narrow, and save-restriction
12512 ;; produces a garbage object.
12514 (narrow-to-region (match-beginning 0) (match-end 0))
12517 ;; If the next character is a dash, then this is a range.
12518 (if (= (following-char) ?-)
12520 ;; We read the upper bound of the range.
12522 (if (not (looking-at "[0-9]+"))
12523 ;; This is a buggy line, by we pretend that
12524 ;; it's kinda OK. Perhaps the user should be
12526 (setq reads (cons num1 reads))
12530 (narrow-to-region (match-beginning 0)
12535 ;; It was just a simple number, so we add it to the
12537 (setq reads (cons num1 reads)))
12538 ;; If the next char in ?\n, then we have reached the end
12539 ;; of the line and return nil.
12540 (/= (following-char) ?\n))
12541 ((= (following-char) ?\n)
12542 ;; End of line, so we end.
12545 ;; Not numbers and not eol, so this might be a buggy
12547 (or (eobp) ; If it was eob instead of ?\n, we allow it.
12549 ;; The line was buggy.
12551 (gnus-message 3 "Mangled line: %s"
12552 (buffer-substring (gnus-point-at-bol)
12553 (gnus-point-at-eol)))
12557 ;; Skip past ", ". Spaces are illegal in these ranges, but
12558 ;; we allow them, because it's a common mistake to put a
12559 ;; space after the comma.
12560 (skip-chars-forward ", "))
12562 ;; We have already read .newsrc.eld, so we gently update the
12563 ;; data in the hash table with the information we have just
12567 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12570 ;; There is an entry for this file in the alist.
12572 (setcar (nthcdr 2 info) (nreverse reads))
12573 ;; We update the level very gently. In fact, we
12574 ;; only change it if there's been a status change
12575 ;; from subscribed to unsubscribed, or vice versa.
12576 (setq level (nth 1 info))
12577 (cond ((and (<= level gnus-level-subscribed)
12579 (setq level (if reads
12580 gnus-level-default-unsubscribed
12581 (1+ gnus-level-default-unsubscribed))))
12582 ((and (> level gnus-level-subscribed) subscribed)
12583 (setq level gnus-level-default-subscribed)))
12584 (setcar (cdr info) level))
12585 ;; This is a new group.
12586 (setq info (list group
12588 gnus-level-default-subscribed
12590 (1+ gnus-level-subscribed)
12591 gnus-level-default-unsubscribed))
12592 (nreverse reads))))
12593 (setq newsrc (cons info newsrc))))))
12596 (setq newsrc (nreverse newsrc))
12598 (if (not already-read)
12600 ;; We now have two newsrc lists - `newsrc', which is what we
12601 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
12602 ;; what we've read from .newsrc.eld. We have to merge these
12603 ;; lists. We do this by "attaching" any (foreign) groups in the
12604 ;; gnus-newsrc-alist to the (native) group that precedes them.
12605 (let ((rc (cdr gnus-newsrc-alist))
12606 (prev gnus-newsrc-alist)
12609 (or (null (nth 4 (car rc))) ; It's a native group.
12610 (assoc (car (car rc)) newsrc) ; It's already in the alist.
12611 (if (setq entry (assoc (car (car prev)) newsrc))
12612 (setcdr (setq mentry (memq entry newsrc))
12613 (cons (car rc) (cdr mentry)))
12614 (setq newsrc (cons (car rc) newsrc))))
12618 (setq gnus-newsrc-alist newsrc)
12619 ;; We make the newsrc hashtb.
12620 (gnus-make-hashtable-from-newsrc-alist)
12622 ;; Finally, if we read some options lines, we parse them.
12623 (or (string= gnus-newsrc-options "")
12624 (gnus-newsrc-parse-options gnus-newsrc-options))))
12626 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12627 ;; The return value will be a list on the form
12628 ;; ((regexp1 . ignore)
12629 ;; (regexp2 . subscribe)...)
12630 ;; When handling new newsgroups, groups that match a `ignore' regexp
12631 ;; will be ignored, and groups that match a `subscribe' regexp will be
12632 ;; subscribed. A line like
12633 ;; options -n !all rec.all
12634 ;; will lead to a list that looks like
12635 ;; (("^rec\\..+" . subscribe)
12636 ;; ("^.+" . ignore))
12637 ;; So all "rec.*" groups will be subscribed, while all the other
12638 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12639 ;; different from "options -n rec.all !all".
12640 (defun gnus-newsrc-parse-options (options)
12643 (gnus-set-work-buffer)
12644 (insert (regexp-quote options))
12645 ;; First we treat all continuation lines.
12646 (goto-char (point-min))
12647 (while (re-search-forward "\n[ \t]+" nil t)
12648 (replace-match " " t t))
12649 ;; Then we transform all "all"s into ".+"s.
12650 (goto-char (point-min))
12651 (while (re-search-forward "\\ball\\b" nil t)
12652 (replace-match ".+" t t))
12653 (goto-char (point-min))
12654 ;; We remove all other options than the "-n" ones.
12655 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12656 (replace-match " ")
12658 (goto-char (point-min))
12660 ;; We are only interested in "options -n" lines - we
12661 ;; ignore the other option lines.
12662 (while (re-search-forward "[ \t]-n" nil t)
12664 (or (save-excursion
12665 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12667 (gnus-point-at-eol)))
12668 ;; Search for all "words"...
12669 (while (re-search-forward "[^ \t,\n]+" eol t)
12670 (if (= (char-after (match-beginning 0)) ?!)
12671 ;; If the word begins with a bang (!), this is a "not"
12672 ;; spec. We put this spec (minus the bang) and the
12673 ;; symbol `ignore' into the list.
12674 (setq out (cons (cons (concat
12675 "^" (buffer-substring
12676 (1+ (match-beginning 0))
12679 ;; There was no bang, so this is a "yes" spec.
12680 (setq out (cons (cons (concat
12681 "^" (buffer-substring (match-beginning 0)
12683 'subscribe) out)))))
12685 (setq gnus-newsrc-options-n out))))
12688 (defun gnus-save-newsrc-file ()
12689 "Save .newsrc file."
12690 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12691 ;; from the variable gnus-newsrc-alist.
12692 (and (or gnus-newsrc-alist gnus-killed-list)
12693 gnus-current-startup-file
12695 (run-hooks 'gnus-save-newsrc-hook)
12697 (if (or (not gnus-dribble-buffer)
12698 (not (buffer-name gnus-dribble-buffer))
12699 (zerop (save-excursion
12700 (set-buffer gnus-dribble-buffer)
12702 (gnus-message 4 "(No changes need to be saved)")
12703 (if gnus-save-newsrc-file
12705 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12706 ;; Make backup file of master newsrc.
12707 (gnus-gnus-to-newsrc-format)
12708 (gnus-message 5 "Saving %s...done"
12709 gnus-current-startup-file)))
12710 ;; Quickly loadable .newsrc.
12711 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12712 (set-visited-file-name (concat gnus-current-startup-file ".eld"))
12713 (gnus-add-current-to-buffer-list)
12714 (buffer-disable-undo (current-buffer))
12716 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12717 (gnus-gnus-to-quick-newsrc-format)
12719 (kill-buffer (current-buffer))
12720 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
12721 (gnus-dribble-delete-file))))))
12723 (defun gnus-gnus-to-quick-newsrc-format ()
12724 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12725 (insert ";; (ding) Gnus startup file.\n")
12726 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12727 (insert ";; to read .newsrc.\n")
12728 (let ((variables gnus-variable-list)
12730 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12732 ;; insert lisp expressions.
12733 (gnus-compress-newsrc-alist)
12735 (setq variable (car variables))
12736 (and (boundp variable)
12737 (symbol-value variable)
12738 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12739 (insert "(setq " (symbol-name variable) " '"
12740 (prin1-to-string (symbol-value variable))
12742 (setq variables (cdr variables)))
12743 (gnus-uncompress-newsrc-alist)))
12746 (defun gnus-gnus-to-newsrc-format ()
12747 ;; Generate and save the .newsrc file.
12748 (let ((newsrc (cdr gnus-newsrc-alist))
12751 (set-buffer (create-file-buffer gnus-startup-file))
12752 (set-visited-file-name gnus-startup-file)
12753 (buffer-disable-undo (current-buffer))
12756 (if gnus-newsrc-options (insert gnus-newsrc-options))
12757 ;; Write subscribed and unsubscribed.
12759 (setq info (car newsrc))
12760 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12762 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12764 (if (setq ranges (nth 2 info))
12767 (if (not (listp (cdr ranges)))
12768 (if (= (car ranges) (cdr ranges))
12769 (insert (int-to-string (car ranges)))
12770 (insert (int-to-string (car ranges)) "-"
12771 (int-to-string (cdr ranges))))
12773 (setq range (car ranges)
12774 ranges (cdr ranges))
12775 (if (or (atom range) (= (car range) (cdr range)))
12776 (insert (int-to-string
12777 (or (and (atom range) range)
12779 (insert (int-to-string (car range)) "-"
12780 (int-to-string (cdr range))))
12781 (if ranges (insert ","))))))
12783 (setq newsrc (cdr newsrc)))
12785 (kill-buffer (current-buffer)))))
12787 (defun gnus-read-all-descriptions-files ()
12788 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
12790 (gnus-read-descriptions-file (car methods))
12791 (setq methods (cdr methods)))
12794 (defun gnus-read-descriptions-file (&optional method)
12795 (let ((method (or method gnus-select-method)))
12796 ;; We create the hashtable whether we manage to read the desc file
12797 ;; to avoid trying to re-read after a failed read.
12798 (or gnus-description-hashtb
12799 (setq gnus-description-hashtb
12800 (gnus-make-hashtable (length gnus-active-hashtb))))
12801 ;; Mark this method's desc file as read.
12802 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
12803 gnus-description-hashtb)
12805 (gnus-message 5 "Reading descriptions file via %s..." (car method))
12807 ((not (or (gnus-server-opened method)
12808 (gnus-open-server method)))
12809 (gnus-message 1 "Couldn't open server")
12811 ((not (gnus-request-list-newsgroups method))
12812 (gnus-message 1 "Couldn't read newsgroups descriptions")
12818 (set-buffer nntp-server-buffer)
12819 (goto-char (point-min))
12820 (if (or (search-forward "\n.\n" nil t)
12821 (goto-char (point-max)))
12823 (beginning-of-line)
12824 (narrow-to-region (point-min) (point))))
12825 (goto-char (point-min))
12826 (while (not (eobp))
12827 ;; If we get an error, we set group to 0, which is not a
12831 (let ((obarray gnus-description-hashtb))
12832 ;; Group is set to a symbol interned in this
12834 (read nntp-server-buffer))
12836 (skip-chars-forward " \t")
12837 ;; ... which leads to this line being effectively ignored.
12838 (and (symbolp group)
12839 (set group (buffer-substring
12840 (point) (progn (end-of-line) (point)))))
12841 (forward-line 1))))
12842 (gnus-message 5 "Reading descriptions file...done")
12845 (defun gnus-group-get-description (group)
12846 ;; Get the description of a group by sending XGTITLE to the server.
12847 (and (gnus-request-group-description group)
12849 (set-buffer nntp-server-buffer)
12850 (goto-char (point-min))
12851 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12852 (buffer-substring (match-beginning 1) (match-end 1))))))
12858 (defvar gnus-server-mode-hook nil
12859 "Hook run in `gnus-server-mode' buffers.")
12861 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12862 "Format of server lines.
12863 It works along the same lines as a normal formatting string,
12864 with some simple extensions.")
12866 (defvar gnus-server-mode-line-format "(ding) List of servers"
12867 "The format specification for the server mode line.")
12869 (defconst gnus-server-line-format-alist
12870 (list (list ?h 'how ?s)
12872 (list ?w 'where ?s)
12875 (defconst gnus-server-mode-line-format-alist
12876 (list (list ?S 'news-server ?s)
12877 (list ?M 'news-method ?s)
12878 (list ?u 'user-defined ?s)))
12880 (defvar gnus-server-line-format-spec nil)
12881 (defvar gnus-server-mode-line-format-spec nil)
12882 (defvar gnus-server-killed-servers nil)
12884 (defvar gnus-server-mode-map nil)
12885 (put 'gnus-server-mode 'mode-class 'special)
12887 (if gnus-server-mode-map
12889 (setq gnus-server-mode-map (make-sparse-keymap))
12890 (suppress-keymap gnus-server-mode-map)
12891 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12892 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12893 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12894 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12895 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12896 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12897 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12898 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12899 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12900 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12902 (defun gnus-server-mode ()
12903 "Major mode for listing and editing servers.
12905 All normal editing commands are switched off.
12906 \\<gnus-server-mode-map>
12908 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12910 The following commands are available:
12912 \\{gnus-server-mode-map}"
12914 (if gnus-visual (gnus-server-make-menu-bar))
12915 (kill-all-local-variables)
12916 (setq mode-line-modified "-- ")
12917 (make-local-variable 'mode-line-format)
12918 (setq mode-line-format (copy-sequence mode-line-format))
12919 (and (equal (nth 3 mode-line-format) " ")
12920 (setcar (nthcdr 3 mode-line-format) ""))
12921 (setq major-mode 'gnus-server-mode)
12922 (setq mode-name "Server")
12923 ; (gnus-group-set-mode-line)
12924 (setq mode-line-process nil)
12925 (use-local-map gnus-server-mode-map)
12926 (buffer-disable-undo (current-buffer))
12927 (setq truncate-lines t)
12928 (setq buffer-read-only t)
12929 (run-hooks 'gnus-server-mode-hook))
12931 (defun gnus-server-insert-server-line (sformat name method)
12932 (let* ((sformat (or sformat gnus-server-line-format-spec))
12934 (where (nth 1 method))
12936 (beginning-of-line)
12938 ;; Insert the text.
12939 (insert (eval sformat))
12940 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
12942 (defun gnus-server-setup-buffer ()
12943 (if (get-buffer gnus-server-buffer)
12946 (set-buffer (get-buffer-create gnus-server-buffer))
12948 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
12950 (defun gnus-server-prepare ()
12951 (setq gnus-server-mode-line-format-spec
12952 (gnus-parse-format gnus-server-mode-line-format
12953 gnus-server-mode-line-format-alist))
12954 (setq gnus-server-line-format-spec
12955 (gnus-parse-format gnus-server-line-format
12956 gnus-server-line-format-alist))
12957 (let ((alist gnus-server-alist)
12958 (buffer-read-only nil))
12961 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
12962 (setq alist (cdr alist))))
12963 (goto-char (point-min))
12964 (gnus-server-position-cursor))
12966 (defun gnus-server-server-name ()
12967 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
12968 (and server (symbol-name server))))
12970 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
12972 (defconst gnus-server-edit-buffer "*Gnus edit server*")
12974 (defun gnus-server-update-server (server)
12976 (set-buffer gnus-server-buffer)
12977 (let ((buffer-read-only nil)
12978 (info (cdr (assoc server gnus-server-alist))))
12979 (gnus-dribble-enter
12980 (concat "(gnus-server-set-info \"" server "\" '"
12981 (prin1-to-string info) ")"))
12982 ;; Buffer may be narrowed.
12985 (if (gnus-server-goto-server server)
12986 (delete-region (progn (beginning-of-line) (point))
12987 (progn (forward-line 1) (point))))
12988 (let ((entry (assoc server gnus-server-alist)))
12989 (gnus-server-insert-server-line nil (car entry) (cdr entry))
12990 (gnus-server-position-cursor))))))
12992 (defun gnus-server-set-info (server info)
12993 ;; Enter a select method into the virtual server alist.
12994 (gnus-dribble-enter
12995 (concat "(gnus-server-set-info \"" server "\" '"
12996 (prin1-to-string info) ")"))
12997 (let* ((server (nth 1 info))
12998 (entry (assoc server gnus-server-alist)))
12999 (if entry (setcdr entry info)
13000 (setq gnus-server-alist
13001 (nconc gnus-server-alist (list (cons server info)))))))
13003 (defun gnus-server-to-method (server)
13004 ;; Map virtual server names to select methods.
13005 (or (and (equal server "native") gnus-select-method)
13006 (cdr (assoc server gnus-server-alist))))
13008 (defun gnus-server-extend-method (group method)
13009 ;; This function "extends" a virtual server. If the server is
13010 ;; "hello", and the select method is ("hello" (my-var "something"))
13011 ;; in the group "alt.alt", this will result in a new virtual server
13012 ;; called "helly+alt.alt".
13014 (gnus-copy-sequence
13015 (if (equal (car method) "native") gnus-select-method
13016 (cdr (assoc (car method) gnus-server-alist))))))
13017 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13018 (nconc entry (cdr method))))
13020 (defun gnus-server-get-method (group method)
13021 ;; Input either a server name, and extended server name, or a
13022 ;; select method, and return a select method.
13023 (cond ((stringp method)
13024 (gnus-server-to-method method))
13025 ((stringp (car method))
13026 (gnus-server-extend-method group method))
13028 (gnus-server-add-address method))))
13030 (defun gnus-server-add-address (method)
13031 (let ((method-name (symbol-name (car method))))
13032 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13033 (not (assq (intern (concat method-name "-address")) method)))
13034 (append method (list (list (intern (concat method-name "-address"))
13038 (defun gnus-server-equal (s1 s2)
13040 (and (= (length s1) (length s2))
13042 (while (and s1 (member (car s1) s2))
13043 (setq s1 (cdr s1)))
13046 ;;; Interactive server functions.
13048 (defun gnus-server-kill-server (server)
13049 "Kill the server on the current line."
13050 (interactive (list (gnus-server-server-name)))
13051 (or (gnus-server-goto-server server)
13052 (if server (error "No such server: %s" server)
13053 (error "No server on the current line")))
13054 (let ((buffer-read-only nil))
13055 (delete-region (progn (beginning-of-line) (point))
13056 (progn (forward-line 1) (point))))
13057 (setq gnus-server-killed-servers
13058 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13059 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13060 gnus-server-alist))
13061 (gnus-server-position-cursor))
13063 (defun gnus-server-yank-server ()
13064 "Yank the previously killed server."
13066 (or gnus-server-killed-servers
13067 (error "No killed servers to be yanked"))
13068 (let ((alist gnus-server-alist)
13069 (server (gnus-server-server-name))
13070 (killed (car gnus-server-killed-servers)))
13072 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13073 (if (string= server (car (car gnus-server-alist)))
13074 (setq gnus-server-alist (cons killed gnus-server-alist))
13075 (while (and (cdr alist)
13076 (not (string= server (car (car (cdr alist))))))
13077 (setq alist (cdr alist)))
13078 (setcdr alist (cons killed (cdr alist)))))
13079 (gnus-server-update-server (car killed))
13080 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13081 (gnus-server-position-cursor)))
13083 (defun gnus-server-exit ()
13084 "Return to the group buffer."
13086 (kill-buffer (current-buffer))
13087 (switch-to-buffer gnus-group-buffer))
13089 (defun gnus-server-list-servers ()
13090 "List all available servers."
13092 (let ((cur (gnus-server-server-name)))
13093 (gnus-server-prepare)
13094 (if cur (gnus-server-goto-server cur)
13095 (goto-char (point-max))
13097 (gnus-server-position-cursor)))
13099 (defun gnus-server-copy-server (from to)
13102 (or (gnus-server-server-name)
13103 (error "No server on the current line"))
13104 (read-string "Copy to: ")))
13105 (or from (error "No server on current line"))
13106 (or (and to (not (string= to ""))) (error "No name to copy to"))
13107 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13108 (or (assoc from gnus-server-alist)
13109 (error "%s: no such server" from))
13110 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13111 (setcar to-entry to)
13112 (setcar (nthcdr 2 to-entry) to)
13113 (setq gnus-server-killed-servers
13114 (cons to-entry gnus-server-killed-servers))
13115 (gnus-server-yank-server)))
13117 (defun gnus-server-add-server (how where)
13119 (list (intern (completing-read "Server method: "
13120 gnus-valid-select-methods nil t))
13121 (read-string "Server name: ")))
13122 (setq gnus-server-killed-servers
13123 (cons (list where how where) gnus-server-killed-servers))
13124 (gnus-server-yank-server))
13126 (defun gnus-server-goto-server (server)
13127 "Jump to a server line."
13129 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13130 (let ((to (text-property-any (point-min) (point-max)
13131 'gnus-server (intern server))))
13135 (gnus-server-position-cursor)))))
13137 (defun gnus-server-edit-server (server)
13138 "Edit the server on the current line."
13139 (interactive (list (gnus-server-server-name)))
13141 (error "No server on current line"))
13142 (let ((winconf (current-window-configuration)))
13143 (get-buffer-create gnus-server-edit-buffer)
13144 (gnus-configure-windows 'edit-server)
13145 (gnus-add-current-to-buffer-list)
13147 (make-local-variable 'gnus-prev-winconf)
13148 (setq gnus-prev-winconf winconf)
13149 (use-local-map (copy-keymap (current-local-map)))
13150 (let ((done-func '(lambda ()
13151 "Exit editing mode and update the information."
13153 (gnus-server-edit-server-done 'group))))
13154 (setcar (cdr (nth 4 done-func)) server)
13155 (local-set-key "\C-c\C-c" done-func))
13157 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13158 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13160 (defun gnus-server-edit-server-done (server)
13162 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13163 (goto-char (point-min))
13164 (let ((form (read (current-buffer)))
13165 (winconf gnus-prev-winconf))
13166 (gnus-server-set-info server form)
13167 (kill-buffer (current-buffer))
13168 (and winconf (set-window-configuration winconf))
13169 (set-buffer gnus-server-buffer)
13170 (gnus-server-update-server (gnus-server-server-name))
13171 (gnus-server-position-cursor)))
13173 (defun gnus-server-read-server (server)
13175 (interactive (list (gnus-server-server-name)))
13176 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13178 (defun gnus-mouse-pick-server (e)
13180 (mouse-set-point e)
13181 (gnus-server-read-server (gnus-server-server-name)))
13184 ;;; entry points into gnus-score.el
13187 ;;; Finding score files.
13189 (defvar gnus-global-score-files nil
13190 "*List of global score files and directories.
13191 Set this variable if you want to use people's score files. One entry
13192 for each score file or each score file directory. Gnus will decide
13193 by itself what score files are applicable to which group.
13195 Say you want to use the single score file
13196 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13197 score files in the \"/ftp.some-where:/pub/score\" directory.
13199 (setq gnus-global-score-files
13200 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13201 \"/ftp.some-where:/pub/score\"))")
13203 (defun gnus-score-score-files (group)
13204 "Return a list of all possible score files."
13205 ;; Search and set any global score files.
13206 (and gnus-global-score-files
13207 (or gnus-internal-global-score-files
13208 (gnus-score-search-global-directories gnus-global-score-files)))
13209 ;; Fix the kill-file dir variable.
13210 (setq gnus-kill-files-directory
13211 (file-name-as-directory
13212 (or gnus-kill-files-directory "~/News/")))
13213 ;; If we can't read it, there are no score files.
13214 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13215 (setq gnus-score-file-list nil)
13216 (if (gnus-use-long-file-name 'not-score)
13217 ;; We want long file names.
13218 (if (or (not gnus-score-file-list)
13219 (not (car gnus-score-file-list))
13220 (gnus-file-newer-than gnus-kill-files-directory
13221 (car gnus-score-file-list)))
13222 (setq gnus-score-file-list
13223 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13226 gnus-kill-files-directory t
13227 (gnus-score-file-regexp))))))
13228 ;; We do not use long file names, so we have to do some
13229 ;; directory traversing.
13230 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13231 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13234 (setq dir (expand-file-name
13235 (concat gnus-kill-files-directory
13236 (gnus-replace-chars-in-string group ?. ?/))))
13237 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13238 (setq suffix (car suffixes)
13239 suffixes (cdr suffixes))
13240 (if (file-exists-p (concat dir "/" suffix))
13241 (setq files (cons (concat dir "/" suffix) files)))
13242 (while (>= (1+ (length dir)) mdir)
13243 (and (file-exists-p (concat dir "/all/" suffix))
13244 (setq files (cons (concat dir "/all/" suffix) files)))
13245 (string-match "/[^/]*$" dir)
13246 (setq dir (substring dir 0 (match-beginning 0)))))
13247 (setq gnus-score-file-list
13248 (cons nil (nreverse files)))))
13249 (cdr gnus-score-file-list)))
13251 (defun gnus-score-file-regexp ()
13252 (concat "\\(" gnus-score-file-suffix
13253 "\\|" gnus-adaptive-file-suffix "\\)$"))
13255 (defun gnus-score-find-bnews (group)
13256 "Return a list of score files for GROUP.
13257 The score files are those files in the ~/News directory which matches
13258 GROUP using BNews sys file syntax."
13259 (let* ((sfiles (append (gnus-score-score-files group)
13260 gnus-internal-global-score-files))
13261 (kill-dir (file-name-as-directory
13262 (expand-file-name gnus-kill-files-directory)))
13263 (klen (length kill-dir))
13264 ofiles not-match regexp)
13266 (set-buffer (get-buffer-create "*gnus score files*"))
13267 (buffer-disable-undo (current-buffer))
13268 ;; Go through all score file names and create regexp with them
13272 (insert (car sfiles))
13273 (goto-char (point-min))
13274 ;; First remove the suffix itself.
13275 (re-search-forward (concat "." (gnus-score-file-regexp)))
13276 (replace-match "" t t)
13277 (goto-char (point-min))
13278 (if (looking-at (regexp-quote kill-dir))
13279 ;; If the file name was just "SCORE", `klen' is one character
13281 (delete-char (min (1- (point-max)) klen))
13282 (goto-char (point-max))
13283 (search-backward "/")
13284 (delete-region (1+ (point)) (point-min)))
13285 ;; If short file names were used, we have to translate slashes.
13286 (goto-char (point-min))
13287 (while (re-search-forward "[/:]" nil t)
13288 (replace-match "." t t))
13289 ;; Translate "all" to ".*".
13290 (while (search-forward "all" nil t)
13291 (replace-match ".*" t t))
13292 (goto-char (point-min))
13293 ;; Deal with "not."s.
13294 (if (looking-at "not.")
13297 (setq regexp (buffer-substring 5 (point-max))))
13298 (setq regexp (buffer-substring 1 (point-max)))
13299 (setq not-match nil))
13300 ;; Finally - if this resulting regexp matches the group name,
13301 ;; we add this score file to the list of score files
13302 ;; applicable to this group.
13303 (if (or (and not-match
13304 (not (string-match regexp group)))
13305 (and (not not-match)
13306 (string-match regexp group)))
13307 (setq ofiles (cons (car sfiles) ofiles)))
13308 (setq sfiles (cdr sfiles)))
13309 (kill-buffer (current-buffer))
13310 ;; Slight kludge here - the last score file returned should be
13311 ;; the local score file, whether it exists or not. This is so
13312 ;; that any score commands the user enters will go to the right
13313 ;; file, and not end up in some global score file.
13316 (if (gnus-use-long-file-name 'not-score)
13317 (concat gnus-kill-files-directory group "."
13318 gnus-score-file-suffix)
13319 (concat gnus-kill-files-directory
13320 (gnus-replace-chars-in-string group ?. ?/)
13321 "/" gnus-score-file-suffix)))))
13322 (and (member localscore ofiles)
13323 (delete localscore ofiles))
13324 (setq ofiles (cons localscore ofiles)))
13325 (nreverse ofiles))))
13327 (defun gnus-score-find-single (group)
13328 "Return list containing the score file for GROUP."
13329 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13330 (gnus-score-file-name group)))
13332 (defun gnus-score-find-hierarchical (group)
13333 "Return list of score files for GROUP.
13334 This includes the score file for the group and all its parents."
13335 (let ((all (copy-sequence '(nil)))
13337 (while (string-match "\\." group (1+ start))
13338 (setq start (match-beginning 0))
13339 (setq all (cons (substring group 0 start) all)))
13340 (setq all (cons group all))
13342 (mapcar (lambda (newsgroup)
13343 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
13344 (setq all (nreverse all)))
13345 (mapcar 'gnus-score-file-name all))))
13347 (defvar gnus-score-file-alist-cache nil)
13349 (defun gnus-score-find-alist (group)
13350 "Return list of score files for GROUP.
13351 The list is determined from the variable gnus-score-file-alist."
13352 (let ((alist gnus-score-file-multiple-match-alist)
13354 ;; if this group has been seen before, return the cached entry
13355 (if (setq score-files (assoc group gnus-score-file-alist-cache))
13356 (cdr score-files) ; ensures caching of groups with no matches
13357 ;; handle the multiple match alist
13359 (and (string-match (car (car alist)) group)
13361 (nconc score-files (cdr (car alist)))))
13362 (setq alist (cdr alist)))
13363 (setq alist gnus-score-file-single-match-alist)
13364 ;; handle the single match alist
13367 (and (string-match (car (car alist)) group)
13368 ;; progn used just in case ("regexp") has no files
13369 ;; and score-files is still nil. -sj
13370 ;; this can be construed as a "stop searching here" feature :>
13371 ;; and used to simplify regexps in the single-alist
13374 (append score-files (cdr (car alist))))
13375 (throw 'done nil)))
13376 (setq alist (cdr alist))))
13377 ;; cache the score files
13378 (setq gnus-score-file-alist-cache
13379 (cons (cons group score-files) gnus-score-file-alist-cache))
13383 (defun gnus-possibly-score-headers (&optional trace)
13384 (let ((func gnus-score-find-score-files-function)
13386 (and func (not (listp func))
13387 (setq func (list func)))
13388 ;; Go through all the functions for finding score files (or actual
13389 ;; scores) and add them to a list.
13390 (setq score-files (copy-sequence
13391 (gnus-score-find-alist gnus-newsgroup-name)))
13393 (and (symbolp (car func))
13394 (fboundp (car func))
13396 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
13397 (setq func (cdr func)))
13398 (if score-files (gnus-score-headers score-files trace))))
13400 (defun gnus-score-file-name (newsgroup &optional suffix)
13401 "Return the name of a score file for NEWSGROUP."
13402 (let ((suffix (or suffix gnus-score-file-suffix)))
13403 (cond ((or (null newsgroup)
13404 (string-equal newsgroup ""))
13405 ;; The global score file is placed at top of the directory.
13407 suffix (or gnus-kill-files-directory "~/News")))
13408 ((gnus-use-long-file-name 'not-score)
13409 ;; Append ".SCORE" to newsgroup name.
13410 (expand-file-name (concat newsgroup "." suffix)
13411 (or gnus-kill-files-directory "~/News")))
13413 ;; Place "SCORE" under the hierarchical directory.
13414 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13416 (or gnus-kill-files-directory "~/News"))))))
13418 (defun gnus-score-search-global-directories (files)
13419 "Scan all global score directories for score files."
13420 ;; Set the variable `gnus-internal-global-score-files' to all
13421 ;; available global score files.
13422 (interactive (list gnus-global-score-files))
13425 (if (string-match "/$" (car files))
13426 (setq out (nconc (directory-files
13428 (concat (gnus-score-file-regexp) "$"))))
13429 (setq out (cons (car files) out)))
13430 (setq files (cdr files)))
13431 (setq gnus-internal-global-score-files out)))
13433 ;; Allow redefinition of Gnus functions.
13435 (gnus-ems-redefine)
13439 ;;; gnus.el ends here