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.95"
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 (defconst gnus-summary-local-variables
1511 '(gnus-newsgroup-name
1512 gnus-newsgroup-begin gnus-newsgroup-end
1513 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1514 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1515 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1516 gnus-newsgroup-unselected gnus-newsgroup-marked
1517 gnus-newsgroup-replied gnus-newsgroup-expirable
1518 gnus-newsgroup-processable gnus-newsgroup-killed
1519 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1520 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1521 gnus-current-article gnus-current-headers gnus-have-all-headers
1522 gnus-last-article gnus-article-internal-prepare-hook
1523 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1524 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1525 gnus-newsgroup-threads gnus-newsgroup-async
1526 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1527 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1528 gnus-newsgroup-history gnus-newsgroup-ancient
1529 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring))
1530 "Variables that are buffer-local to the summary buffers.")
1532 (defconst gnus-bug-message
1533 "Sending a bug report to the Gnus Towers.
1534 ========================================
1536 The buffer below is a mail buffer. When you press `C-c C-c', it will
1537 be sent to the Gnus Bug Exterminators.
1539 At the bottom of the buffer you'll see lots of variable settings.
1540 Please do not delete those. They will tell the Bug People what your
1541 environment is, so that it will be easier to locate the bugs.
1543 If you have found a bug that makes Emacs go \"beep\", set
1544 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1545 and include the backtrace in your bug report.
1547 Please describe the bug in annoying, painstaking detail.
1549 Thank you for your help in stamping out bugs.
1552 ;;; End of variables.
1554 ;; Define some autoload functions Gnus might use.
1558 (autoload 'metamail-buffer "metamail")
1559 (autoload 'Info-goto-node "info")
1560 (autoload 'hexl-hex-string-to-integer "hexl")
1562 (autoload 'pp-to-string "pp")
1563 (autoload 'pp-eval-expression "pp")
1564 (autoload 'mail-extract-address-components "mail-extr")
1566 (autoload 'nnmail-split-fancy "nnmail")
1567 (autoload 'nnvirtual-catchup-group "nnvirtual")
1570 (autoload 'timezone-make-date-arpa-standard "timezone")
1571 (autoload 'timezone-fix-time "timezone")
1572 (autoload 'timezone-make-sortable-date "timezone")
1573 (autoload 'timezone-make-time-string "timezone")
1576 (autoload 'mail-position-on-field "sendmail")
1577 (autoload 'mail-setup "sendmail")
1578 (autoload 'rmail-output "rmailout")
1579 (autoload 'news-mail-other-window "rnewspost")
1580 (autoload 'news-reply-yank-original "rnewspost")
1581 (autoload 'news-caesar-buffer-body "rnewspost")
1582 (autoload 'rmail-insert-rmail-file-header "rmail")
1583 (autoload 'rmail-count-new-messages "rmail")
1584 (autoload 'rmail-show-message "rmail")
1587 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1588 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1589 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1590 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1591 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1592 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1593 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1596 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1597 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1598 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1599 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1600 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1601 (autoload 'gnus-Folder-save-name "gnus-mh")
1602 (autoload 'gnus-folder-save-name "gnus-mh")
1605 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1606 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1607 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1608 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1609 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1610 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1611 (autoload 'gnus-summary-highlight-line "gnus-vis")
1612 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1615 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1616 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1617 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1618 (autoload 'gnus-article-hide "gnus-vis" nil t)
1619 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1620 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1621 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1622 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1623 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1624 (autoload 'gnus-article-add-button "gnus-vis")
1627 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1628 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1629 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1632 (autoload 'gnus-kill "gnus-kill")
1633 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1634 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1635 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1636 (autoload 'gnus-execute "gnus-kill")
1637 (autoload 'gnus-expunge "gnus-kill")
1640 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1641 (autoload 'gnus-cache-save-buffers "gnus-cache")
1642 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1643 (autoload 'gnus-cache-request-article "gnus-cache")
1644 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1645 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1646 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1647 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1650 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1651 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1652 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1653 (autoload 'gnus-score-save "gnus-score")
1654 (autoload 'gnus-score-headers "gnus-score")
1655 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1656 (autoload 'gnus-score-adaptive "gnus-score")
1657 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1658 (autoload 'gnus-score-find-trace "gnus-score")
1661 (autoload 'gnus-score-customize "gnus-edit" nil t)
1664 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1665 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1666 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1667 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1668 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1669 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1670 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1671 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1672 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1673 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1674 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1675 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1676 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1677 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1678 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1679 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1680 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1681 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1682 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1683 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1684 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1685 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1688 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1689 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1690 (autoload 'gnus-group-mail "gnus-msg" nil t)
1691 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1692 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1693 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1694 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1695 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1696 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1697 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1698 (autoload 'gnus-post-news "gnus-msg" nil t)
1699 (autoload 'gnus-inews-news "gnus-msg" nil t)
1700 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1701 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1702 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1703 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1704 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1705 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1706 (autoload 'gnus-mail-yank-original "gnus-msg")
1707 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1708 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1709 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1710 (autoload 'gnus-article-mail-with-original "gnus-msg")
1711 (autoload 'gnus-article-mail "gnus-msg")
1712 (autoload 'gnus-bug "gnus-msg" nil t)
1715 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1716 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1717 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1718 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1719 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1720 (autoload 'gnus-yank-article "gnus-vm" nil t)
1726 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1727 ;; If you want the cursor to go somewhere else, set these two
1728 ;; functions in some startup hook to whatever you want.
1729 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1730 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1732 ;;; Various macros and substs.
1734 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1735 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1736 (` (let ((GnusStartBufferWindow (selected-window)))
1739 (pop-to-buffer (, buffer))
1741 (select-window GnusStartBufferWindow)))))
1743 (defmacro gnus-gethash (string hashtable)
1744 "Get hash value of STRING in HASHTABLE."
1745 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1746 ;;(` (abbrev-expansion (, string) (, hashtable)))
1747 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1749 (defmacro gnus-sethash (string value hashtable)
1750 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1751 ;; We cannot use define-abbrev since it only accepts string as value.
1752 ;; (set (intern string hashtable) value))
1753 (` (set (intern (, string) (, hashtable)) (, value))))
1755 (defsubst gnus-buffer-substring (beg end)
1756 (buffer-substring (match-beginning beg) (match-end end)))
1758 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1759 ;; function `substring' might cut on a middle of multi-octet
1762 (defun gnus-truncate-string (str width)
1763 (substring str 0 width))
1765 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1766 ;; to limit the length of a string. This function is necessary since
1767 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1768 (defsubst gnus-limit-string (str width)
1769 (if (> (length str) width)
1770 (substring str 0 width)
1773 (defsubst gnus-simplify-subject-re (subject)
1774 "Remove \"Re:\" from subject lines."
1775 (let ((case-fold-search t))
1776 (if (string-match "^re: *" subject)
1777 (substring subject (match-end 0))
1780 (defsubst gnus-goto-char (point)
1781 (and point (goto-char point)))
1783 (defmacro gnus-buffer-exists-p (buffer)
1785 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1788 (defmacro gnus-kill-buffer (buffer)
1789 (` (if (gnus-buffer-exists-p (, buffer))
1790 (kill-buffer (, buffer)))))
1792 (defsubst gnus-point-at-bol ()
1793 "Return point at the beginning of line."
1800 (defsubst gnus-point-at-eol ()
1801 "Return point at the beginning of line."
1808 ;; Delete the current line (and the next N lines.);
1809 (defmacro gnus-delete-line (&optional n)
1810 (` (delete-region (progn (beginning-of-line) (point))
1811 (progn (forward-line (, (or n 1))) (point)))))
1813 ;;; Load the compatability functions.
1819 ;;; Gnus Utility Functions
1822 (defun gnus-extract-address-components (from)
1824 ;; First find the address - the thing with the @ in it. This may
1825 ;; not be accurate in mail addresses, but does the trick most of
1826 ;; the time in news messages.
1827 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1828 (setq address (substring from (match-beginning 0) (match-end 0))))
1829 ;; Then we check whether the "name <address>" format is used.
1831 (string-match (concat "<" (regexp-quote address) ">") from)
1832 (and (setq name (substring from 0 (1- (match-beginning 0))))
1833 ;; Strip any quotes from the name.
1834 (string-match "\".*\"" name)
1835 (setq name (substring name 1 (1- (match-end 0))))))
1836 ;; If not, then "address (name)" is used.
1838 (and (string-match "(.+)" from)
1839 (setq name (substring from (1+ (match-beginning 0))
1840 (1- (match-end 0)))))
1841 (and (string-match "()" from)
1842 (setq name address))
1843 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1844 ;; XOVER might not support folded From headers.
1845 (and (string-match "(.*" from)
1846 (setq name (substring from (1+ (match-beginning 0))
1848 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1849 (list (or name from) (or address from))))
1851 (defun gnus-fetch-field (field)
1852 "Return the value of the header FIELD of current article."
1855 (let ((case-fold-search t))
1856 (gnus-narrow-to-headers)
1857 (mail-fetch-field field)))))
1859 (defun gnus-goto-colon ()
1861 (search-forward ":" (gnus-point-at-eol) t))
1863 (defun gnus-narrow-to-headers ()
1867 (goto-char (point-min))
1868 (if (search-forward "\n\n" nil t)
1872 (defun gnus-update-format-specifications ()
1873 (gnus-make-thread-indent-array)
1874 (setq gnus-summary-line-format-spec
1876 gnus-summary-line-format gnus-summary-line-format-alist))
1877 (gnus-update-summary-mark-positions)
1878 (setq gnus-summary-dummy-line-format-spec
1879 (gnus-parse-format gnus-summary-dummy-line-format
1880 gnus-summary-dummy-line-format-alist))
1881 (setq gnus-group-line-format-spec
1883 gnus-group-line-format
1884 gnus-group-line-format-alist))
1885 (if (and (string-match "%D" gnus-group-line-format)
1886 (not gnus-description-hashtb)
1887 gnus-read-active-file)
1888 (gnus-read-all-descriptions-files))
1889 (setq gnus-summary-mode-line-format-spec
1890 (gnus-parse-format gnus-summary-mode-line-format
1891 gnus-summary-mode-line-format-alist))
1892 (setq gnus-article-mode-line-format-spec
1893 (gnus-parse-format gnus-article-mode-line-format
1894 gnus-summary-mode-line-format-alist))
1895 (setq gnus-group-mode-line-format-spec
1896 (gnus-parse-format gnus-group-mode-line-format
1897 gnus-group-mode-line-format-alist)))
1899 (defun gnus-update-summary-mark-positions ()
1901 (let ((gnus-replied-mark 129)
1902 (gnus-score-below-mark 130)
1903 (gnus-score-over-mark 130)
1906 (gnus-set-work-buffer)
1907 (gnus-summary-insert-line
1908 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1909 (goto-char (point-min))
1910 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1912 (goto-char (point-min))
1913 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1914 (- (point) 2))) pos))
1915 (goto-char (point-min))
1916 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1917 (- (point) 2))) pos))
1918 (setq gnus-summary-mark-positions pos))))
1920 (defun gnus-format-max-width (form length)
1921 (let* ((val (eval form))
1922 (valstr (if (numberp val) (int-to-string val) val)))
1923 (gnus-limit-string valstr length)))
1925 (defun gnus-set-mouse-face (string)
1926 ;; Set mouse face property on STRING.
1927 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1930 (defun gnus-parse-format (format spec-alist)
1931 ;; This function parses the FORMAT string with the help of the
1932 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1933 ;; string. If the FORMAT string contains the specifiers %( and %)
1934 ;; the text between them will have the mouse-face text property.
1935 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1936 (if (and gnus-visual gnus-mouse-face)
1937 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1938 (button (substring format (match-beginning 2) (match-end 2)))
1939 (post (substring format (match-beginning 3) (match-end 3))))
1941 (gnus-parse-simple-format pre spec-alist)
1942 (list 'gnus-set-mouse-face
1943 (gnus-parse-simple-format button spec-alist))
1944 (gnus-parse-simple-format post spec-alist)))
1945 (gnus-parse-simple-format
1946 (concat (substring format (match-beginning 1) (match-end 1))
1947 (substring format (match-beginning 2) (match-end 2))
1948 (substring format (match-beginning 3) (match-end 3)))
1950 (gnus-parse-simple-format format spec-alist)))
1952 (defun gnus-parse-simple-format (format spec-alist)
1953 ;; This function parses the FORMAT string with the help of the
1954 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1955 ;; string. The list will consist of the symbol `format', a format
1956 ;; specification string, and a list of forms depending on the
1959 spec flist fstring newspec elem beg)
1961 (gnus-set-work-buffer)
1963 (goto-char (point-min))
1964 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1965 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1967 ;; First check if there are any specs that look anything like
1968 ;; "%12,12A", ie. with a "max width specification". These have
1969 ;; to be treated specially.
1970 (if (setq beg (match-beginning 1))
1973 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1975 (setq beg (match-beginning 2)))
1976 ;; Find the specification from `spec-alist'.
1977 (if (not (setq elem (cdr (assq spec spec-alist))))
1978 (setq elem '("*" ?s)))
1979 ;; Treat user defined format specifiers specially
1980 (and (eq (car elem) 'user-defined)
1983 (list (intern (concat "gnus-user-format-function-"
1989 (delete-region (match-beginning 3) (match-end 3)))
1990 (if (not (zerop max-width))
1991 (let ((el (car elem)))
1992 (cond ((= (car (cdr elem)) ?c)
1993 (setq el (list 'char-to-string el)))
1994 ((= (car (cdr elem)) ?d)
1995 (numberp el) (setq el (list 'int-to-string el))))
1996 (setq flist (cons (list 'gnus-format-max-width el max-width)
1999 (setq flist (cons (car elem) flist))
2000 (setq newspec (car (cdr elem))))
2001 ;; Remove the old specification (and possibly a ",12" string).
2002 (delete-region beg (match-end 2))
2003 ;; Insert the new specification.
2006 (setq fstring (buffer-substring 1 (point-max))))
2007 (cons 'format (cons fstring (nreverse flist)))))
2009 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2010 (defun gnus-read-init-file ()
2012 (or (and (file-exists-p gnus-init-file)
2013 ;; Don't try to load a directory.
2014 (not (file-directory-p gnus-init-file)))
2015 (file-exists-p (concat gnus-init-file ".el"))
2016 (file-exists-p (concat gnus-init-file ".elc")))
2017 (load gnus-init-file nil t)))
2019 (defun gnus-set-work-buffer ()
2020 (if (get-buffer gnus-work-buffer)
2022 (set-buffer gnus-work-buffer)
2024 (set-buffer (get-buffer-create gnus-work-buffer))
2025 (kill-all-local-variables)
2026 (buffer-disable-undo (current-buffer))
2027 (gnus-add-current-to-buffer-list)))
2029 ;; Article file names when saving.
2031 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2032 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2033 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2034 Otherwise, it is like ~/News/news/group/num."
2037 (concat (if (gnus-use-long-file-name 'not-save)
2038 (gnus-capitalize-newsgroup newsgroup)
2039 (gnus-newsgroup-directory-form newsgroup))
2040 "/" (int-to-string (header-number headers)))
2041 (or gnus-article-save-directory "~/News"))))
2043 (string-equal (file-name-directory default)
2044 (file-name-directory last-file))
2045 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2047 (or last-file default))))
2049 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2050 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2051 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2052 Otherwise, it is like ~/News/news/group/num."
2055 (concat (if (gnus-use-long-file-name 'not-save)
2057 (gnus-newsgroup-directory-form newsgroup))
2058 "/" (int-to-string (header-number headers)))
2059 (or gnus-article-save-directory "~/News"))))
2061 (string-equal (file-name-directory default)
2062 (file-name-directory last-file))
2063 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2065 (or last-file default))))
2067 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2068 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2069 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2070 Otherwise, it is like ~/News/news/group/news."
2073 (if (gnus-use-long-file-name 'not-save)
2074 (gnus-capitalize-newsgroup newsgroup)
2075 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2076 (or gnus-article-save-directory "~/News"))))
2078 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2079 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2080 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
2081 Otherwise, it is like ~/News/news/group/news."
2084 (if (gnus-use-long-file-name 'not-save)
2086 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2087 (or gnus-article-save-directory "~/News"))))
2089 ;; For subscribing new newsgroup
2091 (defun gnus-subscribe-hierarchical-interactive (groups)
2092 (let ((groups (sort groups 'string<))
2093 prefixes prefix start ans group starts)
2095 (setq prefixes (list "^"))
2096 (while (and groups prefixes)
2097 (while (not (string-match (car prefixes) (car groups)))
2098 (setq prefixes (cdr prefixes)))
2099 (setq prefix (car prefixes))
2100 (setq start (1- (length prefix)))
2101 (if (and (string-match "[^\\.]\\." (car groups) start)
2104 (concat "^" (substring (car groups) 0 (match-end 0))))
2105 (string-match prefix (car (cdr groups))))
2107 (setq prefixes (cons prefix prefixes))
2108 (message "Descend hierarchy %s? ([y]nsq): "
2109 (substring prefix 1 (1- (length prefix))))
2110 (setq ans (read-char))
2113 (string-match prefix
2114 (setq group (car groups))))
2115 (setq gnus-killed-list
2116 (cons group gnus-killed-list))
2117 (gnus-sethash group group gnus-killed-hashtb)
2118 (setq groups (cdr groups)))
2119 (setq starts (cdr starts)))
2122 (string-match prefix
2123 (setq group (car groups))))
2124 (gnus-sethash group group gnus-killed-hashtb)
2125 (gnus-subscribe-alphabetically (car groups))
2126 (setq groups (cdr groups)))
2127 (setq starts (cdr starts)))
2130 (setq group (car groups))
2131 (setq gnus-killed-list (cons group gnus-killed-list))
2132 (gnus-sethash group group gnus-killed-hashtb)
2133 (setq groups (cdr groups))))
2135 (message "Subscribe %s? ([n]yq)" (car groups))
2136 (setq ans (read-char))
2137 (setq group (car groups))
2139 (gnus-subscribe-alphabetically (car groups))
2140 (gnus-sethash group group gnus-killed-hashtb))
2143 (setq group (car groups))
2144 (setq gnus-killed-list (cons group gnus-killed-list))
2145 (gnus-sethash group group gnus-killed-hashtb)
2146 (setq groups (cdr groups))))
2148 (setq gnus-killed-list (cons group gnus-killed-list))
2149 (gnus-sethash group group gnus-killed-hashtb)))
2150 (setq groups (cdr groups)))))))
2152 (defun gnus-subscribe-randomly (newsgroup)
2153 "Subscribe new NEWSGROUP by making it the first newsgroup."
2154 (gnus-subscribe-newsgroup newsgroup))
2156 (defun gnus-subscribe-alphabetically (newgroup)
2157 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2158 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2159 (let ((groups (cdr gnus-newsrc-alist))
2161 (while (and (not before) groups)
2162 (if (string< newgroup (car (car groups)))
2163 (setq before (car (car groups)))
2164 (setq groups (cdr groups))))
2165 (gnus-subscribe-newsgroup newgroup before)))
2167 (defun gnus-subscribe-hierarchically (newgroup)
2168 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2169 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2171 (set-buffer (find-file-noselect gnus-current-startup-file))
2172 (let ((groupkey newgroup)
2174 (while (and (not before) groupkey)
2175 (goto-char (point-min))
2177 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2178 (while (and (re-search-forward groupkey-re nil t)
2180 (setq before (buffer-substring
2181 (match-beginning 1) (match-end 1)))
2182 (string< before newgroup)))))
2183 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2185 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2186 (substring groupkey (match-beginning 1) (match-end 1)))))
2187 (gnus-subscribe-newsgroup newgroup before))))
2189 (defun gnus-subscribe-interactively (newsgroup)
2190 "Subscribe new NEWSGROUP interactively.
2191 It is inserted in hierarchical newsgroup order if subscribed. If not,
2193 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2194 (gnus-subscribe-hierarchically newsgroup)
2195 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2197 (defun gnus-subscribe-zombies (newsgroup)
2198 "Make new NEWSGROUP a zombie group."
2199 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2201 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2202 "Subscribe new NEWSGROUP.
2203 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2204 the first newsgroup."
2205 ;; We subscribe the group by changing its level to `subscribed'.
2206 (gnus-group-change-level
2207 newsgroup gnus-level-default-subscribed
2208 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2209 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2213 (defun gnus-newsgroup-directory-form (newsgroup)
2214 "Make hierarchical directory name from NEWSGROUP name."
2215 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2216 (len (length newsgroup))
2218 ;; If this is a foreign group, we don't want to translate the
2220 (if (setq idx (string-match ":" newsgroup))
2221 (aset newsgroup idx ?/)
2223 ;; Replace all occurrences of `.' with `/'.
2225 (if (= (aref newsgroup idx) ?.)
2226 (aset newsgroup idx ?/))
2227 (setq idx (1+ idx)))
2230 (defun gnus-make-directory (dir)
2231 "Make DIRECTORY recursively."
2232 (let* ((dir (expand-file-name dir default-directory))
2234 (if (string-match "/$" dir)
2235 (setq dir (substring dir 0 (match-beginning 0))))
2236 (while (not (file-exists-p dir))
2237 (setq dirs (cons dir dirs))
2238 (string-match "/[^/]+$" dir)
2239 (setq dir (substring dir 0 (match-beginning 0))))
2241 (make-directory (car dirs))
2242 (setq dirs (cdr dirs)))))
2244 (defun gnus-capitalize-newsgroup (newsgroup)
2245 "Capitalize NEWSGROUP name."
2246 (and (not (zerop (length newsgroup)))
2247 (concat (char-to-string (upcase (aref newsgroup 0)))
2248 (substring newsgroup 1))))
2252 (defun gnus-simplify-subject (subject &optional re-only)
2253 "Remove `Re:' and words in parentheses.
2254 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2255 (let ((case-fold-search t)) ;Ignore case.
2256 ;; Remove `Re:' and `Re^N:'.
2257 (if (string-match "^re:[ \t]*" subject)
2258 (setq subject (substring subject (match-end 0))))
2259 ;; Remove words in parentheses from end.
2261 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2262 (setq subject (substring subject 0 (match-beginning 0)))))
2263 ;; Return subject string.
2266 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2268 (defun gnus-simplify-subject-fuzzy (subject)
2269 (let ((case-fold-search t))
2271 (gnus-set-work-buffer)
2273 (inline (gnus-simplify-buffer-fuzzy))
2276 (defun gnus-simplify-buffer-fuzzy ()
2277 (goto-char (point-min))
2278 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2279 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2281 (replace-match "" t t))
2282 (goto-char (point-min))
2283 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2284 (replace-match "" t t))
2285 (goto-char (point-min))
2286 (while (re-search-forward "[ \t]+" 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 (if gnus-simplify-subject-fuzzy-regexp
2295 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2296 (replace-match "" t t)))
2299 ;; Add the current buffer to the list of buffers to be killed on exit.
2300 (defun gnus-add-current-to-buffer-list ()
2301 (or (memq (current-buffer) gnus-buffer-list)
2302 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2304 (defun gnus-string> (s1 s2)
2305 (not (or (string< s1 s2)
2308 ;; Functions accessing headers.
2309 ;; Functions are more convenient than macros in some cases.
2311 (defun gnus-header-number (header)
2312 (header-number header))
2314 (defun gnus-header-subject (header)
2315 (header-subject header))
2317 (defun gnus-header-from (header)
2318 (header-from header))
2320 (defun gnus-header-xref (header)
2321 (header-xref header))
2323 (defun gnus-header-lines (header)
2324 (header-lines header))
2326 (defun gnus-header-date (header)
2327 (header-date header))
2329 (defun gnus-header-id (header)
2332 (defun gnus-header-references (header)
2333 (header-references header))
2335 ;;; General various misc type functions.
2337 (defun gnus-clear-system ()
2338 "Clear all variables and buffers."
2339 ;; Clear Gnus variables.
2340 (let ((variables gnus-variable-list))
2342 (set (car variables) nil)
2343 (setq variables (cdr variables))))
2344 ;; Clear other internal variables.
2345 (setq gnus-list-of-killed-groups nil
2346 gnus-have-read-active-file nil
2347 gnus-newsrc-alist nil
2348 gnus-newsrc-hashtb nil
2349 gnus-killed-list nil
2350 gnus-zombie-list nil
2351 gnus-killed-hashtb nil
2352 gnus-active-hashtb nil
2353 gnus-moderated-list nil
2354 gnus-description-hashtb nil
2355 gnus-newsgroup-headers nil
2356 gnus-newsgroup-headers-hashtb-by-number nil
2357 gnus-newsgroup-name nil
2358 gnus-server-alist nil
2359 gnus-current-select-method nil)
2360 ;; Reset any score variables.
2361 (and (boundp 'gnus-score-cache)
2362 (set 'gnus-score-cache nil))
2363 (and (boundp 'gnus-internal-global-score-files)
2364 (set 'gnus-internal-global-score-files nil))
2365 ;; Kill the startup file.
2366 (and gnus-current-startup-file
2367 (get-file-buffer gnus-current-startup-file)
2368 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2369 ;; Save any cache buffers.
2370 (and gnus-use-cache (gnus-cache-save-buffers))
2371 ;; Clear the dribble buffer.
2372 (gnus-dribble-clear)
2373 ;; Kill global KILL file buffer.
2374 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2375 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2376 (gnus-kill-buffer nntp-server-buffer)
2377 ;; Kill Gnus buffers.
2378 (while gnus-buffer-list
2379 (gnus-kill-buffer (car gnus-buffer-list))
2380 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2382 (defun gnus-windows-old-to-new (setting)
2383 (if (symbolp setting)
2385 (cond ((eq setting 'SelectArticle)
2387 ((eq setting 'SelectSubject)
2389 ((eq setting 'SelectNewsgroup)
2392 (if (or (listp setting)
2393 (not (and gnus-window-configuration
2394 (memq setting '(group summary article)))))
2396 (let* ((setting (if (eq setting 'group)
2397 (if (assq 'newsgroup gnus-window-configuration)
2399 'newsgroups) setting))
2400 (elem (car (cdr (assq setting gnus-window-configuration))))
2401 (total (apply '+ elem))
2402 (types '(group summary article))
2403 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2408 (or (zerop (nth i elem))
2410 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2411 (setq out (cons (if (eq pbuf (nth i types))
2412 (vector (nth i types) perc 'point)
2413 (vector (nth i types) perc))
2416 (list (nreverse out)))))
2418 (defun gnus-add-configuration (conf)
2419 (setq gnus-buffer-configuration
2420 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2421 gnus-buffer-configuration))))
2423 (defun gnus-configure-windows (setting)
2424 (setq setting (gnus-windows-old-to-new setting))
2425 (let ((r (if (symbolp setting)
2426 (cdr (assq setting gnus-buffer-configuration))
2428 (in-buf (current-buffer))
2429 rule val w height hor ohor heights sub jump-buffer
2431 (or r (error "No such setting: %s" setting))
2433 ;; Either remove all windows or just remove all Gnus windows.
2434 (if gnus-use-full-window
2435 (delete-other-windows)
2436 (gnus-remove-some-windows)
2437 (switch-to-buffer nntp-server-buffer))
2443 ;; We have to do the (possible) horizontal splitting before the
2445 (if (and (listp (car hor))
2446 (eq (car (car hor)) 'horizontal))
2450 (if (integerp (nth 1 (car hor)))
2452 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2454 (setq hor (cdr hor))))
2456 ;; Go through the rules and eval the elements that are to be
2459 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2461 ;; Expand short buffer name.
2462 (setq w (aref val 0))
2463 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2465 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2467 (setq ohor (cons val ohor))))
2468 (setq hor (cdr hor)))
2469 (setq rule (cons (nreverse ohor) rule))
2471 (setq rule (nreverse rule))
2473 ;; We tally the window sizes.
2474 (setq total (window-height))
2476 (setq hor (car rule))
2477 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2478 (setq hor (cdr hor)))
2481 (setq rel (aref (car hor) 1)
2483 (cond ((and (floatp rel) (= 1.0 rel))
2488 (max (floor (* total rel)) 4)))
2490 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2492 (setq heights (nreverse heights)
2495 ;; We then go through these heighs and create windows for them.
2497 (setq height (car heights)
2498 heights (cdr heights))
2500 (setq height (- total sub)))
2502 (split-window nil height))
2503 (setq to-buf (aref (car hor) 0))
2508 (symbol-value (aref (car hor) 0)))
2510 (aref (car hor) 0))))
2511 (and (> (length (car hor)) 2)
2512 (eq (aref (car hor) 2) 'point)
2513 (setq jump-buffer (current-buffer)))
2515 (setq hor (cdr hor)))
2517 (setq rule (cdr rule)))
2519 ;; Finally, we pop to the buffer that's supposed to have point.
2520 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2522 (select-window (get-buffer-window jump-buffer))
2523 (set-buffer jump-buffer)))
2525 (defun gnus-remove-some-windows ()
2526 (let ((buffers gnus-window-to-buffer)
2530 ;; Remove windows on all known Gnus buffers.
2532 (setq buf (cdr (car buffers)))
2534 (setq buf (and (boundp buf) (symbol-value buf))))
2536 (get-buffer-window buf)
2541 (switch-to-buffer nntp-server-buffer)
2543 (delete-window (get-buffer-window buf)))))
2544 (setq buffers (cdr buffers)))
2545 ;; Remove windows on *all* summary buffers.
2546 (let ((buffers (buffer-list)))
2548 (if (and (string-match
2549 "^\\*Summary" (or (buffer-name (car buffers)) ""))
2550 (get-buffer-window (car buffers)))
2551 (delete-window (get-buffer-window (car buffers))))
2552 (setq buffers (cdr buffers)))))))
2554 (defun gnus-version ()
2555 "Version numbers of this version of Gnus."
2557 (let ((methods gnus-valid-select-methods)
2560 ;; Go through all the legal select methods and add their version
2561 ;; numbers to the total version string. Only the backends that are
2562 ;; currently in use will have their message numbers taken into
2565 (setq meth (intern (concat (car (car methods)) "-version")))
2567 (stringp (symbol-value meth))
2568 (setq mess (concat mess "; " (symbol-value meth))))
2569 (setq methods (cdr methods)))
2570 (gnus-message 2 mess)))
2572 (defun gnus-info-find-node ()
2573 "Find Info documentation of Gnus."
2575 ;; Enlarge info window if needed.
2576 (let ((mode major-mode))
2577 (gnus-configure-windows 'info)
2578 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2580 (defun gnus-overload-functions (&optional overloads)
2581 "Overload functions specified by optional argument OVERLOADS.
2582 If nothing is specified, use the variable gnus-overload-functions."
2584 (overloads (or overloads gnus-overload-functions)))
2586 (setq defs (car overloads))
2587 (setq overloads (cdr overloads))
2588 ;; Load file before overloading function if necessary. Make
2589 ;; sure we cannot use `require' always.
2590 (and (not (fboundp (car defs)))
2591 (car (cdr (cdr defs)))
2592 (load (car (cdr (cdr defs))) nil 'nomessage))
2593 (fset (car defs) (car (cdr defs))))))
2595 (defun gnus-replace-chars-in-string (string from to)
2596 "Replace characters in STRING from FROM to TO."
2597 (let ((string (substring string 0)) ;Copy string.
2598 (len (length string))
2600 ;; Replace all occurrences of FROM with TO.
2602 (if (= (aref string idx) from)
2603 (aset string idx to))
2604 (setq idx (1+ idx)))
2607 (defun gnus-days-between (date1 date2)
2608 ;; Return the number of days between date1 and date2.
2609 (- (gnus-day-number date1) (gnus-day-number date2)))
2611 (defun gnus-day-number (date)
2612 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2613 (timezone-parse-date date))))
2614 (timezone-absolute-from-gregorian
2615 (nth 1 dat) (nth 2 dat) (car dat))))
2617 ;; Returns a floating point number that says how many seconds have
2618 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2619 (defun gnus-seconds-since-epoch (date)
2620 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2621 (timezone-parse-date date)))
2622 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2623 (timezone-parse-time
2624 (aref (timezone-parse-date date) 3))))
2625 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2626 (timezone-parse-date "Jan 1 12:00:00 1970")))
2627 (tday (- (timezone-absolute-from-gregorian
2628 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2629 (timezone-absolute-from-gregorian
2630 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2632 (* (nth 1 ttime) 60)
2633 (* 1.0 (nth 0 ttime) 60 60)
2634 (* 1.0 tday 60 60 24))))
2636 (defun gnus-file-newer-than (file date)
2637 (let ((fdate (nth 5 (file-attributes file))))
2638 (or (> (car fdate) (car date))
2639 (and (= (car fdate) (car date))
2640 (> (nth 1 fdate) (nth 1 date))))))
2642 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2644 (defun gnus-y-or-n-p (prompt)
2649 (defun gnus-yes-or-no-p (prompt)
2651 (yes-or-no-p prompt)
2654 ;; Check whether to use long file names.
2655 (defun gnus-use-long-file-name (symbol)
2656 ;; The variable has to be set...
2657 (and gnus-use-long-file-name
2658 ;; If it isn't a list, then we return t.
2659 (or (not (listp gnus-use-long-file-name))
2660 ;; If it is a list, and the list contains `symbol', we
2662 (not (memq symbol gnus-use-long-file-name)))))
2664 ;; I suspect there's a better way, but I haven't taken the time to do
2665 ;; it yet. -erik selberg@cs.washington.edu
2666 (defun gnus-dd-mmm (messy-date)
2667 "Return a string like DD-MMM from a big messy string"
2668 (let ((datevec (timezone-parse-date messy-date)))
2670 (or (aref datevec 2) "??")
2673 (nth (1- (string-to-number (aref datevec 1)))
2674 timezone-months-assoc))
2677 ;; Make a hash table (default and minimum size is 255).
2678 ;; Optional argument HASHSIZE specifies the table size.
2679 (defun gnus-make-hashtable (&optional hashsize)
2680 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2682 ;; Make a number that is suitable for hashing; bigger than MIN and one
2684 (defun gnus-create-hash-size (min)
2690 ;; Show message if message has a lower level than `gnus-verbose'.
2691 ;; Guide-line for numbers:
2692 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2693 ;; for things that take a long time, 7 - not very important messages
2694 ;; on stuff, 9 - messages inside loops.
2695 (defun gnus-message (level &rest args)
2696 (if (<= level gnus-verbose)
2697 (apply 'message args)
2698 ;; We have to do this format thingie here even if the result isn't
2699 ;; shown - the return value has to be the same as the return value
2701 (apply 'format args)))
2703 ;; Generate a unique new group name.
2704 (defun gnus-generate-new-group-name (leaf)
2707 (while (gnus-gethash name gnus-newsrc-hashtb)
2708 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2711 (defun gnus-find-file-noselect (file &optional force)
2712 "Does vaguely the same as find-file-noselect. No hooks are run."
2714 (if (setq buf (get-file-buffer file))
2716 (setq buf (create-file-buffer file))
2723 (and (file-readable-p file)
2724 (insert-file-contents file))
2725 (set-visited-file-name file)
2726 (set-buffer-modified-p nil)
2727 (current-buffer)))))
2729 ;;; List and range functions
2731 (defun gnus-last-element (list)
2732 "Return last element of LIST."
2734 (setq list (cdr list)))
2737 (defun gnus-copy-sequence (list)
2738 "Do a complete, total copy of a list."
2739 (if (and (consp list) (not (consp (cdr list))))
2740 (cons (car list) (cdr list))
2741 (mapcar (lambda (elem) (if (consp elem)
2742 (if (consp (cdr elem))
2743 (gnus-copy-sequence elem)
2744 (cons (car elem) (cdr elem)))
2748 (defun gnus-set-difference (list1 list2)
2749 "Return a list of elements of LIST1 that do not appear in LIST2."
2750 (let ((list1 (copy-sequence list1)))
2752 (setq list1 (delq (car list2) list1))
2753 (setq list2 (cdr list2)))
2756 (defun gnus-sorted-complement (list1 list2)
2757 "Return a list of elements of LIST1 that do not appear in LIST2.
2758 Both lists have to be sorted over <."
2760 (if (or (null list1) (null list2))
2762 (while (and list1 list2)
2763 (cond ((= (car list1) (car list2))
2764 (setq list1 (cdr list1)
2766 ((< (car list1) (car list2))
2767 (setq out (cons (car list1) out))
2768 (setq list1 (cdr list1)))
2770 (setq out (cons (car list2) out))
2771 (setq list2 (cdr list2)))))
2772 (nconc (nreverse out) (or list1 list2)))))
2774 (defun gnus-intersection (list1 list2)
2777 (if (memq (car list2) list1)
2778 (setq result (cons (car list2) result)))
2779 (setq list2 (cdr list2)))
2782 (defun gnus-sorted-intersection (list1 list2)
2783 ;; LIST1 and LIST2 have to be sorted over <.
2785 (while (and list1 list2)
2786 (cond ((= (car list1) (car list2))
2787 (setq out (cons (car list1) out)
2790 ((< (car list1) (car list2))
2791 (setq list1 (cdr list1)))
2793 (setq list2 (cdr list2)))))
2796 (defun gnus-set-sorted-intersection (list1 list2)
2797 ;; LIST1 and LIST2 have to be sorted over <.
2798 ;; This function modifies LIST1.
2799 (let* ((top (cons nil list1))
2801 (while (and list1 list2)
2802 (cond ((= (car list1) (car list2))
2806 ((< (car list1) (car list2))
2807 (setcdr prev (cdr list1))
2808 (setq list1 (cdr list1)))
2810 (setq list2 (cdr list2)))))
2814 (defun gnus-compress-sequence (numbers &optional always-list)
2815 "Convert list of numbers to a list of ranges or a single range.
2816 If ALWAYS-LIST is non-nil, this function will always release a list of
2818 (let* ((first (car numbers))
2819 (last (car numbers))
2823 (if (not (listp (cdr numbers)))
2826 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2827 ((= (1+ last) (car numbers)) ;Still in sequence
2828 (setq last (car numbers)))
2829 (t ;End of one sequence
2831 (cons (if (= first last) first
2832 (cons first last)) result))
2833 (setq first (car numbers))
2834 (setq last (car numbers))))
2835 (setq numbers (cdr numbers)))
2836 (if (and (not always-list) (null result))
2837 (if (= first last) (list first) (cons first last))
2838 (nreverse (cons (if (= first last) first (cons first last))
2841 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2842 (defun gnus-uncompress-range (ranges)
2843 "Expand a list of ranges into a list of numbers.
2844 RANGES is either a single range on the form `(num . num)' or a list of
2846 (let (first last result)
2850 ((not (listp (cdr ranges)))
2851 (setq first (car ranges))
2852 (setq last (cdr ranges))
2853 (while (<= first last)
2854 (setq result (cons first result))
2855 (setq first (1+ first)))
2859 (if (atom (car ranges))
2860 (if (numberp (car ranges))
2861 (setq result (cons (car ranges) result)))
2862 (setq first (car (car ranges)))
2863 (setq last (cdr (car ranges)))
2864 (while (<= first last)
2865 (setq result (cons first result))
2866 (setq first (1+ first))))
2867 (setq ranges (cdr ranges)))
2868 (nreverse result)))))
2870 (defun gnus-add-to-range (ranges list)
2871 "Return a list of ranges that has all articles from both RANGES and LIST.
2872 Note: LIST has to be sorted over `<'."
2874 (gnus-compress-sequence list t)
2875 (setq list (copy-sequence list))
2876 (or (listp (cdr ranges))
2877 (setq ranges (list ranges)))
2879 ilist lowest highest temp)
2880 (while (and ranges list)
2882 (setq lowest (or (and (atom (car ranges)) (car ranges))
2883 (car (car ranges))))
2884 (while (and list (cdr list) (< (car (cdr list)) lowest))
2885 (setq list (cdr list)))
2886 (if (< (car ilist) lowest)
2889 (setq list (cdr list))
2891 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2892 (setq highest (or (and (atom (car ranges)) (car ranges))
2893 (cdr (car ranges))))
2894 (while (and list (<= (car list) highest))
2895 (setq list (cdr list)))
2896 (setq ranges (cdr ranges)))
2898 (setq out (nconc (gnus-compress-sequence list t) out)))
2899 (setq out (sort out (lambda (r1 r2)
2900 (< (or (and (atom r1) r1) (car r1))
2901 (or (and (atom r2) r2) (car r2))))))
2904 (if (atom (car ranges))
2906 (if (atom (car (cdr ranges)))
2907 (if (= (1+ (car ranges)) (car (cdr ranges)))
2909 (setcar ranges (cons (car ranges)
2910 (car (cdr ranges))))
2911 (setcdr ranges (cdr (cdr ranges)))))
2912 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2914 (setcar (car (cdr ranges)) (car ranges))
2915 (setcar ranges (car (cdr ranges)))
2916 (setcdr ranges (cdr (cdr ranges)))))))
2918 (if (atom (car (cdr ranges)))
2919 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2921 (setcdr (car ranges) (car (cdr ranges)))
2922 (setcdr ranges (cdr (cdr ranges)))))
2923 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2925 (setcdr (car ranges) (cdr (car (cdr ranges))))
2926 (setcdr ranges (cdr (cdr ranges))))))))
2927 (setq ranges (cdr ranges)))
2930 (defun gnus-remove-from-range (ranges list)
2931 "Return a list of ranges that has all articles from LIST removed from RANGES.
2932 Note: LIST has to be sorted over `<'."
2933 ;; !!! This function shouldn't look like this, but I've got a headache.
2934 (gnus-compress-sequence
2935 (gnus-sorted-complement
2936 (gnus-uncompress-range ranges) list)))
2938 (defun gnus-member-of-range (number ranges)
2939 (if (not (listp (cdr ranges)))
2940 (and (>= number (car ranges))
2941 (<= number (cdr ranges)))
2944 (if (numberp (car ranges))
2945 (>= number (car ranges))
2946 (>= number (car (car ranges))))
2948 (if (if (numberp (car ranges))
2949 (= number (car ranges))
2950 (and (>= number (car (car ranges)))
2951 (<= number (cdr (car ranges)))))
2952 (setq not-stop nil))
2953 (setq ranges (cdr ranges)))
2961 (defvar gnus-group-mode-map nil)
2962 (defvar gnus-group-group-map nil)
2963 (defvar gnus-group-mark-map nil)
2964 (defvar gnus-group-list-map nil)
2965 (defvar gnus-group-sub-map nil)
2966 (put 'gnus-group-mode 'mode-class 'special)
2968 (if gnus-group-mode-map
2970 (setq gnus-group-mode-map (make-keymap))
2971 (suppress-keymap gnus-group-mode-map)
2972 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2973 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2974 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2975 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2976 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2977 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2978 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2979 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2980 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2981 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2982 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2983 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2984 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2985 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2986 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2987 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2988 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2989 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2990 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2991 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2992 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2993 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2994 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2995 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2996 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2997 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2998 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2999 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3000 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3001 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3002 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3003 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3004 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3005 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3006 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3007 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3008 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3009 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3010 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3011 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3012 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3013 (define-key gnus-group-mode-map "V" 'gnus-version)
3014 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3015 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3016 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3017 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3018 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3019 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3020 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3021 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3022 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3023 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3024 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3025 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3026 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3027 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3028 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3030 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3031 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3032 (define-prefix-command 'gnus-group-mark-map)
3033 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3034 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3035 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3036 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3038 (define-prefix-command 'gnus-group-group-map)
3039 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3040 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3041 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3042 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3043 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3044 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3045 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3046 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3047 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3048 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3049 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3050 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3051 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3052 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3053 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3054 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3055 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3056 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3058 (define-prefix-command 'gnus-group-list-map)
3059 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3060 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3061 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3062 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3063 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3064 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3065 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3066 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3067 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3069 (define-prefix-command 'gnus-group-sub-map)
3070 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3071 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3072 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3073 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3074 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3075 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3076 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3077 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3079 (defun gnus-group-mode ()
3080 "Major mode for reading news.
3082 All normal editing commands are switched off.
3083 \\<gnus-group-mode-map>
3084 The group buffer lists (some of) the groups available. For instance,
3085 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3086 lists all zombie groups.
3088 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3089 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3091 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3093 The following commands are available:
3095 \\{gnus-group-mode-map}"
3097 (if gnus-visual (gnus-group-make-menu-bar))
3098 (kill-all-local-variables)
3099 (setq mode-line-modified "-- ")
3100 (make-local-variable 'mode-line-format)
3101 (setq mode-line-format (copy-sequence mode-line-format))
3102 (and (equal (nth 3 mode-line-format) " ")
3103 (setcar (nthcdr 3 mode-line-format) ""))
3104 (setq major-mode 'gnus-group-mode)
3105 (setq mode-name "Group")
3106 (gnus-group-set-mode-line)
3107 (setq mode-line-process nil)
3108 (use-local-map gnus-group-mode-map)
3109 (buffer-disable-undo (current-buffer))
3110 (setq truncate-lines t)
3111 (setq buffer-read-only t)
3112 (run-hooks 'gnus-group-mode-hook))
3114 (defun gnus-mouse-pick-group (e)
3117 (gnus-group-read-group nil))
3120 (defun gnus-no-server (&optional arg)
3122 If ARG is a positive number, Gnus will use that as the
3123 startup level. If ARG is nil, Gnus will be started at level 2.
3124 If ARG is non-nil and not a positive number, Gnus will
3125 prompt the user for the name of an NNTP server to use.
3126 As opposed to `gnus', this command will not connect to the local server."
3128 (setq gnus-group-use-permanent-levels t)
3129 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3131 (defalias '\(ding\) 'gnus)
3134 (defun gnus (&optional arg dont-connect)
3136 If ARG is non-nil and a positive number, Gnus will use that as the
3137 startup level. If ARG is non-nil and not a positive number, Gnus will
3138 prompt the user for the name of an NNTP server to use."
3140 (if (get-buffer gnus-group-buffer)
3142 (switch-to-buffer gnus-group-buffer)
3143 (gnus-group-get-new-news))
3145 (nnheader-init-server-buffer)
3146 (gnus-read-init-file)
3147 (let ((level (and arg (numberp arg) (> arg 0) arg))
3151 (gnus-group-setup-buffer)
3154 (gnus-start-news-server (and arg (not level))))))
3155 (if (and (not dont-connect)
3158 (run-hooks 'gnus-startup-hook)
3159 ;; NNTP server is successfully open.
3160 (gnus-update-format-specifications)
3161 (gnus-summary-make-display-table)
3162 (let ((buffer-read-only nil))
3164 (if (not gnus-inhibit-startup-message)
3166 (gnus-group-startup-message)
3168 (gnus-setup-news nil level)
3169 (and gnus-use-dribble-file (gnus-dribble-open))
3170 (gnus-group-list-groups level)
3171 (gnus-configure-windows 'group))))))
3173 (defun gnus-group-startup-message (&optional x y)
3174 "Insert startup message in current buffer."
3175 ;; Insert the message.
3191 ;; And then hack it.
3192 ;; 18 is the longest line.
3193 (indent-rigidly (point-min) (point-max)
3194 (/ (max (- (window-width) (or x 28)) 0) 2))
3195 (goto-char (point-min))
3196 ;; +4 is fuzzy factor.
3197 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3200 (goto-char (point-min))
3201 (search-forward "Praxis")
3202 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3203 (goto-char (point-min)))
3205 (defun gnus-group-setup-buffer ()
3206 (or (get-buffer gnus-group-buffer)
3208 (switch-to-buffer gnus-group-buffer)
3209 (gnus-add-current-to-buffer-list)
3211 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3213 (defun gnus-group-list-groups (level &optional unread)
3214 "List newsgroups with level LEVEL or lower that have unread articles.
3215 Default is all subscribed groups.
3216 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3217 (interactive (list (and current-prefix-arg
3218 (prefix-numeric-value current-prefix-arg))))
3219 (if gnus-group-use-permanent-levels
3221 (setq gnus-group-default-list-level
3222 (or level gnus-group-default-list-level))
3223 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3224 (setq level (or level gnus-group-default-list-level
3225 gnus-level-subscribed)))
3226 (gnus-group-setup-buffer) ;May call from out of group buffer
3227 (let ((case-fold-search nil)
3228 (group (gnus-group-group-name)))
3229 (funcall gnus-group-prepare-function level unread nil)
3230 (if (zerop (buffer-size))
3231 (gnus-message 5 gnus-no-groups-message)
3232 (goto-char (point-min))
3234 ;; Go to the first group with unread articles.
3235 (gnus-group-search-forward nil nil nil t)
3236 ;; Find the right group to put point on. If the current group
3237 ;; has disapeared in the new listing, try to find the next
3238 ;; one. If no next one can be found, just leave point at the
3239 ;; first newsgroup in the buffer.
3240 (if (not (gnus-goto-char
3241 (text-property-any (point-min) (point-max)
3242 'gnus-group (intern group))))
3243 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3245 (not (gnus-goto-char
3247 (point-min) (point-max) 'gnus-group
3248 (intern (car (car newsrc)))))))
3249 (setq newsrc (cdr newsrc)))
3250 (or newsrc (progn (goto-char (point-max))
3251 (forward-line -1))))))
3252 ;; Adjust cursor point.
3253 (gnus-group-position-cursor))))
3255 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3256 "List all newsgroups with unread articles of level LEVEL or lower.
3257 If ALL is non-nil, list groups that have no unread articles.
3258 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3259 If REGEXP, only list groups matching REGEXP."
3260 (set-buffer gnus-group-buffer)
3261 (let ((buffer-read-only nil)
3262 (newsrc (cdr gnus-newsrc-alist))
3263 (lowest (or lowest 1))
3264 info clevel unread group)
3266 (if (< lowest gnus-level-zombie)
3267 ;; List living groups.
3269 (setq info (car newsrc)
3272 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3273 (and unread ; This group might be bogus
3275 (string-match regexp group))
3276 (<= (setq clevel (car (cdr info))) level)
3278 (or all ; We list all groups?
3279 (eq unread t) ; We list unactivated groups
3280 (> unread 0) ; We list groups with unread articles
3281 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3282 (gnus-group-insert-group-line
3283 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3285 ;; List dead groups.
3286 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3287 (gnus-group-prepare-flat-list-dead
3288 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3289 gnus-level-zombie ?Z
3291 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3292 (gnus-group-prepare-flat-list-dead
3293 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3294 gnus-level-killed ?K regexp))
3296 (gnus-group-set-mode-line)
3297 (setq gnus-have-all-newsgroups all)
3298 (run-hooks 'gnus-group-prepare-hook)))
3300 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3301 ;; List zombies and killed lists somehwat faster, which was
3302 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3303 ;; this by ignoring the group format specification altogether.
3306 (setq group (car groups)
3307 groups (cdr groups))
3308 (if (or (not regexp)
3309 (string-match regexp group))
3312 (insert (format " %c *: %s\n" mark group))
3313 (add-text-properties
3315 (list 'gnus-group (intern group)
3317 'gnus-level level)))))))
3319 (defun gnus-group-real-name (group)
3320 "Find the real name of a foreign newsgroup."
3321 (if (string-match ":[^:]+$" group)
3322 (substring group (1+ (match-beginning 0)))
3325 (defun gnus-group-prefixed-name (group method)
3326 "Return the whole name from GROUP and METHOD."
3327 (and (stringp method) (setq method (gnus-server-to-method method)))
3328 (concat (format "%s" (car method))
3330 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3331 (not (string= (nth 1 method) "")))
3332 (concat "+" (nth 1 method)))
3335 (defun gnus-group-real-prefix (group)
3336 "Return the prefix of the current group name."
3337 (if (string-match "^[^:]+:" group)
3338 (substring group 0 (match-end 0))
3341 (defun gnus-group-method-name (group)
3342 "Return the method used for selecting GROUP."
3343 (let ((prefix (gnus-group-real-prefix group)))
3344 (if (equal prefix "")
3346 (if (string-match "^[^\\+]+\\+" prefix)
3347 (list (intern (substring prefix 0 (1- (match-end 0))))
3348 (substring prefix (match-end 0) (1- (length prefix))))
3349 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3351 (defun gnus-group-foreign-p (group)
3352 "Return nil if GROUP is native, non-nil if it is foreign."
3353 (string-match ":" group))
3355 (defun gnus-group-set-info (info &optional method-only-group part)
3356 (let* ((entry (gnus-gethash
3357 (or method-only-group (car info)) gnus-newsrc-hashtb))
3359 (info (if method-only-group (nth 2 entry) info)))
3360 (if (not method-only-group)
3363 (error "Trying to change non-existent group %s" method-only-group))
3364 ;; We have recevied parts of the actual group info - either the
3365 ;; select method or the group parameters. We first check
3366 ;; whether we have to extend the info, and if so, do that.
3367 (let ((len (length info))
3368 (total (if (eq part 'method) 5 6)))
3370 (setcdr (nthcdr (1- len) info)
3371 (make-list (- total len) nil)))
3372 ;; Then we enter the new info.
3373 (setcar (nthcdr (1- total) info) part-info)))
3374 ;; We uncompress some lists of marked articles.
3376 (if (not (setq marked (nth 3 info)))
3379 (or (eq 'score (car (car marked)))
3380 (eq 'bookmark (car (car marked)))
3381 (eq 'killed (car (car marked)))
3382 (setcdr (car marked)
3383 (gnus-uncompress-range (cdr (car marked)))))
3384 (setq marked (cdr marked)))))
3387 ;; This is a new group, so we just create it.
3389 (set-buffer gnus-group-buffer)
3391 ;; It's a foreign group...
3392 (gnus-group-make-group
3393 (gnus-group-real-name (car info))
3394 (prin1-to-string (car (nth 4 info)))
3395 (nth 1 (nth 4 info)))
3396 ;; It's a native group.
3397 (gnus-group-make-group
3399 (prin1-to-string (car gnus-select-method))
3400 (nth 1 gnus-select-method)))
3401 (gnus-message 6 "Note: New group created")
3403 (gnus-gethash (gnus-group-prefixed-name
3404 (gnus-group-real-name (car info))
3405 (or (nth 4 info) gnus-select-method))
3406 gnus-newsrc-hashtb))))
3407 ;; Whether it was a new group or not, we now have the entry, so we
3408 ;; can do the update.
3411 (setcar (nthcdr 2 entry) info)
3412 (if (and (not (eq (car entry) t))
3413 (gnus-gethash (car info) gnus-active-hashtb))
3414 (let ((marked (nth 3 info)))
3416 (max 0 (- (length (gnus-list-of-unread-articles
3418 (length (cdr (assq 'tick marked)))
3419 (length (cdr (assq 'dormant marked)))))))))
3420 (error "No such group: %s" (car info)))))
3422 (defun gnus-group-set-method-info (group select-method)
3423 (gnus-group-set-info select-method group 'method))
3425 (defun gnus-group-set-params-info (group params)
3426 (gnus-group-set-info params group 'params))
3428 (defun gnus-group-update-group-line ()
3429 "This function updates the current line in the newsgroup buffer and
3430 moves the point to the colon."
3431 (let* ((buffer-read-only nil)
3432 (group (gnus-group-group-name))
3433 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3436 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3439 (delete-region (point) (progn (forward-line 1) (point)))
3440 (gnus-group-insert-group-line-info group)
3442 (gnus-group-position-cursor)))
3444 (defun gnus-group-insert-group-line-info (group)
3445 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3449 (setq info (nth 2 entry))
3450 (gnus-group-insert-group-line
3451 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3452 (setq active (gnus-gethash group gnus-active-hashtb))
3453 (gnus-group-insert-group-line
3455 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3456 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3458 (defun gnus-group-insert-group-line (gformat group level marked number method)
3459 (let* ((gformat (or gformat gnus-group-line-format-spec))
3460 (active (gnus-gethash group gnus-active-hashtb))
3461 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3462 (number-of-dormant (length (cdr (assq 'dormant marked))))
3463 (number-of-ticked (length (cdr (assq 'tick marked))))
3464 (number-of-ticked-and-dormant
3465 (+ number-of-ticked number-of-dormant))
3466 (number-of-unread-unticked
3467 (if (numberp number) (int-to-string (max 0 number))
3470 (if (numberp number)
3471 (max 0 (- number-total number))
3473 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3474 ((<= level gnus-level-unsubscribed) ?U)
3475 ((= level gnus-level-zombie) ?Z)
3477 (qualified-group (gnus-group-real-name group))
3478 (newsgroup-description
3479 (if gnus-description-hashtb
3480 (or (gnus-gethash group gnus-description-hashtb) "")
3482 (moderated (if (member group gnus-moderated-list) ?m ? ))
3483 (moderated-string (if (eq moderated ?m) "(m)" ""))
3484 (method (gnus-server-get-method group method))
3485 (news-server (or (car (cdr method)) ""))
3486 (news-method (or (car method) ""))
3488 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3492 (> number-of-ticked 0))
3494 (number (if (eq number t) "*" (+ number number-of-dormant
3496 (process-marked (if (member qualified-group gnus-group-marked)
3497 gnus-process-mark ? ))
3498 (buffer-read-only nil)
3503 (insert (eval gformat))
3505 (add-text-properties
3506 b (1+ b) (list 'gnus-group (intern group)
3507 'gnus-unread (if (numberp number)
3508 (string-to-int number-of-unread-unticked)
3511 'gnus-level level))))
3513 (defun gnus-group-update-group (group &optional visible-only)
3514 "Update newsgroup info of GROUP.
3515 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3517 (set-buffer gnus-group-buffer)
3518 (let ((buffer-read-only nil)
3520 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3523 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3525 ;; Buffer may be narrowed.
3528 ;; Search a line to modify. If the buffer is large, the search
3529 ;; takes long time. In most cases, current point is on the line
3530 ;; we are looking for. So, first of all, check current line.
3533 (eq (get-text-property (point) 'gnus-group)
3538 (point-min) (point-max) 'gnus-group (intern group)))))
3539 ;; GROUP is listed in current buffer. So, delete old line.
3543 (delete-region (point) (progn (forward-line 1) (point))))
3544 ;; No such line in the buffer, find out where it's supposed to
3545 ;; go, and insert it there (or at the end of the buffer).
3546 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3549 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3555 (point-min) (point-max)
3556 'gnus-group (intern (car (car entry)))))))
3557 (setq entry (cdr entry)))
3558 (or entry (goto-char (point-max)))))))
3559 (if (or visible (not visible-only))
3560 (gnus-group-insert-group-line-info group))
3561 (gnus-group-set-mode-line))))
3563 (defun gnus-group-set-mode-line ()
3564 (if (memq 'group gnus-updated-mode-lines)
3565 (let* ((gformat (or gnus-group-mode-line-format-spec
3566 (setq gnus-group-mode-line-format-spec
3568 gnus-group-mode-line-format
3569 gnus-group-mode-line-format-alist))))
3570 (news-server (car (cdr gnus-select-method)))
3571 (news-method (car gnus-select-method))
3573 (mode-string (eval gformat)))
3574 (setq mode-string (eval gformat))
3575 (if (> (length mode-string) max-len)
3576 (setq mode-string (substring mode-string 0 (- max-len 4))))
3577 (setq mode-line-buffer-identification mode-string)
3578 (set-buffer-modified-p t))))
3580 (defun gnus-group-group-name ()
3581 "Get the name of the newsgroup on the current line."
3582 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3583 (and group (symbol-name group))))
3585 (defun gnus-group-group-level ()
3586 "Get the level of the newsgroup on the current line."
3587 (get-text-property (gnus-point-at-bol) 'gnus-level))
3589 (defun gnus-group-group-unread ()
3590 "Get the number of unread articles of the newsgroup on the current line."
3591 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3593 (defun gnus-group-search-forward (&optional backward all level first-too)
3594 "Find the next newsgroup with unread articles.
3595 If BACKWARD is non-nil, find the previous newsgroup instead.
3596 If ALL is non-nil, just find any newsgroup.
3597 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3599 If FIRST-TOO, the current line is also eligible as a target."
3600 (let ((way (if backward -1 1))
3604 (if (and backward (progn (beginning-of-line)) (bobp))
3606 (or first-too (forward-line way))
3614 (get-text-property (point) 'gnus-unread)))
3615 (or (eq unread t) (and unread (> unread 0))))
3616 (let ((lev (get-text-property
3617 (point) 'gnus-level)))
3618 (and lev (<= (get-text-property
3619 (point) 'gnus-level)
3620 gnus-level-subscribed)))))
3622 (let ((lev (get-text-property (point)
3624 (if (and lev (= lev level))
3626 (if (and (< lev low)
3630 (setq pos (point))))
3632 (zerop (forward-line way)))))
3634 (progn (gnus-group-position-cursor) t)
3635 (if pos (goto-char pos) (goto-char beg))
3638 ;;; Gnus group mode commands
3642 (defun gnus-group-mark-group (n &optional unmark no-advance)
3643 "Mark the current group."
3645 (let ((buffer-read-only nil)
3649 (setq group (gnus-group-group-name))
3657 (setq gnus-group-marked (delete group gnus-group-marked)))
3659 (setq gnus-group-marked
3660 (cons group (delete group gnus-group-marked))))
3662 (or no-advance (zerop (gnus-group-next-group 1))))
3664 (gnus-summary-position-cursor)
3667 (defun gnus-group-unmark-group (n)
3668 "Remove the mark from the current group."
3670 (gnus-group-mark-group n 'unmark))
3672 (defun gnus-group-mark-region (unmark beg end)
3673 "Mark all groups between point and mark.
3674 If UNMARK, remove the mark instead."
3675 (interactive "P\nr")
3676 (let ((num (count-lines beg end)))
3679 (- num (gnus-group-mark-group num unmark)))))
3681 (defun gnus-group-remove-mark (group)
3682 (and (gnus-group-goto-group group)
3684 (gnus-group-mark-group 1 'unmark t))))
3686 ;; Return a list of groups to work on. Take into consideration N (the
3687 ;; prefix) and the list of marked groups.
3688 (defun gnus-group-process-prefix (n)
3690 (setq n (prefix-numeric-value n))
3691 ;; There is a prefix, so we return a list of the N next
3693 (let ((way (if (< n 0) -1 1))
3698 (setq group (gnus-group-group-name)))
3699 (setq groups (cons group groups))
3701 (forward-line way)))
3704 ;; No prefix, but a list of marked articles.
3705 (reverse gnus-group-marked))
3707 ;; Neither marked articles or a prefix, so we return the
3709 (let ((group (gnus-group-group-name)))
3710 (and group (list group))))))
3712 ;; Selecting groups.
3714 (defun gnus-group-read-group (all &optional no-article group)
3715 "Read news in this newsgroup.
3716 If argument ALL is non-nil, already read articles become readable.
3717 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3719 (let ((group (or group (gnus-group-group-name)))
3720 number active marked entry)
3721 (or group (error "No group on current line"))
3723 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3724 ;; This group might be a dead group. In that case we have to get
3725 ;; the number of unread articles from `gnus-active-hashtb'.
3727 (setq number (car entry))
3728 (if (setq active (gnus-gethash group gnus-active-hashtb))
3729 (setq number (- (1+ (cdr active)) (car active)))))
3730 (gnus-summary-read-group
3731 group (or all (and (numberp number)
3732 (zerop (+ number (length (cdr (assq 'tick marked)))
3733 (length (cdr (assq 'dormant marked)))))))
3736 (defun gnus-group-select-group (all)
3737 "Select this newsgroup.
3738 No article is selected automatically.
3739 If argument ALL is non-nil, already read articles become readable."
3741 (gnus-group-read-group all t))
3743 ;; Enter a group that is not in the group buffer. Non-nil is returned
3744 ;; if selection was successful.
3745 (defun gnus-group-read-ephemeral-group
3746 (group method &optional activate quit-config)
3747 (let ((group (if (gnus-group-foreign-p group) group
3748 (gnus-group-prefixed-name group method))))
3751 (list t nil (list group gnus-level-default-subscribed nil nil
3755 (if quit-config quit-config
3756 (cons (current-buffer) 'summary)))))))
3758 (set-buffer gnus-group-buffer)
3759 (or (gnus-server-opened method)
3760 (gnus-open-server method)
3761 (error "Unable to contact server: %s" (gnus-status-message method)))
3762 (if activate (or (gnus-request-group group)
3763 (error "Couldn't request group")))
3765 (gnus-group-read-group t t group)
3768 (not (equal major-mode 'gnus-group-mode))))
3770 (defun gnus-group-jump-to-group (group)
3771 "Jump to newsgroup GROUP."
3773 (list (completing-read
3774 "Group: " gnus-active-hashtb nil (not (not gnus-read-active-file)))))
3776 (if (equal group "")
3777 (error "Empty group name"))
3779 (let ((b (text-property-any
3780 (point-min) (point-max) 'gnus-group (intern group))))
3782 ;; Either go to the line in the group buffer...
3784 ;; ... or insert the line.
3786 (gnus-gethash group gnus-active-hashtb)
3787 (gnus-activate-newsgroup group)
3788 (error "%s error: %s" group (gnus-status-message group)))
3790 (gnus-group-update-group group)
3791 (goto-char (text-property-any
3792 (point-min) (point-max) 'gnus-group (intern group)))))
3793 ;; Adjust cursor point.
3794 (gnus-group-position-cursor))
3796 (defun gnus-group-goto-group (group)
3797 "Goto to newsgroup GROUP."
3798 (let ((b (text-property-any (point-min) (point-max)
3799 'gnus-group (intern group))))
3800 (and b (goto-char b))))
3802 (defun gnus-group-next-group (n)
3803 "Go to next N'th newsgroup.
3804 If N is negative, search backward instead.
3805 Returns the difference between N and the number of skips actually
3808 (gnus-group-next-unread-group n t))
3810 (defun gnus-group-next-unread-group (n &optional all level)
3811 "Go to next N'th unread newsgroup.
3812 If N is negative, search backward instead.
3813 If ALL is non-nil, choose any newsgroup, unread or not.
3814 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3815 such group can be found, the next group with a level higher than
3817 Returns the difference between N and the number of skips actually
3820 (let ((backward (< n 0))
3823 (gnus-group-search-forward
3824 backward (or (not gnus-group-goto-unread) all) level))
3826 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3827 (if level " on this level or higher" "")))
3830 (defun gnus-group-prev-group (n)
3831 "Go to previous N'th newsgroup.
3832 Returns the difference between N and the number of skips actually
3835 (gnus-group-next-unread-group (- n) t))
3837 (defun gnus-group-prev-unread-group (n)
3838 "Go to previous N'th unread newsgroup.
3839 Returns the difference between N and the number of skips actually
3842 (gnus-group-next-unread-group (- n)))
3844 (defun gnus-group-next-unread-group-same-level (n)
3845 "Go to next N'th unread newsgroup on the same level.
3846 If N is negative, search backward instead.
3847 Returns the difference between N and the number of skips actually
3850 (gnus-group-next-unread-group n t (gnus-group-group-level))
3851 (gnus-group-position-cursor))
3853 (defun gnus-group-prev-unread-group-same-level (n)
3854 "Go to next N'th unread newsgroup on the same level.
3855 Returns the difference between N and the number of skips actually
3858 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3859 (gnus-group-position-cursor))
3861 (defun gnus-group-best-unread-group (&optional exclude-group)
3862 "Go to the group with the highest level.
3863 If EXCLUDE-GROUP, do not go to that group."
3865 (goto-char (point-min))
3868 (while (setq unread (get-text-property (point) 'gnus-unread))
3869 (if (and (numberp unread) (> unread 0))
3871 (if (and (< (get-text-property (point) 'gnus-level) best)
3872 (or (not exclude-group)
3873 (not (equal exclude-group (gnus-group-group-name)))))
3875 (setq best (get-text-property (point) 'gnus-level))
3876 (setq best-point (point))))))
3878 (if best-point (goto-char best-point))
3879 (gnus-summary-position-cursor)
3880 (and best-point (gnus-group-group-name))))
3882 (defun gnus-group-first-unread-group ()
3883 "Go to the first group with unread articles."
3885 (goto-char (point-min))
3886 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3887 (gnus-group-next-unread-group 1))
3888 (gnus-group-position-cursor))
3890 (defun gnus-group-enter-server-mode ()
3891 "Jump to the server buffer."
3893 (gnus-server-setup-buffer)
3894 (gnus-configure-windows 'server)
3895 (gnus-server-prepare))
3897 (defun gnus-group-make-group (name method &optional address)
3898 "Add a new newsgroup.
3899 The user will be prompted for a NAME, for a select METHOD, and an
3903 (read-string "Group name: ")
3906 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3908 (if (assoc method gnus-valid-select-methods)
3910 (if (memq 'prompt-address
3911 (assoc method gnus-valid-select-methods))
3912 (read-string "Address: ")
3914 (list method nil)))))
3916 (let* ((meth (if address (list (intern method) address) method))
3917 (nname (gnus-group-prefixed-name name meth))
3919 (and (gnus-gethash nname gnus-newsrc-hashtb)
3920 (error "Group %s already exists" nname))
3921 (gnus-group-change-level
3922 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3923 gnus-level-default-subscribed gnus-level-killed
3924 (and (gnus-group-group-name)
3925 (gnus-gethash (gnus-group-group-name)
3926 gnus-newsrc-hashtb))
3928 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
3930 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3931 (gnus-group-insert-group-line-info nname)
3933 (if (assoc method gnus-valid-select-methods)
3934 (require (intern method)))
3935 (and (gnus-check-backend-function 'request-create-group nname)
3936 (gnus-request-create-group nname))))
3938 (defun gnus-group-edit-group (group &optional part)
3939 "Edit the group on the current line."
3940 (interactive (list (gnus-group-group-name)))
3941 (let ((done-func '(lambda ()
3942 "Exit editing mode and update the information."
3944 (gnus-group-edit-group-done 'part 'group)))
3945 (part (or part 'info))
3946 (winconf (current-window-configuration))
3948 (or group (error "No group on current line"))
3949 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3950 (error "Killed group; can't be edited"))
3951 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3952 (gnus-configure-windows 'edit-group)
3953 (gnus-add-current-to-buffer-list)
3955 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3956 (use-local-map (copy-keymap emacs-lisp-mode-map))
3957 (local-set-key "\C-c\C-c" done-func)
3958 (make-local-variable 'gnus-prev-winconf)
3959 (setq gnus-prev-winconf winconf)
3960 ;; We modify the func to let it know what part it is editing.
3961 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3962 (setcar (cdr (cdr (nth 4 done-func))) group)
3967 ";; Type `C-c C-c' after editing the select method.\n\n")
3969 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3971 ";; Type `C-c C-c' after editing the group info.\n\n")))
3972 (let ((cinfo (gnus-copy-sequence info))
3974 (if (not (setq marked (nth 3 cinfo)))
3977 (or (eq 'score (car (car marked)))
3978 (eq 'bookmark (car (car marked)))
3979 (eq 'killed (car (car marked)))
3980 (not (numberp (car (cdr (car marked)))))
3981 (setcdr (car marked)
3982 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3983 (setq marked (cdr marked))))
3986 (cond ((eq part 'method)
3987 (or (nth 4 info) "native"))
3994 (defun gnus-group-edit-group-method (group)
3995 "Edit the select method of GROUP."
3996 (interactive (list (gnus-group-group-name)))
3997 (gnus-group-edit-group group 'method))
3999 (defun gnus-group-edit-group-parameters (group)
4000 "Edit the group parameters of GROUP."
4001 (interactive (list (gnus-group-group-name)))
4002 (gnus-group-edit-group group 'params))
4004 (defun gnus-group-edit-group-done (part group)
4005 "Get info from buffer, update variables and jump to the group buffer."
4006 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4007 (goto-char (point-min))
4008 (let ((form (read (current-buffer)))
4009 (winconf gnus-prev-winconf))
4011 (gnus-group-set-info form)
4012 (gnus-group-set-info form group part))
4013 (kill-buffer (current-buffer))
4014 (and winconf (set-window-configuration winconf))
4015 (set-buffer gnus-group-buffer)
4016 (gnus-group-update-group (gnus-group-group-name))
4017 (gnus-group-position-cursor)))
4019 (defun gnus-group-make-help-group ()
4020 "Create the (ding) Gnus documentation group."
4022 (let ((path load-path)
4024 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4025 "gnus-help" '(nndoc "gnus-help")))
4027 (error "Documentation group already exists"))
4029 (not (file-exists-p (concat (file-name-as-directory (car path))
4031 (setq path (cdr path)))
4032 (or path (error "Couldn't find doc group"))
4033 (gnus-group-make-group
4034 (gnus-group-real-name name)
4036 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4037 (list 'nndoc-article-type 'mbox))))
4038 (gnus-group-position-cursor))
4040 (defun gnus-group-make-doc-group (file type)
4041 "Create a group that uses a single file as the source."
4043 (list (read-file-name "File name: ")
4047 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4048 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4049 ((= char ?b) 'babyl)
4050 ((= char ?d) 'digest)
4051 (t (setq err "%c unknown. " char)
4054 (let* ((file (expand-file-name file))
4055 (name (gnus-generate-new-group-name
4056 (gnus-group-prefixed-name
4057 (file-name-nondirectory file) '(nndoc "")))))
4058 (gnus-group-make-group
4059 (gnus-group-real-name name)
4061 (list 'nndoc-address file)
4062 (list 'nndoc-article-type type)))))
4064 (defun gnus-group-make-archive-group ()
4065 "Create the (ding) Gnus archive group."
4067 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
4069 (error "Archive group already exists"))
4070 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
4071 (gnus-group-position-cursor))
4073 (defun gnus-group-make-directory-group (dir)
4074 "Create an nndir group.
4075 The user will be prompted for a directory. The contents of this
4076 directory will be used as a newsgroup. The directory should contain
4077 mail messages or news articles in files that have numeric names."
4079 (list (read-file-name "Create group from directory: ")))
4080 (or (file-exists-p dir) (error "No such directory"))
4081 (or (file-directory-p dir) (error "Not a directory"))
4082 (gnus-group-make-group dir "nndir" dir)
4083 (gnus-group-position-cursor))
4085 (defun gnus-group-make-kiboze-group (group address scores)
4086 "Create an nnkiboze group.
4087 The user will be prompted for a name, a regexp to match groups, and
4088 score file entries for articles to include in the group."
4091 (read-string "nnkiboze group name: ")
4092 (read-string "Source groups (regexp): ")
4093 (let ((headers (mapcar (lambda (group) (list group))
4094 '("subject" "from" "number" "date" "message-id"
4095 "references" "chars" "lines" "xref")))
4096 scores header regexp regexps)
4097 (while (not (equal "" (setq header (completing-read
4098 "Match on header: " headers nil t))))
4100 (while (not (equal "" (setq regexp (read-string
4101 (format "Match on %s (string): "
4103 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4104 (setq scores (cons (cons header regexps) scores)))
4106 (gnus-group-make-group group "nnkiboze" address)
4108 (gnus-set-work-buffer)
4109 (let (emacs-lisp-mode-hook)
4110 (pp scores (current-buffer)))
4111 (write-region (point-min) (point-max)
4112 (concat (or gnus-kill-files-directory "~/News")
4113 "nnkiboze:" group "." gnus-score-file-suffix)))
4114 (gnus-group-position-cursor))
4116 (defun gnus-group-add-to-virtual (n vgroup)
4117 "Add the current group to a virtual group."
4119 (list current-prefix-arg
4120 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4122 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4123 (error "%s is not an nnvirtual group" vgroup))
4124 (let* ((groups (gnus-group-process-prefix n))
4125 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4126 (setcar (cdr method)
4128 (nth 1 method) "\\|"
4131 (gnus-group-remove-mark s)
4132 (concat "\\(^" (regexp-quote s) "$\\)"))
4134 (gnus-group-position-cursor))
4136 (defun gnus-group-make-empty-virtual (group)
4137 "Create a new, fresh, empty virtual group."
4138 (interactive "sCreate new, empty virtual group: ")
4139 (let* ((method (list 'nnvirtual "^$"))
4140 (pgroup (gnus-group-prefixed-name group method)))
4141 ;; Check whether it exists already.
4142 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4143 (error "Group %s already exists." pgroup))
4144 ;; Subscribe the new group after the group on the current line.
4145 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4146 (gnus-group-update-group pgroup)
4148 (gnus-group-position-cursor)))
4150 (defun gnus-group-enter-directory (dir)
4151 "Enter an ephemeral nneething group."
4152 (interactive "DDirectory to read: ")
4153 (let* ((method (list 'nneething dir))
4154 (leaf (gnus-group-prefixed-name
4155 (file-name-nondirectory (directory-file-name dir))
4157 (name (gnus-generate-new-group-name leaf)))
4158 (let ((nneething-read-only t))
4159 (or (gnus-group-read-ephemeral-group
4161 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4163 (error "Couldn't enter %s" dir)))))
4165 ;; Group sorting commands
4166 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4168 (defun gnus-group-sort-groups ()
4169 "Sort the group buffer using `gnus-group-sort-function'."
4171 (setq gnus-newsrc-alist
4172 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4173 (gnus-make-hashtable-from-newsrc-alist)
4174 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4176 (defun gnus-group-sort-by-alphabet (info1 info2)
4177 (string< (car info1) (car info2)))
4179 (defun gnus-group-sort-by-unread (info1 info2)
4180 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4181 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4182 (< (or (and (numberp n1) n1) 0)
4183 (or (and (numberp n2) n2) 0))))
4185 (defun gnus-group-sort-by-level (info1 info2)
4186 (< (nth 1 info1) (nth 1 info2)))
4188 ;; Group catching up.
4190 (defun gnus-group-catchup-current (n &optional all)
4191 "Mark all articles not marked as unread in current newsgroup as read.
4192 If prefix argument N is numeric, the ARG next newsgroups will be
4193 caught up. If ALL is non-nil, marked articles will also be marked as
4194 read. Cross references (Xref: header) of articles are ignored.
4195 The difference between N and actual number of newsgroups that were
4196 caught up is returned."
4198 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4202 "Do you really want to mark all articles as read? "
4203 "Mark all unread articles as read? "))))
4205 (let ((groups (gnus-group-process-prefix n))
4208 ;; Virtual groups have to be given special treatment.
4209 (let ((method (gnus-find-method-for-group (car groups))))
4210 (if (eq 'nnvirtual (car method))
4211 (nnvirtual-catchup-group
4212 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4213 (gnus-group-remove-mark (car groups))
4215 (gnus-group-goto-group (car groups))
4216 (gnus-group-catchup (car groups) all))
4217 (gnus-group-update-group-line)
4218 (setq ret (1+ ret)))
4219 (setq groups (cdr groups)))
4220 (gnus-group-next-unread-group 1)
4223 (defun gnus-group-catchup-current-all (n)
4224 "Mark all articles in current newsgroup as read.
4225 Cross references (Xref: header) of articles are ignored."
4227 (gnus-group-catchup-current n 'all))
4229 (defun gnus-group-catchup (group &optional all)
4230 "Mark all articles in GROUP as read.
4231 If ALL is non-nil, all articles are marked as read.
4232 The return value is the number of articles that were marked as read,
4233 or nil if no action could be taken."
4234 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4236 (marked (nth 3 (nth 2 entry))))
4237 (if (not (numberp (car entry)))
4238 (gnus-message 1 "Can't catch up; non-active group")
4239 ;; Do the updating only if the newsgroup isn't killed.
4242 (gnus-update-read-articles
4243 group (and (not all) (append (cdr (assq 'tick marked))
4244 (cdr (assq 'dormant marked))))
4245 nil (and (not all) (cdr (assq 'tick marked))))
4247 (setcar (nthcdr 3 (nth 2 entry))
4248 (delq (assq 'dormant marked)
4249 (nth 3 (nth 2 entry)))))))
4252 (defun gnus-group-expire-articles (n)
4253 "Expire all expirable articles in the current newsgroup."
4255 (let ((groups (gnus-group-process-prefix n))
4257 (or groups (error "No groups to expire"))
4259 (setq group (car groups)
4260 groups (cdr groups))
4261 (gnus-group-remove-mark group)
4262 (if (not (gnus-check-backend-function 'request-expire-articles group))
4264 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4265 (expirable (if (memq 'total-expire (nth 5 info))
4266 (cons nil (gnus-list-of-read-articles group))
4267 (assq 'expire (nth 3 info)))))
4270 (gnus-request-expire-articles
4271 (cdr expirable) group))))))))
4273 (defun gnus-group-expire-all-groups ()
4274 "Expire all expirable articles in all newsgroups."
4277 (gnus-message 5 "Expiring...")
4278 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4279 (cdr gnus-newsrc-alist))))
4280 (gnus-group-expire-articles nil)))
4281 (gnus-group-position-cursor)
4282 (gnus-message 5 "Expiring...done"))
4284 (defun gnus-group-set-current-level (n level)
4285 "Set the level of the next N groups to LEVEL."
4286 (interactive "P\nnLevel: ")
4287 (or (and (>= level 1) (<= level gnus-level-killed))
4288 (error "Illegal level: %d" level))
4289 (let ((groups (gnus-group-process-prefix n))
4292 (setq group (car groups)
4293 groups (cdr groups))
4294 (gnus-group-remove-mark group)
4295 (gnus-message 6 "Changed level of %s from %d to %d"
4296 group (gnus-group-group-level) level)
4297 (gnus-group-change-level group level
4298 (gnus-group-group-level))
4299 (gnus-group-update-group-line)))
4300 (gnus-group-position-cursor))
4302 (defun gnus-group-unsubscribe-current-group (n)
4303 "Toggle subscription of the current group.
4304 If given numerical prefix, toggle the N next groups."
4306 (let ((groups (gnus-group-process-prefix n))
4309 (setq group (car groups)
4310 groups (cdr groups))
4311 (gnus-group-remove-mark group)
4312 (gnus-group-unsubscribe-group
4313 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4314 gnus-level-default-unsubscribed
4315 gnus-level-default-subscribed))
4316 (gnus-group-update-group-line))
4317 (gnus-group-next-group 1)))
4319 (defun gnus-group-unsubscribe-group (group &optional level)
4320 "Toggle subscribe from/to unsubscribe GROUP.
4321 New newsgroup is added to .newsrc automatically."
4323 (list (completing-read "Group: " gnus-active-hashtb nil
4324 gnus-have-read-active-file)))
4325 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4327 ;; Toggle subscription flag.
4328 (gnus-group-change-level
4329 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4330 gnus-level-subscribed)
4331 (1+ gnus-level-subscribed)
4332 gnus-level-default-subscribed)))
4333 (gnus-group-update-group group))
4334 ((and (stringp group)
4335 (or (not gnus-have-read-active-file)
4336 (gnus-gethash group gnus-active-hashtb)))
4337 ;; Add new newsgroup.
4338 (gnus-group-change-level
4340 (if level level gnus-level-default-subscribed)
4341 (or (and (member group gnus-zombie-list)
4344 (and (gnus-group-group-name)
4345 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4346 (gnus-group-update-group group))
4347 (t (error "No such newsgroup: %s" group)))
4348 (gnus-group-position-cursor)))
4350 (defun gnus-group-transpose-groups (n)
4351 "Move the current newsgroup up N places.
4352 If given a negative prefix, move down instead. The difference between
4353 N and the number of steps taken is returned."
4355 (or (gnus-group-group-name)
4356 (error "No group on current line"))
4357 (gnus-group-kill-group 1)
4359 (forward-line (- n))
4360 (gnus-group-yank-group)
4361 (gnus-group-position-cursor)))
4363 (defun gnus-group-kill-all-zombies ()
4364 "Kill all zombie newsgroups."
4366 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4367 (setq gnus-zombie-list nil)
4368 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4369 (goto-char (point-min))
4370 (gnus-group-position-cursor))
4372 (defun gnus-group-kill-region (begin end)
4373 "Kill newsgroups in current region (excluding current point).
4374 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4389 (beginning-of-line) ;Important when LINES < 1
4390 (gnus-group-kill-group lines)))
4392 (defun gnus-group-kill-group (n)
4393 "The the next N groups.
4394 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4395 However, only groups that were alive can be yanked; already killed
4396 groups or zombie groups can't be yanked.
4397 The return value is the name of the (last) group that was killed."
4399 (let ((buffer-read-only nil)
4400 (groups (gnus-group-process-prefix n))
4403 (setq group (car groups)
4404 groups (cdr groups))
4405 (gnus-group-remove-mark group)
4406 (setq level (gnus-group-group-level))
4408 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4409 (setq gnus-list-of-killed-groups
4410 (cons (cons (car entry) (nth 2 entry))
4411 gnus-list-of-killed-groups)))
4412 (gnus-group-change-level
4413 (if entry entry group) gnus-level-killed (if entry nil level)))
4414 (gnus-group-position-cursor)
4417 (defun gnus-group-yank-group (&optional arg)
4418 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4419 inserting it before the current newsgroup. The numeric ARG specifies
4420 how many newsgroups are to be yanked. The name of the (last)
4421 newsgroup yanked is returned."
4423 (if (not arg) (setq arg 1))
4424 (let (info group prev)
4425 (while (>= (setq arg (1- arg)) 0)
4426 (if (not (setq info (car gnus-list-of-killed-groups)))
4427 (error "No more newsgroups to yank"))
4428 (setq group (nth 2 info))
4429 ;; Find which newsgroup to insert this one before - search
4430 ;; backward until something suitable is found. If there are no
4431 ;; other newsgroups in this buffer, just make this newsgroup the
4433 (setq prev (gnus-group-group-name))
4434 (gnus-group-change-level
4435 info (nth 2 info) gnus-level-killed
4436 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4438 (gnus-group-insert-group-line-info (nth 1 info))
4439 (setq gnus-list-of-killed-groups
4440 (cdr gnus-list-of-killed-groups)))
4442 (gnus-group-position-cursor)
4445 (defun gnus-group-list-all-groups (arg)
4446 "List all newsgroups with level ARG or lower.
4447 Default is gnus-level-unsubscribed, which lists all subscribed and most
4448 unsubscribed groups."
4450 (setq arg (or arg gnus-level-unsubscribed))
4451 (gnus-group-list-groups arg t))
4453 (defun gnus-group-list-killed ()
4454 "List all killed newsgroups in the group buffer."
4456 (if (not gnus-killed-list)
4457 (gnus-message 6 "No killed groups")
4458 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4459 (goto-char (point-min)))
4460 (gnus-group-position-cursor))
4462 (defun gnus-group-list-zombies ()
4463 "List all zombie newsgroups in the group buffer."
4465 (if (not gnus-zombie-list)
4466 (gnus-message 6 "No zombie groups")
4467 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4468 (goto-char (point-min)))
4469 (gnus-group-position-cursor))
4471 (defun gnus-group-get-new-news (&optional arg)
4472 "Get newly arrived articles.
4473 If ARG is non-nil, it should be a number between one and nine to
4474 specify which levels you are interested in re-scanning."
4476 (run-hooks 'gnus-get-new-news-hook)
4478 (if gnus-group-use-permanent-levels
4480 (setq gnus-group-default-list-level level)
4481 (setq level (or gnus-group-default-list-level
4482 gnus-level-subscribed))))
4483 (if (and gnus-read-active-file (not level))
4485 (gnus-read-active-file)
4486 (gnus-get-unread-articles (or level (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 level (1+ gnus-level-subscribed)))))
4490 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels level)
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))
8039 (kill-buffer tmp-buf))))))))
8041 (defun gnus-summary-enter-digest-group ()
8042 "Enter a digest group based on the current article."
8044 (gnus-set-global-variables)
8045 (gnus-summary-select-article)
8046 ;; We do not want a narrowed article.
8047 (gnus-summary-stop-page-breaking)
8048 (let ((name (format "%s-%d"
8049 (gnus-group-prefixed-name
8050 gnus-newsgroup-name (list 'nndoc ""))
8051 gnus-current-article))
8052 (ogroup gnus-newsgroup-name)
8053 (buf (current-buffer)))
8054 (if (gnus-group-read-ephemeral-group
8055 name (list 'nndoc name
8056 (list 'nndoc-address (get-buffer gnus-article-buffer))
8057 '(nndoc-article-type digest))
8059 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8060 (list (list (cons 'to-group ogroup))))
8061 (switch-to-buffer buf)
8062 (gnus-set-global-variables)
8063 (gnus-configure-windows 'summary)
8064 (gnus-message 3 "Article not a digest?"))))
8066 (defun gnus-summary-isearch-article ()
8067 "Do incremental search forward on current article."
8069 (gnus-set-global-variables)
8070 (gnus-summary-select-article)
8071 (gnus-eval-in-buffer-window
8072 gnus-article-buffer (isearch-forward)))
8074 (defun gnus-summary-search-article-forward (regexp &optional backward)
8075 "Search for an article containing REGEXP forward.
8076 If BACKWARD, search backward instead."
8079 (format "Search article %s (regexp%s): "
8080 (if current-prefix-arg "backward" "forward")
8081 (if gnus-last-search-regexp
8082 (concat ", default " gnus-last-search-regexp)
8084 current-prefix-arg))
8085 (gnus-set-global-variables)
8086 (if (string-equal regexp "")
8087 (setq regexp (or gnus-last-search-regexp ""))
8088 (setq gnus-last-search-regexp regexp))
8089 (if (gnus-summary-search-article regexp backward)
8090 (gnus-article-set-window-start
8091 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8092 (error "Search failed: \"%s\"" regexp)))
8094 (defun gnus-summary-search-article-backward (regexp)
8095 "Search for an article containing REGEXP backward."
8098 (format "Search article backward (regexp%s): "
8099 (if gnus-last-search-regexp
8100 (concat ", default " gnus-last-search-regexp)
8102 (gnus-summary-search-article-forward regexp 'backward))
8104 (defun gnus-summary-search-article (regexp &optional backward)
8105 "Search for an article containing REGEXP.
8106 Optional argument BACKWARD means do search for backward.
8107 gnus-select-article-hook is not called during the search."
8108 (let ((gnus-select-article-hook nil) ;Disable hook.
8109 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8112 (function re-search-backward) (function re-search-forward)))
8115 ;; Hidden thread subtrees must be searched for ,too.
8116 (gnus-summary-show-all-threads)
8117 (if (eobp) (forward-line -1))
8118 ;; First of all, search current article.
8119 ;; We don't want to read article again from NNTP server nor reset
8121 (gnus-summary-select-article)
8122 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8123 (setq last gnus-current-article)
8124 (gnus-eval-in-buffer-window gnus-article-buffer
8127 ;; Begin search from current point.
8128 (setq found (funcall re-search regexp nil t))))
8129 ;; Then search next articles.
8130 (while (and (not found)
8131 (gnus-summary-display-article
8132 (gnus-summary-search-subject backward nil nil)))
8133 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8134 (gnus-eval-in-buffer-window gnus-article-buffer
8137 (goto-char (if backward (point-max) (point-min)))
8138 (setq found (funcall re-search regexp nil t)))))
8140 ;; Adjust article pointer.
8141 (or (eq last gnus-current-article)
8142 (setq gnus-last-article last))
8143 ;; Return T if found such article.
8146 (defun gnus-summary-execute-command (header regexp command &optional backward)
8147 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8148 If HEADER is an empty string (or nil), the match is done on the entire
8149 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8151 (list (let ((completion-ignore-case t))
8154 (mapcar (lambda (string) (list string))
8155 '("Number" "Subject" "From" "Lines" "Date"
8156 "Message-ID" "Xref" "References"))
8157 nil 'require-match))
8158 (read-string "Regexp: ")
8159 (read-key-sequence "Command: ")
8160 current-prefix-arg))
8161 (gnus-set-global-variables)
8162 ;; Hidden thread subtrees must be searched as well.
8163 (gnus-summary-show-all-threads)
8164 ;; We don't want to change current point nor window configuration.
8166 (save-window-excursion
8167 (gnus-message 6 "Executing %s..." (key-description command))
8168 ;; We'd like to execute COMMAND interactively so as to give arguments.
8169 (gnus-execute header regexp
8171 (call-interactively '(, (key-binding command)))))
8173 (gnus-message 6 "Executing %s...done" (key-description command)))))
8175 (defun gnus-summary-beginning-of-article ()
8176 "Scroll the article back to the beginning."
8178 (gnus-set-global-variables)
8179 (gnus-summary-select-article)
8180 (gnus-configure-windows 'article)
8181 (gnus-eval-in-buffer-window
8184 (goto-char (point-min))
8185 (and gnus-break-pages (gnus-narrow-to-page))))
8187 (defun gnus-summary-end-of-article ()
8188 "Scroll to the end of the article."
8190 (gnus-set-global-variables)
8191 (gnus-summary-select-article)
8192 (gnus-configure-windows 'article)
8193 (gnus-eval-in-buffer-window
8196 (goto-char (point-max))
8197 (and gnus-break-pages (gnus-narrow-to-page))))
8199 (defun gnus-summary-show-article (no-refetch)
8200 "Force re-fetching of the current article.
8201 If the prefix argument NO-REFETCH is non-nil, no actual refetch will
8202 be performed. The current article will simply be redisplayed."
8204 (gnus-set-global-variables)
8205 (if (not no-refetch)
8206 (gnus-summary-select-article gnus-have-all-headers t)
8207 (or gnus-current-article
8208 (error "There is no current article"))
8209 (gnus-summary-goto-subject gnus-current-article)
8210 (gnus-configure-windows 'article)
8211 (gnus-summary-position-cursor)))
8213 (defun gnus-summary-verbose-headers (arg)
8214 "Toggle permanent full header display.
8215 If ARG is a positive number, turn header display on.
8216 If ARG is a negative number, turn header display off."
8218 (gnus-set-global-variables)
8219 (gnus-summary-toggle-header arg)
8220 (setq gnus-have-all-headers
8221 (cond ((or (not (numberp arg))
8223 (not gnus-have-all-headers))
8227 (defun gnus-summary-toggle-header (arg)
8228 "Show the headers if they are hidden, or hide them if they are shown.
8229 If ARG is a positive number, show the entire header.
8230 If ARG is a negative number, hide the unwanted header lines."
8232 (gnus-set-global-variables)
8234 (set-buffer gnus-article-buffer)
8235 (let ((buffer-read-only nil))
8237 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8238 gnus-hidden-properties)
8239 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8240 (if (text-property-any (point-min) (point-max) 'invisible t)
8241 (remove-text-properties (point-min) (point-max)
8242 gnus-hidden-properties)
8243 (let ((gnus-have-all-headers nil))
8244 (run-hooks 'gnus-article-display-hook))))
8245 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8247 (defun gnus-summary-show-all-headers ()
8248 "Make all header lines visible."
8250 (gnus-set-global-variables)
8251 (gnus-article-show-all-headers))
8253 (defun gnus-summary-toggle-mime (arg)
8254 "Toggle MIME processing.
8255 If ARG is a positive number, turn MIME processing on."
8257 (gnus-set-global-variables)
8258 (setq gnus-show-mime
8259 (if (null arg) (not gnus-show-mime)
8260 (> (prefix-numeric-value arg) 0)))
8261 (gnus-summary-select-article t 'force))
8263 (defun gnus-summary-caesar-message (arg)
8264 "Caesar rotate the current article by 13.
8265 The numerical prefix specifies how manu places to rotate each letter
8268 (gnus-set-global-variables)
8269 (gnus-summary-select-article)
8270 (let ((mail-header-separator ""))
8271 (gnus-eval-in-buffer-window
8275 (let ((last (point)))
8276 (news-caesar-buffer-body arg)
8280 (defun gnus-summary-stop-page-breaking ()
8281 "Stop page breaking in the current article."
8283 (gnus-set-global-variables)
8284 (gnus-summary-select-article)
8285 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8287 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8289 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
8290 "Move the current article to a different newsgroup.
8291 If N is a positive number, move the N next articles.
8292 If N is a negative number, move the N previous articles.
8293 If N is nil and any articles have been marked with the process mark,
8294 move those articles instead.
8295 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8296 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8297 re-spool using this method.
8298 For this function to work, both the current newsgroup and the
8299 newsgroup that you want to move to have to support the `request-move'
8300 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8302 (gnus-set-global-variables)
8303 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8304 (error "The current newsgroup does not support article moving"))
8305 (let ((articles (gnus-summary-work-articles n))
8306 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8307 art-group to-method sel-met)
8308 (if (and (not to-newsgroup) (not select-method))
8311 (format "Where do you want to move %s? %s"
8312 (if (> (length articles) 1)
8313 (format "these %d articles" (length articles))
8315 (if gnus-current-move-group
8316 (format "(%s default) " gnus-current-move-group)
8318 gnus-active-hashtb nil nil prefix)))
8321 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8322 (setq to-newsgroup (or gnus-current-move-group "")))
8323 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8324 (gnus-activate-newsgroup to-newsgroup)
8325 (error "No such group: %s" to-newsgroup))
8326 (setq gnus-current-move-group to-newsgroup)))
8327 (setq to-method (if select-method (list select-method "")
8328 (gnus-find-method-for-group to-newsgroup)))
8329 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8330 (error "%s does not support article copying" (car to-method)))
8331 (or (gnus-server-opened to-method)
8332 (gnus-open-server to-method)
8333 (error "Can't open server %s" (car to-method)))
8334 (gnus-message 6 "Moving to %s: %s..."
8335 (or select-method to-newsgroup) articles)
8338 (gnus-request-move-article
8339 (car articles) ; Article to move
8340 gnus-newsgroup-name ; From newsgrouo
8341 (nth 1 (gnus-find-method-for-group
8342 gnus-newsgroup-name)) ; Server
8343 (list 'gnus-request-accept-article
8345 (list 'quote select-method)
8347 (not (cdr articles))) ; Accept form
8348 (not (cdr articles)))) ; Only save nov last time
8349 (let* ((buffer-read-only nil)
8352 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8354 (gnus-group-prefixed-name
8356 (if select-method (list select-method "")
8357 (gnus-find-method-for-group to-newsgroup)))
8358 gnus-newsrc-hashtb)))
8359 (info (nth 2 entry))
8360 (article (car articles)))
8361 (gnus-summary-goto-subject article)
8363 (delete-region (point)
8364 (progn (forward-line 1) (point)))
8365 (if (not (memq article gnus-newsgroup-unreads))
8366 (setcar (cdr (cdr info))
8367 (gnus-add-to-range (nth 2 info)
8368 (list (cdr art-group)))))
8369 ;; Copy any marks over to the new group.
8370 (let ((marks '((tick . gnus-newsgroup-marked)
8371 (dormant . gnus-newsgroup-dormant)
8372 (expire . gnus-newsgroup-expirable)
8373 (bookmark . gnus-newsgroup-bookmarks)
8374 ; (score . gnus-newsgroup-scored)
8375 (reply . gnus-newsgroup-replied)))
8376 (to-article (cdr art-group)))
8378 (if (memq article (symbol-value (cdr (car marks))))
8379 (gnus-add-marked-articles
8380 (car info) (car (car marks)) (list to-article) info))
8381 (setq marks (cdr marks))))
8382 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8383 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8384 (setq gnus-newsgroup-dormant
8385 (delq article gnus-newsgroup-dormant)))
8386 (gnus-message 1 "Couldn't move article %s" (car articles)))
8387 (gnus-summary-remove-process-mark (car articles))
8388 (setq articles (cdr articles)))))
8390 (defun gnus-summary-respool-article (n &optional respool-method)
8391 "Respool the current article.
8392 The article will be squeezed through the mail spooling process again,
8393 which means that it will be put in some mail newsgroup or other
8394 depending on `nnmail-split-methods'.
8395 If N is a positive number, respool the N next articles.
8396 If N is a negative number, respool the N previous articles.
8397 If N is nil and any articles have been marked with the process mark,
8398 respool those articles instead.
8400 Respooling can be done both from mail groups and \"real\" newsgroups.
8401 In the former case, the articles in question will be moved from the
8402 current group into whatever groups they are destined to. In the
8403 latter case, they will be copied into the relevant groups."
8405 (gnus-set-global-variables)
8406 (let ((respool-methods (gnus-methods-using 'respool))
8408 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8410 (setq respool-method
8412 "What method do you want to use when respooling? "
8413 respool-methods nil t methname)))
8414 (or (string= respool-method "")
8415 (if (assoc (symbol-name
8416 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8418 (gnus-summary-move-article n nil (intern respool-method))
8419 (gnus-summary-copy-article n nil (intern respool-method))))))
8421 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8422 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
8423 "Move the current article to a different newsgroup.
8424 If N is a positive number, move the N next articles.
8425 If N is a negative number, move the N previous articles.
8426 If N is nil and any articles have been marked with the process mark,
8427 move those articles instead.
8428 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8429 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8430 re-spool using this method.
8431 For this function to work, the newsgroup that you want to move to have
8432 to support the `request-move' and `request-accept'
8433 functions. (Ie. mail newsgroups at present.)"
8435 (gnus-set-global-variables)
8436 (let ((articles (gnus-summary-work-articles n))
8437 (copy-buf (get-buffer-create "*copy work*"))
8438 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8439 art-group to-method)
8440 (buffer-disable-undo copy-buf)
8441 (if (and (not to-newsgroup) (not select-method))
8444 (format "Where do you want to copy %s? %s"
8445 (if (> (length articles) 1)
8446 (format "these %d articles" (length articles))
8448 (if gnus-current-move-group
8449 (format "(%s default) " gnus-current-move-group)
8451 gnus-active-hashtb nil nil prefix)))
8454 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8455 (setq to-newsgroup (or gnus-current-move-group "")))
8456 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8457 (gnus-activate-newsgroup to-newsgroup)
8458 (error "No such group: %s" to-newsgroup))
8459 (setq gnus-current-move-group to-newsgroup)))
8460 (setq to-method (if select-method (list select-method "")
8461 (gnus-find-method-for-group to-newsgroup)))
8462 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8463 (error "%s does not support article copying" (car to-method)))
8464 (or (gnus-server-opened to-method)
8465 (gnus-open-server to-method)
8466 (error "Can't open server %s" (car to-method)))
8467 (gnus-message 6 "Copying to %s: %s..."
8468 (or select-method to-newsgroup) articles)
8472 (set-buffer copy-buf)
8473 (gnus-request-article-this-buffer
8474 (car articles) gnus-newsgroup-name)
8475 (gnus-request-accept-article
8476 (if select-method (quote select-method) to-newsgroup)
8477 (not (cdr articles)))))
8480 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8482 (gnus-group-prefixed-name
8484 (if select-method (list select-method "")
8485 (gnus-find-method-for-group to-newsgroup)))
8486 gnus-newsrc-hashtb)))
8487 (info (nth 2 entry))
8488 (article (car articles)))
8489 (if (not (memq article gnus-newsgroup-unreads))
8490 (setcar (cdr (cdr info))
8491 (gnus-add-to-range (nth 2 info)
8492 (list (cdr art-group)))))
8493 ;; Copy any marks over to the new group.
8494 (let ((marks '((tick . gnus-newsgroup-marked)
8495 (dormant . gnus-newsgroup-dormant)
8496 (expire . gnus-newsgroup-expirable)
8497 (bookmark . gnus-newsgroup-bookmarks)
8498 ; (score . gnus-newsgroup-scored)
8499 (reply . gnus-newsgroup-replied)))
8500 (to-article (cdr art-group)))
8502 (if (memq article (symbol-value (cdr (car marks))))
8503 (gnus-add-marked-articles
8504 (car info) (car (car marks)) (list to-article) info))
8505 (setq marks (cdr marks)))))
8506 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8507 (gnus-summary-remove-process-mark (car articles))
8508 (setq articles (cdr articles)))
8509 (kill-buffer copy-buf)))
8511 (defun gnus-summary-import-article (file)
8512 "Import a random file into a mail newsgroup."
8513 (interactive "fImport file: ")
8514 (let ((group gnus-newsgroup-name)
8516 (or (gnus-check-backend-function 'request-accept-article group)
8517 (error "%s does not support article importing" group))
8518 (or (file-readable-p file)
8519 (not (file-regular-p file))
8520 (error "Can't read %s" file))
8522 (set-buffer (get-buffer-create " *import file*"))
8523 (buffer-disable-undo (current-buffer))
8525 (insert-file-contents file)
8526 (goto-char (point-min))
8527 (if (nnheader-article-p)
8529 (setq atts (file-attributes file))
8530 (insert "From: " (read-string "From: ") "\n"
8531 "Subject: " (read-string "Subject: ") "\n"
8532 "Date: " (current-time-string (nth 5 atts)) "\n"
8533 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8534 (gnus-request-accept-article group t)
8535 (kill-buffer (current-buffer)))))
8537 (defun gnus-summary-expire-articles ()
8538 "Expire all articles that are marked as expirable in the current group."
8540 (if (and gnus-newsgroup-expirable
8541 (gnus-check-backend-function
8542 'request-expire-articles gnus-newsgroup-name))
8543 (let ((expirable gnus-newsgroup-expirable))
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))))))
8555 (defun gnus-summary-expire-articles-now ()
8556 "Expunge all expirable articles in the current group.
8557 This means that *all* articles that are marked as expirable will be
8558 deleted forever, right now."
8560 (or gnus-expert-user
8562 "Are you really, really, really sure you want to expunge? ")
8564 (let ((nnmail-expiry-wait -1)
8565 (nnmail-expiry-wait-function nil))
8566 (gnus-summary-expire-articles)))
8568 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8569 (defun gnus-summary-delete-article (n)
8570 "Delete the N next (mail) articles.
8571 This command actually deletes articles. This is not a marking
8572 command. The article will disappear forever from you life, never to
8574 If N is negative, delete backwards.
8575 If N is nil and articles have been marked with the process mark,
8576 delete these instead."
8578 (or (gnus-check-backend-function 'request-expire-articles
8579 gnus-newsgroup-name)
8580 (error "The current newsgroup does not support article deletion."))
8581 ;; Compute the list of articles to delete.
8582 (let ((articles (gnus-summary-work-articles n))
8584 (if (and gnus-novice-user
8586 (format "Do you really want to delete %s forever? "
8587 (if (> (length articles) 1) "these articles"
8590 ;; Delete the articles.
8591 (setq not-deleted (gnus-request-expire-articles
8592 articles gnus-newsgroup-name 'force))
8594 (gnus-summary-remove-process-mark (car articles))
8595 ;; The backend might not have been able to delete the article
8597 (or (memq (car articles) not-deleted)
8598 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
8599 (setq articles (cdr articles))))
8600 (gnus-summary-position-cursor)
8603 (defun gnus-summary-edit-article ()
8604 "Enter into a buffer and edit the current article.
8605 This will have permanent effect only in mail groups."
8607 (or (gnus-check-backend-function
8608 'request-replace-article gnus-newsgroup-name)
8609 (error "The current newsgroup does not support article editing."))
8610 (gnus-summary-select-article t)
8611 (gnus-configure-windows 'article)
8612 (select-window (get-buffer-window gnus-article-buffer))
8613 (gnus-message 6 "C-c C-c to end edits")
8614 (setq buffer-read-only nil)
8616 (use-local-map (copy-keymap (current-local-map)))
8617 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8618 (buffer-enable-undo)
8619 (goto-char (point-min))
8620 (search-forward "\n\n" nil t))
8622 (defun gnus-summary-edit-article-done ()
8623 "Make edits to the current article permanent."
8625 (if (not (gnus-request-replace-article
8626 (cdr gnus-article-current) (car gnus-article-current)
8628 (error "Couldn't replace article.")
8630 (use-local-map gnus-article-mode-map)
8631 (setq buffer-read-only t)
8632 (buffer-disable-undo (current-buffer))
8633 (pop-to-buffer gnus-summary-buffer)))
8635 (defun gnus-summary-fancy-query ()
8636 "Query where the fancy respool algorithm would put this article."
8638 (gnus-summary-select-article)
8640 (set-buffer gnus-article-buffer)
8642 (goto-char (point-min))
8643 (search-forward "\n\n")
8644 (narrow-to-region (point-min) (point))
8645 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8647 ;; Summary score commands.
8649 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8651 (defun gnus-summary-raise-score (n)
8652 "Raise the score of the current article by N."
8654 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8656 (defun gnus-summary-lower-score (n)
8657 "Lower the score of the current article by N."
8659 (gnus-summary-raise-score (- n)))
8661 (defun gnus-summary-set-score (n)
8662 "Set the score of the current article to N."
8664 ;; Skip dummy header line.
8666 (gnus-summary-show-thread)
8667 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8669 (let ((buffer-read-only nil))
8671 (gnus-summary-update-mark
8672 (if (= n (or gnus-summary-default-score 0)) ?
8673 (if (< n (or gnus-summary-default-score 0))
8674 gnus-score-below-mark gnus-score-over-mark)) 'score))
8675 (let* ((article (gnus-summary-article-number))
8676 (score (assq article gnus-newsgroup-scored)))
8677 (if score (setcdr score n)
8678 (setq gnus-newsgroup-scored
8679 (cons (cons article n) gnus-newsgroup-scored))))
8680 (gnus-summary-update-line)))
8682 (defun gnus-summary-current-score ()
8683 "Return the score of the current article."
8685 (message "%s" (gnus-summary-article-score)))
8687 ;; Summary marking commands.
8689 (defun gnus-summary-raise-same-subject-and-select (score)
8690 "Raise articles which has the same subject with SCORE and select the next."
8692 (let ((subject (gnus-summary-subject-string)))
8693 (gnus-summary-raise-score score)
8694 (while (gnus-summary-search-subject nil nil subject)
8695 (gnus-summary-raise-score score))
8696 (gnus-summary-next-article t)))
8698 (defun gnus-summary-raise-same-subject (score)
8699 "Raise articles which has the same subject with SCORE."
8701 (let ((subject (gnus-summary-subject-string)))
8702 (gnus-summary-raise-score score)
8703 (while (gnus-summary-search-subject nil nil subject)
8704 (gnus-summary-raise-score score))
8705 (gnus-summary-next-subject 1 t)))
8707 (defun gnus-score-default (level)
8708 (if level (prefix-numeric-value level)
8709 gnus-score-interactive-default-score))
8711 (defun gnus-summary-raise-thread (score)
8712 "Raise the score of the articles in the current thread with SCORE."
8714 (setq score (1- (gnus-score-default score)))
8717 (let ((level (gnus-summary-thread-level)))
8718 (gnus-summary-raise-score score)
8719 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8720 (> (gnus-summary-thread-level) level))
8721 (gnus-summary-raise-score score))
8723 (let ((gnus-summary-check-current t))
8724 (or (zerop (gnus-summary-next-subject 1 t))
8726 (gnus-summary-recenter)
8727 (gnus-summary-position-cursor)
8728 (gnus-set-mode-line 'summary))
8730 (defun gnus-summary-lower-same-subject-and-select (score)
8731 "Raise articles which has the same subject with SCORE and select the next."
8733 (gnus-summary-raise-same-subject-and-select (- score)))
8735 (defun gnus-summary-lower-same-subject (score)
8736 "Raise articles which has the same subject with SCORE."
8738 (gnus-summary-raise-same-subject (- score)))
8740 (defun gnus-summary-lower-thread (score)
8741 "Lower score of articles in the current thread with SCORE."
8743 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8745 (defun gnus-summary-kill-same-subject-and-select (unmark)
8746 "Mark articles which has the same subject as read, and then select the next.
8747 If UNMARK is positive, remove any kind of mark.
8748 If UNMARK is negative, tick articles."
8751 (setq unmark (prefix-numeric-value unmark)))
8753 (gnus-summary-mark-same-subject
8754 (gnus-summary-subject-string) unmark)))
8755 ;; Select next unread article. If auto-select-same mode, should
8756 ;; select the first unread article.
8757 (gnus-summary-next-article t (and gnus-auto-select-same
8758 (gnus-summary-subject-string)))
8759 (gnus-message 7 "%d articles are marked as %s"
8760 count (if unmark "unread" "read"))))
8762 (defun gnus-summary-kill-same-subject (unmark)
8763 "Mark articles which has the same subject as read.
8764 If UNMARK is positive, remove any kind of mark.
8765 If UNMARK is negative, tick articles."
8768 (setq unmark (prefix-numeric-value unmark)))
8770 (gnus-summary-mark-same-subject
8771 (gnus-summary-subject-string) unmark)))
8772 ;; If marked as read, go to next unread subject.
8774 ;; Go to next unread subject.
8775 (gnus-summary-next-subject 1 t))
8776 (gnus-message 7 "%d articles are marked as %s"
8777 count (if unmark "unread" "read"))))
8779 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8780 "Mark articles with same SUBJECT as read, and return marked number.
8781 If optional argument UNMARK is positive, remove any kinds of marks.
8782 If optional argument UNMARK is negative, mark articles as unread instead."
8785 (cond ((null unmark)
8786 (gnus-summary-mark-as-read nil gnus-killed-mark))
8788 (gnus-summary-tick-article nil t))
8790 (gnus-summary-tick-article)))
8792 (gnus-summary-search-forward nil subject))
8793 (cond ((null unmark)
8794 (gnus-summary-mark-as-read nil gnus-killed-mark))
8796 (gnus-summary-tick-article nil t))
8798 (gnus-summary-tick-article)))
8799 (setq count (1+ count))))
8800 ;; Hide killed thread subtrees. Does not work properly always.
8801 ;;(and (null unmark)
8802 ;; gnus-thread-hide-killed
8803 ;; (gnus-summary-hide-thread))
8804 ;; Return number of articles marked as read.
8807 (defun gnus-summary-mark-as-processable (n &optional unmark)
8808 "Set the process mark on the next N articles.
8809 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8810 the process mark instead. The difference between N and the actual
8811 number of articles marked is returned."
8813 (let ((backward (< n 0))
8818 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8819 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8820 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8822 (if (/= 0 n) (gnus-message 7 "No more articles"))
8823 (gnus-summary-recenter)
8824 (gnus-summary-position-cursor)
8827 (defun gnus-summary-unmark-as-processable (n)
8828 "Remove the process mark from the next N articles.
8829 If N is negative, mark backward instead. The difference between N and
8830 the actual number of articles marked is returned."
8832 (gnus-summary-mark-as-processable n t))
8834 (defun gnus-summary-unmark-all-processable ()
8835 "Remove the process mark from all articles."
8838 (while gnus-newsgroup-processable
8839 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8840 (gnus-summary-position-cursor))
8842 (defun gnus-summary-mark-as-expirable (n)
8843 "Mark N articles forward as expirable.
8844 If N is negative, mark backward instead. The difference between N and
8845 the actual number of articles marked is returned."
8847 (gnus-summary-mark-forward n gnus-expirable-mark))
8849 (defun gnus-summary-mark-article-as-replied (article)
8850 "Mark ARTICLE replied and update the summary line."
8851 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8852 (let ((buffer-read-only nil))
8853 (if (gnus-summary-goto-subject article)
8855 (gnus-summary-update-mark gnus-replied-mark 'replied)
8858 (defun gnus-summary-set-bookmark (article)
8859 "Set a bookmark in current article."
8860 (interactive (list (gnus-summary-article-number)))
8861 (if (or (not (get-buffer gnus-article-buffer))
8862 (not gnus-current-article)
8863 (not gnus-article-current)
8864 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8865 (error "No current article selected"))
8866 ;; Remove old bookmark, if one exists.
8867 (let ((old (assq article gnus-newsgroup-bookmarks)))
8868 (if old (setq gnus-newsgroup-bookmarks
8869 (delq old gnus-newsgroup-bookmarks))))
8870 ;; Set the new bookmark, which is on the form
8871 ;; (article-number . line-number-in-body).
8872 (setq gnus-newsgroup-bookmarks
8876 (set-buffer gnus-article-buffer)
8880 (goto-char (point-min))
8881 (search-forward "\n\n" nil t)
8884 gnus-newsgroup-bookmarks))
8885 (gnus-message 6 "A bookmark has been added to the current article."))
8887 (defun gnus-summary-remove-bookmark (article)
8888 "Remove the bookmark from the current article."
8889 (interactive (list (gnus-summary-article-number)))
8890 ;; Remove old bookmark, if one exists.
8891 (let ((old (assq article gnus-newsgroup-bookmarks)))
8894 (setq gnus-newsgroup-bookmarks
8895 (delq old gnus-newsgroup-bookmarks))
8896 (gnus-message 6 "Removed bookmark."))
8897 (gnus-message 6 "No bookmark in current article."))))
8899 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8900 (defun gnus-summary-mark-as-dormant (n)
8901 "Mark N articles forward as dormant.
8902 If N is negative, mark backward instead. The difference between N and
8903 the actual number of articles marked is returned."
8905 (gnus-summary-mark-forward n gnus-dormant-mark))
8907 (defun gnus-summary-set-process-mark (article)
8908 "Set the process mark on ARTICLE and update the summary line."
8909 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8910 (let ((buffer-read-only nil))
8911 (if (gnus-summary-goto-subject article)
8913 (gnus-summary-show-thread)
8914 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8916 (gnus-summary-update-mark gnus-process-mark 'replied)
8919 (defun gnus-summary-remove-process-mark (article)
8920 "Remove the process mark from ARTICLE and update the summary line."
8921 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8922 (let ((buffer-read-only nil))
8923 (if (gnus-summary-goto-subject article)
8925 (gnus-summary-show-thread)
8926 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8928 (gnus-summary-update-mark ? 'replied)
8929 (if (memq article gnus-newsgroup-replied)
8930 (gnus-summary-update-mark gnus-replied-mark 'replied))
8933 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8934 "Mark N articles as read forwards.
8935 If N is negative, mark backwards instead.
8936 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8938 The difference between N and the actual number of articles marked is
8941 (gnus-set-global-variables)
8942 (let ((backward (< n 0))
8944 (mark (or mark gnus-del-mark)))
8946 (gnus-summary-mark-article nil mark no-expire)
8947 (zerop (gnus-summary-next-subject
8948 (if backward -1 1) gnus-summary-goto-unread t)))
8950 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8951 (gnus-summary-recenter)
8952 (gnus-summary-position-cursor)
8953 (gnus-set-mode-line 'summary)
8956 (defun gnus-summary-mark-article (&optional article mark no-expire)
8957 "Mark ARTICLE with MARK.
8958 MARK can be any character.
8959 Five MARK strings are reserved: ? (unread),
8960 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8961 If MARK is nil, then the default character ?D is used.
8962 If ARTICLE is nil, then the article on the current line will be
8964 ;; If no mark is given, then we check auto-expiring.
8965 (and (not no-expire)
8966 gnus-newsgroup-auto-expire
8969 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
8970 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
8971 (= mark gnus-read-mark))))
8972 (setq mark gnus-expirable-mark))
8973 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8974 (article (or article (gnus-summary-article-number))))
8975 (or article (error "No article on current line"))
8976 (if (or (= mark gnus-unread-mark)
8977 (= mark gnus-ticked-mark)
8978 (= mark gnus-dormant-mark))
8979 (gnus-mark-article-as-unread article mark)
8980 (gnus-mark-article-as-read article mark))
8982 ;; See whether the article is to be put in the cache.
8984 (not (= mark gnus-canceled-mark))
8986 (gnus-cache-possibly-enter-article
8987 gnus-newsgroup-name article
8988 (gnus-get-header-by-number article)
8989 (= mark gnus-ticked-mark)
8990 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8992 (if (gnus-summary-goto-subject article)
8993 (let ((buffer-read-only nil))
8994 (gnus-summary-show-thread)
8995 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8998 (gnus-summary-update-mark mark 'unread)
9001 (defun gnus-summary-update-mark (mark type)
9003 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9007 (forward-char forward)
9008 (setq plist (text-properties-at (point)))
9011 (and plist (add-text-properties (1- (point)) (point) plist))
9012 (and (eq type 'unread)
9013 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9014 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9016 (defun gnus-mark-article-as-read (article &optional mark)
9017 "Enter ARTICLE in the pertinent lists and remove it from others."
9018 ;; Make the article expirable.
9019 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
9020 (if (= mark gnus-expirable-mark)
9021 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9022 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9023 ;; Remove from unread and marked lists.
9024 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9025 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9026 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9027 ;; Possibly remove from cache, if that is used.
9028 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9030 (defun gnus-mark-article-as-unread (article &optional mark)
9031 "Enter ARTICLE in the pertinent lists and remove it from others."
9032 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
9033 ;; Add to unread list.
9034 (or (memq article gnus-newsgroup-unreads)
9035 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9036 ;; If CLEAR-MARK is non-nil, the article must be removed from mark
9037 ;; lists. Otherwise, it must be added to the list.
9038 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9039 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9040 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9041 (if (= mark gnus-ticked-mark)
9042 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9043 (if (= mark gnus-dormant-mark)
9044 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9046 (defalias 'gnus-summary-mark-as-unread-forward
9047 'gnus-summary-tick-article-forward)
9048 (make-obsolete 'gnus-summary-mark-as-unread-forward
9049 'gnus-summary-tick-article-forward)
9050 (defun gnus-summary-tick-article-forward (n)
9051 "Tick N articles forwards.
9052 If N is negative, tick backwards instead.
9053 The difference between N and the number of articles ticked is returned."
9055 (gnus-summary-mark-forward n gnus-ticked-mark))
9057 (defalias 'gnus-summary-mark-as-unread-backward
9058 'gnus-summary-tick-article-backward)
9059 (make-obsolete 'gnus-summary-mark-as-unread-backward
9060 'gnus-summary-tick-article-backward)
9061 (defun gnus-summary-tick-article-backward (n)
9062 "Tick N articles backwards.
9063 The difference between N and the number of articles ticked is returned."
9065 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9067 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9068 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9069 (defun gnus-summary-tick-article (&optional article clear-mark)
9070 "Mark current article as unread.
9071 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9072 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9073 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9076 (defun gnus-summary-mark-as-read-forward (n)
9077 "Mark N articles as read forwards.
9078 If N is negative, mark backwards instead.
9079 The difference between N and the actual number of articles marked is
9082 (gnus-summary-mark-forward n gnus-del-mark t))
9084 (defun gnus-summary-mark-as-read-backward (n)
9085 "Mark the N articles as read backwards.
9086 The difference between N and the actual number of articles marked is
9089 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9091 (defun gnus-summary-mark-as-read (&optional article mark)
9092 "Mark current article as read.
9093 ARTICLE specifies the article to be marked as read.
9094 MARK specifies a string to be inserted at the beginning of the line."
9095 (gnus-summary-mark-article article mark))
9097 (defun gnus-summary-clear-mark-forward (n)
9098 "Clear marks from N articles forward.
9099 If N is negative, clear backward instead.
9100 The difference between N and the number of marks cleared is returned."
9102 (gnus-summary-mark-forward n gnus-unread-mark))
9104 (defun gnus-summary-clear-mark-backward (n)
9105 "Clear marks from N articles backward.
9106 The difference between N and the number of marks cleared is returned."
9108 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9110 (defun gnus-summary-mark-unread-as-read ()
9111 "Intended to be used by `gnus-summary-mark-article-hook'."
9112 (or (memq gnus-current-article gnus-newsgroup-marked)
9113 (memq gnus-current-article gnus-newsgroup-dormant)
9114 (memq gnus-current-article gnus-newsgroup-expirable)
9115 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
9117 (defun gnus-summary-mark-region-as-read (point mark all)
9118 "Mark all unread articles between point and mark as read.
9119 If given a prefix, mark all articles between point and mark as read,
9120 even ticked and dormant ones."
9121 (interactive "r\nP")
9131 (not (memq (gnus-summary-article-number)
9132 gnus-newsgroup-marked))
9133 (not (memq (gnus-summary-article-number)
9134 gnus-newsgroup-dormant))))
9135 (gnus-summary-mark-article
9136 (gnus-summary-article-number) gnus-del-mark))
9138 (zerop (forward-line 1))))))
9140 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9141 (defalias 'gnus-summary-delete-marked-as-read
9142 'gnus-summary-remove-lines-marked-as-read)
9143 (make-obsolete 'gnus-summary-delete-marked-as-read
9144 'gnus-summary-remove-lines-marked-as-read)
9145 (defun gnus-summary-remove-lines-marked-as-read ()
9146 "Remove lines that are marked as read."
9148 (gnus-summary-remove-lines-marked-with
9150 (lambda (char) (char-to-string (symbol-value char)))
9151 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9152 gnus-killed-mark gnus-kill-file-mark
9153 gnus-low-score-mark gnus-expirable-mark
9157 (defalias 'gnus-summary-delete-marked-with
9158 'gnus-summary-remove-lines-marked-with)
9159 (make-obsolete 'gnus-summary-delete-marked-with
9160 'gnus-summary-remove-lines-marked-with)
9161 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9162 (defun gnus-summary-remove-lines-marked-with (marks)
9163 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9164 (interactive "sMarks: ")
9165 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9166 (gnus-set-global-variables)
9167 (let ((buffer-read-only nil)
9168 (marks (concat "^[" marks "]")))
9169 (goto-char (point-min))
9170 (if gnus-newsgroup-adaptive
9171 (gnus-score-remove-lines-adaptive marks)
9172 (while (re-search-forward marks nil t)
9173 (gnus-delete-line)))
9174 ;; If we use dummy roots, we have to do an additional sweep over
9176 (if (not (eq gnus-summary-make-false-root 'dummy))
9178 (goto-char (point-min))
9179 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9180 (while (re-search-forward marks nil t)
9181 (if (gnus-subject-equal
9182 (gnus-summary-subject-string)
9185 (gnus-summary-subject-string)))
9188 (gnus-delete-line)))))
9189 (or (zerop (buffer-size))
9191 (gnus-summary-prev-subject 1)
9192 (gnus-summary-position-cursor))))
9194 (defun gnus-summary-expunge-below (score)
9195 "Remove articles with score less than SCORE."
9197 (gnus-set-global-variables)
9198 (setq score (if score
9199 (prefix-numeric-value score)
9200 (or gnus-summary-default-score 0)))
9202 (set-buffer gnus-summary-buffer)
9203 (goto-char (point-min))
9204 (let ((buffer-read-only nil)
9207 (if (< (gnus-summary-article-score) score)
9211 (delete-region beg (point)))
9214 (or (zerop (buffer-size))
9216 (gnus-summary-prev-subject 1)
9217 (gnus-summary-position-cursor))))))
9219 (defun gnus-summary-mark-below (score mark)
9220 "Mark articles with score less than SCORE with MARK."
9221 (interactive "P\ncMark: ")
9222 (gnus-set-global-variables)
9223 (setq score (if score
9224 (prefix-numeric-value score)
9225 (or gnus-summary-default-score 0)))
9227 (set-buffer gnus-summary-buffer)
9228 (goto-char (point-min))
9230 (and (< (gnus-summary-article-score) score)
9231 (gnus-summary-mark-article nil mark))
9234 (defun gnus-summary-kill-below (score)
9235 "Mark articles with score below SCORE as read."
9237 (gnus-summary-mark-below score gnus-killed-mark))
9239 (defun gnus-summary-clear-above (score)
9240 "Clear all marks from articles with score above SCORE."
9242 (gnus-summary-mark-above score gnus-unread-mark))
9244 (defun gnus-summary-tick-above (score)
9245 "Tick all articles with score above SCORE."
9247 (gnus-summary-mark-above score gnus-ticked-mark))
9249 (defun gnus-summary-mark-above (score mark)
9250 "Mark articles with score over SCORE with MARK."
9251 (interactive "P\ncMark: ")
9252 (setq score (if score
9253 (prefix-numeric-value score)
9254 (or gnus-summary-default-score 0)))
9256 (set-buffer gnus-summary-buffer)
9257 (goto-char (point-min))
9259 (if (> (gnus-summary-article-score) score)
9261 (gnus-summary-mark-article nil mark)
9263 (forward-line 1)))))
9265 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9266 (defun gnus-summary-show-all-expunged ()
9267 "Display all the hidden articles that were expunged for low scores."
9269 (let ((buffer-read-only nil))
9270 (let ((scored gnus-newsgroup-scored)
9273 (or (gnus-summary-goto-subject (car (car scored)))
9274 (and (setq h (gnus-get-header-by-number (car (car scored))))
9275 (< (cdr (car scored)) gnus-summary-expunge-below)
9276 (setq headers (cons h headers))))
9277 (setq scored (cdr scored)))
9278 (or headers (error "No expunged articles hidden."))
9279 (goto-char (point-min))
9281 (gnus-summary-update-lines
9284 (gnus-summary-prepare-threads (nreverse headers) 0)
9286 (goto-char (point-min))
9287 (gnus-summary-position-cursor)))
9289 (defun gnus-summary-show-all-dormant ()
9290 "Display all the hidden articles that are marked as dormant."
9292 (let ((buffer-read-only nil))
9293 (let ((dormant gnus-newsgroup-dormant)
9296 (or (gnus-summary-goto-subject (car dormant))
9297 (and (setq h (gnus-get-header-by-number (car dormant)))
9298 (setq headers (cons h headers))))
9299 (setq dormant (cdr dormant)))
9300 (or headers (error "No dormant articles hidden."))
9301 (goto-char (point-min))
9303 (gnus-summary-update-lines
9306 (gnus-summary-prepare-threads (nreverse headers) 0)
9308 (goto-char (point-min))
9309 (gnus-summary-position-cursor)))
9311 (defun gnus-summary-hide-all-dormant ()
9312 "Hide all dormant articles."
9314 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9315 (gnus-summary-position-cursor))
9317 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
9318 "Mark all articles not marked as unread in this newsgroup as read.
9319 If prefix argument ALL is non-nil, all articles are marked as read.
9320 If QUIETLY is non-nil, no questions will be asked.
9321 If TO-HERE is non-nil, it should be a point in the buffer. All
9322 articles before this point will be marked as read.
9323 The number of articles marked as read is returned."
9327 (not gnus-interactive-catchup) ;Without confirmation?
9331 "Mark absolutely all articles as read? "
9332 "Mark all unread articles as read? ")))
9334 (not gnus-newsgroup-adaptive)
9335 (not gnus-newsgroup-auto-expire))
9337 (and all (setq gnus-newsgroup-marked nil
9338 gnus-newsgroup-dormant nil))
9339 (setq gnus-newsgroup-unreads
9340 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9341 ;; We actually mark all articles as canceled, which we
9342 ;; have to do when using auto-expiry or adaptive scoring.
9343 (let ((unreads (length gnus-newsgroup-unreads)))
9344 (if (gnus-summary-first-subject (not all))
9345 (while (and (if to-here (< (point) to-here) t)
9346 (gnus-summary-mark-as-read nil gnus-catchup-mark)
9347 (gnus-summary-search-subject nil (not all)))))
9348 (- unreads (length gnus-newsgroup-unreads))
9350 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9351 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9352 (if (and (not to-here) (eq 'nnvirtual (car method)))
9353 (nnvirtual-catchup-group
9354 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9355 (gnus-summary-position-cursor)))
9357 (defun gnus-summary-catchup-to-here (&optional all)
9358 "Mark all unticked articles before the current one as read.
9359 If ALL is non-nil, also mark ticked and dormant articles as read."
9362 (and (zerop (forward-line -1))
9365 (gnus-summary-catchup all t (point))
9366 (gnus-set-mode-line 'summary))))
9367 (gnus-summary-position-cursor))
9369 (defun gnus-summary-catchup-all (&optional quietly)
9370 "Mark all articles in this newsgroup as read."
9372 (gnus-summary-catchup t quietly))
9374 (defun gnus-summary-catchup-and-exit (all &optional quietly)
9375 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9376 If prefix argument ALL is non-nil, all articles are marked as read."
9378 (gnus-summary-catchup all quietly nil 'fast)
9379 ;; Select next newsgroup or exit.
9380 (if (eq gnus-auto-select-next 'quietly)
9381 (gnus-summary-next-group nil)
9382 (gnus-summary-exit)))
9384 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9385 "Mark all articles in this newsgroup as read, and then exit."
9387 (gnus-summary-catchup-and-exit t quietly))
9389 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9390 (defun gnus-summary-catchup-and-goto-next-group (all)
9391 "Mark all articles in this group as read and select the next group.
9392 If given a prefix, mark all articles, unread as well as ticked, as
9395 (gnus-summary-catchup all)
9396 (gnus-summary-next-group))
9398 ;; Thread-based commands.
9400 (defun gnus-summary-toggle-threads (arg)
9401 "Toggle showing conversation threads.
9402 If ARG is positive number, turn showing conversation threads on."
9404 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9405 (setq gnus-show-threads
9406 (if (null arg) (not gnus-show-threads)
9407 (> (prefix-numeric-value arg) 0)))
9408 (gnus-summary-prepare)
9409 (gnus-summary-goto-subject current)
9410 (gnus-summary-position-cursor)))
9412 (defun gnus-summary-show-all-threads ()
9416 (let ((buffer-read-only nil))
9417 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9418 (gnus-summary-position-cursor))
9420 (defun gnus-summary-show-thread ()
9421 "Show thread subtrees.
9422 Returns nil if no thread was there to be shown."
9426 (let ((buffer-read-only nil)
9427 ;; first goto end then to beg, to have point at beg after let
9428 (end (progn (end-of-line) (point)))
9429 (beg (progn (beginning-of-line) (point))))
9431 ;; Any hidden lines here?
9432 (search-forward "\r" end t)
9433 (subst-char-in-region beg end ?\^M ?\n t))))
9434 (gnus-summary-position-cursor)))
9436 (defun gnus-summary-hide-all-threads ()
9437 "Hide all thread subtrees."
9440 (goto-char (point-min))
9441 (gnus-summary-hide-thread)
9442 (while (and (not (eobp)) (zerop (forward-line 1)))
9443 (gnus-summary-hide-thread)))
9444 (gnus-summary-position-cursor))
9446 (defun gnus-summary-hide-thread ()
9447 "Hide thread subtrees.
9448 Returns nil if no threads were there to be hidden."
9450 (let ((buffer-read-only nil)
9452 (level (gnus-summary-thread-level))
9454 ;; Go forward until either the buffer ends or the subthread
9458 (while (and (zerop (forward-line 1))
9459 (> (gnus-summary-thread-level) level))
9464 (search-backward "\n" start t))
9465 (subst-char-in-region start end ?\n ?\^M t)
9466 (forward-line -1)))))
9468 (defun gnus-summary-go-to-next-thread (&optional previous)
9469 "Go to the same level (or less) next thread.
9470 If PREVIOUS is non-nil, go to previous thread instead.
9471 Return the article number moved to, or nil if moving was impossible."
9472 (let ((level (gnus-summary-thread-level))
9473 (article (gnus-summary-article-number)))
9475 (while (and (zerop (forward-line -1))
9476 (> (gnus-summary-thread-level) level)))
9477 (while (and (save-excursion
9480 (zerop (forward-line 1))
9481 (> (gnus-summary-thread-level) level))))
9482 (gnus-summary-recenter)
9483 (gnus-summary-position-cursor)
9484 (let ((oart (gnus-summary-article-number)))
9485 (and (/= oart article) oart))))
9487 (defun gnus-summary-next-thread (n)
9488 "Go to the same level next N'th thread.
9489 If N is negative, search backward instead.
9490 Returns the difference between N and the number of skips actually
9493 (let ((backward (< n 0))
9496 (gnus-summary-go-to-next-thread backward))
9498 (gnus-summary-position-cursor)
9499 (if (/= 0 n) (gnus-message 7 "No more threads"))
9502 (defun gnus-summary-prev-thread (n)
9503 "Go to the same level previous N'th thread.
9504 Returns the difference between N and the number of skips actually
9507 (gnus-summary-next-thread (- n)))
9509 (defun gnus-summary-go-down-thread (&optional same)
9510 "Go down one level in the current thread.
9511 If SAME is non-nil, also move to articles of the same level."
9512 (let ((level (gnus-summary-thread-level))
9514 (if (and (zerop (forward-line 1))
9515 (> (gnus-summary-thread-level) level))
9520 (defun gnus-summary-go-up-thread ()
9521 "Go up one level in the current thread."
9522 (let ((level (gnus-summary-thread-level))
9524 (while (and (zerop (forward-line -1))
9525 (>= (gnus-summary-thread-level) level)))
9526 (if (>= (gnus-summary-thread-level) level)
9532 (defun gnus-summary-down-thread (n)
9533 "Go down thread N steps.
9534 If N is negative, go up instead.
9535 Returns the difference between N and how many steps down that were
9541 (if up (gnus-summary-go-up-thread)
9542 (gnus-summary-go-down-thread)))
9544 (gnus-summary-position-cursor)
9545 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9548 (defun gnus-summary-up-thread (n)
9549 "Go up thread N steps.
9550 If N is negative, go up instead.
9551 Returns the difference between N and how many steps down that were
9554 (gnus-summary-down-thread (- n)))
9556 (defun gnus-summary-kill-thread (unmark)
9557 "Mark articles under current thread as read.
9558 If the prefix argument is positive, remove any kinds of marks.
9559 If the prefix argument is negative, tick articles instead."
9562 (setq unmark (prefix-numeric-value unmark)))
9564 (level (gnus-summary-thread-level)))
9567 ;; Mark the article...
9568 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
9569 ((> unmark 0) (gnus-summary-tick-article nil t))
9570 (t (gnus-summary-tick-article)))
9571 ;; ...and go forward until either the buffer ends or the subtree
9573 (if (not (and (zerop (forward-line 1))
9574 (> (gnus-summary-thread-level) level)))
9575 (setq killing nil))))
9576 ;; Hide killed subtrees.
9578 gnus-thread-hide-killed
9579 (gnus-summary-hide-thread))
9580 ;; If marked as read, go to next unread subject.
9582 ;; Go to next unread subject.
9583 (gnus-summary-next-subject 1 t)))
9584 (gnus-set-mode-line 'summary))
9586 ;; Summary sorting commands
9588 (defun gnus-summary-sort-by-number (&optional reverse)
9589 "Sort summary buffer by article number.
9590 Argument REVERSE means reverse order."
9593 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9595 (defun gnus-summary-sort-by-author (&optional reverse)
9596 "Sort summary buffer by author name alphabetically.
9597 If case-fold-search is non-nil, case of letters is ignored.
9598 Argument REVERSE means reverse order."
9603 (let ((extract (funcall
9604 gnus-extract-address-components
9605 (header-from (gnus-get-header-by-number
9606 (gnus-summary-article-number))))))
9607 (or (car extract) (cdr extract))))
9608 'gnus-thread-sort-by-author)
9611 (defun gnus-summary-sort-by-subject (&optional reverse)
9612 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9613 If case-fold-search is non-nil, case of letters is ignored.
9614 Argument REVERSE means reverse order."
9619 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9620 'gnus-thread-sort-by-subject)
9623 (defun gnus-summary-sort-by-date (&optional reverse)
9624 "Sort summary buffer by date.
9625 Argument REVERSE means reverse order."
9632 (gnus-get-header-by-number (gnus-summary-article-number)))))
9633 'gnus-thread-sort-by-date)
9636 (defun gnus-summary-sort-by-score (&optional reverse)
9637 "Sort summary buffer by score.
9638 Argument REVERSE means reverse order."
9641 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9644 (defvar gnus-summary-already-sorted nil)
9645 (defun gnus-summary-sort (predicate reverse)
9646 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9647 (if gnus-summary-already-sorted
9649 (let (buffer-read-only)
9650 (if (not gnus-show-threads)
9652 (goto-char (point-min))
9653 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9654 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9655 (gnus-summary-prepare-hook nil)
9656 (gnus-summary-already-sorted nil))
9657 (gnus-summary-prepare)
9658 (and gnus-show-threads
9659 gnus-thread-hide-subtree
9660 (gnus-summary-hide-all-threads))
9661 ;; If in async mode, we send some info to the backend.
9662 (and gnus-newsgroup-async
9663 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
9664 (gnus-request-asynchronous
9666 (if (and gnus-asynchronous-article-function
9667 (fboundp gnus-asynchronous-article-function))
9668 (funcall gnus-asynchronous-article-function
9669 gnus-newsgroup-threads)))))))))
9672 (defun gnus-sortable-date (date)
9673 "Make sortable string by string-lessp from DATE.
9674 Timezone package is used."
9675 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9676 (year (aref date 0))
9677 (month (aref date 1))
9678 (day (aref date 2)))
9679 (timezone-make-sortable-date
9681 (timezone-make-time-string
9682 (aref date 3) (aref date 4) (aref date 5)))))
9685 ;; Summary saving commands.
9687 (defun gnus-summary-save-article (n)
9688 "Save the current article using the default saver function.
9689 If N is a positive number, save the N next articles.
9690 If N is a negative number, save the N previous articles.
9691 If N is nil and any articles have been marked with the process mark,
9692 save those articles instead.
9693 The variable `gnus-default-article-saver' specifies the saver function."
9695 (let ((articles (gnus-summary-work-articles n)))
9697 (let ((header (gnus-get-header-by-number (car articles))))
9698 (if (vectorp header)
9700 (gnus-summary-select-article t nil nil (car articles))
9701 (or gnus-save-all-headers
9702 (gnus-article-hide-headers t))
9703 ;; Remove any X-Gnus lines.
9706 (set-buffer gnus-article-buffer)
9707 (let ((buffer-read-only nil))
9708 (goto-char (point-min))
9709 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9711 (while (re-search-forward "^X-Gnus" nil t)
9713 (delete-region (point)
9714 (progn (forward-line 1) (point))))
9717 (if gnus-default-article-saver
9718 (funcall gnus-default-article-saver)
9719 (error "No default saver is defined."))))
9720 (if (assq 'name header)
9721 (gnus-copy-file (cdr (assq 'name header)))
9722 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9723 (gnus-summary-remove-process-mark (car articles))
9724 (setq articles (cdr articles)))
9725 (gnus-summary-position-cursor)
9728 (defun gnus-summary-pipe-output (arg)
9729 "Pipe the current article to a subprocess.
9730 If N is a positive number, pipe the N next articles.
9731 If N is a negative number, pipe the N previous articles.
9732 If N is nil and any articles have been marked with the process mark,
9733 pipe those articles instead."
9735 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9736 (gnus-summary-save-article arg)))
9738 (defun gnus-summary-save-article-mail (arg)
9739 "Append the current article to an mail file.
9740 If N is a positive number, save the N next articles.
9741 If N is a negative number, save the N previous articles.
9742 If N is nil and any articles have been marked with the process mark,
9743 save those articles instead."
9745 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9746 (gnus-summary-save-article arg)))
9748 (defun gnus-summary-save-article-rmail (arg)
9749 "Append the current article to an rmail file.
9750 If N is a positive number, save the N next articles.
9751 If N is a negative number, save the N previous articles.
9752 If N is nil and any articles have been marked with the process mark,
9753 save those articles instead."
9755 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9756 (gnus-summary-save-article arg)))
9758 (defun gnus-summary-save-article-file (arg)
9759 "Append the current article to a file.
9760 If N is a positive number, save the N next articles.
9761 If N is a negative number, save the N previous articles.
9762 If N is nil and any articles have been marked with the process mark,
9763 save those articles instead."
9765 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9766 (gnus-summary-save-article arg)))
9768 (defun gnus-read-save-file-name (prompt default-name)
9769 (let ((methods gnus-split-methods)
9771 (if (not gnus-split-methods)
9774 (set-buffer gnus-article-buffer)
9775 (gnus-narrow-to-headers)
9777 (goto-char (point-min))
9778 (and (condition-case ()
9779 (re-search-forward (car (car methods)) nil t)
9781 (setq split-name (cons (nth 1 (car methods)) split-name)))
9782 (setq methods (cdr methods)))
9784 (cond ((null split-name)
9786 (concat prompt " (default "
9787 (file-name-nondirectory default-name) ") ")
9788 (file-name-directory default-name)
9790 ((= 1 (length split-name))
9792 (concat prompt " (default " (car split-name) ") ")
9793 gnus-article-save-directory
9794 (concat gnus-article-save-directory (car split-name))))
9796 (setq split-name (mapcar (lambda (el) (list el))
9797 (nreverse split-name)))
9798 (let ((result (completing-read
9800 split-name nil nil)))
9801 (concat gnus-article-save-directory
9802 (if (string= result "")
9803 (car (car split-name))
9806 (defun gnus-summary-save-in-rmail (&optional filename)
9807 "Append this article to Rmail file.
9808 Optional argument FILENAME specifies file name.
9809 Directory to save to is default to `gnus-article-save-directory' which
9810 is initialized from the SAVEDIR environment variable."
9813 (funcall gnus-rmail-save-name gnus-newsgroup-name
9814 gnus-current-headers gnus-newsgroup-last-rmail)))
9816 (setq filename (gnus-read-save-file-name
9817 "Save in rmail file:" default-name)))
9818 (gnus-make-directory (file-name-directory filename))
9819 (gnus-eval-in-buffer-window
9824 (gnus-output-to-rmail filename))))
9825 ;; Remember the directory name to save articles.
9826 (setq gnus-newsgroup-last-rmail filename)))
9828 (defun gnus-summary-save-in-mail (&optional filename)
9829 "Append this article to Unix mail file.
9830 Optional argument FILENAME specifies file name.
9831 Directory to save to is default to `gnus-article-save-directory' which
9832 is initialized from the SAVEDIR environment variable."
9835 (funcall gnus-mail-save-name gnus-newsgroup-name
9836 gnus-current-headers gnus-newsgroup-last-mail)))
9838 (setq filename (gnus-read-save-file-name
9839 "Save in Unix mail file:" default-name)))
9841 (expand-file-name filename
9843 (file-name-directory default-name))))
9844 (gnus-make-directory (file-name-directory filename))
9845 (gnus-eval-in-buffer-window
9850 (if (and (file-readable-p filename) (rmail-file-p filename))
9851 (gnus-output-to-rmail filename)
9852 (rmail-output filename 1 t t)))))
9853 ;; Remember the directory name to save articles.
9854 (setq gnus-newsgroup-last-mail filename)))
9856 (defun gnus-summary-save-in-file (&optional filename)
9857 "Append this article to file.
9858 Optional argument FILENAME specifies file name.
9859 Directory to save to is default to `gnus-article-save-directory' which
9860 is initialized from the SAVEDIR environment variable."
9863 (funcall gnus-file-save-name gnus-newsgroup-name
9864 gnus-current-headers gnus-newsgroup-last-file)))
9866 (setq filename (gnus-read-save-file-name
9867 "Save in file:" default-name)))
9868 (gnus-make-directory (file-name-directory filename))
9869 (gnus-eval-in-buffer-window
9874 (gnus-output-to-file filename))))
9875 ;; Remember the directory name to save articles.
9876 (setq gnus-newsgroup-last-file filename)))
9878 (defun gnus-summary-save-in-pipe (&optional command)
9879 "Pipe this article to subprocess."
9881 (let ((command (read-string "Shell command on article: "
9882 gnus-last-shell-command)))
9883 (if (string-equal command "")
9884 (setq command gnus-last-shell-command))
9885 (gnus-eval-in-buffer-window
9889 (shell-command-on-region (point-min) (point-max) command nil)))
9890 (setq gnus-last-shell-command command)))
9892 ;; Summary extract commands
9894 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9895 (let ((buffer-read-only nil)
9896 (article (gnus-summary-article-number))
9898 (or (gnus-summary-goto-subject article)
9899 (error (format "No such article: %d" article)))
9900 (or gnus-newsgroup-headers-hashtb-by-number
9901 (gnus-make-headers-hashtable-by-number))
9902 (gnus-summary-position-cursor)
9903 ;; If all commands are to be bunched up on one line, we collect
9905 (if gnus-view-pseudos-separately
9907 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9910 (setq action (cdr (assq 'action (car ps))))
9911 (setq files (list (cdr (assq 'name (car ps)))))
9912 (while (and ps (cdr ps)
9913 (string= (or action "1")
9914 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9915 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9916 (setcdr ps (cdr (cdr ps))))
9919 (if (not (string-match "%s" action))
9920 (setq files (cons " " files)))
9921 (setq files (cons " " files))
9922 (and (assq 'execute (car ps))
9923 (setcdr (assq 'execute (car ps))
9924 (funcall (if (string-match "%s" action)
9927 (mapconcat (lambda (f) f) files " ")))))
9928 (setq ps (cdr ps)))))
9929 (if (and gnus-view-pseudos (not not-view))
9931 (and (assq 'execute (car pslist))
9932 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9933 (eq gnus-view-pseudos 'not-confirm)))
9934 (setq pslist (cdr pslist)))
9937 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9938 (gnus-summary-article-number)))
9941 (insert " " (file-name-nondirectory
9942 (cdr (assq 'name (car pslist))))
9943 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9944 (add-text-properties
9945 b (1+ b) (list 'gnus-number gnus-reffed-article-number
9946 'gnus-mark gnus-unread-mark
9948 'gnus-pseudo (car pslist)))
9950 (gnus-sethash (int-to-string gnus-reffed-article-number)
9951 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9952 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9953 (setq pslist (cdr pslist)))))))
9955 (defun gnus-pseudos< (p1 p2)
9956 (let ((c1 (cdr (assq 'action p1)))
9957 (c2 (cdr (assq 'action p2))))
9958 (and c1 c2 (string< c1 c2))))
9960 (defun gnus-request-pseudo-article (props)
9961 (cond ((assq 'execute props)
9962 (gnus-execute-command (cdr (assq 'execute props)))))
9963 (let ((gnus-current-article (gnus-summary-article-number)))
9964 (run-hooks 'gnus-mark-article-hook)))
9966 (defun gnus-execute-command (command &optional automatic)
9968 (gnus-article-setup-buffer)
9969 (set-buffer gnus-article-buffer)
9970 (let ((command (if automatic command (read-string "Command: " command)))
9971 (buffer-read-only nil))
9973 (insert "$ " command "\n\n")
9974 (if gnus-view-pseudo-asynchronously
9975 (start-process "gnus-execute" nil "sh" "-c" command)
9976 (call-process "sh" nil t nil "-c" command)))))
9978 (defun gnus-copy-file (file &optional to)
9981 (list (read-file-name "Copy file: " default-directory)
9982 (read-file-name "Copy file to: " default-directory)))
9983 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9984 (and (file-directory-p to)
9985 (setq to (concat (file-name-as-directory to)
9986 (file-name-nondirectory file))))
9987 (copy-file file to))
9989 ;; Summary kill commands.
9991 (defun gnus-summary-edit-global-kill (article)
9992 "Edit the \"global\" kill file."
9993 (interactive (list (gnus-summary-article-number)))
9994 (gnus-group-edit-global-kill article))
9996 (defun gnus-summary-edit-local-kill ()
9997 "Edit a local kill file applied to the current newsgroup."
9999 (setq gnus-current-headers
10001 (int-to-string (gnus-summary-article-number))
10002 gnus-newsgroup-headers-hashtb-by-number))
10003 (gnus-set-global-variables)
10004 (gnus-group-edit-local-kill
10005 (gnus-summary-article-number) gnus-newsgroup-name))
10009 ;;; Gnus article mode
10012 (put 'gnus-article-mode 'mode-class 'special)
10014 (if gnus-article-mode-map
10016 (setq gnus-article-mode-map (make-keymap))
10017 (suppress-keymap gnus-article-mode-map)
10018 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10019 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10020 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10021 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10022 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10023 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10024 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10025 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10026 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10027 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10028 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10029 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10031 ;; Duplicate almost all summary keystrokes in the article mode map.
10034 " " "\177" "n" "p" "N" "P" "\M-\C-n" "\M-\C-p"
10035 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j" "^" "\M-^"
10036 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10037 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10038 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10039 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10040 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10041 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10042 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10043 "\C-c\C-i" "x" "X" "s" "t" "g" "?" "l"
10044 "\C-c\C-v\C-v" "\C-d" "v"
10045 ;; "Mt" "M!" "Md" "Mr"
10046 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10047 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10048 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10049 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10050 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10051 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10052 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10053 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10054 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10055 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10056 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10059 (define-key gnus-article-mode-map (car commands)
10060 'gnus-article-summary-command)
10061 (setq commands (cdr commands))))
10063 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10064 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10067 (define-key gnus-article-mode-map (car commands)
10068 'gnus-article-summary-command-nosave)
10069 (setq commands (cdr commands)))))
10072 (defun gnus-article-mode ()
10073 "Major mode for displaying an article.
10075 All normal editing commands are switched off.
10077 The following commands are available:
10079 \\<gnus-article-mode-map>
10080 \\[gnus-article-next-page]\t Scroll the article one page forwards
10081 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10082 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10083 \\[gnus-article-show-summary]\t Display the summary buffer
10084 \\[gnus-article-mail]\t Send a reply to the address near point
10085 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10086 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10087 \\[gnus-info-find-node]\t Go to the Gnus info node"
10089 (if gnus-visual (gnus-article-make-menu-bar))
10090 (kill-all-local-variables)
10091 (setq mode-line-modified "-- ")
10092 (make-local-variable 'mode-line-format)
10093 (setq mode-line-format (copy-sequence mode-line-format))
10094 (and (equal (nth 3 mode-line-format) " ")
10095 (setcar (nthcdr 3 mode-line-format) ""))
10096 (setq mode-name "Article")
10097 (setq major-mode 'gnus-article-mode)
10098 (make-local-variable 'minor-mode-alist)
10099 (or (assq 'gnus-show-mime minor-mode-alist)
10100 (setq minor-mode-alist
10101 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10102 (use-local-map gnus-article-mode-map)
10103 (make-local-variable 'page-delimiter)
10104 (setq page-delimiter gnus-page-delimiter)
10105 (buffer-disable-undo (current-buffer))
10106 (setq buffer-read-only t) ;Disable modification
10107 (run-hooks 'gnus-article-mode-hook))
10109 (defun gnus-article-setup-buffer ()
10110 "Initialize article mode buffer."
10111 (if (get-buffer gnus-article-buffer)
10113 (set-buffer gnus-article-buffer)
10114 (buffer-disable-undo (current-buffer))
10115 (setq buffer-read-only t)
10116 (gnus-add-current-to-buffer-list)
10117 (or (eq major-mode 'gnus-article-mode)
10118 (gnus-article-mode)))
10120 (set-buffer (get-buffer-create gnus-article-buffer))
10121 (gnus-add-current-to-buffer-list)
10122 (gnus-article-mode))))
10124 ;; Set article window start at LINE, where LINE is the number of lines
10125 ;; from the head of the article.
10126 (defun gnus-article-set-window-start (&optional line)
10128 (get-buffer-window gnus-article-buffer)
10130 (set-buffer gnus-article-buffer)
10131 (goto-char (point-min))
10134 (gnus-message 6 "Moved to bookmark")
10135 (search-forward "\n\n" nil t)
10136 (forward-line line)
10139 (defun gnus-request-article-this-buffer (article group)
10140 "Get an article and insert it into this buffer."
10141 (setq group (or group gnus-newsgroup-name))
10143 ;; Open server if it has closed.
10144 (gnus-check-news-server (gnus-find-method-for-group group))
10146 ;; Using `gnus-request-article' directly will insert the article into
10147 ;; `nntp-server-buffer' - so we'll save some time by not having to
10148 ;; copy it from the server buffer into the article buffer.
10150 ;; We only request an article by message-id when we do not have the
10151 ;; headers for it, so we'll have to get those.
10152 (and (stringp article)
10153 (let ((gnus-override-method gnus-refer-article-method))
10154 (gnus-read-header article)))
10156 ;; If the article number is negative, that means that this article
10157 ;; doesn't belong in this newsgroup (possibly), so we find its
10158 ;; message-id and request it by id instead of number.
10159 (if (not (numberp article))
10162 (set-buffer gnus-summary-buffer)
10163 (let ((header (gnus-get-header-by-number article)))
10165 (if (vectorp header)
10166 ;; It's a real article.
10167 (setq article (header-id header))
10168 ;; It is an extracted pseudo-article.
10169 (setq article 'pseudo)
10170 (gnus-request-pseudo-article header)))
10172 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10173 (if (not (eq (car method) 'nneething))
10175 (let ((dir (concat (file-name-as-directory (nth 1 method))
10176 (header-subject header))))
10177 (if (file-directory-p dir)
10179 (setq article 'nneething)
10180 (gnus-group-enter-directory dir)))))))))
10182 ;; Check the cache.
10183 (if (and gnus-use-cache
10185 (gnus-cache-request-article article group))
10187 ;; Get the article and into the article buffer.
10188 (if (or (stringp article) (numberp article))
10191 (let ((gnus-override-method
10192 (and (stringp article) gnus-refer-article-method)))
10193 (and (gnus-request-article article group (current-buffer))
10197 (defun gnus-read-header (id)
10198 "Read the headers of article ID and enter them into the Gnus system."
10199 (or gnus-newsgroup-headers-hashtb-by-number
10200 (gnus-make-headers-hashtable-by-number))
10202 (if (not (setq header
10203 (car (if (let ((gnus-nov-is-evil t))
10204 (gnus-retrieve-headers
10205 (list id) gnus-newsgroup-name))
10206 (gnus-get-newsgroup-headers)))))
10209 (header-set-number header gnus-reffed-article-number))
10210 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10211 (gnus-sethash (int-to-string (header-number header)) header
10212 gnus-newsgroup-headers-hashtb-by-number)
10214 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10215 (setq gnus-current-headers header)
10218 (defun gnus-article-prepare (article &optional all-headers header)
10219 "Prepare ARTICLE in article mode buffer.
10220 ARTICLE should either be an article number or a Message-ID.
10221 If ARTICLE is an id, HEADER should be the article headers.
10222 If ALL-HEADERS is non-nil, no headers are hidden."
10224 ;; Make sure we start in a summary buffer.
10225 (or (eq major-mode 'gnus-summary-mode)
10226 (set-buffer gnus-summary-buffer))
10227 (setq gnus-summary-buffer (current-buffer))
10228 ;; Make sure the connection to the server is alive.
10229 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10231 (gnus-check-news-server
10232 (gnus-find-method-for-group gnus-newsgroup-name))
10233 (gnus-request-group gnus-newsgroup-name t)))
10234 (or gnus-newsgroup-headers-hashtb-by-number
10235 (gnus-make-headers-hashtable-by-number))
10236 (let* ((article (if header (header-number header) article))
10237 (summary-buffer (current-buffer))
10238 (internal-hook gnus-article-internal-prepare-hook)
10239 (group gnus-newsgroup-name)
10242 (gnus-article-setup-buffer)
10243 (set-buffer gnus-article-buffer)
10244 (if (not (setq result (let ((buffer-read-only nil))
10245 (gnus-request-article-this-buffer
10247 ;; There is no such article.
10249 (if (not (numberp article))
10251 (setq gnus-article-current
10252 (cons gnus-newsgroup-name article))
10253 (set-buffer gnus-summary-buffer)
10254 (setq gnus-current-article article)
10255 (gnus-summary-mark-as-read article gnus-canceled-mark))
10256 (gnus-message 1 "No such article (may be canceled)")
10259 (if (or (eq result 'pseudo) (eq result 'nneething))
10262 (set-buffer summary-buffer)
10263 (setq gnus-last-article gnus-current-article
10264 gnus-newsgroup-history (cons gnus-current-article
10265 gnus-newsgroup-history)
10266 gnus-current-article 0
10267 gnus-current-headers nil
10268 gnus-article-current nil)
10269 (if (eq result 'nneething)
10270 (gnus-configure-windows 'summary)
10271 (gnus-configure-windows 'article))
10272 (gnus-set-global-variables))
10273 (gnus-set-mode-line 'article))
10274 ;; The result from the `request' was an actual article -
10275 ;; or at least some text that is now displayed in the
10277 (if (and (numberp article)
10278 (not (eq article gnus-current-article)))
10279 ;; Seems like a new article has been selected.
10280 ;; `gnus-current-article' must be an article number.
10282 (set-buffer summary-buffer)
10283 (setq gnus-last-article gnus-current-article
10284 gnus-newsgroup-history (cons gnus-current-article
10285 gnus-newsgroup-history)
10286 gnus-current-article article
10287 gnus-current-headers
10288 (gnus-get-header-by-number gnus-current-article)
10289 gnus-article-current
10290 (cons gnus-newsgroup-name gnus-current-article))
10291 (gnus-summary-show-thread)
10292 (run-hooks 'gnus-mark-article-hook)
10293 (gnus-set-mode-line 'summary)
10295 (run-hooks 'gnus-visual-mark-article-hook))
10296 ;; Set the global newsgroup variables here.
10297 ;; Suggested by Jim Sisolak
10298 ;; <sisolak@trans4.neep.wisc.edu>.
10299 (gnus-set-global-variables)
10300 (setq gnus-have-all-headers
10301 (or all-headers gnus-show-all-headers))
10302 (and gnus-use-cache
10303 (gnus-cache-possibly-enter-article
10305 (gnus-get-header-by-number article)
10306 (memq article gnus-newsgroup-marked)
10307 (memq article gnus-newsgroup-dormant)
10308 (memq article gnus-newsgroup-unreads)))))
10309 ;; Hooks for getting information from the article.
10310 ;; This hook must be called before being narrowed.
10311 (let (buffer-read-only)
10312 (run-hooks 'internal-hook)
10313 (run-hooks 'gnus-article-prepare-hook)
10314 ;; Decode MIME message.
10315 (if (and gnus-show-mime
10316 (or (not gnus-strict-mime)
10317 (gnus-fetch-field "Mime-Version")))
10318 (funcall gnus-show-mime-method))
10319 ;; Perform the article display hooks.
10320 (run-hooks 'gnus-article-display-hook))
10322 (goto-char (point-min))
10323 (and gnus-break-pages (gnus-narrow-to-page))
10324 (gnus-set-mode-line 'article)
10325 (gnus-configure-windows 'article)
10326 (goto-char (point-min))
10329 (defun gnus-article-show-all-headers ()
10330 "Show all article headers in article mode buffer."
10332 (gnus-article-setup-buffer)
10333 (set-buffer gnus-article-buffer)
10334 (let ((buffer-read-only nil))
10335 (remove-text-properties (point-min) (point-max)
10336 gnus-hidden-properties))))
10338 (defun gnus-article-hide-headers-if-wanted ()
10339 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10340 Provided for backwards compatability."
10341 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10342 (gnus-article-hide-headers)))
10344 (defun gnus-article-hide-headers (&optional delete)
10345 "Hide unwanted headers and possibly sort them as well."
10348 (set-buffer gnus-article-buffer)
10350 (let ((sorted gnus-sorted-header-list)
10351 (buffer-read-only nil)
10352 want-list beg want-l)
10353 ;; First we narrow to just the headers.
10355 (goto-char (point-min))
10356 ;; Hide any "From " lines at the beginning of (mail) articles.
10357 (while (looking-at "From ")
10360 (add-text-properties (point-min) (point) gnus-hidden-properties))
10361 ;; Then treat the rest of the header lines.
10364 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10365 ;; Then we use the two regular expressions
10366 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10367 ;; select which header lines is to remain visible in the
10369 (goto-char (point-min))
10370 (while (re-search-forward "^[^ \t]*:" nil t)
10371 (beginning-of-line)
10372 ;; We add the headers we want to keep to a list and delete
10373 ;; them from the buffer.
10374 (if (or (and (stringp gnus-visible-headers)
10375 (looking-at gnus-visible-headers))
10376 (and (not (stringp gnus-visible-headers))
10377 (stringp gnus-ignored-headers)
10378 (not (looking-at gnus-ignored-headers))))
10382 ;; Be sure to get multi-line headers...
10383 (re-search-forward "^[^ \t]*:" nil t)
10384 (beginning-of-line)
10386 (cons (buffer-substring beg (point)) want-list))
10387 (delete-region beg (point))
10390 ;; Next we perform the sorting by looking at
10391 ;; `gnus-sorted-header-list'.
10392 (goto-char (point-min))
10393 (while (and sorted want-list)
10394 (setq want-l want-list)
10396 (not (string-match (car sorted) (car want-l))))
10397 (setq want-l (cdr want-l)))
10400 (insert (car want-l))
10401 (setq want-list (delq (car want-l) want-list))))
10402 (setq sorted (cdr sorted)))
10403 ;; Any headers that were not matched by the sorted list we
10404 ;; just tack on the end of the visible header list.
10406 (insert (car want-list))
10407 (setq want-list (cdr want-list)))
10408 ;; And finally we make the unwanted headers invisible.
10410 (delete-region (point) (point-max))
10411 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10412 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10414 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10415 (defun gnus-article-treat-overstrike ()
10416 "Translate overstrikes into bold text."
10419 (set-buffer gnus-article-buffer)
10420 (let ((buffer-read-only nil))
10421 (while (search-forward "\b" nil t)
10422 (let ((next (following-char))
10423 (previous (char-after (- (point) 2))))
10424 (cond ((eq next previous)
10425 (delete-region (- (point) 2) (point))
10426 (put-text-property (point) (1+ (point))
10429 (delete-region (1- (point)) (1+ (point)))
10430 (put-text-property (1- (point)) (point)
10433 (delete-region (- (point) 2) (point))
10434 (put-text-property (point) (1+ (point))
10435 'face 'underline))))))))
10437 (defun gnus-article-word-wrap ()
10438 "Format too long lines."
10441 (set-buffer gnus-article-buffer)
10442 (let ((buffer-read-only nil))
10443 (goto-char (point-min))
10444 (search-forward "\n\n" nil t)
10446 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
10447 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
10448 (adaptive-fill-mode t))
10449 (while (not (eobp))
10450 (and (>= (current-column) (min fill-column (window-width)))
10451 (/= (preceding-char) ?:)
10452 (fill-paragraph nil))
10453 (end-of-line 2))))))
10455 (defun gnus-article-remove-cr ()
10456 "Remove carriage returns from an article."
10459 (set-buffer gnus-article-buffer)
10460 (let ((buffer-read-only nil))
10461 (goto-char (point-min))
10462 (while (search-forward "\r" nil t)
10463 (replace-match "" t t)))))
10465 (defun gnus-article-display-x-face (&optional force)
10466 "Look for an X-Face header and display it if present."
10467 (interactive (list 'force))
10469 (set-buffer gnus-article-buffer)
10470 (let ((inhibit-point-motion-hooks t)
10471 (case-fold-search nil))
10473 (goto-char (point-min))
10474 (search-forward "\n\n")
10475 (narrow-to-region (point-min) (point))
10476 (goto-char (point-min))
10477 (if (or (not gnus-article-x-face-command)
10479 (or (not gnus-article-x-face-too-ugly)
10480 (string-match gnus-article-x-face-too-ugly
10481 (mail-fetch-field "from"))))
10483 (goto-char (point-min))
10484 (not (re-search-forward "^X-Face: " nil t))))
10486 (let ((beg (point))
10487 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
10488 (if (symbolp gnus-article-x-face-command)
10489 (and (or (fboundp gnus-article-x-face-command)
10490 (error "%s is not a function"
10491 gnus-article-x-face-command))
10492 (funcall gnus-article-x-face-command beg end))
10493 (call-process-region beg end "sh" nil 0 nil
10494 "-c" gnus-article-x-face-command))))))))
10496 (defun gnus-article-de-quoted-unreadable (&optional force)
10497 "Do a naïve translation of a quoted-printable-encoded article.
10498 This is in no way, shape or form meant as a replacement for real MIME
10499 processing, but is simply a stop-gap measure until MIME support is
10501 If FORCE, decode the article whether it is marked as quoted-printable
10503 (interactive (list 'force))
10505 (set-buffer gnus-article-buffer)
10506 (let ((case-fold-search t)
10507 (buffer-read-only nil)
10508 (type (gnus-fetch-field "content-transfer-encoding")))
10509 (if (or force (and type (string-match "quoted-printable" type)))
10511 (goto-char (point-min))
10512 (search-forward "\n\n" nil 'move)
10513 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
10515 (defun gnus-mime-decode-quoted-printable (from to)
10516 ;; Decode quoted-printable from region between FROM and TO.
10519 (while (search-forward "=" to t)
10520 (cond ((eq (following-char) ?\n)
10523 ((looking-at "[0-9A-F][0-9A-F]")
10525 (insert (hexl-hex-string-to-integer
10526 (buffer-substring (point) (+ 2 (point)))))
10528 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
10530 (defvar gnus-article-time-units
10531 (list (cons 'year (* 365.25 24 60 60))
10532 (cons 'week (* 7 24 60 60))
10533 (cons 'day (* 24 60 60))
10534 (cons 'hour (* 60 60))
10538 (defun gnus-article-date-ut (&optional type)
10539 "Convert DATE date to universal time in the current article.
10540 If TYPE is `local', convert to local time; if it is `lapsed', output
10541 how much time has lapsed since DATE."
10542 (interactive (list 'ut))
10543 (let ((date (header-date (or gnus-current-headers
10544 (gnus-get-header-by-number
10545 (gnus-summary-article-number))"")))
10546 (date-regexp "^Date: \\|^X-Sent: "))
10551 (set-buffer gnus-article-buffer)
10552 (let ((buffer-read-only nil))
10553 (goto-char (point-min))
10554 (if (and (re-search-forward date-regexp nil t)
10556 (beginning-of-line)
10557 (looking-at date-regexp)))
10558 (delete-region (gnus-point-at-bol)
10559 (progn (end-of-line) (1+ (point))))
10560 (goto-char (point-min))
10561 (goto-char (- (search-forward "\n\n") 2)))
10565 (concat "Date: " (condition-case ()
10566 (timezone-make-date-arpa-standard date)
10572 (timezone-make-date-arpa-standard date nil "UT")
10576 ;; If the date is seriously mangled, the timezone
10577 ;; functions are liable to bug out, so we condition-case
10578 ;; the entire thing.
10579 (let* ((sec (condition-case ()
10580 (max (- (gnus-seconds-since-epoch
10581 (timezone-make-date-arpa-standard
10582 (current-time-string)
10583 (current-time-zone) "UT"))
10584 (gnus-seconds-since-epoch
10585 (timezone-make-date-arpa-standard
10594 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
10596 (setq sec (- sec (* num (cdr unit))))
10598 (concat (if prev ", " "") (int-to-string (floor num))
10599 " " (symbol-name (car unit))
10600 (if (> num 1) "s" ""))
10602 gnus-article-time-units "")
10605 (error "Unknown conversion type: %s" type)))))))))
10607 (defun gnus-article-date-local ()
10608 "Convert the current article date to the local timezone."
10610 (gnus-article-date-ut 'local))
10612 (defun gnus-article-date-lapsed ()
10613 "Convert the current article date to time lapsed since it was sent."
10615 (gnus-article-date-ut 'lapsed))
10617 (defun gnus-article-maybe-highlight ()
10618 (if gnus-visual (gnus-article-highlight)))
10622 (defun gnus-output-to-rmail (file-name)
10623 "Append the current article to an Rmail file named FILE-NAME."
10625 ;; Most of these codes are borrowed from rmailout.el.
10626 (setq file-name (expand-file-name file-name))
10627 (setq rmail-default-rmail-file file-name)
10628 (let ((artbuf (current-buffer))
10629 (tmpbuf (get-buffer-create " *Gnus-output*")))
10631 (or (get-file-buffer file-name)
10632 (file-exists-p file-name)
10633 (if (gnus-yes-or-no-p
10634 (concat "\"" file-name "\" does not exist, create it? "))
10635 (let ((file-buffer (create-file-buffer file-name)))
10637 (set-buffer file-buffer)
10638 (rmail-insert-rmail-file-header)
10639 (let ((require-final-newline nil))
10640 (write-region (point-min) (point-max) file-name t 1)))
10641 (kill-buffer file-buffer))
10642 (error "Output file does not exist")))
10643 (set-buffer tmpbuf)
10644 (buffer-disable-undo (current-buffer))
10646 (insert-buffer-substring artbuf)
10647 (gnus-convert-article-to-rmail)
10648 ;; Decide whether to append to a file or to an Emacs buffer.
10649 (let ((outbuf (get-file-buffer file-name)))
10651 (append-to-file (point-min) (point-max) file-name)
10652 ;; File has been visited, in buffer OUTBUF.
10653 (set-buffer outbuf)
10654 (let ((buffer-read-only nil)
10655 (msg (and (boundp 'rmail-current-message)
10656 (symbol-value 'rmail-current-message))))
10657 ;; If MSG is non-nil, buffer is in RMAIL mode.
10660 (narrow-to-region (point-max) (point-max))))
10661 (insert-buffer-substring tmpbuf)
10664 (goto-char (point-min))
10666 (search-backward "\^_")
10667 (narrow-to-region (point) (point-max))
10668 (goto-char (1+ (point-min)))
10669 (rmail-count-new-messages t)
10670 (rmail-show-message msg)))))))
10671 (kill-buffer tmpbuf)))
10673 (defun gnus-output-to-file (file-name)
10674 "Append the current article to a file named FILE-NAME."
10675 (setq file-name (expand-file-name file-name))
10676 (let ((artbuf (current-buffer))
10677 (tmpbuf (get-buffer-create " *Gnus-output*")))
10679 (set-buffer tmpbuf)
10680 (buffer-disable-undo (current-buffer))
10682 (insert-buffer-substring artbuf)
10683 ;; Append newline at end of the buffer as separator, and then
10684 ;; save it to file.
10685 (goto-char (point-max))
10687 (append-to-file (point-min) (point-max) file-name))
10688 (kill-buffer tmpbuf)))
10690 (defun gnus-convert-article-to-rmail ()
10691 "Convert article in current buffer to Rmail message format."
10692 (let ((buffer-read-only nil))
10693 ;; Convert article directly into Babyl format.
10694 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10695 (goto-char (point-min))
10696 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10697 (while (search-forward "\n\^_" nil t) ;single char
10698 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10699 (goto-char (point-max))
10702 (defun gnus-narrow-to-page (&optional arg)
10703 "Make text outside current page invisible except for page delimiter.
10704 A numeric arg specifies to move forward or backward by that many pages,
10705 thus showing a page other than the one point was originally in."
10707 (setq arg (if arg (prefix-numeric-value arg) 0))
10709 (forward-page -1) ;Beginning of current page.
10714 (forward-page (1- arg))))
10715 ;; Find the end of the page.
10717 ;; If we stopped due to end of buffer, stay there.
10718 ;; If we stopped after a page delimiter, put end of restriction
10719 ;; at the beginning of that line.
10720 ;; These are commented out.
10721 ;; (if (save-excursion (beginning-of-line)
10722 ;; (looking-at page-delimiter))
10723 ;; (beginning-of-line))
10724 (narrow-to-region (point)
10726 ;; Find the top of the page.
10728 ;; If we found beginning of buffer, stay there.
10729 ;; If extra text follows page delimiter on same line,
10731 ;; Otherwise, show text starting with following line.
10732 (if (and (eolp) (not (bobp)))
10736 (defun gnus-gmt-to-local ()
10737 "Rewrite Date header described in GMT to local in current buffer.
10738 Intended to be used with gnus-article-prepare-hook."
10742 (goto-char (point-min))
10743 (narrow-to-region (point-min)
10744 (progn (search-forward "\n\n" nil 'move) (point)))
10745 (goto-char (point-min))
10746 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10747 (let ((buffer-read-only nil)
10748 (date (buffer-substring-no-properties
10749 (match-beginning 1) (match-end 1))))
10750 (delete-region (match-beginning 1) (match-end 1))
10752 (timezone-make-date-arpa-standard
10753 date nil (current-time-zone))))))))
10756 ;; Article mode commands
10758 (defun gnus-article-next-page (lines)
10759 "Show next page of current article.
10760 If end of article, return non-nil. Otherwise return nil.
10761 Argument LINES specifies lines to be scrolled up."
10763 (move-to-window-line -1)
10764 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10765 (if (save-excursion
10767 (and (pos-visible-in-window-p) ;Not continuation line.
10769 ;; Nothing in this page.
10770 (if (or (not gnus-break-pages)
10773 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10775 (gnus-narrow-to-page 1) ;Go to next page.
10777 ;; More in this page.
10781 ;; Long lines may cause an end-of-buffer error.
10782 (goto-char (point-max))))
10785 (defun gnus-article-prev-page (lines)
10786 "Show previous page of current article.
10787 Argument LINES specifies lines to be scrolled down."
10789 (move-to-window-line 0)
10790 (if (and gnus-break-pages
10792 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10794 (gnus-narrow-to-page -1) ;Go to previous page.
10795 (goto-char (point-max))
10797 (scroll-down lines)))
10799 (defun gnus-article-refer-article ()
10800 "Read article specified by message-id around point."
10802 (search-forward ">" nil t) ;Move point to end of "<....>".
10803 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10805 (buffer-substring (match-beginning 1) (match-end 1))))
10806 (set-buffer gnus-summary-buffer)
10807 (gnus-summary-refer-article message-id))
10808 (error "No references around point")))
10810 (defun gnus-article-show-summary ()
10811 "Reconfigure windows to show summary buffer."
10813 (gnus-configure-windows 'article)
10814 (gnus-summary-goto-subject gnus-current-article))
10816 (defun gnus-article-describe-briefly ()
10817 "Describe article mode commands briefly."
10820 (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")))
10822 (defun gnus-article-summary-command ()
10823 "Execute the last keystroke in the summary buffer."
10825 (let ((obuf (current-buffer))
10826 (owin (current-window-configuration))
10828 (switch-to-buffer gnus-summary-buffer 'norecord)
10829 (setq func (lookup-key (current-local-map) (this-command-keys)))
10830 (call-interactively func)
10832 (set-window-configuration owin)
10833 (set-window-start (get-buffer-window (current-buffer)) (point))))
10835 (defun gnus-article-summary-command-nosave ()
10836 "Execute the last keystroke in the summary buffer."
10839 (switch-to-buffer gnus-summary-buffer 'norecord)
10840 (setq func (lookup-key (current-local-map) (this-command-keys)))
10841 (call-interactively func)))
10844 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10847 (defalias 'gnus-batch-kill 'gnus-batch-score)
10849 (defun gnus-batch-score ()
10850 "Run batched scoring.
10851 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10852 Newsgroups is a list of strings in Bnews format. If you want to score
10853 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10854 score the alt hierarchy, you'd say \"!alt.all\"."
10857 (gnus-newsrc-parse-options
10858 (apply (function concat)
10859 (mapcar (lambda (g) (concat g " "))
10860 command-line-args-left))))
10861 (gnus-expert-user t)
10862 (nnmail-spool-file nil)
10863 (gnus-use-dribble-file nil)
10864 (yes (car yes-and-no))
10865 (no (cdr yes-and-no))
10867 ;; Disable verbose message.
10868 gnus-novice-user gnus-large-newsgroup)
10869 ;; Eat all arguments.
10870 (setq command-line-args-left nil)
10873 ;; Apply kills to specified newsgroups in command line arguments.
10874 (setq newsrc (cdr gnus-newsrc-alist))
10876 (setq group (car (car newsrc)))
10877 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10878 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10880 (or (eq (car entry) t)
10881 (not (zerop (car entry)))))
10882 (if yes (string-match yes group) t)
10883 (or (null no) (not (string-match no group))))
10885 (gnus-summary-read-group group nil t)
10886 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10887 (gnus-summary-exit))))
10888 (setq newsrc (cdr newsrc)))
10890 (switch-to-buffer gnus-group-buffer)
10891 (gnus-group-save-newsrc)))
10893 (defun gnus-apply-kill-file ()
10894 "Apply a kill file to the current newsgroup.
10895 Returns the number of articles marked as read."
10896 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10897 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10898 (gnus-apply-kill-file-internal)
10901 (defun gnus-kill-save-kill-buffer ()
10903 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10904 (if (get-file-buffer file)
10906 (set-buffer (get-file-buffer file))
10907 (and (buffer-modified-p) (save-buffer))
10908 (kill-buffer (current-buffer)))))))
10910 (defvar gnus-kill-file-name "KILL"
10911 "Suffix of the kill files.")
10913 (defun gnus-newsgroup-kill-file (newsgroup)
10914 "Return the name of a kill file name for NEWSGROUP.
10915 If NEWSGROUP is nil, return the global kill file name instead."
10916 (cond ((or (null newsgroup)
10917 (string-equal newsgroup ""))
10918 ;; The global KILL file is placed at top of the directory.
10919 (expand-file-name gnus-kill-file-name
10920 (or gnus-kill-files-directory "~/News")))
10921 ((gnus-use-long-file-name 'not-kill)
10922 ;; Append ".KILL" to newsgroup name.
10923 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10924 (or gnus-kill-files-directory "~/News")))
10926 ;; Place "KILL" under the hierarchical directory.
10927 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10928 "/" gnus-kill-file-name)
10929 (or gnus-kill-files-directory "~/News")))))
10936 (defvar gnus-dribble-ignore nil)
10938 (defun gnus-dribble-file-name ()
10939 (concat gnus-startup-file "-dribble"))
10941 (defun gnus-dribble-open ()
10944 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10945 (buffer-disable-undo (current-buffer))
10946 (bury-buffer gnus-dribble-buffer)
10948 (goto-char (point-max))))
10950 (defun gnus-dribble-enter (string)
10951 (if (and (not gnus-dribble-ignore)
10952 gnus-dribble-buffer
10953 (buffer-name gnus-dribble-buffer))
10954 (let ((obuf (current-buffer)))
10955 (set-buffer gnus-dribble-buffer)
10956 (insert string "\n")
10957 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10958 (set-buffer obuf))))
10960 (defun gnus-dribble-read-file ()
10961 (let ((dribble-file (gnus-dribble-file-name)))
10963 (set-buffer (setq gnus-dribble-buffer
10965 (file-name-nondirectory dribble-file))))
10966 (gnus-add-current-to-buffer-list)
10968 (set-visited-file-name dribble-file)
10969 (buffer-disable-undo (current-buffer))
10970 (bury-buffer (current-buffer))
10971 (set-buffer-modified-p nil)
10972 (let ((auto (make-auto-save-file-name))
10973 (gnus-dribble-ignore t))
10974 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10976 (if (file-newer-than-file-p auto dribble-file)
10977 (setq dribble-file auto))
10978 (insert-file-contents dribble-file)
10979 (if (not (zerop (buffer-size)))
10980 (set-buffer-modified-p t))
10982 "Auto-save file exists. Do you want to read it? ")
10984 (gnus-message 5 "Reading %s..." dribble-file)
10985 (eval-buffer (current-buffer))
10986 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
10988 (defun gnus-dribble-delete-file ()
10989 (if (file-exists-p (gnus-dribble-file-name))
10990 (delete-file (gnus-dribble-file-name)))
10991 (if gnus-dribble-buffer
10993 (set-buffer gnus-dribble-buffer)
10994 (let ((auto (make-auto-save-file-name)))
10995 (if (file-exists-p auto)
10996 (delete-file auto))
10998 (set-buffer-modified-p nil)))))
11000 (defun gnus-dribble-save ()
11001 (if (and gnus-dribble-buffer
11002 (buffer-name gnus-dribble-buffer))
11004 (set-buffer gnus-dribble-buffer)
11007 (defun gnus-dribble-clear ()
11009 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11011 (set-buffer gnus-dribble-buffer)
11013 (set-buffer-modified-p nil)
11014 (setq buffer-saved-size (buffer-size))))))
11017 ;;; Server Communication
11020 ;; All the Gnus backends have the same interface, and should return
11021 ;; data in a similar format. Below is an overview of what functions
11022 ;; these packages must supply and what results they should return.
11026 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11029 ;; Functions for the imaginary backend `choke':
11031 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11032 ;; Should return all headers for all ARTICLES, or return NOV lines for
11035 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11036 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11037 ;; must be returned.
11039 ;; `choke-close-group GROUP &optional SERVER'
11040 ;; Close group. Most backends won't have to do anything with this
11041 ;; call, but it is an opportunity to clean up, if that is needed. It
11042 ;; is called when Gnus exits a group.
11044 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11045 ;; Return ARTICLE, which is either an article number or
11046 ;; message-id. Note that not all backends can return articles based on
11049 ;; `choke-request-list SERVER'
11050 ;; Return a list of all newsgroups on SERVER.
11052 ;; `choke-request-list-newsgroups SERVER'
11053 ;; Return a list of descriptions of all newsgroups on SERVER.
11055 ;; `choke-request-newgroups DATE &optional SERVER'
11056 ;; Return a list of all groups that have arrived after DATE on
11057 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11058 ;; always check whether the groups are old or not. Backends that do
11059 ;; not store date information may just return the entire list of
11060 ;; groups, although this might not be a good idea in general.
11062 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11063 ;; Should return a buffer that is suitable for "posting". nnspool and
11064 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11065 ;; buffer. This function should fill out the appropriate headers.
11067 ;; `choke-request-post &optional SERVER'
11068 ;; Function that will be called from a buffer to be posted.
11070 ;; `choke-open-server SERVER &optional ARGUMENT'
11071 ;; Open a connection to SERVER.
11073 ;; `choke-close-server &optional SERVER'
11074 ;; Close the connection to SERVER.
11076 ;; `choke-server-opened &optional SERVER'
11077 ;; Whether the conenction to SERVER is opened or not.
11079 ;; `choke-server-status &optional SERVER'
11080 ;; Should return a status string (not in the nntp buffer, but as the
11081 ;; result of the function).
11083 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11084 ;; Optional function for retrieving active file info on all groups in
11085 ;; GROUPS. Two return formats are supported: The normal active file
11086 ;; format, and a list of GROUP lines. This function should return (as
11087 ;; a function value) either `active' or `group', depending on what
11088 ;; format it returns.
11090 ;; The following functions are optional and apply only to backends
11091 ;; that are able to control the contents of their groups totally
11092 ;; (ie. mail backends.) Backends that aren't able to do that
11093 ;; shouldn't define these functions at all. Gnus will check for their
11094 ;; presence before attempting to call them.
11096 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11097 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11098 ;; backends will not be able to expire articles. Should return a list
11099 ;; of all articles that were not expired.
11101 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11102 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11103 ;; Removes any information it has added to the article (extra headers,
11104 ;; whatever - make it as clean as possible), and then passes the
11105 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11106 ;; function described below. If the ACCEPT-FORM returns a non-nil
11107 ;; value, the article should then be deleted. If LAST is nil, that
11108 ;; means that there will be further calls to this function. This might
11109 ;; be taken as an advice not to save buffers/internal variables just
11110 ;; yet, but wait until the last call to speed things up.
11112 ;; `choke-request-accept-article GROUP &optional LAST'
11113 ;; The contents of the current buffer will be put into GROUP. There
11114 ;; should, of course, be an article in the current buffer. This
11115 ;; function is normally only called by the function described above,
11116 ;; and LAST works the same way as in that function.
11118 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11119 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11120 ;; This provides an easy interface for allowing editing of
11121 ;; articles. Note that even headers may be edited, so the backend has
11122 ;; to update any tables (nov buffers, etc) that it maintains after
11123 ;; replacing the article.
11125 ;; `choke-request-create-group GROUP &optional SERVER'
11126 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11127 ;; might be a group that already exists, but hasn't been registered
11130 ;; All these functions must return nil if they couldn't service the
11131 ;; request. If the optional arguments are not supplied, some "current"
11132 ;; or "default" values should be used. In short, one should emulate an
11133 ;; NNTP server, in a way.
11135 ;; If you want to write a new backend, you just have to supply the
11136 ;; functions listed above. In addition, you must enter the new backend
11137 ;; into the list of valid select methods:
11138 ;; (setq gnus-valid-select-methods
11139 ;; (cons '("choke" mail) gnus-valid-select-methods))
11140 ;; The first element in this list is the name of the backend. Other
11141 ;; elemnets may be `mail' (for mail groups), `post' (for news
11142 ;; groups), `none' (neither), `respool' (for groups that can control
11143 ;; their contents).
11145 (defun gnus-start-news-server (&optional confirm)
11146 "Open a method for getting news.
11147 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11149 (if gnus-current-select-method
11150 ;; Stream is already opened.
11152 ;; Open NNTP server.
11153 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11156 ;; Read server name with completion.
11157 (setq gnus-nntp-server
11158 (completing-read "NNTP server: "
11159 (mapcar (lambda (server) (list server))
11160 (cons (list gnus-nntp-server)
11161 gnus-secondary-servers))
11162 nil nil gnus-nntp-server))))
11164 (if (and gnus-nntp-server
11165 (stringp gnus-nntp-server)
11166 (not (string= gnus-nntp-server "")))
11167 (setq gnus-select-method
11168 (cond ((or (string= gnus-nntp-server "")
11169 (string= gnus-nntp-server "::"))
11170 (list 'nnspool (system-name)))
11171 ((string-match "^:" gnus-nntp-server)
11172 (list 'nnmh gnus-nntp-server
11173 (list 'nnmh-directory
11174 (file-name-as-directory
11176 (concat "~/" (substring
11177 gnus-nntp-server 1)))))
11178 (list 'nnmh-get-new-mail nil)))
11180 (list 'nntp gnus-nntp-server)))))
11182 (setq how (car gnus-select-method))
11183 (cond ((eq how 'nnspool)
11185 (gnus-message 5 "Looking up local news spool..."))
11188 (gnus-message 5 "Looking up mh spool..."))
11191 (setq gnus-current-select-method gnus-select-method)
11192 (run-hooks 'gnus-open-server-hook)
11194 ;; gnus-open-server-hook might have opened it
11195 (gnus-server-opened gnus-select-method)
11196 (gnus-open-server gnus-select-method)
11199 "%s server on %s can't be opened. Continue? "
11200 (car gnus-select-method) (nth 1 gnus-select-method)))
11202 (gnus-message 1 "Couldn't open server on %s"
11203 (nth 1 gnus-select-method))
11207 (defun gnus-check-news-server (&optional method)
11208 "If the news server is down, start it up again."
11209 (let ((method (if method method gnus-select-method)))
11210 (and (stringp method)
11211 (setq method (gnus-server-to-method method)))
11212 (if (gnus-server-opened method)
11213 ;; Stream is already opened.
11216 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11217 (run-hooks 'gnus-open-server-hook)
11218 (or (gnus-server-opened method)
11219 (gnus-open-server method))
11222 (defun gnus-nntp-message (&optional message)
11223 "Check the status of the NNTP server.
11224 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11225 is returned insted of the status string."
11226 (let ((status (gnus-status-message (gnus-find-method-for-group
11227 gnus-newsgroup-name)))
11228 (message (or message "")))
11229 (if (and (stringp status) (> (length status) 0))
11232 (defun gnus-get-function (method function)
11233 (and (stringp method)
11234 (setq method (gnus-server-to-method method)))
11235 (let ((func (intern (format "%s-%s" (car method) function))))
11236 (if (not (fboundp func))
11238 (require (car method))
11239 (if (not (fboundp func))
11240 (error "No such function: %s" func))))
11243 ;;; Interface functions to the backends.
11245 (defun gnus-open-server (method)
11246 (funcall (gnus-get-function method 'open-server)
11247 (nth 1 method) (nthcdr 2 method)))
11249 (defun gnus-close-server (method)
11250 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11252 (defun gnus-request-list (method)
11253 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11255 (defun gnus-request-list-newsgroups (method)
11256 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11258 (defun gnus-request-newgroups (date method)
11259 (funcall (gnus-get-function method 'request-newgroups)
11260 date (nth 1 method)))
11262 (defun gnus-server-opened (method)
11263 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11265 (defun gnus-status-message (method)
11266 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11268 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11270 (defun gnus-request-group (group &optional dont-check)
11271 (let ((method (gnus-find-method-for-group group)))
11272 ; (and t (message "%s GROUP %s" (car method) group))
11273 (funcall (gnus-get-function method 'request-group)
11274 (gnus-group-real-name group) (nth 1 method) dont-check)))
11276 (defun gnus-request-asynchronous (group &optional articles)
11277 (let ((method (gnus-find-method-for-group group)))
11278 (funcall (gnus-get-function method 'request-asynchronous)
11279 (gnus-group-real-name group) (nth 1 method) articles)))
11281 (defun gnus-list-active-group (group)
11282 (let ((method (gnus-find-method-for-group group))
11283 (func 'list-active-group))
11284 (and (gnus-check-backend-function func group)
11285 (funcall (gnus-get-function method func)
11286 (gnus-group-real-name group) (nth 1 method)))))
11288 (defun gnus-request-group-description (group)
11289 (let ((method (gnus-find-method-for-group group))
11290 (func 'request-group-description))
11291 (and (gnus-check-backend-function func group)
11292 (funcall (gnus-get-function method func)
11293 (gnus-group-real-name group) (nth 1 method)))))
11295 (defun gnus-close-group (group)
11296 (let ((method (gnus-find-method-for-group group)))
11297 (funcall (gnus-get-function method 'close-group)
11298 (gnus-group-real-name group) (nth 1 method))))
11300 (defun gnus-retrieve-headers (articles group)
11301 (let ((method (gnus-find-method-for-group group)))
11302 (if (and gnus-use-cache (numberp (car articles)))
11303 (gnus-cache-retrieve-headers articles group)
11304 (funcall (gnus-get-function method 'retrieve-headers)
11305 articles (gnus-group-real-name group) (nth 1 method)))))
11307 (defun gnus-retrieve-groups (groups method)
11308 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11310 (defun gnus-request-article (article group &optional buffer)
11311 (let ((method (gnus-find-method-for-group group)))
11312 (funcall (gnus-get-function method 'request-article)
11313 article (gnus-group-real-name group) (nth 1 method) buffer)))
11315 (defun gnus-request-head (article group)
11316 (let ((method (gnus-find-method-for-group group)))
11317 (funcall (gnus-get-function method 'request-head)
11318 article (gnus-group-real-name group) (nth 1 method))))
11320 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11321 (defun gnus-request-post-buffer (post group subject header artbuf
11322 info follow-to respect-poster)
11323 (let* ((info (or info (and group (nth 2 (gnus-gethash
11324 group gnus-newsrc-hashtb)))))
11326 (if (and gnus-post-method
11327 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11329 (format "%s" (car (gnus-find-method-for-group
11330 gnus-newsgroup-name)))
11331 gnus-valid-select-methods)))
11333 (gnus-find-method-for-group gnus-newsgroup-name))))
11334 (or (gnus-server-opened method)
11335 (gnus-open-server method)
11336 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11337 (let ((mail-self-blind nil)
11338 (mail-archive-file-name nil))
11339 (funcall (gnus-get-function method 'request-post-buffer)
11340 post group subject header artbuf info follow-to
11343 (defun gnus-request-post (method &optional force)
11344 (and (stringp method)
11345 (setq method (gnus-server-to-method method)))
11346 (and (not force) gnus-post-method
11347 (memq 'post (assoc (format "%s" (car method))
11348 gnus-valid-select-methods))
11349 (setq method gnus-post-method))
11350 (funcall (gnus-get-function method 'request-post)
11353 (defun gnus-request-expire-articles (articles group &optional force)
11354 (let ((method (gnus-find-method-for-group group)))
11355 (funcall (gnus-get-function method 'request-expire-articles)
11356 articles (gnus-group-real-name group) (nth 1 method)
11359 (defun gnus-request-move-article
11360 (article group server accept-function &optional last)
11361 (let ((method (gnus-find-method-for-group group)))
11362 (funcall (gnus-get-function method 'request-move-article)
11363 article (gnus-group-real-name group)
11364 (nth 1 method) accept-function last)))
11366 (defun gnus-request-accept-article (group &optional last)
11367 (let ((func (if (symbolp group) group
11368 (car (gnus-find-method-for-group group)))))
11369 (funcall (intern (format "%s-request-accept-article" func))
11370 (if (stringp group) (gnus-group-real-name group) group)
11373 (defun gnus-request-replace-article (article group buffer)
11374 (let ((func (car (gnus-find-method-for-group group))))
11375 (funcall (intern (format "%s-request-replace-article" func))
11376 article (gnus-group-real-name group) buffer)))
11378 (defun gnus-request-create-group (group)
11379 (let ((method (gnus-find-method-for-group group)))
11380 (funcall (gnus-get-function method 'request-create-group)
11381 (gnus-group-real-name group) (nth 1 method))))
11383 (defun gnus-member-of-valid (symbol group)
11384 (memq symbol (assoc
11385 (format "%s" (car (gnus-find-method-for-group group)))
11386 gnus-valid-select-methods)))
11388 (defsubst gnus-secondary-method-p (method)
11389 (member method gnus-secondary-select-methods))
11391 (defun gnus-find-method-for-group (group &optional info)
11392 (or gnus-override-method
11394 gnus-select-method)
11395 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11398 (not (setq method (nth 4 info))))
11399 (setq method gnus-select-method)
11401 (cond ((stringp method)
11402 (gnus-server-to-method method))
11403 ((stringp (car method))
11404 (gnus-server-extend-method group method))
11407 (gnus-server-add-address method))))
11409 (defun gnus-check-backend-function (func group)
11410 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11412 (fboundp (intern (format "%s-%s" method func)))))
11414 (defun gnus-methods-using (method)
11415 (let ((valids gnus-valid-select-methods)
11418 (if (memq method (car valids))
11419 (setq outs (cons (car valids) outs)))
11420 (setq valids (cdr valids)))
11424 ;;; Active & Newsrc File Handling
11427 ;; Newsrc related functions.
11428 ;; Gnus internal format of gnus-newsrc-alist:
11429 ;; (("alt.general" 3 (1 . 1))
11430 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11431 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11432 ;; The first item is the group name; the second is the subscription
11433 ;; level; the third is either a range of a list of ranges of read
11434 ;; articles, the optional fourth element is a list of marked articles,
11435 ;; the optional fifth element is the select method.
11437 ;; Gnus internal format of gnus-newsrc-hashtb:
11438 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11439 ;; This is the entry for "alt.misc". The first element is the number
11440 ;; of unread articles in "alt.misc". The cdr of this entry is the
11441 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11442 ;; trivial to remove or add new elements into gnus-newsrc-alist
11443 ;; without scanning the entire list. So, to get the actual information
11444 ;; of "alt.misc", you'd say something like
11445 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11447 ;; Gnus internal format of gnus-active-hashtb:
11451 ;; The only element in each entry in this hash table is a range of
11452 ;; (possibly) available articles. (Articles in this range may have
11453 ;; been expired or canceled.)
11455 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11456 ;; ("alt.misc" "alt.test" "alt.general" ...)
11458 (defun gnus-setup-news (&optional rawfile level)
11459 "Setup news information.
11460 If RAWFILE is non-nil, the .newsrc file will also be read.
11461 If LEVEL is non-nil, the news will be set up at level LEVEL."
11462 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
11463 ;; Clear some variables to re-initialize news information.
11464 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
11466 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11467 (if init (gnus-read-newsrc-file rawfile))
11469 ;; Read the active file and create `gnus-active-hashtb'.
11470 ;; If `gnus-read-active-file' is nil, then we just create an empty
11471 ;; hash table. The partial filling out of the hash table will be
11472 ;; done in `gnus-get-unread-articles'.
11473 (if (and gnus-read-active-file
11475 (gnus-read-active-file)
11476 (setq gnus-active-hashtb (make-vector 4095 0)))
11478 (and init gnus-use-dribble-file (gnus-dribble-read-file))
11480 ;; Find the number of unread articles in each non-dead group.
11481 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
11482 ;; Find new newsgroups and treat them.
11483 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
11484 (gnus-server-opened gnus-select-method))
11485 (gnus-find-new-newsgroups))
11486 (if (and init gnus-check-bogus-newsgroups
11487 gnus-read-active-file (not level)
11488 (gnus-server-opened gnus-select-method))
11489 (gnus-check-bogus-newsgroups))))
11491 (defun gnus-find-new-newsgroups ()
11492 "Search for new newsgroups and add them.
11493 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11494 The `-n' option line from .newsrc is respected."
11496 (or (gnus-check-first-time-used)
11497 (if (or (consp gnus-check-new-newsgroups)
11498 (eq gnus-check-new-newsgroups 'ask-server))
11499 (gnus-ask-server-for-new-groups)
11501 group new-newsgroups)
11502 (or gnus-have-read-active-file (gnus-read-active-file))
11503 (setq gnus-newsrc-last-checked-date (current-time-string))
11504 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11505 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11506 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11509 (setq group (symbol-name sym))
11510 (if (or (gnus-gethash group gnus-killed-hashtb)
11511 (gnus-gethash group gnus-newsrc-hashtb))
11513 (let ((do-sub (gnus-matches-options-n group)))
11514 (cond ((eq do-sub 'subscribe)
11515 (setq groups (1+ groups))
11516 (gnus-sethash group group gnus-killed-hashtb)
11518 gnus-subscribe-options-newsgroup-method group))
11519 ((eq do-sub 'ignore)
11522 (setq groups (1+ groups))
11523 (gnus-sethash group group gnus-killed-hashtb)
11524 (if gnus-subscribe-hierarchical-interactive
11525 (setq new-newsgroups (cons group new-newsgroups))
11526 (funcall gnus-subscribe-newsgroup-method group)))))))
11527 gnus-active-hashtb)
11529 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11530 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11532 (gnus-message 6 "%d new newsgroup%s arrived."
11533 groups (if (> groups 1) "s have" " has")))))))
11535 (defun gnus-matches-options-n (group)
11536 ;; Returns `subscribe' if the group is to be uncoditionally
11537 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
11538 ;; no match for the group.
11540 ;; First we check the two user variables.
11542 ((and gnus-options-subscribe
11543 (string-match gnus-options-subscribe group))
11545 ((and gnus-options-not-subscribe
11546 (string-match gnus-options-not-subscribe group))
11548 ;; Then we go through the list that was retrieved from the .newsrc
11549 ;; file. This list has elements on the form
11550 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11551 ;; is in the reverse order of the options line) is returned.
11553 (let ((regs gnus-newsrc-options-n))
11555 (not (string-match (car (car regs)) group)))
11556 (setq regs (cdr regs)))
11557 (and regs (cdr (car regs)))))))
11559 (defun gnus-ask-server-for-new-groups ()
11560 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11561 (methods (cons gnus-select-method
11563 (and (consp gnus-check-new-newsgroups)
11564 gnus-check-new-newsgroups)
11565 gnus-secondary-select-methods)))
11567 (new-date (current-time-string))
11568 hashtb group new-newsgroups got-new)
11569 ;; Go thorugh both primary and secondary select methods and
11570 ;; request new newsgroups.
11572 (and (or (gnus-server-opened (car methods))
11573 (gnus-open-server (car methods)))
11574 (gnus-request-newgroups date (car methods))
11577 (set-buffer nntp-server-buffer)
11578 (or hashtb (setq hashtb (gnus-make-hashtable
11579 (count-lines (point-min) (point-max)))))
11580 ;; Enter all the new groups in a hashtable.
11581 (gnus-active-to-gnus-format (car methods) hashtb 'ignore)))
11582 (setq methods (cdr methods)))
11583 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11584 ;; Now all new groups from all select methods are in `hashtb'.
11586 (lambda (group-sym)
11587 (setq group (symbol-name group-sym))
11588 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11589 (member group gnus-zombie-list)
11590 (member group gnus-killed-list))
11591 ;; The group is already known.
11593 (and (symbol-value group-sym)
11594 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
11595 (let ((do-sub (gnus-matches-options-n group)))
11596 (cond ((eq do-sub 'subscribe)
11597 (setq groups (1+ groups))
11598 (gnus-sethash group group gnus-killed-hashtb)
11600 gnus-subscribe-options-newsgroup-method group))
11601 ((eq do-sub 'ignore)
11604 (setq groups (1+ groups))
11605 (gnus-sethash group group gnus-killed-hashtb)
11606 (if gnus-subscribe-hierarchical-interactive
11607 (setq new-newsgroups (cons group new-newsgroups))
11608 (funcall gnus-subscribe-newsgroup-method group)))))))
11611 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11612 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11614 (gnus-message 6 "%d new newsgroup%s arrived."
11615 groups (if (> groups 1) "s have" " has")))
11618 (defun gnus-check-first-time-used ()
11619 (if (or (> (length gnus-newsrc-alist) 1)
11620 (file-exists-p gnus-startup-file)
11621 (file-exists-p (concat gnus-startup-file ".el"))
11622 (file-exists-p (concat gnus-startup-file ".eld")))
11624 (gnus-message 6 "First time user; subscribing you to default groups")
11625 (or gnus-have-read-active-file (gnus-read-active-file))
11626 (setq gnus-newsrc-last-checked-date (current-time-string))
11627 (let ((groups gnus-default-subscribed-newsgroups)
11631 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11634 (setq group (symbol-name sym))
11635 (let ((do-sub (gnus-matches-options-n group)))
11636 (cond ((eq do-sub 'subscribe)
11637 (gnus-sethash group group gnus-killed-hashtb)
11639 gnus-subscribe-options-newsgroup-method group))
11640 ((eq do-sub 'ignore)
11643 (setq gnus-killed-list (cons group gnus-killed-list))))))
11644 gnus-active-hashtb)
11646 (if (gnus-gethash (car groups) gnus-active-hashtb)
11647 (gnus-group-change-level
11648 (car groups) gnus-level-default-subscribed gnus-level-killed))
11649 (setq groups (cdr groups)))
11650 (gnus-group-make-help-group)
11651 (and gnus-novice-user
11652 (gnus-message 7 "`A k' to list killed groups"))))))
11654 (defun gnus-subscribe-group (group previous &optional method)
11655 (gnus-group-change-level
11657 (list t group gnus-level-default-subscribed nil nil method)
11659 gnus-level-default-subscribed gnus-level-killed previous t))
11661 ;; `gnus-group-change-level' is the fundamental function for changing
11662 ;; subscription levels of newsgroups. This might mean just changing
11663 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11664 ;; again, which subscribes/unsubscribes a group, which is equally
11665 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11666 ;; from 8-9 to 1-7 means that you remove the group from the list of
11667 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11668 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11669 ;; which is trivial.
11670 ;; ENTRY can either be a string (newsgroup name) or a list (if
11671 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11672 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11674 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11675 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11677 (defun gnus-group-change-level (entry level &optional oldlevel
11678 previous fromkilled)
11679 (let (group info active num)
11680 ;; Glean what info we can from the arguments
11682 (if fromkilled (setq group (nth 1 entry))
11683 (setq group (car (nth 2 entry))))
11684 (setq group entry))
11685 (if (and (stringp entry)
11687 (< oldlevel gnus-level-zombie))
11688 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11689 (if (and (not oldlevel)
11691 (setq oldlevel (car (cdr (nth 2 entry)))))
11692 (if (stringp previous)
11693 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11695 (gnus-dribble-enter
11696 (format "(gnus-group-change-level %S %S %S %S %S)"
11697 group level oldlevel (car (nth 2 previous)) fromkilled))
11699 ;; Then we remove the newgroup from any old structures, if needed.
11700 ;; If the group was killed, we remove it from the killed or zombie
11701 ;; list. If not, and it is in fact going to be killed, we remove
11702 ;; it from the newsrc hash table and assoc.
11703 (cond ((>= oldlevel gnus-level-zombie)
11704 (if (= oldlevel gnus-level-zombie)
11705 (setq gnus-zombie-list (delete group gnus-zombie-list))
11706 (setq gnus-killed-list (delete group gnus-killed-list))))
11708 (if (>= level gnus-level-zombie)
11710 (gnus-sethash (car (nth 2 entry))
11711 nil gnus-newsrc-hashtb)
11713 (setcdr (gnus-gethash (car (nth 3 entry))
11714 gnus-newsrc-hashtb)
11716 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11718 ;; Finally we enter (if needed) the list where it is supposed to
11719 ;; go, and change the subscription level. If it is to be killed,
11720 ;; we enter it into the killed or zombie list.
11721 (cond ((>= level gnus-level-zombie)
11722 ;; Remove from the hash table.
11723 (gnus-sethash group nil gnus-newsrc-hashtb)
11724 (or (gnus-group-foreign-p group)
11725 ;; We do not enter foreign groups into the list of dead
11727 (if (= level gnus-level-zombie)
11728 (setq gnus-zombie-list (cons group gnus-zombie-list))
11729 (setq gnus-killed-list (cons group gnus-killed-list)))))
11731 ;; If the list is to be entered into the newsrc assoc, and
11732 ;; it was killed, we have to create an entry in the newsrc
11733 ;; hashtb format and fix the pointers in the newsrc assoc.
11734 (if (>= oldlevel gnus-level-zombie)
11738 (setq info (cdr entry))
11739 (setq num (car entry)))
11740 (setq active (gnus-gethash group gnus-active-hashtb))
11741 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11742 ;; Check whether the group is foreign. If so, the
11743 ;; foreign select method has to be entered into the
11745 (let ((method (gnus-group-method-name group)))
11746 (if (eq method gnus-select-method)
11747 (setq info (list group level nil))
11748 (setq info (list group level nil nil method)))))
11751 (let ((p gnus-newsrc-alist))
11752 (while (cdr (cdr p))
11755 (setq entry (cons info (cdr (cdr previous))))
11758 (setcdr (cdr previous) entry)
11759 (gnus-sethash group (cons num (cdr previous))
11760 gnus-newsrc-hashtb))
11761 (setcdr previous entry)
11762 (gnus-sethash group (cons num previous)
11763 gnus-newsrc-hashtb))
11765 (setcdr (gnus-gethash (car (car (cdr entry)))
11766 gnus-newsrc-hashtb)
11768 ;; It was alive, and it is going to stay alive, so we
11769 ;; just change the level and don't change any pointers or
11770 ;; hash table entries.
11771 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11773 (defun gnus-kill-newsgroup (newsgroup)
11774 "Obsolete function. Kills a newsgroup."
11775 (gnus-group-change-level
11776 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11778 (defun gnus-check-bogus-newsgroups (&optional confirm)
11779 "Remove bogus newsgroups.
11780 If CONFIRM is non-nil, the user has to confirm the deletion of every
11782 (let ((newsrc (cdr gnus-newsrc-alist))
11784 (gnus-message 5 "Checking bogus newsgroups...")
11785 (or gnus-have-read-active-file (gnus-read-active-file))
11786 ;; Find all bogus newsgroup that are subscribed.
11788 (setq group (car (car newsrc)))
11789 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
11790 (nth 4 (car newsrc)) ; Foreign
11792 (not (gnus-y-or-n-p
11793 (format "Remove bogus newsgroup: %s " group)))))
11796 ;; Found a bogus newsgroup.
11797 (setq bogus (cons group bogus)))
11798 (setq newsrc (cdr newsrc)))
11799 ;; Remove all bogus subscribed groups by first killing them, and
11800 ;; then removing them from the list of killed groups.
11802 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
11804 (gnus-group-change-level entry gnus-level-killed)
11805 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
11806 (setq bogus (cdr bogus)))
11807 ;; Then we remove all bogus groups from the list of killed and
11808 ;; zombie groups. They are are removed without confirmation.
11809 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11812 (setq killed (symbol-value (car dead-lists)))
11814 (setq group (car killed))
11815 (or (gnus-gethash group gnus-active-hashtb)
11816 ;; The group is bogus.
11817 (set (car dead-lists)
11818 (delete group (symbol-value (car dead-lists)))))
11819 (setq killed (cdr killed)))
11820 (setq dead-lists (cdr dead-lists))))
11821 (gnus-message 5 "Checking bogus newsgroups...done")))
11823 (defun gnus-check-duplicate-killed-groups ()
11824 "Remove duplicates from the list of killed groups."
11826 (let ((killed gnus-killed-list))
11828 (gnus-message 9 "%d" (length killed))
11829 (setcdr killed (delete (car killed) (cdr killed)))
11830 (setq killed (cdr killed)))))
11832 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11833 ;; and compute how many unread articles there are in each group.
11834 (defun gnus-get-unread-articles (&optional level)
11835 (let* ((newsrc (cdr gnus-newsrc-alist))
11836 (level (or level (1+ gnus-level-subscribed)))
11839 (cond ((and gnus-activate-foreign-newsgroups
11840 (not (numberp gnus-activate-foreign-newsgroups)))
11841 (1+ gnus-level-subscribed))
11842 ((numberp gnus-activate-foreign-newsgroups)
11843 gnus-activate-foreign-newsgroups)
11846 info group active virtuals method)
11847 (gnus-message 5 "Checking new news...")
11850 (setq info (car newsrc)
11852 active (gnus-gethash group gnus-active-hashtb))
11854 ;; Check newsgroups. If the user doesn't want to check them, or
11855 ;; they can't be checked (for instance, if the news server can't
11856 ;; be reached) we just set the number of unread articles in this
11857 ;; newsgroup to t. This means that Gnus thinks that there are
11858 ;; unread articles, but it has no idea how many.
11859 (if (and (setq method (nth 4 info))
11860 (not (gnus-server-equal gnus-select-method
11861 (gnus-server-get-method nil method)))
11862 (not (gnus-secondary-method-p method)))
11863 ;; These groups are foreign. Check the level.
11864 (if (<= (nth 1 info) foreign-level)
11865 (if (eq (car (if (stringp method)
11866 (gnus-server-to-method method)
11867 (nth 4 info))) 'nnvirtual)
11868 ;; We have to activate the virtual groups after all
11869 ;; the others, so we just pop them on a list for
11871 (setq virtuals (cons info virtuals))
11872 (and (setq active (gnus-activate-newsgroup (car info)))
11873 ;; Close the groups as we look at them!
11874 (gnus-close-group group))))
11876 ;; These groups are native or secondary.
11877 (if (and (not gnus-have-read-active-file)
11878 (<= (nth 1 info) level))
11879 (setq active (gnus-activate-newsgroup (car info)))))
11882 (gnus-get-unread-articles-in-group info active)
11883 ;; The group couldn't be reached, so we nix out the number of
11884 ;; unread articles and stuff.
11885 (gnus-sethash group nil gnus-active-hashtb)
11886 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
11888 (setq newsrc (cdr newsrc)))
11890 ;; Activate the virtual groups. This has to be done after all the
11892 ;; !!! If one virtual group contains another virtual group, even
11893 ;; doing it this way might cause problems.
11895 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11896 (gnus-get-unread-articles-in-group (car virtuals) active))
11897 (setq virtuals (cdr virtuals)))
11899 (gnus-message 5 "Checking new news...done")))
11901 ;; Create a hash table out of the newsrc alist. The `car's of the
11902 ;; alist elements are used as keys.
11903 (defun gnus-make-hashtable-from-newsrc-alist ()
11904 (let ((alist gnus-newsrc-alist)
11905 (ohashtb gnus-newsrc-hashtb)
11907 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11909 (setq prev (setq gnus-newsrc-alist
11910 (if (equal (car (car gnus-newsrc-alist))
11913 (cons (list "dummy.group" 0 nil) alist)))))
11915 (gnus-sethash (car (car alist))
11916 (cons (and ohashtb (car (gnus-gethash
11917 (car (car alist)) ohashtb)))
11918 prev) gnus-newsrc-hashtb)
11920 alist (cdr alist)))))
11922 (defun gnus-make-hashtable-from-killed ()
11923 "Create a hash table from the killed and zombie lists."
11924 (let ((lists '(gnus-killed-list gnus-zombie-list))
11926 (setq gnus-killed-hashtb
11927 (gnus-make-hashtable
11928 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11930 (setq list (symbol-value (car lists)))
11931 (setq lists (cdr lists))
11933 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11934 (setq list (cdr list))))))
11936 (defun gnus-get-unread-articles-in-group (info active)
11937 (let* ((range (nth 2 info))
11939 (marked (nth 3 info)))
11940 ;; If a cache is present, we may have to alter the active info.
11941 (and gnus-use-cache
11942 (gnus-cache-possibly-alter-active (car info) active))
11943 ;; Modify the list of read articles according to what articles
11944 ;; are available; then tally the unread articles and add the
11945 ;; number to the group hash table entry.
11946 (cond ((zerop (cdr active))
11949 (setq num (- (1+ (cdr active)) (car active))))
11950 ((not (listp (cdr range)))
11951 ;; Fix a single (num . num) range according to the
11952 ;; active hash table.
11953 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
11954 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
11955 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
11956 ;; Compute number of unread articles.
11957 (setq num (max 0 (- (cdr active)
11958 (- (1+ (cdr range)) (car range))))))
11960 ;; The read list is a list of ranges. Fix them according to
11961 ;; the active hash table.
11962 ;; First peel off any elements that are below the lower
11964 (while (and (cdr range)
11966 (or (and (atom (car (cdr range))) (car (cdr range)))
11967 (car (car (cdr range))))))
11968 (if (numberp (car range))
11971 (or (and (numberp (car (cdr range)))
11973 (cdr (car (cdr range))))))
11974 (setcdr (car range)
11975 (or (and (numberp (nth 1 range)) (nth 1 range))
11976 (cdr (car (cdr range))))))
11977 (setcdr range (cdr (cdr range))))
11978 ;; Adjust the first element to be the same as the lower limit.
11979 (if (and (not (atom (car range)))
11980 (< (cdr (car range)) (car active)))
11981 (setcdr (car range) (1- (car active))))
11982 ;; Then we want to peel off any elements that are higher
11983 ;; than the upper active limit.
11984 (let ((srange range))
11985 ;; Go past all legal elements.
11986 (while (and (cdr srange)
11987 (<= (or (and (atom (car (cdr srange)))
11988 (car (cdr srange)))
11989 (car (car (cdr srange)))) (cdr active)))
11990 (setq srange (cdr srange)))
11992 ;; Nuke all remaining illegal elements.
11993 (setcdr srange nil))
11995 ;; Adjust the final element.
11996 (if (and (not (atom (car srange)))
11997 (> (cdr (car srange)) (cdr active)))
11998 (setcdr (car srange) (cdr active))))
11999 ;; Compute the number of unread articles.
12001 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12002 (cdr (car range))))
12003 (or (and (atom (car range)) (car range))
12004 (car (car range))))))
12005 (setq range (cdr range)))
12006 (setq num (max 0 (- (cdr active) num)))))
12009 (and (assq 'tick marked)
12010 (inline (gnus-remove-illegal-marked-articles
12011 (assq 'tick marked) (nth 2 info))))
12012 (and (assq 'dormant marked)
12013 (inline (gnus-remove-illegal-marked-articles
12014 (assq 'dormant marked) (nth 2 info))))
12016 (gnus-gethash (car info) gnus-newsrc-hashtb)
12017 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12018 (length (cdr (assq 'dormant marked)))))))))
12021 (defun gnus-remove-illegal-marked-articles (marked ranges)
12022 (let ((m (cdr marked)))
12023 ;; Make sure that all ticked articles are a subset of the unread
12026 (if (gnus-member-of-range (car m) ranges)
12027 (setcdr marked (cdr m))
12029 (setq m (cdr m)))))
12031 (defun gnus-activate-newsgroup (group)
12032 (let ((method (gnus-find-method-for-group group))
12034 (and (or (gnus-server-opened method) (gnus-open-server method))
12035 (gnus-request-group group)
12037 (set-buffer nntp-server-buffer)
12038 (goto-char (point-min))
12039 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12041 (goto-char (match-beginning 1))
12043 group (setq active (cons (read (current-buffer))
12044 (read (current-buffer))))
12045 gnus-active-hashtb))
12048 (defun gnus-update-read-articles
12049 (group unread unselected ticked &optional domarks replied expirable killed
12050 dormant bookmark score)
12051 "Update the list of read and ticked articles in GROUP using the
12052 UNREAD and TICKED lists.
12053 Note: UNSELECTED has to be sorted over `<'.
12054 Returns whether the updating was successful."
12055 (let* ((active (or gnus-newsgroup-active
12056 (gnus-gethash group gnus-active-hashtb)))
12057 (entry (gnus-gethash group gnus-newsrc-hashtb))
12058 (info (nth 2 entry))
12059 (marked (nth 3 info))
12061 (unread (sort (copy-sequence unread) (function <)))
12063 (if (or (not info) (not active))
12064 ;; There is no info on this group if it was, in fact,
12065 ;; killed. Gnus stores no information on killed groups, so
12066 ;; there's nothing to be done.
12067 ;; One could store the information somewhere temporarily,
12068 ;; perhaps... Hmmm...
12070 ;; Remove any negative articles numbers.
12071 (while (and unread (< (car unread) 0))
12072 (setq unread (cdr unread)))
12073 ;; Remove any expired article numbers
12074 (while (and unread (< (car unread) (car active)))
12075 (setq unread (cdr unread)))
12076 (while (and ticked (< (car ticked) (car active)))
12077 (setq ticked (cdr ticked)))
12078 (while (and dormant (< (car dormant) (car active)))
12079 (setq dormant (cdr dormant)))
12080 (setq unread (sort (append unselected unread) '<))
12081 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12082 (setcar entry (max 0 (- (length unread) (length ticked)
12083 (length dormant))))
12084 ;; Compute the ranges of read articles by looking at the list of
12085 ;; unread articles.
12087 (if (/= (car unread) prev)
12088 (setq read (cons (if (= prev (1- (car unread))) prev
12089 (cons prev (1- (car unread)))) read)))
12090 (setq prev (1+ (car unread)))
12091 (setq unread (cdr unread)))
12092 (if (<= prev (cdr active))
12093 (setq read (cons (cons prev (cdr active)) read)))
12094 ;; Enter this list into the group info.
12095 (setcar (cdr (cdr info))
12096 (if (> (length read) 1) (nreverse read) read))
12097 ;; Enter the list of ticked articles.
12098 (gnus-set-marked-articles
12100 (if domarks replied (cdr (assq 'reply marked)))
12101 (if domarks expirable (cdr (assq 'expire marked)))
12102 (if domarks killed (cdr (assq 'killed marked)))
12103 (if domarks dormant (cdr (assq 'dormant marked)))
12104 (if domarks bookmark (cdr (assq 'bookmark marked)))
12105 (if domarks score (cdr (assq 'score marked))))
12108 (defun gnus-make-articles-unread (group articles)
12109 "Mark ARTICLES in GROUP as unread."
12110 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12111 (gnus-gethash (gnus-group-real-name group)
12112 gnus-newsrc-hashtb))))
12113 (ranges (nth 2 info))
12116 (and (gnus-member-of-range (car articles) ranges)
12117 (setq news (cons (car articles) news)))
12118 (setq articles (cdr articles)))
12121 (setcar (nthcdr 2 info)
12122 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12123 (gnus-group-update-group group t))))
12125 ;; Get the active file(s) from the backend(s).
12126 (defun gnus-read-active-file ()
12127 (gnus-group-set-mode-line)
12128 (let ((methods (if (or (gnus-server-opened gnus-select-method)
12129 (gnus-open-server gnus-select-method))
12130 ;; The native server is available.
12131 (cons gnus-select-method gnus-secondary-select-methods)
12132 ;; The native server is down, so we just do the
12134 gnus-secondary-select-methods))
12136 (setq gnus-have-read-active-file nil)
12138 (set-buffer nntp-server-buffer)
12140 (let* ((where (nth 1 (car methods)))
12141 (mesg (format "Reading active file%s via %s..."
12142 (if (and where (not (zerop (length where))))
12143 (concat " from " where) "")
12144 (car (car methods)))))
12145 (gnus-message 5 mesg)
12146 (gnus-check-news-server (car methods))
12148 ((and (eq gnus-read-active-file 'some)
12149 (gnus-check-backend-function
12150 'retrieve-groups (car (car methods))))
12151 (let ((newsrc (cdr gnus-newsrc-alist))
12154 (and (gnus-server-equal
12155 (gnus-find-method-for-group
12156 (car (car newsrc)) (car newsrc))
12157 (gnus-server-get-method nil (car methods)))
12158 (setq groups (cons (car (car newsrc)) groups)))
12159 (setq newsrc (cdr newsrc)))
12160 (setq list-type (gnus-retrieve-groups groups (car methods)))
12161 (cond ((not list-type)
12163 1 "Cannot read partial active file from %s server."
12164 (car (car methods)))
12167 ((eq list-type 'active)
12168 (gnus-active-to-gnus-format (car methods)))
12170 (gnus-groups-to-gnus-format (car methods))))))
12172 (if (not (gnus-request-list (car methods)))
12174 (gnus-message 1 "Cannot read active file from %s server."
12175 (car (car methods)))
12177 (gnus-active-to-gnus-format (car methods))
12178 (setq gnus-have-read-active-file t)
12179 (gnus-message 5 "%sdone" mesg)))))
12180 (setq methods (cdr methods))))))
12182 ;; Read an active file and place the results in `gnus-active-hashtb'.
12183 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12184 (let ((cur (current-buffer))
12186 (if (and gnus-active-hashtb
12187 (not (equal method gnus-select-method)))
12189 (setq gnus-active-hashtb
12190 (if (equal method gnus-select-method)
12191 (gnus-make-hashtable
12192 (count-lines (point-min) (point-max)))
12193 (gnus-make-hashtable 4096)))))))
12194 ;; Delete unnecessary lines.
12195 (goto-char (point-min))
12196 (while (search-forward "\nto." nil t)
12197 (delete-region (1+ (match-beginning 0))
12198 (progn (forward-line 1) (point))))
12199 (or (string= gnus-ignored-newsgroups "")
12201 (goto-char (point-min))
12202 (delete-matching-lines gnus-ignored-newsgroups)))
12203 ;; If these are groups from a foreign select method, we insert the
12204 ;; group prefix in front of the group names.
12205 (and method (not (eq method gnus-select-method))
12206 (let ((prefix (gnus-group-prefixed-name "" method)))
12207 (goto-char (point-min))
12208 (while (and (not (eobp))
12209 (progn (insert prefix)
12210 (zerop (forward-line 1)))))))
12211 (goto-char (point-min))
12212 ;; Store active file in hashtable.
12213 (goto-char (point-min))
12214 (if (string-match "%[oO]" gnus-group-line-format)
12215 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12216 ;; If we want information on moderated groups, we use this
12218 (let* ((mod-hashtb (make-vector 7 0))
12219 (m (intern "m" mod-hashtb))
12221 (while (not (eobp))
12222 (condition-case nil
12224 (narrow-to-region (point) (gnus-point-at-eol))
12225 (setq group (let ((obarray hashtb)) (read cur)))
12226 (if (and (numberp (setq max (read cur)))
12227 (numberp (setq min (read cur))))
12228 (set group (cons min max))
12230 ;; Enter moderated groups into a list.
12231 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12232 (setq gnus-moderated-list
12233 (cons (symbol-name group) gnus-moderated-list))))
12237 ;; And if we do not care about moderation, we use this loop,
12238 ;; which is faster.
12239 (let (group max min)
12240 (while (not (eobp))
12243 (narrow-to-region (point) (gnus-point-at-eol))
12244 ;; group gets set to a symbol interned in the hash table
12246 (setq group (let ((obarray hashtb)) (read cur)))
12247 (if (and (numberp (setq max (read cur)))
12248 (numberp (setq min (read cur))))
12249 (set group (cons min max))
12256 (gnus-message 3 "Warning - illegal active: %s"
12258 (gnus-point-at-bol) (gnus-point-at-eol)))
12261 (forward-line 1))))))
12263 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12264 ;; Parse a "groups" active file.
12265 (let ((cur (current-buffer))
12269 (setq gnus-active-hashtb
12270 (gnus-make-hashtable
12271 (count-lines (point-min) (point-max)))))))
12272 (prefix (and method (not (eq method gnus-select-method))
12273 (gnus-group-prefixed-name "" method))))
12275 (goto-char (point-min))
12277 ;; We split this into to separate loops, one with the prefix
12278 ;; and one without to speed the reading up somewhat.
12280 (let (min max opoint)
12281 (while (not (eobp))
12282 (read cur) (read cur)
12283 (setq min (read cur)
12286 (skip-chars-forward " \t")
12289 (set (let ((obarray hashtb)) (read cur))
12293 (while (not (eobp))
12294 (if (= (following-char) ?2)
12296 (read cur) (read cur)
12297 (setq min (read cur)
12299 (set (let ((obarray hashtb)) (read cur))
12301 (forward-line 1))))
12303 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
12305 (defun gnus-read-newsrc-file (&optional force)
12306 "Read startup file.
12307 If FORCE is non-nil, the .newsrc file is read."
12308 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12309 ;; Reset variables that might be defined in the .newsrc.eld file.
12310 (let ((variables gnus-variable-list))
12312 (set (car variables) nil)
12313 (setq variables (cdr variables))))
12314 (let* ((newsrc-file gnus-current-startup-file)
12315 (quick-file (concat newsrc-file ".el")))
12317 ;; We always load the .newsrc.eld file. If always contains
12318 ;; much information that can not be gotten from the .newsrc
12319 ;; file (ticked articles, killed groups, foreign methods, etc.)
12320 (gnus-read-newsrc-el-file quick-file)
12323 (and (file-newer-than-file-p newsrc-file quick-file)
12324 (file-newer-than-file-p newsrc-file
12325 (concat quick-file "d")))
12326 (not gnus-newsrc-alist))
12327 ;; We read the .newsrc file. Note that if there if a
12328 ;; .newsrc.eld file exists, it has already been read, and
12329 ;; the `gnus-newsrc-hashtb' has been created. While reading
12330 ;; the .newsrc file, Gnus will only use the information it
12331 ;; can find there for changing the data already read -
12332 ;; ie. reading the .newsrc file will not trash the data
12333 ;; already read (except for read articles).
12335 (gnus-message 5 "Reading %s..." newsrc-file)
12336 (set-buffer (find-file-noselect newsrc-file))
12337 (buffer-disable-undo (current-buffer))
12338 (gnus-newsrc-to-gnus-format)
12339 (kill-buffer (current-buffer))
12340 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12342 (defun gnus-read-newsrc-el-file (file)
12343 (let ((ding-file (concat file "d")))
12344 ;; We always, always read the .eld file.
12345 (gnus-message 5 "Reading %s..." ding-file)
12346 (let (gnus-newsrc-assoc)
12347 (condition-case nil
12348 (load ding-file t t t)
12350 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12351 (let ((inhibit-quit t))
12352 (gnus-uncompress-newsrc-alist))
12353 (gnus-make-hashtable-from-newsrc-alist)
12354 (if (not (file-newer-than-file-p file ding-file))
12356 ;; Old format quick file
12357 (gnus-message 5 "Reading %s..." file)
12358 ;; The .el file is newer than the .eld file, so we read that one
12360 (gnus-read-old-newsrc-el-file file))))
12362 ;; Parse the old-style quick startup file
12363 (defun gnus-read-old-newsrc-el-file (file)
12364 (let (newsrc killed marked group m)
12366 (let ((gnus-killed-assoc nil)
12367 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12369 (condition-case nil
12372 (setq newsrc gnus-newsrc-assoc
12373 killed gnus-killed-assoc
12374 marked gnus-marked-assoc)))
12375 (setq gnus-newsrc-alist nil)
12377 (setq group (car newsrc))
12378 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12381 (setcar (nthcdr 2 info) (cdr (cdr group)))
12383 (if (nth 1 group) gnus-level-default-subscribed
12384 gnus-level-default-unsubscribed))
12385 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
12386 (setq gnus-newsrc-alist
12390 (if (nth 1 group) gnus-level-default-subscribed
12391 gnus-level-default-unsubscribed)
12392 (cdr (cdr group))))
12393 gnus-newsrc-alist)))
12394 (if (setq m (assoc (car group) marked))
12395 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12396 (setq newsrc (cdr newsrc)))
12397 (setq newsrc killed)
12399 (setcar newsrc (car (car newsrc)))
12400 (setq newsrc (cdr newsrc)))
12401 (setq gnus-killed-list killed))
12402 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
12403 (gnus-make-hashtable-from-newsrc-alist)))
12405 (defun gnus-make-newsrc-file (file)
12406 "Make server dependent file name by catenating FILE and server host name."
12407 (let* ((file (expand-file-name file nil))
12408 (real-file (concat file "-" (nth 1 gnus-select-method))))
12409 (if (file-exists-p real-file)
12412 (defun gnus-uncompress-newsrc-alist ()
12413 ;; Uncompress all lists of marked articles in the newsrc assoc.
12414 (let ((newsrc gnus-newsrc-alist)
12417 (if (not (setq marked (nth 3 (car newsrc))))
12420 (or (eq 'score (car (car marked)))
12421 (eq 'bookmark (car (car marked)))
12422 (eq 'killed (car (car marked)))
12423 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12424 (setq marked (cdr marked))))
12425 (setq newsrc (cdr newsrc)))))
12427 (defun gnus-compress-newsrc-alist ()
12428 ;; Compress all lists of marked articles in the newsrc assoc.
12429 (let ((newsrc gnus-newsrc-alist)
12432 (if (not (setq marked (nth 3 (car newsrc))))
12435 (or (eq 'score (car (car marked)))
12436 (eq 'bookmark (car (car marked)))
12437 (eq 'killed (car (car marked)))
12438 (setcdr (car marked)
12440 (gnus-compress-sequence
12441 (sort (cdr (car marked)) '<) t)
12442 (error (cdr (car marked))))))
12443 (setq marked (cdr marked))))
12444 (setq newsrc (cdr newsrc)))))
12446 (defun gnus-newsrc-to-gnus-format ()
12447 (setq gnus-newsrc-options "")
12448 (setq gnus-newsrc-options-n nil)
12450 (or gnus-active-hashtb
12451 (setq gnus-active-hashtb (make-vector 4095 0)))
12452 (let ((buf (current-buffer))
12453 (already-read (> (length gnus-newsrc-alist) 1))
12454 group subscribed options-symbol newsrc
12456 (goto-char (point-min))
12457 ;; We intern the symbol `options' in the active hashtb so that we
12458 ;; can `eq' against it later.
12459 (setq options-symbol (intern "options" gnus-active-hashtb))
12461 (while (not (eobp))
12462 ;; We first read the first word on the line by narrowing and
12463 ;; then reading into `gnus-active-hashtb'. Most groups will
12464 ;; already exist in that hashtb, so this will save some string
12468 (progn (skip-chars-forward "^ \t!:\n") (point)))
12469 (goto-char (point-min))
12471 (and (/= (point-min) (point-max))
12472 (let ((obarray gnus-active-hashtb)) (read buf))))
12474 ;; Now, the symbol we have read is either `options' or a group
12475 ;; name. If it is an options line, we just add it to a string.
12477 ((eq symbol options-symbol)
12478 (setq gnus-newsrc-options
12479 ;; This concatting is quite inefficient, but since our
12480 ;; thorough studies show that approx 99.37% of all
12481 ;; .newsrc files only contain a single options line, we
12482 ;; don't give a damn, frankly, my dear.
12483 (concat gnus-newsrc-options
12485 (gnus-point-at-bol)
12486 ;; Options may continue on the next line.
12487 (or (and (re-search-forward "^[^ \t]" nil 'move)
12488 (progn (beginning-of-line) (point)))
12491 ;; It was a group name.
12492 (setq subscribed (= (following-char) ?:)
12493 group (symbol-name symbol)
12496 ;; If the line ends here, this is clearly a buggy line, so
12497 ;; we put point a the beginning of line and let the cond
12498 ;; below do the error handling.
12499 (beginning-of-line)
12500 ;; We skip to the beginning of the ranges.
12501 (skip-chars-forward "!: \t"))
12502 ;; We are now at the beginning of the list of read articles.
12503 ;; We read them range by range.
12506 ((looking-at "[0-9]+")
12507 ;; We narrow and read a number instead of buffer-substring/
12508 ;; string-to-int because it's faster. narrow/widen is
12509 ;; faster than save-restriction/narrow, and save-restriction
12510 ;; produces a garbage object.
12512 (narrow-to-region (match-beginning 0) (match-end 0))
12515 ;; If the next character is a dash, then this is a range.
12516 (if (= (following-char) ?-)
12518 ;; We read the upper bound of the range.
12520 (if (not (looking-at "[0-9]+"))
12521 ;; This is a buggy line, by we pretend that
12522 ;; it's kinda OK. Perhaps the user should be
12524 (setq reads (cons num1 reads))
12528 (narrow-to-region (match-beginning 0)
12533 ;; It was just a simple number, so we add it to the
12535 (setq reads (cons num1 reads)))
12536 ;; If the next char in ?\n, then we have reached the end
12537 ;; of the line and return nil.
12538 (/= (following-char) ?\n))
12539 ((= (following-char) ?\n)
12540 ;; End of line, so we end.
12543 ;; Not numbers and not eol, so this might be a buggy
12545 (or (eobp) ; If it was eob instead of ?\n, we allow it.
12547 ;; The line was buggy.
12549 (gnus-message 3 "Mangled line: %s"
12550 (buffer-substring (gnus-point-at-bol)
12551 (gnus-point-at-eol)))
12555 ;; Skip past ", ". Spaces are illegal in these ranges, but
12556 ;; we allow them, because it's a common mistake to put a
12557 ;; space after the comma.
12558 (skip-chars-forward ", "))
12560 ;; We have already read .newsrc.eld, so we gently update the
12561 ;; data in the hash table with the information we have just
12565 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12568 ;; There is an entry for this file in the alist.
12570 (setcar (nthcdr 2 info) (nreverse reads))
12571 ;; We update the level very gently. In fact, we
12572 ;; only change it if there's been a status change
12573 ;; from subscribed to unsubscribed, or vice versa.
12574 (setq level (nth 1 info))
12575 (cond ((and (<= level gnus-level-subscribed)
12577 (setq level (if reads
12578 gnus-level-default-unsubscribed
12579 (1+ gnus-level-default-unsubscribed))))
12580 ((and (> level gnus-level-subscribed) subscribed)
12581 (setq level gnus-level-default-subscribed)))
12582 (setcar (cdr info) level))
12583 ;; This is a new group.
12584 (setq info (list group
12586 gnus-level-default-subscribed
12588 (1+ gnus-level-subscribed)
12589 gnus-level-default-unsubscribed))
12590 (nreverse reads))))
12591 (setq newsrc (cons info newsrc))))))
12594 (setq newsrc (nreverse newsrc))
12596 (if (not already-read)
12598 ;; We now have two newsrc lists - `newsrc', which is what we
12599 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
12600 ;; what we've read from .newsrc.eld. We have to merge these
12601 ;; lists. We do this by "attaching" any (foreign) groups in the
12602 ;; gnus-newsrc-alist to the (native) group that precedes them.
12603 (let ((rc (cdr gnus-newsrc-alist))
12604 (prev gnus-newsrc-alist)
12607 (or (null (nth 4 (car rc))) ; It's a native group.
12608 (assoc (car (car rc)) newsrc) ; It's already in the alist.
12609 (if (setq entry (assoc (car (car prev)) newsrc))
12610 (setcdr (setq mentry (memq entry newsrc))
12611 (cons (car rc) (cdr mentry)))
12612 (setq newsrc (cons (car rc) newsrc))))
12616 (setq gnus-newsrc-alist newsrc)
12617 ;; We make the newsrc hashtb.
12618 (gnus-make-hashtable-from-newsrc-alist)
12620 ;; Finally, if we read some options lines, we parse them.
12621 (or (string= gnus-newsrc-options "")
12622 (gnus-newsrc-parse-options gnus-newsrc-options))))
12624 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12625 ;; The return value will be a list on the form
12626 ;; ((regexp1 . ignore)
12627 ;; (regexp2 . subscribe)...)
12628 ;; When handling new newsgroups, groups that match a `ignore' regexp
12629 ;; will be ignored, and groups that match a `subscribe' regexp will be
12630 ;; subscribed. A line like
12631 ;; options -n !all rec.all
12632 ;; will lead to a list that looks like
12633 ;; (("^rec\\..+" . subscribe)
12634 ;; ("^.+" . ignore))
12635 ;; So all "rec.*" groups will be subscribed, while all the other
12636 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12637 ;; different from "options -n rec.all !all".
12638 (defun gnus-newsrc-parse-options (options)
12641 (gnus-set-work-buffer)
12642 (insert (regexp-quote options))
12643 ;; First we treat all continuation lines.
12644 (goto-char (point-min))
12645 (while (re-search-forward "\n[ \t]+" nil t)
12646 (replace-match " " t t))
12647 ;; Then we transform all "all"s into ".+"s.
12648 (goto-char (point-min))
12649 (while (re-search-forward "\\ball\\b" nil t)
12650 (replace-match ".+" t t))
12651 (goto-char (point-min))
12652 ;; We remove all other options than the "-n" ones.
12653 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12654 (replace-match " ")
12656 (goto-char (point-min))
12658 ;; We are only interested in "options -n" lines - we
12659 ;; ignore the other option lines.
12660 (while (re-search-forward "[ \t]-n" nil t)
12662 (or (save-excursion
12663 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12665 (gnus-point-at-eol)))
12666 ;; Search for all "words"...
12667 (while (re-search-forward "[^ \t,\n]+" eol t)
12668 (if (= (char-after (match-beginning 0)) ?!)
12669 ;; If the word begins with a bang (!), this is a "not"
12670 ;; spec. We put this spec (minus the bang) and the
12671 ;; symbol `ignore' into the list.
12672 (setq out (cons (cons (concat
12673 "^" (buffer-substring
12674 (1+ (match-beginning 0))
12677 ;; There was no bang, so this is a "yes" spec.
12678 (setq out (cons (cons (concat
12679 "^" (buffer-substring (match-beginning 0)
12681 'subscribe) out)))))
12683 (setq gnus-newsrc-options-n out))))
12686 (defun gnus-save-newsrc-file ()
12687 "Save .newsrc file."
12688 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12689 ;; from the variable gnus-newsrc-alist.
12690 (and (or gnus-newsrc-alist gnus-killed-list)
12691 gnus-current-startup-file
12693 (run-hooks 'gnus-save-newsrc-hook)
12695 (if (or (not gnus-dribble-buffer)
12696 (not (buffer-name gnus-dribble-buffer))
12697 (zerop (save-excursion
12698 (set-buffer gnus-dribble-buffer)
12700 (gnus-message 4 "(No changes need to be saved)")
12701 (if gnus-save-newsrc-file
12703 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12704 ;; Make backup file of master newsrc.
12705 (gnus-gnus-to-newsrc-format)
12706 (gnus-message 5 "Saving %s...done"
12707 gnus-current-startup-file)))
12708 ;; Quickly loadable .newsrc.
12709 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12710 (set-visited-file-name (concat gnus-current-startup-file ".eld"))
12711 (gnus-add-current-to-buffer-list)
12712 (buffer-disable-undo (current-buffer))
12714 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12715 (gnus-gnus-to-quick-newsrc-format)
12717 (kill-buffer (current-buffer))
12718 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
12719 (gnus-dribble-delete-file))))))
12721 (defun gnus-gnus-to-quick-newsrc-format ()
12722 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12723 (insert ";; (ding) Gnus startup file.\n")
12724 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12725 (insert ";; to read .newsrc.\n")
12726 (let ((variables gnus-variable-list)
12728 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12730 ;; insert lisp expressions.
12731 (gnus-compress-newsrc-alist)
12733 (setq variable (car variables))
12734 (and (boundp variable)
12735 (symbol-value variable)
12736 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12737 (insert "(setq " (symbol-name variable) " '"
12738 (prin1-to-string (symbol-value variable))
12740 (setq variables (cdr variables)))
12741 (gnus-uncompress-newsrc-alist)))
12744 (defun gnus-gnus-to-newsrc-format ()
12745 ;; Generate and save the .newsrc file.
12746 (let ((newsrc (cdr gnus-newsrc-alist))
12749 (set-buffer (create-file-buffer gnus-startup-file))
12750 (set-visited-file-name gnus-startup-file)
12751 (buffer-disable-undo (current-buffer))
12754 (if gnus-newsrc-options (insert gnus-newsrc-options))
12755 ;; Write subscribed and unsubscribed.
12757 (setq info (car newsrc))
12758 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12760 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12762 (if (setq ranges (nth 2 info))
12765 (if (not (listp (cdr ranges)))
12766 (if (= (car ranges) (cdr ranges))
12767 (insert (int-to-string (car ranges)))
12768 (insert (int-to-string (car ranges)) "-"
12769 (int-to-string (cdr ranges))))
12771 (setq range (car ranges)
12772 ranges (cdr ranges))
12773 (if (or (atom range) (= (car range) (cdr range)))
12774 (insert (int-to-string
12775 (or (and (atom range) range)
12777 (insert (int-to-string (car range)) "-"
12778 (int-to-string (cdr range))))
12779 (if ranges (insert ","))))))
12781 (setq newsrc (cdr newsrc)))
12783 (kill-buffer (current-buffer)))))
12785 (defun gnus-read-all-descriptions-files ()
12786 (let ((methods (nconc (list gnus-select-method)
12787 gnus-secondary-select-methods)))
12789 (gnus-read-descriptions-file (car methods))
12790 (setq methods (cdr methods)))
12793 (defun gnus-read-descriptions-file (&optional method)
12794 (let ((method (or method gnus-select-method)))
12795 ;; We create the hashtable whether we manage to read the desc file
12796 ;; to avoid trying to re-read after a failed read.
12797 (or gnus-description-hashtb
12798 (setq gnus-description-hashtb
12799 (gnus-make-hashtable (length gnus-active-hashtb))))
12800 ;; Mark this method's desc file as read.
12801 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
12802 gnus-description-hashtb)
12804 (gnus-message 5 "Reading descriptions file via %s..." (car method))
12806 ((not (or (gnus-server-opened method)
12807 (gnus-open-server method)))
12808 (gnus-message 1 "Couldn't open server")
12810 ((not (gnus-request-list-newsgroups method))
12811 (gnus-message 1 "Couldn't read newsgroups descriptions")
12817 (set-buffer nntp-server-buffer)
12818 (goto-char (point-min))
12819 (if (or (search-forward "\n.\n" nil t)
12820 (goto-char (point-max)))
12822 (beginning-of-line)
12823 (narrow-to-region (point-min) (point))))
12824 (goto-char (point-min))
12825 (while (not (eobp))
12826 ;; If we get an error, we set group to 0, which is not a
12830 (let ((obarray gnus-description-hashtb))
12831 ;; Group is set to a symbol interned in this
12833 (read nntp-server-buffer))
12835 (skip-chars-forward " \t")
12836 ;; ... which leads to this line being effectively ignored.
12837 (and (symbolp group)
12838 (set group (buffer-substring
12839 (point) (progn (end-of-line) (point)))))
12840 (forward-line 1))))
12841 (gnus-message 5 "Reading descriptions file...done")
12844 (defun gnus-group-get-description (group)
12845 ;; Get the description of a group by sending XGTITLE to the server.
12846 (and (gnus-request-group-description group)
12848 (set-buffer nntp-server-buffer)
12849 (goto-char (point-min))
12850 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12851 (buffer-substring (match-beginning 1) (match-end 1))))))
12857 (defvar gnus-server-mode-hook nil
12858 "Hook run in `gnus-server-mode' buffers.")
12860 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12861 "Format of server lines.
12862 It works along the same lines as a normal formatting string,
12863 with some simple extensions.")
12865 (defvar gnus-server-mode-line-format "(ding) List of servers"
12866 "The format specification for the server mode line.")
12868 (defconst gnus-server-line-format-alist
12869 (list (list ?h 'how ?s)
12871 (list ?w 'where ?s)
12874 (defconst gnus-server-mode-line-format-alist
12875 (list (list ?S 'news-server ?s)
12876 (list ?M 'news-method ?s)
12877 (list ?u 'user-defined ?s)))
12879 (defvar gnus-server-line-format-spec nil)
12880 (defvar gnus-server-mode-line-format-spec nil)
12881 (defvar gnus-server-killed-servers nil)
12883 (defvar gnus-server-mode-map nil)
12884 (put 'gnus-server-mode 'mode-class 'special)
12886 (if gnus-server-mode-map
12888 (setq gnus-server-mode-map (make-sparse-keymap))
12889 (suppress-keymap gnus-server-mode-map)
12890 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12891 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12892 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12893 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12894 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12895 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12896 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12897 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12898 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12899 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12901 (defun gnus-server-mode ()
12902 "Major mode for listing and editing servers.
12904 All normal editing commands are switched off.
12905 \\<gnus-server-mode-map>
12907 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12909 The following commands are available:
12911 \\{gnus-server-mode-map}"
12913 (if gnus-visual (gnus-server-make-menu-bar))
12914 (kill-all-local-variables)
12915 (setq mode-line-modified "-- ")
12916 (make-local-variable 'mode-line-format)
12917 (setq mode-line-format (copy-sequence mode-line-format))
12918 (and (equal (nth 3 mode-line-format) " ")
12919 (setcar (nthcdr 3 mode-line-format) ""))
12920 (setq major-mode 'gnus-server-mode)
12921 (setq mode-name "Server")
12922 ; (gnus-group-set-mode-line)
12923 (setq mode-line-process nil)
12924 (use-local-map gnus-server-mode-map)
12925 (buffer-disable-undo (current-buffer))
12926 (setq truncate-lines t)
12927 (setq buffer-read-only t)
12928 (run-hooks 'gnus-server-mode-hook))
12930 (defun gnus-server-insert-server-line (sformat name method)
12931 (let* ((sformat (or sformat gnus-server-line-format-spec))
12933 (where (nth 1 method))
12935 (beginning-of-line)
12937 ;; Insert the text.
12938 (insert (eval sformat))
12939 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
12941 (defun gnus-server-setup-buffer ()
12942 (if (get-buffer gnus-server-buffer)
12945 (set-buffer (get-buffer-create gnus-server-buffer))
12947 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
12949 (defun gnus-server-prepare ()
12950 (setq gnus-server-mode-line-format-spec
12951 (gnus-parse-format gnus-server-mode-line-format
12952 gnus-server-mode-line-format-alist))
12953 (setq gnus-server-line-format-spec
12954 (gnus-parse-format gnus-server-line-format
12955 gnus-server-line-format-alist))
12956 (let ((alist gnus-server-alist)
12957 (buffer-read-only nil))
12960 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
12961 (setq alist (cdr alist))))
12962 (goto-char (point-min))
12963 (gnus-server-position-cursor))
12965 (defun gnus-server-server-name ()
12966 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
12967 (and server (symbol-name server))))
12969 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
12971 (defconst gnus-server-edit-buffer "*Gnus edit server*")
12973 (defun gnus-server-update-server (server)
12975 (set-buffer gnus-server-buffer)
12976 (let ((buffer-read-only nil)
12977 (info (cdr (assoc server gnus-server-alist))))
12978 (gnus-dribble-enter
12979 (concat "(gnus-server-set-info \"" server "\" '"
12980 (prin1-to-string info) ")"))
12981 ;; Buffer may be narrowed.
12984 (if (gnus-server-goto-server server)
12985 (delete-region (progn (beginning-of-line) (point))
12986 (progn (forward-line 1) (point))))
12987 (let ((entry (assoc server gnus-server-alist)))
12988 (gnus-server-insert-server-line nil (car entry) (cdr entry))
12989 (gnus-server-position-cursor))))))
12991 (defun gnus-server-set-info (server info)
12992 ;; Enter a select method into the virtual server alist.
12993 (gnus-dribble-enter
12994 (concat "(gnus-server-set-info \"" server "\" '"
12995 (prin1-to-string info) ")"))
12996 (let* ((server (nth 1 info))
12997 (entry (assoc server gnus-server-alist)))
12998 (if entry (setcdr entry info)
12999 (setq gnus-server-alist
13000 (nconc gnus-server-alist (list (cons server info)))))))
13002 (defun gnus-server-to-method (server)
13003 ;; Map virtual server names to select methods.
13004 (or (and (equal server "native") gnus-select-method)
13005 (cdr (assoc server gnus-server-alist))))
13007 (defun gnus-server-extend-method (group method)
13008 ;; This function "extends" a virtual server. If the server is
13009 ;; "hello", and the select method is ("hello" (my-var "something"))
13010 ;; in the group "alt.alt", this will result in a new virtual server
13011 ;; called "helly+alt.alt".
13013 (gnus-copy-sequence
13014 (if (equal (car method) "native") gnus-select-method
13015 (cdr (assoc (car method) gnus-server-alist))))))
13016 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13017 (nconc entry (cdr method))))
13019 (defun gnus-server-get-method (group method)
13020 ;; Input either a server name, and extended server name, or a
13021 ;; select method, and return a select method.
13022 (cond ((stringp method)
13023 (gnus-server-to-method method))
13024 ((stringp (car method))
13025 (gnus-server-extend-method group method))
13027 (gnus-server-add-address method))))
13029 (defun gnus-server-add-address (method)
13030 (let ((method-name (symbol-name (car method))))
13031 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13032 (not (assq (intern (concat method-name "-address")) method)))
13033 (append method (list (list (intern (concat method-name "-address"))
13037 (defun gnus-server-equal (s1 s2)
13039 (and (= (length s1) (length s2))
13041 (while (and s1 (member (car s1) s2))
13042 (setq s1 (cdr s1)))
13045 ;;; Interactive server functions.
13047 (defun gnus-server-kill-server (server)
13048 "Kill the server on the current line."
13049 (interactive (list (gnus-server-server-name)))
13050 (or (gnus-server-goto-server server)
13051 (if server (error "No such server: %s" server)
13052 (error "No server on the current line")))
13053 (let ((buffer-read-only nil))
13054 (delete-region (progn (beginning-of-line) (point))
13055 (progn (forward-line 1) (point))))
13056 (setq gnus-server-killed-servers
13057 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13058 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13059 gnus-server-alist))
13060 (gnus-server-position-cursor))
13062 (defun gnus-server-yank-server ()
13063 "Yank the previously killed server."
13065 (or gnus-server-killed-servers
13066 (error "No killed servers to be yanked"))
13067 (let ((alist gnus-server-alist)
13068 (server (gnus-server-server-name))
13069 (killed (car gnus-server-killed-servers)))
13071 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13072 (if (string= server (car (car gnus-server-alist)))
13073 (setq gnus-server-alist (cons killed gnus-server-alist))
13074 (while (and (cdr alist)
13075 (not (string= server (car (car (cdr alist))))))
13076 (setq alist (cdr alist)))
13077 (setcdr alist (cons killed (cdr alist)))))
13078 (gnus-server-update-server (car killed))
13079 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13080 (gnus-server-position-cursor)))
13082 (defun gnus-server-exit ()
13083 "Return to the group buffer."
13085 (kill-buffer (current-buffer))
13086 (switch-to-buffer gnus-group-buffer))
13088 (defun gnus-server-list-servers ()
13089 "List all available servers."
13091 (let ((cur (gnus-server-server-name)))
13092 (gnus-server-prepare)
13093 (if cur (gnus-server-goto-server cur)
13094 (goto-char (point-max))
13096 (gnus-server-position-cursor)))
13098 (defun gnus-server-copy-server (from to)
13101 (or (gnus-server-server-name)
13102 (error "No server on the current line"))
13103 (read-string "Copy to: ")))
13104 (or from (error "No server on current line"))
13105 (or (and to (not (string= to ""))) (error "No name to copy to"))
13106 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13107 (or (assoc from gnus-server-alist)
13108 (error "%s: no such server" from))
13109 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13110 (setcar to-entry to)
13111 (setcar (nthcdr 2 to-entry) to)
13112 (setq gnus-server-killed-servers
13113 (cons to-entry gnus-server-killed-servers))
13114 (gnus-server-yank-server)))
13116 (defun gnus-server-add-server (how where)
13118 (list (intern (completing-read "Server method: "
13119 gnus-valid-select-methods nil t))
13120 (read-string "Server name: ")))
13121 (setq gnus-server-killed-servers
13122 (cons (list where how where) gnus-server-killed-servers))
13123 (gnus-server-yank-server))
13125 (defun gnus-server-goto-server (server)
13126 "Jump to a server line."
13128 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13129 (let ((to (text-property-any (point-min) (point-max)
13130 'gnus-server (intern server))))
13134 (gnus-server-position-cursor)))))
13136 (defun gnus-server-edit-server (server)
13137 "Edit the server on the current line."
13138 (interactive (list (gnus-server-server-name)))
13140 (error "No server on current line"))
13141 (let ((winconf (current-window-configuration)))
13142 (get-buffer-create gnus-server-edit-buffer)
13143 (gnus-configure-windows 'edit-server)
13144 (gnus-add-current-to-buffer-list)
13146 (make-local-variable 'gnus-prev-winconf)
13147 (setq gnus-prev-winconf winconf)
13148 (use-local-map (copy-keymap (current-local-map)))
13149 (let ((done-func '(lambda ()
13150 "Exit editing mode and update the information."
13152 (gnus-server-edit-server-done 'group))))
13153 (setcar (cdr (nth 4 done-func)) server)
13154 (local-set-key "\C-c\C-c" done-func))
13156 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13157 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13159 (defun gnus-server-edit-server-done (server)
13161 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13162 (goto-char (point-min))
13163 (let ((form (read (current-buffer)))
13164 (winconf gnus-prev-winconf))
13165 (gnus-server-set-info server form)
13166 (kill-buffer (current-buffer))
13167 (and winconf (set-window-configuration winconf))
13168 (set-buffer gnus-server-buffer)
13169 (gnus-server-update-server (gnus-server-server-name))
13170 (gnus-server-position-cursor)))
13172 (defun gnus-server-read-server (server)
13174 (interactive (list (gnus-server-server-name)))
13175 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13177 (defun gnus-mouse-pick-server (e)
13179 (mouse-set-point e)
13180 (gnus-server-read-server (gnus-server-server-name)))
13183 ;;; entry points into gnus-score.el
13186 ;;; Finding score files.
13188 (defvar gnus-global-score-files nil
13189 "*List of global score files and directories.
13190 Set this variable if you want to use people's score files. One entry
13191 for each score file or each score file directory. Gnus will decide
13192 by itself what score files are applicable to which group.
13194 Say you want to use the single score file
13195 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13196 score files in the \"/ftp.some-where:/pub/score\" directory.
13198 (setq gnus-global-score-files
13199 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13200 \"/ftp.some-where:/pub/score\"))")
13202 (defun gnus-score-score-files (group)
13203 "Return a list of all possible score files."
13204 ;; Search and set any global score files.
13205 (and gnus-global-score-files
13206 (or gnus-internal-global-score-files
13207 (gnus-score-search-global-directories gnus-global-score-files)))
13208 ;; Fix the kill-file dir variable.
13209 (setq gnus-kill-files-directory
13210 (file-name-as-directory
13211 (or gnus-kill-files-directory "~/News/")))
13212 ;; If we can't read it, there are no score files.
13213 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13214 (setq gnus-score-file-list nil)
13215 (if (gnus-use-long-file-name 'not-score)
13216 ;; We want long file names.
13217 (if (or (not gnus-score-file-list)
13218 (not (car gnus-score-file-list))
13219 (gnus-file-newer-than gnus-kill-files-directory
13220 (car gnus-score-file-list)))
13221 (setq gnus-score-file-list
13222 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13225 gnus-kill-files-directory t
13226 (gnus-score-file-regexp))))))
13227 ;; We do not use long file names, so we have to do some
13228 ;; directory traversing.
13229 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13230 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13233 (setq dir (expand-file-name
13234 (concat gnus-kill-files-directory
13235 (gnus-replace-chars-in-string group ?. ?/))))
13236 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13237 (setq suffix (car suffixes)
13238 suffixes (cdr suffixes))
13239 (if (file-exists-p (concat dir "/" suffix))
13240 (setq files (cons (concat dir "/" suffix) files)))
13241 (while (>= (1+ (length dir)) mdir)
13242 (and (file-exists-p (concat dir "/all/" suffix))
13243 (setq files (cons (concat dir "/all/" suffix) files)))
13244 (string-match "/[^/]*$" dir)
13245 (setq dir (substring dir 0 (match-beginning 0)))))
13246 (setq gnus-score-file-list
13247 (cons nil (nreverse files)))))
13248 (cdr gnus-score-file-list)))
13250 (defun gnus-score-file-regexp ()
13251 (concat "\\(" gnus-score-file-suffix
13252 "\\|" gnus-adaptive-file-suffix "\\)$"))
13254 (defun gnus-score-find-bnews (group)
13255 "Return a list of score files for GROUP.
13256 The score files are those files in the ~/News directory which matches
13257 GROUP using BNews sys file syntax."
13258 (let* ((sfiles (append (gnus-score-score-files group)
13259 gnus-internal-global-score-files))
13260 (kill-dir (file-name-as-directory
13261 (expand-file-name gnus-kill-files-directory)))
13262 (klen (length kill-dir))
13263 ofiles not-match regexp)
13265 (set-buffer (get-buffer-create "*gnus score files*"))
13266 (buffer-disable-undo (current-buffer))
13267 ;; Go through all score file names and create regexp with them
13271 (insert (car sfiles))
13272 (goto-char (point-min))
13273 ;; First remove the suffix itself.
13274 (re-search-forward (concat "." (gnus-score-file-regexp)))
13275 (replace-match "" t t)
13276 (goto-char (point-min))
13277 (if (looking-at (regexp-quote kill-dir))
13278 ;; If the file name was just "SCORE", `klen' is one character
13280 (delete-char (min (1- (point-max)) klen))
13281 (goto-char (point-max))
13282 (search-backward "/")
13283 (delete-region (1+ (point)) (point-min)))
13284 ;; If short file names were used, we have to translate slashes.
13285 (goto-char (point-min))
13286 (while (re-search-forward "[/:]" nil t)
13287 (replace-match "." t t))
13288 ;; Translate "all" to ".*".
13289 (while (search-forward "all" nil t)
13290 (replace-match ".*" t t))
13291 (goto-char (point-min))
13292 ;; Deal with "not."s.
13293 (if (looking-at "not.")
13296 (setq regexp (buffer-substring 5 (point-max))))
13297 (setq regexp (buffer-substring 1 (point-max)))
13298 (setq not-match nil))
13299 ;; Finally - if this resulting regexp matches the group name,
13300 ;; we add this score file to the list of score files
13301 ;; applicable to this group.
13302 (if (or (and not-match
13303 (not (string-match regexp group)))
13304 (and (not not-match)
13305 (string-match regexp group)))
13306 (setq ofiles (cons (car sfiles) ofiles)))
13307 (setq sfiles (cdr sfiles)))
13308 (kill-buffer (current-buffer))
13309 ;; Slight kludge here - the last score file returned should be
13310 ;; the local score file, whether it exists or not. This is so
13311 ;; that any score commands the user enters will go to the right
13312 ;; file, and not end up in some global score file.
13315 (if (gnus-use-long-file-name 'not-score)
13316 (concat gnus-kill-files-directory group "."
13317 gnus-score-file-suffix)
13318 (concat gnus-kill-files-directory
13319 (gnus-replace-chars-in-string group ?. ?/)
13320 "/" gnus-score-file-suffix)))))
13321 (and (member localscore ofiles)
13322 (delete localscore ofiles))
13323 (setq ofiles (cons localscore ofiles)))
13324 (nreverse ofiles))))
13326 (defun gnus-score-find-single (group)
13327 "Return list containing the score file for GROUP."
13328 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13329 (gnus-score-file-name group)))
13331 (defun gnus-score-find-hierarchical (group)
13332 "Return list of score files for GROUP.
13333 This includes the score file for the group and all its parents."
13334 (let ((all (copy-sequence '(nil)))
13336 (while (string-match "\\." group (1+ start))
13337 (setq start (match-beginning 0))
13338 (setq all (cons (substring group 0 start) all)))
13339 (setq all (cons group all))
13341 (mapcar (lambda (newsgroup)
13342 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
13343 (setq all (nreverse all)))
13344 (mapcar 'gnus-score-file-name all))))
13346 (defvar gnus-score-file-alist-cache nil)
13348 (defun gnus-score-find-alist (group)
13349 "Return list of score files for GROUP.
13350 The list is determined from the variable gnus-score-file-alist."
13351 (let ((alist gnus-score-file-multiple-match-alist)
13353 ;; if this group has been seen before, return the cached entry
13354 (if (setq score-files (assoc group gnus-score-file-alist-cache))
13355 (cdr score-files) ; ensures caching of groups with no matches
13356 ;; handle the multiple match alist
13358 (and (string-match (car (car alist)) group)
13360 (nconc score-files (cdr (car alist)))))
13361 (setq alist (cdr alist)))
13362 (setq alist gnus-score-file-single-match-alist)
13363 ;; handle the single match alist
13366 (and (string-match (car (car alist)) group)
13367 ;; progn used just in case ("regexp") has no files
13368 ;; and score-files is still nil. -sj
13369 ;; this can be construed as a "stop searching here" feature :>
13370 ;; and used to simplify regexps in the single-alist
13373 (append score-files (cdr (car alist))))
13374 (throw 'done nil)))
13375 (setq alist (cdr alist))))
13376 ;; cache the score files
13377 (setq gnus-score-file-alist-cache
13378 (cons (cons group score-files) gnus-score-file-alist-cache))
13382 (defun gnus-possibly-score-headers (&optional trace)
13383 (let ((func gnus-score-find-score-files-function)
13385 (and func (not (listp func))
13386 (setq func (list func)))
13387 ;; Go through all the functions for finding score files (or actual
13388 ;; scores) and add them to a list.
13389 (setq score-files (copy-sequence
13390 (gnus-score-find-alist gnus-newsgroup-name)))
13392 (and (symbolp (car func))
13393 (fboundp (car func))
13395 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
13396 (setq func (cdr func)))
13397 (if score-files (gnus-score-headers score-files trace))))
13399 (defun gnus-score-file-name (newsgroup &optional suffix)
13400 "Return the name of a score file for NEWSGROUP."
13401 (let ((suffix (or suffix gnus-score-file-suffix)))
13402 (cond ((or (null newsgroup)
13403 (string-equal newsgroup ""))
13404 ;; The global score file is placed at top of the directory.
13406 suffix (or gnus-kill-files-directory "~/News")))
13407 ((gnus-use-long-file-name 'not-score)
13408 ;; Append ".SCORE" to newsgroup name.
13409 (expand-file-name (concat newsgroup "." suffix)
13410 (or gnus-kill-files-directory "~/News")))
13412 ;; Place "SCORE" under the hierarchical directory.
13413 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13415 (or gnus-kill-files-directory "~/News"))))))
13417 (defun gnus-score-search-global-directories (files)
13418 "Scan all global score directories for score files."
13419 ;; Set the variable `gnus-internal-global-score-files' to all
13420 ;; available global score files.
13421 (interactive (list gnus-global-score-files))
13424 (if (string-match "/$" (car files))
13425 (setq out (nconc (directory-files
13427 (concat (gnus-score-file-regexp) "$"))))
13428 (setq out (cons (car files) out)))
13429 (setq files (cdr files)))
13430 (setq gnus-internal-global-score-files out)))
13432 ;; Allow redefinition of Gnus functions.
13434 (gnus-ems-redefine)
13438 ;;; gnus.el ends here