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 ?D
786 "*Mark used for del'd articles.")
787 (defvar gnus-read-mark ?d
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 ?R
800 "*Mark used for articles that have been replied to.")
801 (defvar gnus-process-mark ?#
803 (defvar gnus-ancient-mark ?A
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 (defvar gnus-open-server-hook nil
1079 "*A hook called just before opening connection to the news server.")
1081 (defvar gnus-startup-hook nil
1082 "*A hook called at startup.
1083 This hook is called after Gnus is connected to the NNTP server.")
1085 (defvar gnus-get-new-news-hook nil
1086 "*A hook run just before Gnus checks for new news.")
1088 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1089 "*A function that is called to generate the group buffer.
1090 The function is called with three arguments: The first is a number;
1091 all group with a level less or equal to that number should be listed,
1092 if the second is non-nil, empty groups should also be displayed. If
1093 the third is non-nil, it is a number. No groups with a level lower
1094 than this number should be displayed.
1096 The only current function implemented is `gnus-group-prepare-flat'.")
1098 (defvar gnus-group-prepare-hook nil
1099 "*A hook called after the group buffer has been generated.
1100 If you want to modify the group buffer, you can use this hook.")
1102 (defvar gnus-summary-prepare-hook nil
1103 "*A hook called after the summary buffer has been generated.
1104 If you want to modify the summary buffer, you can use this hook.")
1106 (defvar gnus-article-prepare-hook nil
1107 "*A hook called after an article has been prepared in the article buffer.
1108 If you want to run a special decoding program like nkf, use this hook.")
1110 (defvar gnus-article-display-hook nil
1111 "*A hook called after the article is displayed in the article buffer.
1112 The hook is designed to change the contents of the article
1113 buffer. Typical functions that this hook may contain are
1114 `gnus-article-hide-headers' (hide selected headers),
1115 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1116 `gnus-article-hide-signature' (hide signature) and
1117 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1118 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1119 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1121 (defvar gnus-article-x-face-command
1122 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1123 "String or function to be executed to display an X-Face header.
1124 If it is a string, the command will be executed in a sub-shell
1125 asynchronously. The compressed face will be piped to this command.")
1127 (defvar gnus-article-x-face-too-ugly nil
1128 "Regexp matching posters whose face shouldn't be shown automatically.")
1130 (defvar gnus-select-group-hook nil
1131 "*A hook called when a newsgroup is selected.
1133 If you'd like to simplify subjects like the
1134 `gnus-summary-next-same-subject' command does, you can use the
1137 (setq gnus-select-group-hook
1140 (mapcar (lambda (header)
1143 (gnus-simplify-subject
1144 (header-subject header) 're-only)))
1145 gnus-newsgroup-headers))))")
1147 (defvar gnus-select-article-hook
1148 '(gnus-summary-show-thread)
1149 "*A hook called when an article is selected.
1150 The default hook shows conversation thread subtrees of the selected
1151 article automatically using `gnus-summary-show-thread'.")
1153 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1154 "*A hook called to apply kill files to a group.
1155 This hook is intended to apply a kill file to the selected newsgroup.
1156 The function `gnus-apply-kill-file' is called by default.
1158 Since a general kill file is too heavy to use only for a few
1159 newsgroups, I recommend you to use a lighter hook function. For
1160 example, if you'd like to apply a kill file to articles which contains
1161 a string `rmgroup' in subject in newsgroup `control', you can use the
1164 \(setq gnus-apply-kill-hook
1167 (cond ((string-match \"control\" gnus-newsgroup-name)
1168 (gnus-kill \"Subject\" \"rmgroup\")
1169 (gnus-expunge \"X\"))))))")
1171 (defvar gnus-visual-mark-article-hook
1172 (list 'gnus-highlight-selected-summary)
1173 "*Hook run after selecting an article in the summary buffer.
1174 It is meant to be used for highlighting the article in some way. It
1175 is not run if `gnus-visual' is nil.")
1177 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1178 "*A hook called after preparing body, but before preparing header headers.
1179 The default hook (`gnus-inews-insert-signature') inserts a signature
1180 file specified by the variable `gnus-signature-file'.")
1182 (defvar gnus-exit-group-hook nil
1183 "*A hook called when exiting (not quitting) summary mode.")
1185 (defvar gnus-suspend-gnus-hook nil
1186 "*A hook called when suspending (not exiting) Gnus.")
1188 (defvar gnus-exit-gnus-hook nil
1189 "*A hook called when exiting Gnus.")
1191 (defvar gnus-save-newsrc-hook nil
1192 "*A hook called when saving the newsrc file.")
1194 (defvar gnus-summary-update-hook
1195 (list 'gnus-summary-highlight-line)
1196 "*A hook called when a summary line is changed.
1197 The hook will not be called if `gnus-visual' is nil.
1199 The default function `gnus-summary-highlight-line' will
1200 highlight the line according to the `gnus-summary-highlight'
1203 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1204 "*A hook called when an article is selected for the first time.
1205 The hook is intended to mark an article as read (or unread)
1206 automatically when it is selected.")
1209 ;; Internal variables
1211 ;; Avoid highlighting in kill files.
1212 (defvar gnus-summary-inhibit-highlight nil)
1213 (defvar gnus-newsgroup-selected-overlay nil)
1215 (defvar gnus-article-mode-map nil)
1216 (defvar caesar-translate-table nil)
1217 (defvar gnus-dribble-buffer nil)
1218 (defvar gnus-headers-retrieved-by nil)
1219 (defvar gnus-article-reply nil)
1220 (defvar gnus-override-method nil)
1221 (defvar gnus-article-check-size nil)
1223 (defvar gnus-current-score-file nil)
1224 (defvar gnus-internal-global-score-files nil)
1225 (defvar gnus-score-file-list nil)
1228 (defvar gnus-current-move-group nil)
1230 (defvar gnus-newsgroup-dependencies nil)
1231 (defvar gnus-newsgroup-threads nil)
1232 (defvar gnus-newsgroup-async nil)
1233 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1235 (defvar gnus-newsgroup-adaptive nil)
1237 (defvar gnus-summary-display-table nil)
1239 (defconst gnus-group-line-format-alist
1240 (list (list ?M 'marked ?c)
1241 (list ?S 'subscribed ?c)
1243 (list ?N 'number ?s)
1244 (list ?I 'number-of-dormant ?d)
1245 (list ?T 'number-of-ticked ?d)
1246 (list ?R 'number-of-read ?s)
1247 (list ?t 'number-total ?d)
1248 (list ?y 'number-of-unread-unticked ?s)
1249 (list ?i 'number-of-ticked-and-dormant ?d)
1251 (list ?G 'qualified-group ?s)
1252 (list ?D 'newsgroup-description ?s)
1253 (list ?o 'moderated ?c)
1254 (list ?O 'moderated-string ?s)
1255 (list ?p 'process-marked ?c)
1256 (list ?s 'news-server ?s)
1257 (list ?n 'news-method ?s)
1258 (list ?z 'news-method-string ?s)
1259 (list ?u 'user-defined ?s)))
1261 (defconst gnus-summary-line-format-alist
1262 (list (list ?N 'number ?d)
1263 (list ?S 'subject ?s)
1264 (list ?s 'subject-or-nil ?s)
1266 (list ?A 'address ?s)
1268 (list ?x (macroexpand '(header-xref header)) ?s)
1269 (list ?D (macroexpand '(header-date header)) ?s)
1270 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1271 (list ?M (macroexpand '(header-id header)) ?s)
1272 (list ?r (macroexpand '(header-references header)) ?s)
1273 (list ?c '(or (header-chars header) 0) ?d)
1275 (list ?I 'indentation ?s)
1276 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1277 (list ?R 'replied ?c)
1278 (list ?\[ 'opening-bracket ?c)
1279 (list ?\] 'closing-bracket ?c)
1280 (list ?\> '(make-string level ? ) ?s)
1281 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1283 (list ?z 'score-char ?c)
1284 (list ?U 'unread ?c)
1285 (list ?t '(gnus-summary-number-of-articles-in-thread
1286 (or (prog1 gnus-tmp-adopt-thread
1287 (setq gnus-tmp-adopt-thread nil))
1288 (if (boundp 'thread) (symbol-value 'thread)
1291 (list ?e '(gnus-summary-number-of-articles-in-thread
1292 (or gnus-tmp-adopt-thread
1293 (if (boundp 'thread) (symbol-value 'thread)
1296 (list ?u 'user-defined ?s))
1297 "An alist of format specifications that can appear in summary lines,
1298 and what variables they correspond with, along with the type of the
1299 variable (string, integer, character, etc).")
1301 (defconst gnus-summary-dummy-line-format-alist
1302 (list (list ?S 'subject ?s)
1303 (list ?N 'number ?d)
1304 (list ?u 'user-defined ?s)))
1306 (defconst gnus-summary-mode-line-format-alist
1307 (list (list ?G 'group-name ?s)
1308 (list ?g '(gnus-short-group-name group-name) ?s)
1309 (list ?A 'article-number ?d)
1310 (list ?Z 'unread-and-unselected ?s)
1311 (list ?V 'gnus-version ?s)
1312 (list ?U 'unread ?d)
1313 (list ?S 'subject ?s)
1314 (list ?e 'unselected ?d)
1315 (list ?u 'user-defined ?s)
1316 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1318 (defconst gnus-group-mode-line-format-alist
1319 (list (list ?S 'news-server ?s)
1320 (list ?M 'news-method ?s)
1321 (list ?u 'user-defined ?s)))
1323 (defvar gnus-have-read-active-file nil)
1325 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls & Boys)"
1326 "The mail address of the Gnus maintainers.")
1328 (defconst gnus-version "(ding) Gnus v0.92"
1329 "Version number for this version of Gnus.")
1331 (defvar gnus-info-nodes
1332 '((gnus-group-mode "(gnus)The Group Buffer")
1333 (gnus-summary-mode "(gnus)The Summary Buffer")
1334 (gnus-article-mode "(gnus)The Article Buffer"))
1335 "Assoc list of major modes and related Info nodes.")
1337 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1338 "The location of the (ding) Gnus documentation group.")
1340 (defvar gnus-group-buffer "*Group*")
1341 (defvar gnus-summary-buffer "*Summary*")
1342 (defvar gnus-article-buffer "*Article*")
1343 (defvar gnus-server-buffer "*Server*")
1345 (defvar gnus-work-buffer " *gnus work*")
1347 (defvar gnus-buffer-list nil
1348 "Gnus buffers that should be killed on exit.")
1350 (defvar gnus-server-alist nil
1351 "List of available servers.")
1353 (defvar gnus-variable-list
1354 '(gnus-newsrc-options gnus-newsrc-options-n
1355 gnus-newsrc-last-checked-date
1356 gnus-newsrc-alist gnus-server-alist
1357 gnus-killed-list gnus-zombie-list)
1358 "Gnus variables saved in the quick startup file.")
1360 (defvar gnus-overload-functions
1361 '((news-inews gnus-inews-news "rnewspost")
1362 (caesar-region gnus-caesar-region "rnews"))
1363 "Functions overloaded by gnus.
1364 It is a list of `(original overload &optional file)'.")
1366 (defvar gnus-newsrc-options nil
1367 "Options line in the .newsrc file.")
1369 (defvar gnus-newsrc-options-n nil
1370 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1372 (defvar gnus-newsrc-last-checked-date nil
1373 "Date Gnus last asked server for new newsgroups.")
1375 (defvar gnus-newsrc-alist nil
1376 "Assoc list of read articles.
1377 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1379 (defvar gnus-newsrc-hashtb nil
1380 "Hashtable of gnus-newsrc-alist.")
1382 (defvar gnus-killed-list nil
1383 "List of killed newsgroups.")
1385 (defvar gnus-killed-hashtb nil
1386 "Hash table equivalent of gnus-killed-list.")
1388 (defvar gnus-zombie-list nil
1389 "List of almost dead newsgroups.")
1391 (defvar gnus-description-hashtb nil
1392 "Descriptions of newsgroups.")
1394 (defvar gnus-list-of-killed-groups nil
1395 "List of newsgroups that have recently been killed by the user.")
1397 (defvar gnus-active-hashtb nil
1398 "Hashtable of active articles.")
1400 (defvar gnus-moderated-list nil
1401 "List of moderated newsgroups.")
1403 (defvar gnus-group-marked nil)
1405 (defvar gnus-current-startup-file nil
1406 "Startup file for the current host.")
1408 (defvar gnus-last-search-regexp nil
1409 "Default regexp for article search command.")
1411 (defvar gnus-last-shell-command nil
1412 "Default shell command on article.")
1414 (defvar gnus-current-select-method nil
1415 "The current method for selecting a newsgroup.")
1417 (defvar gnus-have-all-newsgroups nil)
1419 (defvar gnus-article-internal-prepare-hook nil)
1421 (defvar gnus-newsgroup-name nil)
1422 (defvar gnus-newsgroup-begin nil)
1423 (defvar gnus-newsgroup-end nil)
1424 (defvar gnus-newsgroup-last-rmail nil)
1425 (defvar gnus-newsgroup-last-mail nil)
1426 (defvar gnus-newsgroup-last-folder nil)
1427 (defvar gnus-newsgroup-last-file nil)
1428 (defvar gnus-newsgroup-auto-expire nil)
1429 (defvar gnus-newsgroup-active nil)
1431 (defvar gnus-newsgroup-unreads nil
1432 "List of unread articles in the current newsgroup.")
1434 (defvar gnus-newsgroup-unselected nil
1435 "List of unselected unread articles in the current newsgroup.")
1437 (defvar gnus-newsgroup-marked nil
1438 "List of ticked articles in the current newsgroup (a subset of unread art).")
1440 (defvar gnus-newsgroup-killed nil
1441 "List of ranges of articles that have been through the scoring process.")
1443 (defvar gnus-newsgroup-kill-headers nil)
1445 (defvar gnus-newsgroup-replied nil
1446 "List of articles that have been replied to in the current newsgroup.")
1448 (defvar gnus-newsgroup-expirable nil
1449 "List of articles in the current newsgroup that can be expired.")
1451 (defvar gnus-newsgroup-processable nil
1452 "List of articles in the current newsgroup that can be processed.")
1454 (defvar gnus-newsgroup-bookmarks nil
1455 "List of articles in the current newsgroup that have bookmarks.")
1457 (defvar gnus-newsgroup-dormant nil
1458 "List of dormant articles in the current newsgroup.")
1460 (defvar gnus-newsgroup-scored nil
1461 "List of scored articles in the current newsgroup.")
1463 (defvar gnus-newsgroup-headers nil
1464 "List of article headers in the current newsgroup.")
1465 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1467 (defvar gnus-newsgroup-ancient nil
1468 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1470 (defvar gnus-current-article nil)
1471 (defvar gnus-article-current nil)
1472 (defvar gnus-current-headers nil)
1473 (defvar gnus-have-all-headers nil)
1474 (defvar gnus-last-article nil)
1475 (defvar gnus-newsgroup-history nil)
1476 (defvar gnus-current-kill-article nil)
1478 ;; Save window configuration.
1479 (defvar gnus-prev-winconf nil)
1482 (defvar gnus-summary-line-format-spec nil)
1483 (defvar gnus-summary-dummy-line-format-spec nil)
1484 (defvar gnus-group-line-format-spec nil)
1485 (defvar gnus-summary-mode-line-format-spec nil)
1486 (defvar gnus-article-mode-line-format-spec nil)
1487 (defvar gnus-group-mode-line-format-spec nil)
1488 (defvar gnus-summary-mark-positions nil)
1490 (defvar gnus-summary-expunge-below nil)
1491 (defvar gnus-reffed-article-number nil)
1493 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1494 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1496 (defconst gnus-summary-local-variables
1497 '(gnus-newsgroup-name
1498 gnus-newsgroup-begin gnus-newsgroup-end
1499 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1500 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1501 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1502 gnus-newsgroup-unselected gnus-newsgroup-marked
1503 gnus-newsgroup-replied gnus-newsgroup-expirable
1504 gnus-newsgroup-processable gnus-newsgroup-killed
1505 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1506 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1507 gnus-current-article gnus-current-headers gnus-have-all-headers
1508 gnus-last-article gnus-article-internal-prepare-hook
1509 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1510 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1511 gnus-newsgroup-threads gnus-newsgroup-async
1512 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1513 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1514 gnus-newsgroup-history gnus-newsgroup-ancient
1515 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring))
1516 "Variables that are buffer-local to the summary buffers.")
1518 (defconst gnus-bug-message
1519 "Sending a bug report to the Gnus Towers.
1520 ========================================
1522 The buffer below is a mail buffer. When you press `C-c C-c', it will
1523 be sent to the Gnus Bug Exterminators.
1525 At the bottom of the buffer you'll see lots of variable settings.
1526 Please do not delete those. They will tell the Bug People what your
1527 environment is, so that it will be easier to locate the bugs.
1529 If you have found a bug that makes Emacs go \"beep\", set
1530 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1531 and include the backtrace in your bug report.
1533 Please describe the bug in annoying, painstaking detail.
1535 Thank you for your help in stamping out bugs.
1538 ;;; End of variables.
1540 ;; Define some autoload functions Gnus might use.
1544 (autoload 'metamail-buffer "metamail")
1545 (autoload 'Info-goto-node "info")
1546 (autoload 'hexl-hex-string-to-integer "hexl")
1548 (autoload 'pp-to-string "pp")
1549 (autoload 'pp-eval-expression "pp")
1550 (autoload 'mail-extract-address-components "mail-extr")
1552 (autoload 'nnmail-split-fancy "nnmail")
1553 (autoload 'nnvirtual-catchup-group "nnvirtual")
1556 (autoload 'timezone-make-date-arpa-standard "timezone")
1557 (autoload 'timezone-fix-time "timezone")
1558 (autoload 'timezone-make-sortable-date "timezone")
1559 (autoload 'timezone-make-time-string "timezone")
1562 (autoload 'mail-position-on-field "sendmail")
1563 (autoload 'mail-setup "sendmail")
1564 (autoload 'rmail-output "rmailout")
1565 (autoload 'news-mail-other-window "rnewspost")
1566 (autoload 'news-reply-yank-original "rnewspost")
1567 (autoload 'news-caesar-buffer-body "rnewspost")
1568 (autoload 'rmail-insert-rmail-file-header "rmail")
1569 (autoload 'rmail-count-new-messages "rmail")
1570 (autoload 'rmail-show-message "rmail")
1573 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1574 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1575 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1576 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1577 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1578 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1579 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1582 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1583 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1584 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1585 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1586 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1587 (autoload 'gnus-Folder-save-name "gnus-mh")
1588 (autoload 'gnus-folder-save-name "gnus-mh")
1591 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1592 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1593 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1594 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1595 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1596 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1597 (autoload 'gnus-summary-highlight-line "gnus-vis")
1598 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1601 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1602 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1603 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1604 (autoload 'gnus-article-hide "gnus-vis" nil t)
1605 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1606 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1607 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1608 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1609 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1610 (autoload 'gnus-article-add-button "gnus-vis")
1613 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1614 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1615 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1618 (autoload 'gnus-kill "gnus-kill")
1619 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1620 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1621 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1622 (autoload 'gnus-execute "gnus-kill")
1623 (autoload 'gnus-expunge "gnus-kill")
1626 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1627 (autoload 'gnus-cache-save-buffers "gnus-cache")
1628 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1629 (autoload 'gnus-cache-request-article "gnus-cache")
1630 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1631 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1632 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1633 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1636 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1637 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1638 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1639 (autoload 'gnus-score-save "gnus-score")
1640 (autoload 'gnus-score-headers "gnus-score")
1641 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1642 (autoload 'gnus-score-adaptive "gnus-score")
1643 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1644 (autoload 'gnus-score-find-trace "gnus-score")
1647 (autoload 'gnus-score-customize "gnus-edit" nil t)
1650 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1651 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1652 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1653 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1654 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1655 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1656 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1657 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1658 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1659 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1660 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1661 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1662 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1663 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1664 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1665 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1666 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1667 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1668 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1669 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1670 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1671 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1674 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1675 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1676 (autoload 'gnus-group-mail "gnus-msg" nil t)
1677 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1678 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1679 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1680 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1681 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1682 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1683 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1684 (autoload 'gnus-post-news "gnus-msg" nil t)
1685 (autoload 'gnus-inews-news "gnus-msg" nil t)
1686 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1687 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1688 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1689 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1690 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1691 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1692 (autoload 'gnus-mail-yank-original "gnus-msg")
1693 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1694 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1695 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1696 (autoload 'gnus-article-mail-with-original "gnus-msg")
1697 (autoload 'gnus-article-mail "gnus-msg")
1698 (autoload 'gnus-bug "gnus-msg" nil t)
1701 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1702 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1703 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1704 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1705 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1706 (autoload 'gnus-yank-article "gnus-vm" nil t)
1712 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1713 ;; If you want the cursor to go somewhere else, set these two
1714 ;; functions in some startup hook to whatever you want.
1715 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1716 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1718 ;;; Various macros and substs.
1720 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1721 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1722 (` (let ((GnusStartBufferWindow (selected-window)))
1725 (pop-to-buffer (, buffer))
1727 (select-window GnusStartBufferWindow)))))
1729 (defmacro gnus-gethash (string hashtable)
1730 "Get hash value of STRING in HASHTABLE."
1731 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1732 ;;(` (abbrev-expansion (, string) (, hashtable)))
1733 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1735 (defmacro gnus-sethash (string value hashtable)
1736 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1737 ;; We cannot use define-abbrev since it only accepts string as value.
1738 ;; (set (intern string hashtable) value))
1739 (` (set (intern (, string) (, hashtable)) (, value))))
1741 (defsubst gnus-buffer-substring (beg end)
1742 (buffer-substring (match-beginning beg) (match-end end)))
1744 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1745 ;; function `substring' might cut on a middle of multi-octet
1748 (defun gnus-truncate-string (str width)
1749 (substring str 0 width))
1751 (defsubst gnus-simplify-subject-re (subject)
1752 "Remove \"Re:\" from subject lines."
1753 (let ((case-fold-search t))
1754 (if (string-match "^re: *" subject)
1755 (substring subject (match-end 0))
1758 (defsubst gnus-goto-char (point)
1759 (and point (goto-char point)))
1761 (defmacro gnus-buffer-exists-p (buffer)
1763 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1766 (defmacro gnus-kill-buffer (buffer)
1767 (` (if (gnus-buffer-exists-p (, buffer))
1768 (kill-buffer (, buffer)))))
1770 (defsubst gnus-point-at-bol ()
1771 "Return point at the beginning of line."
1778 (defsubst gnus-point-at-eol ()
1779 "Return point at the beginning of line."
1786 ;; Delete the current line (and the next N lines.);
1787 (defmacro gnus-delete-line (&optional n)
1788 (` (delete-region (progn (beginning-of-line) (point))
1789 (progn (forward-line (, (or n 1))) (point)))))
1791 ;;; Load the compatability functions.
1797 ;;; Gnus Utility Functions
1800 (defun gnus-extract-address-components (from)
1802 ;; First find the address - the thing with the @ in it. This may
1803 ;; not be accurate in mail addresses, but does the trick most of
1804 ;; the time in news messages.
1805 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1806 (setq address (substring from (match-beginning 0) (match-end 0))))
1807 ;; Then we check whether the "name <address>" format is used.
1809 (string-match (concat "<" (regexp-quote address) ">") from)
1810 (and (setq name (substring from 0 (1- (match-beginning 0))))
1811 ;; Strip any quotes from the name.
1812 (string-match "\".*\"" name)
1813 (setq name (substring name 1 (1- (match-end 0))))))
1814 ;; If not, then "address (name)" is used.
1816 (and (string-match "(.+)" from)
1817 (setq name (substring from (1+ (match-beginning 0))
1818 (1- (match-end 0)))))
1819 (and (string-match "()" from)
1820 (setq name address))
1821 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1822 ;; XOVER might not support folded From headers.
1823 (and (string-match "(.*" from)
1824 (setq name (substring from (1+ (match-beginning 0))
1826 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1827 (list (or name from) (or address from))))
1829 (defun gnus-fetch-field (field)
1830 "Return the value of the header FIELD of current article."
1833 (let ((case-fold-search t))
1834 (gnus-narrow-to-headers)
1835 (mail-fetch-field field)))))
1837 (defun gnus-goto-colon ()
1839 (search-forward ":" (gnus-point-at-eol) t))
1841 (defun gnus-narrow-to-headers ()
1845 (goto-char (point-min))
1846 (if (search-forward "\n\n" nil t)
1850 (defun gnus-update-format-specifications ()
1851 (gnus-make-thread-indent-array)
1852 (setq gnus-summary-line-format-spec
1854 gnus-summary-line-format gnus-summary-line-format-alist))
1855 (gnus-update-summary-mark-positions)
1856 (setq gnus-summary-dummy-line-format-spec
1857 (gnus-parse-format gnus-summary-dummy-line-format
1858 gnus-summary-dummy-line-format-alist))
1859 (setq gnus-group-line-format-spec
1861 gnus-group-line-format
1862 gnus-group-line-format-alist))
1863 (if (and (string-match "%D" gnus-group-line-format)
1864 (not gnus-description-hashtb)
1865 gnus-read-active-file)
1866 (gnus-read-all-descriptions-files))
1867 (setq gnus-summary-mode-line-format-spec
1868 (gnus-parse-format gnus-summary-mode-line-format
1869 gnus-summary-mode-line-format-alist))
1870 (setq gnus-article-mode-line-format-spec
1871 (gnus-parse-format gnus-article-mode-line-format
1872 gnus-summary-mode-line-format-alist))
1873 (setq gnus-group-mode-line-format-spec
1874 (gnus-parse-format gnus-group-mode-line-format
1875 gnus-group-mode-line-format-alist)))
1877 (defun gnus-update-summary-mark-positions ()
1879 (let ((gnus-replied-mark 129)
1880 (gnus-score-below-mark 130)
1881 (gnus-score-over-mark 130)
1884 (gnus-set-work-buffer)
1885 (gnus-summary-insert-line
1886 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1887 (goto-char (point-min))
1888 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1890 (goto-char (point-min))
1891 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1892 (- (point) 2))) pos))
1893 (goto-char (point-min))
1894 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1895 (- (point) 2))) pos))
1896 (setq gnus-summary-mark-positions pos))))
1898 (defun gnus-format-max-width (form length)
1899 (let* ((val (eval form))
1900 (valstr (if (numberp val) (int-to-string val) val)))
1901 (if (> (length valstr) length)
1902 (substring valstr 0 length)
1905 (defun gnus-set-mouse-face (string)
1906 ;; Set mouse face property on STRING.
1907 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1910 (defun gnus-parse-format (format spec-alist)
1911 ;; This function parses the FORMAT string with the help of the
1912 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1913 ;; string. If the FORMAT string contains the specifiers %( and %)
1914 ;; the text between them will have the mouse-face text property.
1915 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1916 (if (and gnus-visual gnus-mouse-face)
1917 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1918 (button (substring format (match-beginning 2) (match-end 2)))
1919 (post (substring format (match-beginning 3) (match-end 3))))
1921 (gnus-parse-simple-format pre spec-alist)
1922 (list 'gnus-set-mouse-face
1923 (gnus-parse-simple-format button spec-alist))
1924 (gnus-parse-simple-format post spec-alist)))
1925 (gnus-parse-simple-format
1926 (concat (substring format (match-beginning 1) (match-end 1))
1927 (substring format (match-beginning 2) (match-end 2))
1928 (substring format (match-beginning 3) (match-end 3)))
1930 (gnus-parse-simple-format format spec-alist)))
1932 (defun gnus-parse-simple-format (format spec-alist)
1933 ;; This function parses the FORMAT string with the help of the
1934 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1935 ;; string. The list will consist of the symbol `format', a format
1936 ;; specification string, and a list of forms depending on the
1939 spec flist fstring newspec elem beg)
1941 (gnus-set-work-buffer)
1943 (goto-char (point-min))
1944 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1945 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1947 ;; First check if there are any specs that look anything like
1948 ;; "%12,12A", ie. with a "max width specification". These have
1949 ;; to be treated specially.
1950 (if (setq beg (match-beginning 1))
1953 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1955 (setq beg (match-beginning 2)))
1956 ;; Find the specification from `spec-alist'.
1957 (if (not (setq elem (cdr (assq spec spec-alist))))
1958 (setq elem '("*" ?s)))
1959 ;; Treat user defined format specifiers specially
1960 (and (eq (car elem) 'user-defined)
1963 (list (intern (concat "gnus-user-format-function-"
1969 (delete-region (match-beginning 3) (match-end 3)))
1970 (if (not (zerop max-width))
1971 (let ((el (car elem)))
1972 (cond ((= (car (cdr elem)) ?c)
1973 (setq el (list 'char-to-string el)))
1974 ((= (car (cdr elem)) ?d)
1975 (numberp el) (setq el (list 'int-to-string el))))
1976 (setq flist (cons (list 'gnus-format-max-width el max-width)
1979 (setq flist (cons (car elem) flist))
1980 (setq newspec (car (cdr elem))))
1981 ;; Remove the old specification (and possibly a ",12" string).
1982 (delete-region beg (match-end 2))
1983 ;; Insert the new specification.
1986 (setq fstring (buffer-substring 1 (point-max))))
1987 (cons 'format (cons fstring (nreverse flist)))))
1989 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1990 (defun gnus-read-init-file ()
1992 (or (and (file-exists-p gnus-init-file)
1993 ;; Don't try to load a directory.
1994 (not (file-directory-p gnus-init-file)))
1995 (file-exists-p (concat gnus-init-file ".el"))
1996 (file-exists-p (concat gnus-init-file ".elc")))
1997 (load gnus-init-file nil t)))
1999 (defun gnus-set-work-buffer ()
2000 (if (get-buffer gnus-work-buffer)
2002 (set-buffer gnus-work-buffer)
2004 (set-buffer (get-buffer-create gnus-work-buffer))
2005 (kill-all-local-variables)
2006 (buffer-disable-undo (current-buffer))
2007 (gnus-add-current-to-buffer-list)))
2009 ;; Article file names when saving.
2011 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2012 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2013 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2014 Otherwise, it is like ~/News/news/group/num."
2017 (concat (if (gnus-use-long-file-name 'not-save)
2018 (gnus-capitalize-newsgroup newsgroup)
2019 (gnus-newsgroup-directory-form newsgroup))
2020 "/" (int-to-string (header-number headers)))
2021 (or gnus-article-save-directory "~/News"))))
2023 (string-equal (file-name-directory default)
2024 (file-name-directory last-file))
2025 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2027 (or last-file default))))
2029 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2030 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2031 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2032 Otherwise, it is like ~/News/news/group/num."
2035 (concat (if (gnus-use-long-file-name 'not-save)
2037 (gnus-newsgroup-directory-form newsgroup))
2038 "/" (int-to-string (header-number headers)))
2039 (or gnus-article-save-directory "~/News"))))
2041 (string-equal (file-name-directory default)
2042 (file-name-directory last-file))
2043 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2045 (or last-file default))))
2047 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2048 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2049 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2050 Otherwise, it is like ~/News/news/group/news."
2053 (if (gnus-use-long-file-name 'not-save)
2054 (gnus-capitalize-newsgroup newsgroup)
2055 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2056 (or gnus-article-save-directory "~/News"))))
2058 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2059 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2060 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
2061 Otherwise, it is like ~/News/news/group/news."
2064 (if (gnus-use-long-file-name 'not-save)
2066 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2067 (or gnus-article-save-directory "~/News"))))
2069 ;; For subscribing new newsgroup
2071 (defun gnus-subscribe-hierarchical-interactive (groups)
2072 (let ((groups (sort groups 'string<))
2073 prefixes prefix start ans group starts)
2075 (setq prefixes (list "^"))
2076 (while (and groups prefixes)
2077 (while (not (string-match (car prefixes) (car groups)))
2078 (setq prefixes (cdr prefixes)))
2079 (setq prefix (car prefixes))
2080 (setq start (1- (length prefix)))
2081 (if (and (string-match "[^\\.]\\." (car groups) start)
2084 (concat "^" (substring (car groups) 0 (match-end 0))))
2085 (string-match prefix (car (cdr groups))))
2087 (setq prefixes (cons prefix prefixes))
2088 (message "Descend hierarchy %s? ([y]nsq): "
2089 (substring prefix 1 (1- (length prefix))))
2090 (setq ans (read-char))
2093 (string-match prefix
2094 (setq group (car groups))))
2095 (setq gnus-killed-list
2096 (cons group gnus-killed-list))
2097 (gnus-sethash group group gnus-killed-hashtb)
2098 (setq groups (cdr groups)))
2099 (setq starts (cdr starts)))
2102 (string-match prefix
2103 (setq group (car groups))))
2104 (gnus-sethash group group gnus-killed-hashtb)
2105 (gnus-subscribe-alphabetically (car groups))
2106 (setq groups (cdr groups)))
2107 (setq starts (cdr starts)))
2110 (setq group (car groups))
2111 (setq gnus-killed-list (cons group gnus-killed-list))
2112 (gnus-sethash group group gnus-killed-hashtb)
2113 (setq groups (cdr groups))))
2115 (message "Subscribe %s? ([n]yq)" (car groups))
2116 (setq ans (read-char))
2117 (setq group (car groups))
2119 (gnus-subscribe-alphabetically (car groups))
2120 (gnus-sethash group group gnus-killed-hashtb))
2123 (setq group (car groups))
2124 (setq gnus-killed-list (cons group gnus-killed-list))
2125 (gnus-sethash group group gnus-killed-hashtb)
2126 (setq groups (cdr groups))))
2128 (setq gnus-killed-list (cons group gnus-killed-list))
2129 (gnus-sethash group group gnus-killed-hashtb)))
2130 (setq groups (cdr groups)))))))
2132 (defun gnus-subscribe-randomly (newsgroup)
2133 "Subscribe new NEWSGROUP by making it the first newsgroup."
2134 (gnus-subscribe-newsgroup newsgroup))
2136 (defun gnus-subscribe-alphabetically (newgroup)
2137 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2138 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2139 (let ((groups (cdr gnus-newsrc-alist))
2141 (while (and (not before) groups)
2142 (if (string< newgroup (car (car groups)))
2143 (setq before (car (car groups)))
2144 (setq groups (cdr groups))))
2145 (gnus-subscribe-newsgroup newgroup before)))
2147 (defun gnus-subscribe-hierarchically (newgroup)
2148 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2149 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2151 (set-buffer (find-file-noselect gnus-current-startup-file))
2152 (let ((groupkey newgroup)
2154 (while (and (not before) groupkey)
2155 (goto-char (point-min))
2157 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2158 (while (and (re-search-forward groupkey-re nil t)
2160 (setq before (buffer-substring
2161 (match-beginning 1) (match-end 1)))
2162 (string< before newgroup)))))
2163 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2165 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2166 (substring groupkey (match-beginning 1) (match-end 1)))))
2167 (gnus-subscribe-newsgroup newgroup before))))
2169 (defun gnus-subscribe-interactively (newsgroup)
2170 "Subscribe new NEWSGROUP interactively.
2171 It is inserted in hierarchical newsgroup order if subscribed. If not,
2173 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2174 (gnus-subscribe-hierarchically newsgroup)
2175 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2177 (defun gnus-subscribe-zombies (newsgroup)
2178 "Make new NEWSGROUP a zombie group."
2179 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2181 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2182 "Subscribe new NEWSGROUP.
2183 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2184 the first newsgroup."
2185 ;; We subscribe the group by changing its level to `subscribed'.
2186 (gnus-group-change-level
2187 newsgroup gnus-level-default-subscribed
2188 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2189 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2193 (defun gnus-newsgroup-directory-form (newsgroup)
2194 "Make hierarchical directory name from NEWSGROUP name."
2195 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2196 (len (length newsgroup))
2198 ;; If this is a foreign group, we don't want to translate the
2200 (if (setq idx (string-match ":" newsgroup))
2201 (aset newsgroup idx ?/)
2203 ;; Replace all occurrences of `.' with `/'.
2205 (if (= (aref newsgroup idx) ?.)
2206 (aset newsgroup idx ?/))
2207 (setq idx (1+ idx)))
2210 (defun gnus-make-directory (dir)
2211 "Make DIRECTORY recursively."
2212 (let* ((dir (expand-file-name dir default-directory))
2214 (if (string-match "/$" dir)
2215 (setq dir (substring dir 0 (match-beginning 0))))
2216 (while (not (file-exists-p dir))
2217 (setq dirs (cons dir dirs))
2218 (string-match "/[^/]+$" dir)
2219 (setq dir (substring dir 0 (match-beginning 0))))
2221 (make-directory (car dirs))
2222 (setq dirs (cdr dirs)))))
2224 (defun gnus-capitalize-newsgroup (newsgroup)
2225 "Capitalize NEWSGROUP name."
2226 (and (not (zerop (length newsgroup)))
2227 (concat (char-to-string (upcase (aref newsgroup 0)))
2228 (substring newsgroup 1))))
2232 (defun gnus-simplify-subject (subject &optional re-only)
2233 "Remove `Re:' and words in parentheses.
2234 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2235 (let ((case-fold-search t)) ;Ignore case.
2236 ;; Remove `Re:' and `Re^N:'.
2237 (if (string-match "^re:[ \t]*" subject)
2238 (setq subject (substring subject (match-end 0))))
2239 ;; Remove words in parentheses from end.
2241 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2242 (setq subject (substring subject 0 (match-beginning 0)))))
2243 ;; Return subject string.
2246 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2248 (defun gnus-simplify-subject-fuzzy (subject)
2249 (let ((case-fold-search t))
2251 (gnus-set-work-buffer)
2253 (inline (gnus-simplify-buffer-fuzzy))
2256 (defun gnus-simplify-buffer-fuzzy ()
2257 (goto-char (point-min))
2258 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2259 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2261 (replace-match "" t t))
2262 (goto-char (point-min))
2263 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2264 (replace-match "" t t))
2265 (goto-char (point-min))
2266 (while (re-search-forward "[ \t]+" nil t)
2267 (replace-match " " t t))
2268 (goto-char (point-min))
2269 (while (re-search-forward "[ \t]+$" nil t)
2270 (replace-match "" t t))
2271 (goto-char (point-min))
2272 (while (re-search-forward "^[ \t]+" nil t)
2273 (replace-match "" t t))
2274 (if gnus-simplify-subject-fuzzy-regexp
2275 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2276 (replace-match "" t t)))
2279 ;; Add the current buffer to the list of buffers to be killed on exit.
2280 (defun gnus-add-current-to-buffer-list ()
2281 (or (memq (current-buffer) gnus-buffer-list)
2282 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2284 (defun gnus-string> (s1 s2)
2285 (not (or (string< s1 s2)
2288 ;; Functions accessing headers.
2289 ;; Functions are more convenient than macros in some cases.
2291 (defun gnus-header-number (header)
2292 (header-number header))
2294 (defun gnus-header-subject (header)
2295 (header-subject header))
2297 (defun gnus-header-from (header)
2298 (header-from header))
2300 (defun gnus-header-xref (header)
2301 (header-xref header))
2303 (defun gnus-header-lines (header)
2304 (header-lines header))
2306 (defun gnus-header-date (header)
2307 (header-date header))
2309 (defun gnus-header-id (header)
2312 (defun gnus-header-references (header)
2313 (header-references header))
2315 ;;; General various misc type functions.
2317 (defun gnus-clear-system ()
2318 "Clear all variables and buffers."
2319 ;; Clear Gnus variables.
2320 (let ((variables gnus-variable-list))
2322 (set (car variables) nil)
2323 (setq variables (cdr variables))))
2324 ;; Clear other internal variables.
2325 (setq gnus-list-of-killed-groups nil
2326 gnus-have-read-active-file nil
2327 gnus-newsrc-alist nil
2328 gnus-newsrc-hashtb nil
2329 gnus-killed-list nil
2330 gnus-zombie-list nil
2331 gnus-killed-hashtb nil
2332 gnus-active-hashtb nil
2333 gnus-moderated-list nil
2334 gnus-description-hashtb nil
2335 gnus-newsgroup-headers nil
2336 gnus-newsgroup-headers-hashtb-by-number nil
2337 gnus-newsgroup-name nil
2338 gnus-server-alist nil
2339 gnus-current-select-method nil)
2340 ;; Reset any score variables.
2341 (and (boundp 'gnus-score-cache)
2342 (set 'gnus-score-cache nil))
2343 (and (boundp 'gnus-internal-global-score-files)
2344 (set 'gnus-internal-global-score-files nil))
2345 ;; Kill the startup file.
2346 (and gnus-current-startup-file
2347 (get-file-buffer gnus-current-startup-file)
2348 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2349 ;; Save any cache buffers.
2350 (and gnus-use-cache (gnus-cache-save-buffers))
2351 ;; Clear the dribble buffer.
2352 (gnus-dribble-clear)
2353 ;; Kill global KILL file buffer.
2354 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2355 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2356 (gnus-kill-buffer nntp-server-buffer)
2357 ;; Kill Gnus buffers.
2358 (while gnus-buffer-list
2359 (gnus-kill-buffer (car gnus-buffer-list))
2360 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2362 (defun gnus-windows-old-to-new (setting)
2363 (if (symbolp setting)
2365 (cond ((eq setting 'SelectArticle)
2367 ((eq setting 'SelectSubject)
2369 ((eq setting 'SelectNewsgroup)
2372 (if (or (listp setting)
2373 (not (and gnus-window-configuration
2374 (memq setting '(group summary article)))))
2376 (let* ((setting (if (eq setting 'group)
2377 (if (assq 'newsgroup gnus-window-configuration)
2379 'newsgroups) setting))
2380 (elem (car (cdr (assq setting gnus-window-configuration))))
2381 (total (apply '+ elem))
2382 (types '(group summary article))
2383 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2388 (or (zerop (nth i elem))
2390 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2391 (setq out (cons (if (eq pbuf (nth i types))
2392 (vector (nth i types) perc 'point)
2393 (vector (nth i types) perc))
2396 (list (nreverse out)))))
2398 (defun gnus-add-configuration (conf)
2399 (setq gnus-buffer-configuration
2400 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2401 gnus-buffer-configuration))))
2403 (defun gnus-configure-windows (setting)
2404 (setq setting (gnus-windows-old-to-new setting))
2405 (let ((r (if (symbolp setting)
2406 (cdr (assq setting gnus-buffer-configuration))
2408 (in-buf (current-buffer))
2409 rule val w height hor ohor heights sub jump-buffer
2411 (or r (error "No such setting: %s" setting))
2413 ;; Either remove all windows or just remove all Gnus windows.
2414 (if gnus-use-full-window
2415 (delete-other-windows)
2416 (gnus-remove-some-windows)
2417 (switch-to-buffer nntp-server-buffer))
2423 ;; We have to do the (possible) horizontal splitting before the
2425 (if (and (listp (car hor))
2426 (eq (car (car hor)) 'horizontal))
2430 (if (integerp (nth 1 (car hor)))
2432 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2434 (setq hor (cdr hor))))
2436 ;; Go through the rules and eval the elements that are to be
2439 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2441 ;; Expand short buffer name.
2442 (setq w (aref val 0))
2443 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2445 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2447 (setq ohor (cons val ohor))))
2448 (setq hor (cdr hor)))
2449 (setq rule (cons (nreverse ohor) rule))
2451 (setq rule (nreverse rule))
2453 ;; We tally the window sizes.
2454 (setq total (window-height))
2456 (setq hor (car rule))
2457 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2458 (setq hor (cdr hor)))
2461 (setq rel (aref (car hor) 1)
2463 (cond ((and (floatp rel) (= 1.0 rel))
2468 (max (floor (* total rel)) 4)))
2470 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2472 (setq heights (nreverse heights)
2475 ;; We then go through these heighs and create windows for them.
2477 (setq height (car heights)
2478 heights (cdr heights))
2480 (setq height (- total sub)))
2482 (split-window nil height))
2483 (setq to-buf (aref (car hor) 0))
2488 (symbol-value (aref (car hor) 0)))
2490 (aref (car hor) 0))))
2491 (and (> (length (car hor)) 2)
2492 (eq (aref (car hor) 2) 'point)
2493 (setq jump-buffer (current-buffer)))
2495 (setq hor (cdr hor)))
2497 (setq rule (cdr rule)))
2499 ;; Finally, we pop to the buffer that's supposed to have point.
2500 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2502 (select-window (get-buffer-window jump-buffer))
2503 (set-buffer jump-buffer)))
2505 (defun gnus-remove-some-windows ()
2506 (let ((buffers gnus-window-to-buffer)
2510 ;; Remove windows on all known Gnus buffers.
2512 (setq buf (cdr (car buffers)))
2514 (setq buf (and (boundp buf) (symbol-value buf))))
2516 (get-buffer-window buf)
2521 (switch-to-buffer nntp-server-buffer)
2523 (delete-window (get-buffer-window buf)))))
2524 (setq buffers (cdr buffers)))
2525 ;; Remove windows on *all* summary buffers.
2526 (let ((buffers (buffer-list)))
2528 (if (and (string-match
2529 "^\\*Summary" (or (buffer-name (car buffers)) ""))
2530 (get-buffer-window (car buffers)))
2531 (delete-window (get-buffer-window (car buffers))))
2532 (setq buffers (cdr buffers)))))))
2534 (defun gnus-version ()
2535 "Version numbers of this version of Gnus."
2537 (let ((methods gnus-valid-select-methods)
2540 ;; Go through all the legal select methods and add their version
2541 ;; numbers to the total version string. Only the backends that are
2542 ;; currently in use will have their message numbers taken into
2545 (setq meth (intern (concat (car (car methods)) "-version")))
2547 (stringp (symbol-value meth))
2548 (setq mess (concat mess "; " (symbol-value meth))))
2549 (setq methods (cdr methods)))
2550 (gnus-message 2 mess)))
2552 (defun gnus-info-find-node ()
2553 "Find Info documentation of Gnus."
2555 ;; Enlarge info window if needed.
2556 (let ((mode major-mode))
2557 (gnus-configure-windows 'info)
2558 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2560 (defun gnus-overload-functions (&optional overloads)
2561 "Overload functions specified by optional argument OVERLOADS.
2562 If nothing is specified, use the variable gnus-overload-functions."
2564 (overloads (or overloads gnus-overload-functions)))
2566 (setq defs (car overloads))
2567 (setq overloads (cdr overloads))
2568 ;; Load file before overloading function if necessary. Make
2569 ;; sure we cannot use `require' always.
2570 (and (not (fboundp (car defs)))
2571 (car (cdr (cdr defs)))
2572 (load (car (cdr (cdr defs))) nil 'nomessage))
2573 (fset (car defs) (car (cdr defs))))))
2575 (defun gnus-replace-chars-in-string (string from to)
2576 "Replace characters in STRING from FROM to TO."
2577 (let ((string (substring string 0)) ;Copy string.
2578 (len (length string))
2580 ;; Replace all occurrences of FROM with TO.
2582 (if (= (aref string idx) from)
2583 (aset string idx to))
2584 (setq idx (1+ idx)))
2587 (defun gnus-days-between (date1 date2)
2588 ;; Return the number of days between date1 and date2.
2589 (- (gnus-day-number date1) (gnus-day-number date2)))
2591 (defun gnus-day-number (date)
2592 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2593 (timezone-parse-date date))))
2594 (timezone-absolute-from-gregorian
2595 (nth 1 dat) (nth 2 dat) (car dat))))
2597 ;; Returns a floating point number that says how many seconds have
2598 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2599 (defun gnus-seconds-since-epoch (date)
2600 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2601 (timezone-parse-date date)))
2602 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2603 (timezone-parse-time
2604 (aref (timezone-parse-date date) 3))))
2605 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2606 (timezone-parse-date "Jan 1 12:00:00 1970")))
2607 (tday (- (timezone-absolute-from-gregorian
2608 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2609 (timezone-absolute-from-gregorian
2610 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2612 (* (nth 1 ttime) 60)
2613 (* 1.0 (nth 0 ttime) 60 60)
2614 (* 1.0 tday 60 60 24))))
2616 (defun gnus-file-newer-than (file date)
2617 (let ((fdate (nth 5 (file-attributes file))))
2618 (or (> (car fdate) (car date))
2619 (and (= (car fdate) (car date))
2620 (> (nth 1 fdate) (nth 1 date))))))
2622 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2624 (defun gnus-y-or-n-p (prompt)
2629 (defun gnus-yes-or-no-p (prompt)
2631 (yes-or-no-p prompt)
2634 ;; Check whether to use long file names.
2635 (defun gnus-use-long-file-name (symbol)
2636 ;; The variable has to be set...
2637 (and gnus-use-long-file-name
2638 ;; If it isn't a list, then we return t.
2639 (or (not (listp gnus-use-long-file-name))
2640 ;; If it is a list, and the list contains `symbol', we
2642 (not (memq symbol gnus-use-long-file-name)))))
2644 ;; I suspect there's a better way, but I haven't taken the time to do
2645 ;; it yet. -erik selberg@cs.washington.edu
2646 (defun gnus-dd-mmm (messy-date)
2647 "Return a string like DD-MMM from a big messy string"
2648 (let ((datevec (timezone-parse-date messy-date)))
2650 (or (aref datevec 2) "??")
2653 (nth (1- (string-to-number (aref datevec 1)))
2654 timezone-months-assoc))
2657 ;; Make a hash table (default and minimum size is 255).
2658 ;; Optional argument HASHSIZE specifies the table size.
2659 (defun gnus-make-hashtable (&optional hashsize)
2660 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2662 ;; Make a number that is suitable for hashing; bigger than MIN and one
2664 (defun gnus-create-hash-size (min)
2670 ;; Show message if message has a lower level than `gnus-verbose'.
2671 ;; Guide-line for numbers:
2672 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2673 ;; for things that take a long time, 7 - not very important messages
2674 ;; on stuff, 9 - messages inside loops.
2675 (defun gnus-message (level &rest args)
2676 (if (<= level gnus-verbose)
2677 (apply 'message args)
2678 ;; We have to do this format thingie here even if the result isn't
2679 ;; shown - the return value has to be the same as the return value
2681 (apply 'format args)))
2683 ;; Generate a unique new group name.
2684 (defun gnus-generate-new-group-name (leaf)
2687 (while (gnus-gethash name gnus-newsrc-hashtb)
2688 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2691 (defun gnus-find-file-noselect (file &optional force)
2692 "Does vaguely the same as find-file-noselect. No hooks are run."
2694 (if (setq buf (get-file-buffer file))
2696 (setq buf (create-file-buffer file))
2703 (and (file-readable-p file)
2704 (insert-file-contents file))
2705 (set-visited-file-name file)
2706 (set-buffer-modified-p nil)
2707 (current-buffer)))))
2709 ;;; List and range functions
2711 (defun gnus-last-element (list)
2712 "Return last element of LIST."
2714 (setq list (cdr list)))
2717 (defun gnus-copy-sequence (list)
2718 "Do a complete, total copy of a list."
2719 (if (and (consp list) (not (consp (cdr list))))
2720 (cons (car list) (cdr list))
2721 (mapcar (lambda (elem) (if (consp elem)
2722 (if (consp (cdr elem))
2723 (gnus-copy-sequence elem)
2724 (cons (car elem) (cdr elem)))
2728 (defun gnus-set-difference (list1 list2)
2729 "Return a list of elements of LIST1 that do not appear in LIST2."
2730 (let ((list1 (copy-sequence list1)))
2732 (setq list1 (delq (car list2) list1))
2733 (setq list2 (cdr list2)))
2736 (defun gnus-sorted-complement (list1 list2)
2737 "Return a list of elements of LIST1 that do not appear in LIST2.
2738 Both lists have to be sorted over <."
2740 (if (or (null list1) (null list2))
2742 (while (and list1 list2)
2743 (cond ((= (car list1) (car list2))
2744 (setq list1 (cdr list1)
2746 ((< (car list1) (car list2))
2747 (setq out (cons (car list1) out))
2748 (setq list1 (cdr list1)))
2750 (setq out (cons (car list2) out))
2751 (setq list2 (cdr list2)))))
2752 (nconc (nreverse out) (or list1 list2)))))
2754 (defun gnus-intersection (list1 list2)
2757 (if (memq (car list2) list1)
2758 (setq result (cons (car list2) result)))
2759 (setq list2 (cdr list2)))
2762 (defun gnus-sorted-intersection (list1 list2)
2763 ;; LIST1 and LIST2 have to be sorted over <.
2765 (while (and list1 list2)
2766 (cond ((= (car list1) (car list2))
2767 (setq out (cons (car list1) out)
2770 ((< (car list1) (car list2))
2771 (setq list1 (cdr list1)))
2773 (setq list2 (cdr list2)))))
2776 (defun gnus-set-sorted-intersection (list1 list2)
2777 ;; LIST1 and LIST2 have to be sorted over <.
2778 ;; This function modifies LIST1.
2779 (let* ((top (cons nil list1))
2781 (while (and list1 list2)
2782 (cond ((= (car list1) (car list2))
2786 ((< (car list1) (car list2))
2787 (setcdr prev (cdr list1))
2788 (setq list1 (cdr list1)))
2790 (setq list2 (cdr list2)))))
2794 (defun gnus-compress-sequence (numbers &optional always-list)
2795 "Convert list of numbers to a list of ranges or a single range.
2796 If ALWAYS-LIST is non-nil, this function will always release a list of
2798 (let* ((first (car numbers))
2799 (last (car numbers))
2803 (if (not (listp (cdr numbers)))
2806 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2807 ((= (1+ last) (car numbers)) ;Still in sequence
2808 (setq last (car numbers)))
2809 (t ;End of one sequence
2811 (cons (if (= first last) first
2812 (cons first last)) result))
2813 (setq first (car numbers))
2814 (setq last (car numbers))))
2815 (setq numbers (cdr numbers)))
2816 (if (and (not always-list) (null result))
2817 (if (= first last) (list first) (cons first last))
2818 (nreverse (cons (if (= first last) first (cons first last))
2821 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2822 (defun gnus-uncompress-range (ranges)
2823 "Expand a list of ranges into a list of numbers.
2824 RANGES is either a single range on the form `(num . num)' or a list of
2826 (let (first last result)
2830 ((not (listp (cdr ranges)))
2831 (setq first (car ranges))
2832 (setq last (cdr ranges))
2833 (while (<= first last)
2834 (setq result (cons first result))
2835 (setq first (1+ first)))
2839 (if (atom (car ranges))
2840 (if (numberp (car ranges))
2841 (setq result (cons (car ranges) result)))
2842 (setq first (car (car ranges)))
2843 (setq last (cdr (car ranges)))
2844 (while (<= first last)
2845 (setq result (cons first result))
2846 (setq first (1+ first))))
2847 (setq ranges (cdr ranges)))
2848 (nreverse result)))))
2850 (defun gnus-add-to-range (ranges list)
2851 "Return a list of ranges that has all articles from both RANGES and LIST.
2852 Note: LIST has to be sorted over `<'."
2854 (gnus-compress-sequence list t)
2855 (setq list (copy-sequence list))
2856 (or (listp (cdr ranges))
2857 (setq ranges (list ranges)))
2859 ilist lowest highest temp)
2860 (while (and ranges list)
2862 (setq lowest (or (and (atom (car ranges)) (car ranges))
2863 (car (car ranges))))
2864 (while (and list (cdr list) (< (car (cdr list)) lowest))
2865 (setq list (cdr list)))
2866 (if (< (car ilist) lowest)
2869 (setq list (cdr list))
2871 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2872 (setq highest (or (and (atom (car ranges)) (car ranges))
2873 (cdr (car ranges))))
2874 (while (and list (<= (car list) highest))
2875 (setq list (cdr list)))
2876 (setq ranges (cdr ranges)))
2878 (setq out (nconc (gnus-compress-sequence list t) out)))
2879 (setq out (sort out (lambda (r1 r2)
2880 (< (or (and (atom r1) r1) (car r1))
2881 (or (and (atom r2) r2) (car r2))))))
2884 (if (atom (car ranges))
2886 (if (atom (car (cdr ranges)))
2887 (if (= (1+ (car ranges)) (car (cdr ranges)))
2889 (setcar ranges (cons (car ranges)
2890 (car (cdr ranges))))
2891 (setcdr ranges (cdr (cdr ranges)))))
2892 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2894 (setcar (car (cdr ranges)) (car ranges))
2895 (setcar ranges (car (cdr ranges)))
2896 (setcdr ranges (cdr (cdr ranges)))))))
2898 (if (atom (car (cdr ranges)))
2899 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2901 (setcdr (car ranges) (car (cdr ranges)))
2902 (setcdr ranges (cdr (cdr ranges)))))
2903 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2905 (setcdr (car ranges) (cdr (car (cdr ranges))))
2906 (setcdr ranges (cdr (cdr ranges))))))))
2907 (setq ranges (cdr ranges)))
2910 (defun gnus-remove-from-range (ranges list)
2911 "Return a list of ranges that has all articles from LIST removed from RANGES.
2912 Note: LIST has to be sorted over `<'."
2913 ;; !!! This function shouldn't look like this, but I've got a headache.
2914 (gnus-compress-sequence
2915 (gnus-sorted-complement
2916 (gnus-uncompress-range ranges) list)))
2918 (defun gnus-member-of-range (number ranges)
2919 (if (not (listp (cdr ranges)))
2920 (and (>= number (car ranges))
2921 (<= number (cdr ranges)))
2924 (if (numberp (car ranges))
2925 (>= number (car ranges))
2926 (>= number (car (car ranges))))
2928 (if (if (numberp (car ranges))
2929 (= number (car ranges))
2930 (and (>= number (car (car ranges)))
2931 (<= number (cdr (car ranges)))))
2932 (setq not-stop nil))
2933 (setq ranges (cdr ranges)))
2941 (defvar gnus-group-mode-map nil)
2942 (defvar gnus-group-group-map nil)
2943 (defvar gnus-group-mark-map nil)
2944 (defvar gnus-group-list-map nil)
2945 (defvar gnus-group-sub-map nil)
2946 (put 'gnus-group-mode 'mode-class 'special)
2948 (if gnus-group-mode-map
2950 (setq gnus-group-mode-map (make-keymap))
2951 (suppress-keymap gnus-group-mode-map)
2952 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2953 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2954 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2955 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2956 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2957 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2958 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2959 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2960 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2961 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2962 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2963 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2964 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2965 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2966 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2967 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2968 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2969 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2970 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2971 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2972 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2973 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2974 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2975 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2976 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2977 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2978 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2979 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2980 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2981 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2982 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2983 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2984 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2985 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2986 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2987 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2988 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2989 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2990 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2991 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2992 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2993 (define-key gnus-group-mode-map "V" 'gnus-version)
2994 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2995 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2996 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2997 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2998 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2999 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3000 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3001 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3002 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3003 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3004 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3005 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3006 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3007 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3008 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3010 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3011 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3012 (define-prefix-command 'gnus-group-mark-map)
3013 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3014 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3015 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3016 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3018 (define-prefix-command 'gnus-group-group-map)
3019 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3020 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3021 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3022 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3023 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3024 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3025 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3026 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3027 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3028 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3029 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3030 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3031 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3032 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3033 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3034 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3035 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3036 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3038 (define-prefix-command 'gnus-group-list-map)
3039 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3040 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3041 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3042 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3043 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3044 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3045 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3046 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3047 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3049 (define-prefix-command 'gnus-group-sub-map)
3050 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3051 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3052 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3053 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3054 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3055 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3056 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3057 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3059 (defun gnus-group-mode ()
3060 "Major mode for reading news.
3062 All normal editing commands are switched off.
3063 \\<gnus-group-mode-map>
3064 The group buffer lists (some of) the groups available. For instance,
3065 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3066 lists all zombie groups.
3068 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3069 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3071 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3073 The following commands are available:
3075 \\{gnus-group-mode-map}"
3077 (if gnus-visual (gnus-group-make-menu-bar))
3078 (kill-all-local-variables)
3079 (setq mode-line-modified "-- ")
3080 (make-local-variable 'mode-line-format)
3081 (setq mode-line-format (copy-sequence mode-line-format))
3082 (and (equal (nth 3 mode-line-format) " ")
3083 (setcar (nthcdr 3 mode-line-format) ""))
3084 (setq major-mode 'gnus-group-mode)
3085 (setq mode-name "Group")
3086 (gnus-group-set-mode-line)
3087 (setq mode-line-process nil)
3088 (use-local-map gnus-group-mode-map)
3089 (buffer-disable-undo (current-buffer))
3090 (setq truncate-lines t)
3091 (setq buffer-read-only t)
3092 (run-hooks 'gnus-group-mode-hook))
3094 (defun gnus-mouse-pick-group (e)
3097 (gnus-group-read-group nil))
3100 (defun gnus-no-server (&optional arg)
3102 If ARG is a positive number, Gnus will use that as the
3103 startup level. If ARG is nil, Gnus will be started at level 2.
3104 If ARG is non-nil and not a positive number, Gnus will
3105 prompt the user for the name of an NNTP server to use.
3106 As opposed to `gnus', this command will not connect to the local server."
3108 (setq gnus-group-use-permanent-levels t)
3109 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3111 (defalias '\(ding\) 'gnus)
3114 (defun gnus (&optional arg dont-connect)
3116 If ARG is non-nil and a positive number, Gnus will use that as the
3117 startup level. If ARG is non-nil and not a positive number, Gnus will
3118 prompt the user for the name of an NNTP server to use."
3120 (if (get-buffer gnus-group-buffer)
3122 (switch-to-buffer gnus-group-buffer)
3123 (gnus-group-get-new-news))
3125 (nnheader-init-server-buffer)
3126 (gnus-read-init-file)
3127 (let ((level (and arg (numberp arg) (> arg 0) arg))
3131 (gnus-group-setup-buffer)
3134 (gnus-start-news-server (and arg (not level))))))
3135 (if (and (not dont-connect)
3138 (run-hooks 'gnus-startup-hook)
3139 ;; NNTP server is successfully open.
3140 (gnus-update-format-specifications)
3141 (gnus-summary-make-display-table)
3142 (let ((buffer-read-only nil))
3144 (if (not gnus-inhibit-startup-message)
3146 (gnus-group-startup-message)
3148 (gnus-setup-news nil level)
3149 (and gnus-use-dribble-file (gnus-dribble-open))
3150 (gnus-group-list-groups level)
3151 (gnus-configure-windows 'group))))))
3153 (defun gnus-group-startup-message (&optional x y)
3154 "Insert startup message in current buffer."
3155 ;; Insert the message.
3171 ;; And then hack it.
3172 ;; 18 is the longest line.
3173 (indent-rigidly (point-min) (point-max)
3174 (/ (max (- (window-width) (or x 28)) 0) 2))
3175 (goto-char (point-min))
3176 ;; +4 is fuzzy factor.
3177 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3180 (goto-char (point-min))
3181 (search-forward "Praxis")
3182 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3183 (goto-char (point-min)))
3185 (defun gnus-group-setup-buffer ()
3186 (or (get-buffer gnus-group-buffer)
3188 (switch-to-buffer gnus-group-buffer)
3189 (gnus-add-current-to-buffer-list)
3191 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3193 (defun gnus-group-list-groups (level &optional unread)
3194 "List newsgroups with level LEVEL or lower that have unread articles.
3195 Default is all subscribed groups.
3196 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3197 (interactive (list (and current-prefix-arg
3198 (prefix-numeric-value current-prefix-arg))))
3199 (if gnus-group-use-permanent-levels
3201 (setq gnus-group-default-list-level
3202 (or level gnus-group-default-list-level))
3203 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3204 (setq level (or level gnus-group-default-list-level
3205 gnus-level-subscribed)))
3206 (gnus-group-setup-buffer) ;May call from out of group buffer
3207 (let ((case-fold-search nil)
3208 (group (gnus-group-group-name)))
3209 (funcall gnus-group-prepare-function level unread nil)
3210 (if (zerop (buffer-size))
3211 (gnus-message 5 gnus-no-groups-message)
3212 (goto-char (point-min))
3214 ;; Go to the first group with unread articles.
3215 (gnus-group-search-forward nil nil nil t)
3216 ;; Find the right group to put point on. If the current group
3217 ;; has disapeared in the new listing, try to find the next
3218 ;; one. If no next one can be found, just leave point at the
3219 ;; first newsgroup in the buffer.
3220 (if (not (gnus-goto-char
3221 (text-property-any (point-min) (point-max)
3222 'gnus-group (intern group))))
3223 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3225 (not (gnus-goto-char
3227 (point-min) (point-max) 'gnus-group
3228 (intern (car (car newsrc)))))))
3229 (setq newsrc (cdr newsrc)))
3230 (or newsrc (progn (goto-char (point-max))
3231 (forward-line -1))))))
3232 ;; Adjust cursor point.
3233 (gnus-group-position-cursor))))
3235 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3236 "List all newsgroups with unread articles of level LEVEL or lower.
3237 If ALL is non-nil, list groups that have no unread articles.
3238 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3239 If REGEXP, only list groups matching REGEXP."
3240 (set-buffer gnus-group-buffer)
3241 (let ((buffer-read-only nil)
3242 (newsrc (cdr gnus-newsrc-alist))
3243 (lowest (or lowest 1))
3244 info clevel unread group)
3246 (if (< lowest gnus-level-zombie)
3247 ;; List living groups.
3249 (setq info (car newsrc)
3252 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3253 (and unread ; This group might be bogus
3255 (string-match regexp group))
3256 (<= (setq clevel (car (cdr info))) level)
3258 (or all ; We list all groups?
3259 (eq unread t) ; We list unactivated groups
3260 (> unread 0) ; We list groups with unread articles
3261 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3262 (gnus-group-insert-group-line
3263 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3265 ;; List dead groups.
3266 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3267 (gnus-group-prepare-flat-list-dead
3268 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3269 gnus-level-zombie ?Z
3271 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3272 (gnus-group-prepare-flat-list-dead
3273 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3274 gnus-level-killed ?K regexp))
3276 (gnus-group-set-mode-line)
3277 (setq gnus-have-all-newsgroups all)
3278 (run-hooks 'gnus-group-prepare-hook)))
3280 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3281 ;; List zombies and killed lists somehwat faster, which was
3282 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3283 ;; this by ignoring the group format specification altogether.
3286 (setq group (car groups)
3287 groups (cdr groups))
3288 (if (or (not regexp)
3289 (string-match regexp group))
3292 (insert (format " %c *: %s\n" mark group))
3293 (add-text-properties
3295 (list 'gnus-group (intern group)
3297 'gnus-level level)))))))
3299 (defun gnus-group-real-name (group)
3300 "Find the real name of a foreign newsgroup."
3301 (if (string-match ":[^:]+$" group)
3302 (substring group (1+ (match-beginning 0)))
3305 (defun gnus-group-prefixed-name (group method)
3306 "Return the whole name from GROUP and METHOD."
3307 (and (stringp method) (setq method (gnus-server-to-method method)))
3308 (concat (format "%s" (car method))
3310 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3311 (not (string= (nth 1 method) "")))
3312 (concat "+" (nth 1 method)))
3315 (defun gnus-group-real-prefix (group)
3316 "Return the prefix of the current group name."
3317 (if (string-match "^[^:]+:" group)
3318 (substring group 0 (match-end 0))
3321 (defun gnus-group-method-name (group)
3322 "Return the method used for selecting GROUP."
3323 (let ((prefix (gnus-group-real-prefix group)))
3324 (if (equal prefix "")
3326 (if (string-match "^[^\\+]+\\+" prefix)
3327 (list (intern (substring prefix 0 (1- (match-end 0))))
3328 (substring prefix (match-end 0) (1- (length prefix))))
3329 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3331 (defun gnus-group-foreign-p (group)
3332 "Return nil if GROUP is native, non-nil if it is foreign."
3333 (string-match ":" group))
3335 (defun gnus-group-set-info (info &optional method-only-group part)
3336 (let* ((entry (gnus-gethash
3337 (or method-only-group (car info)) gnus-newsrc-hashtb))
3339 (info (if method-only-group (nth 2 entry) info)))
3340 (if (not method-only-group)
3343 (error "Trying to change non-existent group %s" method-only-group))
3344 ;; We have recevied parts of the actual group info - either the
3345 ;; select method or the group parameters. We first check
3346 ;; whether we have to extend the info, and if so, do that.
3347 (let ((len (length info))
3348 (total (if (eq part 'method) 5 6)))
3350 (setcdr (nthcdr (1- len) info)
3351 (make-list (- total len) nil)))
3352 ;; Then we enter the new info.
3353 (setcar (nthcdr (1- total) info) part-info)))
3354 ;; We uncompress some lists of marked articles.
3356 (if (not (setq marked (nth 3 info)))
3359 (or (eq 'score (car (car marked)))
3360 (eq 'bookmark (car (car marked)))
3361 (eq 'killed (car (car marked)))
3362 (setcdr (car marked)
3363 (gnus-uncompress-range (cdr (car marked)))))
3364 (setq marked (cdr marked)))))
3367 ;; This is a new group, so we just create it.
3369 (set-buffer gnus-group-buffer)
3371 ;; It's a foreign group...
3372 (gnus-group-make-group
3373 (gnus-group-real-name (car info))
3374 (prin1-to-string (car (nth 4 info)))
3375 (nth 1 (nth 4 info)))
3376 ;; It's a native group.
3377 (gnus-group-make-group
3379 (prin1-to-string (car gnus-select-method))
3380 (nth 1 gnus-select-method)))
3381 (gnus-message 6 "Note: New group created")
3383 (gnus-gethash (gnus-group-prefixed-name
3384 (gnus-group-real-name (car info))
3385 (or (nth 4 info) gnus-select-method))
3386 gnus-newsrc-hashtb))))
3387 ;; Whether it was a new group or not, we now have the entry, so we
3388 ;; can do the update.
3391 (setcar (nthcdr 2 entry) info)
3392 (if (and (not (eq (car entry) t))
3393 (gnus-gethash (car info) gnus-active-hashtb))
3394 (let ((marked (nth 3 info)))
3396 (max 0 (- (length (gnus-list-of-unread-articles
3398 (length (cdr (assq 'tick marked)))
3399 (length (cdr (assq 'dormant marked)))))))))
3400 (error "No such group: %s" (car info)))))
3402 (defun gnus-group-set-method-info (group select-method)
3403 (gnus-group-set-info select-method group 'method))
3405 (defun gnus-group-set-params-info (group params)
3406 (gnus-group-set-info params group 'params))
3408 (defun gnus-group-update-group-line ()
3409 "This function updates the current line in the newsgroup buffer and
3410 moves the point to the colon."
3411 (let* ((buffer-read-only nil)
3412 (group (gnus-group-group-name))
3413 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3416 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3419 (delete-region (point) (progn (forward-line 1) (point)))
3420 (gnus-group-insert-group-line-info group)
3422 (gnus-group-position-cursor)))
3424 (defun gnus-group-insert-group-line-info (group)
3425 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3429 (setq info (nth 2 entry))
3430 (gnus-group-insert-group-line
3431 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3432 (setq active (gnus-gethash group gnus-active-hashtb))
3433 (gnus-group-insert-group-line
3435 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3436 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3438 (defun gnus-group-insert-group-line (gformat group level marked number method)
3439 (let* ((gformat (or gformat gnus-group-line-format-spec))
3440 (active (gnus-gethash group gnus-active-hashtb))
3441 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3442 (number-of-dormant (length (cdr (assq 'dormant marked))))
3443 (number-of-ticked (length (cdr (assq 'tick marked))))
3444 (number-of-ticked-and-dormant
3445 (+ number-of-ticked number-of-dormant))
3446 (number-of-unread-unticked
3447 (if (numberp number) (int-to-string (max 0 number))
3450 (if (numberp number)
3451 (max 0 (- number-total number))
3453 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3454 ((<= level gnus-level-unsubscribed) ?U)
3455 ((= level gnus-level-zombie) ?Z)
3457 (qualified-group (gnus-group-real-name group))
3458 (newsgroup-description
3459 (if gnus-description-hashtb
3460 (or (gnus-gethash group gnus-description-hashtb) "")
3462 (moderated (if (member group gnus-moderated-list) ?m ? ))
3463 (moderated-string (if (eq moderated ?m) "(m)" ""))
3464 (method (gnus-server-get-method group method))
3465 (news-server (or (car (cdr method)) ""))
3466 (news-method (or (car method) ""))
3468 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3472 (> number-of-ticked 0))
3474 (number (if (eq number t) "*" (+ number number-of-dormant
3476 (process-marked (if (member qualified-group gnus-group-marked)
3477 gnus-process-mark ? ))
3478 (buffer-read-only nil)
3483 (insert (eval gformat))
3485 (add-text-properties
3486 b (1+ b) (list 'gnus-group (intern group)
3487 'gnus-unread (if (numberp number)
3488 (string-to-int number-of-unread-unticked)
3491 'gnus-level level))))
3493 (defun gnus-group-update-group (group &optional visible-only)
3494 "Update newsgroup info of GROUP.
3495 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3497 (set-buffer gnus-group-buffer)
3498 (let ((buffer-read-only nil)
3500 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3503 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3505 ;; Buffer may be narrowed.
3508 ;; Search a line to modify. If the buffer is large, the search
3509 ;; takes long time. In most cases, current point is on the line
3510 ;; we are looking for. So, first of all, check current line.
3513 (eq (get-text-property (point) 'gnus-group)
3518 (point-min) (point-max) 'gnus-group (intern group)))))
3519 ;; GROUP is listed in current buffer. So, delete old line.
3523 (delete-region (point) (progn (forward-line 1) (point))))
3524 ;; No such line in the buffer, find out where it's supposed to
3525 ;; go, and insert it there (or at the end of the buffer).
3526 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3529 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3535 (point-min) (point-max)
3536 'gnus-group (intern (car (car entry)))))))
3537 (setq entry (cdr entry)))
3538 (or entry (goto-char (point-max)))))))
3539 (if (or visible (not visible-only))
3540 (gnus-group-insert-group-line-info group))
3541 (gnus-group-set-mode-line))))
3543 (defun gnus-group-set-mode-line ()
3544 (if (memq 'group gnus-updated-mode-lines)
3545 (let* ((gformat (or gnus-group-mode-line-format-spec
3546 (setq gnus-group-mode-line-format-spec
3548 gnus-group-mode-line-format
3549 gnus-group-mode-line-format-alist))))
3550 (news-server (car (cdr gnus-select-method)))
3551 (news-method (car gnus-select-method))
3553 (mode-string (eval gformat)))
3554 (setq mode-string (eval gformat))
3555 (if (> (length mode-string) max-len)
3556 (setq mode-string (substring mode-string 0 (- max-len 4))))
3557 (setq mode-line-buffer-identification mode-string)
3558 (set-buffer-modified-p t))))
3560 (defun gnus-group-group-name ()
3561 "Get the name of the newsgroup on the current line."
3562 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3563 (and group (symbol-name group))))
3565 (defun gnus-group-group-level ()
3566 "Get the level of the newsgroup on the current line."
3567 (get-text-property (gnus-point-at-bol) 'gnus-level))
3569 (defun gnus-group-group-unread ()
3570 "Get the number of unread articles of the newsgroup on the current line."
3571 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3573 (defun gnus-group-search-forward (&optional backward all level first-too)
3574 "Find the next newsgroup with unread articles.
3575 If BACKWARD is non-nil, find the previous newsgroup instead.
3576 If ALL is non-nil, just find any newsgroup.
3577 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3579 If FIRST-TOO, the current line is also eligible as a target."
3580 (let ((way (if backward -1 1))
3584 (if (and backward (progn (beginning-of-line)) (bobp))
3586 (or first-too (forward-line way))
3594 (get-text-property (point) 'gnus-unread)))
3595 (or (eq unread t) (and unread (> unread 0))))
3596 (let ((lev (get-text-property
3597 (point) 'gnus-level)))
3598 (and lev (<= (get-text-property
3599 (point) 'gnus-level)
3600 gnus-level-subscribed)))))
3602 (let ((lev (get-text-property (point) 'gnus-level)))
3603 (if (and lev (<= lev level))
3608 (setq pos (point))))
3610 (zerop (forward-line way)))))
3612 (progn (gnus-group-position-cursor) t)
3613 (if pos (goto-char pos) (goto-char beg))
3616 ;;; Gnus group mode commands
3620 (defun gnus-group-mark-group (n &optional unmark no-advance)
3621 "Mark the current group."
3623 (let ((buffer-read-only nil)
3627 (setq group (gnus-group-group-name))
3635 (setq gnus-group-marked (delete group gnus-group-marked)))
3637 (setq gnus-group-marked
3638 (cons group (delete group gnus-group-marked))))
3640 (or no-advance (zerop (gnus-group-next-group 1))))
3642 (gnus-summary-position-cursor)
3645 (defun gnus-group-unmark-group (n)
3646 "Remove the mark from the current group."
3648 (gnus-group-mark-group n 'unmark))
3650 (defun gnus-group-mark-region (unmark beg end)
3651 "Mark all groups between point and mark.
3652 If UNMARK, remove the mark instead."
3653 (interactive "P\nr")
3654 (let ((num (count-lines beg end)))
3657 (- num (gnus-group-mark-group num unmark)))))
3659 (defun gnus-group-remove-mark (group)
3660 (and (gnus-group-goto-group group)
3662 (gnus-group-mark-group 1 'unmark t))))
3664 ;; Return a list of groups to work on. Take into consideration N (the
3665 ;; prefix) and the list of marked groups.
3666 (defun gnus-group-process-prefix (n)
3668 (setq n (prefix-numeric-value n))
3669 ;; There is a prefix, so we return a list of the N next
3671 (let ((way (if (< n 0) -1 1))
3676 (setq group (gnus-group-group-name)))
3677 (setq groups (cons group groups))
3679 (forward-line way)))
3682 ;; No prefix, but a list of marked articles.
3683 (reverse gnus-group-marked))
3685 ;; Neither marked articles or a prefix, so we return the
3687 (let ((group (gnus-group-group-name)))
3688 (and group (list group))))))
3690 ;; Selecting groups.
3692 (defun gnus-group-read-group (all &optional no-article group)
3693 "Read news in this newsgroup.
3694 If argument ALL is non-nil, already read articles become readable.
3695 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3697 (let ((group (or group (gnus-group-group-name)))
3698 number active marked entry)
3699 (or group (error "No group on current line"))
3701 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3702 ;; This group might be a dead group. In that case we have to get
3703 ;; the number of unread articles from `gnus-active-hashtb'.
3705 (setq number (car entry))
3706 (if (setq active (gnus-gethash group gnus-active-hashtb))
3707 (setq number (- (1+ (cdr active)) (car active)))))
3708 (gnus-summary-read-group
3709 group (or all (and (numberp number)
3710 (zerop (+ number (length (cdr (assq 'tick marked)))
3711 (length (cdr (assq 'dormant marked)))))))
3714 (defun gnus-group-select-group (all)
3715 "Select this newsgroup.
3716 No article is selected automatically.
3717 If argument ALL is non-nil, already read articles become readable."
3719 (gnus-group-read-group all t))
3721 ;; Enter a group that is not in the group buffer. Non-nil is returned
3722 ;; if selection was successful.
3723 (defun gnus-group-read-ephemeral-group
3724 (group method &optional activate quit-config)
3725 (let ((group (if (gnus-group-foreign-p group) group
3726 (gnus-group-prefixed-name group method))))
3729 (list t nil (list group gnus-level-default-subscribed nil nil
3733 (if quit-config quit-config
3734 (cons (current-buffer) 'summary)))))))
3736 (set-buffer gnus-group-buffer)
3737 (or (gnus-server-opened method)
3738 (gnus-open-server method)
3739 (error "Unable to contact server: %s" (gnus-status-message method)))
3740 (if activate (gnus-request-group group))
3742 (gnus-group-read-group t t group)
3745 (not (equal major-mode 'gnus-group-mode))))
3747 (defun gnus-group-jump-to-group (group)
3748 "Jump to newsgroup GROUP."
3750 (list (completing-read
3751 "Group: " gnus-active-hashtb nil (not (not gnus-read-active-file)))))
3753 (if (equal group "")
3754 (error "Empty group name"))
3756 (let ((b (text-property-any
3757 (point-min) (point-max) 'gnus-group (intern group))))
3759 ;; Either go to the line in the group buffer...
3761 ;; ... or insert the line.
3763 (gnus-gethash group gnus-active-hashtb)
3764 (gnus-activate-newsgroup group)
3765 (error "%s error: %s" group (gnus-status-message group)))
3767 (gnus-group-update-group group)
3768 (goto-char (text-property-any
3769 (point-min) (point-max) 'gnus-group (intern group)))))
3770 ;; Adjust cursor point.
3771 (gnus-group-position-cursor))
3773 (defun gnus-group-goto-group (group)
3774 "Goto to newsgroup GROUP."
3775 (let ((b (text-property-any (point-min) (point-max)
3776 'gnus-group (intern group))))
3777 (and b (goto-char b))))
3779 (defun gnus-group-next-group (n)
3780 "Go to next N'th newsgroup.
3781 If N is negative, search backward instead.
3782 Returns the difference between N and the number of skips actually
3785 (gnus-group-next-unread-group n t))
3787 (defun gnus-group-next-unread-group (n &optional all level)
3788 "Go to next N'th unread newsgroup.
3789 If N is negative, search backward instead.
3790 If ALL is non-nil, choose any newsgroup, unread or not.
3791 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3792 such group can be found, the next group with a level higher than
3794 Returns the difference between N and the number of skips actually
3797 (let ((backward (< n 0))
3800 (gnus-group-search-forward
3801 backward (or (not gnus-group-goto-unread) all) level))
3803 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3804 (if level " on this level or higher" "")))
3807 (defun gnus-group-prev-group (n)
3808 "Go to previous N'th newsgroup.
3809 Returns the difference between N and the number of skips actually
3812 (gnus-group-next-unread-group (- n) t))
3814 (defun gnus-group-prev-unread-group (n)
3815 "Go to previous N'th unread newsgroup.
3816 Returns the difference between N and the number of skips actually
3819 (gnus-group-next-unread-group (- n)))
3821 (defun gnus-group-next-unread-group-same-level (n)
3822 "Go to next N'th unread newsgroup on the same level.
3823 If N is negative, search backward instead.
3824 Returns the difference between N and the number of skips actually
3827 (gnus-group-next-unread-group n t (gnus-group-group-level))
3828 (gnus-group-position-cursor))
3830 (defun gnus-group-prev-unread-group-same-level (n)
3831 "Go to next N'th unread newsgroup on the same level.
3832 Returns the difference between N and the number of skips actually
3835 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3836 (gnus-group-position-cursor))
3838 (defun gnus-group-best-unread-group (&optional exclude-group)
3839 "Go to the group with the highest level.
3840 If EXCLUDE-GROUP, do not go to that group."
3842 (goto-char (point-min))
3845 (while (setq unread (get-text-property (point) 'gnus-unread))
3846 (if (and (numberp unread) (> unread 0))
3848 (if (and (< (get-text-property (point) 'gnus-level) best)
3849 (or (not exclude-group)
3850 (not (equal exclude-group (gnus-group-group-name)))))
3852 (setq best (get-text-property (point) 'gnus-level))
3853 (setq best-point (point))))))
3855 (if best-point (goto-char best-point))
3856 (gnus-summary-position-cursor)
3857 (and best-point (gnus-group-group-name))))
3859 (defun gnus-group-first-unread-group ()
3860 "Go to the first group with unread articles."
3862 (goto-char (point-min))
3863 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3864 (gnus-group-next-unread-group 1))
3865 (gnus-group-position-cursor))
3867 (defun gnus-group-enter-server-mode ()
3868 "Jump to the server buffer."
3870 (gnus-server-setup-buffer)
3871 (gnus-configure-windows 'server)
3872 (gnus-server-prepare))
3874 (defun gnus-group-make-group (name method &optional address)
3875 "Add a new newsgroup.
3876 The user will be prompted for a NAME, for a select METHOD, and an
3880 (read-string "Group name: ")
3883 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3885 (if (assoc method gnus-valid-select-methods)
3887 (if (memq 'prompt-address
3888 (assoc method gnus-valid-select-methods))
3889 (read-string "Address: ")
3891 (list method nil)))))
3893 (let* ((meth (if address (list (intern method) address) method))
3894 (nname (gnus-group-prefixed-name name meth))
3896 (and (gnus-gethash nname gnus-newsrc-hashtb)
3897 (error "Group %s already exists" nname))
3898 (gnus-group-change-level
3899 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3900 gnus-level-default-subscribed gnus-level-killed
3901 (and (gnus-group-group-name)
3902 (gnus-gethash (gnus-group-group-name)
3903 gnus-newsrc-hashtb))
3905 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
3907 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3908 (gnus-group-insert-group-line-info nname)
3910 (require (intern method))
3911 (and (gnus-check-backend-function 'request-create-group nname)
3912 (gnus-request-create-group nname))))
3914 (defun gnus-group-edit-group (group &optional part)
3915 "Edit the group on the current line."
3916 (interactive (list (gnus-group-group-name)))
3917 (let ((done-func '(lambda ()
3918 "Exit editing mode and update the information."
3920 (gnus-group-edit-group-done 'part 'group)))
3921 (part (or part 'info))
3922 (winconf (current-window-configuration))
3924 (or group (error "No group on current line"))
3925 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3926 (error "Killed group; can't be edited"))
3927 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3928 (gnus-configure-windows 'edit-group)
3929 (gnus-add-current-to-buffer-list)
3931 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3932 (use-local-map (copy-keymap emacs-lisp-mode-map))
3933 (local-set-key "\C-c\C-c" done-func)
3934 (make-local-variable 'gnus-prev-winconf)
3935 (setq gnus-prev-winconf winconf)
3936 ;; We modify the func to let it know what part it is editing.
3937 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3938 (setcar (cdr (cdr (nth 4 done-func))) group)
3943 ";; Type `C-c C-c' after editing the select method.\n\n")
3945 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3947 ";; Type `C-c C-c' after editing the group info.\n\n")))
3948 (let ((cinfo (gnus-copy-sequence info))
3950 (if (not (setq marked (nth 3 cinfo)))
3953 (or (eq 'score (car (car marked)))
3954 (eq 'bookmark (car (car marked)))
3955 (eq 'killed (car (car marked)))
3956 (not (numberp (car (cdr (car marked)))))
3957 (setcdr (car marked)
3958 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3959 (setq marked (cdr marked))))
3962 (cond ((eq part 'method)
3963 (or (nth 4 info) "native"))
3970 (defun gnus-group-edit-group-method (group)
3971 "Edit the select method of GROUP."
3972 (interactive (list (gnus-group-group-name)))
3973 (gnus-group-edit-group group 'method))
3975 (defun gnus-group-edit-group-parameters (group)
3976 "Edit the group parameters of GROUP."
3977 (interactive (list (gnus-group-group-name)))
3978 (gnus-group-edit-group group 'params))
3980 (defun gnus-group-edit-group-done (part group)
3981 "Get info from buffer, update variables and jump to the group buffer."
3982 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3983 (goto-char (point-min))
3984 (let ((form (read (current-buffer)))
3985 (winconf gnus-prev-winconf))
3987 (gnus-group-set-info form)
3988 (gnus-group-set-info form group part))
3989 (kill-buffer (current-buffer))
3990 (and winconf (set-window-configuration winconf))
3991 (set-buffer gnus-group-buffer)
3992 (gnus-group-update-group (gnus-group-group-name))
3993 (gnus-group-position-cursor)))
3995 (defun gnus-group-make-help-group ()
3996 "Create the (ding) Gnus documentation group."
3998 (let ((path load-path)
4000 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4001 "gnus-help" '(nndoc "gnus-help")))
4003 (error "Documentation group already exists"))
4005 (not (file-exists-p (concat (file-name-as-directory (car path))
4007 (setq path (cdr path)))
4008 (or path (error "Couldn't find doc group"))
4009 (gnus-group-make-group
4010 (gnus-group-real-name name)
4012 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4013 (list 'nndoc-article-type 'mbox))))
4014 (gnus-group-position-cursor))
4016 (defun gnus-group-make-doc-group (file type)
4017 "Create a group that uses a single file as the source."
4019 (list (read-file-name "File name: ")
4023 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4024 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4025 ((= char ?b) 'babyl)
4026 ((= char ?d) 'digest)
4027 (t (setq err "%c unknown. " char)
4030 (let* ((file (expand-file-name file))
4031 (name (gnus-generate-new-group-name
4032 (gnus-group-prefixed-name
4033 (file-name-nondirectory file) '(nndoc "")))))
4034 (gnus-group-make-group
4035 (gnus-group-real-name name)
4037 (list 'nndoc-address file)
4038 (list 'nndoc-article-type type)))))
4040 (defun gnus-group-make-archive-group ()
4041 "Create the (ding) Gnus archive group."
4043 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
4045 (error "Archive group already exists"))
4046 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
4047 (gnus-group-position-cursor))
4049 (defun gnus-group-make-directory-group (dir)
4050 "Create an nndir group.
4051 The user will be prompted for a directory. The contents of this
4052 directory will be used as a newsgroup. The directory should contain
4053 mail messages or news articles in files that have numeric names."
4055 (list (read-file-name "Create group from directory: ")))
4056 (or (file-exists-p dir) (error "No such directory"))
4057 (or (file-directory-p dir) (error "Not a directory"))
4058 (gnus-group-make-group dir "nndir" dir)
4059 (gnus-group-position-cursor))
4061 (defun gnus-group-make-kiboze-group (group address scores)
4062 "Create an nnkiboze group.
4063 The user will be prompted for a name, a regexp to match groups, and
4064 score file entries for articles to include in the group."
4067 (read-string "nnkiboze group name: ")
4068 (read-string "Source groups (regexp): ")
4069 (let ((headers (mapcar (lambda (group) (list group))
4070 '("subject" "from" "number" "date" "message-id"
4071 "references" "chars" "lines" "xref")))
4072 scores header regexp regexps)
4073 (while (not (equal "" (setq header (completing-read
4074 "Match on header: " headers nil t))))
4076 (while (not (equal "" (setq regexp (read-string
4077 (format "Match on %s (string): "
4079 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4080 (setq scores (cons (cons header regexps) scores)))
4082 (gnus-group-make-group group "nnkiboze" address)
4084 (gnus-set-work-buffer)
4085 (let (emacs-lisp-mode-hook)
4086 (pp scores (current-buffer)))
4087 (write-region (point-min) (point-max)
4088 (concat (or gnus-kill-files-directory "~/News")
4089 "nnkiboze:" group "." gnus-score-file-suffix)))
4090 (gnus-group-position-cursor))
4092 (defun gnus-group-add-to-virtual (n vgroup)
4093 "Add the current group to a virtual group."
4095 (list current-prefix-arg
4096 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4098 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4099 (error "%s is not an nnvirtual group" vgroup))
4100 (let* ((groups (gnus-group-process-prefix n))
4101 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4102 (setcar (cdr method)
4104 (nth 1 method) "\\|"
4107 (gnus-group-remove-mark s)
4108 (concat "\\(^" (regexp-quote s) "$\\)"))
4110 (gnus-group-position-cursor))
4112 (defun gnus-group-make-empty-virtual (group)
4113 "Create a new, fresh, empty virtual group."
4114 (interactive "sCreate new, empty virtual group: ")
4115 (let* ((method (list 'nnvirtual "^$"))
4116 (pgroup (gnus-group-prefixed-name group method)))
4117 ;; Check whether it exists already.
4118 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4119 (error "Group %s already exists." pgroup))
4120 ;; Subscribe the new group after the group on the current line.
4121 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4122 (gnus-group-update-group pgroup)
4124 (gnus-group-position-cursor)))
4126 (defun gnus-group-enter-directory (dir)
4127 "Enter an ephemeral nneething group."
4128 (interactive "DDirectory to read: ")
4129 (let* ((method (list 'nneething dir))
4130 (leaf (gnus-group-prefixed-name
4131 (file-name-nondirectory (directory-file-name dir))
4133 (name (gnus-generate-new-group-name leaf)))
4134 (let ((nneething-read-only t))
4135 (or (gnus-group-read-ephemeral-group
4137 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4139 (error "Couldn't enter %s" dir)))))
4141 ;; Group sorting commands
4142 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4144 (defun gnus-group-sort-groups ()
4145 "Sort the group buffer using `gnus-group-sort-function'."
4147 (setq gnus-newsrc-alist
4148 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4149 (gnus-make-hashtable-from-newsrc-alist)
4150 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4152 (defun gnus-group-sort-by-alphabet (info1 info2)
4153 (string< (car info1) (car info2)))
4155 (defun gnus-group-sort-by-unread (info1 info2)
4156 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4157 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4158 (< (or (and (numberp n1) n1) 0)
4159 (or (and (numberp n2) n2) 0))))
4161 (defun gnus-group-sort-by-level (info1 info2)
4162 (< (nth 1 info1) (nth 1 info2)))
4164 ;; Group catching up.
4166 (defun gnus-group-catchup-current (n &optional all)
4167 "Mark all articles not marked as unread in current newsgroup as read.
4168 If prefix argument N is numeric, the ARG next newsgroups will be
4169 caught up. If ALL is non-nil, marked articles will also be marked as
4170 read. Cross references (Xref: header) of articles are ignored.
4171 The difference between N and actual number of newsgroups that were
4172 caught up is returned."
4174 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4178 "Do you really want to mark all articles as read? "
4179 "Mark all unread articles as read? "))))
4181 (let ((groups (gnus-group-process-prefix n))
4184 ;; Virtual groups have to be given special treatment.
4185 (let ((method (gnus-find-method-for-group (car groups))))
4186 (if (eq 'nnvirtual (car method))
4187 (nnvirtual-catchup-group
4188 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4189 (gnus-group-remove-mark (car groups))
4191 (gnus-group-goto-group (car groups))
4192 (gnus-group-catchup (car groups) all))
4193 (gnus-group-update-group-line)
4194 (setq ret (1+ ret)))
4195 (setq groups (cdr groups)))
4196 (gnus-group-next-unread-group 1)
4199 (defun gnus-group-catchup-current-all (n)
4200 "Mark all articles in current newsgroup as read.
4201 Cross references (Xref: header) of articles are ignored."
4203 (gnus-group-catchup-current n 'all))
4205 (defun gnus-group-catchup (group &optional all)
4206 "Mark all articles in GROUP as read.
4207 If ALL is non-nil, all articles are marked as read.
4208 The return value is the number of articles that were marked as read,
4209 or nil if no action could be taken."
4210 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4212 (marked (nth 3 (nth 2 entry))))
4213 (if (not (numberp (car entry)))
4214 (gnus-message 1 "Can't catch up; non-active group")
4215 ;; Do the updating only if the newsgroup isn't killed.
4218 (gnus-update-read-articles
4219 group (and (not all) (append (cdr (assq 'tick marked))
4220 (cdr (assq 'dormant marked))))
4221 nil (and (not all) (cdr (assq 'tick marked))))
4223 (setcar (nthcdr 3 (nth 2 entry))
4224 (delq (assq 'dormant marked)
4225 (nth 3 (nth 2 entry)))))))
4228 (defun gnus-group-expire-articles (n)
4229 "Expire all expirable articles in the current newsgroup."
4231 (let ((groups (gnus-group-process-prefix n))
4233 (or groups (error "No groups to expire"))
4235 (setq group (car groups)
4236 groups (cdr groups))
4237 (gnus-group-remove-mark group)
4238 (if (not (gnus-check-backend-function 'request-expire-articles group))
4240 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4241 (expirable (if (memq 'total-expire (nth 5 info))
4242 (cons nil (gnus-list-of-read-articles group))
4243 (assq 'expire (nth 3 info)))))
4246 (gnus-request-expire-articles
4247 (cdr expirable) group))))))))
4249 (defun gnus-group-expire-all-groups ()
4250 "Expire all expirable articles in all newsgroups."
4253 (gnus-message 5 "Expiring...")
4254 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4255 (cdr gnus-newsrc-alist))))
4256 (gnus-group-expire-articles nil)))
4257 (gnus-group-position-cursor)
4258 (gnus-message 5 "Expiring...done"))
4260 (defun gnus-group-set-current-level (n level)
4261 "Set the level of the next N groups to LEVEL."
4262 (interactive "P\nnLevel: ")
4263 (or (and (>= level 1) (<= level gnus-level-killed))
4264 (error "Illegal level: %d" level))
4265 (let ((groups (gnus-group-process-prefix n))
4268 (setq group (car groups)
4269 groups (cdr groups))
4270 (gnus-group-remove-mark group)
4271 (gnus-message 6 "Changed level of %s from %d to %d"
4272 group (gnus-group-group-level) level)
4273 (gnus-group-change-level group level
4274 (gnus-group-group-level))
4275 (gnus-group-update-group-line)))
4276 (gnus-group-position-cursor))
4278 (defun gnus-group-unsubscribe-current-group (n)
4279 "Toggle subscription of the current group.
4280 If given numerical prefix, toggle the N next groups."
4282 (let ((groups (gnus-group-process-prefix n))
4285 (setq group (car groups)
4286 groups (cdr groups))
4287 (gnus-group-remove-mark group)
4288 (gnus-group-unsubscribe-group
4289 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4290 gnus-level-default-unsubscribed
4291 gnus-level-default-subscribed))
4292 (gnus-group-update-group-line))
4293 (gnus-group-next-group 1)))
4295 (defun gnus-group-unsubscribe-group (group &optional level)
4296 "Toggle subscribe from/to unsubscribe GROUP.
4297 New newsgroup is added to .newsrc automatically."
4299 (list (completing-read "Group: " gnus-active-hashtb nil
4300 gnus-have-read-active-file)))
4301 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4303 ;; Toggle subscription flag.
4304 (gnus-group-change-level
4305 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4306 gnus-level-subscribed)
4307 (1+ gnus-level-subscribed)
4308 gnus-level-default-subscribed)))
4309 (gnus-group-update-group group))
4310 ((and (stringp group)
4311 (or (not gnus-have-read-active-file)
4312 (gnus-gethash group gnus-active-hashtb)))
4313 ;; Add new newsgroup.
4314 (gnus-group-change-level
4316 (if level level gnus-level-default-subscribed)
4317 (or (and (member group gnus-zombie-list)
4320 (and (gnus-group-group-name)
4321 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4322 (gnus-group-update-group group))
4323 (t (error "No such newsgroup: %s" group)))
4324 (gnus-group-position-cursor)))
4326 (defun gnus-group-transpose-groups (n)
4327 "Move the current newsgroup up N places.
4328 If given a negative prefix, move down instead. The difference between
4329 N and the number of steps taken is returned."
4331 (or (gnus-group-group-name)
4332 (error "No group on current line"))
4333 (gnus-group-kill-group 1)
4335 (forward-line (- n))
4336 (gnus-group-yank-group)
4337 (gnus-group-position-cursor)))
4339 (defun gnus-group-kill-all-zombies ()
4340 "Kill all zombie newsgroups."
4342 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4343 (setq gnus-zombie-list nil)
4344 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4345 (goto-char (point-min))
4346 (gnus-group-position-cursor))
4348 (defun gnus-group-kill-region (begin end)
4349 "Kill newsgroups in current region (excluding current point).
4350 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4365 (beginning-of-line) ;Important when LINES < 1
4366 (gnus-group-kill-group lines)))
4368 (defun gnus-group-kill-group (n)
4369 "The the next N groups.
4370 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4371 However, only groups that were alive can be yanked; already killed
4372 groups or zombie groups can't be yanked.
4373 The return value is the name of the (last) group that was killed."
4375 (let ((buffer-read-only nil)
4376 (groups (gnus-group-process-prefix n))
4379 (setq group (car groups)
4380 groups (cdr groups))
4381 (gnus-group-remove-mark group)
4382 (setq level (gnus-group-group-level))
4384 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4385 (setq gnus-list-of-killed-groups
4386 (cons (cons (car entry) (nth 2 entry))
4387 gnus-list-of-killed-groups)))
4388 (gnus-group-change-level
4389 (if entry entry group) gnus-level-killed (if entry nil level)))
4390 (gnus-group-position-cursor)
4393 (defun gnus-group-yank-group (&optional arg)
4394 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4395 inserting it before the current newsgroup. The numeric ARG specifies
4396 how many newsgroups are to be yanked. The name of the (last)
4397 newsgroup yanked is returned."
4399 (if (not arg) (setq arg 1))
4400 (let (info group prev)
4401 (while (>= (setq arg (1- arg)) 0)
4402 (if (not (setq info (car gnus-list-of-killed-groups)))
4403 (error "No more newsgroups to yank"))
4404 (setq group (nth 2 info))
4405 ;; Find which newsgroup to insert this one before - search
4406 ;; backward until something suitable is found. If there are no
4407 ;; other newsgroups in this buffer, just make this newsgroup the
4409 (setq prev (gnus-group-group-name))
4410 (gnus-group-change-level
4411 info (nth 2 info) gnus-level-killed
4412 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4414 (gnus-group-insert-group-line-info (nth 1 info))
4415 (setq gnus-list-of-killed-groups
4416 (cdr gnus-list-of-killed-groups)))
4418 (gnus-group-position-cursor)
4421 (defun gnus-group-list-all-groups (arg)
4422 "List all newsgroups with level ARG or lower.
4423 Default is gnus-level-unsubscribed, which lists all subscribed and most
4424 unsubscribed groups."
4426 (setq arg (or arg gnus-level-unsubscribed))
4427 (gnus-group-list-groups arg t))
4429 (defun gnus-group-list-killed ()
4430 "List all killed newsgroups in the group buffer."
4432 (if (not gnus-killed-list)
4433 (gnus-message 6 "No killed groups")
4434 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4435 (goto-char (point-min)))
4436 (gnus-group-position-cursor))
4438 (defun gnus-group-list-zombies ()
4439 "List all zombie newsgroups in the group buffer."
4441 (if (not gnus-zombie-list)
4442 (gnus-message 6 "No zombie groups")
4443 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4444 (goto-char (point-min)))
4445 (gnus-group-position-cursor))
4447 (defun gnus-group-get-new-news (&optional arg)
4448 "Get newly arrived articles.
4449 If ARG is non-nil, it should be a number between one and nine to
4450 specify which levels you are interested in re-scanning."
4452 (run-hooks 'gnus-get-new-news-hook)
4454 (if gnus-group-use-permanent-levels
4456 (setq gnus-group-default-list-level level)
4457 (setq level (or gnus-group-default-list-level
4458 gnus-level-subscribed))))
4459 (if (and gnus-read-active-file (not level))
4461 (gnus-read-active-file)
4462 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
4463 (let ((gnus-read-active-file nil)
4464 (gnus-have-read-active-file (not arg)))
4465 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))))
4466 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels level)
4467 gnus-group-default-list-level
4468 gnus-level-subscribed)
4469 gnus-have-all-newsgroups)))
4471 (defun gnus-group-get-new-news-this-group (n)
4472 "Check for newly arrived news in the current group (and the N-1 next groups).
4473 The difference between N and the number of newsgroup checked is returned.
4474 If N is negative, this group and the N-1 previous groups will be checked."
4476 (let* ((groups (gnus-group-process-prefix n))
4477 (ret (if (numberp n) (- n (length groups)) 0))
4480 (setq group (car groups)
4481 groups (cdr groups))
4482 (gnus-group-remove-mark group)
4483 (or (gnus-get-new-news-in-group group)
4486 (message "%s error: %s" group (gnus-status-message group))
4488 ;; !!! I don't know why the buffer scrolls forward when updating
4489 ;; the first line in the group buffer, but it does. So we set the
4490 ;; window start forcibly.
4491 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4492 (gnus-group-next-unread-group 1 t)
4493 (gnus-summary-position-cursor)
4496 (defun gnus-get-new-news-in-group (group)
4498 (gnus-activate-newsgroup group)
4500 (gnus-get-unread-articles-in-group
4501 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4502 (gnus-gethash group gnus-active-hashtb))
4503 (gnus-group-update-group-line)
4506 (defun gnus-group-fetch-faq (group)
4507 "Fetch the FAQ for the current group."
4508 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4509 (or group (error "No group name given"))
4510 (let ((file (concat gnus-group-faq-directory group)))
4511 (if (not (file-exists-p file))
4512 (error "No such file: %s" file)
4515 (defun gnus-group-describe-group (force &optional group)
4516 "Display a description of the current newsgroup."
4517 (interactive (list current-prefix-arg (gnus-group-group-name)))
4518 (and force (setq gnus-description-hashtb nil))
4519 (let ((method (gnus-find-method-for-group group))
4521 (or group (error "No group name given"))
4522 (and (or (and gnus-description-hashtb
4523 ;; We check whether this group's method has been
4524 ;; queried for a description file.
4526 (gnus-group-prefixed-name "" method)
4527 gnus-description-hashtb))
4528 (setq desc (gnus-group-get-description group))
4529 (gnus-read-descriptions-file method))
4531 (or desc (gnus-gethash group gnus-description-hashtb)
4532 "No description available")))))
4534 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4535 (defun gnus-group-describe-all-groups (force)
4536 "Pop up a buffer with descriptions of all newsgroups."
4538 (and force (setq gnus-description-hashtb nil))
4539 (if (not (or gnus-description-hashtb
4540 (gnus-read-all-descriptions-files)))
4541 (error "Couldn't request descriptions file"))
4542 (let ((buffer-read-only nil)
4548 (insert (format " *: %-20s %s\n" (symbol-name group)
4549 (symbol-value group)))
4550 (add-text-properties
4551 b (1+ b) (list 'gnus-group group
4552 'gnus-unread t 'gnus-marked nil
4553 'gnus-level (1+ gnus-level-subscribed))))
4554 gnus-description-hashtb)
4555 (goto-char (point-min))
4556 (gnus-group-position-cursor)))
4558 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4559 (defun gnus-group-apropos (regexp &optional search-description)
4560 "List all newsgroups that have names that match a regexp."
4561 (interactive "sGnus apropos (regexp): ")
4563 (obuf (current-buffer))
4565 ;; Go through all newsgroups that are known to Gnus.
4568 (and (string-match regexp (symbol-name group))
4569 (setq groups (cons (symbol-name group) groups))))
4571 ;; Go through all descriptions that are known to Gnus.
4572 (if search-description
4575 (and (string-match regexp (symbol-value group))
4576 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4577 (setq groups (cons (symbol-name group) groups))))
4578 gnus-description-hashtb))
4580 (gnus-message 3 "No groups matched \"%s\"." regexp)
4581 ;; Print out all the groups.
4583 (pop-to-buffer "*Gnus Help*")
4584 (buffer-disable-undo (current-buffer))
4586 (setq groups (sort groups 'string<))
4588 ;; Groups may be entered twice into the list of groups.
4589 (if (not (string= (car groups) prev))
4591 (insert (setq prev (car groups)) "\n")
4592 (if (and gnus-description-hashtb
4593 (setq des (gnus-gethash (car groups)
4594 gnus-description-hashtb)))
4595 (insert " " des "\n"))))
4596 (setq groups (cdr groups)))
4597 (goto-char (point-min))))
4598 (pop-to-buffer obuf)))
4600 (defun gnus-group-description-apropos (regexp)
4601 "List all newsgroups that have names or descriptions that match a regexp."
4602 (interactive "sGnus description apropos (regexp): ")
4603 (if (not (or gnus-description-hashtb
4604 (gnus-read-all-descriptions-files)))
4605 (error "Couldn't request descriptions file"))
4606 (gnus-group-apropos regexp t))
4608 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4609 (defun gnus-group-list-matching (level regexp &optional all lowest)
4610 "List all groups with unread articles that match REGEXP.
4611 If the prefix LEVEL is non-nil, it should be a number that says which
4612 level to cut off listing groups.
4613 If ALL, also list groups with no unread articles.
4614 If LOWEST, don't list groups with level lower than LOWEST."
4615 (interactive "P\nsList newsgroups matching: ")
4616 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4617 all (or lowest 1) regexp)
4618 (goto-char (point-min))
4619 (gnus-group-position-cursor))
4621 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4622 "List all groups that match REGEXP.
4623 If the prefix LEVEL is non-nil, it should be a number that says which
4624 level to cut off listing groups.
4625 If LOWEST, don't list groups with level lower than LOWEST."
4626 (interactive "P\nsList newsgroups matching: ")
4627 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4629 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4630 (defun gnus-group-save-newsrc ()
4631 "Save the Gnus startup files."
4633 (gnus-save-newsrc-file))
4635 (defun gnus-group-restart (&optional arg)
4636 "Force Gnus to read the .newsrc file."
4638 (gnus-save-newsrc-file)
4639 (gnus-setup-news 'force)
4640 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4642 (defun gnus-group-read-init-file ()
4643 "Read the Gnus elisp init file."
4645 (gnus-read-init-file))
4647 (defun gnus-group-check-bogus-groups (silent)
4648 "Check bogus newsgroups.
4649 If given a prefix, don't ask for confirmation before removing a bogus
4652 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4653 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4655 (defun gnus-group-edit-global-kill (article &optional group)
4656 "Edit the global kill file.
4657 If GROUP, edit that local kill file instead."
4659 (setq gnus-current-kill-article article)
4660 (gnus-kill-file-edit-file group)
4662 (substitute-command-keys
4663 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4665 (defun gnus-group-edit-local-kill (article group)
4666 "Edit a local kill file."
4667 (interactive (list nil (gnus-group-group-name)))
4668 (gnus-group-edit-global-kill article group))
4670 (defun gnus-group-force-update ()
4671 "Update `.newsrc' file."
4673 (gnus-save-newsrc-file))
4675 (defun gnus-group-suspend ()
4676 "Suspend the current Gnus session.
4677 In fact, cleanup buffers except for group mode buffer.
4678 The hook gnus-suspend-gnus-hook is called before actually suspending."
4680 (run-hooks 'gnus-suspend-gnus-hook)
4681 ;; Kill Gnus buffers except for group mode buffer.
4682 (let ((group-buf (get-buffer gnus-group-buffer)))
4683 ;; Do this on a separate list in case the user does a ^G before we finish
4684 (let ((gnus-buffer-list
4685 (delq group-buf (delq gnus-dribble-buffer
4686 (append gnus-buffer-list nil)))))
4687 (while gnus-buffer-list
4688 (gnus-kill-buffer (car gnus-buffer-list))
4689 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4692 (setq gnus-buffer-list (list group-buf))
4693 (bury-buffer group-buf)
4694 (delete-windows-on group-buf t)))))
4696 (defun gnus-group-clear-dribble ()
4697 "Clear all information from the dribble buffer."
4699 (gnus-dribble-clear))
4701 (defun gnus-group-exit ()
4702 "Quit reading news after updating .newsrc.eld and .newsrc.
4703 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4705 (if (or noninteractive ;For gnus-batch-kill
4706 (zerop (buffer-size)) ;No news is good news.
4707 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4708 (not gnus-interactive-exit) ;Without confirmation
4710 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4712 (if gnus-use-full-window
4713 (delete-other-windows)
4714 (gnus-remove-some-windows))
4715 (run-hooks 'gnus-exit-gnus-hook)
4716 (gnus-offer-save-summaries)
4717 (gnus-save-newsrc-file)
4718 (gnus-close-backends)
4719 (gnus-clear-system))))
4721 (defun gnus-close-backends ()
4722 ;; Send a close request to all backends that support such a request.
4723 (let ((methods gnus-valid-select-methods)
4726 (if (fboundp (setq func (intern (concat (car (car methods))
4727 "-request-close"))))
4729 (setq methods (cdr methods)))))
4731 (defun gnus-group-quit ()
4732 "Quit reading news without updating .newsrc.eld or .newsrc.
4733 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4735 (if (or noninteractive ;For gnus-batch-kill
4736 (zerop (buffer-size))
4737 (not (gnus-server-opened gnus-select-method))
4739 (not gnus-current-startup-file)
4741 (format "Quit reading news without saving %s? "
4742 (file-name-nondirectory gnus-current-startup-file))))
4744 (run-hooks 'gnus-exit-gnus-hook)
4745 (if gnus-use-full-window
4746 (delete-other-windows)
4747 (gnus-remove-some-windows))
4749 (gnus-close-backends)
4750 (gnus-clear-system))))
4752 (defun gnus-offer-save-summaries ()
4753 (let ((buffers (buffer-list)))
4757 ;; We look for buffers with "Summary" in the name.
4758 (string-match "Summary" (or (buffer-name (car buffers)) ""))
4760 (set-buffer (car buffers))
4761 ;; We check that this is, indeed, a summary buffer.
4762 (eq major-mode 'gnus-summary-mode))
4763 ;; We ask the user whether she wants to save the info.
4765 (format "Update summary buffer %s? " (buffer-name)))
4766 ;; We do it by simply exiting.
4767 (gnus-summary-exit))
4768 (setq buffers (cdr buffers))))))
4770 (defun gnus-group-describe-briefly ()
4771 "Give a one line description of the group mode commands."
4774 (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")))
4776 (defun gnus-group-browse-foreign-server (method)
4777 "Browse a foreign news server.
4778 If called interactively, this function will ask for a select method
4779 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4780 If not, METHOD should be a list where the first element is the method
4781 and the second element is the address."
4783 (list (let ((how (completing-read
4785 (append gnus-valid-select-methods gnus-server-alist)
4787 ;; We either got a backend name or a virtual server name.
4788 ;; If the first, we also need an address.
4789 (if (assoc how gnus-valid-select-methods)
4791 ;; Suggested by mapjph@bath.ac.uk.
4794 (mapcar (lambda (server) (list server))
4795 gnus-secondary-servers)))
4796 ;; We got a server name, so we find the method.
4797 (gnus-server-to-method how)))))
4798 (gnus-browse-foreign-server method))
4802 ;;; Browse Server Mode
4805 (defvar gnus-browse-mode-hook nil)
4806 (defvar gnus-browse-mode-map nil)
4807 (put 'gnus-browse-mode 'mode-class 'special)
4809 (if gnus-browse-mode-map
4811 (setq gnus-browse-mode-map (make-keymap))
4812 (suppress-keymap gnus-browse-mode-map)
4813 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4814 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
4815 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4816 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4817 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4818 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4819 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4820 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4821 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4822 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
4823 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4824 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4825 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4826 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4827 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4828 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4829 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4830 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4833 (defvar gnus-browse-current-method nil)
4834 (defvar gnus-browse-return-buffer nil)
4836 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4838 (defun gnus-browse-foreign-server (method &optional return-buffer)
4839 (setq gnus-browse-current-method method)
4840 (setq gnus-browse-return-buffer return-buffer)
4841 (let ((gnus-select-method method)
4843 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4844 (or (gnus-server-opened method)
4845 (gnus-open-server method)
4846 (error "Unable to contact server: %s" (gnus-status-message method)))
4847 (or (gnus-request-list method)
4848 (error "Couldn't request list: %s" (gnus-status-message method)))
4849 (get-buffer-create gnus-browse-buffer)
4850 (gnus-add-current-to-buffer-list)
4851 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4852 (gnus-configure-windows 'browse)
4853 (buffer-disable-undo (current-buffer))
4854 (let ((buffer-read-only nil))
4857 (setq mode-line-buffer-identification
4859 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4861 (set-buffer nntp-server-buffer)
4862 (let ((cur (current-buffer)))
4863 (goto-char (point-min))
4864 (or (string= gnus-ignored-newsgroups "")
4865 (delete-matching-lines gnus-ignored-newsgroups))
4866 (while (re-search-forward
4867 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4868 (goto-char (match-end 1))
4869 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4871 (max 0 (- (1+ (read cur)) (read cur))))
4873 (setq groups (sort groups
4875 (string< (car l1) (car l2)))))
4876 (let ((buffer-read-only nil))
4878 (setq group (car groups))
4880 (format "K%7d: %s\n" (cdr group) (car group)))
4881 (setq groups (cdr groups))))
4882 (switch-to-buffer (current-buffer))
4883 (goto-char (point-min))
4884 (gnus-group-position-cursor)))
4886 (defun gnus-browse-mode ()
4887 "Major mode for browsing a foreign server.
4889 All normal editing commands are switched off.
4891 \\<gnus-browse-mode-map>
4892 The only things you can do in this buffer is
4894 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
4895 The group will be inserted into the group buffer upon exit from this
4898 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
4900 3) `\\[gnus-browse-exit]' to return to the group buffer."
4902 (kill-all-local-variables)
4903 (if gnus-visual (gnus-browse-make-menu-bar))
4904 (setq mode-line-modified "-- ")
4905 (make-local-variable 'mode-line-format)
4906 (setq mode-line-format (copy-sequence mode-line-format))
4907 (and (equal (nth 3 mode-line-format) " ")
4908 (setcar (nthcdr 3 mode-line-format) ""))
4909 (setq major-mode 'gnus-browse-mode)
4910 (setq mode-name "Browse Server")
4911 (setq mode-line-process nil)
4912 (use-local-map gnus-browse-mode-map)
4913 (buffer-disable-undo (current-buffer))
4914 (setq truncate-lines t)
4915 (setq buffer-read-only t)
4916 (run-hooks 'gnus-browse-mode-hook))
4918 (defun gnus-browse-read-group (&optional no-article)
4919 "Enter the group at the current line."
4921 (let ((group (gnus-browse-group-name)))
4922 (or (gnus-group-read-ephemeral-group
4923 group gnus-browse-current-method nil
4924 (cons (current-buffer) 'browse))
4925 (error "Couldn't enter %s" group))))
4927 (defun gnus-browse-select-group ()
4928 "Select the current group."
4930 (gnus-browse-read-group 'no))
4932 (defun gnus-browse-next-group (n)
4933 "Go to the next group."
4937 (gnus-group-position-cursor)))
4939 (defun gnus-browse-prev-group (n)
4940 "Go to the next group."
4942 (gnus-browse-next-group (- n)))
4944 (defun gnus-browse-unsubscribe-current-group (arg)
4945 "(Un)subscribe to the next ARG groups."
4948 (error "No group at current line."))
4949 (let ((ward (if (< arg 0) -1 1))
4951 (while (and (> arg 0)
4953 (gnus-browse-unsubscribe-group)
4954 (zerop (gnus-browse-next-group ward)))
4955 (setq arg (1- arg)))
4956 (gnus-group-position-cursor)
4957 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
4960 (defun gnus-browse-group-name ()
4963 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
4965 (gnus-group-prefixed-name
4966 (buffer-substring (match-beginning 1) (match-end 1))
4967 gnus-browse-current-method))))
4969 (defun gnus-browse-unsubscribe-group ()
4971 (buffer-read-only nil)
4975 (if (= (following-char) ?K) (setq sub t))
4976 (setq group (gnus-browse-group-name))
4981 (gnus-group-change-level
4982 (list t group gnus-level-default-subscribed
4983 nil nil gnus-browse-current-method)
4984 gnus-level-default-subscribed gnus-level-killed
4985 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
4988 (gnus-group-change-level
4989 group gnus-level-killed gnus-level-default-subscribed)
4993 (defun gnus-browse-exit ()
4994 "Quit browsing and return to the group buffer."
4996 (if (eq major-mode 'gnus-browse-mode)
4997 (kill-buffer (current-buffer)))
4998 (if gnus-browse-return-buffer
4999 (gnus-configure-windows 'server)
5000 (gnus-configure-windows 'group)))
5002 (defun gnus-browse-describe-briefly ()
5003 "Give a one line description of the group mode commands."
5006 (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")))
5010 ;;; Gnus summary mode
5013 (defvar gnus-summary-mode-map nil)
5014 (defvar gnus-summary-mark-map nil)
5015 (defvar gnus-summary-mscore-map nil)
5016 (defvar gnus-summary-article-map nil)
5017 (defvar gnus-summary-thread-map nil)
5018 (defvar gnus-summary-goto-map nil)
5019 (defvar gnus-summary-exit-map nil)
5020 (defvar gnus-summary-various-map nil)
5021 (defvar gnus-summary-interest-map nil)
5022 (defvar gnus-summary-sort-map nil)
5023 (defvar gnus-summary-backend-map nil)
5024 (defvar gnus-summary-save-map nil)
5025 (defvar gnus-summary-wash-map nil)
5026 (defvar gnus-summary-help-map nil)
5028 (put 'gnus-summary-mode 'mode-class 'special)
5030 (if gnus-summary-mode-map
5032 (setq gnus-summary-mode-map (make-keymap))
5033 (suppress-keymap gnus-summary-mode-map)
5035 ;; Non-orthogonal keys
5037 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5038 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5039 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5040 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5041 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5042 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5043 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5044 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5045 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5046 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5047 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5048 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5049 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5050 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5051 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5052 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5053 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5054 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5055 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5056 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5057 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5058 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5059 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5060 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5061 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5062 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5063 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5064 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5065 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5066 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5067 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5068 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5069 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5070 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5071 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5072 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5073 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5074 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5075 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5076 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5077 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5078 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5079 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5080 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5081 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5082 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5083 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5084 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5085 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5086 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5087 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5088 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5089 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5090 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5091 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5092 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5093 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5094 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5095 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5096 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5097 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5098 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5099 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5100 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5101 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5102 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5103 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5104 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5105 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5106 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5107 (define-key gnus-summary-mode-map "V" 'gnus-version)
5108 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5109 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5110 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5111 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5112 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5113 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5114 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5115 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5116 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5117 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5118 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5119 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5120 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5121 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5122 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5123 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5124 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5125 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5128 ;; Sort of orthogonal keymap
5129 (define-prefix-command 'gnus-summary-mark-map)
5130 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5131 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5132 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5133 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5134 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5135 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5136 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5137 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5138 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5139 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5140 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5141 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5142 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5143 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5144 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5145 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5146 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5147 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5148 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5149 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5150 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5151 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5152 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5153 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5155 (define-prefix-command 'gnus-summary-mscore-map)
5156 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
5157 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5158 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5159 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5160 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5162 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
5164 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5166 (define-prefix-command 'gnus-summary-goto-map)
5167 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5168 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5169 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5170 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5171 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5172 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5173 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5174 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5175 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5176 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5177 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5178 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5179 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5180 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5183 (define-prefix-command 'gnus-summary-thread-map)
5184 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5185 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5186 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5187 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5188 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5189 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5190 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5191 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5192 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5193 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5194 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5195 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5196 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5197 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5200 (define-prefix-command 'gnus-summary-exit-map)
5201 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5202 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5203 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5204 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5205 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5206 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5207 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5208 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5209 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5210 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5211 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5214 (define-prefix-command 'gnus-summary-article-map)
5215 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5216 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5217 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5218 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5219 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5220 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5221 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5222 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5223 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5224 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5225 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5226 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5227 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
5228 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
5229 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5230 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
5231 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
5232 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5235 (define-prefix-command 'gnus-summary-wash-map)
5236 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5237 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
5238 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
5239 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
5240 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5241 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5242 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
5243 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5244 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5245 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
5246 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
5247 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
5249 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
5250 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
5251 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
5252 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
5253 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
5254 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5257 (define-prefix-command 'gnus-summary-help-map)
5258 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5259 (define-key gnus-summary-help-map "v" 'gnus-version)
5260 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5261 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5262 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5263 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5266 (define-prefix-command 'gnus-summary-backend-map)
5267 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5268 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5269 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5270 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5271 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5272 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5273 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5274 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5275 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5278 (define-prefix-command 'gnus-summary-save-map)
5279 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5280 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5281 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5282 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5283 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5284 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5285 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5286 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5287 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5289 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5291 (define-prefix-command 'gnus-summary-various-map)
5292 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
5293 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
5294 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5295 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5296 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5297 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5298 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5299 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5300 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
5301 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5302 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5304 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
5306 (define-prefix-command 'gnus-summary-sort-map)
5307 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5308 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5309 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5310 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5311 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5312 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5314 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5315 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5321 (defun gnus-summary-mode (&optional group)
5322 "Major mode for reading articles.
5324 All normal editing commands are switched off.
5325 \\<gnus-summary-mode-map>
5326 Each line in this buffer represents one article. To read an
5327 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5328 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5331 You can also post articles and send mail from this buffer. To
5332 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5333 of an article, type `\\[gnus-summary-reply]'.
5335 There are approx. one gazillion commands you can execute in this
5336 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5338 The following commands are available:
5340 \\{gnus-summary-mode-map}"
5342 (if gnus-visual (gnus-summary-make-menu-bar))
5343 (kill-all-local-variables)
5344 (let ((locals gnus-summary-local-variables))
5346 (if (consp (car locals))
5348 (make-local-variable (car (car locals)))
5349 (set (car (car locals)) (eval (cdr (car locals)))))
5350 (make-local-variable (car locals))
5351 (set (car locals) nil))
5352 (setq locals (cdr locals))))
5353 (gnus-make-thread-indent-array)
5354 (gnus-update-format-specifications)
5355 (setq mode-line-modified "-- ")
5356 (make-local-variable 'mode-line-format)
5357 (setq mode-line-format (copy-sequence mode-line-format))
5358 (and (equal (nth 3 mode-line-format) " ")
5359 (setcar (nthcdr 3 mode-line-format) ""))
5360 (setq major-mode 'gnus-summary-mode)
5361 (setq mode-name "Summary")
5362 (make-local-variable 'minor-mode-alist)
5363 (use-local-map gnus-summary-mode-map)
5364 (buffer-disable-undo (current-buffer))
5365 (setq buffer-read-only t) ;Disable modification
5366 (setq truncate-lines t)
5367 (setq selective-display t)
5368 (setq selective-display-ellipses t) ;Display `...'
5369 (setq buffer-display-table gnus-summary-display-table)
5370 (setq gnus-newsgroup-name group)
5371 (run-hooks 'gnus-summary-mode-hook))
5373 (defun gnus-summary-make-display-table ()
5374 ;; Change the display table. Odd characters have a tendency to mess
5375 ;; up nicely formatted displays - we make all possible glyphs
5376 ;; display only a single character.
5378 ;; We start from the standard display table, if any.
5379 (setq gnus-summary-display-table
5380 (or (copy-sequence standard-display-table)
5381 (make-display-table)))
5382 ;; Nix out all the control chars...
5384 (while (>= (setq i (1- i)) 0)
5385 (aset gnus-summary-display-table i [??])))
5386 ;; ... but not newline and cr, of course. (cr is necessary for the
5387 ;; selective display).
5388 (aset gnus-summary-display-table ?\n nil)
5389 (aset gnus-summary-display-table ?\r nil)
5390 ;; We nix out any glyphs over 126 that are not set already.
5392 (while (>= (setq i (1- i)) 127)
5393 ;; Only modify if the entry is nil.
5394 (or (aref gnus-summary-display-table i)
5395 (aset gnus-summary-display-table i [??])))))
5397 (defun gnus-summary-clear-local-variables ()
5398 (let ((locals gnus-summary-local-variables))
5400 (if (consp (car locals))
5401 (and (vectorp (car (car locals)))
5402 (set (car (car locals)) nil))
5403 (and (vectorp (car locals))
5404 (set (car locals) nil)))
5405 (setq locals (cdr locals)))))
5407 (defun gnus-mouse-pick-article (e)
5410 (gnus-summary-next-page nil t))
5412 (defun gnus-summary-setup-buffer (group)
5413 "Initialize summary buffer."
5414 (let ((buffer (concat "*Summary " group "*")))
5415 (if (get-buffer buffer)
5418 (not gnus-newsgroup-begin))
5419 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5420 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5421 (gnus-add-current-to-buffer-list)
5422 (gnus-summary-mode group)
5423 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5424 (setq gnus-newsgroup-name group)
5427 (defun gnus-set-global-variables ()
5428 ;; Set the global equivalents of the summary buffer-local variables
5429 ;; to the latest values they had. These reflect the summary buffer
5430 ;; that was in action when the last article was fetched.
5431 (if (eq major-mode 'gnus-summary-mode)
5433 (setq gnus-summary-buffer (current-buffer))
5434 (let ((name gnus-newsgroup-name)
5435 (marked gnus-newsgroup-marked)
5436 (unread gnus-newsgroup-unreads)
5437 (headers gnus-current-headers)
5438 (score-file gnus-current-score-file))
5440 (set-buffer gnus-group-buffer)
5441 (setq gnus-newsgroup-name name)
5442 (setq gnus-newsgroup-marked marked)
5443 (setq gnus-newsgroup-unreads unread)
5444 (setq gnus-current-headers headers)
5445 (setq gnus-current-score-file score-file))))))
5447 (defun gnus-summary-insert-dummy-line (sformat subject number)
5449 (setq sformat gnus-summary-dummy-line-format-spec))
5453 (insert (eval sformat))
5454 (add-text-properties
5456 (list 'gnus-number number
5457 'gnus-mark gnus-dummy-mark
5460 (defvar gnus-thread-indent-array nil)
5461 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5462 (defun gnus-make-thread-indent-array ()
5464 (if (and gnus-thread-indent-array
5465 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5467 (setq gnus-thread-indent-array (make-vector 201 "")
5468 gnus-thread-indent-array-level gnus-thread-indent-level)
5470 (aset gnus-thread-indent-array n
5471 (make-string (* n gnus-thread-indent-level) ? ))
5474 (defun gnus-summary-insert-line
5475 (sformat header level current unread replied expirable subject-or-nil
5476 &optional dummy score)
5477 (or sformat (setq sformat gnus-summary-line-format-spec))
5478 (let* ((indentation (aref gnus-thread-indent-array level))
5479 (lines (header-lines header))
5480 (score (or score gnus-summary-default-score 0))
5482 (if (or (null gnus-summary-default-score)
5483 (<= (abs (- score gnus-summary-default-score))
5484 gnus-summary-zcore-fuzz)) ?
5485 (if (< score gnus-summary-default-score)
5486 gnus-score-below-mark gnus-score-over-mark)))
5487 (replied (if replied gnus-replied-mark ? ))
5488 (from (header-from header))
5489 (name-address (funcall gnus-extract-address-components from))
5490 (address (car (cdr name-address)))
5491 (name (or (car name-address) (car (cdr name-address))))
5492 (subject (header-subject header))
5493 (number (header-number header))
5494 (opening-bracket (if dummy ?\< ?\[))
5495 (closing-bracket (if dummy ?\> ?\]))
5496 (buffer-read-only nil)
5497 (b (progn (beginning-of-line) (point))))
5498 (or (numberp lines) (setq lines 0))
5499 (insert (eval sformat))
5500 (add-text-properties
5501 b (1+ b) (list 'gnus-number number
5502 'gnus-mark (or unread gnus-unread-mark)
5503 'gnus-level level))))
5505 (defun gnus-summary-update-line (&optional dont-update)
5506 ;; Update summary line after change.
5507 (or (not gnus-summary-default-score)
5508 gnus-summary-inhibit-highlight
5509 (let ((gnus-summary-inhibit-highlight t)
5510 (article (gnus-summary-article-number)))
5513 (if (and gnus-summary-mark-below
5514 (< (gnus-summary-article-score)
5515 gnus-summary-mark-below))
5516 (and (not (memq article gnus-newsgroup-marked))
5517 (not (memq article gnus-newsgroup-dormant))
5518 (memq article gnus-newsgroup-unreads)
5519 (gnus-summary-mark-article nil gnus-low-score-mark))
5520 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5521 (gnus-summary-mark-article nil gnus-unread-mark))))
5523 (run-hooks 'gnus-summary-update-hook))))))
5525 (defun gnus-summary-update-lines (&optional beg end)
5526 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5527 (let ((beg (or beg (point-min)))
5528 (end (or end (point-max))))
5530 (set-buffer gnus-summary-buffer)
5532 (while (and (not (eobp)) (< (point) end))
5533 (gnus-summary-update-line)
5534 (forward-line 1)))))
5536 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5537 ;; Sum up all elements (and sub-elements) in a list.
5541 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5544 (if (> number 1) gnus-not-empty-thread-mark
5545 gnus-empty-thread-mark)
5548 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5549 "Start reading news in newsgroup GROUP.
5550 If SHOW-ALL is non-nil, already read articles are also listed.
5551 If NO-ARTICLE is non-nil, no article is selected initially."
5552 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5553 (let* ((new-group (gnus-summary-setup-buffer group))
5554 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5556 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5559 (gnus-set-global-variables)
5560 (gnus-kill-buffer kill-buffer)
5561 (gnus-configure-windows 'summary)
5562 (gnus-set-mode-line 'summary)
5563 (gnus-summary-position-cursor)
5567 (and (eq major-mode 'gnus-summary-mode)
5568 (not (equal (current-buffer) kill-buffer))
5570 (kill-buffer (current-buffer))
5571 (if (not quit-config)
5573 (set-buffer gnus-group-buffer)
5574 (gnus-group-jump-to-group group)
5575 (gnus-group-next-unread-group 1))
5576 (if (not (buffer-name (car quit-config)))
5577 (gnus-configure-windows 'group)
5578 (set-buffer (car quit-config))
5579 (and (eq major-mode 'gnus-summary-mode)
5580 (gnus-set-global-variables))
5581 (gnus-configure-windows (cdr quit-config))))))
5582 (message "Can't select group")
5584 ((eq did-select 'quit)
5585 (and (eq major-mode 'gnus-summary-mode)
5586 (not (equal (current-buffer) kill-buffer))
5587 (kill-buffer (current-buffer)))
5588 (gnus-kill-buffer kill-buffer)
5589 (if (not quit-config)
5591 (set-buffer gnus-group-buffer)
5592 (gnus-group-jump-to-group group)
5593 (gnus-group-next-unread-group 1))
5594 (if (not (buffer-name (car quit-config)))
5595 (gnus-configure-windows 'group)
5596 (set-buffer (car quit-config))
5597 (and (eq major-mode 'gnus-summary-mode)
5598 (gnus-set-global-variables))
5599 (gnus-configure-windows (cdr quit-config))))
5602 (gnus-set-global-variables)
5603 ;; Save the active value in effect when the group was entered.
5604 (setq gnus-newsgroup-active
5606 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5607 ;; You can change the subjects in this hook.
5608 (run-hooks 'gnus-select-group-hook)
5609 ;; Do score processing.
5610 (and gnus-use-scoring (gnus-possibly-score-headers))
5611 ;; Update the format specifiers.
5612 (gnus-update-format-specifications)
5613 ;; Generate the summary buffer.
5614 (gnus-summary-prepare)
5615 (if (zerop (buffer-size))
5616 (cond (gnus-newsgroup-dormant
5617 (gnus-summary-show-all-dormant))
5618 ((and gnus-newsgroup-scored show-all)
5619 (gnus-summary-show-all-expunged))))
5620 ;; Function `gnus-apply-kill-file' must be called in this hook.
5621 (run-hooks 'gnus-apply-kill-hook)
5622 (if (zerop (buffer-size))
5624 ;; This newsgroup is empty.
5625 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5626 (gnus-message 6 "No unread news")
5627 (gnus-kill-buffer kill-buffer)
5631 ;; (let ((gnus-summary-buffer kill-buffer))
5632 ;; (gnus-configure-windows 'group))))
5633 ;; Hide conversation thread subtrees. We cannot do this in
5634 ;; gnus-summary-prepare-hook since kill processing may not
5635 ;; work with hidden articles.
5636 (and gnus-show-threads
5637 gnus-thread-hide-subtree
5638 (gnus-summary-hide-all-threads))
5639 ;; Show first unread article if requested.
5640 (goto-char (point-min))
5641 (if (and (not no-article)
5642 gnus-auto-select-first
5643 (gnus-summary-first-unread-article))
5645 (gnus-configure-windows 'summary))
5646 (gnus-set-mode-line 'summary)
5647 (gnus-summary-position-cursor)
5648 ;; If in async mode, we send some info to the backend.
5649 (and gnus-newsgroup-async
5650 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5651 (gnus-request-asynchronous
5653 (if (and gnus-asynchronous-article-function
5654 (fboundp gnus-asynchronous-article-function))
5655 (funcall gnus-asynchronous-article-function
5656 gnus-newsgroup-threads)
5657 gnus-newsgroup-threads)))
5658 (gnus-kill-buffer kill-buffer)
5659 (if (not (get-buffer-window gnus-group-buffer))
5661 ;; gotta use windows, because recenter does wierd stuff if
5662 ;; the current buffer ain't the displayed window.
5663 (let ((owin (selected-window)))
5664 (select-window (get-buffer-window gnus-group-buffer))
5665 (and (gnus-group-goto-group group)
5667 (select-window owin))))
5670 (defun gnus-summary-prepare ()
5671 ;; Generate the summary buffer.
5672 (let ((buffer-read-only nil))
5674 (gnus-summary-prepare-threads
5675 (if gnus-show-threads
5676 (gnus-gather-threads
5678 (if (and gnus-summary-expunge-below
5679 (not gnus-fetch-old-headers))
5680 (gnus-make-threads-and-expunge)
5681 (gnus-make-threads))))
5682 gnus-newsgroup-headers)
5684 ;; Erase header retrieval message.
5685 (gnus-summary-update-lines)
5687 ;; Remove the final newline.
5688 ;;(goto-char (point-max))
5690 ;; Call hooks for modifying summary buffer.
5691 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5692 (goto-char (point-min))
5693 (run-hooks 'gnus-summary-prepare-hook)))
5695 (defun gnus-subject-equal (s1 s2)
5697 ((numberp gnus-summary-gather-subject-limit)
5698 (string= (if (> (length s1) gnus-summary-gather-subject-limit)
5699 (substring s1 0 gnus-summary-gather-subject-limit)
5701 (if (> (length s2) gnus-summary-gather-subject-limit)
5702 (substring s2 0 gnus-summary-gather-subject-limit)
5704 ((eq 'fuzzy gnus-summary-gather-subject-limit)
5705 (string= (gnus-simplify-subject-fuzzy s1)
5706 (gnus-simplify-subject-fuzzy s2)))
5710 (defun gnus-gather-threads (threads)
5711 "Gather threads that have lost their roots."
5712 (if (not gnus-summary-make-false-root)
5714 (let ((hashtb (gnus-make-hashtable 1023))
5717 subject hthread whole-subject)
5720 (setq subject (header-subject (car (car threads)))))
5721 (if gnus-summary-gather-subject-limit
5722 (or (and (numberp gnus-summary-gather-subject-limit)
5723 (> (length subject) gnus-summary-gather-subject-limit)
5725 (substring subject 0
5726 gnus-summary-gather-subject-limit)))
5727 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5728 (setq subject (gnus-simplify-subject-fuzzy subject))))
5729 (setq subject (gnus-simplify-subject-re subject)))
5731 (gnus-gethash subject hashtb))
5733 (or (stringp (car (car hthread)))
5734 (setcar hthread (list whole-subject (car hthread))))
5735 (setcdr (car hthread) (nconc (cdr (car hthread))
5736 (list (car threads))))
5737 (setcdr prev (cdr threads))
5738 (setq threads prev))
5739 (gnus-sethash subject threads hashtb))
5741 (setq threads (cdr threads)))
5744 (defun gnus-make-threads ()
5745 ;; This function takes the dependencies already made by
5746 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5747 ;; through the dependecies in the hash table and finds all the
5748 ;; roots. Roots do not refer back to any valid articles.
5750 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5751 (gnus-build-old-threads))
5754 (if (not (car (symbol-value refs)))
5755 (setq roots (append (cdr (symbol-value refs)) roots))
5756 ;; Ok, these refer back to valid articles, but if
5757 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5758 ;; the root has the same subject as its children. The children
5759 ;; that do not are made into roots and removed from the list
5761 (or gnus-thread-ignore-subject
5762 (let* ((prev (symbol-value refs))
5763 (subject (gnus-simplify-subject-re
5764 (header-subject (car prev))))
5765 (headers (cdr prev)))
5767 (if (not (string= subject
5768 (gnus-simplify-subject-re
5769 (header-subject (car headers)))))
5771 (setq roots (cons (car headers) roots))
5772 (setcdr prev (cdr headers)))
5773 (setq prev headers))
5774 (setq headers (cdr headers)))))))
5775 gnus-newsgroup-dependencies)
5777 (mapcar 'gnus-trim-thread
5779 (mapcar 'gnus-cut-thread
5780 (mapcar 'gnus-make-sub-thread roots))))))
5782 (defun gnus-make-threads-and-expunge ()
5783 ;; This function takes the dependencies already made by
5784 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5785 ;; through the dependecies in the hash table and finds all the
5786 ;; roots. Roots do not refer back to any valid articles.
5787 (let ((default (or gnus-summary-default-score 0))
5788 (below gnus-summary-expunge-below)
5790 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5791 (gnus-build-old-threads))
5794 (if (not (car (symbol-value refs)))
5795 ;; These articles do not refer back to any other articles -
5797 (let ((headers (cdr (symbol-value refs))))
5798 ;; We weed out the low-scored articles.
5800 (if (not (< (or (cdr (assq (header-number (car headers))
5801 gnus-newsgroup-scored)) default)
5804 (setq roots (cons (car headers) roots))
5805 ;; It is below, so we mark it as read.
5806 (setq gnus-newsgroup-unreads
5807 (delq (header-number (car headers))
5808 gnus-newsgroup-unreads)))
5809 (setq headers (cdr headers))))
5810 ;; Ok, these refer back to valid articles, but if
5811 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5812 ;; the root has the same subject as its children. The children
5813 ;; that do not are made into roots and removed from the list
5815 (or gnus-thread-ignore-subject
5816 (let* ((prev (symbol-value refs))
5817 (subject (gnus-simplify-subject-re
5818 (header-subject (car prev))))
5819 (headers (cdr prev)))
5821 (if (not (string= subject
5822 (gnus-simplify-subject-re
5823 (header-subject (car headers)))))
5825 (if (not (< (or (cdr (assq (header-number (car headers))
5826 gnus-newsgroup-scored))
5828 (setq roots (cons (car headers) roots))
5829 (setq gnus-newsgroup-unreads
5830 (delq (header-number (car headers))
5831 gnus-newsgroup-unreads)))
5832 (setcdr prev (cdr headers)))
5833 (setq prev headers))
5834 (setq headers (cdr headers)))))
5835 ;; If this article is expunged, some of the children might be
5837 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
5838 gnus-newsgroup-scored)) default)
5840 (let* ((prev (symbol-value refs))
5841 (headers (cdr prev)))
5843 (setq article (header-number (car headers)))
5844 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5846 (progn (setq roots (cons (car headers) roots))
5847 (setq prev headers))
5848 (setq gnus-newsgroup-unreads
5849 (delq article gnus-newsgroup-unreads))
5850 (setcdr prev (cdr headers)))
5851 (setq headers (cdr headers))))
5852 ;; It was not expunged, but we look at expunged children.
5853 (let* ((prev (symbol-value refs))
5854 (headers (cdr prev))
5857 (setq article (header-number (car headers)))
5858 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5861 (setq gnus-newsgroup-unreads
5862 (delq article gnus-newsgroup-unreads))
5863 (setcdr prev (cdr headers)))
5864 (setq headers (cdr headers)))))))
5865 gnus-newsgroup-dependencies)
5867 (mapcar 'gnus-trim-thread
5869 (mapcar 'gnus-cut-thread
5870 (mapcar 'gnus-make-sub-thread roots))))))
5872 (defun gnus-cut-thread (thread)
5873 ;; Remove leaf dormant or ancient articles from THREAD.
5874 (let ((head (car thread))
5875 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5876 (if (and (null tail)
5877 (let ((number (header-number head)))
5878 (or (memq number gnus-newsgroup-ancient)
5879 (memq number gnus-newsgroup-dormant)
5880 (and gnus-summary-expunge-below
5881 (eq gnus-fetch-old-headers 'some)
5882 (< (or (cdr (assq number gnus-newsgroup-scored))
5883 gnus-summary-default-score 0)
5884 gnus-summary-expunge-below)
5886 (setq gnus-newsgroup-unreads
5887 (delq number gnus-newsgroup-unreads))
5890 (list (cons head tail)))))
5892 (defun gnus-trim-thread (thread)
5893 ;; Remove root ancient articles with only one child from THREAD.
5894 (if (and (eq gnus-fetch-old-headers 'some)
5895 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5896 (= (length thread) 2))
5897 (gnus-trim-thread (nth 1 thread))
5900 (defun gnus-make-sub-thread (root)
5901 ;; This function makes a sub-tree for a node in the tree.
5902 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5903 gnus-newsgroup-dependencies)))))
5904 (cons root (mapcar 'gnus-make-sub-thread children))))
5906 (defun gnus-build-old-threads ()
5907 ;; Look at all the articles that refer back to old articles, and
5908 ;; fetch the headers for the articles that aren't there. This will
5909 ;; build complete threads - if the roots haven't been expired by the
5914 (if (not (car (symbol-value refs)))
5916 (setq heads (cdr (symbol-value refs)))
5918 (if (not (memq (header-number (car heads))
5919 gnus-newsgroup-dormant))
5921 (setq id (symbol-name refs))
5922 (while (and (setq id (gnus-build-get-header id))
5923 (not (car (gnus-gethash
5924 id gnus-newsgroup-dependencies)))))
5926 (setq heads (cdr heads)))))))
5927 gnus-newsgroup-dependencies)))
5929 (defun gnus-build-get-header (id)
5930 ;; Look through the buffer of NOV lines and find the header to
5931 ;; ID. Enter this line into the dependencies hash table, and return
5932 ;; the id of the parent article (if any).
5933 (let ((deps gnus-newsgroup-dependencies)
5937 (set-buffer nntp-server-buffer)
5938 (goto-char (point-min))
5939 (while (and (not found) (search-forward id nil t))
5941 (setq found (looking-at
5942 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5943 (regexp-quote id))))
5944 (or found (beginning-of-line 2)))
5949 (setq header (gnus-nov-parse-line
5950 (read (current-buffer)) deps))
5951 (setq ref (header-references header))
5952 (string-match "\\(<[^>]+>\\) *$" ref)
5953 (substring ref (match-beginning 1) (match-end 1))))))
5955 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5956 gnus-newsgroup-ancient (cons (header-number header)
5957 gnus-newsgroup-ancient))))))
5959 ;; Re-build the thread containing ID.
5960 (defun gnus-rebuild-thread (id)
5961 (let ((dep gnus-newsgroup-dependencies)
5962 (buffer-read-only nil)
5963 parent headers refs thread art)
5964 (while (and id (setq headers
5965 (car (setq art (gnus-gethash (downcase id) dep)))))
5967 (setq id (and (setq refs (header-references headers))
5968 (string-match "\\(<[^>]+>\\) *$" refs)
5969 (substring refs (match-beginning 1) (match-end 1)))))
5970 (setq thread (gnus-make-sub-thread (car parent)))
5971 (gnus-rebuild-remove-articles thread)
5972 (let ((beg (point)))
5973 (gnus-summary-prepare-threads (list thread) 0)
5974 (gnus-summary-update-lines beg (point)))))
5976 ;; Delete all lines in the summary buffer that correspond to articles
5978 (defun gnus-rebuild-remove-articles (thread)
5979 (and (gnus-summary-goto-subject (header-number (car thread)))
5981 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
5983 (defun gnus-sort-threads (threads)
5984 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5985 (let ((fun gnus-thread-sort-functions))
5987 (setq threads (sort threads (car fun))
5991 (defun gnus-thread-header (thread)
5992 ;; Return header of first article in THREAD.
5994 (if (stringp (car thread))
5995 (car (car (cdr thread)))
5999 (defun gnus-thread-sort-by-number (h1 h2)
6000 "Sort threads by root article number."
6001 (let ((h1 (gnus-thread-header h1))
6002 (h2 (gnus-thread-header h2)))
6003 (< (header-number h1) (header-number h2))))
6005 (defun gnus-thread-sort-by-author (h1 h2)
6006 "Sort threads by root author."
6007 (let ((h1 (gnus-thread-header h1))
6008 (h2 (gnus-thread-header h2)))
6010 (let ((extract (funcall
6011 gnus-extract-address-components (header-from h1))))
6012 (or (car extract) (cdr extract)))
6013 (let ((extract (funcall
6014 gnus-extract-address-components (header-from h2))))
6015 (or (car extract) (cdr extract))))))
6017 (defun gnus-thread-sort-by-subject (h1 h2)
6018 "Sort threads by root subject."
6019 (let ((h1 (gnus-thread-header h1))
6020 (h2 (gnus-thread-header h2)))
6022 (downcase (gnus-simplify-subject (header-subject h1)))
6023 (downcase (gnus-simplify-subject (header-subject h2))))))
6025 (defun gnus-thread-sort-by-date (h1 h2)
6026 "Sort threads by root article date."
6027 (let ((h1 (gnus-thread-header h1))
6028 (h2 (gnus-thread-header h2)))
6030 (gnus-sortable-date (header-date h1))
6031 (gnus-sortable-date (header-date h2)))))
6033 (defun gnus-thread-sort-by-score (h1 h2)
6034 "Sort threads by root article score.
6035 Unscored articles will be counted as having a score of zero."
6036 (let ((h1 (gnus-thread-header h1))
6037 (h2 (gnus-thread-header h2)))
6038 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
6039 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
6040 (> (or (cdr s1) gnus-summary-default-score 0)
6041 (or (cdr s2) gnus-summary-default-score 0)))))
6043 (defun gnus-thread-sort-by-total-score (h1 h2)
6044 "Sort threads by the sum of all scores in the thread.
6045 Unscored articles will be counted as having a score of zero."
6046 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6048 (defun gnus-thread-total-score (thread)
6049 ;; This function find the total score of THREAD.
6051 (if (stringp (car thread))
6052 (apply gnus-thread-score-function 0
6053 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6054 (gnus-thread-total-score-1 thread))
6055 (gnus-thread-total-score-1 (list thread))))
6057 (defun gnus-thread-total-score-1 (root)
6058 ;; This function find the total score of the thread below ROOT.
6059 (setq root (car root))
6060 (apply gnus-thread-score-function
6061 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
6062 gnus-summary-default-score 0)
6063 (mapcar 'gnus-thread-total-score
6064 (cdr (gnus-gethash (downcase (header-id root))
6065 gnus-newsgroup-dependencies)))))
6067 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6068 (defvar gnus-tmp-prev-subject "")
6069 (defvar gnus-tmp-adopt-thread nil)
6071 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
6072 (defun gnus-summary-prepare-threads
6073 (threads level &optional not-child no-subject cull)
6074 "Prepare summary buffer from THREADS and indentation LEVEL.
6075 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6076 or a straight list of headers."
6077 (let (thread header number subject clevel)
6079 (setq thread (car threads)
6080 threads (cdr threads))
6081 ;; If `thread' is a cons, hierarchical threads are used. If not,
6082 ;; `thread' is the header.
6084 (setq header (car thread))
6085 (setq header thread)
6087 (or (memq (setq number (header-number header))
6088 gnus-newsgroup-dormant)
6089 (and gnus-summary-expunge-below
6090 (< (or (cdr (assq number gnus-newsgroup-scored))
6091 gnus-summary-default-score 0)
6092 gnus-summary-expunge-below)))
6095 (setq gnus-newsgroup-unreads
6096 (delq number gnus-newsgroup-unreads)))))
6099 ;; The header is a dummy root.
6100 (cond ((eq gnus-summary-make-false-root 'adopt)
6101 ;; We let the first article adopt the rest.
6102 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
6103 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
6104 (setq thread (cdr (cdr thread)))
6106 (gnus-summary-prepare-threads (list (car thread)) 1 t)
6107 (setq thread (cdr thread))))
6108 ((eq gnus-summary-make-false-root 'dummy)
6109 ;; We output a dummy root.
6110 (gnus-summary-insert-dummy-line
6111 nil header (header-number (car (car (cdr thread)))))
6113 ((eq gnus-summary-make-false-root 'empty)
6114 ;; We print the articles with empty subject fields.
6115 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
6116 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
6117 (setq thread (cdr (cdr thread)))
6119 (gnus-summary-prepare-threads
6120 (list (car thread)) 0 nil
6121 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
6123 (gnus-simplify-subject-re
6124 (header-subject (car (car thread))))
6125 (gnus-simplify-subject-re header))))))
6126 (setq thread (cdr thread))))
6128 ;; We do not make a root for the gathered
6129 ;; sub-threads at all.
6131 ;; Print the sub-threads.
6132 (and (consp thread) (cdr thread)
6133 (gnus-summary-prepare-threads (cdr thread) clevel)))
6134 ;; The header is a real article.
6136 (setq number (header-number header)
6137 subject (header-subject header))
6138 (and gnus-newsgroup-async
6139 (setq gnus-newsgroup-threads
6140 (cons (cons (header-number header)
6141 (header-lines header)) gnus-newsgroup-threads)))
6142 (gnus-summary-insert-line
6143 nil header level nil
6144 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6145 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6146 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6147 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6148 (t gnus-ancient-mark))
6149 (memq number gnus-newsgroup-replied)
6150 (memq number gnus-newsgroup-expirable)
6152 gnus-summary-same-subject
6153 (if (or (zerop level)
6154 (and gnus-thread-ignore-subject
6156 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6157 (gnus-simplify-subject-re subject)))))
6159 gnus-summary-same-subject))
6161 (cdr (assq number gnus-newsgroup-scored)))
6162 (setq gnus-tmp-prev-subject subject)
6163 ;; Recursively print subthreads.
6164 (and (consp thread) (cdr thread)
6165 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
6167 (defun gnus-select-newsgroup (group &optional read-all)
6168 "Select newsgroup GROUP.
6169 If READ-ALL is non-nil, all articles in the group are selected."
6170 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6171 (info (nth 2 entry))
6173 (gnus-check-news-server
6174 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6176 (or (gnus-server-opened gnus-current-select-method)
6177 (gnus-open-server gnus-current-select-method)
6178 (error "Couldn't open server"))
6180 (or (and (eq (car entry) t)
6181 (gnus-activate-newsgroup (car info)))
6182 (gnus-request-group group t)
6184 (kill-buffer (current-buffer))
6185 (error "Couldn't request group %s: %s"
6186 group (gnus-status-message group))))
6188 (setq gnus-newsgroup-name group)
6189 (setq gnus-newsgroup-unselected nil)
6190 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6192 (and gnus-asynchronous
6193 (gnus-check-backend-function
6194 'request-asynchronous gnus-newsgroup-name)
6195 (setq gnus-newsgroup-async
6196 (gnus-request-asynchronous gnus-newsgroup-name)))
6198 (setq articles (gnus-articles-to-read group read-all))
6202 (gnus-message 3 "Couldn't select newsgroup")
6204 ((eq articles 0) nil)
6206 ;; Init the dependencies hash table.
6207 (setq gnus-newsgroup-dependencies
6208 (gnus-make-hashtable (length articles)))
6209 ;; Retrieve the headers and read them in.
6210 (setq gnus-newsgroup-headers
6211 (if (eq 'nov (setq gnus-headers-retrieved-by
6212 (gnus-retrieve-headers
6213 (if (and gnus-fetch-old-headers
6214 (not (eq 1 (car articles))))
6217 gnus-newsgroup-name)))
6219 (gnus-get-newsgroup-headers-xover articles))
6220 ;; If we were to fetch old headers, but the backend didn't
6221 ;; support XOVER, then it is possible we fetched one article
6222 ;; that we shouldn't have. If that's the case, we pop it off the
6224 (if (not gnus-fetch-old-headers)
6227 (set-buffer nntp-server-buffer)
6228 (goto-char (point-min))
6229 (and (looking-at "[0-9]+[ \t]+1[ \t]")
6232 (search-forward "\n.\n" nil t)))))
6233 (gnus-get-newsgroup-headers)))
6234 ;; Remove canceled articles from the list of unread articles.
6235 (setq gnus-newsgroup-unreads
6236 (gnus-set-sorted-intersection
6237 gnus-newsgroup-unreads
6238 (mapcar (lambda (headers) (header-number headers))
6239 gnus-newsgroup-headers)))
6240 ;; Adjust and set lists of article marks.
6243 (gnus-adjust-marked-articles info)
6244 (setq gnus-newsgroup-marked
6245 (cdr (assq 'tick (setq marked (nth 3 info)))))
6246 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
6247 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
6248 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
6249 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
6250 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
6251 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
6252 (setq gnus-newsgroup-processable nil)))
6253 ;; Check whether auto-expire is to be done in this group.
6254 (setq gnus-newsgroup-auto-expire
6255 (or (and (stringp gnus-auto-expirable-newsgroups)
6256 (string-match gnus-auto-expirable-newsgroups group))
6257 (memq 'auto-expire (nth 5 info))))
6258 ;; First and last article in this newsgroup.
6259 (and gnus-newsgroup-headers
6260 (setq gnus-newsgroup-begin
6261 (header-number (car gnus-newsgroup-headers)))
6262 (setq gnus-newsgroup-end
6263 (header-number (gnus-last-element gnus-newsgroup-headers))))
6264 (setq gnus-reffed-article-number -1)
6265 ;; GROUP is successfully selected.
6266 (or gnus-newsgroup-headers t)))))
6268 (defun gnus-articles-to-read (group read-all)
6269 ;; Find out what articles the user wants to read.
6271 ;; Select all articles if `read-all' is non-nil, or if all the
6272 ;; unread articles are dormant articles.
6273 (if (or (and read-all (not (numberp read-all)))
6274 (= (length gnus-newsgroup-unreads)
6275 (length gnus-newsgroup-dormant)))
6276 (gnus-uncompress-range
6277 (gnus-gethash group gnus-active-hashtb))
6278 gnus-newsgroup-unreads))
6279 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6280 (scored (length scored-list))
6281 (number (length articles))
6282 (marked (+ (length gnus-newsgroup-marked)
6283 (length gnus-newsgroup-dormant)))
6290 (cond ((and (or (<= scored marked)
6292 (numberp gnus-large-newsgroup)
6293 (> number gnus-large-newsgroup))
6297 "How many articles from %s (default %d): "
6298 gnus-newsgroup-name number))))
6299 (if (string-match "^[ \t]*$" input)
6301 ((and (> scored marked) (< scored number))
6305 "%s %s (%d scored, %d total): "
6306 "How many articles from"
6307 group scored number))))
6308 (if (string-match "^[ \t]*$" input)
6312 (setq select (if (stringp select) (string-to-number select) select))
6313 (if (or (null select) (zerop select))
6315 (if (and (not (zerop scored)) (<= (abs select) scored))
6317 (setq articles (sort scored-list '<))
6318 (setq number (length articles)))
6319 (setq articles (copy-sequence articles)))
6321 (if (< (abs select) number)
6323 ;; Select the N oldest articles.
6324 (setcdr (nthcdr (1- (abs select)) articles) nil)
6325 ;; Select the N most recent articles.
6326 (setq articles (nthcdr (- number select) articles))))
6327 (setq gnus-newsgroup-unselected
6328 (gnus-sorted-intersection
6329 gnus-newsgroup-unreads
6330 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6333 (defun gnus-killed-articles (killed articles)
6336 (if (inline (gnus-member-of-range (car articles) killed))
6337 (setq out (cons (car articles) out)))
6338 (setq articles (cdr articles)))
6341 (defun gnus-adjust-marked-articles (info &optional active)
6342 "Remove all marked articles that are no longer legal."
6343 (let ((marked-lists (nth 3 info))
6344 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6346 ;; There are many types of marked articles.
6348 (setq m (cdr (setq prev (car marked-lists))))
6349 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6350 ;; Make sure that all ticked articles are a subset of the
6351 ;; unread/unselected articles.
6353 (if (or (memq (car m) gnus-newsgroup-unreads)
6354 (memq (car m) gnus-newsgroup-unselected))
6356 (setcdr prev (cdr m)))
6358 ((eq 'score (car prev))
6359 ;; Scored articles should be a subset of
6360 ;; unread/unselected articles.
6362 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6363 (memq (car (car m)) gnus-newsgroup-unreads))
6365 (setcdr prev (cdr m)))
6367 ((eq 'bookmark (car prev))
6368 ;; Bookmarks should be a subset of active articles.
6370 (if (< (car (car m)) (car active))
6371 (setcdr prev (cdr m))
6374 ((eq 'killed (car prev))
6375 ;; Articles that have been through the kill process are
6376 ;; to be a subset of active articles.
6377 (while (and m (< (or (and (numberp (car m)) (car m))
6380 (setcdr prev (cdr m))
6382 (if (and m (< (or (and (numberp (car m)) (car m))
6385 (setcar (if (numberp (car m)) m (car m)) (car active))))
6386 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6387 ;; The replied and expirable articles have to be articles
6390 (if (< (car m) (car active))
6391 (setcdr prev (cdr m))
6394 (setq marked-lists (cdr marked-lists)))
6395 ;; Remove all lists that are empty.
6396 (setq marked-lists (nth 3 info))
6399 (while (= 1 (length (car marked-lists)))
6400 (setq marked-lists (cdr marked-lists)))
6401 (setq m (cdr (setq prev marked-lists)))
6403 (if (= 1 (length (car m)))
6404 (setcdr prev (cdr m))
6407 (setcar (nthcdr 3 info) marked-lists)))
6408 ;; Finally, if there are no marked lists at all left, and if there
6409 ;; are no elements after the lists in the info list, we just chop
6410 ;; the info list off before the marked lists.
6411 (and (null marked-lists)
6412 (not (nthcdr 4 info))
6413 (setcdr (nthcdr 2 info) nil)))
6416 (defun gnus-set-marked-articles
6417 (info ticked replied expirable killed dormant bookmark score)
6418 "Enter the various lists of marked articles into the newsgroup info list."
6420 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6421 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6422 (and expirable (setq newmarked (cons (cons 'expire expirable)
6424 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6425 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6426 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6428 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6431 (setcar (nthcdr 3 info) newmarked)
6432 (and (not newmarked)
6433 (not (nthcdr 4 info))
6434 (setcdr (nthcdr 2 info) nil)))
6436 (setcdr (nthcdr 2 info) (list newmarked))))))
6438 (defun gnus-add-marked-articles (group type articles &optional info force)
6439 ;; Add ARTICLES of TYPE to the info of GROUP.
6440 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6441 ;; add, but replace marked articles of TYPE with ARTICLES.
6442 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6445 (and (not (setq marked (nthcdr 3 info)))
6446 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6447 (and (not (setq m (assq type (car marked))))
6448 (setcar marked (cons (cons type articles) (car marked))))
6451 (nconc m articles)))))
6453 (defun gnus-set-mode-line (where)
6454 "This function sets the mode line of the article or summary buffers.
6455 If WHERE is `summary', the summary mode line format will be used."
6456 (if (memq where gnus-updated-mode-lines)
6459 (set-buffer gnus-summary-buffer)
6460 (let* ((mformat (if (eq where 'article)
6461 gnus-article-mode-line-format-spec
6462 gnus-summary-mode-line-format-spec))
6463 (group-name gnus-newsgroup-name)
6464 (article-number (or gnus-current-article 0))
6465 (unread (- (length gnus-newsgroup-unreads)
6466 (length gnus-newsgroup-dormant)))
6467 (unread-and-unticked
6468 (- unread (length gnus-newsgroup-marked)))
6469 (unselected (length gnus-newsgroup-unselected))
6470 (unread-and-unselected
6471 (cond ((and (zerop unread-and-unticked)
6472 (zerop unselected)) "")
6474 (format "{%d more}" unread-and-unticked))
6475 (t (format "{%d(+%d) more}"
6476 unread-and-unticked unselected))))
6478 (if gnus-current-headers
6479 (header-subject gnus-current-headers) ""))
6480 (max-len (and gnus-mode-non-string-length
6481 (- (frame-width) gnus-mode-non-string-length)))
6482 header) ;; passed as argument to any user-format-funcs
6483 (setq mode-string (eval mformat))
6484 (or (numberp max-len)
6485 (setq max-len (length mode-string)))
6486 (if (< max-len 4) (setq max-len 4))
6487 (if (> (length mode-string) max-len)
6488 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6489 ;; function `substring' might cut on a middle
6490 ;; of multi-octet character.
6492 (concat (gnus-truncate-string mode-string (- max-len 3))
6494 (setq mode-string (format (format "%%-%ds" max-len)
6496 (setq mode-line-buffer-identification mode-string)
6497 (set-buffer-modified-p t))))
6499 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6500 "Go through the HEADERS list and add all Xrefs to a hash table.
6501 The resulting hash table is returned, or nil if no Xrefs were found."
6502 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6504 (gnus-group-foreign-p from-newsgroup)
6506 (assoc (symbol-name (car from-method))
6507 gnus-valid-select-methods))))
6508 (gnus-group-real-prefix from-newsgroup)))
6509 (xref-hashtb (make-vector 63 0))
6510 start group entry number xrefs header)
6512 (setq header (car headers))
6513 (if (and (setq xrefs (header-xref header))
6514 (not (memq (header-number header) unreads)))
6517 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6518 (setq start (match-end 0))
6519 (setq group (concat prefix (substring xrefs (match-beginning 1)
6522 (string-to-int (substring xrefs (match-beginning 2)
6524 (if (setq entry (gnus-gethash group xref-hashtb))
6525 (setcdr entry (cons number (cdr entry)))
6526 (gnus-sethash group (cons number nil) xref-hashtb)))))
6527 (setq headers (cdr headers)))
6528 (if start xref-hashtb nil)))
6530 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6531 "Look through all the headers and mark the Xrefs as read."
6532 (let ((virtual (memq 'virtual
6533 (assoc (symbol-name (car (gnus-find-method-for-group
6535 gnus-valid-select-methods)))
6536 name entry info xref-hashtb idlist method
6539 (set-buffer gnus-group-buffer)
6540 (if (setq xref-hashtb
6541 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6544 (if (string= from-newsgroup (setq name (symbol-name group)))
6546 (setq idlist (symbol-value group))
6547 ;; Dead groups are not updated.
6549 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6551 (if (stringp (setq nth4 (nth 4 info)))
6552 (setq nth4 (gnus-server-to-method nth4))))
6553 ;; Only do the xrefs if the group has the same
6554 ;; select method as the group we have just read.
6555 (or (gnus-methods-equal-p
6556 nth4 (gnus-find-method-for-group from-newsgroup))
6559 (setq method (gnus-find-method-for-group
6561 (and (equal (car nth4) (car method))
6562 (equal (nth 1 nth4) (nth 1 method))))
6563 gnus-use-cross-reference
6564 (or (not (eq gnus-use-cross-reference t))
6566 ;; Only do cross-references on subscribed
6567 ;; groups, if that is what is wanted.
6568 (<= (nth 1 info) gnus-level-subscribed)))
6569 (gnus-group-make-articles-read name idlist expirable))))
6572 (defun gnus-group-make-articles-read (group articles expirable)
6574 (entry (gnus-gethash group gnus-newsrc-hashtb))
6575 (info (nth 2 entry))
6576 (active (gnus-gethash group gnus-active-hashtb))
6577 exps expirable range)
6578 ;; First peel off all illegal article numbers.
6580 (let ((ids articles)
6581 (ticked (cdr (assq 'tick (nth 3 info))))
6582 (dormant (cdr (assq 'dormant (nth 3 info))))
6587 (if (or (> id (cdr active))
6591 (setq articles (delq id articles)))
6592 (and (memq id expirable)
6593 (setq exps (cons id exps)))
6594 (setq ids (cdr ids)))))
6595 ;; Update expirable articles.
6596 (gnus-add-marked-articles nil 'expirable exps info)
6600 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6601 (setcar (nthcdr 2 info)
6605 (setq articles (sort articles '<)))))
6606 ;; Then we have to re-compute how many unread
6607 ;; articles there are in this group.
6612 (setq num (- (1+ (cdr active)) (car active))))
6613 ((not (listp (cdr range)))
6614 (setq num (- (cdr active) (- (1+ (cdr range))
6618 (if (numberp (car range))
6620 (setq num (+ num (- (1+ (cdr (car range)))
6621 (car (car range))))))
6622 (setq range (cdr range)))
6623 (setq num (- (cdr active) num))))
6624 ;; Update the number of unread articles.
6628 (length (cdr (assq 'tick (nth 3 info))))
6630 (cdr (assq 'dormant (nth 3 info)))))))
6631 ;; Update the group buffer.
6632 (gnus-group-update-group group t)))))
6634 (defun gnus-methods-equal-p (m1 m2)
6635 (let ((m1 (or m1 gnus-select-method))
6636 (m2 (or m2 gnus-select-method)))
6638 (and (eq (car m1) (car m2))
6639 (or (not (memq 'address (assoc (symbol-name (car m1))
6640 gnus-valid-select-methods)))
6641 (equal (nth 1 m1) (nth 1 m2)))))))
6643 (defsubst gnus-header-value ()
6644 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6646 (defvar gnus-newsgroup-none-id 0)
6648 (defun gnus-get-newsgroup-headers ()
6649 (setq gnus-article-internal-prepare-hook nil)
6650 (let ((cur nntp-server-buffer)
6651 (dependencies gnus-newsgroup-dependencies)
6652 headers id dep end ref)
6654 (set-buffer nntp-server-buffer)
6655 (goto-char (point-min))
6656 ;; Search to the beginning of the next header. Error messages
6657 ;; do not begin with 2 or 3.
6658 (while (re-search-forward "^[23][0-9]+ " nil t)
6659 (let ((header (make-vector 9 nil))
6660 (case-fold-search t)
6665 (header-set-number header (read cur))
6666 ;; This implementation of this function, with nine
6667 ;; search-forwards instead of the one re-search-forward and
6668 ;; a case (which basically was the old function) is actually
6669 ;; about twice as fast, even though it looks messier. You
6670 ;; can't have everything, I guess. Speed and elegance
6671 ;; doesn't always come hand in hand.
6673 (narrow-to-region (point) (or (save-excursion
6674 (search-forward "\n.\n" nil t))
6676 (if (search-forward "\nfrom: " nil t)
6677 (header-set-from header (gnus-header-value))
6678 (header-set-from header "(nobody)"))
6680 (if (search-forward "\nsubject: " nil t)
6681 (header-set-subject header (gnus-header-value))
6682 (header-set-subject header "(none)"))
6684 (and (search-forward "\nxref: " nil t)
6685 (header-set-xref header (gnus-header-value)))
6687 (or (numberp (and (search-forward "\nlines: " nil t)
6688 (header-set-lines header (read cur))))
6689 (header-set-lines header 0))
6691 (and (search-forward "\ndate: " nil t)
6692 (header-set-date header (gnus-header-value)))
6694 (if (search-forward "\nmessage-id: " nil t)
6695 (header-set-id header (setq id (gnus-header-value)))
6696 ;; If there was no message-id, we just fake one to make
6697 ;; subsequent routines simpler.
6700 (setq id (concat "none+"
6702 (setq gnus-newsgroup-none-id
6703 (1+ gnus-newsgroup-none-id)))))))
6705 (if (search-forward "\nreferences: " nil t)
6707 (header-set-references header (gnus-header-value))
6708 (setq end (match-end 0))
6715 (search-backward ">" end t)
6718 (search-backward "<" end t)
6720 ;; Get the references from the in-reply-to header if there
6721 ;; ware no references and the in-reply-to header looks
6723 (if (and (search-forward "\nin-reply-to: " nil t)
6724 (setq in-reply-to (gnus-header-value))
6725 (string-match "<[^>]+>" in-reply-to))
6727 (header-set-references
6729 (setq ref (substring in-reply-to (match-beginning 0)
6731 (setq ref (downcase ref)))
6733 ;; We do some threading while we read the headers. The
6734 ;; message-id and the last reference are both entered into
6735 ;; the same hash table. Some tippy-toeing around has to be
6736 ;; done in case an article has arrived before the article
6737 ;; which it refers to.
6738 (if (boundp (setq dep (intern (downcase id) dependencies)))
6739 (if (car (symbol-value dep))
6740 ;; An article with this Message-ID has already
6741 ;; been seen, so we ignore this one, except we add
6742 ;; any additional Xrefs (in case the two articles
6743 ;; came from different servers.
6746 (car (symbol-value dep))
6747 (concat (or (header-xref (car (symbol-value dep))) "")
6748 (or (header-xref header) "")))
6750 (setcar (symbol-value dep) header))
6751 (set dep (list header)))
6754 (if (boundp (setq dep (intern ref dependencies)))
6755 (setcdr (symbol-value dep)
6756 (cons header (cdr (symbol-value dep))))
6757 (set dep (list nil header)))
6758 (setq headers (cons header headers))))
6759 (goto-char (point-max))))))
6760 (nreverse headers)))
6762 ;; The following macros and functions were written by Felix Lee
6763 ;; <flee@cse.psu.edu>.
6765 (defmacro gnus-nov-read-integer ()
6767 (if (= (following-char) ?\t)
6769 (let ((num (condition-case nil (read buffer) (error nil))))
6770 (if (numberp num) num 0)))
6771 (or (eobp) (forward-char 1))))
6773 (defmacro gnus-nov-skip-field ()
6774 '(search-forward "\t" eol 'move))
6776 (defmacro gnus-nov-field ()
6777 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6779 ;; Goes through the xover lines and returns a list of vectors
6780 (defun gnus-get-newsgroup-headers-xover (sequence)
6781 "Parse the news overview data in the server buffer, and return a
6782 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6783 ;; Get the Xref when the users reads the articles since most/some
6784 ;; NNTP servers do not include Xrefs when using XOVER.
6785 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6786 (let ((cur nntp-server-buffer)
6787 (dependencies gnus-newsgroup-dependencies)
6788 number headers header)
6790 (set-buffer nntp-server-buffer)
6791 (goto-char (point-min))
6792 (while (and sequence (not (eobp)))
6793 (setq number (read cur))
6794 (while (and sequence (< (car sequence) number))
6795 (setq sequence (cdr sequence)))
6797 (eq number (car sequence))
6799 (setq sequence (cdr sequence))
6801 (inline (gnus-nov-parse-line number dependencies)))
6802 (setq headers (cons header headers)))))
6804 (setq headers (nreverse headers)))
6807 ;; This function has to be called with point after the article number
6808 ;; on the beginning of the line.
6809 (defun gnus-nov-parse-line (number dependencies)
6811 (eol (gnus-point-at-eol))
6812 (buffer (current-buffer))
6815 ;; overview: [num subject from date id refs chars lines misc]
6816 (narrow-to-region (point) eol)
6823 (gnus-nov-field) ; subject
6824 (gnus-nov-field) ; from
6825 (gnus-nov-field) ; date
6826 (setq id (or (gnus-nov-field)
6829 (setq none (1+ none)))))) ; id
6832 (let ((beg (point)))
6833 (search-forward "\t" eol)
6834 (if (search-backward ">" beg t)
6840 (search-backward "<" beg t)
6843 (gnus-nov-field)) ; refs
6844 (gnus-nov-read-integer) ; chars
6845 (gnus-nov-read-integer) ; lines
6846 (if (= (following-char) ?\n)
6848 (gnus-nov-field)) ; misc
6852 (message "Strange nov line.")
6858 ;; We build the thread tree.
6860 (if (boundp (setq dep (intern (downcase id) dependencies)))
6861 (if (car (symbol-value dep))
6862 ;; An article with this Message-ID has already been seen,
6863 ;; so we ignore this one, except we add any additional
6864 ;; Xrefs (in case the two articles came from different
6868 (car (symbol-value dep))
6869 (concat (or (header-xref (car (symbol-value dep))) "")
6870 (or (header-xref header) "")))
6872 (setcar (symbol-value dep) header))
6873 (set dep (list header))))
6876 (if (boundp (setq dep (intern (or ref "none")
6878 (setcdr (symbol-value dep)
6879 (cons header (cdr (symbol-value dep))))
6880 (set dep (list nil header)))))
6883 (defun gnus-article-get-xrefs ()
6884 "Fill in the Xref value in `gnus-current-headers', if necessary.
6885 This is meant to be called in `gnus-article-internal-prepare-hook'."
6886 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6887 gnus-current-headers)))
6888 (or (not gnus-use-cross-reference)
6890 (and (header-xref headers)
6891 (not (string= (header-xref headers) "")))
6892 (let ((case-fold-search t)
6895 (gnus-narrow-to-headers)
6896 (goto-char (point-min))
6897 (if (or (and (eq (downcase (following-char)) ?x)
6898 (looking-at "Xref:"))
6899 (search-forward "\nXref:" nil t))
6901 (goto-char (1+ (match-end 0)))
6902 (setq xref (buffer-substring (point)
6903 (progn (end-of-line) (point))))
6904 (header-set-xref headers xref))))))))
6906 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6907 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6909 ;; Return a header specified by a NUMBER.
6910 (defun gnus-get-header-by-number (number)
6912 (set-buffer gnus-summary-buffer)
6913 (or gnus-newsgroup-headers-hashtb-by-number
6914 (gnus-make-headers-hashtable-by-number))
6915 (gnus-gethash (int-to-string number)
6916 gnus-newsgroup-headers-hashtb-by-number)))
6918 (defun gnus-make-headers-hashtable-by-number ()
6919 "Make hashtable for the variable gnus-newsgroup-headers by number."
6921 (set-buffer gnus-summary-buffer)
6922 (let ((headers gnus-newsgroup-headers)
6924 (setq gnus-newsgroup-headers-hashtb-by-number
6925 (gnus-make-hashtable (length headers)))
6927 (setq header (car headers))
6928 (gnus-sethash (int-to-string (header-number header))
6929 header gnus-newsgroup-headers-hashtb-by-number)
6930 (setq headers (cdr headers))))))
6932 (defun gnus-more-header-backward ()
6933 "Find new header backward."
6934 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6935 (artnum gnus-newsgroup-begin)
6937 (while (and (not header)
6939 (setq artnum (1- artnum))
6940 (setq header (gnus-read-header artnum)))
6943 (defun gnus-more-header-forward (&optional backward)
6944 "Find new header forward.
6945 If BACKWARD, find new header backward instead."
6947 (gnus-more-header-backward)
6948 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6949 (artnum gnus-newsgroup-end)
6951 (while (and (not header)
6953 (setq artnum (1+ artnum))
6954 (setq header (gnus-read-header artnum)))
6957 (defun gnus-extend-newsgroup (header &optional backward)
6958 "Extend newsgroup selection with HEADER.
6959 Optional argument BACKWARD means extend toward backward."
6961 (let ((artnum (header-number header)))
6962 (setq gnus-newsgroup-headers
6964 (cons header gnus-newsgroup-headers)
6965 (nconc gnus-newsgroup-headers (list header))))
6966 (setq gnus-newsgroup-unselected
6967 (delq artnum gnus-newsgroup-unselected))
6968 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6969 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6971 (defun gnus-summary-work-articles (n)
6972 "Return a list of articles to be worked upon. The prefix argument,
6973 the list of process marked articles, and the current article will be
6974 taken into consideration."
6976 (if (and n (numberp n))
6977 (let ((backward (< n 0))
6981 (setq articles (cons (gnus-summary-article-number)
6983 (gnus-summary-search-forward nil nil backward))
6985 (sort articles (function <)))
6986 (or (reverse gnus-newsgroup-processable)
6987 (list (gnus-summary-article-number))))))
6989 (defun gnus-summary-search-group (&optional backward use-level)
6990 "Search for next unread newsgroup.
6991 If optional argument BACKWARD is non-nil, search backward instead."
6993 (set-buffer gnus-group-buffer)
6994 (if (gnus-group-search-forward
6995 backward nil (if use-level (gnus-group-group-level) nil))
6996 (gnus-group-group-name))))
6998 (defun gnus-summary-best-group (&optional exclude-group)
6999 "Find the name of the best unread group.
7000 If EXCLUDE-GROUP, do not go to this group."
7002 (set-buffer gnus-group-buffer)
7004 (gnus-group-best-unread-group exclude-group))))
7006 (defun gnus-summary-search-subject (&optional backward unread subject)
7007 "Search for article forward.
7008 If BACKWARD is non-nil, search backward.
7009 If UNREAD is non-nil, only unread articles are selected.
7010 If SUBJECT is non-nil, the article which has the same subject will be
7012 (let ((func (if backward 'previous-single-property-change
7013 'next-single-property-change))
7018 (and gnus-summary-check-current unread
7019 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7023 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7026 (setq pos (funcall func (point) 'gnus-number))
7027 (goto-char (if backward (1- pos) pos))
7031 (eq (get-text-property (point) 'gnus-mark)
7034 (and (setq psubject (gnus-summary-subject-string))
7035 (gnus-subject-eq subject psubject))))))
7036 (if backward (if (bobp) nil (forward-char -1) t)
7037 (if (eobp) nil (forward-char 1) t)))))
7039 (progn (goto-char beg) nil)
7041 (get-text-property (point) 'gnus-number)
7042 (gnus-summary-position-cursor)))))
7044 (defun gnus-subject-eq (s1 s2)
7046 ((null gnus-summary-gather-subject-limit)
7047 (equal (gnus-simplify-subject-re s1)
7048 (gnus-simplify-subject-re s2)))
7049 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7050 (equal (gnus-simplify-subject-fuzzy s1)
7051 (gnus-simplify-subject-fuzzy s2)))
7052 ((numberp gnus-summary-gather-subject-limit)
7053 (equal (substring s1 gnus-summary-gather-subject-limit)
7054 (substring s2 gnus-summary-gather-subject-limit)))
7058 (defun gnus-summary-search-forward (&optional unread subject backward)
7059 "Search for article forward.
7060 If UNREAD is non-nil, only unread articles are selected.
7061 If SUBJECT is non-nil, the article which has the same subject will be
7063 If BACKWARD is non-nil, the search will be performed backwards instead."
7064 (gnus-summary-search-subject backward unread subject))
7066 (defun gnus-summary-search-backward (&optional unread subject)
7067 "Search for article backward.
7068 If 1st optional argument UNREAD is non-nil, only unread article is selected.
7069 If 2nd optional argument SUBJECT is non-nil, the article which has
7070 the same subject will be searched for."
7071 (gnus-summary-search-forward unread subject t))
7073 (defun gnus-summary-article-number (&optional number-or-nil)
7074 "The article number of the article on the current line.
7075 If there isn's an article number here, then we return the current
7077 (let* ((number (get-text-property (gnus-point-at-bol) 'gnus-number)))
7078 (if number-or-nil number (or number gnus-current-article))))
7080 (defun gnus-summary-thread-level ()
7081 "The thread level of the article on the current line."
7082 (or (get-text-property (gnus-point-at-bol) 'gnus-level)
7085 (defun gnus-summary-pseudo-article ()
7086 "The thread level of the article on the current line."
7087 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7089 (defun gnus-summary-article-mark ()
7090 "The mark on the current line."
7091 (get-text-property (gnus-point-at-bol) 'gnus-mark))
7093 (defun gnus-summary-subject-string ()
7094 "Return current subject string or nil if nothing."
7095 (let ((article (gnus-summary-article-number))
7098 (setq header (gnus-get-header-by-number article))
7100 (header-subject header))))
7102 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7103 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7104 (defun gnus-summary-article-score ()
7105 "Return current article score."
7106 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7107 gnus-summary-default-score 0))
7109 (defun gnus-summary-recenter ()
7110 "Center point in the summary window.
7111 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7112 displayed, no centering will be performed."
7113 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7114 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7115 (let* ((top (cond ((< (window-height) 4) 0)
7116 ((< (window-height) 7) 1)
7118 (height (1- (window-height)))
7119 (bottom (save-excursion (goto-char (point-max))
7120 (forward-line (- height))
7122 (window (get-buffer-window (current-buffer))))
7124 ;; The user has to want it,
7125 gnus-auto-center-summary
7126 ;; the article buffer must be displayed,
7127 (get-buffer-window gnus-article-buffer)
7128 ;; Set the window start to either `bottom', which is the biggest
7129 ;; possible valid number, or the second line from the top,
7130 ;; whichever is the least.
7132 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7134 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7135 (defun gnus-short-group-name (group &optional levels)
7136 "Collapse GROUP name LEVELS."
7137 (let* ((name "") (foreign "") (depth -1) (skip 1)
7140 (while (string-match "\\." group skip)
7141 (setq skip (match-end 0)
7144 (if (string-match ":" group)
7145 (setq foreign (substring group 0 (match-end 0))
7146 group (substring group (match-end 0))))
7148 (if (and (string-match "\\." group) (> levels 0))
7149 (setq name (concat name (substring group 0 1))
7150 group (substring group (match-end 0))
7152 name (concat name "."))
7153 (setq name (concat foreign name group)
7157 (defun gnus-summary-jump-to-group (newsgroup)
7158 "Move point to NEWSGROUP in group mode buffer."
7159 ;; Keep update point of group mode buffer if visible.
7160 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7161 (save-window-excursion
7162 ;; Take care of tree window mode.
7163 (if (get-buffer-window gnus-group-buffer)
7164 (pop-to-buffer gnus-group-buffer))
7165 (gnus-group-jump-to-group newsgroup))
7167 ;; Take care of tree window mode.
7168 (if (get-buffer-window gnus-group-buffer)
7169 (pop-to-buffer gnus-group-buffer)
7170 (set-buffer gnus-group-buffer))
7171 (gnus-group-jump-to-group newsgroup))))
7173 ;; This function returns a list of article numbers based on the
7174 ;; difference between the ranges of read articles in this group and
7175 ;; the range of active articles.
7176 (defun gnus-list-of-unread-articles (group)
7177 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7178 (active (gnus-gethash group gnus-active-hashtb))
7181 ;; If none are read, then all are unread.
7183 (setq first (car active))
7184 ;; If the range of read articles is a single range, then the
7185 ;; first unread article is the article after the last read
7186 ;; article. Sounds logical, doesn't it?
7187 (if (not (listp (cdr read)))
7188 (setq first (1+ (cdr read)))
7189 ;; `read' is a list of ranges.
7190 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7191 (car (car read)))) 1)
7195 (while (< first nlast)
7196 (setq unread (cons first unread))
7197 (setq first (1+ first))))
7198 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7199 (setq nlast (if (atom (car (cdr read)))
7201 (car (car (cdr read)))))
7202 (setq read (cdr read)))))
7203 ;; And add the last unread articles.
7204 (while (<= first last)
7205 (setq unread (cons first unread))
7206 (setq first (1+ first)))
7207 ;; Return the list of unread articles.
7210 (defun gnus-list-of-read-articles (group)
7211 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7212 (active (gnus-gethash group gnus-active-hashtb)))
7214 (gnus-sorted-complement
7215 (gnus-uncompress-range active)
7216 (gnus-list-of-unread-articles group)))))
7218 ;; Various summary commands
7220 (defun gnus-summary-universal-argument ()
7221 "Perform any operation on all articles marked with the process mark."
7223 (gnus-set-global-variables)
7224 (let ((articles (reverse gnus-newsgroup-processable))
7226 (or articles (error "No articles marked"))
7227 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7228 (error "Undefined key"))
7230 (gnus-summary-goto-subject (car articles))
7231 (command-execute func)
7232 (gnus-summary-remove-process-mark (car articles))
7233 (setq articles (cdr articles)))))
7235 (defun gnus-summary-toggle-truncation (arg)
7236 "Toggle truncation of summary lines.
7237 With arg, turn line truncation on iff arg is positive."
7239 (setq truncate-lines
7240 (if (null arg) (not truncate-lines)
7241 (> (prefix-numeric-value arg) 0)))
7244 (defun gnus-summary-reselect-current-group (all)
7245 "Once exit and then reselect the current newsgroup.
7246 The prefix argument ALL means to select all articles."
7248 (gnus-set-global-variables)
7249 (let ((current-subject (gnus-summary-article-number))
7250 (group gnus-newsgroup-name))
7251 (setq gnus-newsgroup-begin nil)
7252 (gnus-summary-exit t)
7253 ;; We have to adjust the point of group mode buffer because the
7254 ;; current point was moved to the next unread newsgroup by
7256 (gnus-summary-jump-to-group group)
7257 (gnus-group-read-group all t)
7258 (gnus-summary-goto-subject current-subject)))
7260 (defun gnus-summary-rescan-group (all)
7261 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7263 (gnus-set-global-variables)
7264 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7265 (let ((group gnus-newsgroup-name))
7267 (gnus-summary-jump-to-group group)
7269 (set-buffer gnus-group-buffer)
7270 (gnus-group-get-new-news-this-group 1))
7271 (gnus-summary-jump-to-group group)
7272 (gnus-group-read-group all)))
7274 (defun gnus-summary-update-info ()
7275 (let* ((group gnus-newsgroup-name))
7276 (if gnus-newsgroup-kill-headers
7277 (setq gnus-newsgroup-killed
7278 (gnus-compress-sequence
7280 (gnus-set-sorted-intersection
7281 (gnus-uncompress-range gnus-newsgroup-killed)
7282 (setq gnus-newsgroup-unselected
7283 (sort gnus-newsgroup-unselected '<)))
7284 (setq gnus-newsgroup-unreads
7285 (sort gnus-newsgroup-unreads '<))) t)))
7286 (or (listp (cdr gnus-newsgroup-killed))
7287 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7288 (let ((headers gnus-newsgroup-headers))
7289 (gnus-close-group group)
7290 (run-hooks 'gnus-exit-group-hook)
7291 (gnus-update-read-articles
7292 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7293 gnus-newsgroup-marked
7294 t gnus-newsgroup-replied gnus-newsgroup-expirable
7295 gnus-newsgroup-killed gnus-newsgroup-dormant
7296 gnus-newsgroup-bookmarks
7297 (and gnus-save-score gnus-newsgroup-scored))
7298 (and gnus-use-cross-reference
7299 (gnus-mark-xrefs-as-read
7300 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7301 ;; Do adaptive scoring, and possibly save score files.
7302 (and gnus-newsgroup-adaptive
7303 (gnus-score-adaptive))
7304 (and gnus-use-scoring
7305 (fboundp 'gnus-score-save)
7306 (funcall 'gnus-score-save))
7307 ;; Do not switch windows but change the buffer to work.
7308 (set-buffer gnus-group-buffer)
7309 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7310 (gnus-group-update-group group)))))
7312 (defun gnus-summary-exit (&optional temporary)
7313 "Exit reading current newsgroup, and then return to group selection mode.
7314 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7316 (gnus-set-global-variables)
7317 (gnus-kill-save-kill-buffer)
7318 (let* ((group gnus-newsgroup-name)
7319 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7320 gnus-newsgroup-name))))
7322 (buf (current-buffer)))
7323 (gnus-summary-update-info) ; Make all changes in this group permanent.
7324 ;; Make sure where I was, and go to next newsgroup.
7327 (gnus-group-jump-to-group group)
7328 (gnus-group-next-unread-group 1)))
7329 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7332 ;; We set all buffer-local variables to nil. It is unclear why
7333 ;; this is needed, but if we don't, buffer-local variables are
7334 ;; not garbage-collected, it seems. This would the lead to en
7335 ;; ever-growing Emacs.
7337 (gnus-summary-clear-local-variables)
7338 ;; We clear the global counterparts of the buffer-local
7339 ;; variables as well, just to be on the safe side.
7340 (gnus-configure-windows 'group)
7341 (gnus-summary-clear-local-variables)
7342 ;; Return to group mode buffer.
7343 (if (eq mode 'gnus-summary-mode)
7344 (gnus-kill-buffer buf))
7345 (if (get-buffer gnus-article-buffer)
7346 (bury-buffer gnus-article-buffer))
7347 (setq gnus-current-select-method gnus-select-method)
7348 (pop-to-buffer gnus-group-buffer)
7349 (if (not quit-config)
7351 (gnus-group-jump-to-group group)
7352 (gnus-group-next-unread-group 1))
7353 (if (not (buffer-name (car quit-config)))
7354 (gnus-configure-windows 'group)
7355 (set-buffer (car quit-config))
7356 (and (eq major-mode 'gnus-summary-mode)
7357 (gnus-set-global-variables))
7358 (gnus-configure-windows (cdr quit-config)))))))
7360 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7361 (defun gnus-summary-exit-no-update (&optional no-questions)
7362 "Quit reading current newsgroup without updating read article info."
7364 (gnus-set-global-variables)
7365 (let* ((group gnus-newsgroup-name)
7366 (quit-config (nth 1 (assoc 'quit-config
7367 (gnus-find-method-for-group group)))))
7368 (if (or no-questions
7370 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7372 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7373 (gnus-close-group group)
7374 (gnus-summary-clear-local-variables)
7375 (set-buffer gnus-group-buffer)
7376 (gnus-summary-clear-local-variables)
7377 ;; Return to group selection mode.
7378 (gnus-configure-windows 'group)
7379 (if (get-buffer gnus-summary-buffer)
7380 (kill-buffer gnus-summary-buffer))
7381 (if (get-buffer gnus-article-buffer)
7382 (bury-buffer gnus-article-buffer))
7383 (if (equal (gnus-group-group-name) group)
7384 (gnus-group-next-unread-group 1))
7387 (if (not (buffer-name (car quit-config)))
7388 (gnus-configure-windows 'group)
7389 (set-buffer (car quit-config))
7390 (and (eq major-mode 'gnus-summary-mode)
7391 (gnus-set-global-variables))
7392 (gnus-configure-windows (cdr quit-config)))))))))
7394 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7395 (defun gnus-summary-fetch-faq (group)
7396 "Fetch the FAQ for the current group."
7397 (interactive (list gnus-newsgroup-name))
7398 (let ((gnus-faq-buffer
7399 (find-file (concat gnus-group-faq-directory
7400 (gnus-group-real-name group)))))
7401 (and gnus-faq-buffer (gnus-configure-windows 'summary-faq))))
7403 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7404 (defun gnus-summary-describe-group (force)
7405 "Describe the current newsgroup."
7407 (gnus-group-describe-group force gnus-newsgroup-name))
7409 (defun gnus-summary-describe-briefly ()
7410 "Describe summary mode commands briefly."
7413 (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")))
7415 ;; Walking around group mode buffer from summary mode.
7417 (defun gnus-summary-next-group (&optional no-article target-group backward)
7418 "Exit current newsgroup and then select next unread newsgroup.
7419 If prefix argument NO-ARTICLE is non-nil, no article is selected
7420 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7421 previous group instead."
7423 (gnus-set-global-variables)
7424 (let ((current-group gnus-newsgroup-name)
7425 (current-buffer (current-buffer))
7427 ;; First we semi-exit this group to update Xrefs and all variables.
7428 ;; We can't do a real exit, because the window conf must remain
7429 ;; the same in case the user is prompted for info, and we don't
7430 ;; want the window conf to change before that...
7431 (gnus-summary-exit t)
7432 (while (not entered)
7433 ;; Then we find what group we are supposed to enter.
7434 (set-buffer gnus-group-buffer)
7435 (gnus-group-jump-to-group current-group)
7438 (if (eq gnus-keep-same-level 'best)
7439 (gnus-summary-best-group gnus-newsgroup-name)
7440 (gnus-summary-search-group backward gnus-keep-same-level))))
7441 (if (not target-group)
7442 ;; There are no further groups, so we return to the group
7445 (gnus-message 5 "Returning to the group buffer")
7447 (set-buffer current-buffer)
7448 (gnus-summary-exit))
7449 ;; We try to enter the target group.
7450 (gnus-group-jump-to-group target-group)
7451 (if (and (not (zerop (gnus-group-group-unread)))
7452 (gnus-summary-read-group
7453 target-group nil no-article current-buffer))
7455 (setq current-group target-group
7456 target-group nil))))))
7458 (defun gnus-summary-next-group-old (&optional no-article group backward)
7459 "Exit current newsgroup and then select next unread newsgroup.
7460 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7461 If BACKWARD, go to previous group instead."
7463 (gnus-set-global-variables)
7464 (let ((ingroup gnus-newsgroup-name)
7465 (sumbuf (current-buffer))
7467 (set-buffer gnus-group-buffer)
7469 (or (and (numberp (setq num (car (gnus-gethash
7470 group gnus-newsrc-hashtb))))
7474 (gnus-group-jump-to-group group)
7476 (gnus-group-jump-to-group ingroup))
7477 (gnus-summary-search-group backward)
7478 (let ((group (or group (gnus-summary-search-group backward))))
7480 (gnus-summary-exit t) ;Update all information.
7482 (gnus-summary-exit-no-update t)
7483 (gnus-group-jump-to-group ingroup)
7484 (setq group (gnus-summary-search-group backward))
7485 (gnus-message 5 "Selecting %s..." group)
7486 (set-buffer gnus-group-buffer)
7487 ;; We are now in group mode buffer.
7488 ;; Make sure group mode buffer point is on GROUP.
7489 (gnus-group-jump-to-group group)
7490 (if (not (eq gnus-auto-select-next 'quietly))
7492 (gnus-summary-read-group group nil no-article sumbuf)
7493 (and (string= gnus-newsgroup-name ingroup)
7494 (bufferp sumbuf) (buffer-name sumbuf)
7496 (set-buffer (setq gnus-summary-buffer sumbuf))
7497 (gnus-summary-exit-no-update t))))
7498 (let ((prevgroup group))
7499 (gnus-group-jump-to-group ingroup)
7500 (setq group (gnus-summary-search-group backward))
7501 (gnus-summary-read-group group nil no-article sumbuf)
7502 (while (and (string= gnus-newsgroup-name ingroup)
7504 (buffer-name sumbuf)
7505 (not (string= prevgroup (gnus-group-group-name))))
7506 (set-buffer gnus-group-buffer)
7507 (gnus-summary-read-group
7508 (setq prevgroup (gnus-group-group-name))
7509 nil no-article sumbuf))
7510 (and (string= prevgroup (gnus-group-group-name))
7511 ;; We have reached the final group in the group
7514 (if (buffer-name sumbuf)
7517 (gnus-summary-exit)))))))))))
7519 (defun gnus-summary-prev-group (no-article)
7520 "Exit current newsgroup and then select previous unread newsgroup.
7521 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7523 (gnus-summary-next-group no-article nil t))
7525 ;; Walking around summary lines.
7527 (defun gnus-summary-first-subject (unread)
7528 "Go to the first unread subject.
7529 If UNREAD is non-nil, go to the first unread article.
7530 Returns nil if there are no unread articles."
7534 (goto-char (point-min)))
7537 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7540 ;; There are no unread articles.
7541 (gnus-message 3 "No more unread articles")
7543 (gnus-summary-position-cursor)))
7545 (defun gnus-summary-next-subject (n &optional unread dont-display)
7546 "Go to next N'th summary line.
7547 If N is negative, go to the previous N'th subject line.
7548 If UNREAD is non-nil, only unread articles are selected.
7549 The difference between N and the actual number of steps taken is
7552 (let ((backward (< n 0))
7555 (gnus-summary-search-forward unread nil backward))
7557 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7558 (if unread " unread" "")))
7561 (gnus-summary-recenter)
7562 (gnus-summary-position-cursor)))
7565 (defun gnus-summary-next-unread-subject (n)
7566 "Go to next N'th unread summary line."
7568 (gnus-summary-next-subject n t))
7570 (defun gnus-summary-prev-subject (n &optional unread)
7571 "Go to previous N'th summary line.
7572 If optional argument UNREAD is non-nil, only unread article is selected."
7574 (gnus-summary-next-subject (- n) unread))
7576 (defun gnus-summary-prev-unread-subject (n)
7577 "Go to previous N'th unread summary line."
7579 (gnus-summary-next-subject (- n) t))
7581 (defun gnus-summary-goto-subject (article)
7582 "Go the subject line of ARTICLE."
7586 (completing-read "Article number: "
7590 (int-to-string (header-number headers))))
7591 gnus-newsgroup-headers)
7592 nil 'require-match))))
7593 (or article (error "No article number"))
7595 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
7596 'gnus-number article)))
7598 (gnus-summary-show-thread)
7599 ;; Skip dummy articles.
7600 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7607 (gnus-summary-position-cursor)))))
7609 ;; Walking around summary lines with displaying articles.
7611 (defun gnus-summary-expand-window ()
7612 "Make the summary buffer take up the entire Emacs frame."
7614 (gnus-set-global-variables)
7615 (gnus-configure-windows 'summary))
7617 (defun gnus-summary-display-article (article &optional all-header)
7618 "Display ARTICLE in article buffer."
7619 (gnus-set-global-variables)
7623 (gnus-article-prepare article all-header)
7624 (gnus-summary-show-thread)
7625 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7628 (gnus-summary-position-cursor)))
7629 (run-hooks 'gnus-select-article-hook)
7630 (gnus-summary-recenter)
7631 (gnus-summary-goto-subject article)
7632 ;; Successfully display article.
7633 (gnus-summary-update-line)
7634 (gnus-article-set-window-start
7635 (cdr (assq article gnus-newsgroup-bookmarks)))
7638 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7639 "Select the current article.
7640 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7641 non-nil, the article will be re-fetched even if it already present in
7642 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7644 (and (not pseudo) (gnus-summary-pseudo-article)
7645 (error "This is a pseudo-article."))
7646 (let ((article (or article (gnus-summary-article-number)))
7647 (all-headers (not (not all-headers))) ;Must be T or NIL.
7651 (set-buffer gnus-summary-buffer)
7652 (if (or (null gnus-current-article)
7653 (null gnus-article-current)
7654 (not (eq article (cdr gnus-article-current)))
7655 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7657 ;; The requested article is different from the current article.
7659 (gnus-summary-display-article article all-headers)
7661 (if all-headers (gnus-article-show-all-headers))
7664 (gnus-article-set-window-start
7665 (cdr (assq article gnus-newsgroup-bookmarks)))))))
7667 (defun gnus-summary-set-current-mark (&optional current-mark)
7668 "Obsolete function."
7671 (defun gnus-summary-next-article (unread &optional subject backward)
7672 "Select the next article.
7673 If UNREAD, only unread articles are selected.
7674 If SUBJECT, only articles with SUBJECT are selected.
7675 If BACKWARD, the previous article is selected instead of the next."
7677 (gnus-set-global-variables)
7680 ;; Is there such an article?
7681 ((gnus-summary-display-article
7682 (gnus-summary-search-forward unread subject backward))
7683 (gnus-summary-position-cursor))
7684 ;; If not, we try the first unread, if that is wanted.
7686 gnus-auto-select-same
7687 (gnus-summary-first-unread-article))
7688 (gnus-message 6 "Wrapped"))
7689 ;; Try to get next/previous article not displayed in this group.
7690 ((and gnus-auto-extend-newsgroup
7691 (not unread) (not subject)
7692 (setq header (gnus-more-header-forward backward)))
7693 (gnus-extend-newsgroup header backward)
7694 (let ((buffer-read-only nil))
7695 (goto-char (if backward (point-min) (point-max)))
7696 (gnus-summary-prepare-threads (list header) 0))
7697 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7698 gnus-newsgroup-end)))
7699 ;; Go to next/previous group.
7701 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7702 (gnus-summary-jump-to-group gnus-newsgroup-name))
7703 (let ((cmd (aref (this-command-keys) 0))
7705 (if (eq gnus-keep-same-level 'best)
7706 (gnus-summary-best-group gnus-newsgroup-name)
7707 (gnus-summary-search-group backward gnus-keep-same-level))))
7708 ;; For some reason, the group window gets selected. We change
7710 (select-window (get-buffer-window (current-buffer)))
7711 ;; Keep just the event type of CMD.
7712 (and (listp cmd) (setq cmd (car cmd)))
7713 ;; Select next unread newsgroup automagically.
7715 ((not gnus-auto-select-next)
7716 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7717 ((eq gnus-auto-select-next 'quietly)
7719 (if (assoc 'quit-config (gnus-find-method-for-group
7720 gnus-newsgroup-name))
7722 (gnus-message 7 "No more%s articles (%s)..."
7723 (if unread " unread" "")
7724 (if group (concat "selecting " group)
7726 (gnus-summary-next-group nil group backward)))
7728 (let ((keystrokes '(?\C-n ?\C-p))
7730 (while (or (null key) (memq key keystrokes))
7732 7 "No more%s articles%s" (if unread " unread" "")
7733 (if (and group (not (assoc 'quit-config
7734 (gnus-find-method-for-group
7735 gnus-newsgroup-name))))
7736 (format " (Type %s for %s [%s])"
7737 (single-key-description cmd) group
7738 (car (gnus-gethash group gnus-newsrc-hashtb)))
7739 (format " (Type %s to exit %s)"
7740 (single-key-description cmd)
7741 gnus-newsgroup-name)))
7742 ;; Confirm auto selection.
7743 (let* ((event (read-event)))
7744 (setq key (if (listp event) (car event) event))
7745 (if (memq key keystrokes)
7746 (let ((obuf (current-buffer)))
7747 (switch-to-buffer gnus-group-buffer)
7748 (gnus-group-jump-to-group group)
7749 (execute-kbd-macro (char-to-string key))
7750 (setq group (gnus-group-group-name))
7751 (switch-to-buffer obuf)))))
7753 (if (or (not group) (assoc 'quit-config
7754 (gnus-find-method-for-group
7755 gnus-newsgroup-name)))
7757 (gnus-summary-next-group nil group backward))
7758 (setq unread-command-events (list key)))))))))))
7760 (defun gnus-summary-next-unread-article ()
7761 "Select unread article after current one."
7763 (gnus-summary-next-article t (and gnus-auto-select-same
7764 (gnus-summary-subject-string))))
7766 (defun gnus-summary-prev-article (unread &optional subject)
7767 "Select the article after the current one.
7768 If UNREAD is non-nil, only unread articles are selected."
7770 (gnus-summary-next-article unread subject t))
7772 (defun gnus-summary-prev-unread-article ()
7773 "Select unred article before current one."
7775 (gnus-summary-prev-article t (and gnus-auto-select-same
7776 (gnus-summary-subject-string))))
7778 (defun gnus-summary-next-page (lines &optional circular)
7779 "Show next page of selected article.
7780 If end of article, select next article.
7781 Argument LINES specifies lines to be scrolled up.
7782 If CIRCULAR is non-nil, go to the start of the article instead of
7783 instead of selecting the next article when reaching the end of the
7786 (setq gnus-summary-buffer (current-buffer))
7787 (gnus-set-global-variables)
7788 (let ((article (gnus-summary-article-number))
7790 (gnus-configure-windows 'article)
7791 (if (or (null gnus-current-article)
7792 (null gnus-article-current)
7793 (/= article (cdr gnus-article-current))
7794 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7795 ;; Selected subject is different from current article's.
7796 (gnus-summary-display-article article)
7797 (gnus-eval-in-buffer-window
7799 (setq endp (gnus-article-next-page lines)))
7802 (gnus-summary-beginning-of-article))
7804 (gnus-message 3 "End of message"))
7806 (gnus-summary-next-unread-article)))))
7807 (gnus-summary-recenter)
7808 (gnus-summary-position-cursor)))
7810 (defun gnus-summary-prev-page (lines)
7811 "Show previous page of selected article.
7812 Argument LINES specifies lines to be scrolled down."
7814 (gnus-set-global-variables)
7815 (let ((article (gnus-summary-article-number)))
7816 (gnus-configure-windows 'article)
7817 (if (or (null gnus-current-article)
7818 (null gnus-article-current)
7819 (/= article (cdr gnus-article-current))
7820 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7821 ;; Selected subject is different from current article's.
7822 (gnus-summary-display-article article)
7823 (gnus-summary-recenter)
7824 (gnus-eval-in-buffer-window gnus-article-buffer
7825 (gnus-article-prev-page lines))))
7826 (gnus-summary-position-cursor))
7828 (defun gnus-summary-scroll-up (lines)
7829 "Scroll up (or down) one line current article.
7830 Argument LINES specifies lines to be scrolled up (or down if negative)."
7832 (gnus-set-global-variables)
7833 (gnus-configure-windows 'article)
7834 (or (gnus-summary-select-article nil nil 'pseudo)
7835 (gnus-eval-in-buffer-window
7838 (if (gnus-article-next-page lines)
7839 (gnus-message 3 "End of message")))
7841 (gnus-article-prev-page (- lines))))))
7842 (gnus-summary-recenter)
7843 (gnus-summary-position-cursor))
7845 (defun gnus-summary-next-same-subject ()
7846 "Select next article which has the same subject as current one."
7848 (gnus-set-global-variables)
7849 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7851 (defun gnus-summary-prev-same-subject ()
7852 "Select previous article which has the same subject as current one."
7854 (gnus-set-global-variables)
7855 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7857 (defun gnus-summary-next-unread-same-subject ()
7858 "Select next unread article which has the same subject as current one."
7860 (gnus-set-global-variables)
7861 (gnus-summary-next-article t (gnus-summary-subject-string)))
7863 (defun gnus-summary-prev-unread-same-subject ()
7864 "Select previous unread article which has the same subject as current one."
7866 (gnus-set-global-variables)
7867 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7869 (defun gnus-summary-first-unread-article ()
7870 "Select the first unread article.
7871 Return nil if there are no unread articles."
7873 (gnus-set-global-variables)
7875 (if (gnus-summary-first-subject t)
7876 (gnus-summary-display-article (gnus-summary-article-number)))
7877 (gnus-summary-position-cursor)))
7879 (defun gnus-summary-best-unread-article ()
7880 "Select the unread article with the highest score."
7882 (gnus-set-global-variables)
7883 (let ((scored gnus-newsgroup-scored)
7887 (or (> best (cdr (car scored)))
7888 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7889 (not (memq art gnus-newsgroup-marked))
7890 (not (memq art gnus-newsgroup-dormant))
7891 (if (= best (cdr (car scored)))
7892 (setq article (min art article))
7894 (setq best (cdr (car scored))))))
7895 (setq scored (cdr scored)))
7897 (gnus-summary-goto-article article)
7898 (gnus-summary-first-unread-article))
7899 (gnus-summary-position-cursor)))
7901 (defun gnus-summary-goto-article (article &optional all-headers)
7902 "Fetch ARTICLE and display it if it exists.
7903 If ALL-HEADERS is non-nil, no header lines are hidden."
7909 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7910 gnus-newsgroup-headers)
7911 nil 'require-match))))
7913 (and (gnus-summary-goto-subject article)
7914 (gnus-summary-display-article article all-headers))
7915 (gnus-summary-position-cursor)))
7917 (defun gnus-summary-goto-last-article ()
7918 "Go to the previously read article."
7921 (and gnus-last-article
7922 (gnus-summary-goto-article gnus-last-article))
7923 (gnus-summary-position-cursor)))
7925 (defun gnus-summary-pop-article (number)
7926 "Pop one article off the history and go to the previous.
7927 NUMBER articles will be popped off."
7930 (setq gnus-newsgroup-history
7931 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7933 (gnus-summary-goto-article (car to))
7934 (error "Article history empty")))
7935 (gnus-summary-position-cursor))
7937 ;; Summary article oriented commands
7939 (defun gnus-summary-refer-parent-article (n)
7940 "Refer parent article N times.
7941 The difference between N and the number of articles fetched is returned."
7943 (gnus-set-global-variables)
7947 (let ((ref (header-references (gnus-get-header-by-number
7948 (gnus-summary-article-number)))))
7949 (if (and ref (not (equal ref ""))
7950 (string-match "<[^<>]*>[ \t]*$" ref))
7951 (gnus-summary-refer-article
7952 (substring ref (match-beginning 0) (match-end 0)))
7953 (gnus-message 1 "No references in article %d"
7954 (gnus-summary-article-number))
7957 (gnus-summary-position-cursor)
7960 (defun gnus-summary-refer-article (message-id)
7961 "Refer article specified by MESSAGE-ID.
7962 NOTE: This command only works with newsgroups that use real or simulated NNTP."
7963 (interactive "sMessage-ID: ")
7964 (if (or (not (stringp message-id))
7965 (zerop (length message-id)))
7967 ;; Construct the correct Message-ID if necessary.
7968 ;; Suggested by tale@pawl.rpi.edu.
7969 (or (string-match "^<" message-id)
7970 (setq message-id (concat "<" message-id)))
7971 (or (string-match ">$" message-id)
7972 (setq message-id (concat message-id ">")))
7973 (let ((header (car (gnus-gethash (downcase message-id)
7974 gnus-newsgroup-dependencies))))
7976 (or (gnus-summary-goto-article (header-number header))
7977 ;; The header has been read, but the article had been
7978 ;; expunged, so we insert it again.
7980 (gnus-summary-insert-line
7981 nil header 0 nil gnus-read-mark nil nil
7982 (header-subject header))
7984 (header-number header)))
7985 (let ((gnus-override-method gnus-refer-article-method)
7986 (gnus-ancient-mark gnus-read-mark)
7987 (tmp-buf (get-buffer-create " *gnus refer"))
7988 (tmp-point (window-start
7989 (get-buffer-window gnus-article-buffer)))
7991 (and gnus-refer-article-method
7992 (or (gnus-server-opened gnus-refer-article-method)
7993 (gnus-open-server gnus-refer-article-method)))
7994 ;; Save the old article buffer.
7996 (set-buffer tmp-buf)
7997 (buffer-disable-undo (current-buffer))
7998 (insert-buffer-substring gnus-article-buffer))
8000 (if (gnus-article-prepare
8001 message-id nil (gnus-read-header message-id))
8003 (setq number (header-number gnus-current-headers))
8004 (gnus-rebuild-thread message-id)
8005 (gnus-summary-goto-subject number)
8006 (gnus-summary-recenter)
8007 (gnus-article-set-window-start
8008 (cdr (assq number gnus-newsgroup-bookmarks)))
8010 ;; We restore the old article buffer.
8012 (set-buffer gnus-article-buffer)
8013 (let ((buffer-read-only nil))
8014 (insert-buffer-substring tmp-buf)
8016 (set-window-start (get-buffer-window (current-buffer))
8019 (kill-buffer tmp-buf)))))))
8021 (defun gnus-summary-enter-digest-group ()
8022 "Enter a digest group based on the current article."
8024 (gnus-set-global-variables)
8025 (gnus-summary-select-article)
8026 ;; We do not want a narrowed article.
8027 (gnus-summary-stop-page-breaking)
8028 (let ((name (format "%s-%d"
8029 (gnus-group-prefixed-name
8030 gnus-newsgroup-name (list 'nndoc ""))
8031 gnus-current-article))
8032 (ogroup gnus-newsgroup-name)
8033 (buf (current-buffer)))
8034 (if (gnus-group-read-ephemeral-group
8035 name (list 'nndoc name
8036 (list 'nndoc-address (get-buffer gnus-article-buffer))
8037 '(nndoc-article-type digest))
8039 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8040 (list (list (cons 'to-group ogroup))))
8041 (switch-to-buffer buf)
8042 (gnus-set-global-variables)
8043 (gnus-configure-windows 'summary)
8044 (gnus-message 3 "Article not a digest?"))))
8046 (defun gnus-summary-isearch-article ()
8047 "Do incremental search forward on current article."
8049 (gnus-set-global-variables)
8050 (gnus-summary-select-article)
8051 (gnus-eval-in-buffer-window
8052 gnus-article-buffer (isearch-forward)))
8054 (defun gnus-summary-search-article-forward (regexp &optional backward)
8055 "Search for an article containing REGEXP forward.
8056 If BACKWARD, search backward instead."
8059 (format "Search article %s (regexp%s): "
8060 (if current-prefix-arg "backward" "forward")
8061 (if gnus-last-search-regexp
8062 (concat ", default " gnus-last-search-regexp)
8064 current-prefix-arg))
8065 (gnus-set-global-variables)
8066 (if (string-equal regexp "")
8067 (setq regexp (or gnus-last-search-regexp ""))
8068 (setq gnus-last-search-regexp regexp))
8069 (if (gnus-summary-search-article regexp backward)
8070 (gnus-article-set-window-start
8071 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8072 (error "Search failed: \"%s\"" regexp)))
8074 (defun gnus-summary-search-article-backward (regexp)
8075 "Search for an article containing REGEXP backward."
8078 (format "Search article backward (regexp%s): "
8079 (if gnus-last-search-regexp
8080 (concat ", default " gnus-last-search-regexp)
8082 (gnus-summary-search-article-forward regexp 'backward))
8084 (defun gnus-summary-search-article (regexp &optional backward)
8085 "Search for an article containing REGEXP.
8086 Optional argument BACKWARD means do search for backward.
8087 gnus-select-article-hook is not called during the search."
8088 (let ((gnus-select-article-hook nil) ;Disable hook.
8089 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8092 (function re-search-backward) (function re-search-forward)))
8095 ;; Hidden thread subtrees must be searched for ,too.
8096 (gnus-summary-show-all-threads)
8097 (if (eobp) (forward-line -1))
8098 ;; First of all, search current article.
8099 ;; We don't want to read article again from NNTP server nor reset
8101 (gnus-summary-select-article)
8102 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8103 (setq last gnus-current-article)
8104 (gnus-eval-in-buffer-window gnus-article-buffer
8107 ;; Begin search from current point.
8108 (setq found (funcall re-search regexp nil t))))
8109 ;; Then search next articles.
8110 (while (and (not found)
8111 (gnus-summary-display-article
8112 (gnus-summary-search-subject backward nil nil)))
8113 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8114 (gnus-eval-in-buffer-window gnus-article-buffer
8117 (goto-char (if backward (point-max) (point-min)))
8118 (setq found (funcall re-search regexp nil t)))))
8120 ;; Adjust article pointer.
8121 (or (eq last gnus-current-article)
8122 (setq gnus-last-article last))
8123 ;; Return T if found such article.
8126 (defun gnus-summary-execute-command (header regexp command &optional backward)
8127 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8128 If HEADER is an empty string (or nil), the match is done on the entire
8129 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8131 (list (let ((completion-ignore-case t))
8134 (mapcar (lambda (string) (list string))
8135 '("Number" "Subject" "From" "Lines" "Date"
8136 "Message-ID" "Xref" "References"))
8137 nil 'require-match))
8138 (read-string "Regexp: ")
8139 (read-key-sequence "Command: ")
8140 current-prefix-arg))
8141 (gnus-set-global-variables)
8142 ;; Hidden thread subtrees must be searched as well.
8143 (gnus-summary-show-all-threads)
8144 ;; We don't want to change current point nor window configuration.
8146 (save-window-excursion
8147 (gnus-message 6 "Executing %s..." (key-description command))
8148 ;; We'd like to execute COMMAND interactively so as to give arguments.
8149 (gnus-execute header regexp
8151 (call-interactively '(, (key-binding command)))))
8153 (gnus-message 6 "Executing %s...done" (key-description command)))))
8155 (defun gnus-summary-beginning-of-article ()
8156 "Scroll the article back to the beginning."
8158 (gnus-set-global-variables)
8159 (gnus-summary-select-article)
8160 (gnus-configure-windows 'article)
8161 (gnus-eval-in-buffer-window
8164 (goto-char (point-min))
8165 (and gnus-break-pages (gnus-narrow-to-page))))
8167 (defun gnus-summary-end-of-article ()
8168 "Scroll to the end of the article."
8170 (gnus-set-global-variables)
8171 (gnus-summary-select-article)
8172 (gnus-configure-windows 'article)
8173 (gnus-eval-in-buffer-window
8176 (goto-char (point-max))
8177 (and gnus-break-pages (gnus-narrow-to-page))))
8179 (defun gnus-summary-show-article ()
8180 "Force re-fetching of the current article."
8182 (gnus-set-global-variables)
8183 (gnus-summary-select-article gnus-have-all-headers t))
8185 (defun gnus-summary-verbose-headers (arg)
8186 "Toggle permanent full header display.
8187 If ARG is a positive number, turn header display on.
8188 If ARG is a negative number, turn header display off."
8190 (gnus-set-global-variables)
8191 (gnus-summary-toggle-header arg)
8192 (setq gnus-have-all-headers
8193 (cond ((or (not (numberp arg))
8195 (not gnus-have-all-headers))
8199 (defun gnus-summary-toggle-header (arg)
8200 "Show the headers if they are hidden, or hide them if they are shown.
8201 If ARG is a positive number, show the entire header.
8202 If ARG is a negative number, hide the unwanted header lines."
8204 (gnus-set-global-variables)
8206 (set-buffer gnus-article-buffer)
8207 (let ((buffer-read-only nil))
8209 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8210 gnus-hidden-properties)
8211 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8212 (if (text-property-any (point-min) (point-max) 'invisible t)
8213 (remove-text-properties (point-min) (point-max)
8214 gnus-hidden-properties)
8215 (let ((gnus-have-all-headers nil))
8216 (run-hooks 'gnus-article-display-hook))))
8217 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8219 (defun gnus-summary-show-all-headers ()
8220 "Make all header lines visible."
8222 (gnus-set-global-variables)
8223 (gnus-article-show-all-headers))
8225 (defun gnus-summary-toggle-mime (arg)
8226 "Toggle MIME processing.
8227 If ARG is a positive number, turn MIME processing on."
8229 (gnus-set-global-variables)
8230 (setq gnus-show-mime
8231 (if (null arg) (not gnus-show-mime)
8232 (> (prefix-numeric-value arg) 0)))
8233 (gnus-summary-select-article t 'force))
8235 (defun gnus-summary-caesar-message (rotnum)
8236 "Caesar rotates all letters of current message by 13/47 places.
8237 With prefix arg, specifies the number of places to rotate each letter forward.
8238 Caesar rotates Japanese letters by 47 places in any case."
8240 (gnus-set-global-variables)
8241 (gnus-summary-select-article)
8242 (let ((mail-header-separator "")) ; !!! Is this necessary?
8243 (gnus-overload-functions)
8244 (gnus-eval-in-buffer-window
8248 ;; We don't want to jump to the beginning of the message.
8249 ;; `save-excursion' does not do its job.
8250 (move-to-window-line 0)
8251 (let ((last (point)))
8252 (news-caesar-buffer-body rotnum)
8256 (defun gnus-summary-stop-page-breaking ()
8257 "Stop page breaking in the current article."
8259 (gnus-set-global-variables)
8260 (gnus-summary-select-article)
8261 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8263 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8265 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
8266 "Move the current article to a different newsgroup.
8267 If N is a positive number, move the N next articles.
8268 If N is a negative number, move the N previous articles.
8269 If N is nil and any articles have been marked with the process mark,
8270 move those articles instead.
8271 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8272 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8273 re-spool using this method.
8274 For this function to work, both the current newsgroup and the
8275 newsgroup that you want to move to have to support the `request-move'
8276 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8278 (gnus-set-global-variables)
8279 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8280 (error "The current newsgroup does not support article moving"))
8281 (let ((articles (gnus-summary-work-articles n))
8282 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8283 art-group to-method)
8284 (if (and (not to-newsgroup) (not select-method))
8287 (format "Where do you want to move %s? %s"
8288 (if (> (length articles) 1)
8289 (format "these %d articles" (length articles))
8291 (if gnus-current-move-group
8292 (format "(%s default) " gnus-current-move-group)
8294 gnus-active-hashtb nil nil prefix)))
8297 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8298 (setq to-newsgroup (or gnus-current-move-group "")))
8299 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8300 (gnus-activate-newsgroup to-newsgroup)
8301 (error "No such group: %s" to-newsgroup))
8302 (setq gnus-current-move-group to-newsgroup)))
8303 (setq to-method (or select-method (gnus-find-method-for-group
8305 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8306 (error "%s does not support article copying" (car to-method)))
8307 (or (gnus-server-opened to-method)
8308 (gnus-open-server to-method)
8309 (error "Can't open server %s" (car to-method)))
8310 (gnus-message 6 "Moving to %s: %s..."
8311 (or select-method to-newsgroup) articles)
8314 (gnus-request-move-article
8315 (car articles) ; Article to move
8316 gnus-newsgroup-name ; From newsgrouo
8317 (nth 1 (gnus-find-method-for-group
8318 gnus-newsgroup-name)) ; Server
8319 (list 'gnus-request-accept-article
8321 (list 'quote select-method)
8323 (not (cdr articles))) ; Accept form
8324 (not (cdr articles)))) ; Only save nov last time
8325 (let* ((buffer-read-only nil)
8328 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8330 (gnus-group-prefixed-name
8332 (if select-method (list select-method "")
8333 (gnus-find-method-for-group to-newsgroup)))
8334 gnus-newsrc-hashtb)))
8335 (info (nth 2 entry))
8336 (article (car articles)))
8337 (gnus-summary-goto-subject article)
8339 (delete-region (point)
8340 (progn (forward-line 1) (point)))
8341 (if (not (memq article gnus-newsgroup-unreads))
8342 (setcar (cdr (cdr info))
8343 (gnus-add-to-range (nth 2 info)
8344 (list (cdr art-group)))))
8345 ;; Copy any marks over to the new group.
8346 (let ((marks '((tick . gnus-newsgroup-marked)
8347 (dormant . gnus-newsgroup-dormant)
8348 (expire . gnus-newsgroup-expirable)
8349 (bookmark . gnus-newsgroup-bookmarks)
8350 ; (score . gnus-newsgroup-scored)
8351 (reply . gnus-newsgroup-replied)))
8352 (to-article (cdr art-group)))
8354 (if (memq article (symbol-value (cdr (car marks))))
8355 (gnus-add-marked-articles
8356 (car info) (car (car marks)) (list to-article) info))
8357 (setq marks (cdr marks))))
8358 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8359 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8360 (setq gnus-newsgroup-dormant
8361 (delq article gnus-newsgroup-dormant)))
8362 (gnus-message 1 "Couldn't move article %s" (car articles)))
8363 (gnus-summary-remove-process-mark (car articles))
8364 (setq articles (cdr articles)))))
8366 (defun gnus-summary-respool-article (n &optional respool-method)
8367 "Respool the current article.
8368 The article will be squeezed through the mail spooling process again,
8369 which means that it will be put in some mail newsgroup or other
8370 depending on `nnmail-split-methods'.
8371 If N is a positive number, respool the N next articles.
8372 If N is a negative number, respool the N previous articles.
8373 If N is nil and any articles have been marked with the process mark,
8374 respool those articles instead.
8376 Respooling can be done both from mail groups and \"real\" newsgroups.
8377 In the former case, the articles in question will be moved from the
8378 current group into whatever groups they are destined to. In the
8379 latter case, they will be copied into the relevant groups."
8381 (gnus-set-global-variables)
8382 (let ((respool-methods (gnus-methods-using 'respool))
8384 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8386 (setq respool-method
8388 "What method do you want to use when respooling? "
8389 respool-methods nil t methname)))
8390 (or (string= respool-method "")
8391 (if (assoc (symbol-name
8392 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8394 (gnus-summary-move-article n nil (intern respool-method))
8395 (gnus-summary-copy-article n nil (intern respool-method))))))
8397 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8398 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
8399 "Move the current article to a different newsgroup.
8400 If N is a positive number, move the N next articles.
8401 If N is a negative number, move the N previous articles.
8402 If N is nil and any articles have been marked with the process mark,
8403 move those articles instead.
8404 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8405 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8406 re-spool using this method.
8407 For this function to work, the newsgroup that you want to move to have
8408 to support the `request-move' and `request-accept'
8409 functions. (Ie. mail newsgroups at present.)"
8411 (gnus-set-global-variables)
8412 (let ((articles (gnus-summary-work-articles n))
8413 (copy-buf (get-buffer-create "*copy work*"))
8414 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8415 art-group to-method)
8416 (buffer-disable-undo copy-buf)
8417 (if (and (not to-newsgroup) (not select-method))
8420 (format "Where do you want to copy %s? %s"
8421 (if (> (length articles) 1)
8422 (format "these %d articles" (length articles))
8424 (if gnus-current-move-group
8425 (format "(%s default) " gnus-current-move-group)
8427 gnus-active-hashtb nil nil prefix)))
8430 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8431 (setq to-newsgroup (or gnus-current-move-group "")))
8432 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8433 (gnus-activate-newsgroup to-newsgroup)
8434 (error "No such group: %s" to-newsgroup))
8435 (setq gnus-current-move-group to-newsgroup)))
8436 (setq to-method (or select-method (gnus-find-method-for-group
8438 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8439 (error "%s does not support article copying" (car to-method)))
8440 (or (gnus-server-opened to-method)
8441 (gnus-open-server to-method)
8442 (error "Can't open server %s" (car to-method)))
8443 (gnus-message 6 "Copying to %s: %s..."
8444 (or select-method to-newsgroup) articles)
8448 (set-buffer copy-buf)
8449 (gnus-request-article-this-buffer
8450 (car articles) gnus-newsgroup-name)
8451 (gnus-request-accept-article
8452 (if select-method (quote select-method) to-newsgroup)
8453 (not (cdr articles)))))
8456 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8458 (gnus-group-prefixed-name
8460 (if select-method (list select-method "")
8461 (gnus-find-method-for-group to-newsgroup)))
8462 gnus-newsrc-hashtb)))
8463 (info (nth 2 entry))
8464 (article (car articles)))
8465 (if (not (memq article gnus-newsgroup-unreads))
8466 (setcar (cdr (cdr info))
8467 (gnus-add-to-range (nth 2 info)
8468 (list (cdr art-group)))))
8469 ;; Copy any marks over to the new group.
8470 (let ((marks '((tick . gnus-newsgroup-marked)
8471 (dormant . gnus-newsgroup-dormant)
8472 (expire . gnus-newsgroup-expirable)
8473 (bookmark . gnus-newsgroup-bookmarks)
8474 ; (score . gnus-newsgroup-scored)
8475 (reply . gnus-newsgroup-replied)))
8476 (to-article (cdr art-group)))
8478 (if (memq article (symbol-value (cdr (car marks))))
8479 (gnus-add-marked-articles
8480 (car info) (car (car marks)) (list to-article) info))
8481 (setq marks (cdr marks)))))
8482 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8483 (gnus-summary-remove-process-mark (car articles))
8484 (setq articles (cdr articles)))
8485 (kill-buffer copy-buf)))
8487 (defun gnus-summary-import-article (file)
8488 "Import a random file into a mail newsgroup."
8489 (interactive "fImport file: ")
8490 (let ((group gnus-newsgroup-name)
8492 (or (gnus-check-backend-function 'request-accept-article group)
8493 (error "%s does not support article importing" group))
8494 (or (file-readable-p file)
8495 (not (file-regular-p file))
8496 (error "Can't read %s" file))
8498 (set-buffer (get-buffer-create " *import file*"))
8499 (buffer-disable-undo (current-buffer))
8501 (insert-file-contents file)
8502 (goto-char (point-min))
8503 (if (nnheader-article-p)
8505 (setq atts (file-attributes file))
8506 (insert "From: " (read-string "From: ") "\n"
8507 "Subject: " (read-string "Subject: ") "\n"
8508 "Date: " (current-time-string (nth 5 atts)) "\n"
8509 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8510 (gnus-request-accept-article group t)
8511 (kill-buffer (current-buffer)))))
8513 (defun gnus-summary-expire-articles ()
8514 "Expire all articles that are marked as expirable in the current group."
8516 (if (and gnus-newsgroup-expirable
8517 (gnus-check-backend-function
8518 'request-expire-articles gnus-newsgroup-name))
8519 (let ((expirable gnus-newsgroup-expirable))
8520 ;; The list of articles that weren't expired is returned.
8521 (setq gnus-newsgroup-expirable
8522 (gnus-request-expire-articles gnus-newsgroup-expirable
8523 gnus-newsgroup-name))
8524 ;; We go through the old list of expirable, and mark all
8525 ;; really expired articles as non-existent.
8527 (or (memq (car expirable) gnus-newsgroup-expirable)
8528 (gnus-summary-mark-as-read (car expirable) gnus-canceled-mark))
8529 (setq expirable (cdr expirable))))))
8531 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8532 (defun gnus-summary-delete-article (n)
8533 "Delete the N next (mail) articles.
8534 This command actually deletes articles. This is not a marking
8535 command. The article will disappear forever from you life, never to
8537 If N is negative, delete backwards.
8538 If N is nil and articles have been marked with the process mark,
8539 delete these instead."
8541 (or (gnus-check-backend-function 'request-expire-articles
8542 gnus-newsgroup-name)
8543 (error "The current newsgroup does not support article deletion."))
8544 ;; Compute the list of articles to delete.
8545 (let ((articles (gnus-summary-work-articles n))
8547 (if (and gnus-novice-user
8549 (format "Do you really want to delete %s forever? "
8550 (if (> (length articles) 1) "these articles"
8553 ;; Delete the articles.
8554 (setq not-deleted (gnus-request-expire-articles
8555 articles gnus-newsgroup-name 'force))
8557 (gnus-summary-remove-process-mark (car articles))
8558 ;; The backend might not have been able to delete the article
8560 (or (memq (car articles) not-deleted)
8561 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
8562 (setq articles (cdr articles))))
8563 (gnus-summary-position-cursor)
8566 (defun gnus-summary-edit-article ()
8567 "Enter into a buffer and edit the current article.
8568 This will have permanent effect only in mail groups."
8570 (or (gnus-check-backend-function
8571 'request-replace-article gnus-newsgroup-name)
8572 (error "The current newsgroup does not support article editing."))
8573 (gnus-summary-select-article t)
8575 (gnus-message 6 "C-c C-c to end edits")
8576 (setq buffer-read-only nil)
8578 (use-local-map (copy-keymap (current-local-map)))
8579 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8580 (buffer-enable-undo)
8581 (goto-char (point-min))
8582 (search-forward "\n\n" nil t))
8584 (defun gnus-summary-edit-article-done ()
8585 "Make edits to the current article permanent."
8587 (if (not (gnus-request-replace-article
8588 (cdr gnus-article-current) (car gnus-article-current)
8590 (error "Couldn't replace article.")
8592 (use-local-map gnus-article-mode-map)
8593 (setq buffer-read-only t)
8594 (buffer-disable-undo (current-buffer))
8595 (pop-to-buffer gnus-summary-buffer)))
8597 (defun gnus-summary-fancy-query ()
8598 "Query where the fancy respool algorithm would put this article."
8600 (gnus-summary-select-article)
8602 (set-buffer gnus-article-buffer)
8604 (goto-char (point-min))
8605 (search-forward "\n\n")
8606 (narrow-to-region (point-min) (point))
8607 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8609 ;; Summary score commands.
8611 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8613 (defun gnus-summary-raise-score (n)
8614 "Raise the score of the current article by N."
8616 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8618 (defun gnus-summary-lower-score (n)
8619 "Lower the score of the current article by N."
8621 (gnus-summary-raise-score (- n)))
8623 (defun gnus-summary-set-score (n)
8624 "Set the score of the current article to N."
8626 ;; Skip dummy header line.
8628 (gnus-summary-show-thread)
8629 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8631 (let ((buffer-read-only nil))
8633 (gnus-summary-update-mark
8634 (if (= n (or gnus-summary-default-score 0)) ?
8635 (if (< n (or gnus-summary-default-score 0))
8636 gnus-score-below-mark gnus-score-over-mark)) 'score))
8637 (let* ((article (gnus-summary-article-number))
8638 (score (assq article gnus-newsgroup-scored)))
8639 (if score (setcdr score n)
8640 (setq gnus-newsgroup-scored
8641 (cons (cons article n) gnus-newsgroup-scored))))
8642 (gnus-summary-update-line)))
8644 (defun gnus-summary-current-score ()
8645 "Return the score of the current article."
8647 (message "%s" (gnus-summary-article-score)))
8649 ;; Summary marking commands.
8651 (defun gnus-summary-raise-same-subject-and-select (score)
8652 "Raise articles which has the same subject with SCORE and select the next."
8654 (let ((subject (gnus-summary-subject-string)))
8655 (gnus-summary-raise-score score)
8656 (while (gnus-summary-search-subject nil nil subject)
8657 (gnus-summary-raise-score score))
8658 (gnus-summary-next-article t)))
8660 (defun gnus-summary-raise-same-subject (score)
8661 "Raise articles which has the same subject with SCORE."
8663 (let ((subject (gnus-summary-subject-string)))
8664 (gnus-summary-raise-score score)
8665 (while (gnus-summary-search-subject nil nil subject)
8666 (gnus-summary-raise-score score))
8667 (gnus-summary-next-subject 1 t)))
8669 (defun gnus-score-default (level)
8670 (if level (prefix-numeric-value level)
8671 gnus-score-interactive-default-score))
8673 (defun gnus-summary-raise-thread (score)
8674 "Raise the score of the articles in the current thread with SCORE."
8676 (setq score (1- (gnus-score-default score)))
8679 (let ((level (gnus-summary-thread-level)))
8680 (gnus-summary-raise-score score)
8681 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8682 (> (gnus-summary-thread-level) level))
8683 (gnus-summary-raise-score score))
8685 (let ((gnus-summary-check-current t))
8686 (or (zerop (gnus-summary-next-subject 1 t))
8688 (gnus-summary-recenter)
8689 (gnus-summary-position-cursor)
8690 (gnus-set-mode-line 'summary))
8692 (defun gnus-summary-lower-same-subject-and-select (score)
8693 "Raise articles which has the same subject with SCORE and select the next."
8695 (gnus-summary-raise-same-subject-and-select (- score)))
8697 (defun gnus-summary-lower-same-subject (score)
8698 "Raise articles which has the same subject with SCORE."
8700 (gnus-summary-raise-same-subject (- score)))
8702 (defun gnus-summary-lower-thread (score)
8703 "Lower score of articles in the current thread with SCORE."
8705 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8707 (defun gnus-summary-kill-same-subject-and-select (unmark)
8708 "Mark articles which has the same subject as read, and then select the next.
8709 If UNMARK is positive, remove any kind of mark.
8710 If UNMARK is negative, tick articles."
8713 (setq unmark (prefix-numeric-value unmark)))
8715 (gnus-summary-mark-same-subject
8716 (gnus-summary-subject-string) unmark)))
8717 ;; Select next unread article. If auto-select-same mode, should
8718 ;; select the first unread article.
8719 (gnus-summary-next-article t (and gnus-auto-select-same
8720 (gnus-summary-subject-string)))
8721 (gnus-message 7 "%d articles are marked as %s"
8722 count (if unmark "unread" "read"))))
8724 (defun gnus-summary-kill-same-subject (unmark)
8725 "Mark articles which has the same subject as read.
8726 If UNMARK is positive, remove any kind of mark.
8727 If UNMARK is negative, tick articles."
8730 (setq unmark (prefix-numeric-value unmark)))
8732 (gnus-summary-mark-same-subject
8733 (gnus-summary-subject-string) unmark)))
8734 ;; If marked as read, go to next unread subject.
8736 ;; Go to next unread subject.
8737 (gnus-summary-next-subject 1 t))
8738 (gnus-message 7 "%d articles are marked as %s"
8739 count (if unmark "unread" "read"))))
8741 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8742 "Mark articles with same SUBJECT as read, and return marked number.
8743 If optional argument UNMARK is positive, remove any kinds of marks.
8744 If optional argument UNMARK is negative, mark articles as unread instead."
8747 (cond ((null unmark)
8748 (gnus-summary-mark-as-read nil gnus-killed-mark))
8750 (gnus-summary-tick-article nil t))
8752 (gnus-summary-tick-article)))
8754 (gnus-summary-search-forward nil subject))
8755 (cond ((null unmark)
8756 (gnus-summary-mark-as-read nil gnus-killed-mark))
8758 (gnus-summary-tick-article nil t))
8760 (gnus-summary-tick-article)))
8761 (setq count (1+ count))))
8762 ;; Hide killed thread subtrees. Does not work properly always.
8763 ;;(and (null unmark)
8764 ;; gnus-thread-hide-killed
8765 ;; (gnus-summary-hide-thread))
8766 ;; Return number of articles marked as read.
8769 (defun gnus-summary-mark-as-processable (n &optional unmark)
8770 "Set the process mark on the next N articles.
8771 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8772 the process mark instead. The difference between N and the actual
8773 number of articles marked is returned."
8775 (let ((backward (< n 0))
8780 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8781 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8782 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8784 (if (/= 0 n) (gnus-message 7 "No more articles"))
8785 (gnus-summary-recenter)
8786 (gnus-summary-position-cursor)
8789 (defun gnus-summary-unmark-as-processable (n)
8790 "Remove the process mark from the next N articles.
8791 If N is negative, mark backward instead. The difference between N and
8792 the actual number of articles marked is returned."
8794 (gnus-summary-mark-as-processable n t))
8796 (defun gnus-summary-unmark-all-processable ()
8797 "Remove the process mark from all articles."
8800 (while gnus-newsgroup-processable
8801 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8802 (gnus-summary-position-cursor))
8804 (defun gnus-summary-mark-as-expirable (n)
8805 "Mark N articles forward as expirable.
8806 If N is negative, mark backward instead. The difference between N and
8807 the actual number of articles marked is returned."
8809 (gnus-summary-mark-forward n gnus-expirable-mark))
8811 (defun gnus-summary-mark-article-as-replied (article)
8812 "Mark ARTICLE replied and update the summary line."
8813 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8814 (let ((buffer-read-only nil))
8815 (if (gnus-summary-goto-subject article)
8817 (gnus-summary-update-mark gnus-replied-mark 'replied)
8820 (defun gnus-summary-set-bookmark (article)
8821 "Set a bookmark in current article."
8822 (interactive (list (gnus-summary-article-number)))
8823 (if (or (not (get-buffer gnus-article-buffer))
8824 (not gnus-current-article)
8825 (not gnus-article-current)
8826 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8827 (error "No current article selected"))
8828 ;; Remove old bookmark, if one exists.
8829 (let ((old (assq article gnus-newsgroup-bookmarks)))
8830 (if old (setq gnus-newsgroup-bookmarks
8831 (delq old gnus-newsgroup-bookmarks))))
8832 ;; Set the new bookmark, which is on the form
8833 ;; (article-number . line-number-in-body).
8834 (setq gnus-newsgroup-bookmarks
8838 (set-buffer gnus-article-buffer)
8842 (goto-char (point-min))
8843 (search-forward "\n\n" nil t)
8846 gnus-newsgroup-bookmarks))
8847 (gnus-message 6 "A bookmark has been added to the current article."))
8849 (defun gnus-summary-remove-bookmark (article)
8850 "Remove the bookmark from the current article."
8851 (interactive (list (gnus-summary-article-number)))
8852 ;; Remove old bookmark, if one exists.
8853 (let ((old (assq article gnus-newsgroup-bookmarks)))
8856 (setq gnus-newsgroup-bookmarks
8857 (delq old gnus-newsgroup-bookmarks))
8858 (gnus-message 6 "Removed bookmark."))
8859 (gnus-message 6 "No bookmark in current article."))))
8861 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8862 (defun gnus-summary-mark-as-dormant (n)
8863 "Mark N articles forward as dormant.
8864 If N is negative, mark backward instead. The difference between N and
8865 the actual number of articles marked is returned."
8867 (gnus-summary-mark-forward n gnus-dormant-mark))
8869 (defun gnus-summary-set-process-mark (article)
8870 "Set the process mark on ARTICLE and update the summary line."
8871 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8872 (let ((buffer-read-only nil))
8873 (if (gnus-summary-goto-subject article)
8875 (gnus-summary-show-thread)
8876 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8878 (gnus-summary-update-mark gnus-process-mark 'replied)
8881 (defun gnus-summary-remove-process-mark (article)
8882 "Remove the process mark from ARTICLE and update the summary line."
8883 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8884 (let ((buffer-read-only nil))
8885 (if (gnus-summary-goto-subject article)
8887 (gnus-summary-show-thread)
8888 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8890 (gnus-summary-update-mark ? 'replied)
8891 (if (memq article gnus-newsgroup-replied)
8892 (gnus-summary-update-mark gnus-replied-mark 'replied))
8895 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8896 "Mark N articles as read forwards.
8897 If N is negative, mark backwards instead.
8898 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8900 The difference between N and the actual number of articles marked is
8903 (gnus-set-global-variables)
8904 (let ((backward (< n 0))
8906 (mark (or mark gnus-del-mark)))
8908 (gnus-summary-mark-article nil mark no-expire)
8909 (zerop (gnus-summary-next-subject
8910 (if backward -1 1) gnus-summary-goto-unread t)))
8912 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8913 (gnus-summary-recenter)
8914 (gnus-summary-position-cursor)
8915 (gnus-set-mode-line 'summary)
8918 (defun gnus-summary-mark-article (&optional article mark no-expire)
8919 "Mark ARTICLE with MARK.
8920 MARK can be any character.
8921 Five MARK strings are reserved: ? (unread),
8922 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8923 If MARK is nil, then the default character ?D is used.
8924 If ARTICLE is nil, then the article on the current line will be
8926 ;; If no mark is given, then we check auto-expiring.
8927 (and (not no-expire)
8928 gnus-newsgroup-auto-expire
8931 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
8932 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
8933 (= mark gnus-read-mark))))
8934 (setq mark gnus-expirable-mark))
8935 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8936 (article (or article (gnus-summary-article-number))))
8937 (or article (error "No article on current line"))
8938 (if (or (= mark gnus-unread-mark)
8939 (= mark gnus-ticked-mark)
8940 (= mark gnus-dormant-mark))
8941 (gnus-mark-article-as-unread article mark)
8942 (gnus-mark-article-as-read article mark))
8944 ;; See whether the article is to be put in the cache.
8947 (gnus-cache-possibly-enter-article
8948 gnus-newsgroup-name article
8949 (gnus-get-header-by-number article)
8950 (= mark gnus-ticked-mark)
8951 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8953 (if (gnus-summary-goto-subject article)
8954 (let ((buffer-read-only nil))
8955 (gnus-summary-show-thread)
8956 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8959 (gnus-summary-update-mark mark 'unread)
8962 (defun gnus-summary-update-mark (mark type)
8964 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8968 (forward-char forward)
8969 (setq plist (text-properties-at (point)))
8972 (and plist (add-text-properties (1- (point)) (point) plist))
8973 (and (eq type 'unread)
8974 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
8975 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8977 (defun gnus-mark-article-as-read (article &optional mark)
8978 "Enter ARTICLE in the pertinent lists and remove it from others."
8979 ;; Make the article expirable.
8980 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
8981 (if (= mark gnus-expirable-mark)
8982 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8983 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8984 ;; Remove from unread and marked lists.
8985 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8986 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8987 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8988 ;; Possibly remove from cache, if that is used.
8989 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
8991 (defun gnus-mark-article-as-unread (article &optional mark)
8992 "Enter ARTICLE in the pertinent lists and remove it from others."
8993 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8994 ;; Add to unread list.
8995 (or (memq article gnus-newsgroup-unreads)
8996 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
8997 ;; If CLEAR-MARK is non-nil, the article must be removed from mark
8998 ;; lists. Otherwise, it must be added to the list.
8999 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9000 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9001 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9002 (if (= mark gnus-ticked-mark)
9003 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9004 (if (= mark gnus-dormant-mark)
9005 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9007 (defalias 'gnus-summary-mark-as-unread-forward
9008 'gnus-summary-tick-article-forward)
9009 (make-obsolete 'gnus-summary-mark-as-unread-forward
9010 'gnus-summary-tick-article-forward)
9011 (defun gnus-summary-tick-article-forward (n)
9012 "Tick N articles forwards.
9013 If N is negative, tick backwards instead.
9014 The difference between N and the number of articles ticked is returned."
9016 (gnus-summary-mark-forward n gnus-ticked-mark))
9018 (defalias 'gnus-summary-mark-as-unread-backward
9019 'gnus-summary-tick-article-backward)
9020 (make-obsolete 'gnus-summary-mark-as-unread-backward
9021 'gnus-summary-tick-article-backward)
9022 (defun gnus-summary-tick-article-backward (n)
9023 "Tick N articles backwards.
9024 The difference between N and the number of articles ticked is returned."
9026 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9028 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9029 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9030 (defun gnus-summary-tick-article (&optional article clear-mark)
9031 "Mark current article as unread.
9032 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9033 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9034 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9037 (defun gnus-summary-mark-as-read-forward (n)
9038 "Mark N articles as read forwards.
9039 If N is negative, mark backwards instead.
9040 The difference between N and the actual number of articles marked is
9043 (gnus-summary-mark-forward n gnus-del-mark t))
9045 (defun gnus-summary-mark-as-read-backward (n)
9046 "Mark the N articles as read backwards.
9047 The difference between N and the actual number of articles marked is
9050 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9052 (defun gnus-summary-mark-as-read (&optional article mark)
9053 "Mark current article as read.
9054 ARTICLE specifies the article to be marked as read.
9055 MARK specifies a string to be inserted at the beginning of the line."
9056 (gnus-summary-mark-article article mark))
9058 (defun gnus-summary-clear-mark-forward (n)
9059 "Clear marks from N articles forward.
9060 If N is negative, clear backward instead.
9061 The difference between N and the number of marks cleared is returned."
9063 (gnus-summary-mark-forward n gnus-unread-mark))
9065 (defun gnus-summary-clear-mark-backward (n)
9066 "Clear marks from N articles backward.
9067 The difference between N and the number of marks cleared is returned."
9069 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9071 (defun gnus-summary-mark-unread-as-read ()
9072 "Intended to be used by `gnus-summary-mark-article-hook'."
9073 (or (memq gnus-current-article gnus-newsgroup-marked)
9074 (memq gnus-current-article gnus-newsgroup-dormant)
9075 (memq gnus-current-article gnus-newsgroup-expirable)
9076 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
9078 (defun gnus-summary-mark-region-as-read (point mark all)
9079 "Mark all unread articles between point and mark as read.
9080 If given a prefix, mark all articles between point and mark as read,
9081 even ticked and dormant ones."
9082 (interactive "r\nP")
9092 (not (memq (gnus-summary-article-number)
9093 gnus-newsgroup-marked))
9094 (not (memq (gnus-summary-article-number)
9095 gnus-newsgroup-dormant))))
9096 (gnus-summary-mark-article
9097 (gnus-summary-article-number) gnus-del-mark))
9099 (zerop (forward-line 1))))))
9101 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9102 (defalias 'gnus-summary-delete-marked-as-read
9103 'gnus-summary-remove-lines-marked-as-read)
9104 (make-obsolete 'gnus-summary-delete-marked-as-read
9105 'gnus-summary-remove-lines-marked-as-read)
9106 (defun gnus-summary-remove-lines-marked-as-read ()
9107 "Remove lines that are marked as read."
9109 (gnus-summary-remove-lines-marked-with
9111 (lambda (char) (char-to-string (symbol-value char)))
9112 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9113 gnus-killed-mark gnus-kill-file-mark
9114 gnus-low-score-mark gnus-expirable-mark
9118 (defalias 'gnus-summary-delete-marked-with
9119 'gnus-summary-remove-lines-marked-with)
9120 (make-obsolete 'gnus-summary-delete-marked-with
9121 'gnus-summary-remove-lines-marked-with)
9122 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9123 (defun gnus-summary-remove-lines-marked-with (marks)
9124 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9125 (interactive "sMarks: ")
9126 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9127 (gnus-set-global-variables)
9128 (let ((buffer-read-only nil)
9129 (marks (concat "^[" marks "]")))
9130 (goto-char (point-min))
9131 (if gnus-newsgroup-adaptive
9132 (gnus-score-remove-lines-adaptive marks)
9133 (while (re-search-forward marks nil t)
9134 (gnus-delete-line)))
9135 ;; If we use dummy roots, we have to do an additional sweep over
9137 (if (not (eq gnus-summary-make-false-root 'dummy))
9139 (goto-char (point-min))
9140 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9141 (while (re-search-forward marks nil t)
9142 (if (gnus-subject-equal
9143 (gnus-summary-subject-string)
9146 (gnus-summary-subject-string)))
9149 (gnus-delete-line)))))
9150 (or (zerop (buffer-size))
9152 (gnus-summary-prev-subject 1)
9153 (gnus-summary-position-cursor))))
9155 (defun gnus-summary-expunge-below (score)
9156 "Remove articles with score less than SCORE."
9158 (gnus-set-global-variables)
9159 (setq score (if score
9160 (prefix-numeric-value score)
9161 (or gnus-summary-default-score 0)))
9163 (set-buffer gnus-summary-buffer)
9164 (goto-char (point-min))
9165 (let ((buffer-read-only nil)
9168 (if (< (gnus-summary-article-score) score)
9172 (delete-region beg (point)))
9175 (or (zerop (buffer-size))
9177 (gnus-summary-prev-subject 1)
9178 (gnus-summary-position-cursor))))))
9180 (defun gnus-summary-mark-below (score mark)
9181 "Mark articles with score less than SCORE with MARK."
9182 (interactive "P\ncMark: ")
9183 (gnus-set-global-variables)
9184 (setq score (if score
9185 (prefix-numeric-value score)
9186 (or gnus-summary-default-score 0)))
9188 (set-buffer gnus-summary-buffer)
9189 (goto-char (point-min))
9191 (and (< (gnus-summary-article-score) score)
9192 (gnus-summary-mark-article nil mark))
9195 (defun gnus-summary-kill-below (score)
9196 "Mark articles with score below SCORE as read."
9198 (gnus-summary-mark-below score gnus-killed-mark))
9200 (defun gnus-summary-clear-above (score)
9201 "Clear all marks from articles with score above SCORE."
9203 (gnus-summary-mark-above score gnus-unread-mark))
9205 (defun gnus-summary-tick-above (score)
9206 "Tick all articles with score above SCORE."
9208 (gnus-summary-mark-above score gnus-ticked-mark))
9210 (defun gnus-summary-mark-above (score mark)
9211 "Mark articles with score over SCORE with MARK."
9212 (interactive "P\ncMark: ")
9213 (setq score (if score
9214 (prefix-numeric-value score)
9215 (or gnus-summary-default-score 0)))
9217 (set-buffer gnus-summary-buffer)
9218 (goto-char (point-min))
9220 (if (> (gnus-summary-article-score) score)
9222 (gnus-summary-mark-article nil mark)
9224 (forward-line 1)))))
9226 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9227 (defun gnus-summary-show-all-expunged ()
9228 "Display all the hidden articles that were expunged for low scores."
9230 (let ((buffer-read-only nil))
9231 (let ((scored gnus-newsgroup-scored)
9234 (or (gnus-summary-goto-subject (car (car scored)))
9235 (and (setq h (gnus-get-header-by-number (car (car scored))))
9236 (< (cdr (car scored)) gnus-summary-expunge-below)
9237 (setq headers (cons h headers))))
9238 (setq scored (cdr scored)))
9239 (or headers (error "No expunged articles hidden."))
9240 (goto-char (point-min))
9242 (gnus-summary-update-lines
9245 (gnus-summary-prepare-threads (nreverse headers) 0)
9247 (goto-char (point-min))
9248 (gnus-summary-position-cursor)))
9250 (defun gnus-summary-show-all-dormant ()
9251 "Display all the hidden articles that are marked as dormant."
9253 (let ((buffer-read-only nil))
9254 (goto-char (point-min))
9255 (let ((dormant gnus-newsgroup-dormant)
9258 (or (gnus-summary-goto-subject (car dormant))
9259 (and (setq h (gnus-get-header-by-number (car dormant)))
9260 (setq headers (cons h headers))))
9261 (setq dormant (cdr dormant)))
9262 (or headers (error "No dormant articles hidden."))
9264 (gnus-summary-update-lines
9267 (gnus-summary-prepare-threads (nreverse headers) 0)
9269 (goto-char (point-min))
9270 (gnus-summary-position-cursor)))
9272 (defun gnus-summary-hide-all-dormant ()
9273 "Hide all dormant articles."
9275 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9276 (gnus-summary-position-cursor))
9278 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
9279 "Mark all articles not marked as unread in this newsgroup as read.
9280 If prefix argument ALL is non-nil, all articles are marked as read.
9281 If QUIETLY is non-nil, no questions will be asked.
9282 If TO-HERE is non-nil, it should be a point in the buffer. All
9283 articles before this point will be marked as read.
9284 The number of articles marked as read is returned."
9288 (not gnus-interactive-catchup) ;Without confirmation?
9292 "Mark absolutely all articles as read? "
9293 "Mark all unread articles as read? ")))
9295 (not gnus-newsgroup-adaptive)
9296 (not gnus-newsgroup-auto-expire))
9298 (and all (setq gnus-newsgroup-marked nil
9299 gnus-newsgroup-dormant nil))
9300 (setq gnus-newsgroup-unreads
9301 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9302 ;; We actually mark all articles as canceled, which we
9303 ;; have to do when using auto-expiry or adaptive scoring.
9304 (let ((unreads (length gnus-newsgroup-unreads)))
9305 (if (gnus-summary-first-subject (not all))
9306 (while (and (if to-here (< (point) to-here) t)
9307 (gnus-summary-mark-as-read nil gnus-catchup-mark)
9308 (gnus-summary-search-subject nil (not all)))))
9309 (- unreads (length gnus-newsgroup-unreads))
9311 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9312 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9313 (if (and (not to-here) (eq 'nnvirtual (car method)))
9314 (nnvirtual-catchup-group
9315 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9316 (gnus-summary-position-cursor)))
9318 (defun gnus-summary-catchup-to-here (&optional all)
9319 "Mark all unticked articles before the current one as read.
9320 If ALL is non-nil, also mark ticked and dormant articles as read."
9324 (gnus-summary-catchup all t (point))
9325 (gnus-set-mode-line 'summary))
9326 (gnus-summary-position-cursor))
9328 (defun gnus-summary-catchup-all (&optional quietly)
9329 "Mark all articles in this newsgroup as read."
9331 (gnus-summary-catchup t quietly))
9333 (defun gnus-summary-catchup-and-exit (all &optional quietly)
9334 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9335 If prefix argument ALL is non-nil, all articles are marked as read."
9337 (gnus-summary-catchup all quietly nil 'fast)
9338 ;; Select next newsgroup or exit.
9339 (if (eq gnus-auto-select-next 'quietly)
9340 (gnus-summary-next-group nil)
9341 (gnus-summary-exit)))
9343 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9344 "Mark all articles in this newsgroup as read, and then exit."
9346 (gnus-summary-catchup-and-exit t quietly))
9348 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9349 (defun gnus-summary-catchup-and-goto-next-group (all)
9350 "Mark all articles in this group as read and select the next group.
9351 If given a prefix, mark all articles, unread as well as ticked, as
9354 (gnus-summary-catchup all)
9355 (gnus-summary-next-group))
9357 ;; Thread-based commands.
9359 (defun gnus-summary-toggle-threads (arg)
9360 "Toggle showing conversation threads.
9361 If ARG is positive number, turn showing conversation threads on."
9363 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9364 (setq gnus-show-threads
9365 (if (null arg) (not gnus-show-threads)
9366 (> (prefix-numeric-value arg) 0)))
9367 (gnus-summary-prepare)
9368 (gnus-summary-goto-subject current)
9369 (gnus-summary-position-cursor)))
9371 (defun gnus-summary-show-all-threads ()
9375 (let ((buffer-read-only nil))
9376 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9377 (gnus-summary-position-cursor))
9379 (defun gnus-summary-show-thread ()
9380 "Show thread subtrees.
9381 Returns nil if no thread was there to be shown."
9385 (let ((buffer-read-only nil)
9386 ;; first goto end then to beg, to have point at beg after let
9387 (end (progn (end-of-line) (point)))
9388 (beg (progn (beginning-of-line) (point))))
9390 ;; Any hidden lines here?
9391 (search-forward "\r" end t)
9392 (subst-char-in-region beg end ?\^M ?\n t))))
9393 (gnus-summary-position-cursor)))
9395 (defun gnus-summary-hide-all-threads ()
9396 "Hide all thread subtrees."
9399 (goto-char (point-min))
9400 (gnus-summary-hide-thread)
9401 (while (and (not (eobp)) (zerop (forward-line 1)))
9402 (gnus-summary-hide-thread)))
9403 (gnus-summary-position-cursor))
9405 (defun gnus-summary-hide-thread ()
9406 "Hide thread subtrees.
9407 Returns nil if no threads were there to be hidden."
9409 (let ((buffer-read-only nil)
9411 (level (gnus-summary-thread-level))
9413 ;; Go forward until either the buffer ends or the subthread
9417 (while (and (zerop (forward-line 1))
9418 (> (gnus-summary-thread-level) level))
9423 (search-backward "\n" start t))
9424 (subst-char-in-region start end ?\n ?\^M t)
9425 (forward-line -1)))))
9427 (defun gnus-summary-go-to-next-thread (&optional previous)
9428 "Go to the same level (or less) next thread.
9429 If PREVIOUS is non-nil, go to previous thread instead.
9430 Return the article number moved to, or nil if moving was impossible."
9431 (let ((level (gnus-summary-thread-level))
9432 (article (gnus-summary-article-number)))
9434 (while (and (zerop (forward-line -1))
9435 (> (gnus-summary-thread-level) level)))
9436 (while (and (save-excursion
9439 (zerop (forward-line 1))
9440 (> (gnus-summary-thread-level) level))))
9441 (gnus-summary-recenter)
9442 (gnus-summary-position-cursor)
9443 (let ((oart (gnus-summary-article-number)))
9444 (and (/= oart article) oart))))
9446 (defun gnus-summary-next-thread (n)
9447 "Go to the same level next N'th thread.
9448 If N is negative, search backward instead.
9449 Returns the difference between N and the number of skips actually
9452 (let ((backward (< n 0))
9455 (gnus-summary-go-to-next-thread backward))
9457 (gnus-summary-position-cursor)
9458 (if (/= 0 n) (gnus-message 7 "No more threads"))
9461 (defun gnus-summary-prev-thread (n)
9462 "Go to the same level previous N'th thread.
9463 Returns the difference between N and the number of skips actually
9466 (gnus-summary-next-thread (- n)))
9468 (defun gnus-summary-go-down-thread (&optional same)
9469 "Go down one level in the current thread.
9470 If SAME is non-nil, also move to articles of the same level."
9471 (let ((level (gnus-summary-thread-level))
9473 (if (and (zerop (forward-line 1))
9474 (> (gnus-summary-thread-level) level))
9479 (defun gnus-summary-go-up-thread ()
9480 "Go up one level in the current thread."
9481 (let ((level (gnus-summary-thread-level))
9483 (while (and (zerop (forward-line -1))
9484 (>= (gnus-summary-thread-level) level)))
9485 (if (>= (gnus-summary-thread-level) level)
9491 (defun gnus-summary-down-thread (n)
9492 "Go down thread N steps.
9493 If N is negative, go up instead.
9494 Returns the difference between N and how many steps down that were
9500 (if up (gnus-summary-go-up-thread)
9501 (gnus-summary-go-down-thread)))
9503 (gnus-summary-position-cursor)
9504 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9507 (defun gnus-summary-up-thread (n)
9508 "Go up thread N steps.
9509 If N is negative, go up instead.
9510 Returns the difference between N and how many steps down that were
9513 (gnus-summary-down-thread (- n)))
9515 (defun gnus-summary-kill-thread (unmark)
9516 "Mark articles under current thread as read.
9517 If the prefix argument is positive, remove any kinds of marks.
9518 If the prefix argument is negative, tick articles instead."
9521 (setq unmark (prefix-numeric-value unmark)))
9523 (level (gnus-summary-thread-level)))
9526 ;; Mark the article...
9527 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
9528 ((> unmark 0) (gnus-summary-tick-article nil t))
9529 (t (gnus-summary-tick-article)))
9530 ;; ...and go forward until either the buffer ends or the subtree
9532 (if (not (and (zerop (forward-line 1))
9533 (> (gnus-summary-thread-level) level)))
9534 (setq killing nil))))
9535 ;; Hide killed subtrees.
9537 gnus-thread-hide-killed
9538 (gnus-summary-hide-thread))
9539 ;; If marked as read, go to next unread subject.
9541 ;; Go to next unread subject.
9542 (gnus-summary-next-subject 1 t)))
9543 (gnus-set-mode-line 'summary))
9545 ;; Summary sorting commands
9547 (defun gnus-summary-sort-by-number (&optional reverse)
9548 "Sort summary buffer by article number.
9549 Argument REVERSE means reverse order."
9552 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9554 (defun gnus-summary-sort-by-author (&optional reverse)
9555 "Sort summary buffer by author name alphabetically.
9556 If case-fold-search is non-nil, case of letters is ignored.
9557 Argument REVERSE means reverse order."
9562 (let ((extract (funcall
9563 gnus-extract-address-components
9564 (header-from (gnus-get-header-by-number
9565 (gnus-summary-article-number))))))
9566 (or (car extract) (cdr extract))))
9567 'gnus-thread-sort-by-author)
9570 (defun gnus-summary-sort-by-subject (&optional reverse)
9571 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9572 If case-fold-search is non-nil, case of letters is ignored.
9573 Argument REVERSE means reverse order."
9578 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9579 'gnus-thread-sort-by-subject)
9582 (defun gnus-summary-sort-by-date (&optional reverse)
9583 "Sort summary buffer by date.
9584 Argument REVERSE means reverse order."
9591 (gnus-get-header-by-number (gnus-summary-article-number)))))
9592 'gnus-thread-sort-by-date)
9595 (defun gnus-summary-sort-by-score (&optional reverse)
9596 "Sort summary buffer by score.
9597 Argument REVERSE means reverse order."
9600 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9603 (defvar gnus-summary-already-sorted nil)
9604 (defun gnus-summary-sort (predicate reverse)
9605 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9606 (if gnus-summary-already-sorted
9608 (let (buffer-read-only)
9609 (if (not gnus-show-threads)
9611 (goto-char (point-min))
9612 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9613 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9614 (gnus-summary-prepare-hook nil)
9615 (gnus-summary-already-sorted nil))
9616 (gnus-summary-prepare)
9617 (and gnus-show-threads
9618 gnus-thread-hide-subtree
9619 (gnus-summary-hide-all-threads))
9620 ;; If in async mode, we send some info to the backend.
9621 (and gnus-newsgroup-async
9622 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
9623 (gnus-request-asynchronous
9625 (if (and gnus-asynchronous-article-function
9626 (fboundp gnus-asynchronous-article-function))
9627 (funcall gnus-asynchronous-article-function
9628 gnus-newsgroup-threads)))))))))
9631 (defun gnus-sortable-date (date)
9632 "Make sortable string by string-lessp from DATE.
9633 Timezone package is used."
9634 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9635 (year (aref date 0))
9636 (month (aref date 1))
9637 (day (aref date 2)))
9638 (timezone-make-sortable-date
9640 (timezone-make-time-string
9641 (aref date 3) (aref date 4) (aref date 5)))))
9644 ;; Summary saving commands.
9646 (defun gnus-summary-save-article (n)
9647 "Save the current article using the default saver function.
9648 If N is a positive number, save the N next articles.
9649 If N is a negative number, save the N previous articles.
9650 If N is nil and any articles have been marked with the process mark,
9651 save those articles instead.
9652 The variable `gnus-default-article-saver' specifies the saver function."
9654 (let ((articles (gnus-summary-work-articles n)))
9656 (let ((header (gnus-get-header-by-number (car articles))))
9657 (if (vectorp header)
9659 (gnus-summary-select-article t nil nil (car articles))
9660 (or gnus-save-all-headers
9661 (gnus-article-hide-headers t))
9662 ;; Remove any X-Gnus lines.
9665 (set-buffer gnus-article-buffer)
9666 (let ((buffer-read-only nil))
9667 (goto-char (point-min))
9668 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9670 (while (re-search-forward "^X-Gnus" nil t)
9672 (delete-region (point)
9673 (progn (forward-line 1) (point))))
9676 (if gnus-default-article-saver
9677 (funcall gnus-default-article-saver)
9678 (error "No default saver is defined."))))
9679 (if (assq 'name header)
9680 (gnus-copy-file (cdr (assq 'name header)))
9681 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9682 (gnus-summary-remove-process-mark (car articles))
9683 (setq articles (cdr articles)))
9684 (gnus-summary-position-cursor)
9687 (defun gnus-summary-pipe-output (arg)
9688 "Pipe the current article to a subprocess.
9689 If N is a positive number, pipe the N next articles.
9690 If N is a negative number, pipe the N previous articles.
9691 If N is nil and any articles have been marked with the process mark,
9692 pipe those articles instead."
9694 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9695 (gnus-summary-save-article arg)))
9697 (defun gnus-summary-save-article-mail (arg)
9698 "Append the current article to an mail file.
9699 If N is a positive number, save the N next articles.
9700 If N is a negative number, save the N previous articles.
9701 If N is nil and any articles have been marked with the process mark,
9702 save those articles instead."
9704 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9705 (gnus-summary-save-article arg)))
9707 (defun gnus-summary-save-article-rmail (arg)
9708 "Append the current article to an rmail file.
9709 If N is a positive number, save the N next articles.
9710 If N is a negative number, save the N previous articles.
9711 If N is nil and any articles have been marked with the process mark,
9712 save those articles instead."
9714 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9715 (gnus-summary-save-article arg)))
9717 (defun gnus-summary-save-article-file (arg)
9718 "Append the current article to a file.
9719 If N is a positive number, save the N next articles.
9720 If N is a negative number, save the N previous articles.
9721 If N is nil and any articles have been marked with the process mark,
9722 save those articles instead."
9724 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9725 (gnus-summary-save-article arg)))
9727 (defun gnus-read-save-file-name (prompt default-name)
9728 (let ((methods gnus-split-methods)
9730 (if (not gnus-split-methods)
9733 (set-buffer gnus-article-buffer)
9734 (gnus-narrow-to-headers)
9736 (goto-char (point-min))
9737 (and (condition-case ()
9738 (re-search-forward (car (car methods)) nil t)
9740 (setq split-name (cons (nth 1 (car methods)) split-name)))
9741 (setq methods (cdr methods)))
9743 (cond ((null split-name)
9745 (concat prompt " (default "
9746 (file-name-nondirectory default-name) ") ")
9747 (file-name-directory default-name)
9749 ((= 1 (length split-name))
9751 (concat prompt " (default " (car split-name) ") ")
9752 gnus-article-save-directory
9753 (concat gnus-article-save-directory (car split-name))))
9755 (setq split-name (mapcar (lambda (el) (list el))
9756 (nreverse split-name)))
9757 (let ((result (completing-read
9759 split-name nil nil)))
9760 (concat gnus-article-save-directory
9761 (if (string= result "")
9762 (car (car split-name))
9765 (defun gnus-summary-save-in-rmail (&optional filename)
9766 "Append this article to Rmail file.
9767 Optional argument FILENAME specifies file name.
9768 Directory to save to is default to `gnus-article-save-directory' which
9769 is initialized from the SAVEDIR environment variable."
9772 (funcall gnus-rmail-save-name gnus-newsgroup-name
9773 gnus-current-headers gnus-newsgroup-last-rmail)))
9775 (setq filename (gnus-read-save-file-name
9776 "Save in rmail file:" default-name)))
9777 (gnus-make-directory (file-name-directory filename))
9778 (gnus-eval-in-buffer-window
9783 (gnus-output-to-rmail filename))))
9784 ;; Remember the directory name to save articles.
9785 (setq gnus-newsgroup-last-rmail filename)))
9787 (defun gnus-summary-save-in-mail (&optional filename)
9788 "Append this article to Unix mail file.
9789 Optional argument FILENAME specifies file name.
9790 Directory to save to is default to `gnus-article-save-directory' which
9791 is initialized from the SAVEDIR environment variable."
9794 (funcall gnus-mail-save-name gnus-newsgroup-name
9795 gnus-current-headers gnus-newsgroup-last-mail)))
9797 (setq filename (gnus-read-save-file-name
9798 "Save in Unix mail file:" default-name)))
9800 (expand-file-name filename
9802 (file-name-directory default-name))))
9803 (gnus-make-directory (file-name-directory filename))
9804 (gnus-eval-in-buffer-window
9809 (if (and (file-readable-p filename) (rmail-file-p filename))
9810 (gnus-output-to-rmail filename)
9811 (rmail-output filename 1 t t)))))
9812 ;; Remember the directory name to save articles.
9813 (setq gnus-newsgroup-last-mail filename)))
9815 (defun gnus-summary-save-in-file (&optional filename)
9816 "Append this article to file.
9817 Optional argument FILENAME specifies file name.
9818 Directory to save to is default to `gnus-article-save-directory' which
9819 is initialized from the SAVEDIR environment variable."
9822 (funcall gnus-file-save-name gnus-newsgroup-name
9823 gnus-current-headers gnus-newsgroup-last-file)))
9825 (setq filename (gnus-read-save-file-name
9826 "Save in file:" default-name)))
9827 (gnus-make-directory (file-name-directory filename))
9828 (gnus-eval-in-buffer-window
9833 (gnus-output-to-file filename))))
9834 ;; Remember the directory name to save articles.
9835 (setq gnus-newsgroup-last-file filename)))
9837 (defun gnus-summary-save-in-pipe (&optional command)
9838 "Pipe this article to subprocess."
9840 (let ((command (read-string "Shell command on article: "
9841 gnus-last-shell-command)))
9842 (if (string-equal command "")
9843 (setq command gnus-last-shell-command))
9844 (gnus-eval-in-buffer-window
9848 (shell-command-on-region (point-min) (point-max) command nil)))
9849 (setq gnus-last-shell-command command)))
9851 ;; Summary extract commands
9853 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9854 (let ((buffer-read-only nil)
9855 (article (gnus-summary-article-number))
9857 (or (gnus-summary-goto-subject article)
9858 (error (format "No such article: %d" article)))
9859 (or gnus-newsgroup-headers-hashtb-by-number
9860 (gnus-make-headers-hashtable-by-number))
9861 (gnus-summary-position-cursor)
9862 ;; If all commands are to be bunched up on one line, we collect
9864 (if gnus-view-pseudos-separately
9866 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9869 (setq action (cdr (assq 'action (car ps))))
9870 (setq files (list (cdr (assq 'name (car ps)))))
9871 (while (and ps (cdr ps)
9872 (string= (or action "1")
9873 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9874 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9875 (setcdr ps (cdr (cdr ps))))
9878 (if (not (string-match "%s" action))
9879 (setq files (cons " " files)))
9880 (setq files (cons " " files))
9881 (and (assq 'execute (car ps))
9882 (setcdr (assq 'execute (car ps))
9883 (funcall (if (string-match "%s" action)
9886 (mapconcat (lambda (f) f) files " ")))))
9887 (setq ps (cdr ps)))))
9888 (if (and gnus-view-pseudos (not not-view))
9890 (and (assq 'execute (car pslist))
9891 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9892 (eq gnus-view-pseudos 'not-confirm)))
9893 (setq pslist (cdr pslist)))
9896 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9897 (gnus-summary-article-number)))
9900 (insert " " (file-name-nondirectory
9901 (cdr (assq 'name (car pslist))))
9902 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9903 (add-text-properties
9904 b (1+ b) (list 'gnus-number gnus-reffed-article-number
9905 'gnus-mark gnus-unread-mark
9907 'gnus-pseudo (car pslist)))
9909 (gnus-sethash (int-to-string gnus-reffed-article-number)
9910 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9911 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9912 (setq pslist (cdr pslist)))))))
9914 (defun gnus-pseudos< (p1 p2)
9915 (let ((c1 (cdr (assq 'action p1)))
9916 (c2 (cdr (assq 'action p2))))
9917 (and c1 c2 (string< c1 c2))))
9919 (defun gnus-request-pseudo-article (props)
9920 (cond ((assq 'execute props)
9921 (gnus-execute-command (cdr (assq 'execute props)))))
9922 (let ((gnus-current-article (gnus-summary-article-number)))
9923 (run-hooks 'gnus-mark-article-hook)))
9925 (defun gnus-execute-command (command &optional automatic)
9927 (gnus-article-setup-buffer)
9928 (set-buffer gnus-article-buffer)
9929 (let ((command (if automatic command (read-string "Command: " command)))
9930 (buffer-read-only nil))
9932 (insert "$ " command "\n\n")
9933 (if gnus-view-pseudo-asynchronously
9934 (start-process "gnus-execute" nil "sh" "-c" command)
9935 (call-process "sh" nil t nil "-c" command)))))
9937 (defun gnus-copy-file (file &optional to)
9940 (list (read-file-name "Copy file: " default-directory)
9941 (read-file-name "Copy file to: " default-directory)))
9942 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9943 (and (file-directory-p to)
9944 (setq to (concat (file-name-as-directory to)
9945 (file-name-nondirectory file))))
9946 (copy-file file to))
9948 ;; Summary kill commands.
9950 (defun gnus-summary-edit-global-kill (article)
9951 "Edit the \"global\" kill file."
9952 (interactive (list (gnus-summary-article-number)))
9953 (gnus-group-edit-global-kill article))
9955 (defun gnus-summary-edit-local-kill ()
9956 "Edit a local kill file applied to the current newsgroup."
9958 (setq gnus-current-headers
9960 (int-to-string (gnus-summary-article-number))
9961 gnus-newsgroup-headers-hashtb-by-number))
9962 (gnus-set-global-variables)
9963 (gnus-group-edit-local-kill
9964 (gnus-summary-article-number) gnus-newsgroup-name))
9968 ;;; Gnus article mode
9971 (put 'gnus-article-mode 'mode-class 'special)
9973 (if gnus-article-mode-map
9975 (setq gnus-article-mode-map (make-keymap))
9976 (suppress-keymap gnus-article-mode-map)
9977 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9978 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9979 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9980 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9981 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9982 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9983 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9984 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9985 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
9986 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
9987 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
9988 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
9990 ;; Duplicate almost all summary keystrokes in the article mode map.
9993 " " "\177" "\r" "n" "p" "N" "P" "\M-\C-n" "\M-\C-p"
9994 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j" "^" "\M-^"
9995 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
9996 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
9997 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
9998 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
9999 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10000 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10001 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10002 "\C-c\C-i" "x" "X" "s" "t" "g" "?" "l"
10003 "\C-c\C-v\C-v" "\C-d" "v"
10004 ;; "Mt" "M!" "Md" "Mr"
10005 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10006 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10007 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10008 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10009 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10010 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10011 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10012 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10013 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10014 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10015 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10018 (define-key gnus-article-mode-map (car commands)
10019 'gnus-article-summary-command)
10020 (setq commands (cdr commands))))
10022 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10023 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10026 (define-key gnus-article-mode-map (car commands)
10027 'gnus-article-summary-command-nosave)
10028 (setq commands (cdr commands)))))
10031 (defun gnus-article-mode ()
10032 "Major mode for displaying an article.
10034 All normal editing commands are switched off.
10036 The following commands are available:
10038 \\<gnus-article-mode-map>
10039 \\[gnus-article-next-page]\t Scroll the article one page forwards
10040 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10041 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10042 \\[gnus-article-show-summary]\t Display the summary buffer
10043 \\[gnus-article-mail]\t Send a reply to the address near point
10044 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10045 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10046 \\[gnus-info-find-node]\t Go to the Gnus info node"
10048 (if gnus-visual (gnus-article-make-menu-bar))
10049 (kill-all-local-variables)
10050 (setq mode-line-modified "-- ")
10051 (make-local-variable 'mode-line-format)
10052 (setq mode-line-format (copy-sequence mode-line-format))
10053 (and (equal (nth 3 mode-line-format) " ")
10054 (setcar (nthcdr 3 mode-line-format) ""))
10055 (setq mode-name "Article")
10056 (setq major-mode 'gnus-article-mode)
10057 (make-local-variable 'minor-mode-alist)
10058 (or (assq 'gnus-show-mime minor-mode-alist)
10059 (setq minor-mode-alist
10060 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10061 (use-local-map gnus-article-mode-map)
10062 (make-local-variable 'page-delimiter)
10063 (setq page-delimiter gnus-page-delimiter)
10064 (buffer-disable-undo (current-buffer))
10065 (setq buffer-read-only t) ;Disable modification
10066 (run-hooks 'gnus-article-mode-hook))
10068 (defun gnus-article-setup-buffer ()
10069 "Initialize article mode buffer."
10070 (if (get-buffer gnus-article-buffer)
10072 (set-buffer gnus-article-buffer)
10073 (buffer-disable-undo (current-buffer))
10074 (setq buffer-read-only t)
10075 (gnus-add-current-to-buffer-list)
10076 (or (eq major-mode 'gnus-article-mode)
10077 (gnus-article-mode)))
10079 (set-buffer (get-buffer-create gnus-article-buffer))
10080 (gnus-add-current-to-buffer-list)
10081 (gnus-article-mode))))
10083 ;; Set article window start at LINE, where LINE is the number of lines
10084 ;; from the head of the article.
10085 (defun gnus-article-set-window-start (&optional line)
10087 (get-buffer-window gnus-article-buffer)
10089 (set-buffer gnus-article-buffer)
10090 (goto-char (point-min))
10093 (gnus-message 6 "Moved to bookmark")
10094 (search-forward "\n\n" nil t)
10095 (forward-line line)
10098 (defun gnus-request-article-this-buffer (article group)
10099 "Get an article and insert it into this buffer."
10100 (setq group (or group gnus-newsgroup-name))
10102 ;; Open server if it has closed.
10103 (gnus-check-news-server (gnus-find-method-for-group group))
10105 ;; Using `gnus-request-article' directly will insert the article into
10106 ;; `nntp-server-buffer' - so we'll save some time by not having to
10107 ;; copy it from the server buffer into the article buffer.
10109 ;; We only request an article by message-id when we do not have the
10110 ;; headers for it, so we'll have to get those.
10111 (and (stringp article)
10112 (let ((gnus-override-method gnus-refer-article-method))
10113 (gnus-read-header article)))
10115 ;; If the article number is negative, that means that this article
10116 ;; doesn't belong in this newsgroup (possibly), so we find its
10117 ;; message-id and request it by id instead of number.
10118 (if (not (numberp article))
10121 (set-buffer gnus-summary-buffer)
10122 (let ((header (gnus-get-header-by-number article)))
10124 (if (vectorp header)
10125 ;; It's a real article.
10126 (setq article (header-id header))
10127 ;; It is an extracted pseudo-article.
10128 (setq article 'pseudo)
10129 (gnus-request-pseudo-article header)))
10131 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10132 (if (not (eq (car method) 'nneething))
10134 (let ((dir (concat (file-name-as-directory (nth 1 method))
10135 (header-subject header))))
10136 (if (file-directory-p dir)
10138 (setq article 'nneething)
10139 (gnus-group-enter-directory dir)))))))))
10141 ;; Check the cache.
10142 (if (and gnus-use-cache
10144 (gnus-cache-request-article article group))
10146 ;; Get the article and into the article buffer.
10147 (if (or (stringp article) (numberp article))
10150 (let ((gnus-override-method
10151 (and (stringp article) gnus-refer-article-method)))
10152 (and (gnus-request-article article group (current-buffer))
10156 (defun gnus-read-header (id)
10157 "Read the headers of article ID and enter them into the Gnus system."
10158 (or gnus-newsgroup-headers-hashtb-by-number
10159 (gnus-make-headers-hashtable-by-number))
10161 (if (not (setq header
10162 (car (if (let ((gnus-nov-is-evil t))
10163 (gnus-retrieve-headers
10164 (list id) gnus-newsgroup-name))
10165 (gnus-get-newsgroup-headers)))))
10168 (header-set-number header gnus-reffed-article-number))
10169 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10170 (gnus-sethash (int-to-string (header-number header)) header
10171 gnus-newsgroup-headers-hashtb-by-number)
10173 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10174 (setq gnus-current-headers header)
10177 (defun gnus-article-prepare (article &optional all-headers header)
10178 "Prepare ARTICLE in article mode buffer.
10179 ARTICLE should either be an article number or a Message-ID.
10180 If ARTICLE is an id, HEADER should be the article headers.
10181 If ALL-HEADERS is non-nil, no headers are hidden."
10183 ;; Make sure we start in a summary buffer.
10184 (or (eq major-mode 'gnus-summary-mode)
10185 (set-buffer gnus-summary-buffer))
10186 (setq gnus-summary-buffer (current-buffer))
10187 ;; Make sure the connection to the server is alive.
10188 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10190 (gnus-check-news-server
10191 (gnus-find-method-for-group gnus-newsgroup-name))
10192 (gnus-request-group gnus-newsgroup-name t)))
10193 (or gnus-newsgroup-headers-hashtb-by-number
10194 (gnus-make-headers-hashtable-by-number))
10195 (let* ((article (if header (header-number header) article))
10196 (summary-buffer (current-buffer))
10197 (internal-hook gnus-article-internal-prepare-hook)
10198 (group gnus-newsgroup-name)
10201 (gnus-article-setup-buffer)
10202 (set-buffer gnus-article-buffer)
10203 (if (not (setq result (let ((buffer-read-only nil))
10204 (gnus-request-article-this-buffer
10206 ;; There is no such article.
10208 (if (not (numberp article))
10210 (setq gnus-article-current
10211 (cons gnus-newsgroup-name article))
10212 (set-buffer gnus-summary-buffer)
10213 (setq gnus-current-article article)
10214 (gnus-summary-mark-as-read article gnus-canceled-mark))
10215 (gnus-message 1 "No such article (may be canceled)")
10218 (if (or (eq result 'pseudo) (eq result 'nneething))
10221 (set-buffer summary-buffer)
10222 (setq gnus-last-article gnus-current-article
10223 gnus-newsgroup-history (cons gnus-current-article
10224 gnus-newsgroup-history)
10225 gnus-current-article 0
10226 gnus-current-headers nil
10227 gnus-article-current nil)
10228 (if (eq result 'nneething)
10229 (gnus-configure-windows 'summary)
10230 (gnus-configure-windows 'article))
10231 (gnus-set-global-variables))
10232 (gnus-set-mode-line 'article))
10233 ;; The result from the `request' was an actual article -
10234 ;; or at least some text that is now displayed in the
10236 (if (and (numberp article)
10237 (not (eq article gnus-current-article)))
10238 ;; Seems like a new article has been selected.
10239 ;; `gnus-current-article' must be an article number.
10241 (set-buffer summary-buffer)
10242 (setq gnus-last-article gnus-current-article
10243 gnus-newsgroup-history (cons gnus-current-article
10244 gnus-newsgroup-history)
10245 gnus-current-article article
10246 gnus-current-headers
10247 (gnus-get-header-by-number gnus-current-article)
10248 gnus-article-current
10249 (cons gnus-newsgroup-name gnus-current-article))
10250 (gnus-summary-show-thread)
10251 (run-hooks 'gnus-mark-article-hook)
10252 (gnus-set-mode-line 'summary)
10254 (run-hooks 'gnus-visual-mark-article-hook))
10255 ;; Set the global newsgroup variables here.
10256 ;; Suggested by Jim Sisolak
10257 ;; <sisolak@trans4.neep.wisc.edu>.
10258 (gnus-set-global-variables)
10259 (and gnus-use-cache
10260 (gnus-cache-possibly-enter-article
10262 (gnus-get-header-by-number article)
10263 (memq article gnus-newsgroup-marked)
10264 (memq article gnus-newsgroup-dormant)
10265 (memq article gnus-newsgroup-unreads)))))
10266 ;; gnus-have-all-headers must be either T or NIL.
10267 (setq gnus-have-all-headers
10268 (not (not (or all-headers gnus-show-all-headers))))
10269 ;; Hooks for getting information from the article.
10270 ;; This hook must be called before being narrowed.
10271 (let (buffer-read-only)
10272 (run-hooks 'internal-hook)
10273 (run-hooks 'gnus-article-prepare-hook)
10274 ;; Decode MIME message.
10275 (if (and gnus-show-mime
10276 (or (not gnus-strict-mime)
10277 (gnus-fetch-field "Mime-Version")))
10278 (funcall gnus-show-mime-method))
10279 ;; Perform the article display hooks.
10280 (run-hooks 'gnus-article-display-hook))
10282 (goto-char (point-min))
10283 (and gnus-break-pages (gnus-narrow-to-page))
10284 (gnus-set-mode-line 'article)
10285 (gnus-configure-windows 'article)
10286 (goto-char (point-min))
10289 (defun gnus-article-show-all-headers ()
10290 "Show all article headers in article mode buffer."
10292 (gnus-article-setup-buffer)
10293 (set-buffer gnus-article-buffer)
10294 (let ((buffer-read-only nil))
10295 (remove-text-properties (point-min) (point-max)
10296 gnus-hidden-properties))))
10298 (defun gnus-article-hide-headers-if-wanted ()
10299 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10300 Provided for backwards compatability."
10301 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10302 (gnus-article-hide-headers)))
10304 (defun gnus-article-hide-headers (&optional delete)
10305 "Hide unwanted headers and possibly sort them as well."
10308 (set-buffer gnus-article-buffer)
10310 (let ((sorted gnus-sorted-header-list)
10311 (buffer-read-only nil)
10312 want-list beg want-l)
10313 ;; First we narrow to just the headers.
10315 (goto-char (point-min))
10316 ;; Hide any "From " lines at the beginning of (mail) articles.
10317 (while (looking-at "From ")
10320 (add-text-properties (point-min) (point) gnus-hidden-properties))
10321 ;; Then treat the rest of the header lines.
10324 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10325 ;; Then we use the two regular expressions
10326 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10327 ;; select which header lines is to remain visible in the
10329 (goto-char (point-min))
10330 (while (re-search-forward "^[^ \t]*:" nil t)
10331 (beginning-of-line)
10332 ;; We add the headers we want to keep to a list and delete
10333 ;; them from the buffer.
10334 (if (or (and (stringp gnus-visible-headers)
10335 (looking-at gnus-visible-headers))
10336 (and (not (stringp gnus-visible-headers))
10337 (stringp gnus-ignored-headers)
10338 (not (looking-at gnus-ignored-headers))))
10342 ;; Be sure to get multi-line headers...
10343 (re-search-forward "^[^ \t]*:" nil t)
10344 (beginning-of-line)
10346 (cons (buffer-substring beg (point)) want-list))
10347 (delete-region beg (point))
10350 ;; Next we perform the sorting by looking at
10351 ;; `gnus-sorted-header-list'.
10352 (goto-char (point-min))
10353 (while (and sorted want-list)
10354 (setq want-l want-list)
10356 (not (string-match (car sorted) (car want-l))))
10357 (setq want-l (cdr want-l)))
10360 (insert (car want-l))
10361 (setq want-list (delq (car want-l) want-list))))
10362 (setq sorted (cdr sorted)))
10363 ;; Any headers that were not matched by the sorted list we
10364 ;; just tack on the end of the visible header list.
10366 (insert (car want-list))
10367 (setq want-list (cdr want-list)))
10368 ;; And finally we make the unwanted headers invisible.
10370 (delete-region (point) (point-max))
10371 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10372 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10374 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10375 (defun gnus-article-treat-overstrike ()
10376 "Translate overstrikes into bold text."
10379 (set-buffer gnus-article-buffer)
10380 (let ((buffer-read-only nil))
10381 (while (search-forward "\b" nil t)
10382 (let ((next (following-char))
10383 (previous (char-after (- (point) 2))))
10384 (cond ((eq next previous)
10385 (delete-region (- (point) 2) (point))
10386 (put-text-property (point) (1+ (point))
10389 (delete-region (1- (point)) (1+ (point)))
10390 (put-text-property (1- (point)) (point)
10393 (delete-region (- (point) 2) (point))
10394 (put-text-property (point) (1+ (point))
10395 'face 'underline))))))))
10397 (defun gnus-article-word-wrap ()
10398 "Format too long lines."
10401 (set-buffer gnus-article-buffer)
10402 (let ((buffer-read-only nil))
10403 (goto-char (point-min))
10404 (search-forward "\n\n" nil t)
10406 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
10407 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
10408 (adaptive-fill-mode t))
10409 (while (not (eobp))
10410 (and (>= (current-column) (min fill-column (window-width)))
10411 (/= (preceding-char) ?:)
10412 (fill-paragraph nil))
10413 (end-of-line 2))))))
10415 (defun gnus-article-remove-cr ()
10416 "Remove carriage returns from an article."
10419 (set-buffer gnus-article-buffer)
10420 (let ((buffer-read-only nil))
10421 (goto-char (point-min))
10422 (while (search-forward "\r" nil t)
10423 (replace-match "" t t)))))
10425 (defun gnus-article-display-x-face (&optional force)
10426 "Look for an X-Face header and display it if present."
10427 (interactive (list 'force))
10429 (set-buffer gnus-article-buffer)
10430 (let ((inhibit-point-motion-hooks t)
10431 (case-fold-search nil))
10433 (goto-char (point-min))
10434 (search-forward "\n\n")
10435 (narrow-to-region (point-min) (point))
10436 (goto-char (point-min))
10437 (if (or (not gnus-article-x-face-command)
10439 (or (not gnus-article-x-face-too-ugly)
10440 (string-match gnus-article-x-face-too-ugly
10441 (mail-fetch-field "from"))))
10443 (goto-char (point-min))
10444 (not (re-search-forward "^X-Face: " nil t))))
10446 (let ((beg (point))
10447 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
10448 (if (symbolp gnus-article-x-face-command)
10449 (and (or (fboundp gnus-article-x-face-command)
10450 (error "%s is not a function"
10451 gnus-article-x-face-command))
10452 (funcall gnus-article-x-face-command beg end))
10453 (call-process-region beg end "sh" nil 0 nil
10454 "-c" gnus-article-x-face-command))))))))
10456 (defun gnus-article-de-quoted-unreadable (&optional force)
10457 "Do a naïve translation of a quoted-printable-encoded article.
10458 This is in no way, shape or form meant as a replacement for real MIME
10459 processing, but is simply a stop-gap measure until MIME support is
10461 If FORCE, decode the article whether it is marked as quoted-printable
10463 (interactive (list 'force))
10465 (set-buffer gnus-article-buffer)
10466 (let ((case-fold-search t)
10467 (buffer-read-only nil)
10468 (type (gnus-fetch-field "content-transfer-encoding")))
10469 (if (or force (and type (string-match "quoted-printable" type)))
10471 (goto-char (point-min))
10472 (search-forward "\n\n" nil 'move)
10473 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
10475 (defun gnus-mime-decode-quoted-printable (from to)
10476 ;; Decode quoted-printable from region between FROM and TO.
10479 (while (search-forward "=" to t)
10480 (cond ((eq (following-char) ?\n)
10483 ((looking-at "[0-9A-F][0-9A-F]")
10485 (insert (hexl-hex-string-to-integer
10486 (buffer-substring (point) (+ 2 (point)))))
10488 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
10490 (defvar gnus-article-time-units
10491 (list (cons 'year (* 365.25 24 60 60))
10492 (cons 'week (* 7 24 60 60))
10493 (cons 'day (* 24 60 60))
10494 (cons 'hour (* 60 60))
10498 (defun gnus-article-date-ut (&optional type)
10499 "Convert DATE date to universal time in the current article.
10500 If TYPE is `local', convert to local time; if it is `lapsed', output
10501 how much time has lapsed since DATE."
10502 (interactive (list 'ut))
10503 (let ((date (header-date (or gnus-current-headers
10504 (gnus-get-header-by-number
10505 (gnus-summary-article-number))"")))
10506 (date-regexp "^Date: \\|^X-Sent: "))
10511 (set-buffer gnus-article-buffer)
10512 (let ((buffer-read-only nil))
10513 (goto-char (point-min))
10514 (if (and (re-search-forward date-regexp nil t)
10516 (beginning-of-line)
10517 (looking-at date-regexp)))
10518 (delete-region (gnus-point-at-bol)
10519 (progn (end-of-line) (1+ (point))))
10520 (goto-char (point-min))
10521 (goto-char (- (search-forward "\n\n") 2)))
10525 (concat "Date: " (condition-case ()
10526 (timezone-make-date-arpa-standard date)
10532 (timezone-make-date-arpa-standard date nil "UT")
10536 ;; If the date is seriously mangled, the timezone
10537 ;; functions are liable to bug out, so we condition-case
10538 ;; the entire thing.
10539 (let* ((sec (condition-case ()
10540 (max (- (gnus-seconds-since-epoch
10541 (timezone-make-date-arpa-standard
10542 (current-time-string)
10543 (current-time-zone) "UT"))
10544 (gnus-seconds-since-epoch
10545 (timezone-make-date-arpa-standard
10554 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
10556 (setq sec (- sec (* num (cdr unit))))
10558 (concat (if prev ", " "") (int-to-string (floor num))
10559 " " (symbol-name (car unit))
10560 (if (> num 1) "s" ""))
10562 gnus-article-time-units "")
10565 (error "Unknown conversion type: %s" type)))))))))
10567 (defun gnus-article-date-local ()
10568 "Convert the current article date to the local timezone."
10570 (gnus-article-date-ut 'local))
10572 (defun gnus-article-date-lapsed ()
10573 "Convert the current article date to time lapsed since it was sent."
10575 (gnus-article-date-ut 'lapsed))
10577 (defun gnus-article-maybe-highlight ()
10578 (if gnus-visual (gnus-article-highlight)))
10582 (defun gnus-output-to-rmail (file-name)
10583 "Append the current article to an Rmail file named FILE-NAME."
10585 ;; Most of these codes are borrowed from rmailout.el.
10586 (setq file-name (expand-file-name file-name))
10587 (setq rmail-default-rmail-file file-name)
10588 (let ((artbuf (current-buffer))
10589 (tmpbuf (get-buffer-create " *Gnus-output*")))
10591 (or (get-file-buffer file-name)
10592 (file-exists-p file-name)
10593 (if (gnus-yes-or-no-p
10594 (concat "\"" file-name "\" does not exist, create it? "))
10595 (let ((file-buffer (create-file-buffer file-name)))
10597 (set-buffer file-buffer)
10598 (rmail-insert-rmail-file-header)
10599 (let ((require-final-newline nil))
10600 (write-region (point-min) (point-max) file-name t 1)))
10601 (kill-buffer file-buffer))
10602 (error "Output file does not exist")))
10603 (set-buffer tmpbuf)
10604 (buffer-disable-undo (current-buffer))
10606 (insert-buffer-substring artbuf)
10607 (gnus-convert-article-to-rmail)
10608 ;; Decide whether to append to a file or to an Emacs buffer.
10609 (let ((outbuf (get-file-buffer file-name)))
10611 (append-to-file (point-min) (point-max) file-name)
10612 ;; File has been visited, in buffer OUTBUF.
10613 (set-buffer outbuf)
10614 (let ((buffer-read-only nil)
10615 (msg (and (boundp 'rmail-current-message)
10616 (symbol-value 'rmail-current-message))))
10617 ;; If MSG is non-nil, buffer is in RMAIL mode.
10620 (narrow-to-region (point-max) (point-max))))
10621 (insert-buffer-substring tmpbuf)
10624 (goto-char (point-min))
10626 (search-backward "\^_")
10627 (narrow-to-region (point) (point-max))
10628 (goto-char (1+ (point-min)))
10629 (rmail-count-new-messages t)
10630 (rmail-show-message msg)))))))
10631 (kill-buffer tmpbuf)))
10633 (defun gnus-output-to-file (file-name)
10634 "Append the current article to a file named FILE-NAME."
10635 (setq file-name (expand-file-name file-name))
10636 (let ((artbuf (current-buffer))
10637 (tmpbuf (get-buffer-create " *Gnus-output*")))
10639 (set-buffer tmpbuf)
10640 (buffer-disable-undo (current-buffer))
10642 (insert-buffer-substring artbuf)
10643 ;; Append newline at end of the buffer as separator, and then
10644 ;; save it to file.
10645 (goto-char (point-max))
10647 (append-to-file (point-min) (point-max) file-name))
10648 (kill-buffer tmpbuf)))
10650 (defun gnus-convert-article-to-rmail ()
10651 "Convert article in current buffer to Rmail message format."
10652 (let ((buffer-read-only nil))
10653 ;; Convert article directly into Babyl format.
10654 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10655 (goto-char (point-min))
10656 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10657 (while (search-forward "\n\^_" nil t) ;single char
10658 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10659 (goto-char (point-max))
10662 (defun gnus-narrow-to-page (&optional arg)
10663 "Make text outside current page invisible except for page delimiter.
10664 A numeric arg specifies to move forward or backward by that many pages,
10665 thus showing a page other than the one point was originally in."
10667 (setq arg (if arg (prefix-numeric-value arg) 0))
10669 (forward-page -1) ;Beginning of current page.
10674 (forward-page (1- arg))))
10675 ;; Find the end of the page.
10677 ;; If we stopped due to end of buffer, stay there.
10678 ;; If we stopped after a page delimiter, put end of restriction
10679 ;; at the beginning of that line.
10680 ;; These are commented out.
10681 ;; (if (save-excursion (beginning-of-line)
10682 ;; (looking-at page-delimiter))
10683 ;; (beginning-of-line))
10684 (narrow-to-region (point)
10686 ;; Find the top of the page.
10688 ;; If we found beginning of buffer, stay there.
10689 ;; If extra text follows page delimiter on same line,
10691 ;; Otherwise, show text starting with following line.
10692 (if (and (eolp) (not (bobp)))
10696 (defun gnus-gmt-to-local ()
10697 "Rewrite Date header described in GMT to local in current buffer.
10698 Intended to be used with gnus-article-prepare-hook."
10702 (goto-char (point-min))
10703 (narrow-to-region (point-min)
10704 (progn (search-forward "\n\n" nil 'move) (point)))
10705 (goto-char (point-min))
10706 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10707 (let ((buffer-read-only nil)
10708 (date (buffer-substring-no-properties
10709 (match-beginning 1) (match-end 1))))
10710 (delete-region (match-beginning 1) (match-end 1))
10712 (timezone-make-date-arpa-standard
10713 date nil (current-time-zone))))))))
10716 ;; Article mode commands
10718 (defun gnus-article-next-page (lines)
10719 "Show next page of current article.
10720 If end of article, return non-nil. Otherwise return nil.
10721 Argument LINES specifies lines to be scrolled up."
10723 (move-to-window-line -1)
10724 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10725 (if (save-excursion
10727 (and (pos-visible-in-window-p) ;Not continuation line.
10729 ;; Nothing in this page.
10730 (if (or (not gnus-break-pages)
10733 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10735 (gnus-narrow-to-page 1) ;Go to next page.
10737 ;; More in this page.
10741 ;; Long lines may cause an end-of-buffer error.
10742 (goto-char (point-max))))
10745 (defun gnus-article-prev-page (lines)
10746 "Show previous page of current article.
10747 Argument LINES specifies lines to be scrolled down."
10749 (move-to-window-line 0)
10750 (if (and gnus-break-pages
10752 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10754 (gnus-narrow-to-page -1) ;Go to previous page.
10755 (goto-char (point-max))
10757 (scroll-down lines)))
10759 (defun gnus-article-refer-article ()
10760 "Read article specified by message-id around point."
10762 (search-forward ">" nil t) ;Move point to end of "<....>".
10763 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10765 (buffer-substring (match-beginning 1) (match-end 1))))
10766 (set-buffer gnus-summary-buffer)
10767 (gnus-summary-refer-article message-id))
10768 (error "No references around point")))
10770 (defun gnus-article-show-summary ()
10771 "Reconfigure windows to show summary buffer."
10773 (gnus-configure-windows 'article)
10774 (gnus-summary-goto-subject gnus-current-article))
10776 (defun gnus-article-describe-briefly ()
10777 "Describe article mode commands briefly."
10780 (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")))
10782 (defun gnus-article-summary-command ()
10783 "Execute the last keystroke in the summary buffer."
10785 (let ((obuf (current-buffer))
10786 (owin (current-window-configuration))
10788 (switch-to-buffer gnus-summary-buffer 'norecord)
10789 (setq func (lookup-key (current-local-map) (this-command-keys)))
10790 (call-interactively func)
10792 (set-window-configuration owin)
10793 (set-window-start (get-buffer-window (current-buffer)) (point))))
10795 (defun gnus-article-summary-command-nosave ()
10796 "Execute the last keystroke in the summary buffer."
10799 (switch-to-buffer gnus-summary-buffer 'norecord)
10800 (setq func (lookup-key (current-local-map) (this-command-keys)))
10801 (call-interactively func)))
10803 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
10804 ;; Modified by tower@prep Nov 86
10805 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
10807 (defun gnus-caesar-region (&optional n)
10808 "Caesar rotation of region by N, default 13, for decrypting netnews.
10809 ROT47 will be performed for Japanese text in any case."
10810 (interactive (if current-prefix-arg ; Was there a prefix arg?
10811 (list (prefix-numeric-value current-prefix-arg))
10813 (cond ((not (numberp n)) (setq n 13))
10814 (t (setq n (mod n 26)))) ;canonicalize N
10815 (if (not (zerop n)) ; no action needed for a rot of 0
10817 (if (or (not (boundp 'caesar-translate-table))
10818 (not caesar-translate-table)
10819 (/= (aref caesar-translate-table ?a) (+ ?a n)))
10821 (lower "abcdefghijklmnopqrstuvwxyz")
10823 (gnus-message 9 "Building caesar-translate-table...")
10824 (setq caesar-translate-table (make-vector 256 0))
10826 (aset caesar-translate-table i i)
10828 (setq lower (concat lower lower)
10829 upper (upcase lower)
10832 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
10833 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
10835 ;; ROT47 for Japanese text.
10836 ;; Thanks to ichikawa@flab.fujitsu.junet.
10838 (let ((t1 (logior ?O 128))
10839 (t2 (logior ?! 128))
10840 (t3 (logior ?~ 128)))
10842 (aset caesar-translate-table i
10843 (let ((v (aref caesar-translate-table i)))
10844 (if (<= v t1) (if (< v t2) v (+ v 47))
10845 (if (<= v t3) (- v 47) v))))
10847 (gnus-message 9 "Building caesar-translate-table...done")))
10848 (let ((from (region-beginning))
10851 (setq str (buffer-substring from to))
10852 (setq len (length str))
10854 (aset str i (aref caesar-translate-table (aref str i)))
10857 (delete-region from to)
10861 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10864 (defalias 'gnus-batch-kill 'gnus-batch-score)
10866 (defun gnus-batch-score ()
10867 "Run batched scoring.
10868 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10869 Newsgroups is a list of strings in Bnews format. If you want to score
10870 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10871 score the alt hierarchy, you'd say \"!alt.all\"."
10874 (gnus-newsrc-parse-options
10875 (apply (function concat)
10876 (mapcar (lambda (g) (concat g " "))
10877 command-line-args-left))))
10878 (gnus-expert-user t)
10879 (nnmail-spool-file nil)
10880 (gnus-use-dribble-file nil)
10881 (yes (car yes-and-no))
10882 (no (cdr yes-and-no))
10884 ;; Disable verbose message.
10885 gnus-novice-user gnus-large-newsgroup)
10886 ;; Eat all arguments.
10887 (setq command-line-args-left nil)
10890 ;; Apply kills to specified newsgroups in command line arguments.
10891 (setq newsrc (cdr gnus-newsrc-alist))
10893 (setq group (car (car newsrc)))
10894 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10895 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10897 (or (eq (car entry) t)
10898 (not (zerop (car entry)))))
10899 (if yes (string-match yes group) t)
10900 (or (null no) (not (string-match no group))))
10902 (gnus-summary-read-group group nil t)
10903 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10904 (gnus-summary-exit))))
10905 (setq newsrc (cdr newsrc)))
10907 (switch-to-buffer gnus-group-buffer)
10908 (gnus-group-save-newsrc)))
10910 (defun gnus-apply-kill-file ()
10911 "Apply a kill file to the current newsgroup.
10912 Returns the number of articles marked as read."
10913 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10914 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10915 (gnus-apply-kill-file-internal)
10918 (defun gnus-kill-save-kill-buffer ()
10920 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10921 (if (get-file-buffer file)
10923 (set-buffer (get-file-buffer file))
10924 (and (buffer-modified-p) (save-buffer))
10925 (kill-buffer (current-buffer)))))))
10927 (defvar gnus-kill-file-name "KILL"
10928 "Suffix of the kill files.")
10930 (defun gnus-newsgroup-kill-file (newsgroup)
10931 "Return the name of a kill file name for NEWSGROUP.
10932 If NEWSGROUP is nil, return the global kill file name instead."
10933 (cond ((or (null newsgroup)
10934 (string-equal newsgroup ""))
10935 ;; The global KILL file is placed at top of the directory.
10936 (expand-file-name gnus-kill-file-name
10937 (or gnus-kill-files-directory "~/News")))
10938 ((gnus-use-long-file-name 'not-kill)
10939 ;; Append ".KILL" to newsgroup name.
10940 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10941 (or gnus-kill-files-directory "~/News")))
10943 ;; Place "KILL" under the hierarchical directory.
10944 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10945 "/" gnus-kill-file-name)
10946 (or gnus-kill-files-directory "~/News")))))
10953 (defvar gnus-dribble-ignore nil)
10955 (defun gnus-dribble-file-name ()
10956 (concat gnus-startup-file "-dribble"))
10958 (defun gnus-dribble-open ()
10961 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10962 (buffer-disable-undo (current-buffer))
10963 (bury-buffer gnus-dribble-buffer)
10965 (goto-char (point-max))))
10967 (defun gnus-dribble-enter (string)
10968 (if (and (not gnus-dribble-ignore)
10969 gnus-dribble-buffer
10970 (buffer-name gnus-dribble-buffer))
10971 (let ((obuf (current-buffer)))
10972 (set-buffer gnus-dribble-buffer)
10973 (insert string "\n")
10974 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10975 (set-buffer obuf))))
10977 (defun gnus-dribble-read-file ()
10978 (let ((dribble-file (gnus-dribble-file-name)))
10980 (set-buffer (setq gnus-dribble-buffer
10982 (file-name-nondirectory dribble-file))))
10983 (gnus-add-current-to-buffer-list)
10985 (set-visited-file-name dribble-file)
10986 (buffer-disable-undo (current-buffer))
10987 (bury-buffer (current-buffer))
10988 (set-buffer-modified-p nil)
10989 (let ((auto (make-auto-save-file-name))
10990 (gnus-dribble-ignore t))
10991 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10993 (if (file-newer-than-file-p auto dribble-file)
10994 (setq dribble-file auto))
10995 (insert-file-contents dribble-file)
10996 (if (not (zerop (buffer-size)))
10997 (set-buffer-modified-p t))
10999 "Auto-save file exists. Do you want to read it? ")
11001 (gnus-message 5 "Reading %s..." dribble-file)
11002 (eval-buffer (current-buffer))
11003 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
11005 (defun gnus-dribble-delete-file ()
11006 (if (file-exists-p (gnus-dribble-file-name))
11007 (delete-file (gnus-dribble-file-name)))
11008 (if gnus-dribble-buffer
11010 (set-buffer gnus-dribble-buffer)
11011 (let ((auto (make-auto-save-file-name)))
11012 (if (file-exists-p auto)
11013 (delete-file auto))
11015 (set-buffer-modified-p nil)))))
11017 (defun gnus-dribble-save ()
11018 (if (and gnus-dribble-buffer
11019 (buffer-name gnus-dribble-buffer))
11021 (set-buffer gnus-dribble-buffer)
11024 (defun gnus-dribble-clear ()
11026 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11028 (set-buffer gnus-dribble-buffer)
11030 (set-buffer-modified-p nil)
11031 (setq buffer-saved-size (buffer-size))))))
11034 ;;; Server Communication
11037 ;; All the Gnus backends have the same interface, and should return
11038 ;; data in a similar format. Below is an overview of what functions
11039 ;; these packages must supply and what results they should return.
11043 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11046 ;; Functions for the imaginary backend `choke':
11048 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11049 ;; Should return all headers for all ARTICLES, or return NOV lines for
11052 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11053 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11054 ;; must be returned.
11056 ;; `choke-close-group GROUP &optional SERVER'
11057 ;; Close group. Most backends won't have to do anything with this
11058 ;; call, but it is an opportunity to clean up, if that is needed. It
11059 ;; is called when Gnus exits a group.
11061 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11062 ;; Return ARTICLE, which is either an article number or
11063 ;; message-id. Note that not all backends can return articles based on
11066 ;; `choke-request-list SERVER'
11067 ;; Return a list of all newsgroups on SERVER.
11069 ;; `choke-request-list-newsgroups SERVER'
11070 ;; Return a list of descriptions of all newsgroups on SERVER.
11072 ;; `choke-request-newgroups DATE &optional SERVER'
11073 ;; Return a list of all groups that have arrived after DATE on
11074 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11075 ;; always check whether the groups are old or not. Backends that do
11076 ;; not store date information may just return the entire list of
11077 ;; groups, although this might not be a good idea in general.
11079 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11080 ;; Should return a buffer that is suitable for "posting". nnspool and
11081 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11082 ;; buffer. This function should fill out the appropriate headers.
11084 ;; `choke-request-post &optional SERVER'
11085 ;; Function that will be called from a buffer to be posted.
11087 ;; `choke-open-server SERVER &optional ARGUMENT'
11088 ;; Open a connection to SERVER.
11090 ;; `choke-close-server &optional SERVER'
11091 ;; Close the connection to SERVER.
11093 ;; `choke-server-opened &optional SERVER'
11094 ;; Whether the conenction to SERVER is opened or not.
11096 ;; `choke-server-status &optional SERVER'
11097 ;; Should return a status string (not in the nntp buffer, but as the
11098 ;; result of the function).
11100 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11101 ;; Optional function for retrieving active file info on all groups in
11102 ;; GROUPS. Two return formats are supported: The normal active file
11103 ;; format, and a list of GROUP lines. This function should return (as
11104 ;; a function value) either `active' or `group', depending on what
11105 ;; format it returns.
11107 ;; The following functions are optional and apply only to backends
11108 ;; that are able to control the contents of their groups totally
11109 ;; (ie. mail backends.) Backends that aren't able to do that
11110 ;; shouldn't define these functions at all. Gnus will check for their
11111 ;; presence before attempting to call them.
11113 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11114 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11115 ;; backends will not be able to expire articles. Should return a list
11116 ;; of all articles that were not expired.
11118 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11119 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11120 ;; Removes any information it has added to the article (extra headers,
11121 ;; whatever - make it as clean as possible), and then passes the
11122 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11123 ;; function described below. If the ACCEPT-FORM returns a non-nil
11124 ;; value, the article should then be deleted. If LAST is nil, that
11125 ;; means that there will be further calls to this function. This might
11126 ;; be taken as an advice not to save buffers/internal variables just
11127 ;; yet, but wait until the last call to speed things up.
11129 ;; `choke-request-accept-article GROUP &optional LAST'
11130 ;; The contents of the current buffer will be put into GROUP. There
11131 ;; should, of course, be an article in the current buffer. This
11132 ;; function is normally only called by the function described above,
11133 ;; and LAST works the same way as in that function.
11135 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11136 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11137 ;; This provides an easy interface for allowing editing of
11138 ;; articles. Note that even headers may be edited, so the backend has
11139 ;; to update any tables (nov buffers, etc) that it maintains after
11140 ;; replacing the article.
11142 ;; `choke-request-create-group GROUP &optional SERVER'
11143 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11144 ;; might be a group that already exists, but hasn't been registered
11147 ;; All these functions must return nil if they couldn't service the
11148 ;; request. If the optional arguments are not supplied, some "current"
11149 ;; or "default" values should be used. In short, one should emulate an
11150 ;; NNTP server, in a way.
11152 ;; If you want to write a new backend, you just have to supply the
11153 ;; functions listed above. In addition, you must enter the new backend
11154 ;; into the list of valid select methods:
11155 ;; (setq gnus-valid-select-methods
11156 ;; (cons '("choke" mail) gnus-valid-select-methods))
11157 ;; The first element in this list is the name of the backend. Other
11158 ;; elemnets may be `mail' (for mail groups), `post' (for news
11159 ;; groups), `none' (neither), `respool' (for groups that can control
11160 ;; their contents).
11162 (defun gnus-start-news-server (&optional confirm)
11163 "Open a method for getting news.
11164 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11166 (if gnus-current-select-method
11167 ;; Stream is already opened.
11169 ;; Open NNTP server.
11170 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11173 ;; Read server name with completion.
11174 (setq gnus-nntp-server
11175 (completing-read "NNTP server: "
11176 (mapcar (lambda (server) (list server))
11177 (cons (list gnus-nntp-server)
11178 gnus-secondary-servers))
11179 nil nil gnus-nntp-server))))
11181 (if (and gnus-nntp-server
11182 (stringp gnus-nntp-server)
11183 (not (string= gnus-nntp-server "")))
11184 (setq gnus-select-method
11185 (cond ((or (string= gnus-nntp-server "")
11186 (string= gnus-nntp-server "::"))
11187 (list 'nnspool (system-name)))
11188 ((string-match "^:" gnus-nntp-server)
11189 (list 'nnmh gnus-nntp-server
11190 (list 'nnmh-directory
11191 (file-name-as-directory
11193 (concat "~/" (substring
11194 gnus-nntp-server 1)))))
11195 (list 'nnmh-get-new-mail nil)))
11197 (list 'nntp gnus-nntp-server)))))
11199 (setq how (car gnus-select-method))
11200 (cond ((eq how 'nnspool)
11202 (gnus-message 5 "Looking up local news spool..."))
11205 (gnus-message 5 "Looking up mh spool..."))
11208 (setq gnus-current-select-method gnus-select-method)
11209 (run-hooks 'gnus-open-server-hook)
11211 ;; gnus-open-server-hook might have opened it
11212 (gnus-server-opened gnus-select-method)
11213 (gnus-open-server gnus-select-method)
11216 "%s server on %s can't be opened. Continue? "
11217 (car gnus-select-method) (nth 1 gnus-select-method)))
11219 (gnus-message 1 "Couldn't open server on %s"
11220 (nth 1 gnus-select-method))
11224 (defun gnus-check-news-server (&optional method)
11225 "If the news server is down, start it up again."
11226 (let ((method (if method method gnus-select-method)))
11227 (and (stringp method)
11228 (setq method (gnus-server-to-method method)))
11229 (if (gnus-server-opened method)
11230 ;; Stream is already opened.
11233 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11234 (run-hooks 'gnus-open-server-hook)
11235 (or (gnus-server-opened method)
11236 (gnus-open-server method))
11239 (defun gnus-nntp-message (&optional message)
11240 "Check the status of the NNTP server.
11241 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11242 is returned insted of the status string."
11243 (let ((status (gnus-status-message (gnus-find-method-for-group
11244 gnus-newsgroup-name)))
11245 (message (or message "")))
11246 (if (and (stringp status) (> (length status) 0))
11249 (defun gnus-get-function (method function)
11250 (and (stringp method)
11251 (setq method (gnus-server-to-method method)))
11252 (let ((func (intern (format "%s-%s" (car method) function))))
11253 (if (not (fboundp func))
11255 (require (car method))
11256 (if (not (fboundp func))
11257 (error "No such function: %s" func))))
11260 ;;; Interface functions to the backends.
11262 (defun gnus-open-server (method)
11263 (funcall (gnus-get-function method 'open-server)
11264 (nth 1 method) (nthcdr 2 method)))
11266 (defun gnus-close-server (method)
11267 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11269 (defun gnus-request-list (method)
11270 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11272 (defun gnus-request-list-newsgroups (method)
11273 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11275 (defun gnus-request-newgroups (date method)
11276 (funcall (gnus-get-function method 'request-newgroups)
11277 date (nth 1 method)))
11279 (defun gnus-server-opened (method)
11280 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11282 (defun gnus-status-message (method)
11283 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11285 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11287 (defun gnus-request-group (group &optional dont-check)
11288 (let ((method (gnus-find-method-for-group group)))
11289 ; (and t (message "%s GROUP %s" (car method) group))
11290 (funcall (gnus-get-function method 'request-group)
11291 (gnus-group-real-name group) (nth 1 method) dont-check)))
11293 (defun gnus-request-asynchronous (group &optional articles)
11294 (let ((method (gnus-find-method-for-group group)))
11295 (funcall (gnus-get-function method 'request-asynchronous)
11296 (gnus-group-real-name group) (nth 1 method) articles)))
11298 (defun gnus-list-active-group (group)
11299 (let ((method (gnus-find-method-for-group group))
11300 (func 'list-active-group))
11301 (and (gnus-check-backend-function func group)
11302 (funcall (gnus-get-function method func)
11303 (gnus-group-real-name group) (nth 1 method)))))
11305 (defun gnus-request-group-description (group)
11306 (let ((method (gnus-find-method-for-group group))
11307 (func 'request-group-description))
11308 (and (gnus-check-backend-function func group)
11309 (funcall (gnus-get-function method func)
11310 (gnus-group-real-name group) (nth 1 method)))))
11312 (defun gnus-close-group (group)
11313 (let ((method (gnus-find-method-for-group group)))
11314 (funcall (gnus-get-function method 'close-group)
11315 (gnus-group-real-name group) (nth 1 method))))
11317 (defun gnus-retrieve-headers (articles group)
11318 (let ((method (gnus-find-method-for-group group)))
11319 (if (and gnus-use-cache (numberp (car articles)))
11320 (gnus-cache-retrieve-headers articles group)
11321 (funcall (gnus-get-function method 'retrieve-headers)
11322 articles (gnus-group-real-name group) (nth 1 method)))))
11324 (defun gnus-retrieve-groups (groups method)
11325 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11327 (defun gnus-request-article (article group &optional buffer)
11328 (let ((method (gnus-find-method-for-group group)))
11329 (funcall (gnus-get-function method 'request-article)
11330 article (gnus-group-real-name group) (nth 1 method) buffer)))
11332 (defun gnus-request-head (article group)
11333 (let ((method (gnus-find-method-for-group group)))
11334 (funcall (gnus-get-function method 'request-head)
11335 article (gnus-group-real-name group) (nth 1 method))))
11337 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11338 (defun gnus-request-post-buffer (post group subject header artbuf
11339 info follow-to respect-poster)
11340 (let* ((info (or info (and group (nth 2 (gnus-gethash
11341 group gnus-newsrc-hashtb)))))
11343 (if (and gnus-post-method
11344 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11346 (format "%s" (car (gnus-find-method-for-group
11347 gnus-newsgroup-name)))
11348 gnus-valid-select-methods)))
11350 (gnus-find-method-for-group gnus-newsgroup-name))))
11351 (or (gnus-server-opened method)
11352 (gnus-open-server method)
11353 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11354 (let ((mail-self-blind nil)
11355 (mail-archive-file-name nil))
11356 (funcall (gnus-get-function method 'request-post-buffer)
11357 post group subject header artbuf info follow-to
11360 (defun gnus-request-post (method &optional force)
11361 (and (stringp method)
11362 (setq method (gnus-server-to-method method)))
11363 (and (not force) gnus-post-method
11364 (memq 'post (assoc (format "%s" (car method))
11365 gnus-valid-select-methods))
11366 (setq method gnus-post-method))
11367 (funcall (gnus-get-function method 'request-post)
11370 (defun gnus-request-expire-articles (articles group &optional force)
11371 (let ((method (gnus-find-method-for-group group)))
11372 (funcall (gnus-get-function method 'request-expire-articles)
11373 articles (gnus-group-real-name group) (nth 1 method)
11376 (defun gnus-request-move-article
11377 (article group server accept-function &optional last)
11378 (let ((method (gnus-find-method-for-group group)))
11379 (funcall (gnus-get-function method 'request-move-article)
11380 article (gnus-group-real-name group)
11381 (nth 1 method) accept-function last)))
11383 (defun gnus-request-accept-article (group &optional last)
11384 (let ((func (if (symbolp group) group
11385 (car (gnus-find-method-for-group group)))))
11386 (funcall (intern (format "%s-request-accept-article" func))
11387 (if (stringp group) (gnus-group-real-name group) group)
11390 (defun gnus-request-replace-article (article group buffer)
11391 (let ((func (car (gnus-find-method-for-group group))))
11392 (funcall (intern (format "%s-request-replace-article" func))
11393 article (gnus-group-real-name group) buffer)))
11395 (defun gnus-request-create-group (group)
11396 (let ((method (gnus-find-method-for-group group)))
11397 (funcall (gnus-get-function method 'request-create-group)
11398 (gnus-group-real-name group) (nth 1 method))))
11400 (defun gnus-member-of-valid (symbol group)
11401 (memq symbol (assoc
11402 (format "%s" (car (gnus-find-method-for-group group)))
11403 gnus-valid-select-methods)))
11405 (defsubst gnus-secondary-method-p (method)
11406 (member method gnus-secondary-select-methods))
11408 (defun gnus-find-method-for-group (group &optional info)
11409 (or gnus-override-method
11411 gnus-select-method)
11412 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11415 (not (setq method (nth 4 info))))
11416 (setq method gnus-select-method)
11418 (cond ((stringp method)
11419 (gnus-server-to-method method))
11420 ((stringp (car method))
11421 (gnus-server-extend-method group method))
11424 (gnus-server-add-address method))))
11426 (defun gnus-check-backend-function (func group)
11427 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11429 (fboundp (intern (format "%s-%s" method func)))))
11431 (defun gnus-methods-using (method)
11432 (let ((valids gnus-valid-select-methods)
11435 (if (memq method (car valids))
11436 (setq outs (cons (car valids) outs)))
11437 (setq valids (cdr valids)))
11441 ;;; Active & Newsrc File Handling
11444 ;; Newsrc related functions.
11445 ;; Gnus internal format of gnus-newsrc-alist:
11446 ;; (("alt.general" 3 (1 . 1))
11447 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11448 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11449 ;; The first item is the group name; the second is the subscription
11450 ;; level; the third is either a range of a list of ranges of read
11451 ;; articles, the optional fourth element is a list of marked articles,
11452 ;; the optional fifth element is the select method.
11454 ;; Gnus internal format of gnus-newsrc-hashtb:
11455 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11456 ;; This is the entry for "alt.misc". The first element is the number
11457 ;; of unread articles in "alt.misc". The cdr of this entry is the
11458 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11459 ;; trivial to remove or add new elements into gnus-newsrc-alist
11460 ;; without scanning the entire list. So, to get the actual information
11461 ;; of "alt.misc", you'd say something like
11462 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11464 ;; Gnus internal format of gnus-active-hashtb:
11468 ;; The only element in each entry in this hash table is a range of
11469 ;; (possibly) available articles. (Articles in this range may have
11470 ;; been expired or canceled.)
11472 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11473 ;; ("alt.misc" "alt.test" "alt.general" ...)
11475 (defun gnus-setup-news (&optional rawfile level)
11476 "Setup news information.
11477 If RAWFILE is non-nil, the .newsrc file will also be read.
11478 If LEVEL is non-nil, the news will be set up at level LEVEL."
11479 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
11480 ;; Clear some variables to re-initialize news information.
11481 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
11483 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11484 (if init (gnus-read-newsrc-file rawfile))
11486 ;; Read the active file and create `gnus-active-hashtb'.
11487 ;; If `gnus-read-active-file' is nil, then we just create an empty
11488 ;; hash table. The partial filling out of the hash table will be
11489 ;; done in `gnus-get-unread-articles'.
11490 (if (and gnus-read-active-file
11492 (gnus-read-active-file)
11493 (setq gnus-active-hashtb (make-vector 4095 0)))
11495 (and init gnus-use-dribble-file (gnus-dribble-read-file))
11497 ;; Find the number of unread articles in each non-dead group.
11498 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
11499 ;; Find new newsgroups and treat them.
11500 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
11501 (gnus-server-opened gnus-select-method))
11502 (gnus-find-new-newsgroups))
11503 (if (and init gnus-check-bogus-newsgroups
11504 gnus-read-active-file (not level)
11505 (gnus-server-opened gnus-select-method))
11506 (gnus-check-bogus-newsgroups))))
11508 (defun gnus-find-new-newsgroups ()
11509 "Search for new newsgroups and add them.
11510 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11511 The `-n' option line from .newsrc is respected."
11513 (or (gnus-check-first-time-used)
11514 (if (or (consp gnus-check-new-newsgroups)
11515 (eq gnus-check-new-newsgroups 'ask-server))
11516 (gnus-ask-server-for-new-groups)
11518 group new-newsgroups)
11519 (or gnus-have-read-active-file (gnus-read-active-file))
11520 (setq gnus-newsrc-last-checked-date (current-time-string))
11521 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11522 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11523 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11526 (setq group (symbol-name sym))
11527 (if (or (gnus-gethash group gnus-killed-hashtb)
11528 (gnus-gethash group gnus-newsrc-hashtb))
11530 (let ((do-sub (gnus-matches-options-n group)))
11531 (cond ((eq do-sub 'subscribe)
11532 (setq groups (1+ groups))
11533 (gnus-sethash group group gnus-killed-hashtb)
11535 gnus-subscribe-options-newsgroup-method group))
11536 ((eq do-sub 'ignore)
11539 (setq groups (1+ groups))
11540 (gnus-sethash group group gnus-killed-hashtb)
11541 (if gnus-subscribe-hierarchical-interactive
11542 (setq new-newsgroups (cons group new-newsgroups))
11543 (funcall gnus-subscribe-newsgroup-method group)))))))
11544 gnus-active-hashtb)
11546 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11547 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11549 (gnus-message 6 "%d new newsgroup%s arrived."
11550 groups (if (> groups 1) "s have" " has")))))))
11552 (defun gnus-matches-options-n (group)
11553 ;; Returns `subscribe' if the group is to be uncoditionally
11554 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
11555 ;; no match for the group.
11557 ;; First we check the two user variables.
11559 ((and gnus-options-subscribe
11560 (string-match gnus-options-subscribe group))
11562 ((and gnus-options-not-subscribe
11563 (string-match gnus-options-not-subscribe group))
11565 ;; Then we go through the list that was retrieved from the .newsrc
11566 ;; file. This list has elements on the form
11567 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11568 ;; is in the reverse order of the options line) is returned.
11570 (let ((regs gnus-newsrc-options-n))
11572 (not (string-match (car (car regs)) group)))
11573 (setq regs (cdr regs)))
11574 (and regs (cdr (car regs)))))))
11576 (defun gnus-ask-server-for-new-groups ()
11577 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11578 (methods (cons gnus-select-method
11580 (and (consp gnus-check-new-newsgroups)
11581 gnus-check-new-newsgroups)
11582 gnus-secondary-select-methods)))
11584 (new-date (current-time-string))
11585 hashtb group new-newsgroups got-new)
11586 ;; Go thorugh both primary and secondary select methods and
11587 ;; request new newsgroups.
11589 (and (or (gnus-server-opened (car methods))
11590 (gnus-open-server (car methods)))
11591 (gnus-request-newgroups date (car methods))
11594 (set-buffer nntp-server-buffer)
11595 (or hashtb (setq hashtb (gnus-make-hashtable
11596 (count-lines (point-min) (point-max)))))
11597 ;; Enter all the new groups in a hashtable.
11598 (gnus-active-to-gnus-format (car methods) hashtb 'ignore)))
11599 (setq methods (cdr methods)))
11600 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11601 ;; Now all new groups from all select methods are in `hashtb'.
11603 (lambda (group-sym)
11604 (setq group (symbol-name group-sym))
11605 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11606 (member group gnus-zombie-list)
11607 (member group gnus-killed-list))
11608 ;; The group is already known.
11610 (and (symbol-value group-sym)
11611 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
11612 (let ((do-sub (gnus-matches-options-n group)))
11613 (cond ((eq do-sub 'subscribe)
11614 (setq groups (1+ groups))
11615 (gnus-sethash group group gnus-killed-hashtb)
11617 gnus-subscribe-options-newsgroup-method group))
11618 ((eq do-sub 'ignore)
11621 (setq groups (1+ groups))
11622 (gnus-sethash group group gnus-killed-hashtb)
11623 (if gnus-subscribe-hierarchical-interactive
11624 (setq new-newsgroups (cons group new-newsgroups))
11625 (funcall gnus-subscribe-newsgroup-method group)))))))
11628 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11629 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11631 (gnus-message 6 "%d new newsgroup%s arrived."
11632 groups (if (> groups 1) "s have" " has")))
11635 (defun gnus-check-first-time-used ()
11636 (if (or (> (length gnus-newsrc-alist) 1)
11637 (file-exists-p gnus-startup-file)
11638 (file-exists-p (concat gnus-startup-file ".el"))
11639 (file-exists-p (concat gnus-startup-file ".eld")))
11641 (gnus-message 6 "First time user; subscribing you to default groups")
11642 (or gnus-have-read-active-file (gnus-read-active-file))
11643 (setq gnus-newsrc-last-checked-date (current-time-string))
11644 (let ((groups gnus-default-subscribed-newsgroups)
11648 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11651 (setq group (symbol-name sym))
11652 (let ((do-sub (gnus-matches-options-n group)))
11653 (cond ((eq do-sub 'subscribe)
11654 (gnus-sethash group group gnus-killed-hashtb)
11656 gnus-subscribe-options-newsgroup-method group))
11657 ((eq do-sub 'ignore)
11660 (setq gnus-killed-list (cons group gnus-killed-list))))))
11661 gnus-active-hashtb)
11663 (if (gnus-gethash (car groups) gnus-active-hashtb)
11664 (gnus-group-change-level
11665 (car groups) gnus-level-default-subscribed gnus-level-killed))
11666 (setq groups (cdr groups)))
11667 (gnus-group-make-help-group)
11668 (and gnus-novice-user
11669 (gnus-message 7 "`A k' to list killed groups"))))))
11671 (defun gnus-subscribe-group (group previous &optional method)
11672 (gnus-group-change-level
11674 (list t group gnus-level-default-subscribed nil nil method)
11676 gnus-level-default-subscribed gnus-level-killed previous t))
11678 ;; `gnus-group-change-level' is the fundamental function for changing
11679 ;; subscription levels of newsgroups. This might mean just changing
11680 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11681 ;; again, which subscribes/unsubscribes a group, which is equally
11682 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11683 ;; from 8-9 to 1-7 means that you remove the group from the list of
11684 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11685 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11686 ;; which is trivial.
11687 ;; ENTRY can either be a string (newsgroup name) or a list (if
11688 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11689 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11691 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11692 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11694 (defun gnus-group-change-level (entry level &optional oldlevel
11695 previous fromkilled)
11696 (let (group info active num)
11697 ;; Glean what info we can from the arguments
11699 (if fromkilled (setq group (nth 1 entry))
11700 (setq group (car (nth 2 entry))))
11701 (setq group entry))
11702 (if (and (stringp entry)
11704 (< oldlevel gnus-level-zombie))
11705 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11706 (if (and (not oldlevel)
11708 (setq oldlevel (car (cdr (nth 2 entry)))))
11709 (if (stringp previous)
11710 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11712 (gnus-dribble-enter
11713 (format "(gnus-group-change-level %S %S %S %S %S)"
11714 group level oldlevel (car (nth 2 previous)) fromkilled))
11716 ;; Then we remove the newgroup from any old structures, if needed.
11717 ;; If the group was killed, we remove it from the killed or zombie
11718 ;; list. If not, and it is in fact going to be killed, we remove
11719 ;; it from the newsrc hash table and assoc.
11720 (cond ((>= oldlevel gnus-level-zombie)
11721 (if (= oldlevel gnus-level-zombie)
11722 (setq gnus-zombie-list (delete group gnus-zombie-list))
11723 (setq gnus-killed-list (delete group gnus-killed-list))))
11725 (if (>= level gnus-level-zombie)
11727 (gnus-sethash (car (nth 2 entry))
11728 nil gnus-newsrc-hashtb)
11730 (setcdr (gnus-gethash (car (nth 3 entry))
11731 gnus-newsrc-hashtb)
11733 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11735 ;; Finally we enter (if needed) the list where it is supposed to
11736 ;; go, and change the subscription level. If it is to be killed,
11737 ;; we enter it into the killed or zombie list.
11738 (cond ((>= level gnus-level-zombie)
11739 ;; Remove from the hash table.
11740 (gnus-sethash group nil gnus-newsrc-hashtb)
11741 (or (gnus-group-foreign-p group)
11742 ;; We do not enter foreign groups into the list of dead
11744 (if (= level gnus-level-zombie)
11745 (setq gnus-zombie-list (cons group gnus-zombie-list))
11746 (setq gnus-killed-list (cons group gnus-killed-list)))))
11748 ;; If the list is to be entered into the newsrc assoc, and
11749 ;; it was killed, we have to create an entry in the newsrc
11750 ;; hashtb format and fix the pointers in the newsrc assoc.
11751 (if (>= oldlevel gnus-level-zombie)
11755 (setq info (cdr entry))
11756 (setq num (car entry)))
11757 (setq active (gnus-gethash group gnus-active-hashtb))
11758 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11759 ;; Check whether the group is foreign. If so, the
11760 ;; foreign select method has to be entered into the
11762 (let ((method (gnus-group-method-name group)))
11763 (if (eq method gnus-select-method)
11764 (setq info (list group level nil))
11765 (setq info (list group level nil nil method)))))
11768 (let ((p gnus-newsrc-alist))
11769 (while (cdr (cdr p))
11772 (setq entry (cons info (cdr (cdr previous))))
11775 (setcdr (cdr previous) entry)
11776 (gnus-sethash group (cons num (cdr previous))
11777 gnus-newsrc-hashtb))
11778 (setcdr previous entry)
11779 (gnus-sethash group (cons num previous)
11780 gnus-newsrc-hashtb))
11782 (setcdr (gnus-gethash (car (car (cdr entry)))
11783 gnus-newsrc-hashtb)
11785 ;; It was alive, and it is going to stay alive, so we
11786 ;; just change the level and don't change any pointers or
11787 ;; hash table entries.
11788 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11790 (defun gnus-kill-newsgroup (newsgroup)
11791 "Obsolete function. Kills a newsgroup."
11792 (gnus-group-change-level
11793 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11795 (defun gnus-check-bogus-newsgroups (&optional confirm)
11796 "Remove bogus newsgroups.
11797 If CONFIRM is non-nil, the user has to confirm the deletion of every
11799 (let ((newsrc (cdr gnus-newsrc-alist))
11801 (gnus-message 5 "Checking bogus newsgroups...")
11802 (or gnus-have-read-active-file (gnus-read-active-file))
11803 ;; Find all bogus newsgroup that are subscribed.
11805 (setq group (car (car newsrc)))
11806 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
11807 (nth 4 (car newsrc)) ; Foreign
11809 (not (gnus-y-or-n-p
11810 (format "Remove bogus newsgroup: %s " group)))))
11813 ;; Found a bogus newsgroup.
11814 (setq bogus (cons group bogus)))
11815 (setq newsrc (cdr newsrc)))
11816 ;; Remove all bogus subscribed groups by first killing them, and
11817 ;; then removing them from the list of killed groups.
11819 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
11821 (gnus-group-change-level entry gnus-level-killed)
11822 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
11823 (setq bogus (cdr bogus)))
11824 ;; Then we remove all bogus groups from the list of killed and
11825 ;; zombie groups. They are are removed without confirmation.
11826 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11829 (setq killed (symbol-value (car dead-lists)))
11831 (setq group (car killed))
11832 (or (gnus-gethash group gnus-active-hashtb)
11833 ;; The group is bogus.
11834 (set (car dead-lists)
11835 (delete group (symbol-value (car dead-lists)))))
11836 (setq killed (cdr killed)))
11837 (setq dead-lists (cdr dead-lists))))
11838 (gnus-message 5 "Checking bogus newsgroups...done")))
11840 (defun gnus-check-duplicate-killed-groups ()
11841 "Remove duplicates from the list of killed groups."
11843 (let ((killed gnus-killed-list))
11845 (gnus-message 9 "%d" (length killed))
11846 (setcdr killed (delete (car killed) (cdr killed)))
11847 (setq killed (cdr killed)))))
11849 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11850 ;; and compute how many unread articles there are in each group.
11851 (defun gnus-get-unread-articles (&optional level)
11852 (let* ((newsrc (cdr gnus-newsrc-alist))
11853 (level (or level (1+ gnus-level-subscribed)))
11856 (cond ((and gnus-activate-foreign-newsgroups
11857 (not (numberp gnus-activate-foreign-newsgroups)))
11858 (1+ gnus-level-subscribed))
11859 ((numberp gnus-activate-foreign-newsgroups)
11860 gnus-activate-foreign-newsgroups)
11863 info group active virtuals method)
11864 (gnus-message 5 "Checking new news...")
11867 (setq info (car newsrc)
11869 active (gnus-gethash group gnus-active-hashtb))
11871 ;; Check newsgroups. If the user doesn't want to check them, or
11872 ;; they can't be checked (for instance, if the news server can't
11873 ;; be reached) we just set the number of unread articles in this
11874 ;; newsgroup to t. This means that Gnus thinks that there are
11875 ;; unread articles, but it has no idea how many.
11876 (if (and (setq method (nth 4 info))
11877 (not (gnus-server-equal gnus-select-method
11878 (gnus-server-get-method nil method)))
11879 (not (gnus-secondary-method-p method)))
11880 ;; These groups are foreign. Check the level.
11881 (if (<= (nth 1 info) foreign-level)
11882 (if (eq (car (if (stringp method)
11883 (gnus-server-to-method method)
11884 (nth 4 info))) 'nnvirtual)
11885 ;; We have to activate the virtual groups after all
11886 ;; the others, so we just pop them on a list for
11888 (setq virtuals (cons info virtuals))
11889 (and (setq active (gnus-activate-newsgroup (car info)))
11890 ;; Close the groups as we look at them!
11891 (gnus-close-group group))))
11893 ;; These groups are native or secondary.
11894 (if (and (not gnus-have-read-active-file)
11895 (<= (nth 1 info) level))
11896 (setq active (gnus-activate-newsgroup (car info)))))
11899 (gnus-get-unread-articles-in-group info active)
11900 ;; The group couldn't be reached, so we nix out the number of
11901 ;; unread articles and stuff.
11902 (gnus-sethash group nil gnus-active-hashtb)
11903 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
11905 (setq newsrc (cdr newsrc)))
11907 ;; Activate the virtual groups. This has to be done after all the
11909 ;; !!! If one virtual group contains another virtual group, even
11910 ;; doing it this way might cause problems.
11912 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11913 (gnus-get-unread-articles-in-group (car virtuals) active))
11914 (setq virtuals (cdr virtuals)))
11916 (gnus-message 5 "Checking new news...done")))
11918 ;; Create a hash table out of the newsrc alist. The `car's of the
11919 ;; alist elements are used as keys.
11920 (defun gnus-make-hashtable-from-newsrc-alist ()
11921 (let ((alist gnus-newsrc-alist)
11922 (ohashtb gnus-newsrc-hashtb)
11924 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11926 (setq prev (setq gnus-newsrc-alist
11927 (if (equal (car (car gnus-newsrc-alist))
11930 (cons (list "dummy.group" 0 nil) alist)))))
11932 (gnus-sethash (car (car alist))
11933 (cons (and ohashtb (car (gnus-gethash
11934 (car (car alist)) ohashtb)))
11935 prev) gnus-newsrc-hashtb)
11937 alist (cdr alist)))))
11939 (defun gnus-make-hashtable-from-killed ()
11940 "Create a hash table from the killed and zombie lists."
11941 (let ((lists '(gnus-killed-list gnus-zombie-list))
11943 (setq gnus-killed-hashtb
11944 (gnus-make-hashtable
11945 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11947 (setq list (symbol-value (car lists)))
11948 (setq lists (cdr lists))
11950 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11951 (setq list (cdr list))))))
11953 (defun gnus-get-unread-articles-in-group (info active)
11954 (let* ((range (nth 2 info))
11956 (marked (nth 3 info)))
11957 ;; If a cache is present, we may have to alter the active info.
11958 (and gnus-use-cache
11959 (gnus-cache-possibly-alter-active (car info) active))
11960 ;; Modify the list of read articles according to what articles
11961 ;; are available; then tally the unread articles and add the
11962 ;; number to the group hash table entry.
11963 (cond ((zerop (cdr active))
11966 (setq num (- (1+ (cdr active)) (car active))))
11967 ((not (listp (cdr range)))
11968 ;; Fix a single (num . num) range according to the
11969 ;; active hash table.
11970 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
11971 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
11972 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
11973 ;; Compute number of unread articles.
11974 (setq num (max 0 (- (cdr active)
11975 (- (1+ (cdr range)) (car range))))))
11977 ;; The read list is a list of ranges. Fix them according to
11978 ;; the active hash table.
11979 ;; First peel off any elements that are below the lower
11981 (while (and (cdr range)
11983 (or (and (atom (car (cdr range))) (car (cdr range)))
11984 (car (car (cdr range))))))
11985 (if (numberp (car range))
11988 (or (and (numberp (car (cdr range)))
11990 (cdr (car (cdr range))))))
11991 (setcdr (car range)
11992 (or (and (numberp (nth 1 range)) (nth 1 range))
11993 (cdr (car (cdr range))))))
11994 (setcdr range (cdr (cdr range))))
11995 ;; Adjust the first element to be the same as the lower limit.
11996 (if (and (not (atom (car range)))
11997 (< (cdr (car range)) (car active)))
11998 (setcdr (car range) (1- (car active))))
11999 ;; Then we want to peel off any elements that are higher
12000 ;; than the upper active limit.
12001 (let ((srange range))
12002 ;; Go past all legal elements.
12003 (while (and (cdr srange)
12004 (<= (or (and (atom (car (cdr srange)))
12005 (car (cdr srange)))
12006 (car (car (cdr srange)))) (cdr active)))
12007 (setq srange (cdr srange)))
12009 ;; Nuke all remaining illegal elements.
12010 (setcdr srange nil))
12012 ;; Adjust the final element.
12013 (if (and (not (atom (car srange)))
12014 (> (cdr (car srange)) (cdr active)))
12015 (setcdr (car srange) (cdr active))))
12016 ;; Compute the number of unread articles.
12018 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12019 (cdr (car range))))
12020 (or (and (atom (car range)) (car range))
12021 (car (car range))))))
12022 (setq range (cdr range)))
12023 (setq num (max 0 (- (cdr active) num)))))
12026 (and (assq 'tick marked)
12027 (inline (gnus-remove-illegal-marked-articles
12028 (assq 'tick marked) (nth 2 info))))
12029 (and (assq 'dormant marked)
12030 (inline (gnus-remove-illegal-marked-articles
12031 (assq 'dormant marked) (nth 2 info))))
12033 (gnus-gethash (car info) gnus-newsrc-hashtb)
12034 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12035 (length (cdr (assq 'dormant marked)))))))))
12038 (defun gnus-remove-illegal-marked-articles (marked ranges)
12039 (let ((m (cdr marked)))
12040 ;; Make sure that all ticked articles are a subset of the unread
12043 (if (gnus-member-of-range (car m) ranges)
12044 (setcdr marked (cdr m))
12046 (setq m (cdr m)))))
12048 (defun gnus-activate-newsgroup (group)
12049 (let ((method (gnus-find-method-for-group group))
12051 (and (or (gnus-server-opened method) (gnus-open-server method))
12052 (gnus-request-group group)
12054 (set-buffer nntp-server-buffer)
12055 (goto-char (point-min))
12056 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12058 (goto-char (match-beginning 1))
12060 group (setq active (cons (read (current-buffer))
12061 (read (current-buffer))))
12062 gnus-active-hashtb))
12065 (defun gnus-update-read-articles
12066 (group unread unselected ticked &optional domarks replied expirable killed
12067 dormant bookmark score)
12068 "Update the list of read and ticked articles in GROUP using the
12069 UNREAD and TICKED lists.
12070 Note: UNSELECTED has to be sorted over `<'.
12071 Returns whether the updating was successful."
12072 (let* ((active (or gnus-newsgroup-active
12073 (gnus-gethash group gnus-active-hashtb)))
12074 (entry (gnus-gethash group gnus-newsrc-hashtb))
12075 (info (nth 2 entry))
12076 (marked (nth 3 info))
12078 (unread (sort (copy-sequence unread) (function <)))
12080 (if (or (not info) (not active))
12081 ;; There is no info on this group if it was, in fact,
12082 ;; killed. Gnus stores no information on killed groups, so
12083 ;; there's nothing to be done.
12084 ;; One could store the information somewhere temporarily,
12085 ;; perhaps... Hmmm...
12087 ;; Remove any negative articles numbers.
12088 (while (and unread (< (car unread) 0))
12089 (setq unread (cdr unread)))
12090 ;; Remove any expired article numbers
12091 (while (and unread (< (car unread) (car active)))
12092 (setq unread (cdr unread)))
12093 (while (and ticked (< (car ticked) (car active)))
12094 (setq ticked (cdr ticked)))
12095 (while (and dormant (< (car dormant) (car active)))
12096 (setq dormant (cdr dormant)))
12097 (setq unread (sort (append unselected unread) '<))
12098 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12099 (setcar entry (max 0 (- (length unread) (length ticked)
12100 (length dormant))))
12101 ;; Compute the ranges of read articles by looking at the list of
12102 ;; unread articles.
12104 (if (/= (car unread) prev)
12105 (setq read (cons (if (= prev (1- (car unread))) prev
12106 (cons prev (1- (car unread)))) read)))
12107 (setq prev (1+ (car unread)))
12108 (setq unread (cdr unread)))
12109 (if (<= prev (cdr active))
12110 (setq read (cons (cons prev (cdr active)) read)))
12111 ;; Enter this list into the group info.
12112 (setcar (cdr (cdr info))
12113 (if (> (length read) 1) (nreverse read) read))
12114 ;; Enter the list of ticked articles.
12115 (gnus-set-marked-articles
12117 (if domarks replied (cdr (assq 'reply marked)))
12118 (if domarks expirable (cdr (assq 'expire marked)))
12119 (if domarks killed (cdr (assq 'killed marked)))
12120 (if domarks dormant (cdr (assq 'dormant marked)))
12121 (if domarks bookmark (cdr (assq 'bookmark marked)))
12122 (if domarks score (cdr (assq 'score marked))))
12125 (defun gnus-make-articles-unread (group articles)
12126 "Mark ARTICLES in GROUP as unread."
12127 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12128 (gnus-gethash (gnus-group-real-name group)
12129 gnus-newsrc-hashtb))))
12130 (ranges (nth 2 info))
12133 (and (gnus-member-of-range (car articles) ranges)
12134 (setq news (cons (car articles) news)))
12135 (setq articles (cdr articles)))
12138 (setcar (nthcdr 2 info)
12139 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12140 (gnus-group-update-group group t))))
12142 ;; Get the active file(s) from the backend(s).
12143 (defun gnus-read-active-file ()
12144 (gnus-group-set-mode-line)
12145 (let ((methods (if (or (gnus-server-opened gnus-select-method)
12146 (gnus-open-server gnus-select-method))
12147 ;; The native server is available.
12148 (cons gnus-select-method gnus-secondary-select-methods)
12149 ;; The native server is down, so we just do the
12151 gnus-secondary-select-methods))
12153 (setq gnus-have-read-active-file nil)
12155 (set-buffer nntp-server-buffer)
12157 (let* ((where (nth 1 (car methods)))
12158 (mesg (format "Reading active file%s via %s..."
12159 (if (and where (not (zerop (length where))))
12160 (concat " from " where) "")
12161 (car (car methods)))))
12162 (gnus-message 5 mesg)
12163 (gnus-check-news-server (car methods))
12165 ((and (eq gnus-read-active-file 'some)
12166 (gnus-check-backend-function
12167 'retrieve-groups (car (car methods))))
12168 (let ((newsrc (cdr gnus-newsrc-alist))
12171 (and (gnus-server-equal
12172 (gnus-find-method-for-group
12173 (car (car newsrc)) (car newsrc))
12174 (gnus-server-get-method nil (car methods)))
12175 (setq groups (cons (car (car newsrc)) groups)))
12176 (setq newsrc (cdr newsrc)))
12177 (setq list-type (gnus-retrieve-groups groups (car methods)))
12178 (cond ((not list-type)
12180 1 "Cannot read partial active file from %s server."
12181 (car (car methods)))
12184 ((eq list-type 'active)
12185 (gnus-active-to-gnus-format (car methods)))
12187 (gnus-groups-to-gnus-format (car methods))))))
12189 (if (not (gnus-request-list (car methods)))
12191 (gnus-message 1 "Cannot read active file from %s server."
12192 (car (car methods)))
12194 (gnus-active-to-gnus-format (car methods))
12195 (setq gnus-have-read-active-file t)
12196 (gnus-message 5 "%sdone" mesg)))))
12197 (setq methods (cdr methods))))))
12199 ;; Read an active file and place the results in `gnus-active-hashtb'.
12200 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12201 (let ((cur (current-buffer))
12203 (if (and gnus-active-hashtb
12204 (not (equal method gnus-select-method)))
12206 (setq gnus-active-hashtb
12207 (if (equal method gnus-select-method)
12208 (gnus-make-hashtable
12209 (count-lines (point-min) (point-max)))
12210 (gnus-make-hashtable 4096)))))))
12211 ;; Delete unnecessary lines.
12212 (goto-char (point-min))
12213 (while (search-forward "\nto." nil t)
12214 (delete-region (1+ (match-beginning 0))
12215 (progn (forward-line 1) (point))))
12216 (or (string= gnus-ignored-newsgroups "")
12218 (goto-char (point-min))
12219 (delete-matching-lines gnus-ignored-newsgroups)))
12220 ;; If these are groups from a foreign select method, we insert the
12221 ;; group prefix in front of the group names.
12222 (and method (not (eq method gnus-select-method))
12223 (let ((prefix (gnus-group-prefixed-name "" method)))
12224 (goto-char (point-min))
12225 (while (and (not (eobp))
12226 (progn (insert prefix)
12227 (zerop (forward-line 1)))))))
12228 (goto-char (point-min))
12229 ;; Store active file in hashtable.
12230 (goto-char (point-min))
12231 (if (string-match "%[oO]" gnus-group-line-format)
12232 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12233 ;; If we want information on moderated groups, we use this
12235 (let* ((mod-hashtb (make-vector 7 0))
12236 (m (intern "m" mod-hashtb))
12238 (while (not (eobp))
12239 (condition-case nil
12241 (narrow-to-region (point) (gnus-point-at-eol))
12242 (setq group (let ((obarray hashtb)) (read cur)))
12243 (if (and (numberp (setq max (read cur)))
12244 (numberp (setq min (read cur))))
12245 (set group (cons min max))
12247 ;; Enter moderated groups into a list.
12248 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12249 (setq gnus-moderated-list
12250 (cons (symbol-name group) gnus-moderated-list))))
12254 ;; And if we do not care about moderation, we use this loop,
12255 ;; which is faster.
12256 (let (group max min)
12257 (while (not (eobp))
12260 (narrow-to-region (point) (gnus-point-at-eol))
12261 ;; group gets set to a symbol interned in the hash table
12263 (setq group (let ((obarray hashtb)) (read cur)))
12264 (if (and (numberp (setq max (read cur)))
12265 (numberp (setq min (read cur))))
12266 (set group (cons min max))
12273 (gnus-message 3 "Warning - illegal active: %s"
12275 (gnus-point-at-bol) (gnus-point-at-eol)))
12278 (forward-line 1))))))
12280 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12281 ;; Parse a "groups" active file.
12282 (let ((cur (current-buffer))
12286 (setq gnus-active-hashtb
12287 (gnus-make-hashtable
12288 (count-lines (point-min) (point-max)))))))
12289 (prefix (and method (not (eq method gnus-select-method))
12290 (gnus-group-prefixed-name "" method))))
12292 (goto-char (point-min))
12294 ;; We split this into to separate loops, one with the prefix
12295 ;; and one without to speed the reading up somewhat.
12297 (let (min max opoint)
12298 (while (not (eobp))
12299 (read cur) (read cur)
12300 (setq min (read cur)
12303 (skip-chars-forward " \t")
12306 (set (let ((obarray hashtb)) (read cur))
12310 (while (not (eobp))
12311 (if (= (following-char) ?2)
12313 (read cur) (read cur)
12314 (setq min (read cur)
12316 (set (let ((obarray hashtb)) (read cur))
12318 (forward-line 1))))
12320 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
12322 (defun gnus-read-newsrc-file (&optional force)
12323 "Read startup file.
12324 If FORCE is non-nil, the .newsrc file is read."
12325 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12326 ;; Reset variables that might be defined in the .newsrc.eld file.
12327 (let ((variables gnus-variable-list))
12329 (set (car variables) nil)
12330 (setq variables (cdr variables))))
12331 (let* ((newsrc-file gnus-current-startup-file)
12332 (quick-file (concat newsrc-file ".el")))
12334 ;; We always load the .newsrc.eld file. If always contains
12335 ;; much information that can not be gotten from the .newsrc
12336 ;; file (ticked articles, killed groups, foreign methods, etc.)
12337 (gnus-read-newsrc-el-file quick-file)
12340 (and (file-newer-than-file-p newsrc-file quick-file)
12341 (file-newer-than-file-p newsrc-file
12342 (concat quick-file "d")))
12343 (not gnus-newsrc-alist))
12344 ;; We read the .newsrc file. Note that if there if a
12345 ;; .newsrc.eld file exists, it has already been read, and
12346 ;; the `gnus-newsrc-hashtb' has been created. While reading
12347 ;; the .newsrc file, Gnus will only use the information it
12348 ;; can find there for changing the data already read -
12349 ;; ie. reading the .newsrc file will not trash the data
12350 ;; already read (except for read articles).
12352 (gnus-message 5 "Reading %s..." newsrc-file)
12353 (set-buffer (find-file-noselect newsrc-file))
12354 (buffer-disable-undo (current-buffer))
12355 (gnus-newsrc-to-gnus-format)
12356 (kill-buffer (current-buffer))
12357 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12359 (defun gnus-read-newsrc-el-file (file)
12360 (let ((ding-file (concat file "d")))
12361 ;; We always, always read the .eld file.
12362 (gnus-message 5 "Reading %s..." ding-file)
12363 (let (gnus-newsrc-assoc)
12364 (condition-case nil
12365 (load ding-file t t t)
12367 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12368 (let ((inhibit-quit t))
12369 (gnus-uncompress-newsrc-alist))
12370 (gnus-make-hashtable-from-newsrc-alist)
12371 (if (not (file-newer-than-file-p file ding-file))
12373 ;; Old format quick file
12374 (gnus-message 5 "Reading %s..." file)
12375 ;; The .el file is newer than the .eld file, so we read that one
12377 (gnus-read-old-newsrc-el-file file))))
12379 ;; Parse the old-style quick startup file
12380 (defun gnus-read-old-newsrc-el-file (file)
12381 (let (newsrc killed marked group m)
12383 (let ((gnus-killed-assoc nil)
12384 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12386 (condition-case nil
12389 (setq newsrc gnus-newsrc-assoc
12390 killed gnus-killed-assoc
12391 marked gnus-marked-assoc)))
12392 (setq gnus-newsrc-alist nil)
12394 (setq group (car newsrc))
12395 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12398 (setcar (nthcdr 2 info) (cdr (cdr group)))
12400 (if (nth 1 group) gnus-level-default-subscribed
12401 gnus-level-default-unsubscribed))
12402 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
12403 (setq gnus-newsrc-alist
12407 (if (nth 1 group) gnus-level-default-subscribed
12408 gnus-level-default-unsubscribed)
12409 (cdr (cdr group))))
12410 gnus-newsrc-alist)))
12411 (if (setq m (assoc (car group) marked))
12412 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12413 (setq newsrc (cdr newsrc)))
12414 (setq newsrc killed)
12416 (setcar newsrc (car (car newsrc)))
12417 (setq newsrc (cdr newsrc)))
12418 (setq gnus-killed-list killed))
12419 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
12420 (gnus-make-hashtable-from-newsrc-alist)))
12422 (defun gnus-make-newsrc-file (file)
12423 "Make server dependent file name by catenating FILE and server host name."
12424 (let* ((file (expand-file-name file nil))
12425 (real-file (concat file "-" (nth 1 gnus-select-method))))
12426 (if (file-exists-p real-file)
12429 (defun gnus-uncompress-newsrc-alist ()
12430 ;; Uncompress all lists of marked articles in the newsrc assoc.
12431 (let ((newsrc gnus-newsrc-alist)
12434 (if (not (setq marked (nth 3 (car newsrc))))
12437 (or (eq 'score (car (car marked)))
12438 (eq 'bookmark (car (car marked)))
12439 (eq 'killed (car (car marked)))
12440 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12441 (setq marked (cdr marked))))
12442 (setq newsrc (cdr newsrc)))))
12444 (defun gnus-compress-newsrc-alist ()
12445 ;; Compress all lists of marked articles in the newsrc assoc.
12446 (let ((newsrc gnus-newsrc-alist)
12449 (if (not (setq marked (nth 3 (car newsrc))))
12452 (or (eq 'score (car (car marked)))
12453 (eq 'bookmark (car (car marked)))
12454 (eq 'killed (car (car marked)))
12455 (setcdr (car marked)
12457 (gnus-compress-sequence
12458 (sort (cdr (car marked)) '<) t)
12459 (error (cdr (car marked))))))
12460 (setq marked (cdr marked))))
12461 (setq newsrc (cdr newsrc)))))
12463 (defun gnus-newsrc-to-gnus-format ()
12464 (setq gnus-newsrc-options "")
12465 (setq gnus-newsrc-options-n nil)
12467 (or gnus-active-hashtb
12468 (setq gnus-active-hashtb (make-vector 4095 0)))
12469 (let ((buf (current-buffer))
12470 (already-read (> (length gnus-newsrc-alist) 1))
12471 group subscribed options-symbol newsrc
12473 (goto-char (point-min))
12474 ;; We intern the symbol `options' in the active hashtb so that we
12475 ;; can `eq' against it later.
12476 (setq options-symbol (intern "options" gnus-active-hashtb))
12478 (while (not (eobp))
12479 ;; We first read the first word on the line by narrowing and
12480 ;; then reading into `gnus-active-hashtb'. Most groups will
12481 ;; already exist in that hashtb, so this will save some string
12485 (progn (skip-chars-forward "^ \t!:\n") (point)))
12486 (goto-char (point-min))
12488 (and (/= (point-min) (point-max))
12489 (let ((obarray gnus-active-hashtb)) (read buf))))
12491 ;; Now, the symbol we have read is either `options' or a group
12492 ;; name. If it is an options line, we just add it to a string.
12494 ((eq symbol options-symbol)
12495 (setq gnus-newsrc-options
12496 ;; This concatting is quite inefficient, but since our
12497 ;; thorough studies show that approx 99.37% of all
12498 ;; .newsrc files only contain a single options line, we
12499 ;; don't give a damn, frankly, my dear.
12500 (concat gnus-newsrc-options
12502 (gnus-point-at-bol)
12503 ;; Options may continue on the next line.
12504 (or (and (re-search-forward "^[^ \t]" nil 'move)
12505 (progn (beginning-of-line) (point)))
12508 ;; It was a group name.
12509 (setq subscribed (= (following-char) ?:)
12510 group (symbol-name symbol)
12513 ;; If the line ends here, this is clearly a buggy line, so
12514 ;; we put point a the beginning of line and let the cond
12515 ;; below do the error handling.
12516 (beginning-of-line)
12517 ;; We skip to the beginning of the ranges.
12518 (skip-chars-forward "!: \t"))
12519 ;; We are now at the beginning of the list of read articles.
12520 ;; We read them range by range.
12523 ((looking-at "[0-9]+")
12524 ;; We narrow and read a number instead of buffer-substring/
12525 ;; string-to-int because it's faster. narrow/widen is
12526 ;; faster than save-restriction/narrow, and save-restriction
12527 ;; produces a garbage object.
12529 (narrow-to-region (match-beginning 0) (match-end 0))
12532 ;; If the next character is a dash, then this is a range.
12533 (if (= (following-char) ?-)
12535 ;; We read the upper bound of the range.
12537 (if (not (looking-at "[0-9]+"))
12538 ;; This is a buggy line, by we pretend that
12539 ;; it's kinda OK. Perhaps the user should be
12541 (setq reads (cons num1 reads))
12545 (narrow-to-region (match-beginning 0)
12550 ;; It was just a simple number, so we add it to the
12552 (setq reads (cons num1 reads)))
12553 ;; If the next char in ?\n, then we have reached the end
12554 ;; of the line and return nil.
12555 (/= (following-char) ?\n))
12556 ((= (following-char) ?\n)
12557 ;; End of line, so we end.
12560 ;; Not numbers and not eol, so this might be a buggy
12562 (or (eobp) ; If it was eob instead of ?\n, we allow it.
12564 ;; The line was buggy.
12566 (gnus-message 3 "Mangled line: %s"
12567 (buffer-substring (gnus-point-at-bol)
12568 (gnus-point-at-eol)))
12572 ;; Skip past ", ". Spaces are illegal in these ranges, but
12573 ;; we allow them, because it's a common mistake to put a
12574 ;; space after the comma.
12575 (skip-chars-forward ", "))
12577 ;; We have already read .newsrc.eld, so we gently update the
12578 ;; data in the hash table with the information we have just
12582 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12585 ;; There is an entry for this file in the alist.
12587 (setcar (nthcdr 2 info) (nreverse reads))
12588 ;; We update the level very gently. In fact, we
12589 ;; only change it if there's been a status change
12590 ;; from subscribed to unsubscribed, or vice versa.
12591 (setq level (nth 1 info))
12592 (cond ((and (<= level gnus-level-subscribed)
12594 (setq level (if reads
12595 gnus-level-default-unsubscribed
12596 (1+ gnus-level-default-unsubscribed))))
12597 ((and (> level gnus-level-subscribed) subscribed)
12598 (setq level gnus-level-default-subscribed)))
12599 (setcar (cdr info) level))
12600 ;; This is a new group.
12601 (setq info (list group
12603 gnus-level-default-subscribed
12605 (1+ gnus-level-subscribed)
12606 gnus-level-default-unsubscribed))
12607 (nreverse reads))))
12608 (setq newsrc (cons info newsrc))))))
12611 (setq newsrc (nreverse newsrc))
12613 (if (not already-read)
12615 ;; We now have two newsrc lists - `newsrc', which is what we
12616 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
12617 ;; what we've read from .newsrc.eld. We have to merge these
12618 ;; lists. We do this by "attaching" any (foreign) groups in the
12619 ;; gnus-newsrc-alist to the (native) group that precedes them.
12620 (let ((rc (cdr gnus-newsrc-alist))
12621 (prev gnus-newsrc-alist)
12624 (or (null (nth 4 (car rc))) ; It's a native group.
12625 (assoc (car (car rc)) newsrc) ; It's already in the alist.
12626 (if (setq entry (assoc (car (car prev)) newsrc))
12627 (setcdr (setq mentry (memq entry newsrc))
12628 (cons (car rc) (cdr mentry)))
12629 (setq newsrc (cons (car rc) newsrc))))
12633 (setq gnus-newsrc-alist newsrc)
12634 ;; We make the newsrc hashtb.
12635 (gnus-make-hashtable-from-newsrc-alist)
12637 ;; Finally, if we read some options lines, we parse them.
12638 (or (string= gnus-newsrc-options "")
12639 (gnus-newsrc-parse-options gnus-newsrc-options))))
12641 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12642 ;; The return value will be a list on the form
12643 ;; ((regexp1 . ignore)
12644 ;; (regexp2 . subscribe)...)
12645 ;; When handling new newsgroups, groups that match a `ignore' regexp
12646 ;; will be ignored, and groups that match a `subscribe' regexp will be
12647 ;; subscribed. A line like
12648 ;; options -n !all rec.all
12649 ;; will lead to a list that looks like
12650 ;; (("^rec\\..+" . subscribe)
12651 ;; ("^.+" . ignore))
12652 ;; So all "rec.*" groups will be subscribed, while all the other
12653 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12654 ;; different from "options -n rec.all !all".
12655 (defun gnus-newsrc-parse-options (options)
12658 (gnus-set-work-buffer)
12659 (insert (regexp-quote options))
12660 ;; First we treat all continuation lines.
12661 (goto-char (point-min))
12662 (while (re-search-forward "\n[ \t]+" nil t)
12663 (replace-match " " t t))
12664 ;; Then we transform all "all"s into ".+"s.
12665 (goto-char (point-min))
12666 (while (re-search-forward "\\ball\\b" nil t)
12667 (replace-match ".+" t t))
12668 (goto-char (point-min))
12669 ;; We remove all other options than the "-n" ones.
12670 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12671 (replace-match " ")
12673 (goto-char (point-min))
12675 ;; We are only interested in "options -n" lines - we
12676 ;; ignore the other option lines.
12677 (while (re-search-forward "[ \t]-n" nil t)
12679 (or (save-excursion
12680 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12682 (gnus-point-at-eol)))
12683 ;; Search for all "words"...
12684 (while (re-search-forward "[^ \t,\n]+" eol t)
12685 (if (= (char-after (match-beginning 0)) ?!)
12686 ;; If the word begins with a bang (!), this is a "not"
12687 ;; spec. We put this spec (minus the bang) and the
12688 ;; symbol `ignore' into the list.
12689 (setq out (cons (cons (concat
12690 "^" (buffer-substring
12691 (1+ (match-beginning 0))
12694 ;; There was no bang, so this is a "yes" spec.
12695 (setq out (cons (cons (concat
12696 "^" (buffer-substring (match-beginning 0)
12698 'subscribe) out)))))
12700 (setq gnus-newsrc-options-n out))))
12703 (defun gnus-save-newsrc-file ()
12704 "Save .newsrc file."
12705 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12706 ;; from the variable gnus-newsrc-alist.
12707 (and (or gnus-newsrc-alist gnus-killed-list)
12708 gnus-current-startup-file
12709 (let ((make-backup-files t)
12710 (version-control nil)
12711 (require-final-newline t)) ;Don't ask even if requested.
12712 ;; You can stop or change version control of backup file.
12713 ;; Suggested by jason@violet.berkeley.edu.
12714 (run-hooks 'gnus-save-newsrc-hook)
12716 (if (or (not gnus-dribble-buffer)
12717 (not (buffer-name gnus-dribble-buffer))
12718 (zerop (save-excursion
12719 (set-buffer gnus-dribble-buffer)
12721 (gnus-message 4 "(No changes need to be saved)")
12722 (if gnus-save-newsrc-file
12724 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12725 ;; Make backup file of master newsrc.
12726 (gnus-gnus-to-newsrc-format)
12727 (gnus-message 5 "Saving %s...done"
12728 gnus-current-startup-file)))
12729 ;; Quickly loadable .newsrc.
12730 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12731 (gnus-add-current-to-buffer-list)
12732 (buffer-disable-undo (current-buffer))
12734 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12735 (gnus-gnus-to-quick-newsrc-format)
12736 (write-region 1 (point-max)
12737 (concat gnus-current-startup-file ".eld")
12739 (kill-buffer (current-buffer))
12740 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
12741 (gnus-dribble-delete-file))))))
12743 (defun gnus-gnus-to-quick-newsrc-format ()
12744 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12745 (insert ";; (ding) Gnus startup file.\n")
12746 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12747 (insert ";; to read .newsrc.\n")
12748 (let ((variables gnus-variable-list)
12750 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12752 ;; insert lisp expressions.
12753 (gnus-compress-newsrc-alist)
12755 (setq variable (car variables))
12756 (and (boundp variable)
12757 (symbol-value variable)
12758 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12759 (insert "(setq " (symbol-name variable) " '"
12760 (prin1-to-string (symbol-value variable))
12762 (setq variables (cdr variables)))
12763 (gnus-uncompress-newsrc-alist)))
12766 (defun gnus-gnus-to-newsrc-format ()
12767 ;; Generate and save the .newsrc file.
12768 (let ((newsrc (cdr gnus-newsrc-alist))
12771 (set-buffer (create-file-buffer gnus-startup-file))
12772 (buffer-disable-undo (current-buffer))
12775 (if gnus-newsrc-options (insert gnus-newsrc-options))
12776 ;; Write subscribed and unsubscribed.
12778 (setq info (car newsrc))
12779 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12781 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12783 (if (setq ranges (nth 2 info))
12786 (if (not (listp (cdr ranges)))
12787 (if (= (car ranges) (cdr ranges))
12788 (insert (int-to-string (car ranges)))
12789 (insert (int-to-string (car ranges)) "-"
12790 (int-to-string (cdr ranges))))
12792 (setq range (car ranges)
12793 ranges (cdr ranges))
12794 (if (or (atom range) (= (car range) (cdr range)))
12795 (insert (int-to-string
12796 (or (and (atom range) range)
12798 (insert (int-to-string (car range)) "-"
12799 (int-to-string (cdr range))))
12800 (if ranges (insert ","))))))
12802 (setq newsrc (cdr newsrc)))
12803 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12804 (kill-buffer (current-buffer)))))
12806 (defun gnus-read-all-descriptions-files ()
12807 (let ((methods (nconc (list gnus-select-method)
12808 gnus-secondary-select-methods)))
12810 (gnus-read-descriptions-file (car methods))
12811 (setq methods (cdr methods)))
12814 (defun gnus-read-descriptions-file (&optional method)
12815 (let ((method (or method gnus-select-method)))
12816 ;; We create the hashtable whether we manage to read the desc file
12817 ;; to avoid trying to re-read after a failed read.
12818 (or gnus-description-hashtb
12819 (setq gnus-description-hashtb
12820 (gnus-make-hashtable (length gnus-active-hashtb))))
12821 ;; Mark this method's desc file as read.
12822 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
12823 gnus-description-hashtb)
12825 (gnus-message 5 "Reading descriptions file via %s..." (car method))
12827 ((not (or (gnus-server-opened method)
12828 (gnus-open-server method)))
12829 (gnus-message 1 "Couldn't open server")
12831 ((not (gnus-request-list-newsgroups method))
12832 (gnus-message 1 "Couldn't read newsgroups descriptions")
12838 (set-buffer nntp-server-buffer)
12839 (goto-char (point-min))
12840 (if (or (search-forward "\n.\n" nil t)
12841 (goto-char (point-max)))
12843 (beginning-of-line)
12844 (narrow-to-region (point-min) (point))))
12845 (goto-char (point-min))
12846 (while (not (eobp))
12847 ;; If we get an error, we set group to 0, which is not a
12851 (let ((obarray gnus-description-hashtb))
12852 ;; Group is set to a symbol interned in this
12854 (read nntp-server-buffer))
12856 (skip-chars-forward " \t")
12857 ;; ... which leads to this line being effectively ignored.
12858 (and (symbolp group)
12859 (set group (buffer-substring
12860 (point) (progn (end-of-line) (point)))))
12861 (forward-line 1))))
12862 (gnus-message 5 "Reading descriptions file...done")
12865 (defun gnus-group-get-description (group)
12866 ;; Get the description of a group by sending XGTITLE to the server.
12867 (and (gnus-request-group-description group)
12869 (set-buffer nntp-server-buffer)
12870 (goto-char (point-min))
12871 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12872 (buffer-substring (match-beginning 1) (match-end 1))))))
12878 (defvar gnus-server-mode-hook nil
12879 "Hook run in `gnus-server-mode' buffers.")
12881 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12882 "Format of server lines.
12883 It works along the same lines as a normal formatting string,
12884 with some simple extensions.")
12886 (defvar gnus-server-mode-line-format "(ding) List of servers"
12887 "The format specification for the server mode line.")
12889 (defconst gnus-server-line-format-alist
12890 (list (list ?h 'how ?s)
12892 (list ?w 'where ?s)
12895 (defconst gnus-server-mode-line-format-alist
12896 (list (list ?S 'news-server ?s)
12897 (list ?M 'news-method ?s)
12898 (list ?u 'user-defined ?s)))
12900 (defvar gnus-server-line-format-spec nil)
12901 (defvar gnus-server-mode-line-format-spec nil)
12902 (defvar gnus-server-killed-servers nil)
12904 (defvar gnus-server-mode-map nil)
12905 (put 'gnus-server-mode 'mode-class 'special)
12907 (if gnus-server-mode-map
12909 (setq gnus-server-mode-map (make-sparse-keymap))
12910 (suppress-keymap gnus-server-mode-map)
12911 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12912 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12913 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12914 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12915 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12916 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12917 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12918 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12919 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12920 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12922 (defun gnus-server-mode ()
12923 "Major mode for listing and editing servers.
12925 All normal editing commands are switched off.
12926 \\<gnus-server-mode-map>
12928 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12930 The following commands are available:
12932 \\{gnus-server-mode-map}"
12934 (if gnus-visual (gnus-server-make-menu-bar))
12935 (kill-all-local-variables)
12936 (setq mode-line-modified "-- ")
12937 (make-local-variable 'mode-line-format)
12938 (setq mode-line-format (copy-sequence mode-line-format))
12939 (and (equal (nth 3 mode-line-format) " ")
12940 (setcar (nthcdr 3 mode-line-format) ""))
12941 (setq major-mode 'gnus-server-mode)
12942 (setq mode-name "Server")
12943 ; (gnus-group-set-mode-line)
12944 (setq mode-line-process nil)
12945 (use-local-map gnus-server-mode-map)
12946 (buffer-disable-undo (current-buffer))
12947 (setq truncate-lines t)
12948 (setq buffer-read-only t)
12949 (run-hooks 'gnus-server-mode-hook))
12951 (defun gnus-server-insert-server-line (sformat name method)
12952 (let* ((sformat (or sformat gnus-server-line-format-spec))
12954 (where (nth 1 method))
12956 (beginning-of-line)
12958 ;; Insert the text.
12959 (insert (eval sformat))
12960 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
12962 (defun gnus-server-setup-buffer ()
12963 (if (get-buffer gnus-server-buffer)
12966 (set-buffer (get-buffer-create gnus-server-buffer))
12968 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
12970 (defun gnus-server-prepare ()
12971 (setq gnus-server-mode-line-format-spec
12972 (gnus-parse-format gnus-server-mode-line-format
12973 gnus-server-mode-line-format-alist))
12974 (setq gnus-server-line-format-spec
12975 (gnus-parse-format gnus-server-line-format
12976 gnus-server-line-format-alist))
12977 (let ((alist gnus-server-alist)
12978 (buffer-read-only nil))
12981 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
12982 (setq alist (cdr alist))))
12983 (goto-char (point-min))
12984 (gnus-server-position-cursor))
12986 (defun gnus-server-server-name ()
12987 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
12988 (and server (symbol-name server))))
12990 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
12992 (defconst gnus-server-edit-buffer "*Gnus edit server*")
12994 (defun gnus-server-update-server (server)
12996 (set-buffer gnus-server-buffer)
12997 (let ((buffer-read-only nil)
12998 (info (cdr (assoc server gnus-server-alist))))
12999 (gnus-dribble-enter
13000 (concat "(gnus-server-set-info \"" server "\" '"
13001 (prin1-to-string info) ")"))
13002 ;; Buffer may be narrowed.
13005 (if (gnus-server-goto-server server)
13006 (delete-region (progn (beginning-of-line) (point))
13007 (progn (forward-line 1) (point))))
13008 (let ((entry (assoc server gnus-server-alist)))
13009 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13010 (gnus-server-position-cursor))))))
13012 (defun gnus-server-set-info (server info)
13013 ;; Enter a select method into the virtual server alist.
13014 (gnus-dribble-enter
13015 (concat "(gnus-server-set-info \"" server "\" '"
13016 (prin1-to-string info) ")"))
13017 (let* ((server (nth 1 info))
13018 (entry (assoc server gnus-server-alist)))
13019 (if entry (setcdr entry info)
13020 (setq gnus-server-alist
13021 (nconc gnus-server-alist (list (cons server info)))))))
13023 (defun gnus-server-to-method (server)
13024 ;; Map virtual server names to select methods.
13025 (or (and (equal server "native") gnus-select-method)
13026 (cdr (assoc server gnus-server-alist))))
13028 (defun gnus-server-extend-method (group method)
13029 ;; This function "extends" a virtual server. If the server is
13030 ;; "hello", and the select method is ("hello" (my-var "something"))
13031 ;; in the group "alt.alt", this will result in a new virtual server
13032 ;; called "helly+alt.alt".
13034 (gnus-copy-sequence
13035 (if (equal (car method) "native") gnus-select-method
13036 (cdr (assoc (car method) gnus-server-alist))))))
13037 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13038 (nconc entry (cdr method))))
13040 (defun gnus-server-get-method (group method)
13041 ;; Input either a server name, and extended server name, or a
13042 ;; select method, and return a select method.
13043 (cond ((stringp method)
13044 (gnus-server-to-method method))
13045 ((stringp (car method))
13046 (gnus-server-extend-method group method))
13048 (gnus-server-add-address method))))
13050 (defun gnus-server-add-address (method)
13051 (let ((method-name (symbol-name (car method))))
13052 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13053 (not (assq (intern (concat method-name "-address")) method)))
13054 (append method (list (list (intern (concat method-name "-address"))
13058 (defun gnus-server-equal (s1 s2)
13060 (and (= (length s1) (length s2))
13062 (while (and s1 (member (car s1) s2))
13063 (setq s1 (cdr s1)))
13066 ;;; Interactive server functions.
13068 (defun gnus-server-kill-server (server)
13069 "Kill the server on the current line."
13070 (interactive (list (gnus-server-server-name)))
13071 (or (gnus-server-goto-server server)
13072 (if server (error "No such server: %s" server)
13073 (error "No server on the current line")))
13074 (let ((buffer-read-only nil))
13075 (delete-region (progn (beginning-of-line) (point))
13076 (progn (forward-line 1) (point))))
13077 (setq gnus-server-killed-servers
13078 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13079 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13080 gnus-server-alist))
13081 (gnus-server-position-cursor))
13083 (defun gnus-server-yank-server ()
13084 "Yank the previously killed server."
13086 (or gnus-server-killed-servers
13087 (error "No killed servers to be yanked"))
13088 (let ((alist gnus-server-alist)
13089 (server (gnus-server-server-name))
13090 (killed (car gnus-server-killed-servers)))
13092 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13093 (if (string= server (car (car gnus-server-alist)))
13094 (setq gnus-server-alist (cons killed gnus-server-alist))
13095 (while (and (cdr alist)
13096 (not (string= server (car (car (cdr alist))))))
13097 (setq alist (cdr alist)))
13098 (setcdr alist (cons killed (cdr alist)))))
13099 (gnus-server-update-server (car killed))
13100 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13101 (gnus-server-position-cursor)))
13103 (defun gnus-server-exit ()
13104 "Return to the group buffer."
13106 (kill-buffer (current-buffer))
13107 (switch-to-buffer gnus-group-buffer))
13109 (defun gnus-server-list-servers ()
13110 "List all available servers."
13112 (let ((cur (gnus-server-server-name)))
13113 (gnus-server-prepare)
13114 (if cur (gnus-server-goto-server cur)
13115 (goto-char (point-max))
13117 (gnus-server-position-cursor)))
13119 (defun gnus-server-copy-server (from to)
13122 (or (gnus-server-server-name)
13123 (error "No server on the current line"))
13124 (read-string "Copy to: ")))
13125 (or from (error "No server on current line"))
13126 (or (and to (not (string= to ""))) (error "No name to copy to"))
13127 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13128 (or (assoc from gnus-server-alist)
13129 (error "%s: no such server" from))
13130 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13131 (setcar to-entry to)
13132 (setcar (nthcdr 2 to-entry) to)
13133 (setq gnus-server-killed-servers
13134 (cons to-entry gnus-server-killed-servers))
13135 (gnus-server-yank-server)))
13137 (defun gnus-server-add-server (how where)
13139 (list (intern (completing-read "Server method: "
13140 gnus-valid-select-methods nil t))
13141 (read-string "Server name: ")))
13142 (setq gnus-server-killed-servers
13143 (cons (list where how where) gnus-server-killed-servers))
13144 (gnus-server-yank-server))
13146 (defun gnus-server-goto-server (server)
13147 "Jump to a server line."
13149 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13150 (let ((to (text-property-any (point-min) (point-max)
13151 'gnus-server (intern server))))
13155 (gnus-server-position-cursor)))))
13157 (defun gnus-server-edit-server (server)
13158 "Edit the server on the current line."
13159 (interactive (list (gnus-server-server-name)))
13161 (error "No server on current line"))
13162 (let ((winconf (current-window-configuration)))
13163 (get-buffer-create gnus-server-edit-buffer)
13164 (gnus-configure-windows 'edit-server)
13165 (gnus-add-current-to-buffer-list)
13167 (make-local-variable 'gnus-prev-winconf)
13168 (setq gnus-prev-winconf winconf)
13169 (use-local-map (copy-keymap (current-local-map)))
13170 (let ((done-func '(lambda ()
13171 "Exit editing mode and update the information."
13173 (gnus-server-edit-server-done 'group))))
13174 (setcar (cdr (nth 4 done-func)) server)
13175 (local-set-key "\C-c\C-c" done-func))
13177 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13178 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13180 (defun gnus-server-edit-server-done (server)
13182 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13183 (goto-char (point-min))
13184 (let ((form (read (current-buffer)))
13185 (winconf gnus-prev-winconf))
13186 (gnus-server-set-info server form)
13187 (kill-buffer (current-buffer))
13188 (and winconf (set-window-configuration winconf))
13189 (set-buffer gnus-server-buffer)
13190 (gnus-server-update-server (gnus-server-server-name))
13191 (gnus-server-position-cursor)))
13193 (defun gnus-server-read-server (server)
13195 (interactive (list (gnus-server-server-name)))
13196 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13198 (defun gnus-mouse-pick-server (e)
13200 (mouse-set-point e)
13201 (gnus-server-read-server (gnus-server-server-name)))
13204 ;;; entry points into gnus-score.el
13207 ;;; Finding score files.
13209 (defvar gnus-global-score-files nil
13210 "*List of global score files and directories.
13211 Set this variable if you want to use people's score files. One entry
13212 for each score file or each score file directory. Gnus will decide
13213 by itself what score files are applicable to which group.
13215 Say you want to use the single score file
13216 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13217 score files in the \"/ftp.some-where:/pub/score\" directory.
13219 (setq gnus-global-score-files
13220 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13221 \"/ftp.some-where:/pub/score\"))")
13223 (defun gnus-score-score-files (group)
13224 "Return a list of all possible score files."
13225 ;; Search and set any global score files.
13226 (and gnus-global-score-files
13227 (or gnus-internal-global-score-files
13228 (gnus-score-search-global-directories gnus-global-score-files)))
13229 ;; Fix the kill-file dir variable.
13230 (setq gnus-kill-files-directory
13231 (file-name-as-directory
13232 (or gnus-kill-files-directory "~/News/")))
13233 ;; If we can't read it, there are no score files.
13234 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13235 (setq gnus-score-file-list nil)
13236 (if (gnus-use-long-file-name 'not-score)
13237 ;; We want long file names.
13238 (if (or (not gnus-score-file-list)
13239 (not (car gnus-score-file-list))
13240 (gnus-file-newer-than gnus-kill-files-directory
13241 (car gnus-score-file-list)))
13242 (setq gnus-score-file-list
13243 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13246 gnus-kill-files-directory t
13247 (gnus-score-file-regexp))))))
13248 ;; We do not use long file names, so we have to do some
13249 ;; directory traversing.
13250 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13251 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13254 (setq dir (expand-file-name
13255 (concat gnus-kill-files-directory
13256 (gnus-replace-chars-in-string group ?. ?/))))
13257 (setq suffix (car suffixes)
13258 suffixes (cdr suffixes))
13259 (if (file-exists-p (concat dir "/" suffix))
13260 (setq files (cons (concat dir "/" suffix) files)))
13261 (while (>= (1+ (length dir)) mdir)
13262 (and (file-exists-p (concat dir "/all/" suffix))
13263 (setq files (cons (concat dir "/all/" suffix) files)))
13264 (string-match "/[^/]*$" dir)
13265 (setq dir (substring dir 0 (match-beginning 0)))))
13266 (setq gnus-score-file-list
13267 (cons nil (nreverse files)))))
13268 (cdr gnus-score-file-list)))
13270 (defun gnus-score-file-regexp ()
13271 (concat "\\(" gnus-score-file-suffix
13272 "\\|" gnus-adaptive-file-suffix "\\)$"))
13274 (defun gnus-score-find-bnews (group)
13275 "Return a list of score files for GROUP.
13276 The score files are those files in the ~/News directory which matches
13277 GROUP using BNews sys file syntax."
13278 (let* ((sfiles (append (gnus-score-score-files group)
13279 gnus-internal-global-score-files))
13280 (kill-dir (file-name-as-directory
13281 (expand-file-name gnus-kill-files-directory)))
13282 (klen (length kill-dir))
13283 ofiles not-match regexp)
13285 (set-buffer (get-buffer-create "*gnus score files*"))
13286 (buffer-disable-undo (current-buffer))
13287 ;; Go through all score file names and create regexp with them
13291 (insert (car sfiles))
13292 (goto-char (point-min))
13293 ;; First remove the suffix itself.
13294 (re-search-forward (concat "." (gnus-score-file-regexp)))
13295 (replace-match "" t t)
13296 (goto-char (point-min))
13297 (if (looking-at (regexp-quote kill-dir))
13298 ;; If the file name was just "SCORE", `klen' is one character
13300 (delete-char (min (1- (point-max)) klen))
13301 (goto-char (point-max))
13302 (search-backward "/")
13303 (delete-region (1+ (point)) (point-min)))
13304 ;; If short file names were used, we have to translate slashes.
13305 (goto-char (point-min))
13306 (while (search-forward "/" nil t)
13307 (replace-match "." t t))
13308 ;; Translate "all" to ".*".
13309 (while (search-forward "all" nil t)
13310 (replace-match ".*" t t))
13311 (goto-char (point-min))
13312 ;; Deal with "not."s.
13313 (if (looking-at "not.")
13316 (setq regexp (buffer-substring 5 (point-max))))
13317 (setq regexp (buffer-substring 1 (point-max)))
13318 (setq not-match nil))
13319 ;; Finally - if this resulting regexp matches the group name,
13320 ;; we add this score file to the list of score files
13321 ;; applicable to this group.
13322 (if (or (and not-match
13323 (not (string-match regexp group)))
13324 (and (not not-match)
13325 (string-match regexp group)))
13326 (setq ofiles (cons (car sfiles) ofiles)))
13327 (setq sfiles (cdr sfiles)))
13328 (kill-buffer (current-buffer))
13329 ;; Slight kludge here - the last score file returned should be
13330 ;; the local score file, whether it exists or not. This is so
13331 ;; that any score commands the user enters will go to the right
13332 ;; file, and not end up in some global score file.
13335 (if (gnus-use-long-file-name 'not-score)
13336 (concat gnus-kill-files-directory group "."
13337 gnus-score-file-suffix)
13338 (concat gnus-kill-files-directory
13339 (gnus-replace-chars-in-string group ?. ?/)
13340 "/" gnus-score-file-suffix)))))
13341 (and (member localscore ofiles)
13342 (delete localscore ofiles))
13343 (setq ofiles (cons localscore ofiles)))
13344 (nreverse ofiles))))
13346 (defun gnus-score-find-single (group)
13347 "Return list containing the score file for GROUP."
13348 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13349 (gnus-score-file-name group)))
13351 (defun gnus-score-find-hierarchical (group)
13352 "Return list of score files for GROUP.
13353 This includes the score file for the group and all its parents."
13354 (let ((all (copy-sequence '(nil)))
13356 (while (string-match "\\." group (1+ start))
13357 (setq start (match-beginning 0))
13358 (setq all (cons (substring group 0 start) all)))
13359 (setq all (cons group all))
13361 (mapcar (lambda (newsgroup)
13362 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
13363 (setq all (nreverse all)))
13364 (mapcar 'gnus-score-file-name all))))
13366 (defvar gnus-score-file-alist-cache nil)
13368 (defun gnus-score-find-alist (group)
13369 "Return list of score files for GROUP.
13370 The list is determined from the variable gnus-score-file-alist."
13371 (let ((alist gnus-score-file-multiple-match-alist)
13373 ;; if this group has been seen before, return the cached entry
13374 (if (setq score-files (assoc group gnus-score-file-alist-cache))
13375 (cdr score-files) ; ensures caching of groups with no matches
13376 ;; handle the multiple match alist
13378 (and (string-match (car (car alist)) group)
13380 (nconc score-files (cdr (car alist)))))
13381 (setq alist (cdr alist)))
13382 (setq alist gnus-score-file-single-match-alist)
13383 ;; handle the single match alist
13386 (and (string-match (car (car alist)) group)
13387 ;; progn used just in case ("regexp") has no files
13388 ;; and score-files is still nil. -sj
13389 ;; this can be construed as a "stop searching here" feature :>
13390 ;; and used to simplify regexps in the single-alist
13393 (append score-files (cdr (car alist))))
13394 (throw 'done nil)))
13395 (setq alist (cdr alist))))
13396 ;; cache the score files
13397 (setq gnus-score-file-alist-cache
13398 (cons (cons group score-files) gnus-score-file-alist-cache))
13402 (defun gnus-possibly-score-headers (&optional trace)
13403 (let ((func gnus-score-find-score-files-function)
13405 (and func (not (listp func))
13406 (setq func (list func)))
13407 ;; Go through all the functions for finding score files (or actual
13408 ;; scores) and add them to a list.
13409 (setq score-files (copy-sequence
13410 (gnus-score-find-alist gnus-newsgroup-name)))
13412 (and (symbolp (car func))
13413 (fboundp (car func))
13415 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
13416 (setq func (cdr func)))
13417 (if score-files (gnus-score-headers score-files trace))))
13419 (defun gnus-score-file-name (newsgroup &optional suffix)
13420 "Return the name of a score file for NEWSGROUP."
13421 (let ((suffix (or suffix gnus-score-file-suffix)))
13422 (cond ((or (null newsgroup)
13423 (string-equal newsgroup ""))
13424 ;; The global score file is placed at top of the directory.
13426 suffix (or gnus-kill-files-directory "~/News")))
13427 ((gnus-use-long-file-name 'not-score)
13428 ;; Append ".SCORE" to newsgroup name.
13429 (expand-file-name (concat newsgroup "." suffix)
13430 (or gnus-kill-files-directory "~/News")))
13432 ;; Place "SCORE" under the hierarchical directory.
13433 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13435 (or gnus-kill-files-directory "~/News"))))))
13437 (defun gnus-score-search-global-directories (files)
13438 "Scan all global score directories for score files."
13439 ;; Set the variable `gnus-internal-global-score-files' to all
13440 ;; available global score files.
13441 (interactive (list gnus-global-score-files))
13444 (if (string-match "/$" (car files))
13445 (setq out (nconc (directory-files
13447 (concat (gnus-score-file-regexp) "$"))))
13448 (setq out (cons (car files) out)))
13449 (setq files (cdr files)))
13450 (setq gnus-internal-global-score-files out)))
13452 ;; Allow redefinition of Gnus functions.
13454 (gnus-ems-redefine)
13458 ;;; gnus.el ends here