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@ftp.hpc.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 t
421 "*If non-nil, marking commands will go to the next unread article.")
423 (defvar gnus-group-goto-unread t
424 "*If non-nil, movement commands will go to the next unread and subscribed group.")
426 (defvar gnus-check-new-newsgroups t
427 "*Non-nil means that Gnus will add new newsgroups at startup.
428 If this variable is `ask-server', Gnus will ask the server for new
429 groups since the last time it checked. This means that the killed list
430 is no longer necessary, so you could set `gnus-save-killed-list' to
433 A variant is to have this variable be a list of select methods. Gnus
434 will then use the `ask-server' method on all these select methods to
435 query for new groups from all those servers.
438 (setq gnus-check-new-newsgroups
439 '((nntp \"some.server\") (nntp \"other.server\")))
441 If this variable is nil, then you have to tell Gnus explicitly to
442 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
444 (defvar gnus-check-bogus-newsgroups nil
445 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
446 If this variable is nil, then you have to tell Gnus explicitly to
447 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
449 (defvar gnus-read-active-file t
450 "*Non-nil means that Gnus will read the entire active file at startup.
451 If this variable is nil, Gnus will only know about the groups in your
454 If this variable is `some', Gnus will try to only read the relevant
455 parts of the active file from the server. Not all servers support
456 this, and it might be quite slow with other servers, but this should
457 generally be faster than both the t and nil value.
459 If you set this variable to nil or `some', you probably still want to
460 be told about new newsgroups that arrive. To do that, set
461 `gnus-check-new-newsgroups' to `ask-server'. This may not work
462 properly with all servers.")
464 (defvar gnus-level-subscribed 5
465 "*Groups with levels less than or equal to this variable are subscribed.")
467 (defvar gnus-level-unsubscribed 7
468 "*Groups with levels less than or equal to this variable are unsubscribed.
469 Groups with levels less than `gnus-level-subscribed', which should be
470 less than this variable, are subscribed.")
472 (defvar gnus-level-zombie 8
473 "*Groups with this level are zombie groups.")
475 (defvar gnus-level-killed 9
476 "*Groups with this level are killed.")
478 (defvar gnus-level-default-subscribed 3
479 "*New subscribed groups will be subscribed at this level.")
481 (defvar gnus-level-default-unsubscribed 6
482 "*New unsubscribed groups will be unsubscribed at this level.")
484 (defvar gnus-activate-foreign-newsgroups nil
485 "*If nil, Gnus will not check foreign newsgroups at startup.
486 If it is non-nil, it should be a number between one and nine. Foreign
487 newsgroups that have a level lower or equal to this number will be
488 activated on startup. For instance, if you want to active all
489 subscribed newsgroups, but not the rest, you'd set this variable to
490 `gnus-level-subscribed'.
492 If you subscribe to lots of newsgroups from different servers, startup
493 might take a while. By setting this variable to nil, you'll save time,
494 but you won't be told how many unread articles there are in the
497 (defvar gnus-save-newsrc-file t
498 "*Non-nil means that Gnus will save the `.newsrc' file.
499 Gnus always saves its own startup file, which is called
500 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
501 be readily understood by other newsreaders. If you don't plan on
502 using other newsreaders, set this variable to nil to save some time on
505 (defvar gnus-save-killed-list t
506 "*If non-nil, save the list of killed groups to the startup file.
507 This will save both time (when starting and quitting) and space (both
508 memory and disk), but it will also mean that Gnus has no record of
509 which groups are new and which are old, so the automatic new
510 newsgroups subscription methods become meaningless. You should always
511 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
514 (defvar gnus-interactive-catchup t
515 "*If non-nil, require your confirmation when catching up a group.")
517 (defvar gnus-interactive-post t
518 "*If non-nil, group name will be asked for when posting.")
520 (defvar gnus-interactive-exit t
521 "*If non-nil, require your confirmation when exiting Gnus.")
523 (defvar gnus-kill-killed nil
524 "*If non-nil, Gnus will apply kill files to already killed articles.
525 If it is nil, Gnus will never apply kill files to articles that have
526 already been through the scoring process, which might very well save lots
529 (defvar gnus-extract-address-components 'gnus-extract-address-components
530 "*Function for extracting address components from a From header.
531 Two pre-defined function exist: `gnus-extract-address-components',
532 which is the default, quite fast, and too simplistic solution, and
533 `mail-extract-address-components', which works much better, but is
536 (defvar gnus-summary-default-score 0
537 "*Default article score level.
538 If this variable is nil, scoring will be disabled.")
540 (defvar gnus-summary-zcore-fuzz 0
541 "*Fuzziness factor for the zcore in the summary buffer.
542 Articles with scores closer than this to `gnus-summary-default-score'
543 will not be marked.")
545 (defvar gnus-simplify-subject-fuzzy-regexp nil
546 "*Regular expression that will be removed from subject strings if
547 fuzzy subject simplification is selected.")
549 (defvar gnus-group-default-list-level gnus-level-subscribed
550 "*Default listing level.
551 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
553 (defvar gnus-group-use-permanent-levels nil
554 "*If non-nil, once you set a level, Gnus will use this level.")
556 (defvar gnus-show-mime nil
557 "*If non-nil, do mime processing of articles.
558 The articles will simply be fed to the function given by
559 `gnus-show-mime-method'.")
561 (defvar gnus-strict-mime t
562 "*If nil, decode MIME header even if there is not Mime-Version field.")
564 (defvar gnus-show-mime-method (function metamail-buffer)
565 "*Function to process a MIME message.
566 The function is called from the article buffer.")
568 (defvar gnus-show-threads t
569 "*If non-nil, display threads in summary mode.")
571 (defvar gnus-thread-hide-subtree nil
572 "*If non-nil, hide all threads initially.
573 If threads are hidden, you have to run the command
574 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
575 to expose hidden threads.")
577 (defvar gnus-thread-hide-killed t
578 "*If non-nil, hide killed threads automatically.")
580 (defvar gnus-thread-ignore-subject nil
581 "*If non-nil, ignore subjects and do all threading based on the Reference header.
582 If nil, which is the default, articles that have different subjects
583 from their parents will start separate threads.")
585 (defvar gnus-thread-indent-level 4
586 "*Number that says how much each sub-thread should be indented.")
588 (defvar gnus-ignored-newsgroups ""
589 "*A regexp to match uninteresting newsgroups in the active file.
590 Any lines in the active file matching this regular expression are
591 removed from the newsgroup list before anything else is done to it,
592 thus making them effectively non-existent.")
594 (defvar gnus-ignored-headers
595 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
596 "*All headers that match this regexp will be hidden.
597 Also see `gnus-visible-headers'.")
599 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
600 "*All headers that do not match this regexp will be hidden.
601 Also see `gnus-ignored-headers'.")
603 (defvar gnus-sorted-header-list
604 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
605 "^Cc:" "^Date:" "^Organization:")
606 "*This variable is a list of regular expressions.
607 If it is non-nil, headers that match the regular expressions will
608 be placed first in the article buffer in the sequence specified by
611 (defvar gnus-show-all-headers nil
612 "*If non-nil, don't hide any headers.")
614 (defvar gnus-save-all-headers t
615 "*If non-nil, don't remove any headers before saving.")
617 (defvar gnus-inhibit-startup-message nil
618 "*If non-nil, the startup message will not be displayed.")
620 (defvar gnus-signature-separator "^-- *$"
621 "Regexp matching signature separator.")
623 (defvar gnus-auto-extend-newsgroup t
624 "*If non-nil, extend newsgroup forward and backward when requested.")
626 (defvar gnus-auto-select-first t
627 "*If non-nil, select the first unread article when entering a group.
628 If you want to prevent automatic selection of the first unread article
629 in some newsgroups, set the variable to nil in
630 `gnus-select-group-hook'.")
632 (defvar gnus-auto-select-next t
633 "*If non-nil, offer to go to the next group from the end of the previous.
634 If the value is t and the next newsgroup is empty, Gnus will exit
635 summary mode and go back to group mode. If the value is neither nil
636 nor t, Gnus will select the following unread newsgroup. In
637 particular, if the value is the symbol `quietly', the next unread
638 newsgroup will be selected without any confirmations.")
640 (defvar gnus-auto-select-same nil
641 "*If non-nil, select the next article with the same subject.")
643 (defvar gnus-summary-check-current nil
644 "*If non-nil, consider the current article when moving.
645 The \"unread\" movement commands will stay on the same line if the
646 current article is unread.")
648 (defvar gnus-auto-center-summary t
649 "*If non-nil, always center the current summary buffer.")
651 (defvar gnus-break-pages t
652 "*If non-nil, do page breaking on articles.
653 The page delimiter is specified by the `gnus-page-delimiter'
656 (defvar gnus-page-delimiter "^\^L"
657 "*Regexp describing what to use as article page delimiters.
658 The default value is \"^\^L\", which is a form linefeed at the
659 beginning of a line.")
661 (defvar gnus-use-full-window t
662 "*If non-nil, use the entire Emacs screen.")
664 (defvar gnus-window-configuration nil
665 "Obsolete variable. See `gnus-buffer-configuration'.")
667 (defvar gnus-buffer-configuration
668 '((group ([group 1.0 point]
669 (if gnus-carpal [group-carpal 4])))
670 (summary ([summary 1.0 point]
671 (if gnus-carpal [summary-carpal 4])))
672 (article ([summary 0.25 point]
673 (if gnus-carpal [summary-carpal 4])
675 (server ([server 1.0 point]
676 (if gnus-carpal [server-carpal 2])))
677 (browse ([browse 1.0 point]
678 (if gnus-carpal [browse-carpal 2])))
679 (group-mail ([mail 1.0 point]))
680 (summary-mail ([mail 1.0 point]))
681 (summary-reply ([article 0.5]
683 (info ([nil 1.0 point]))
684 (summary-faq ([summary 0.25]
686 (edit-group ([group 0.5]
687 [edit-group 1.0 point]))
688 (edit-server ([server 0.5]
689 [edit-server 1.0 point]))
690 (edit-score ([summary 0.25]
691 [edit-score 1.0 point]))
692 (post ([post 1.0 point]))
693 (reply ([article 0.5]
695 (mail-forward ([mail 1.0 point]))
696 (post-forward ([post 1.0 point]))
697 (reply-yank ([mail 1.0 point]))
698 (followup ([article 0.5]
700 (followup-yank ([post 1.0 point])))
701 "Window configuration for all possible Gnus buffers.
702 This variable is a list of lists. Each of these lists has a NAME and
703 a RULE. The NAMEs are commonsense names like `group', which names a
704 rule used when displaying the group buffer; `summary', which names a
705 rule for what happens when you enter a group and do not display an
706 article buffer; and so on. See the value of this variable for a
707 complete list of NAMEs.
709 Each RULE is a list of vectors. The first element in this vector is
710 the name of the buffer to be displayed; the second element is the
711 percentage of the screen this buffer is to occupy (a number in the
712 0.0-0.99 range); the optional third element is `point', which should
713 be present to denote which buffer point is to go to after making this
714 buffer configuration.")
716 (defvar gnus-window-to-buffer
717 '((group . gnus-group-buffer)
718 (summary . gnus-summary-buffer)
719 (article . gnus-article-buffer)
720 (server . gnus-server-buffer)
721 (browse . "*Gnus Browse Server*")
722 (edit-group . gnus-group-edit-buffer)
723 (edit-server . gnus-server-edit-buffer)
724 (group-carpal . gnus-carpal-group-buffer)
725 (summary-carpal . gnus-carpal-summary-buffer)
726 (server-carpal . gnus-carpal-server-buffer)
727 (browse-carpal . gnus-carpal-browse-buffer)
728 (edit-score . gnus-score-edit-buffer)
729 (mail . gnus-mail-buffer)
730 (post . gnus-post-news-buffer)
731 (faq . gnus-faq-buffer))
732 "Mapping from short symbols to buffer names or buffer variables.")
734 (defvar gnus-carpal nil
735 "*If non-nil, display clickable icons.")
737 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
738 "*Function called with a group name when new group is detected.
739 A few pre-made functions are supplied: `gnus-subscribe-randomly'
740 inserts new groups at the beginning of the list of groups;
741 `gnus-subscribe-alphabetically' inserts new groups in strict
742 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
743 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
746 ;; Suggested by a bug report by Hallvard B Furuseth.
747 ;; <h.b.furuseth@usit.uio.no>.
748 (defvar gnus-subscribe-options-newsgroup-method
749 (function gnus-subscribe-alphabetically)
750 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
751 If, for instance, you want to subscribe to all newsgroups in the
752 \"no\" and \"alt\" hierarchies, you'd put the following in your
755 options -n no.all alt.all
757 Gnus will the subscribe all new newsgroups in these hierarchies with
758 the subscription method in this variable.")
760 (defvar gnus-subscribe-hierarchical-interactive nil
761 "*If non-nil, Gnus will offer to subscribe hierarchically.
762 When a new hierarchy appears, Gnus will ask the user:
764 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
766 If the user pressed `d', Gnus will descend the hierarchy, `y' will
767 subscribe to all newsgroups in the hierarchy and `s' will skip this
768 hierarchy in its entirety.")
770 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
771 "*Function used for sorting the group buffer.
772 This function will be called with group info entries as the arguments
773 for the groups to be sorted. Pre-made functions include
774 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
775 `gnus-sort-by-level'")
777 ;; Mark variables suggested by Thomas Michanek
778 ;; <Thomas.Michanek@telelogic.se>.
779 (defvar gnus-unread-mark ?
780 "*Mark used for unread articles.")
781 (defvar gnus-ticked-mark ?!
782 "*Mark used for ticked articles.")
783 (defvar gnus-dormant-mark ??
784 "*Mark used for dormant articles.")
785 (defvar gnus-del-mark ?r
786 "*Mark used for del'd articles.")
787 (defvar gnus-read-mark ?R
788 "*Mark used for read articles.")
789 (defvar gnus-expirable-mark ?E
790 "*Mark used for expirable articles.")
791 (defvar gnus-killed-mark ?K
792 "*Mark used for killed articles.")
793 (defvar gnus-kill-file-mark ?X
794 "*Mark used for articles killed by kill files.")
795 (defvar gnus-low-score-mark ?Y
796 "*Mark used for articles with a low score.")
797 (defvar gnus-catchup-mark ?C
798 "*Mark used for articles that are caught up.")
799 (defvar gnus-replied-mark ?A
800 "*Mark used for articles that have been replied to.")
801 (defvar gnus-process-mark ?#
803 (defvar gnus-ancient-mark ?O
804 "*Mark used for ancient articles.")
805 (defvar gnus-canceled-mark ?G
806 "*Mark used for canceled articles.")
807 (defvar gnus-score-over-mark ?+
808 "*Score mark used for articles with high scores.")
809 (defvar gnus-score-below-mark ?-
810 "*Score mark used for articles with low scores.")
811 (defvar gnus-empty-thread-mark ?
812 "*There is no thread under the article.")
813 (defvar gnus-not-empty-thread-mark ?=
814 "*There is a thread under the article.")
815 (defvar gnus-dummy-mark ?Z
816 "*This is a dummy article.")
818 (defvar gnus-view-pseudo-asynchronously nil
819 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
821 (defvar gnus-view-pseudos nil
822 "*If `automatic', pseudo-articles will be viewed automatically.
823 If `not-confirm', pseudos will be viewed automatically, and the user
824 will not be asked to confirm the command.")
826 (defvar gnus-view-pseudos-separately t
827 "*If non-nil, one pseudo-article will be created for each file to be viewed.
828 If nil, all files that use the same viewing command will be given as a
829 list of parameters to that command.")
831 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
832 "*Format of group lines.
833 It works along the same lines as a normal formatting string,
834 with some simple extensions.
836 %M Only marked articles (character, \"*\" or \" \")
837 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
838 %L Level of subscribedness (integer)
839 %N Number of unread articles (integer)
840 %I Number of dormant articles (integer)
841 %i Number of ticked and dormant (integer)
842 %T Number of ticked articles (integer)
843 %R Number of read articles (integer)
844 %t Total number of articles (integer)
845 %y Number of unread, unticked articles (integer)
846 %G Group name (string)
847 %g Qualified group name (string)
848 %D Group description (string)
849 %s Select method (string)
850 %o Moderated group (char, \"m\")
851 %p Process mark (char)
852 %O Moderated group (string, \"(m)\" or \"\")
853 %n Select from where (string)
854 %z A string that look like `<%s:%n>' if a foreign select method is used
855 %u User defined specifier. The next character in the format string should
856 be a letter. Gnus will call the function gnus-user-format-function-X,
857 where X is the letter following %u. The function will be passed the
858 current header as argument. The function should return a string, which
859 will be inserted into the buffer just like information from any other
862 Text between %( and %) will be highlighted with `gnus-mouse-face' when
863 the mouse point move inside the area. There can only be one such area.
865 Note that this format specification is not always respected. For
866 reasons of efficiency, when listing killed groups, this specification
867 is ignored altogether. If the spec is changed considerably, your
868 output may end up looking strange when listing both alive and killed
871 If you use %o or %O, reading the active file will be slower and quite
872 a bit of extra memory will be used. %D will also worsen performance.
873 Also note that if you change the format specification to include any
874 of these specs, you must probably re-start Gnus to see them go into
877 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
878 "*The format specification of the lines in the summary buffer.
880 It works along the same lines as a normal formatting string,
881 with some simple extensions.
883 %N Article number, left padded with spaces (string)
885 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
886 %n Name of the poster (string)
887 %a Extracted name of the poster (string)
888 %A Extracted address of the poster (string)
889 %F Contents of the From: header (string)
890 %x Contents of the Xref: header (string)
891 %D Date of the article (string)
892 %d Date of the article (string) in DD-MMM format
893 %M Message-id of the article (string)
894 %r References of the article (string)
895 %c Number of characters in the article (integer)
896 %L Number of lines in the article (integer)
897 %I Indentation based on thread level (a string of spaces)
898 %T A string with two possible values: 80 spaces if the article
899 is on thread level two or larger and 0 spaces on level one
900 %R \"R\" if this article has been replied to, \" \" otherwise (character)
901 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
902 %[ Opening bracket (character, \"[\" or \"<\")
903 %] Closing bracket (character, \"]\" or \">\")
904 %> Spaces of length thread-level (string)
905 %< Spaces of length (- 20 thread-level) (string)
906 %i Article score (number)
907 %z Article zcore (character)
908 %t Number of articles under the current thread (number).
909 %e Whether the thread is empty or not (character).
910 %u User defined specifier. The next character in the format string should
911 be a letter. Gnus will call the function gnus-user-format-function-X,
912 where X is the letter following %u. The function will be passed the
913 current header as argument. The function should return a string, which
914 will be inserted into the summary just like information from any other
917 Text between %( and %) will be highlighted with `gnus-mouse-face'
918 when the mouse point is placed inside the area. There can only be one
921 The %U (status), %R (replied) and %z (zcore) specs have to be handled
922 with care. For reasons of efficiency, Gnus will compute what column
923 these characters will end up in, and \"hard-code\" that. This means that
924 it is illegal to have these specs after a variable-length spec. Well,
925 you might not be arrested, but your summary buffer will look strange,
928 The smart choice is to have these specs as for to the left as
931 This restriction may disappear in later versions of Gnus.")
933 (defvar gnus-summary-dummy-line-format "* : : %S\n"
934 "*The format specification for the dummy roots in the summary buffer.
935 It works along the same lines as a normal formatting string,
936 with some simple extensions.
940 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
941 "*The format specification for the summary mode line.")
943 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
944 "*The format specification for the article mode line.")
946 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
947 "*The format specification for the group mode line.")
949 (defvar gnus-valid-select-methods
950 '(("nntp" post address prompt-address)
952 ("nnvirtual" none virtual prompt-address)
953 ("nnmbox" mail respool)
954 ("nnml" mail respool)
955 ("nnmh" mail respool)
956 ("nndir" none prompt-address address)
957 ("nneething" none prompt-address)
959 ("nndoc" none prompt-address)
960 ("nnbabyl" mail respool)
961 ("nnkiboze" post virtual)
963 ("nnfolder" mail respool))
964 "An alist of valid select methods.
965 The first element of each list lists should be a string with the name
966 of the select method. The other elements may be be the category of
967 this method (ie. `post', `mail', `none' or whatever) or other
968 properties that this method has (like being respoolable).
969 If you implement a new select method, all you should have to change is
970 this variable. I think.")
972 (defvar gnus-updated-mode-lines '(group article summary)
973 "*List of buffers that should update their mode lines.
974 The list may contain the symbols `group', `article' and `summary'. If
975 the corresponding symbol is present, Gnus will keep that mode line
976 updated with information that may be pertinent.
977 If this variable is nil, screen refresh may be quicker.")
979 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
980 (defvar gnus-mode-non-string-length 21
981 "*Max length of mode-line non-string contents.
982 If this is nil, Gnus will take space as is needed, leaving the rest
983 of the modeline intact.")
985 (defvar gnus-mouse-face 'highlight
986 "*Face used for mouse highlighting in Gnus.
987 No mouse highlights will be done if `gnus-visual' is nil.")
989 (defvar gnus-summary-mark-below nil
990 "*Mark all articles with a score below this variable as read.
991 This variable is local to each summary buffer and usually set by the
994 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
995 "*List of functions used for sorting threads in the summary buffer.
996 By default, threads are sorted by article number.
998 Each function takes two threads and return non-nil if the first thread
999 should be sorted before the other. If you use more than one function,
1000 the primary sort function should be the last.
1002 Ready-mady functions include `gnus-thread-sort-by-number',
1003 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1004 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1005 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1007 (defvar gnus-thread-score-function '+
1008 "*Function used for calculating the total score of a thread.
1010 The function is called with the scores of the article and each
1011 subthread and should then return the score of the thread.
1013 Some functions you can use are `+', `max', or `min'.")
1015 (defvar gnus-options-subscribe nil
1016 "*All new groups matching this regexp will be subscribed unconditionally.
1017 Note that this variable deals only with new newsgroups. This variable
1018 does not affect old newsgroups.")
1020 (defvar gnus-options-not-subscribe nil
1021 "*All new groups matching this regexp will be ignored.
1022 Note that this variable deals only with new newsgroups. This variable
1023 does not affect old (already subscribed) newsgroups.")
1025 (defvar gnus-auto-expirable-newsgroups nil
1026 "*Groups in which to automatically mark read articles as expirable.
1027 If non-nil, this should be a regexp that should match all groups in
1028 which to perform auto-expiry. This only makes sense for mail groups.")
1030 (defvar gnus-hidden-properties '(invisible t intangible t)
1031 "Property list to use for hiding text.")
1035 (defvar gnus-group-mode-hook nil
1036 "*A hook for Gnus group mode.")
1038 (defvar gnus-summary-mode-hook nil
1039 "*A hook for Gnus summary mode.
1040 This hook is run before any variables are set in the summary buffer.")
1042 (defvar gnus-article-mode-hook nil
1043 "*A hook for Gnus article mode.")
1045 (defun gnus-summary-exit-hook nil
1046 "*A hook called on exit from the summary buffer.
1047 It calls `gnus-summary-expire-articles' by default.")
1048 (add-hook 'gnus-summary-exit-hook 'gnus-summary-expire-articles)
1050 (defvar gnus-open-server-hook nil
1051 "*A hook called just before opening connection to the news server.")
1053 (defvar gnus-startup-hook nil
1054 "*A hook called at startup.
1055 This hook is called after Gnus is connected to the NNTP server.")
1057 (defvar gnus-get-new-news-hook nil
1058 "*A hook run just before Gnus checks for new news.")
1060 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1061 "*A function that is called to generate the group buffer.
1062 The function is called with three arguments: The first is a number;
1063 all group with a level less or equal to that number should be listed,
1064 if the second is non-nil, empty groups should also be displayed. If
1065 the third is non-nil, it is a number. No groups with a level lower
1066 than this number should be displayed.
1068 The only current function implemented is `gnus-group-prepare-flat'.")
1070 (defvar gnus-group-prepare-hook nil
1071 "*A hook called after the group buffer has been generated.
1072 If you want to modify the group buffer, you can use this hook.")
1074 (defvar gnus-summary-prepare-hook nil
1075 "*A hook called after the summary buffer has been generated.
1076 If you want to modify the summary buffer, you can use this hook.")
1078 (defvar gnus-article-prepare-hook nil
1079 "*A hook called after an article has been prepared in the article buffer.
1080 If you want to run a special decoding program like nkf, use this hook.")
1082 (defvar gnus-article-display-hook nil
1083 "*A hook called after the article is displayed in the article buffer.
1084 The hook is designed to change the contents of the article
1085 buffer. Typical functions that this hook may contain are
1086 `gnus-article-hide-headers' (hide selected headers),
1087 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1088 `gnus-article-hide-signature' (hide signature) and
1089 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1090 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1091 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1093 (defvar gnus-article-x-face-command
1094 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1095 "String or function to be executed to display an X-Face header.
1096 If it is a string, the command will be executed in a sub-shell
1097 asynchronously. The compressed face will be piped to this command.")
1099 (defvar gnus-article-x-face-too-ugly nil
1100 "Regexp matching posters whose face shouldn't be shown automatically.")
1102 (defvar gnus-select-group-hook nil
1103 "*A hook called when a newsgroup is selected.
1105 If you'd like to simplify subjects like the
1106 `gnus-summary-next-same-subject' command does, you can use the
1109 (setq gnus-select-group-hook
1112 (mapcar (lambda (header)
1115 (gnus-simplify-subject
1116 (header-subject header) 're-only)))
1117 gnus-newsgroup-headers))))")
1119 (defvar gnus-select-article-hook
1120 '(gnus-summary-show-thread)
1121 "*A hook called when an article is selected.
1122 The default hook shows conversation thread subtrees of the selected
1123 article automatically using `gnus-summary-show-thread'.")
1125 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1126 "*A hook called to apply kill files to a group.
1127 This hook is intended to apply a kill file to the selected newsgroup.
1128 The function `gnus-apply-kill-file' is called by default.
1130 Since a general kill file is too heavy to use only for a few
1131 newsgroups, I recommend you to use a lighter hook function. For
1132 example, if you'd like to apply a kill file to articles which contains
1133 a string `rmgroup' in subject in newsgroup `control', you can use the
1136 \(setq gnus-apply-kill-hook
1139 (cond ((string-match \"control\" gnus-newsgroup-name)
1140 (gnus-kill \"Subject\" \"rmgroup\")
1141 (gnus-expunge \"X\"))))))")
1143 (defvar gnus-visual-mark-article-hook
1144 (list 'gnus-highlight-selected-summary)
1145 "*Hook run after selecting an article in the summary buffer.
1146 It is meant to be used for highlighting the article in some way. It
1147 is not run if `gnus-visual' is nil.")
1149 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1150 "*A hook called after preparing body, but before preparing header headers.
1151 The default hook (`gnus-inews-insert-signature') inserts a signature
1152 file specified by the variable `gnus-signature-file'.")
1154 (defvar gnus-exit-group-hook nil
1155 "*A hook called when exiting (not quitting) summary mode.")
1157 (defvar gnus-suspend-gnus-hook nil
1158 "*A hook called when suspending (not exiting) Gnus.")
1160 (defvar gnus-exit-gnus-hook nil
1161 "*A hook called when exiting Gnus.")
1163 (defvar gnus-save-newsrc-hook nil
1164 "*A hook called when saving the newsrc file.")
1166 (defvar gnus-summary-update-hook
1167 (list 'gnus-summary-highlight-line)
1168 "*A hook called when a summary line is changed.
1169 The hook will not be called if `gnus-visual' is nil.
1171 The default function `gnus-summary-highlight-line' will
1172 highlight the line according to the `gnus-summary-highlight'
1175 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1176 "*A hook called when an article is selected for the first time.
1177 The hook is intended to mark an article as read (or unread)
1178 automatically when it is selected.")
1180 ;; Remove any hilit infestation.
1181 (add-hook 'gnus-startup-hook
1183 (remove-hook 'gnus-summary-prepare-hook
1184 'hilit-rehighlight-buffer-quietly)
1185 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1186 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1187 (remove-hook 'gnus-article-prepare-hook
1188 'hilit-rehighlight-buffer-quietly)))
1192 ;; Internal variables
1194 ;; Avoid highlighting in kill files.
1195 (defvar gnus-summary-inhibit-highlight nil)
1196 (defvar gnus-newsgroup-selected-overlay nil)
1198 (defvar gnus-article-mode-map nil)
1199 (defvar gnus-dribble-buffer nil)
1200 (defvar gnus-headers-retrieved-by nil)
1201 (defvar gnus-article-reply nil)
1202 (defvar gnus-override-method nil)
1203 (defvar gnus-article-check-size nil)
1205 (defvar gnus-current-score-file nil)
1206 (defvar gnus-internal-global-score-files nil)
1207 (defvar gnus-score-file-list nil)
1210 (defvar gnus-current-move-group nil)
1212 (defvar gnus-newsgroup-dependencies nil)
1213 (defvar gnus-newsgroup-threads nil)
1214 (defvar gnus-newsgroup-async nil)
1215 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1217 (defvar gnus-newsgroup-adaptive nil)
1219 (defvar gnus-summary-display-table nil)
1221 (defconst gnus-group-line-format-alist
1222 (list (list ?M 'marked ?c)
1223 (list ?S 'subscribed ?c)
1225 (list ?N 'number ?s)
1226 (list ?I 'number-of-dormant ?d)
1227 (list ?T 'number-of-ticked ?d)
1228 (list ?R 'number-of-read ?s)
1229 (list ?t 'number-total ?d)
1230 (list ?y 'number-of-unread-unticked ?s)
1231 (list ?i 'number-of-ticked-and-dormant ?d)
1233 (list ?G 'qualified-group ?s)
1234 (list ?D 'newsgroup-description ?s)
1235 (list ?o 'moderated ?c)
1236 (list ?O 'moderated-string ?s)
1237 (list ?p 'process-marked ?c)
1238 (list ?s 'news-server ?s)
1239 (list ?n 'news-method ?s)
1240 (list ?z 'news-method-string ?s)
1241 (list ?u 'user-defined ?s)))
1243 (defconst gnus-summary-line-format-alist
1244 (list (list ?N 'number ?d)
1245 (list ?S 'subject ?s)
1246 (list ?s 'subject-or-nil ?s)
1248 (list ?A '(car (cdr (funcall gnus-extract-address-components from))) ?s)
1249 (list ?a '(or (car (funcall gnus-extract-address-components from)) from) ?s)
1251 (list ?x (macroexpand '(header-xref header)) ?s)
1252 (list ?D (macroexpand '(header-date header)) ?s)
1253 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1254 (list ?M (macroexpand '(header-id header)) ?s)
1255 (list ?r (macroexpand '(header-references header)) ?s)
1256 (list ?c '(or (header-chars header) 0) ?d)
1258 (list ?I 'indentation ?s)
1259 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1260 (list ?R 'replied ?c)
1261 (list ?\[ 'opening-bracket ?c)
1262 (list ?\] 'closing-bracket ?c)
1263 (list ?\> '(make-string level ? ) ?s)
1264 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1266 (list ?z 'score-char ?c)
1267 (list ?U 'unread ?c)
1268 (list ?t '(gnus-summary-number-of-articles-in-thread
1269 (and (boundp 'thread) (car thread)))
1271 (list ?e '(gnus-summary-number-of-articles-in-thread
1272 (and (boundp 'thread) (car thread)) t)
1274 (list ?u 'user-defined ?s))
1275 "An alist of format specifications that can appear in summary lines,
1276 and what variables they correspond with, along with the type of the
1277 variable (string, integer, character, etc).")
1279 (defconst gnus-summary-dummy-line-format-alist
1280 (list (list ?S 'subject ?s)
1281 (list ?N 'number ?d)
1282 (list ?u 'user-defined ?s)))
1284 (defconst gnus-summary-mode-line-format-alist
1285 (list (list ?G 'group-name ?s)
1286 (list ?g '(gnus-short-group-name group-name) ?s)
1287 (list ?A 'article-number ?d)
1288 (list ?Z 'unread-and-unselected ?s)
1289 (list ?V 'gnus-version ?s)
1290 (list ?U 'unread ?d)
1291 (list ?S 'subject ?s)
1292 (list ?e 'unselected ?d)
1293 (list ?u 'user-defined ?s)
1294 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1296 (defconst gnus-group-mode-line-format-alist
1297 (list (list ?S 'news-server ?s)
1298 (list ?M 'news-method ?s)
1299 (list ?u 'user-defined ?s)))
1301 (defvar gnus-have-read-active-file nil)
1303 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1304 "The mail address of the Gnus maintainers.")
1306 (defconst gnus-version "(ding) Gnus v0.98.1"
1307 "Version number for this version of Gnus.")
1309 (defvar gnus-info-nodes
1310 '((gnus-group-mode "(gnus)The Group Buffer")
1311 (gnus-summary-mode "(gnus)The Summary Buffer")
1312 (gnus-article-mode "(gnus)The Article Buffer"))
1313 "Assoc list of major modes and related Info nodes.")
1315 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1316 "The location of the (ding) Gnus documentation group.")
1318 (defvar gnus-group-buffer "*Group*")
1319 (defvar gnus-summary-buffer "*Summary*")
1320 (defvar gnus-article-buffer "*Article*")
1321 (defvar gnus-server-buffer "*Server*")
1323 (defvar gnus-work-buffer " *gnus work*")
1325 (defvar gnus-buffer-list nil
1326 "Gnus buffers that should be killed on exit.")
1328 (defvar gnus-server-alist nil
1329 "List of available servers.")
1331 (defvar gnus-variable-list
1332 '(gnus-newsrc-options gnus-newsrc-options-n
1333 gnus-newsrc-last-checked-date
1334 gnus-newsrc-alist gnus-server-alist
1335 gnus-killed-list gnus-zombie-list)
1336 "Gnus variables saved in the quick startup file.")
1338 (defvar gnus-overload-functions
1339 '((news-inews gnus-inews-news "rnewspost"))
1340 "Functions overloaded by gnus.
1341 It is a list of `(original overload &optional file)'.")
1343 (defvar gnus-newsrc-options nil
1344 "Options line in the .newsrc file.")
1346 (defvar gnus-newsrc-options-n nil
1347 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1349 (defvar gnus-newsrc-last-checked-date nil
1350 "Date Gnus last asked server for new newsgroups.")
1352 (defvar gnus-newsrc-alist nil
1353 "Assoc list of read articles.
1354 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1356 (defvar gnus-newsrc-hashtb nil
1357 "Hashtable of gnus-newsrc-alist.")
1359 (defvar gnus-killed-list nil
1360 "List of killed newsgroups.")
1362 (defvar gnus-killed-hashtb nil
1363 "Hash table equivalent of gnus-killed-list.")
1365 (defvar gnus-zombie-list nil
1366 "List of almost dead newsgroups.")
1368 (defvar gnus-description-hashtb nil
1369 "Descriptions of newsgroups.")
1371 (defvar gnus-list-of-killed-groups nil
1372 "List of newsgroups that have recently been killed by the user.")
1374 (defvar gnus-active-hashtb nil
1375 "Hashtable of active articles.")
1377 (defvar gnus-moderated-list nil
1378 "List of moderated newsgroups.")
1380 (defvar gnus-group-marked nil)
1382 (defvar gnus-current-startup-file nil
1383 "Startup file for the current host.")
1385 (defvar gnus-last-search-regexp nil
1386 "Default regexp for article search command.")
1388 (defvar gnus-last-shell-command nil
1389 "Default shell command on article.")
1391 (defvar gnus-current-select-method nil
1392 "The current method for selecting a newsgroup.")
1394 (defvar gnus-have-all-newsgroups nil)
1396 (defvar gnus-article-internal-prepare-hook nil)
1398 (defvar gnus-newsgroup-name nil)
1399 (defvar gnus-newsgroup-begin nil)
1400 (defvar gnus-newsgroup-end nil)
1401 (defvar gnus-newsgroup-last-rmail nil)
1402 (defvar gnus-newsgroup-last-mail nil)
1403 (defvar gnus-newsgroup-last-folder nil)
1404 (defvar gnus-newsgroup-last-file nil)
1405 (defvar gnus-newsgroup-auto-expire nil)
1406 (defvar gnus-newsgroup-active nil)
1408 (defvar gnus-newsgroup-unreads nil
1409 "List of unread articles in the current newsgroup.")
1411 (defvar gnus-newsgroup-unselected nil
1412 "List of unselected unread articles in the current newsgroup.")
1414 (defvar gnus-newsgroup-marked nil
1415 "List of ticked articles in the current newsgroup (a subset of unread art).")
1417 (defvar gnus-newsgroup-killed nil
1418 "List of ranges of articles that have been through the scoring process.")
1420 (defvar gnus-newsgroup-kill-headers nil)
1422 (defvar gnus-newsgroup-replied nil
1423 "List of articles that have been replied to in the current newsgroup.")
1425 (defvar gnus-newsgroup-expirable nil
1426 "List of articles in the current newsgroup that can be expired.")
1428 (defvar gnus-newsgroup-processable nil
1429 "List of articles in the current newsgroup that can be processed.")
1431 (defvar gnus-newsgroup-bookmarks nil
1432 "List of articles in the current newsgroup that have bookmarks.")
1434 (defvar gnus-newsgroup-dormant nil
1435 "List of dormant articles in the current newsgroup.")
1437 (defvar gnus-newsgroup-scored nil
1438 "List of scored articles in the current newsgroup.")
1440 (defvar gnus-newsgroup-headers nil
1441 "List of article headers in the current newsgroup.")
1442 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1444 (defvar gnus-newsgroup-ancient nil
1445 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1447 (defvar gnus-current-article nil)
1448 (defvar gnus-article-current nil)
1449 (defvar gnus-current-headers nil)
1450 (defvar gnus-have-all-headers nil)
1451 (defvar gnus-last-article nil)
1452 (defvar gnus-newsgroup-history nil)
1453 (defvar gnus-current-kill-article nil)
1455 ;; Save window configuration.
1456 (defvar gnus-prev-winconf nil)
1459 (defvar gnus-summary-line-format-spec nil)
1460 (defvar gnus-summary-dummy-line-format-spec nil)
1461 (defvar gnus-group-line-format-spec nil)
1462 (defvar gnus-summary-mode-line-format-spec nil)
1463 (defvar gnus-article-mode-line-format-spec nil)
1464 (defvar gnus-group-mode-line-format-spec nil)
1465 (defvar gnus-summary-mark-positions nil)
1467 (defvar gnus-summary-expunge-below nil)
1468 (defvar gnus-reffed-article-number nil)
1470 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1471 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1473 (defvar gnus-cache-removeable-articles nil)
1475 (defconst gnus-summary-local-variables
1476 '(gnus-newsgroup-name
1477 gnus-newsgroup-begin gnus-newsgroup-end
1478 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1479 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1480 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1481 gnus-newsgroup-unselected gnus-newsgroup-marked
1482 gnus-newsgroup-replied gnus-newsgroup-expirable
1483 gnus-newsgroup-processable gnus-newsgroup-killed
1484 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1485 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1486 gnus-current-article gnus-current-headers gnus-have-all-headers
1487 gnus-last-article gnus-article-internal-prepare-hook
1488 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1489 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1490 gnus-newsgroup-threads gnus-newsgroup-async
1491 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1492 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1493 gnus-newsgroup-history gnus-newsgroup-ancient
1494 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1495 gnus-cache-removeable-articles)
1496 "Variables that are buffer-local to the summary buffers.")
1498 (defconst gnus-bug-message
1499 "Sending a bug report to the Gnus Towers.
1500 ========================================
1502 The buffer below is a mail buffer. When you press `C-c C-c', it will
1503 be sent to the Gnus Bug Exterminators.
1505 At the bottom of the buffer you'll see lots of variable settings.
1506 Please do not delete those. They will tell the Bug People what your
1507 environment is, so that it will be easier to locate the bugs.
1509 If you have found a bug that makes Emacs go \"beep\", set
1510 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1511 and include the backtrace in your bug report.
1513 Please describe the bug in annoying, painstaking detail.
1515 Thank you for your help in stamping out bugs.
1518 ;;; End of variables.
1520 ;; Define some autoload functions Gnus might use.
1524 (autoload 'metamail-buffer "metamail")
1525 (autoload 'Info-goto-node "info")
1526 (autoload 'hexl-hex-string-to-integer "hexl")
1528 (autoload 'pp-to-string "pp")
1529 (autoload 'pp-eval-expression "pp")
1530 (autoload 'mail-extract-address-components "mail-extr")
1532 (autoload 'nnmail-split-fancy "nnmail")
1533 (autoload 'nnvirtual-catchup-group "nnvirtual")
1536 (autoload 'timezone-make-date-arpa-standard "timezone")
1537 (autoload 'timezone-fix-time "timezone")
1538 (autoload 'timezone-make-sortable-date "timezone")
1539 (autoload 'timezone-make-time-string "timezone")
1542 (autoload 'mail-position-on-field "sendmail")
1543 (autoload 'mail-setup "sendmail")
1544 (autoload 'rmail-output "rmailout")
1545 (autoload 'news-mail-other-window "rnewspost")
1546 (autoload 'news-reply-yank-original "rnewspost")
1547 (autoload 'news-caesar-buffer-body "rnewspost")
1548 (autoload 'rmail-insert-rmail-file-header "rmail")
1549 (autoload 'rmail-count-new-messages "rmail")
1550 (autoload 'rmail-show-message "rmail")
1553 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1554 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1555 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1556 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1557 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1558 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1559 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1562 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1563 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1564 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1565 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1566 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1567 (autoload 'gnus-Folder-save-name "gnus-mh")
1568 (autoload 'gnus-folder-save-name "gnus-mh")
1571 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1572 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1573 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1574 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1575 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1576 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1577 (autoload 'gnus-summary-highlight-line "gnus-vis")
1578 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1581 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1582 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1583 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1584 (autoload 'gnus-article-hide "gnus-vis" nil t)
1585 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1586 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1587 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1588 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1589 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1590 (autoload 'gnus-article-add-button "gnus-vis")
1593 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1594 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1595 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1598 (autoload 'gnus-kill "gnus-kill")
1599 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1600 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1601 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1602 (autoload 'gnus-execute "gnus-kill")
1603 (autoload 'gnus-expunge "gnus-kill")
1606 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1607 (autoload 'gnus-cache-save-buffers "gnus-cache")
1608 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1609 (autoload 'gnus-cache-request-article "gnus-cache")
1610 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1611 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1612 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1613 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1616 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1617 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1618 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1619 (autoload 'gnus-score-save "gnus-score")
1620 (autoload 'gnus-score-headers "gnus-score")
1621 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1622 (autoload 'gnus-score-adaptive "gnus-score")
1623 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1624 (autoload 'gnus-score-find-trace "gnus-score")
1627 (autoload 'gnus-score-customize "gnus-edit" nil t)
1630 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1631 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1632 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1633 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1634 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1635 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1636 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1637 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1638 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1639 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1640 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1641 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1642 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1643 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1644 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1645 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1646 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1647 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1648 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1649 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1650 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1651 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1654 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1655 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1656 (autoload 'gnus-group-mail "gnus-msg" nil t)
1657 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1658 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1659 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1660 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1661 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1662 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1663 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1664 (autoload 'gnus-post-news "gnus-msg" nil t)
1665 (autoload 'gnus-inews-news "gnus-msg" nil t)
1666 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1667 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1668 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1669 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1670 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1671 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1672 (autoload 'gnus-mail-yank-original "gnus-msg")
1673 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1674 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1675 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1676 (autoload 'gnus-article-mail-with-original "gnus-msg")
1677 (autoload 'gnus-article-mail "gnus-msg")
1678 (autoload 'gnus-bug "gnus-msg" nil t)
1681 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1682 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1683 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1684 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1685 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1686 (autoload 'gnus-yank-article "gnus-vm" nil t)
1692 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1693 ;; If you want the cursor to go somewhere else, set these two
1694 ;; functions in some startup hook to whatever you want.
1695 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1696 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1698 ;;; Various macros and substs.
1700 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1701 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1702 (` (let ((GnusStartBufferWindow (selected-window)))
1705 (pop-to-buffer (, buffer))
1707 (select-window GnusStartBufferWindow)))))
1709 (defmacro gnus-gethash (string hashtable)
1710 "Get hash value of STRING in HASHTABLE."
1711 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1712 ;;(` (abbrev-expansion (, string) (, hashtable)))
1713 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1715 (defmacro gnus-sethash (string value hashtable)
1716 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1717 ;; We cannot use define-abbrev since it only accepts string as value.
1718 ;; (set (intern string hashtable) value))
1719 (` (set (intern (, string) (, hashtable)) (, value))))
1721 (defsubst gnus-buffer-substring (beg end)
1722 (buffer-substring (match-beginning beg) (match-end end)))
1724 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1725 ;; function `substring' might cut on a middle of multi-octet
1728 (defun gnus-truncate-string (str width)
1729 (substring str 0 width))
1731 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1732 ;; to limit the length of a string. This function is necessary since
1733 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1734 (defsubst gnus-limit-string (str width)
1735 (if (> (length str) width)
1736 (substring str 0 width)
1739 (defsubst gnus-simplify-subject-re (subject)
1740 "Remove \"Re:\" from subject lines."
1741 (let ((case-fold-search t))
1742 (if (string-match "^re: *" subject)
1743 (substring subject (match-end 0))
1746 (defsubst gnus-goto-char (point)
1747 (and point (goto-char point)))
1749 (defmacro gnus-buffer-exists-p (buffer)
1751 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1754 (defmacro gnus-kill-buffer (buffer)
1755 (` (if (gnus-buffer-exists-p (, buffer))
1756 (kill-buffer (, buffer)))))
1758 (defsubst gnus-point-at-bol ()
1759 "Return point at the beginning of line."
1766 (defsubst gnus-point-at-eol ()
1767 "Return point at the beginning of line."
1774 ;; Delete the current line (and the next N lines.);
1775 (defmacro gnus-delete-line (&optional n)
1776 (` (delete-region (progn (beginning-of-line) (point))
1777 (progn (forward-line (, (or n 1))) (point)))))
1779 ;;; Load the compatability functions.
1785 ;;; Gnus Utility Functions
1788 (defun gnus-extract-address-components (from)
1790 ;; First find the address - the thing with the @ in it. This may
1791 ;; not be accurate in mail addresses, but does the trick most of
1792 ;; the time in news messages.
1793 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1794 (setq address (substring from (match-beginning 0) (match-end 0))))
1795 ;; Then we check whether the "name <address>" format is used.
1797 (string-match (concat "<" (regexp-quote address) ">") from)
1798 (and (setq name (substring from 0 (1- (match-beginning 0))))
1799 ;; Strip any quotes from the name.
1800 (string-match "\".*\"" name)
1801 (setq name (substring name 1 (1- (match-end 0))))))
1802 ;; If not, then "address (name)" is used.
1804 (and (string-match "(.+)" from)
1805 (setq name (substring from (1+ (match-beginning 0))
1806 (1- (match-end 0)))))
1807 (and (string-match "()" from)
1808 (setq name address))
1809 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1810 ;; XOVER might not support folded From headers.
1811 (and (string-match "(.*" from)
1812 (setq name (substring from (1+ (match-beginning 0))
1814 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1815 (list (or name from) (or address from))))
1817 (defun gnus-fetch-field (field)
1818 "Return the value of the header FIELD of current article."
1821 (let ((case-fold-search t))
1822 (gnus-narrow-to-headers)
1823 (mail-fetch-field field)))))
1825 (defun gnus-goto-colon ()
1827 (search-forward ":" (gnus-point-at-eol) t))
1829 (defun gnus-narrow-to-headers ()
1833 (goto-char (point-min))
1834 (if (search-forward "\n\n" nil t)
1838 (defvar gnus-old-specs nil)
1840 (defun gnus-update-format-specifications ()
1841 (gnus-make-thread-indent-array)
1843 (let ((formats '(summary summary-dummy group
1844 summary-mode group-mode article-mode))
1845 old-format new-format)
1847 (setq new-format (symbol-value
1848 (intern (format "gnus-%s-line-format" (car formats)))))
1849 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1850 (equal old-format new-format))
1851 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1855 (intern (format "gnus-%s-line-format-alist"
1856 (if (eq (car formats) 'article-mode)
1857 'summary-mode (car formats))))))))
1858 (setq gnus-old-specs (cons (cons (car formats) new-format)
1859 (delq (car formats) gnus-old-specs)))
1860 (setq formats (cdr formats))))
1862 (gnus-update-summary-mark-positions)
1864 (if (and (string-match "%D" gnus-group-line-format)
1865 (not gnus-description-hashtb)
1866 gnus-read-active-file)
1867 (gnus-read-all-descriptions-files)))
1869 (defun gnus-update-summary-mark-positions ()
1871 (let ((gnus-replied-mark 129)
1872 (gnus-score-below-mark 130)
1873 (gnus-score-over-mark 130)
1876 (gnus-set-work-buffer)
1877 (gnus-summary-insert-line
1878 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1879 (goto-char (point-min))
1880 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1882 (goto-char (point-min))
1883 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1884 (- (point) 2))) pos))
1885 (goto-char (point-min))
1886 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1887 (- (point) 2))) pos))
1888 (setq gnus-summary-mark-positions pos))))
1890 (defun gnus-format-max-width (form length)
1891 (let* ((val (eval form))
1892 (valstr (if (numberp val) (int-to-string val) val)))
1893 (gnus-limit-string valstr length)))
1895 (defun gnus-set-mouse-face (string)
1896 ;; Set mouse face property on STRING.
1897 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1901 (defun gnus-mouse-face-function (form)
1902 (` (let ((string (, form)))
1903 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1906 (defun gnus-max-width-function (el max-width)
1907 (` (let* ((val (eval (, el)))
1908 (valstr (if (numberp val)
1909 (int-to-string val) val)))
1910 (if (> (length valstr) (, max-width))
1911 (substring valstr 0 (, max-width))
1914 (defun gnus-parse-format (format spec-alist)
1915 ;; This function parses the FORMAT string with the help of the
1916 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1917 ;; string. If the FORMAT string contains the specifiers %( and %)
1918 ;; the text between them will have the mouse-face text property.
1919 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1920 (if (and gnus-visual gnus-mouse-face)
1921 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1922 (button (substring format (match-beginning 2) (match-end 2)))
1923 (post (substring format (match-beginning 3) (match-end 3))))
1925 (gnus-parse-simple-format pre spec-alist)
1926 (gnus-mouse-face-function
1927 (gnus-parse-simple-format button spec-alist))
1928 (gnus-parse-simple-format post spec-alist)))
1929 (gnus-parse-simple-format
1930 (concat (substring format (match-beginning 1) (match-end 1))
1931 (substring format (match-beginning 2) (match-end 2))
1932 (substring format (match-beginning 3) (match-end 3)))
1934 (gnus-parse-simple-format format spec-alist)))
1936 (defun gnus-parse-simple-format (format spec-alist)
1937 ;; This function parses the FORMAT string with the help of the
1938 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1939 ;; string. The list will consist of the symbol `format', a format
1940 ;; specification string, and a list of forms depending on the
1943 spec flist fstring newspec elem beg)
1945 (gnus-set-work-buffer)
1947 (goto-char (point-min))
1948 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1949 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1951 ;; First check if there are any specs that look anything like
1952 ;; "%12,12A", ie. with a "max width specification". These have
1953 ;; to be treated specially.
1954 (if (setq beg (match-beginning 1))
1957 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1959 (setq beg (match-beginning 2)))
1960 ;; Find the specification from `spec-alist'.
1961 (if (not (setq elem (cdr (assq spec spec-alist))))
1962 (setq elem '("*" ?s)))
1963 ;; Treat user defined format specifiers specially
1964 (and (eq (car elem) 'user-defined)
1967 (list (intern (concat "gnus-user-format-function-"
1973 (delete-region (match-beginning 3) (match-end 3)))
1974 (if (not (zerop max-width))
1975 (let ((el (car elem)))
1976 (cond ((= (car (cdr elem)) ?c)
1977 (setq el (list 'char-to-string el)))
1978 ((= (car (cdr elem)) ?d)
1979 (numberp el) (setq el (list 'int-to-string el))))
1980 (setq flist (cons (gnus-max-width-function el max-width)
1983 (setq flist (cons (car elem) flist))
1984 (setq newspec (car (cdr elem))))
1985 ;; Remove the old specification (and possibly a ",12" string).
1986 (delete-region beg (match-end 2))
1987 ;; Insert the new specification.
1990 (setq fstring (buffer-substring 1 (point-max))))
1991 (cons 'format (cons fstring (nreverse flist)))))
1993 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1994 (defun gnus-read-init-file ()
1996 (or (and (file-exists-p gnus-init-file)
1997 ;; Don't try to load a directory.
1998 (not (file-directory-p gnus-init-file)))
1999 (file-exists-p (concat gnus-init-file ".el"))
2000 (file-exists-p (concat gnus-init-file ".elc")))
2001 (load gnus-init-file nil t)))
2003 (defun gnus-set-work-buffer ()
2004 (if (get-buffer gnus-work-buffer)
2006 (set-buffer gnus-work-buffer)
2008 (set-buffer (get-buffer-create gnus-work-buffer))
2009 (kill-all-local-variables)
2010 (buffer-disable-undo (current-buffer))
2011 (gnus-add-current-to-buffer-list)))
2013 ;; Article file names when saving.
2015 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2016 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2017 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2018 Otherwise, it is like ~/News/news/group/num."
2021 (concat (if (gnus-use-long-file-name 'not-save)
2022 (gnus-capitalize-newsgroup newsgroup)
2023 (gnus-newsgroup-directory-form newsgroup))
2024 "/" (int-to-string (header-number headers)))
2025 (or gnus-article-save-directory "~/News"))))
2027 (string-equal (file-name-directory default)
2028 (file-name-directory last-file))
2029 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2031 (or last-file default))))
2033 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2034 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2035 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2036 Otherwise, it is like ~/News/news/group/num."
2039 (concat (if (gnus-use-long-file-name 'not-save)
2041 (gnus-newsgroup-directory-form newsgroup))
2042 "/" (int-to-string (header-number headers)))
2043 (or gnus-article-save-directory "~/News"))))
2045 (string-equal (file-name-directory default)
2046 (file-name-directory last-file))
2047 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2049 (or last-file default))))
2051 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2052 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2053 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2054 Otherwise, it is like ~/News/news/group/news."
2057 (if (gnus-use-long-file-name 'not-save)
2058 (gnus-capitalize-newsgroup newsgroup)
2059 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2060 (or gnus-article-save-directory "~/News"))))
2062 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2063 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2064 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
2065 Otherwise, it is like ~/News/news/group/news."
2068 (if (gnus-use-long-file-name 'not-save)
2070 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2071 (or gnus-article-save-directory "~/News"))))
2073 ;; For subscribing new newsgroup
2075 (defun gnus-subscribe-hierarchical-interactive (groups)
2076 (let ((groups (sort groups 'string<))
2077 prefixes prefix start ans group starts)
2079 (setq prefixes (list "^"))
2080 (while (and groups prefixes)
2081 (while (not (string-match (car prefixes) (car groups)))
2082 (setq prefixes (cdr prefixes)))
2083 (setq prefix (car prefixes))
2084 (setq start (1- (length prefix)))
2085 (if (and (string-match "[^\\.]\\." (car groups) start)
2088 (concat "^" (substring (car groups) 0 (match-end 0))))
2089 (string-match prefix (car (cdr groups))))
2091 (setq prefixes (cons prefix prefixes))
2092 (message "Descend hierarchy %s? ([y]nsq): "
2093 (substring prefix 1 (1- (length prefix))))
2094 (setq ans (read-char))
2097 (string-match prefix
2098 (setq group (car groups))))
2099 (setq gnus-killed-list
2100 (cons group gnus-killed-list))
2101 (gnus-sethash group group gnus-killed-hashtb)
2102 (setq groups (cdr groups)))
2103 (setq starts (cdr starts)))
2106 (string-match prefix
2107 (setq group (car groups))))
2108 (gnus-sethash group group gnus-killed-hashtb)
2109 (gnus-subscribe-alphabetically (car groups))
2110 (setq groups (cdr groups)))
2111 (setq starts (cdr starts)))
2114 (setq group (car groups))
2115 (setq gnus-killed-list (cons group gnus-killed-list))
2116 (gnus-sethash group group gnus-killed-hashtb)
2117 (setq groups (cdr groups))))
2119 (message "Subscribe %s? ([n]yq)" (car groups))
2120 (setq ans (read-char))
2121 (setq group (car groups))
2123 (gnus-subscribe-alphabetically (car groups))
2124 (gnus-sethash group group gnus-killed-hashtb))
2127 (setq group (car 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 (setq gnus-killed-list (cons group gnus-killed-list))
2133 (gnus-sethash group group gnus-killed-hashtb)))
2134 (setq groups (cdr groups)))))))
2136 (defun gnus-subscribe-randomly (newsgroup)
2137 "Subscribe new NEWSGROUP by making it the first newsgroup."
2138 (gnus-subscribe-newsgroup newsgroup))
2140 (defun gnus-subscribe-alphabetically (newgroup)
2141 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2142 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2143 (let ((groups (cdr gnus-newsrc-alist))
2145 (while (and (not before) groups)
2146 (if (string< newgroup (car (car groups)))
2147 (setq before (car (car groups)))
2148 (setq groups (cdr groups))))
2149 (gnus-subscribe-newsgroup newgroup before)))
2151 (defun gnus-subscribe-hierarchically (newgroup)
2152 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2153 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2155 (set-buffer (find-file-noselect gnus-current-startup-file))
2156 (let ((groupkey newgroup)
2158 (while (and (not before) groupkey)
2159 (goto-char (point-min))
2161 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2162 (while (and (re-search-forward groupkey-re nil t)
2164 (setq before (buffer-substring
2165 (match-beginning 1) (match-end 1)))
2166 (string< before newgroup)))))
2167 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2169 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2170 (substring groupkey (match-beginning 1) (match-end 1)))))
2171 (gnus-subscribe-newsgroup newgroup before))))
2173 (defun gnus-subscribe-interactively (newsgroup)
2174 "Subscribe new NEWSGROUP interactively.
2175 It is inserted in hierarchical newsgroup order if subscribed. If not,
2177 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2178 (gnus-subscribe-hierarchically newsgroup)
2179 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2181 (defun gnus-subscribe-zombies (newsgroup)
2182 "Make new NEWSGROUP a zombie group."
2183 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2185 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2186 "Subscribe new NEWSGROUP.
2187 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2188 the first newsgroup."
2189 ;; We subscribe the group by changing its level to `subscribed'.
2190 (gnus-group-change-level
2191 newsgroup gnus-level-default-subscribed
2192 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2193 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2197 (defun gnus-newsgroup-directory-form (newsgroup)
2198 "Make hierarchical directory name from NEWSGROUP name."
2199 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2200 (len (length newsgroup))
2202 ;; If this is a foreign group, we don't want to translate the
2204 (if (setq idx (string-match ":" newsgroup))
2205 (aset newsgroup idx ?/)
2207 ;; Replace all occurrences of `.' with `/'.
2209 (if (= (aref newsgroup idx) ?.)
2210 (aset newsgroup idx ?/))
2211 (setq idx (1+ idx)))
2214 (defun gnus-make-directory (dir)
2215 "Make DIRECTORY recursively."
2216 (let* ((dir (expand-file-name dir default-directory))
2218 (if (string-match "/$" dir)
2219 (setq dir (substring dir 0 (match-beginning 0))))
2220 (while (not (file-exists-p dir))
2221 (setq dirs (cons dir dirs))
2222 (string-match "/[^/]+$" dir)
2223 (setq dir (substring dir 0 (match-beginning 0))))
2225 (make-directory (car dirs))
2226 (setq dirs (cdr dirs)))))
2228 (defun gnus-capitalize-newsgroup (newsgroup)
2229 "Capitalize NEWSGROUP name."
2230 (and (not (zerop (length newsgroup)))
2231 (concat (char-to-string (upcase (aref newsgroup 0)))
2232 (substring newsgroup 1))))
2236 (defun gnus-simplify-subject (subject &optional re-only)
2237 "Remove `Re:' and words in parentheses.
2238 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2239 (let ((case-fold-search t)) ;Ignore case.
2240 ;; Remove `Re:' and `Re^N:'.
2241 (if (string-match "^re:[ \t]*" subject)
2242 (setq subject (substring subject (match-end 0))))
2243 ;; Remove words in parentheses from end.
2245 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2246 (setq subject (substring subject 0 (match-beginning 0)))))
2247 ;; Return subject string.
2250 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2252 (defun gnus-simplify-subject-fuzzy (subject)
2253 (let ((case-fold-search t))
2255 (gnus-set-work-buffer)
2257 (inline (gnus-simplify-buffer-fuzzy))
2260 (defun gnus-simplify-buffer-fuzzy ()
2261 (goto-char (point-min))
2262 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2263 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2265 (replace-match "" t t))
2266 (goto-char (point-min))
2267 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2268 (replace-match "" t t))
2269 (goto-char (point-min))
2270 (while (re-search-forward "[ \t]+" nil t)
2271 (replace-match " " t t))
2272 (goto-char (point-min))
2273 (while (re-search-forward "[ \t]+$" nil t)
2274 (replace-match "" t t))
2275 (goto-char (point-min))
2276 (while (re-search-forward "^[ \t]+" nil t)
2277 (replace-match "" t t))
2278 (if gnus-simplify-subject-fuzzy-regexp
2279 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2280 (replace-match "" t t))))
2282 ;; Add the current buffer to the list of buffers to be killed on exit.
2283 (defun gnus-add-current-to-buffer-list ()
2284 (or (memq (current-buffer) gnus-buffer-list)
2285 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2287 (defun gnus-string> (s1 s2)
2288 (not (or (string< s1 s2)
2291 ;; Functions accessing headers.
2292 ;; Functions are more convenient than macros in some cases.
2294 (defun gnus-header-number (header)
2295 (header-number header))
2297 (defun gnus-header-subject (header)
2298 (header-subject header))
2300 (defun gnus-header-from (header)
2301 (header-from header))
2303 (defun gnus-header-xref (header)
2304 (header-xref header))
2306 (defun gnus-header-lines (header)
2307 (header-lines header))
2309 (defun gnus-header-date (header)
2310 (header-date header))
2312 (defun gnus-header-id (header)
2315 (defun gnus-header-references (header)
2316 (header-references header))
2318 ;;; General various misc type functions.
2320 (defun gnus-clear-system ()
2321 "Clear all variables and buffers."
2322 ;; Clear Gnus variables.
2323 (let ((variables gnus-variable-list))
2325 (set (car variables) nil)
2326 (setq variables (cdr variables))))
2327 ;; Clear other internal variables.
2328 (setq gnus-list-of-killed-groups nil
2329 gnus-have-read-active-file nil
2330 gnus-newsrc-alist nil
2331 gnus-newsrc-hashtb nil
2332 gnus-killed-list nil
2333 gnus-zombie-list nil
2334 gnus-killed-hashtb nil
2335 gnus-active-hashtb nil
2336 gnus-moderated-list nil
2337 gnus-description-hashtb nil
2338 gnus-newsgroup-headers nil
2339 gnus-newsgroup-headers-hashtb-by-number nil
2340 gnus-newsgroup-name nil
2341 gnus-server-alist nil
2342 gnus-current-select-method nil)
2343 ;; Reset any score variables.
2344 (and (boundp 'gnus-score-cache)
2345 (set 'gnus-score-cache nil))
2346 (and (boundp 'gnus-internal-global-score-files)
2347 (set 'gnus-internal-global-score-files nil))
2348 ;; Kill the startup file.
2349 (and gnus-current-startup-file
2350 (get-file-buffer gnus-current-startup-file)
2351 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2352 ;; Save any cache buffers.
2353 (and gnus-use-cache (gnus-cache-save-buffers))
2354 ;; Clear the dribble buffer.
2355 (gnus-dribble-clear)
2356 ;; Kill global KILL file buffer.
2357 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2358 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2359 (gnus-kill-buffer nntp-server-buffer)
2360 ;; Kill Gnus buffers.
2361 (while gnus-buffer-list
2362 (gnus-kill-buffer (car gnus-buffer-list))
2363 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2365 (defun gnus-windows-old-to-new (setting)
2366 (if (symbolp setting)
2368 (cond ((eq setting 'SelectArticle)
2370 ((eq setting 'SelectSubject)
2372 ((eq setting 'SelectNewsgroup)
2375 (if (or (listp setting)
2376 (not (and gnus-window-configuration
2377 (memq setting '(group summary article)))))
2379 (let* ((setting (if (eq setting 'group)
2380 (if (assq 'newsgroup gnus-window-configuration)
2382 'newsgroups) setting))
2383 (elem (car (cdr (assq setting gnus-window-configuration))))
2384 (total (apply '+ elem))
2385 (types '(group summary article))
2386 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2391 (or (zerop (nth i elem))
2393 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2394 (setq out (cons (if (eq pbuf (nth i types))
2395 (vector (nth i types) perc 'point)
2396 (vector (nth i types) perc))
2399 (list (nreverse out)))))
2401 (defun gnus-add-configuration (conf)
2402 (setq gnus-buffer-configuration
2403 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2404 gnus-buffer-configuration))))
2406 (defun gnus-configure-windows (setting &optional force)
2407 (setq setting (gnus-windows-old-to-new setting))
2408 (let ((r (if (symbolp setting)
2409 (cdr (assq setting gnus-buffer-configuration))
2411 (in-buf (current-buffer))
2412 rule val w height hor ohor heights sub jump-buffer
2413 rel total to-buf all-visible)
2414 (or r (error "No such setting: %s" setting))
2416 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2417 ;; All the windows mentioned are already visibe, so we just
2418 ;; put point in the assigned buffer, and do not touch the
2420 (select-window (get-buffer-window all-visible))
2422 ;; Either remove all windows or just remove all Gnus windows.
2423 (if gnus-use-full-window
2424 (delete-other-windows)
2425 (gnus-remove-some-windows)
2426 (switch-to-buffer nntp-server-buffer))
2432 ;; We have to do the (possible) horizontal splitting before the
2434 (if (and (listp (car hor))
2435 (eq (car (car hor)) 'horizontal))
2439 (if (integerp (nth 1 (car hor)))
2441 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2443 (setq hor (cdr hor))))
2445 ;; Go through the rules and eval the elements that are to be
2448 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2450 ;; Expand short buffer name.
2451 (setq w (aref val 0))
2452 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2454 (setq val (apply 'vector (mapcar 'identity val)))
2456 (setq ohor (cons val ohor))))
2457 (setq hor (cdr hor)))
2458 (setq rule (cons (nreverse ohor) rule))
2460 (setq rule (nreverse rule))
2462 ;; We tally the window sizes.
2463 (setq total (window-height))
2465 (setq hor (car rule))
2466 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2467 (setq hor (cdr hor)))
2470 (setq rel (aref (car hor) 1)
2472 (cond ((and (floatp rel) (= 1.0 rel))
2477 (max (floor (* total rel)) 4)))
2479 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2481 (setq heights (nreverse heights)
2484 ;; We then go through these heighs and create windows for them.
2486 (setq height (car heights)
2487 heights (cdr heights))
2489 (setq height (- total sub)))
2491 (split-window nil height))
2492 (setq to-buf (aref (car hor) 0))
2497 (symbol-value (aref (car hor) 0)))
2499 (aref (car hor) 0))))
2500 (and (> (length (car hor)) 2)
2501 (eq (aref (car hor) 2) 'point)
2502 (setq jump-buffer (current-buffer)))
2504 (setq hor (cdr hor)))
2506 (setq rule (cdr rule)))
2508 ;; Finally, we pop to the buffer that's supposed to have point.
2509 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2511 (select-window (get-buffer-window jump-buffer))
2512 (set-buffer jump-buffer))))
2514 (defun gnus-all-windows-visible-p (rule)
2515 (let (invisible hor jump-buffer val buffer)
2516 ;; Go through the rules and eval the elements that are to be
2518 (while (and rule (not invisible))
2519 (setq hor (car rule)
2521 (while (and hor (not invisible))
2522 (if (setq val (if (vectorp (car hor))
2524 (if (not (eq (car (car hor)) 'horizontal))
2527 ;; Expand short buffer name.
2528 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2530 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2532 (and (> (length val) 2) (eq 'point (aref val 2))
2533 (setq jump-buffer buffer))
2534 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2535 (setq hor (cdr hor))))
2536 (and (not invisible) jump-buffer)))
2539 (defun gnus-remove-some-windows ()
2540 (let ((buffers gnus-window-to-buffer)
2544 ;; Remove windows on all known Gnus buffers.
2546 (setq buf (cdr (car buffers)))
2548 (setq buf (and (boundp buf) (symbol-value buf))))
2550 (get-buffer-window buf)
2555 (switch-to-buffer nntp-server-buffer)
2557 (delete-window (get-buffer-window buf)))))
2558 (setq buffers (cdr buffers)))
2559 ;; Remove windows on *all* summary buffers.
2560 (let ((buffers (buffer-list)))
2562 (if (and (string-match
2563 "^\\*Summary" (or (buffer-name (car buffers)) ""))
2564 (get-buffer-window (car buffers)))
2565 (delete-window (get-buffer-window (car buffers))))
2566 (setq buffers (cdr buffers)))))))
2568 (defun gnus-version ()
2569 "Version numbers of this version of Gnus."
2571 (let ((methods gnus-valid-select-methods)
2574 ;; Go through all the legal select methods and add their version
2575 ;; numbers to the total version string. Only the backends that are
2576 ;; currently in use will have their message numbers taken into
2579 (setq meth (intern (concat (car (car methods)) "-version")))
2581 (stringp (symbol-value meth))
2582 (setq mess (concat mess "; " (symbol-value meth))))
2583 (setq methods (cdr methods)))
2584 (gnus-message 2 mess)))
2586 (defun gnus-info-find-node ()
2587 "Find Info documentation of Gnus."
2589 ;; Enlarge info window if needed.
2590 (let ((mode major-mode))
2591 (gnus-configure-windows 'info)
2592 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2594 (defun gnus-overload-functions (&optional overloads)
2595 "Overload functions specified by optional argument OVERLOADS.
2596 If nothing is specified, use the variable gnus-overload-functions."
2598 (overloads (or overloads gnus-overload-functions)))
2600 (setq defs (car overloads))
2601 (setq overloads (cdr overloads))
2602 ;; Load file before overloading function if necessary. Make
2603 ;; sure we cannot use `require' always.
2604 (and (not (fboundp (car defs)))
2605 (car (cdr (cdr defs)))
2606 (load (car (cdr (cdr defs))) nil 'nomessage))
2607 (fset (car defs) (car (cdr defs))))))
2609 (defun gnus-replace-chars-in-string (string from to)
2610 "Replace characters in STRING from FROM to TO."
2611 (let ((string (substring string 0)) ;Copy string.
2612 (len (length string))
2614 ;; Replace all occurrences of FROM with TO.
2616 (if (= (aref string idx) from)
2617 (aset string idx to))
2618 (setq idx (1+ idx)))
2621 (defun gnus-days-between (date1 date2)
2622 ;; Return the number of days between date1 and date2.
2623 (- (gnus-day-number date1) (gnus-day-number date2)))
2625 (defun gnus-day-number (date)
2626 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2627 (timezone-parse-date date))))
2628 (timezone-absolute-from-gregorian
2629 (nth 1 dat) (nth 2 dat) (car dat))))
2631 ;; Returns a floating point number that says how many seconds have
2632 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2633 (defun gnus-seconds-since-epoch (date)
2634 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2635 (timezone-parse-date date)))
2636 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2637 (timezone-parse-time
2638 (aref (timezone-parse-date date) 3))))
2639 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2640 (timezone-parse-date "Jan 1 12:00:00 1970")))
2641 (tday (- (timezone-absolute-from-gregorian
2642 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2643 (timezone-absolute-from-gregorian
2644 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2646 (* (nth 1 ttime) 60)
2647 (* 1.0 (nth 0 ttime) 60 60)
2648 (* 1.0 tday 60 60 24))))
2650 (defun gnus-file-newer-than (file date)
2651 (let ((fdate (nth 5 (file-attributes file))))
2652 (or (> (car fdate) (car date))
2653 (and (= (car fdate) (car date))
2654 (> (nth 1 fdate) (nth 1 date))))))
2656 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2658 (defun gnus-y-or-n-p (prompt)
2663 (defun gnus-yes-or-no-p (prompt)
2665 (yes-or-no-p prompt)
2668 ;; Check whether to use long file names.
2669 (defun gnus-use-long-file-name (symbol)
2670 ;; The variable has to be set...
2671 (and gnus-use-long-file-name
2672 ;; If it isn't a list, then we return t.
2673 (or (not (listp gnus-use-long-file-name))
2674 ;; If it is a list, and the list contains `symbol', we
2676 (not (memq symbol gnus-use-long-file-name)))))
2678 ;; I suspect there's a better way, but I haven't taken the time to do
2679 ;; it yet. -erik selberg@cs.washington.edu
2680 (defun gnus-dd-mmm (messy-date)
2681 "Return a string like DD-MMM from a big messy string"
2682 (let ((datevec (timezone-parse-date messy-date)))
2684 (or (aref datevec 2) "??")
2687 (nth (1- (string-to-number (aref datevec 1)))
2688 timezone-months-assoc))
2691 ;; Make a hash table (default and minimum size is 255).
2692 ;; Optional argument HASHSIZE specifies the table size.
2693 (defun gnus-make-hashtable (&optional hashsize)
2694 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2696 ;; Make a number that is suitable for hashing; bigger than MIN and one
2698 (defun gnus-create-hash-size (min)
2704 ;; Show message if message has a lower level than `gnus-verbose'.
2705 ;; Guide-line for numbers:
2706 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2707 ;; for things that take a long time, 7 - not very important messages
2708 ;; on stuff, 9 - messages inside loops.
2709 (defun gnus-message (level &rest args)
2710 (if (<= level gnus-verbose)
2711 (apply 'message args)
2712 ;; We have to do this format thingie here even if the result isn't
2713 ;; shown - the return value has to be the same as the return value
2715 (apply 'format args)))
2717 ;; Generate a unique new group name.
2718 (defun gnus-generate-new-group-name (leaf)
2721 (while (gnus-gethash name gnus-newsrc-hashtb)
2722 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2725 (defun gnus-find-file-noselect (file &optional force)
2726 "Does vaguely the same as find-file-noselect. No hooks are run."
2728 (if (setq buf (get-file-buffer file))
2730 (setq buf (create-file-buffer file))
2737 (and (file-readable-p file)
2738 (insert-file-contents file))
2739 (set-visited-file-name file)
2740 (set-buffer-modified-p nil)
2741 (current-buffer)))))
2743 ;;; List and range functions
2745 (defun gnus-last-element (list)
2746 "Return last element of LIST."
2748 (setq list (cdr list)))
2751 (defun gnus-copy-sequence (list)
2752 "Do a complete, total copy of a list."
2753 (if (and (consp list) (not (consp (cdr list))))
2754 (cons (car list) (cdr list))
2755 (mapcar (lambda (elem) (if (consp elem)
2756 (if (consp (cdr elem))
2757 (gnus-copy-sequence elem)
2758 (cons (car elem) (cdr elem)))
2762 (defun gnus-set-difference (list1 list2)
2763 "Return a list of elements of LIST1 that do not appear in LIST2."
2764 (let ((list1 (copy-sequence list1)))
2766 (setq list1 (delq (car list2) list1))
2767 (setq list2 (cdr list2)))
2770 (defun gnus-sorted-complement (list1 list2)
2771 "Return a list of elements of LIST1 that do not appear in LIST2.
2772 Both lists have to be sorted over <."
2774 (if (or (null list1) (null list2))
2776 (while (and list1 list2)
2777 (cond ((= (car list1) (car list2))
2778 (setq list1 (cdr list1)
2780 ((< (car list1) (car list2))
2781 (setq out (cons (car list1) out))
2782 (setq list1 (cdr list1)))
2784 (setq out (cons (car list2) out))
2785 (setq list2 (cdr list2)))))
2786 (nconc (nreverse out) (or list1 list2)))))
2788 (defun gnus-intersection (list1 list2)
2791 (if (memq (car list2) list1)
2792 (setq result (cons (car list2) result)))
2793 (setq list2 (cdr list2)))
2796 (defun gnus-sorted-intersection (list1 list2)
2797 ;; LIST1 and LIST2 have to be sorted over <.
2799 (while (and list1 list2)
2800 (cond ((= (car list1) (car list2))
2801 (setq out (cons (car list1) out)
2804 ((< (car list1) (car list2))
2805 (setq list1 (cdr list1)))
2807 (setq list2 (cdr list2)))))
2810 (defun gnus-set-sorted-intersection (list1 list2)
2811 ;; LIST1 and LIST2 have to be sorted over <.
2812 ;; This function modifies LIST1.
2813 (let* ((top (cons nil list1))
2815 (while (and list1 list2)
2816 (cond ((= (car list1) (car list2))
2820 ((< (car list1) (car list2))
2821 (setcdr prev (cdr list1))
2822 (setq list1 (cdr list1)))
2824 (setq list2 (cdr list2)))))
2828 (defun gnus-compress-sequence (numbers &optional always-list)
2829 "Convert list of numbers to a list of ranges or a single range.
2830 If ALWAYS-LIST is non-nil, this function will always release a list of
2832 (let* ((first (car numbers))
2833 (last (car numbers))
2837 (if (not (listp (cdr numbers)))
2840 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2841 ((= (1+ last) (car numbers)) ;Still in sequence
2842 (setq last (car numbers)))
2843 (t ;End of one sequence
2845 (cons (if (= first last) first
2846 (cons first last)) result))
2847 (setq first (car numbers))
2848 (setq last (car numbers))))
2849 (setq numbers (cdr numbers)))
2850 (if (and (not always-list) (null result))
2851 (if (= first last) (list first) (cons first last))
2852 (nreverse (cons (if (= first last) first (cons first last))
2855 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2856 (defun gnus-uncompress-range (ranges)
2857 "Expand a list of ranges into a list of numbers.
2858 RANGES is either a single range on the form `(num . num)' or a list of
2860 (let (first last result)
2864 ((not (listp (cdr ranges)))
2865 (setq first (car ranges))
2866 (setq last (cdr ranges))
2867 (while (<= first last)
2868 (setq result (cons first result))
2869 (setq first (1+ first)))
2873 (if (atom (car ranges))
2874 (if (numberp (car ranges))
2875 (setq result (cons (car ranges) result)))
2876 (setq first (car (car ranges)))
2877 (setq last (cdr (car ranges)))
2878 (while (<= first last)
2879 (setq result (cons first result))
2880 (setq first (1+ first))))
2881 (setq ranges (cdr ranges)))
2882 (nreverse result)))))
2884 (defun gnus-add-to-range (ranges list)
2885 "Return a list of ranges that has all articles from both RANGES and LIST.
2886 Note: LIST has to be sorted over `<'."
2888 (gnus-compress-sequence list t)
2889 (setq list (copy-sequence list))
2890 (or (listp (cdr ranges))
2891 (setq ranges (list ranges)))
2893 ilist lowest highest temp)
2894 (while (and ranges list)
2896 (setq lowest (or (and (atom (car ranges)) (car ranges))
2897 (car (car ranges))))
2898 (while (and list (cdr list) (< (car (cdr list)) lowest))
2899 (setq list (cdr list)))
2900 (if (< (car ilist) lowest)
2903 (setq list (cdr list))
2905 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2906 (setq highest (or (and (atom (car ranges)) (car ranges))
2907 (cdr (car ranges))))
2908 (while (and list (<= (car list) highest))
2909 (setq list (cdr list)))
2910 (setq ranges (cdr ranges)))
2912 (setq out (nconc (gnus-compress-sequence list t) out)))
2913 (setq out (sort out (lambda (r1 r2)
2914 (< (or (and (atom r1) r1) (car r1))
2915 (or (and (atom r2) r2) (car r2))))))
2918 (if (atom (car ranges))
2920 (if (atom (car (cdr ranges)))
2921 (if (= (1+ (car ranges)) (car (cdr ranges)))
2923 (setcar ranges (cons (car ranges)
2924 (car (cdr ranges))))
2925 (setcdr ranges (cdr (cdr ranges)))))
2926 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2928 (setcar (car (cdr ranges)) (car ranges))
2929 (setcar ranges (car (cdr ranges)))
2930 (setcdr ranges (cdr (cdr ranges)))))))
2932 (if (atom (car (cdr ranges)))
2933 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2935 (setcdr (car ranges) (car (cdr ranges)))
2936 (setcdr ranges (cdr (cdr ranges)))))
2937 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2939 (setcdr (car ranges) (cdr (car (cdr ranges))))
2940 (setcdr ranges (cdr (cdr ranges))))))))
2941 (setq ranges (cdr ranges)))
2944 (defun gnus-remove-from-range (ranges list)
2945 "Return a list of ranges that has all articles from LIST removed from RANGES.
2946 Note: LIST has to be sorted over `<'."
2947 ;; !!! This function shouldn't look like this, but I've got a headache.
2948 (gnus-compress-sequence
2949 (gnus-sorted-complement
2950 (gnus-uncompress-range ranges) list)))
2952 (defun gnus-member-of-range (number ranges)
2953 (if (not (listp (cdr ranges)))
2954 (and (>= number (car ranges))
2955 (<= number (cdr ranges)))
2958 (if (numberp (car ranges))
2959 (>= number (car ranges))
2960 (>= number (car (car ranges))))
2962 (if (if (numberp (car ranges))
2963 (= number (car ranges))
2964 (and (>= number (car (car ranges)))
2965 (<= number (cdr (car ranges)))))
2966 (setq not-stop nil))
2967 (setq ranges (cdr ranges)))
2975 (defvar gnus-group-mode-map nil)
2976 (defvar gnus-group-group-map nil)
2977 (defvar gnus-group-mark-map nil)
2978 (defvar gnus-group-list-map nil)
2979 (defvar gnus-group-sub-map nil)
2980 (put 'gnus-group-mode 'mode-class 'special)
2982 (if gnus-group-mode-map
2984 (setq gnus-group-mode-map (make-keymap))
2985 (suppress-keymap gnus-group-mode-map)
2986 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2987 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2988 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2989 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2990 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2991 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2992 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2993 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2994 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2995 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2996 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2997 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2998 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2999 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3000 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3001 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3002 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3003 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3004 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3005 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3006 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3007 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3008 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3009 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3010 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3011 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3012 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3013 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3014 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3015 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3016 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3017 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3018 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3019 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3020 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3021 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3022 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3023 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3024 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3025 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3026 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3027 (define-key gnus-group-mode-map "V" 'gnus-version)
3028 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3029 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3030 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3031 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3032 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3033 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3034 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3035 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3036 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3037 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3038 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3039 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3040 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3041 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3042 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3044 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3045 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3046 (define-prefix-command 'gnus-group-mark-map)
3047 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3048 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3049 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3050 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3052 (define-prefix-command 'gnus-group-group-map)
3053 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3054 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3055 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3056 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3057 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3058 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3059 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3060 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3061 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3062 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3063 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3064 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3065 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3066 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3067 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3068 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3069 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3070 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3072 (define-prefix-command 'gnus-group-list-map)
3073 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3074 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3075 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3076 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3077 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3078 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3079 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3080 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3081 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3083 (define-prefix-command 'gnus-group-sub-map)
3084 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3085 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3086 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3087 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3088 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3089 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3090 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3091 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3093 (defun gnus-group-mode ()
3094 "Major mode for reading news.
3096 All normal editing commands are switched off.
3097 \\<gnus-group-mode-map>
3098 The group buffer lists (some of) the groups available. For instance,
3099 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3100 lists all zombie groups.
3102 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3103 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3105 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3107 The following commands are available:
3109 \\{gnus-group-mode-map}"
3111 (if gnus-visual (gnus-group-make-menu-bar))
3112 (kill-all-local-variables)
3113 (setq mode-line-modified "-- ")
3114 (make-local-variable 'mode-line-format)
3115 (setq mode-line-format (copy-sequence mode-line-format))
3116 (and (equal (nth 3 mode-line-format) " ")
3117 (setcar (nthcdr 3 mode-line-format) ""))
3118 (setq major-mode 'gnus-group-mode)
3119 (setq mode-name "Group")
3120 (gnus-group-set-mode-line)
3121 (setq mode-line-process nil)
3122 (use-local-map gnus-group-mode-map)
3123 (buffer-disable-undo (current-buffer))
3124 (setq truncate-lines t)
3125 (setq buffer-read-only t)
3126 (run-hooks 'gnus-group-mode-hook))
3128 (defun gnus-mouse-pick-group (e)
3131 (gnus-group-read-group nil))
3134 (defun gnus-no-server (&optional arg)
3136 If ARG is a positive number, Gnus will use that as the
3137 startup level. If ARG is nil, Gnus will be started at level 2.
3138 If ARG is non-nil and not a positive number, Gnus will
3139 prompt the user for the name of an NNTP server to use.
3140 As opposed to `gnus', this command will not connect to the local server."
3142 (setq gnus-group-use-permanent-levels t)
3143 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3145 (defalias '\(ding\) 'gnus)
3148 (defun gnus (&optional arg dont-connect)
3150 If ARG is non-nil and a positive number, Gnus will use that as the
3151 startup level. If ARG is non-nil and not a positive number, Gnus will
3152 prompt the user for the name of an NNTP server to use."
3154 (if (get-buffer gnus-group-buffer)
3156 (switch-to-buffer gnus-group-buffer)
3157 (gnus-group-get-new-news))
3159 (nnheader-init-server-buffer)
3160 (gnus-read-init-file)
3161 (let ((level (and arg (numberp arg) (> arg 0) arg))
3165 (gnus-group-setup-buffer)
3168 (gnus-start-news-server (and arg (not level))))))
3169 (if (and (not dont-connect)
3172 (run-hooks 'gnus-startup-hook)
3173 ;; NNTP server is successfully open.
3174 (gnus-update-format-specifications)
3175 (gnus-summary-make-display-table)
3176 (let ((buffer-read-only nil))
3178 (if (not gnus-inhibit-startup-message)
3180 (gnus-group-startup-message)
3182 (gnus-setup-news nil level)
3183 (and gnus-use-dribble-file (gnus-dribble-open))
3184 (gnus-group-list-groups level)
3185 (gnus-configure-windows 'group))))))
3187 (defun gnus-unload ()
3188 "Unload all Gnus features."
3190 (let ((history load-history)
3193 (and (string-match "^gnus" (car (car history)))
3194 (setq feature (cdr (assq 'provide (car history))))
3195 (unload-feature feature 'force))
3196 (setq history (cdr history)))))
3198 (defun gnus-group-startup-message (&optional x y)
3199 "Insert startup message in current buffer."
3200 ;; Insert the message.
3216 ;; And then hack it.
3217 ;; 18 is the longest line.
3218 (indent-rigidly (point-min) (point-max)
3219 (/ (max (- (window-width) (or x 28)) 0) 2))
3220 (goto-char (point-min))
3221 ;; +4 is fuzzy factor.
3222 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3225 (goto-char (point-min))
3226 (search-forward "Praxis")
3227 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3228 (goto-char (point-min)))
3230 (defun gnus-group-setup-buffer ()
3231 (or (get-buffer gnus-group-buffer)
3233 (switch-to-buffer gnus-group-buffer)
3234 (gnus-add-current-to-buffer-list)
3236 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3238 (defun gnus-group-list-groups (level &optional unread)
3239 "List newsgroups with level LEVEL or lower that have unread articles.
3240 Default is all subscribed groups.
3241 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3242 (interactive (list (and current-prefix-arg
3243 (prefix-numeric-value current-prefix-arg))))
3244 (if gnus-group-use-permanent-levels
3246 (setq gnus-group-default-list-level
3247 (or level gnus-group-default-list-level))
3248 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3249 (setq level (or level gnus-group-default-list-level
3250 gnus-level-subscribed)))
3251 (gnus-group-setup-buffer) ;May call from out of group buffer
3252 (let ((case-fold-search nil)
3253 (group (gnus-group-group-name)))
3254 (funcall gnus-group-prepare-function level unread nil)
3255 (if (zerop (buffer-size))
3256 (gnus-message 5 gnus-no-groups-message)
3257 (goto-char (point-min))
3259 ;; Go to the first group with unread articles.
3260 (gnus-group-search-forward nil nil nil t)
3261 ;; Find the right group to put point on. If the current group
3262 ;; has disapeared in the new listing, try to find the next
3263 ;; one. If no next one can be found, just leave point at the
3264 ;; first newsgroup in the buffer.
3265 (if (not (gnus-goto-char
3266 (text-property-any (point-min) (point-max)
3267 'gnus-group (intern group))))
3268 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3270 (not (gnus-goto-char
3272 (point-min) (point-max) 'gnus-group
3273 (intern (car (car newsrc)))))))
3274 (setq newsrc (cdr newsrc)))
3275 (or newsrc (progn (goto-char (point-max))
3276 (forward-line -1))))))
3277 ;; Adjust cursor point.
3278 (gnus-group-position-cursor))))
3280 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3281 "List all newsgroups with unread articles of level LEVEL or lower.
3282 If ALL is non-nil, list groups that have no unread articles.
3283 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3284 If REGEXP, only list groups matching REGEXP."
3285 (set-buffer gnus-group-buffer)
3286 (let ((buffer-read-only nil)
3287 (newsrc (cdr gnus-newsrc-alist))
3288 (lowest (or lowest 1))
3289 info clevel unread group)
3291 (if (< lowest gnus-level-zombie)
3292 ;; List living groups.
3294 (setq info (car newsrc)
3297 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3298 (and unread ; This group might be bogus
3300 (string-match regexp group))
3301 (<= (setq clevel (car (cdr info))) level)
3303 (or all ; We list all groups?
3304 (eq unread t) ; We list unactivated groups
3305 (> unread 0) ; We list groups with unread articles
3306 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3307 (gnus-group-insert-group-line
3308 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3310 ;; List dead groups.
3311 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3312 (gnus-group-prepare-flat-list-dead
3313 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3314 gnus-level-zombie ?Z
3316 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3317 (gnus-group-prepare-flat-list-dead
3318 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3319 gnus-level-killed ?K regexp))
3321 (gnus-group-set-mode-line)
3322 (setq gnus-have-all-newsgroups all)
3323 (run-hooks 'gnus-group-prepare-hook)))
3325 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3326 ;; List zombies and killed lists somehwat faster, which was
3327 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3328 ;; this by ignoring the group format specification altogether.
3331 (setq group (car groups)
3332 groups (cdr groups))
3333 (if (or (not regexp)
3334 (string-match regexp group))
3337 (insert (format " %c *: %s\n" mark group))
3338 (add-text-properties
3340 (list 'gnus-group (intern group)
3342 'gnus-level level)))))))
3344 (defun gnus-group-real-name (group)
3345 "Find the real name of a foreign newsgroup."
3346 (if (string-match ":[^:]+$" group)
3347 (substring group (1+ (match-beginning 0)))
3350 (defun gnus-group-prefixed-name (group method)
3351 "Return the whole name from GROUP and METHOD."
3352 (and (stringp method) (setq method (gnus-server-to-method method)))
3353 (concat (format "%s" (car method))
3355 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3356 (not (string= (nth 1 method) "")))
3357 (concat "+" (nth 1 method)))
3360 (defun gnus-group-real-prefix (group)
3361 "Return the prefix of the current group name."
3362 (if (string-match "^[^:]+:" group)
3363 (substring group 0 (match-end 0))
3366 (defun gnus-group-method-name (group)
3367 "Return the method used for selecting GROUP."
3368 (let ((prefix (gnus-group-real-prefix group)))
3369 (if (equal prefix "")
3371 (if (string-match "^[^\\+]+\\+" prefix)
3372 (list (intern (substring prefix 0 (1- (match-end 0))))
3373 (substring prefix (match-end 0) (1- (length prefix))))
3374 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3376 (defun gnus-group-foreign-p (group)
3377 "Return nil if GROUP is native, non-nil if it is foreign."
3378 (string-match ":" group))
3380 (defun gnus-group-set-info (info &optional method-only-group part)
3381 (let* ((entry (gnus-gethash
3382 (or method-only-group (car info)) gnus-newsrc-hashtb))
3384 (info (if method-only-group (nth 2 entry) info)))
3385 (if (not method-only-group)
3388 (error "Trying to change non-existent group %s" method-only-group))
3389 ;; We have recevied parts of the actual group info - either the
3390 ;; select method or the group parameters. We first check
3391 ;; whether we have to extend the info, and if so, do that.
3392 (let ((len (length info))
3393 (total (if (eq part 'method) 5 6)))
3395 (setcdr (nthcdr (1- len) info)
3396 (make-list (- total len) nil)))
3397 ;; Then we enter the new info.
3398 (setcar (nthcdr (1- total) info) part-info)))
3399 ;; We uncompress some lists of marked articles.
3401 (if (not (setq marked (nth 3 info)))
3404 (or (eq 'score (car (car marked)))
3405 (eq 'bookmark (car (car marked)))
3406 (eq 'killed (car (car marked)))
3407 (setcdr (car marked)
3408 (gnus-uncompress-range (cdr (car marked)))))
3409 (setq marked (cdr marked)))))
3412 ;; This is a new group, so we just create it.
3414 (set-buffer gnus-group-buffer)
3416 ;; It's a foreign group...
3417 (gnus-group-make-group
3418 (gnus-group-real-name (car info))
3419 (prin1-to-string (car (nth 4 info)))
3420 (nth 1 (nth 4 info)))
3421 ;; It's a native group.
3422 (gnus-group-make-group
3424 (prin1-to-string (car gnus-select-method))
3425 (nth 1 gnus-select-method)))
3426 (gnus-message 6 "Note: New group created")
3428 (gnus-gethash (gnus-group-prefixed-name
3429 (gnus-group-real-name (car info))
3430 (or (nth 4 info) gnus-select-method))
3431 gnus-newsrc-hashtb))))
3432 ;; Whether it was a new group or not, we now have the entry, so we
3433 ;; can do the update.
3436 (setcar (nthcdr 2 entry) info)
3437 (if (and (not (eq (car entry) t))
3438 (gnus-gethash (car info) gnus-active-hashtb))
3439 (let ((marked (nth 3 info)))
3441 (max 0 (- (length (gnus-list-of-unread-articles
3443 (length (cdr (assq 'tick marked)))
3444 (length (cdr (assq 'dormant marked)))))))))
3445 (error "No such group: %s" (car info)))))
3447 (defun gnus-group-set-method-info (group select-method)
3448 (gnus-group-set-info select-method group 'method))
3450 (defun gnus-group-set-params-info (group params)
3451 (gnus-group-set-info params group 'params))
3453 (defun gnus-group-update-group-line ()
3454 "This function updates the current line in the newsgroup buffer and
3455 moves the point to the colon."
3456 (let* ((buffer-read-only nil)
3457 (group (gnus-group-group-name))
3458 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3461 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3464 (delete-region (point) (progn (forward-line 1) (point)))
3465 (gnus-group-insert-group-line-info group)
3467 (gnus-group-position-cursor)))
3469 (defun gnus-group-insert-group-line-info (group)
3470 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3474 (setq info (nth 2 entry))
3475 (gnus-group-insert-group-line
3476 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3477 (setq active (gnus-gethash group gnus-active-hashtb))
3478 (gnus-group-insert-group-line
3480 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3481 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3483 (defun gnus-group-insert-group-line (gformat group level marked number method)
3484 (let* ((gformat (or gformat gnus-group-line-format-spec))
3485 (active (gnus-gethash group gnus-active-hashtb))
3486 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3487 (number-of-dormant (length (cdr (assq 'dormant marked))))
3488 (number-of-ticked (length (cdr (assq 'tick marked))))
3489 (number-of-ticked-and-dormant
3490 (+ number-of-ticked number-of-dormant))
3491 (number-of-unread-unticked
3492 (if (numberp number) (int-to-string (max 0 number))
3495 (if (numberp number)
3496 (max 0 (- number-total number))
3498 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3499 ((<= level gnus-level-unsubscribed) ?U)
3500 ((= level gnus-level-zombie) ?Z)
3502 (qualified-group (gnus-group-real-name group))
3503 (newsgroup-description
3504 (if gnus-description-hashtb
3505 (or (gnus-gethash group gnus-description-hashtb) "")
3507 (moderated (if (member group gnus-moderated-list) ?m ? ))
3508 (moderated-string (if (eq moderated ?m) "(m)" ""))
3509 (method (gnus-server-get-method group method))
3510 (news-server (or (car (cdr method)) ""))
3511 (news-method (or (car method) ""))
3513 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3517 (> number-of-ticked 0))
3519 (number (if (eq number t) "*" (+ number number-of-dormant
3521 (process-marked (if (member qualified-group gnus-group-marked)
3522 gnus-process-mark ? ))
3523 (buffer-read-only nil)
3524 header ; passed as parameter to user-funcs.
3529 (insert (eval gformat))
3531 (add-text-properties
3532 b (1+ b) (list 'gnus-group (intern group)
3533 'gnus-unread (if (numberp number)
3534 (string-to-int number-of-unread-unticked)
3537 'gnus-level level))))
3539 (defun gnus-group-update-group (group &optional visible-only)
3540 "Update newsgroup info of GROUP.
3541 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3543 (set-buffer gnus-group-buffer)
3544 (let ((buffer-read-only nil)
3546 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3549 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3551 ;; Buffer may be narrowed.
3554 ;; Search a line to modify. If the buffer is large, the search
3555 ;; takes long time. In most cases, current point is on the line
3556 ;; we are looking for. So, first of all, check current line.
3559 (eq (get-text-property (point) 'gnus-group)
3564 (point-min) (point-max) 'gnus-group (intern group)))))
3565 ;; GROUP is listed in current buffer. So, delete old line.
3569 (delete-region (point) (progn (forward-line 1) (point))))
3570 ;; No such line in the buffer, find out where it's supposed to
3571 ;; go, and insert it there (or at the end of the buffer).
3572 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3575 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3581 (point-min) (point-max)
3582 'gnus-group (intern (car (car entry)))))))
3583 (setq entry (cdr entry)))
3584 (or entry (goto-char (point-max)))))))
3585 (if (or visible (not visible-only))
3586 (gnus-group-insert-group-line-info group))
3587 (gnus-group-set-mode-line))))
3589 (defun gnus-group-set-mode-line ()
3590 (if (memq 'group gnus-updated-mode-lines)
3591 (let* ((gformat (or gnus-group-mode-line-format-spec
3592 (setq gnus-group-mode-line-format-spec
3594 gnus-group-mode-line-format
3595 gnus-group-mode-line-format-alist))))
3596 (news-server (car (cdr gnus-select-method)))
3597 (news-method (car gnus-select-method))
3599 (mode-string (eval gformat)))
3600 (setq mode-string (eval gformat))
3601 (if (> (length mode-string) max-len)
3602 (setq mode-string (substring mode-string 0 (- max-len 4))))
3603 (setq mode-line-buffer-identification mode-string)
3604 (set-buffer-modified-p t))))
3606 (defun gnus-group-group-name ()
3607 "Get the name of the newsgroup on the current line."
3608 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3609 (and group (symbol-name group))))
3611 (defun gnus-group-group-level ()
3612 "Get the level of the newsgroup on the current line."
3613 (get-text-property (gnus-point-at-bol) 'gnus-level))
3615 (defun gnus-group-group-unread ()
3616 "Get the number of unread articles of the newsgroup on the current line."
3617 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3619 (defun gnus-group-search-forward (&optional backward all level first-too)
3620 "Find the next newsgroup with unread articles.
3621 If BACKWARD is non-nil, find the previous newsgroup instead.
3622 If ALL is non-nil, just find any newsgroup.
3623 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3625 If FIRST-TOO, the current line is also eligible as a target."
3626 (let ((way (if backward -1 1))
3627 (low gnus-level-killed)
3630 (if (and backward (progn (beginning-of-line)) (bobp))
3632 (or first-too (forward-line way))
3640 (get-text-property (point) 'gnus-unread)))
3641 (or (eq unread t) (and unread (> unread 0))))
3642 (setq lev (get-text-property (point)
3644 (<= lev gnus-level-subscribed)))
3646 (and (setq lev (get-text-property (point)
3655 (zerop (forward-line way)))))
3657 (progn (gnus-group-position-cursor) t)
3658 (goto-char (or pos beg))
3661 ;;; Gnus group mode commands
3665 (defun gnus-group-mark-group (n &optional unmark no-advance)
3666 "Mark the current group."
3668 (let ((buffer-read-only nil)
3672 (setq group (gnus-group-group-name))
3680 (setq gnus-group-marked (delete group gnus-group-marked)))
3682 (setq gnus-group-marked
3683 (cons group (delete group gnus-group-marked))))
3685 (or no-advance (zerop (gnus-group-next-group 1))))
3687 (gnus-summary-position-cursor)
3690 (defun gnus-group-unmark-group (n)
3691 "Remove the mark from the current group."
3693 (gnus-group-mark-group n 'unmark))
3695 (defun gnus-group-mark-region (unmark beg end)
3696 "Mark all groups between point and mark.
3697 If UNMARK, remove the mark instead."
3698 (interactive "P\nr")
3699 (let ((num (count-lines beg end)))
3702 (- num (gnus-group-mark-group num unmark)))))
3704 (defun gnus-group-remove-mark (group)
3705 (and (gnus-group-goto-group group)
3707 (gnus-group-mark-group 1 'unmark t))))
3709 ;; Return a list of groups to work on. Take into consideration N (the
3710 ;; prefix) and the list of marked groups.
3711 (defun gnus-group-process-prefix (n)
3713 (setq n (prefix-numeric-value n))
3714 ;; There is a prefix, so we return a list of the N next
3716 (let ((way (if (< n 0) -1 1))
3721 (setq group (gnus-group-group-name)))
3722 (setq groups (cons group groups))
3724 (forward-line way)))
3727 ;; No prefix, but a list of marked articles.
3728 (reverse gnus-group-marked))
3730 ;; Neither marked articles or a prefix, so we return the
3732 (let ((group (gnus-group-group-name)))
3733 (and group (list group))))))
3735 ;; Selecting groups.
3737 (defun gnus-group-read-group (all &optional no-article group)
3738 "Read news in this newsgroup.
3739 If the prefix argument ALL is non-nil, already read articles become
3740 readable. If the optional argument NO-ARTICLE is non-nil, no article
3741 will be auto-selected upon group entry."
3743 (let ((group (or group (gnus-group-group-name)))
3744 number active marked entry)
3745 (or group (error "No group on current line"))
3747 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3748 ;; This group might be a dead group. In that case we have to get
3749 ;; the number of unread articles from `gnus-active-hashtb'.
3751 (setq number (car entry))
3752 (if (setq active (gnus-gethash group gnus-active-hashtb))
3753 (setq number (- (1+ (cdr active)) (car active)))))
3754 (gnus-summary-read-group
3755 group (or all (and (numberp number)
3756 (zerop (+ number (length (cdr (assq 'tick marked)))
3757 (length (cdr (assq 'dormant marked)))))))
3760 (defun gnus-group-select-group (all)
3761 "Select this newsgroup.
3762 No article is selected automatically.
3763 If argument ALL is non-nil, already read articles become readable."
3765 (gnus-group-read-group all t))
3767 ;; Enter a group that is not in the group buffer. Non-nil is returned
3768 ;; if selection was successful.
3769 (defun gnus-group-read-ephemeral-group
3770 (group method &optional activate quit-config)
3771 (let ((group (if (gnus-group-foreign-p group) group
3772 (gnus-group-prefixed-name group method))))
3775 (list t nil (list group gnus-level-default-subscribed nil nil
3779 (if quit-config quit-config
3780 (cons (current-buffer) 'summary)))))))
3782 (set-buffer gnus-group-buffer)
3783 (or (gnus-server-opened method)
3784 (gnus-open-server method)
3785 (error "Unable to contact server: %s" (gnus-status-message method)))
3786 (if activate (or (gnus-request-group group)
3787 (error "Couldn't request group")))
3789 (gnus-group-read-group t t group)
3792 (not (equal major-mode 'gnus-group-mode))))
3794 (defun gnus-group-jump-to-group (group)
3795 "Jump to newsgroup GROUP."
3797 (list (completing-read
3798 "Group: " gnus-active-hashtb nil (not (not gnus-read-active-file)))))
3800 (if (equal group "")
3801 (error "Empty group name"))
3803 (let ((b (text-property-any
3804 (point-min) (point-max) 'gnus-group (intern group))))
3806 ;; Either go to the line in the group buffer...
3808 ;; ... or insert the line.
3810 (gnus-gethash group gnus-active-hashtb)
3811 (gnus-activate-newsgroup group)
3812 (error "%s error: %s" group (gnus-status-message group)))
3814 (gnus-group-update-group group)
3815 (goto-char (text-property-any
3816 (point-min) (point-max) 'gnus-group (intern group)))))
3817 ;; Adjust cursor point.
3818 (gnus-group-position-cursor))
3820 (defun gnus-group-goto-group (group)
3821 "Goto to newsgroup GROUP."
3822 (let ((b (text-property-any (point-min) (point-max)
3823 'gnus-group (intern group))))
3824 (and b (goto-char b))))
3826 (defun gnus-group-next-group (n)
3827 "Go to next N'th newsgroup.
3828 If N is negative, search backward instead.
3829 Returns the difference between N and the number of skips actually
3832 (gnus-group-next-unread-group n t))
3834 (defun gnus-group-next-unread-group (n &optional all level)
3835 "Go to next N'th unread newsgroup.
3836 If N is negative, search backward instead.
3837 If ALL is non-nil, choose any newsgroup, unread or not.
3838 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3839 such group can be found, the next group with a level higher than
3841 Returns the difference between N and the number of skips actually
3844 (let ((backward (< n 0))
3847 (gnus-group-search-forward
3848 backward (or (not gnus-group-goto-unread) all) level))
3850 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3851 (if level " on this level or higher" "")))
3854 (defun gnus-group-prev-group (n)
3855 "Go to previous N'th newsgroup.
3856 Returns the difference between N and the number of skips actually
3859 (gnus-group-next-unread-group (- n) t))
3861 (defun gnus-group-prev-unread-group (n)
3862 "Go to previous N'th unread newsgroup.
3863 Returns the difference between N and the number of skips actually
3866 (gnus-group-next-unread-group (- n)))
3868 (defun gnus-group-next-unread-group-same-level (n)
3869 "Go to next N'th unread newsgroup on the same level.
3870 If N is negative, search backward instead.
3871 Returns the difference between N and the number of skips actually
3874 (gnus-group-next-unread-group n t (gnus-group-group-level))
3875 (gnus-group-position-cursor))
3877 (defun gnus-group-prev-unread-group-same-level (n)
3878 "Go to next N'th unread newsgroup on the same level.
3879 Returns the difference between N and the number of skips actually
3882 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3883 (gnus-group-position-cursor))
3885 (defun gnus-group-best-unread-group (&optional exclude-group)
3886 "Go to the group with the highest level.
3887 If EXCLUDE-GROUP, do not go to that group."
3889 (goto-char (point-min))
3892 (while (setq unread (get-text-property (point) 'gnus-unread))
3893 (if (and (numberp unread) (> unread 0))
3895 (if (and (< (get-text-property (point) 'gnus-level) best)
3896 (or (not exclude-group)
3897 (not (equal exclude-group (gnus-group-group-name)))))
3899 (setq best (get-text-property (point) 'gnus-level))
3900 (setq best-point (point))))))
3902 (if best-point (goto-char best-point))
3903 (gnus-summary-position-cursor)
3904 (and best-point (gnus-group-group-name))))
3906 (defun gnus-group-first-unread-group ()
3907 "Go to the first group with unread articles."
3909 (goto-char (point-min))
3910 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3911 (gnus-group-next-unread-group 1))
3912 (gnus-group-position-cursor))
3914 (defun gnus-group-enter-server-mode ()
3915 "Jump to the server buffer."
3917 (gnus-server-setup-buffer)
3918 (gnus-configure-windows 'server)
3919 (gnus-server-prepare))
3921 (defun gnus-group-make-group (name method &optional address)
3922 "Add a new newsgroup.
3923 The user will be prompted for a NAME, for a select METHOD, and an
3927 (read-string "Group name: ")
3930 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3932 (if (assoc method gnus-valid-select-methods)
3934 (if (memq 'prompt-address
3935 (assoc method gnus-valid-select-methods))
3936 (read-string "Address: ")
3938 (list method nil)))))
3940 (let* ((meth (if address (list (intern method) address) method))
3941 (nname (gnus-group-prefixed-name name meth))
3943 (and (gnus-gethash nname gnus-newsrc-hashtb)
3944 (error "Group %s already exists" nname))
3945 (gnus-group-change-level
3946 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3947 gnus-level-default-subscribed gnus-level-killed
3948 (and (gnus-group-group-name)
3949 (gnus-gethash (gnus-group-group-name)
3950 gnus-newsrc-hashtb))
3952 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
3954 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3955 (gnus-group-insert-group-line-info nname)
3957 (if (assoc method gnus-valid-select-methods)
3958 (require (intern method)))
3959 (and (gnus-check-backend-function 'request-create-group nname)
3960 (gnus-request-create-group nname))))
3962 (defun gnus-group-edit-group (group &optional part)
3963 "Edit the group on the current line."
3964 (interactive (list (gnus-group-group-name)))
3965 (let ((done-func '(lambda ()
3966 "Exit editing mode and update the information."
3968 (gnus-group-edit-group-done 'part 'group)))
3969 (part (or part 'info))
3970 (winconf (current-window-configuration))
3972 (or group (error "No group on current line"))
3973 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3974 (error "Killed group; can't be edited"))
3975 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3976 (gnus-configure-windows 'edit-group)
3977 (gnus-add-current-to-buffer-list)
3979 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3980 (use-local-map (copy-keymap emacs-lisp-mode-map))
3981 (local-set-key "\C-c\C-c" done-func)
3982 (make-local-variable 'gnus-prev-winconf)
3983 (setq gnus-prev-winconf winconf)
3984 ;; We modify the func to let it know what part it is editing.
3985 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3986 (setcar (cdr (cdr (nth 4 done-func))) group)
3991 ";; Type `C-c C-c' after editing the select method.\n\n")
3993 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3995 ";; Type `C-c C-c' after editing the group info.\n\n")))
3996 (let ((cinfo (gnus-copy-sequence info))
3998 (if (not (setq marked (nth 3 cinfo)))
4001 (or (eq 'score (car (car marked)))
4002 (eq 'bookmark (car (car marked)))
4003 (eq 'killed (car (car marked)))
4004 (not (numberp (car (cdr (car marked)))))
4005 (setcdr (car marked)
4006 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4007 (setq marked (cdr marked))))
4010 (cond ((eq part 'method)
4011 (or (nth 4 info) "native"))
4018 (defun gnus-group-edit-group-method (group)
4019 "Edit the select method of GROUP."
4020 (interactive (list (gnus-group-group-name)))
4021 (gnus-group-edit-group group 'method))
4023 (defun gnus-group-edit-group-parameters (group)
4024 "Edit the group parameters of GROUP."
4025 (interactive (list (gnus-group-group-name)))
4026 (gnus-group-edit-group group 'params))
4028 (defun gnus-group-edit-group-done (part group)
4029 "Get info from buffer, update variables and jump to the group buffer."
4030 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4031 (goto-char (point-min))
4032 (let ((form (read (current-buffer)))
4033 (winconf gnus-prev-winconf))
4035 (gnus-group-set-info form)
4036 (gnus-group-set-info form group part))
4037 (kill-buffer (current-buffer))
4038 (and winconf (set-window-configuration winconf))
4039 (set-buffer gnus-group-buffer)
4040 (gnus-group-update-group (gnus-group-group-name))
4041 (gnus-group-position-cursor)))
4043 (defun gnus-group-make-help-group ()
4044 "Create the (ding) Gnus documentation group."
4046 (let ((path load-path)
4048 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4049 "gnus-help" '(nndoc "gnus-help")))
4051 (error "Documentation group already exists"))
4053 (not (file-exists-p (concat (file-name-as-directory (car path))
4055 (setq path (cdr path)))
4056 (or path (error "Couldn't find doc group"))
4057 (gnus-group-make-group
4058 (gnus-group-real-name name)
4060 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4061 (list 'nndoc-article-type 'mbox))))
4062 (gnus-group-position-cursor))
4064 (defun gnus-group-make-doc-group (file type)
4065 "Create a group that uses a single file as the source."
4067 (list (read-file-name "File name: ")
4071 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4072 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4073 ((= char ?b) 'babyl)
4074 ((= char ?d) 'digest)
4075 (t (setq err "%c unknown. " char)
4078 (let* ((file (expand-file-name file))
4079 (name (gnus-generate-new-group-name
4080 (gnus-group-prefixed-name
4081 (file-name-nondirectory file) '(nndoc "")))))
4082 (gnus-group-make-group
4083 (gnus-group-real-name name)
4085 (list 'nndoc-address file)
4086 (list 'nndoc-article-type type)))))
4088 (defun gnus-group-make-archive-group ()
4089 "Create the (ding) Gnus archive group."
4091 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
4093 (error "Archive group already exists"))
4094 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
4095 (gnus-group-position-cursor))
4097 (defun gnus-group-make-directory-group (dir)
4098 "Create an nndir group.
4099 The user will be prompted for a directory. The contents of this
4100 directory will be used as a newsgroup. The directory should contain
4101 mail messages or news articles in files that have numeric names."
4103 (list (read-file-name "Create group from directory: ")))
4104 (or (file-exists-p dir) (error "No such directory"))
4105 (or (file-directory-p dir) (error "Not a directory"))
4106 (gnus-group-make-group dir "nndir" dir)
4107 (gnus-group-position-cursor))
4109 (defun gnus-group-make-kiboze-group (group address scores)
4110 "Create an nnkiboze group.
4111 The user will be prompted for a name, a regexp to match groups, and
4112 score file entries for articles to include in the group."
4115 (read-string "nnkiboze group name: ")
4116 (read-string "Source groups (regexp): ")
4117 (let ((headers (mapcar (lambda (group) (list group))
4118 '("subject" "from" "number" "date" "message-id"
4119 "references" "chars" "lines" "xref")))
4120 scores header regexp regexps)
4121 (while (not (equal "" (setq header (completing-read
4122 "Match on header: " headers nil t))))
4124 (while (not (equal "" (setq regexp (read-string
4125 (format "Match on %s (string): "
4127 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4128 (setq scores (cons (cons header regexps) scores)))
4130 (gnus-group-make-group group "nnkiboze" address)
4132 (gnus-set-work-buffer)
4133 (let (emacs-lisp-mode-hook)
4134 (pp scores (current-buffer)))
4135 (write-region (point-min) (point-max)
4136 (concat (or gnus-kill-files-directory "~/News")
4137 "nnkiboze:" group "." gnus-score-file-suffix)))
4138 (gnus-group-position-cursor))
4140 (defun gnus-group-add-to-virtual (n vgroup)
4141 "Add the current group to a virtual group."
4143 (list current-prefix-arg
4144 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4146 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4147 (error "%s is not an nnvirtual group" vgroup))
4148 (let* ((groups (gnus-group-process-prefix n))
4149 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4150 (setcar (cdr method)
4152 (nth 1 method) "\\|"
4155 (gnus-group-remove-mark s)
4156 (concat "\\(^" (regexp-quote s) "$\\)"))
4158 (gnus-group-position-cursor))
4160 (defun gnus-group-make-empty-virtual (group)
4161 "Create a new, fresh, empty virtual group."
4162 (interactive "sCreate new, empty virtual group: ")
4163 (let* ((method (list 'nnvirtual "^$"))
4164 (pgroup (gnus-group-prefixed-name group method)))
4165 ;; Check whether it exists already.
4166 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4167 (error "Group %s already exists." pgroup))
4168 ;; Subscribe the new group after the group on the current line.
4169 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4170 (gnus-group-update-group pgroup)
4172 (gnus-group-position-cursor)))
4174 (defun gnus-group-enter-directory (dir)
4175 "Enter an ephemeral nneething group."
4176 (interactive "DDirectory to read: ")
4177 (let* ((method (list 'nneething dir))
4178 (leaf (gnus-group-prefixed-name
4179 (file-name-nondirectory (directory-file-name dir))
4181 (name (gnus-generate-new-group-name leaf)))
4182 (let ((nneething-read-only t))
4183 (or (gnus-group-read-ephemeral-group
4185 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4187 (error "Couldn't enter %s" dir)))))
4189 ;; Group sorting commands
4190 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4192 (defun gnus-group-sort-groups ()
4193 "Sort the group buffer using `gnus-group-sort-function'."
4195 (setq gnus-newsrc-alist
4196 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4197 (gnus-make-hashtable-from-newsrc-alist)
4198 (gnus-group-list-groups (if gnus-have-all-newsgroups gnus-level-unsubscribed)
4199 gnus-have-all-newsgroups))
4201 (defun gnus-group-sort-by-alphabet (info1 info2)
4202 (string< (car info1) (car info2)))
4204 (defun gnus-group-sort-by-unread (info1 info2)
4205 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4206 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4207 (< (or (and (numberp n1) n1) 0)
4208 (or (and (numberp n2) n2) 0))))
4210 (defun gnus-group-sort-by-level (info1 info2)
4211 (< (nth 1 info1) (nth 1 info2)))
4213 ;; Group catching up.
4215 (defun gnus-group-catchup-current (n &optional all)
4216 "Mark all articles not marked as unread in current newsgroup as read.
4217 If prefix argument N is numeric, the ARG next newsgroups will be
4218 caught up. If ALL is non-nil, marked articles will also be marked as
4219 read. Cross references (Xref: header) of articles are ignored.
4220 The difference between N and actual number of newsgroups that were
4221 caught up is returned."
4223 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4227 "Do you really want to mark all articles as read? "
4228 "Mark all unread articles as read? "))))
4230 (let ((groups (gnus-group-process-prefix n))
4233 ;; Virtual groups have to be given special treatment.
4234 (let ((method (gnus-find-method-for-group (car groups))))
4235 (if (eq 'nnvirtual (car method))
4236 (nnvirtual-catchup-group
4237 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4238 (gnus-group-remove-mark (car groups))
4240 (gnus-group-goto-group (car groups))
4241 (gnus-group-catchup (car groups) all))
4242 (gnus-group-update-group-line)
4243 (setq ret (1+ ret)))
4244 (setq groups (cdr groups)))
4245 (gnus-group-next-unread-group 1)
4248 (defun gnus-group-catchup-current-all (n)
4249 "Mark all articles in current newsgroup as read.
4250 Cross references (Xref: header) of articles are ignored."
4252 (gnus-group-catchup-current n 'all))
4254 (defun gnus-group-catchup (group &optional all)
4255 "Mark all articles in GROUP as read.
4256 If ALL is non-nil, all articles are marked as read.
4257 The return value is the number of articles that were marked as read,
4258 or nil if no action could be taken."
4259 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4261 (marked (nth 3 (nth 2 entry))))
4262 (if (not (numberp (car entry)))
4263 (gnus-message 1 "Can't catch up; non-active group")
4264 ;; Do the updating only if the newsgroup isn't killed.
4267 (gnus-update-read-articles
4268 group (and (not all) (append (cdr (assq 'tick marked))
4269 (cdr (assq 'dormant marked))))
4270 nil (and (not all) (cdr (assq 'tick marked))))
4272 (setcar (nthcdr 3 (nth 2 entry))
4273 (delq (assq 'dormant marked)
4274 (nth 3 (nth 2 entry)))))))
4277 (defun gnus-group-expire-articles (n)
4278 "Expire all expirable articles in the current newsgroup."
4280 (let ((groups (gnus-group-process-prefix n))
4282 (or groups (error "No groups to expire"))
4284 (setq group (car groups)
4285 groups (cdr groups))
4286 (gnus-group-remove-mark group)
4287 (if (not (gnus-check-backend-function 'request-expire-articles group))
4289 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4290 (expirable (if (memq 'total-expire (nth 5 info))
4291 (cons nil (gnus-list-of-read-articles group))
4292 (assq 'expire (nth 3 info)))))
4295 (gnus-request-expire-articles
4296 (cdr expirable) group))))))))
4298 (defun gnus-group-expire-all-groups ()
4299 "Expire all expirable articles in all newsgroups."
4302 (gnus-message 5 "Expiring...")
4303 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4304 (cdr gnus-newsrc-alist))))
4305 (gnus-group-expire-articles nil)))
4306 (gnus-group-position-cursor)
4307 (gnus-message 5 "Expiring...done"))
4309 (defun gnus-group-set-current-level (n level)
4310 "Set the level of the next N groups to LEVEL."
4311 (interactive "P\nnLevel: ")
4312 (or (and (>= level 1) (<= level gnus-level-killed))
4313 (error "Illegal level: %d" level))
4314 (let ((groups (gnus-group-process-prefix n))
4317 (setq group (car groups)
4318 groups (cdr groups))
4319 (gnus-group-remove-mark group)
4320 (gnus-message 6 "Changed level of %s from %d to %d"
4321 group (gnus-group-group-level) level)
4322 (gnus-group-change-level group level
4323 (gnus-group-group-level))
4324 (gnus-group-update-group-line)))
4325 (gnus-group-position-cursor))
4327 (defun gnus-group-unsubscribe-current-group (n)
4328 "Toggle subscription of the current group.
4329 If given numerical prefix, toggle the N next groups."
4331 (let ((groups (gnus-group-process-prefix n))
4334 (setq group (car groups)
4335 groups (cdr groups))
4336 (gnus-group-remove-mark group)
4337 (gnus-group-unsubscribe-group
4338 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4339 gnus-level-default-unsubscribed
4340 gnus-level-default-subscribed))
4341 (gnus-group-update-group-line))
4342 (gnus-group-next-group 1)))
4344 (defun gnus-group-unsubscribe-group (group &optional level)
4345 "Toggle subscribe from/to unsubscribe GROUP.
4346 New newsgroup is added to .newsrc automatically."
4348 (list (completing-read "Group: " gnus-active-hashtb nil
4349 gnus-have-read-active-file)))
4350 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4352 ;; Toggle subscription flag.
4353 (gnus-group-change-level
4354 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4355 gnus-level-subscribed)
4356 (1+ gnus-level-subscribed)
4357 gnus-level-default-subscribed)))
4358 (gnus-group-update-group group))
4359 ((and (stringp group)
4360 (or (not gnus-have-read-active-file)
4361 (gnus-gethash group gnus-active-hashtb)))
4362 ;; Add new newsgroup.
4363 (gnus-group-change-level
4365 (if level level gnus-level-default-subscribed)
4366 (or (and (member group gnus-zombie-list)
4369 (and (gnus-group-group-name)
4370 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4371 (gnus-group-update-group group))
4372 (t (error "No such newsgroup: %s" group)))
4373 (gnus-group-position-cursor)))
4375 (defun gnus-group-transpose-groups (n)
4376 "Move the current newsgroup up N places.
4377 If given a negative prefix, move down instead. The difference between
4378 N and the number of steps taken is returned."
4380 (or (gnus-group-group-name)
4381 (error "No group on current line"))
4382 (gnus-group-kill-group 1)
4384 (forward-line (- n))
4385 (gnus-group-yank-group)
4386 (gnus-group-position-cursor)))
4388 (defun gnus-group-kill-all-zombies ()
4389 "Kill all zombie newsgroups."
4391 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4392 (setq gnus-zombie-list nil)
4393 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4394 (goto-char (point-min))
4395 (gnus-group-position-cursor))
4397 (defun gnus-group-kill-region (begin end)
4398 "Kill newsgroups in current region (excluding current point).
4399 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4414 (beginning-of-line) ;Important when LINES < 1
4415 (gnus-group-kill-group lines)))
4417 (defun gnus-group-kill-group (n)
4418 "The the next N groups.
4419 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4420 However, only groups that were alive can be yanked; already killed
4421 groups or zombie groups can't be yanked.
4422 The return value is the name of the (last) group that was killed."
4424 (let ((buffer-read-only nil)
4425 (groups (gnus-group-process-prefix n))
4428 (setq group (car groups)
4429 groups (cdr groups))
4430 (gnus-group-remove-mark group)
4431 (setq level (gnus-group-group-level))
4433 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4434 (setq gnus-list-of-killed-groups
4435 (cons (cons (car entry) (nth 2 entry))
4436 gnus-list-of-killed-groups)))
4437 (gnus-group-change-level
4438 (if entry entry group) gnus-level-killed (if entry nil level)))
4439 (gnus-group-position-cursor)
4442 (defun gnus-group-yank-group (&optional arg)
4443 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4444 inserting it before the current newsgroup. The numeric ARG specifies
4445 how many newsgroups are to be yanked. The name of the (last)
4446 newsgroup yanked is returned."
4448 (if (not arg) (setq arg 1))
4449 (let (info group prev)
4450 (while (>= (setq arg (1- arg)) 0)
4451 (if (not (setq info (car gnus-list-of-killed-groups)))
4452 (error "No more newsgroups to yank"))
4453 (setq group (nth 2 info))
4454 ;; Find which newsgroup to insert this one before - search
4455 ;; backward until something suitable is found. If there are no
4456 ;; other newsgroups in this buffer, just make this newsgroup the
4458 (setq prev (gnus-group-group-name))
4459 (gnus-group-change-level
4460 info (nth 2 info) gnus-level-killed
4461 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4463 (gnus-group-insert-group-line-info (nth 1 info))
4464 (setq gnus-list-of-killed-groups
4465 (cdr gnus-list-of-killed-groups)))
4467 (gnus-group-position-cursor)
4470 (defun gnus-group-list-all-groups (arg)
4471 "List all newsgroups with level ARG or lower.
4472 Default is gnus-level-unsubscribed, which lists all subscribed and most
4473 unsubscribed groups."
4475 (setq arg (or arg gnus-level-unsubscribed))
4476 (gnus-group-list-groups arg t))
4478 (defun gnus-group-list-killed ()
4479 "List all killed newsgroups in the group buffer."
4481 (if (not gnus-killed-list)
4482 (gnus-message 6 "No killed groups")
4483 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4484 (goto-char (point-min)))
4485 (gnus-group-position-cursor))
4487 (defun gnus-group-list-zombies ()
4488 "List all zombie newsgroups in the group buffer."
4490 (if (not gnus-zombie-list)
4491 (gnus-message 6 "No zombie groups")
4492 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4493 (goto-char (point-min)))
4494 (gnus-group-position-cursor))
4496 (defun gnus-group-get-new-news (&optional arg)
4497 "Get newly arrived articles.
4498 If ARG is non-nil, it should be a number between one and nine to
4499 specify which levels you are interested in re-scanning."
4501 (run-hooks 'gnus-get-new-news-hook)
4502 (if gnus-group-use-permanent-levels
4504 (setq gnus-group-default-list-level
4505 (or arg gnus-group-default-list-level
4506 gnus-level-subscribed))))
4507 (if (and gnus-read-active-file (not arg))
4509 (gnus-read-active-file)
4510 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4511 (let ((gnus-read-active-file nil)
4512 (gnus-have-read-active-file (not arg)))
4513 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4514 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels arg)
4515 gnus-group-default-list-level
4516 gnus-level-subscribed)
4517 gnus-have-all-newsgroups))
4519 (defun gnus-group-get-new-news-this-group (n)
4520 "Check for newly arrived news in the current group (and the N-1 next groups).
4521 The difference between N and the number of newsgroup checked is returned.
4522 If N is negative, this group and the N-1 previous groups will be checked."
4524 (let* ((groups (gnus-group-process-prefix n))
4525 (ret (if (numberp n) (- n (length groups)) 0))
4528 (setq group (car groups)
4529 groups (cdr groups))
4530 (gnus-group-remove-mark group)
4531 (or (gnus-get-new-news-in-group group)
4534 (message "%s error: %s" group (gnus-status-message group))
4536 ;; !!! I don't know why the buffer scrolls forward when updating
4537 ;; the first line in the group buffer, but it does. So we set the
4538 ;; window start forcibly.
4539 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4540 (gnus-group-next-unread-group 1 t)
4541 (gnus-summary-position-cursor)
4544 (defun gnus-get-new-news-in-group (group)
4546 (gnus-activate-newsgroup group)
4548 (gnus-get-unread-articles-in-group
4549 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4550 (gnus-gethash group gnus-active-hashtb))
4551 (gnus-group-update-group-line)
4554 (defun gnus-group-fetch-faq (group)
4555 "Fetch the FAQ for the current group."
4556 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4557 (or group (error "No group name given"))
4558 (let ((file (concat gnus-group-faq-directory group)))
4559 (if (not (file-exists-p file))
4560 (error "No such file: %s" file)
4563 (defun gnus-group-describe-group (force &optional group)
4564 "Display a description of the current newsgroup."
4565 (interactive (list current-prefix-arg (gnus-group-group-name)))
4566 (and force (setq gnus-description-hashtb nil))
4567 (let ((method (gnus-find-method-for-group group))
4569 (or group (error "No group name given"))
4570 (and (or (and gnus-description-hashtb
4571 ;; We check whether this group's method has been
4572 ;; queried for a description file.
4574 (gnus-group-prefixed-name "" method)
4575 gnus-description-hashtb))
4576 (setq desc (gnus-group-get-description group))
4577 (gnus-read-descriptions-file method))
4579 (or desc (gnus-gethash group gnus-description-hashtb)
4580 "No description available")))))
4582 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4583 (defun gnus-group-describe-all-groups (force)
4584 "Pop up a buffer with descriptions of all newsgroups."
4586 (and force (setq gnus-description-hashtb nil))
4587 (if (not (or gnus-description-hashtb
4588 (gnus-read-all-descriptions-files)))
4589 (error "Couldn't request descriptions file"))
4590 (let ((buffer-read-only nil)
4596 (insert (format " *: %-20s %s\n" (symbol-name group)
4597 (symbol-value group)))
4598 (add-text-properties
4599 b (1+ b) (list 'gnus-group group
4600 'gnus-unread t 'gnus-marked nil
4601 'gnus-level (1+ gnus-level-subscribed))))
4602 gnus-description-hashtb)
4603 (goto-char (point-min))
4604 (gnus-group-position-cursor)))
4606 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4607 (defun gnus-group-apropos (regexp &optional search-description)
4608 "List all newsgroups that have names that match a regexp."
4609 (interactive "sGnus apropos (regexp): ")
4611 (obuf (current-buffer))
4613 ;; Go through all newsgroups that are known to Gnus.
4616 (and (string-match regexp (symbol-name group))
4617 (setq groups (cons (symbol-name group) groups))))
4619 ;; Go through all descriptions that are known to Gnus.
4620 (if search-description
4623 (and (string-match regexp (symbol-value group))
4624 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4625 (setq groups (cons (symbol-name group) groups))))
4626 gnus-description-hashtb))
4628 (gnus-message 3 "No groups matched \"%s\"." regexp)
4629 ;; Print out all the groups.
4631 (pop-to-buffer "*Gnus Help*")
4632 (buffer-disable-undo (current-buffer))
4634 (setq groups (sort groups 'string<))
4636 ;; Groups may be entered twice into the list of groups.
4637 (if (not (string= (car groups) prev))
4639 (insert (setq prev (car groups)) "\n")
4640 (if (and gnus-description-hashtb
4641 (setq des (gnus-gethash (car groups)
4642 gnus-description-hashtb)))
4643 (insert " " des "\n"))))
4644 (setq groups (cdr groups)))
4645 (goto-char (point-min))))
4646 (pop-to-buffer obuf)))
4648 (defun gnus-group-description-apropos (regexp)
4649 "List all newsgroups that have names or descriptions that match a regexp."
4650 (interactive "sGnus description apropos (regexp): ")
4651 (if (not (or gnus-description-hashtb
4652 (gnus-read-all-descriptions-files)))
4653 (error "Couldn't request descriptions file"))
4654 (gnus-group-apropos regexp t))
4656 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4657 (defun gnus-group-list-matching (level regexp &optional all lowest)
4658 "List all groups with unread articles that match REGEXP.
4659 If the prefix LEVEL is non-nil, it should be a number that says which
4660 level to cut off listing groups.
4661 If ALL, also list groups with no unread articles.
4662 If LOWEST, don't list groups with level lower than LOWEST."
4663 (interactive "P\nsList newsgroups matching: ")
4664 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4665 all (or lowest 1) regexp)
4666 (goto-char (point-min))
4667 (gnus-group-position-cursor))
4669 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4670 "List all groups that match REGEXP.
4671 If the prefix LEVEL is non-nil, it should be a number that says which
4672 level to cut off listing groups.
4673 If LOWEST, don't list groups with level lower than LOWEST."
4674 (interactive "P\nsList newsgroups matching: ")
4675 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4677 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4678 (defun gnus-group-save-newsrc ()
4679 "Save the Gnus startup files."
4681 (gnus-save-newsrc-file))
4683 (defun gnus-group-restart (&optional arg)
4684 "Force Gnus to read the .newsrc file."
4686 (gnus-save-newsrc-file)
4687 (gnus-setup-news 'force)
4688 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4690 (defun gnus-group-read-init-file ()
4691 "Read the Gnus elisp init file."
4693 (gnus-read-init-file))
4695 (defun gnus-group-check-bogus-groups (silent)
4696 "Check bogus newsgroups.
4697 If given a prefix, don't ask for confirmation before removing a bogus
4700 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4701 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4703 (defun gnus-group-edit-global-kill (article &optional group)
4704 "Edit the global kill file.
4705 If GROUP, edit that local kill file instead."
4707 (setq gnus-current-kill-article article)
4708 (gnus-kill-file-edit-file group)
4710 (substitute-command-keys
4711 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4713 (defun gnus-group-edit-local-kill (article group)
4714 "Edit a local kill file."
4715 (interactive (list nil (gnus-group-group-name)))
4716 (gnus-group-edit-global-kill article group))
4718 (defun gnus-group-force-update ()
4719 "Update `.newsrc' file."
4721 (gnus-save-newsrc-file))
4723 (defun gnus-group-suspend ()
4724 "Suspend the current Gnus session.
4725 In fact, cleanup buffers except for group mode buffer.
4726 The hook gnus-suspend-gnus-hook is called before actually suspending."
4728 (run-hooks 'gnus-suspend-gnus-hook)
4729 ;; Kill Gnus buffers except for group mode buffer.
4730 (let ((group-buf (get-buffer gnus-group-buffer)))
4731 ;; Do this on a separate list in case the user does a ^G before we finish
4732 (let ((gnus-buffer-list
4733 (delq group-buf (delq gnus-dribble-buffer
4734 (append gnus-buffer-list nil)))))
4735 (while gnus-buffer-list
4736 (gnus-kill-buffer (car gnus-buffer-list))
4737 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4740 (setq gnus-buffer-list (list group-buf))
4741 (bury-buffer group-buf)
4742 (delete-windows-on group-buf t)))))
4744 (defun gnus-group-clear-dribble ()
4745 "Clear all information from the dribble buffer."
4747 (gnus-dribble-clear))
4749 (defun gnus-group-exit ()
4750 "Quit reading news after updating .newsrc.eld and .newsrc.
4751 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4753 (if (or noninteractive ;For gnus-batch-kill
4754 (zerop (buffer-size)) ;No news is good news.
4755 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4756 (not gnus-interactive-exit) ;Without confirmation
4758 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4760 (if gnus-use-full-window
4761 (delete-other-windows)
4762 (gnus-remove-some-windows))
4763 (run-hooks 'gnus-exit-gnus-hook)
4764 (gnus-offer-save-summaries)
4765 (gnus-save-newsrc-file)
4766 (gnus-close-backends)
4767 (gnus-clear-system))))
4769 (defun gnus-close-backends ()
4770 ;; Send a close request to all backends that support such a request.
4771 (let ((methods gnus-valid-select-methods)
4774 (if (fboundp (setq func (intern (concat (car (car methods))
4775 "-request-close"))))
4777 (setq methods (cdr methods)))))
4779 (defun gnus-group-quit ()
4780 "Quit reading news without updating .newsrc.eld or .newsrc.
4781 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4783 (if (or noninteractive ;For gnus-batch-kill
4784 (zerop (buffer-size))
4785 (not (gnus-server-opened gnus-select-method))
4787 (not gnus-current-startup-file)
4789 (format "Quit reading news without saving %s? "
4790 (file-name-nondirectory gnus-current-startup-file))))
4792 (run-hooks 'gnus-exit-gnus-hook)
4793 (if gnus-use-full-window
4794 (delete-other-windows)
4795 (gnus-remove-some-windows))
4797 (gnus-close-backends)
4798 (gnus-clear-system))))
4800 (defun gnus-offer-save-summaries ()
4801 (let ((buffers (buffer-list)))
4805 ;; We look for buffers with "Summary" in the name.
4806 (string-match "Summary" (or (buffer-name (car buffers)) ""))
4808 (set-buffer (car buffers))
4809 ;; We check that this is, indeed, a summary buffer.
4810 (eq major-mode 'gnus-summary-mode))
4811 ;; We ask the user whether she wants to save the info.
4813 (format "Update summary buffer %s? " (buffer-name)))
4814 ;; We do it by simply exiting.
4815 (gnus-summary-exit))
4816 (setq buffers (cdr buffers))))))
4818 (defun gnus-group-describe-briefly ()
4819 "Give a one line description of the group mode commands."
4821 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
4823 (defun gnus-group-browse-foreign-server (method)
4824 "Browse a foreign news server.
4825 If called interactively, this function will ask for a select method
4826 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4827 If not, METHOD should be a list where the first element is the method
4828 and the second element is the address."
4830 (list (let ((how (completing-read
4832 (append gnus-valid-select-methods gnus-server-alist)
4834 ;; We either got a backend name or a virtual server name.
4835 ;; If the first, we also need an address.
4836 (if (assoc how gnus-valid-select-methods)
4838 ;; Suggested by mapjph@bath.ac.uk.
4841 (mapcar (lambda (server) (list server))
4842 gnus-secondary-servers)))
4843 ;; We got a server name, so we find the method.
4844 (gnus-server-to-method how)))))
4845 (gnus-browse-foreign-server method))
4849 ;;; Browse Server Mode
4852 (defvar gnus-browse-mode-hook nil)
4853 (defvar gnus-browse-mode-map nil)
4854 (put 'gnus-browse-mode 'mode-class 'special)
4856 (if gnus-browse-mode-map
4858 (setq gnus-browse-mode-map (make-keymap))
4859 (suppress-keymap gnus-browse-mode-map)
4860 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4861 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
4862 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4863 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4864 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4865 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4866 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4867 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4868 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4869 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
4870 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4871 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4872 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4873 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4874 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4875 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4876 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4877 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4880 (defvar gnus-browse-current-method nil)
4881 (defvar gnus-browse-return-buffer nil)
4883 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4885 (defun gnus-browse-foreign-server (method &optional return-buffer)
4886 (setq gnus-browse-current-method method)
4887 (setq gnus-browse-return-buffer return-buffer)
4888 (let ((gnus-select-method method)
4890 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4891 (or (gnus-server-opened method)
4892 (gnus-open-server method)
4893 (error "Unable to contact server: %s" (gnus-status-message method)))
4894 (or (gnus-request-list method)
4895 (error "Couldn't request list: %s" (gnus-status-message method)))
4896 (get-buffer-create gnus-browse-buffer)
4897 (gnus-add-current-to-buffer-list)
4898 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4899 (gnus-configure-windows 'browse)
4900 (buffer-disable-undo (current-buffer))
4901 (let ((buffer-read-only nil))
4904 (setq mode-line-buffer-identification
4906 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4908 (set-buffer nntp-server-buffer)
4909 (let ((cur (current-buffer)))
4910 (goto-char (point-min))
4911 (or (string= gnus-ignored-newsgroups "")
4912 (delete-matching-lines gnus-ignored-newsgroups))
4913 (while (re-search-forward
4914 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4915 (goto-char (match-end 1))
4916 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4918 (max 0 (- (1+ (read cur)) (read cur))))
4920 (setq groups (sort groups
4922 (string< (car l1) (car l2)))))
4923 (let ((buffer-read-only nil))
4925 (setq group (car groups))
4927 (format "K%7d: %s\n" (cdr group) (car group)))
4928 (setq groups (cdr groups))))
4929 (switch-to-buffer (current-buffer))
4930 (goto-char (point-min))
4931 (gnus-group-position-cursor)))
4933 (defun gnus-browse-mode ()
4934 "Major mode for browsing a foreign server.
4936 All normal editing commands are switched off.
4938 \\<gnus-browse-mode-map>
4939 The only things you can do in this buffer is
4941 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
4942 The group will be inserted into the group buffer upon exit from this
4945 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
4947 3) `\\[gnus-browse-exit]' to return to the group buffer."
4949 (kill-all-local-variables)
4950 (if gnus-visual (gnus-browse-make-menu-bar))
4951 (setq mode-line-modified "-- ")
4952 (make-local-variable 'mode-line-format)
4953 (setq mode-line-format (copy-sequence mode-line-format))
4954 (and (equal (nth 3 mode-line-format) " ")
4955 (setcar (nthcdr 3 mode-line-format) ""))
4956 (setq major-mode 'gnus-browse-mode)
4957 (setq mode-name "Browse Server")
4958 (setq mode-line-process nil)
4959 (use-local-map gnus-browse-mode-map)
4960 (buffer-disable-undo (current-buffer))
4961 (setq truncate-lines t)
4962 (setq buffer-read-only t)
4963 (run-hooks 'gnus-browse-mode-hook))
4965 (defun gnus-browse-read-group (&optional no-article)
4966 "Enter the group at the current line."
4968 (let ((group (gnus-browse-group-name)))
4969 (or (gnus-group-read-ephemeral-group
4970 group gnus-browse-current-method nil
4971 (cons (current-buffer) 'browse))
4972 (error "Couldn't enter %s" group))))
4974 (defun gnus-browse-select-group ()
4975 "Select the current group."
4977 (gnus-browse-read-group 'no))
4979 (defun gnus-browse-next-group (n)
4980 "Go to the next group."
4984 (gnus-group-position-cursor)))
4986 (defun gnus-browse-prev-group (n)
4987 "Go to the next group."
4989 (gnus-browse-next-group (- n)))
4991 (defun gnus-browse-unsubscribe-current-group (arg)
4992 "(Un)subscribe to the next ARG groups."
4995 (error "No group at current line."))
4996 (let ((ward (if (< arg 0) -1 1))
4998 (while (and (> arg 0)
5000 (gnus-browse-unsubscribe-group)
5001 (zerop (gnus-browse-next-group ward)))
5002 (setq arg (1- arg)))
5003 (gnus-group-position-cursor)
5004 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5007 (defun gnus-browse-group-name ()
5010 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5012 (gnus-group-prefixed-name
5013 (buffer-substring (match-beginning 1) (match-end 1))
5014 gnus-browse-current-method))))
5016 (defun gnus-browse-unsubscribe-group ()
5018 (buffer-read-only nil)
5022 (if (= (following-char) ?K) (setq sub t))
5023 (setq group (gnus-browse-group-name))
5028 (gnus-group-change-level
5029 (list t group gnus-level-default-subscribed
5030 nil nil gnus-browse-current-method)
5031 gnus-level-default-subscribed gnus-level-killed
5032 (and (car (nth 1 gnus-newsrc-alist))
5033 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5034 gnus-newsrc-hashtb))
5037 (gnus-group-change-level
5038 group gnus-level-killed gnus-level-default-subscribed)
5042 (defun gnus-browse-exit ()
5043 "Quit browsing and return to the group buffer."
5045 (if (eq major-mode 'gnus-browse-mode)
5046 (kill-buffer (current-buffer)))
5047 (if gnus-browse-return-buffer
5048 (gnus-configure-windows 'server 'force)
5049 (gnus-configure-windows 'group 'force)
5050 (gnus-group-list-groups nil)))
5052 (defun gnus-browse-describe-briefly ()
5053 "Give a one line description of the group mode commands."
5056 (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")))
5060 ;;; Gnus summary mode
5063 (defvar gnus-summary-mode-map nil)
5064 (defvar gnus-summary-mark-map nil)
5065 (defvar gnus-summary-mscore-map nil)
5066 (defvar gnus-summary-article-map nil)
5067 (defvar gnus-summary-thread-map nil)
5068 (defvar gnus-summary-goto-map nil)
5069 (defvar gnus-summary-exit-map nil)
5070 (defvar gnus-summary-various-map nil)
5071 (defvar gnus-summary-interest-map nil)
5072 (defvar gnus-summary-sort-map nil)
5073 (defvar gnus-summary-backend-map nil)
5074 (defvar gnus-summary-save-map nil)
5075 (defvar gnus-summary-wash-map nil)
5076 (defvar gnus-summary-help-map nil)
5078 (put 'gnus-summary-mode 'mode-class 'special)
5080 (if gnus-summary-mode-map
5082 (setq gnus-summary-mode-map (make-keymap))
5083 (suppress-keymap gnus-summary-mode-map)
5085 ;; Non-orthogonal keys
5087 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5088 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5089 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5090 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5091 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5092 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5093 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5094 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5095 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5096 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5097 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5098 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5099 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5100 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5101 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5102 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5103 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5104 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5105 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5106 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5107 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5108 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5109 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5110 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5111 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5112 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5113 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5114 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5115 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5116 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5117 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5118 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5119 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5120 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5121 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5122 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5123 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5124 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5125 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5126 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5127 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5128 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5129 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5130 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5131 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5132 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5133 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5134 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5135 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5136 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5137 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5138 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5139 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5140 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5141 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5142 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5143 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5144 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5145 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5146 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5147 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5148 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5149 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5150 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5151 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5152 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5153 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5154 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5155 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5156 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5157 (define-key gnus-summary-mode-map "V" 'gnus-version)
5158 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5159 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5160 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5161 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5162 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5163 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5164 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5165 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5166 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5167 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5168 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5169 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5170 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5171 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5172 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5173 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5174 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5175 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5178 ;; Sort of orthogonal keymap
5179 (define-prefix-command 'gnus-summary-mark-map)
5180 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5181 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5182 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5183 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5184 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5185 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5186 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5187 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5188 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5189 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5190 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5191 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5192 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5193 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5194 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5195 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5196 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5197 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5198 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5199 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5200 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5201 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5202 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5203 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5205 (define-prefix-command 'gnus-summary-mscore-map)
5206 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
5207 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5208 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5209 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5210 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5212 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
5214 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5216 (define-prefix-command 'gnus-summary-goto-map)
5217 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5218 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5219 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5220 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5221 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5222 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5223 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5224 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5225 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5226 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5227 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5228 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5229 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5230 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5233 (define-prefix-command 'gnus-summary-thread-map)
5234 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5235 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5236 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5237 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5238 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5239 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5240 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5241 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5242 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5243 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5244 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5245 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5246 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5247 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5250 (define-prefix-command 'gnus-summary-exit-map)
5251 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5252 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5253 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5254 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5255 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5256 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5257 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5258 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5259 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5260 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5261 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5264 (define-prefix-command 'gnus-summary-article-map)
5265 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5266 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5267 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5268 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5269 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5270 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5271 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5272 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5273 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5274 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5275 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5276 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5277 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
5278 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
5279 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5280 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
5281 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
5282 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5285 (define-prefix-command 'gnus-summary-wash-map)
5286 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5287 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
5288 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
5289 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
5290 (define-key gnus-summary-wash-map "\C-c" 'gnus-article-hide-citation-maybe)
5291 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5292 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5293 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
5294 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5295 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5296 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
5297 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
5298 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
5300 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
5301 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
5302 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
5303 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
5304 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
5305 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5308 (define-prefix-command 'gnus-summary-help-map)
5309 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5310 (define-key gnus-summary-help-map "v" 'gnus-version)
5311 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5312 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5313 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5314 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5317 (define-prefix-command 'gnus-summary-backend-map)
5318 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5319 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5320 (define-key gnus-summary-backend-map "\M-\C-e"
5321 'gnus-summary-expire-articles-now)
5322 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5323 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5324 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5325 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5326 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5327 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5328 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5331 (define-prefix-command 'gnus-summary-save-map)
5332 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5333 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5334 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5335 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5336 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5337 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5338 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5339 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5340 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5342 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5344 (define-prefix-command 'gnus-summary-various-map)
5345 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
5346 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
5347 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5348 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5349 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5350 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5351 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5352 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5353 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
5354 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5355 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5357 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
5359 (define-prefix-command 'gnus-summary-sort-map)
5360 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5361 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5362 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5363 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5364 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5365 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5367 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5368 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5374 (defun gnus-summary-mode (&optional group)
5375 "Major mode for reading articles.
5377 All normal editing commands are switched off.
5378 \\<gnus-summary-mode-map>
5379 Each line in this buffer represents one article. To read an
5380 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5381 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5384 You can also post articles and send mail from this buffer. To
5385 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5386 of an article, type `\\[gnus-summary-reply]'.
5388 There are approx. one gazillion commands you can execute in this
5389 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5391 The following commands are available:
5393 \\{gnus-summary-mode-map}"
5395 (if gnus-visual (gnus-summary-make-menu-bar))
5396 (kill-all-local-variables)
5397 (let ((locals gnus-summary-local-variables))
5399 (if (consp (car locals))
5401 (make-local-variable (car (car locals)))
5402 (set (car (car locals)) (eval (cdr (car locals)))))
5403 (make-local-variable (car locals))
5404 (set (car locals) nil))
5405 (setq locals (cdr locals))))
5406 (gnus-make-thread-indent-array)
5407 (setq mode-line-modified "-- ")
5408 (make-local-variable 'mode-line-format)
5409 (setq mode-line-format (copy-sequence mode-line-format))
5410 (and (equal (nth 3 mode-line-format) " ")
5411 (setcar (nthcdr 3 mode-line-format) ""))
5412 (setq major-mode 'gnus-summary-mode)
5413 (setq mode-name "Summary")
5414 (make-local-variable 'minor-mode-alist)
5415 (use-local-map gnus-summary-mode-map)
5416 (buffer-disable-undo (current-buffer))
5417 (setq buffer-read-only t) ;Disable modification
5418 (setq truncate-lines t)
5419 (setq selective-display t)
5420 (setq selective-display-ellipses t) ;Display `...'
5421 (setq buffer-display-table gnus-summary-display-table)
5422 (setq gnus-newsgroup-name group)
5423 (run-hooks 'gnus-summary-mode-hook))
5425 (defun gnus-summary-make-display-table ()
5426 ;; Change the display table. Odd characters have a tendency to mess
5427 ;; up nicely formatted displays - we make all possible glyphs
5428 ;; display only a single character.
5430 ;; We start from the standard display table, if any.
5431 (setq gnus-summary-display-table
5432 (or (copy-sequence standard-display-table)
5433 (make-display-table)))
5434 ;; Nix out all the control chars...
5436 (while (>= (setq i (1- i)) 0)
5437 (aset gnus-summary-display-table i [??])))
5438 ;; ... but not newline and cr, of course. (cr is necessary for the
5439 ;; selective display).
5440 (aset gnus-summary-display-table ?\n nil)
5441 (aset gnus-summary-display-table ?\r nil)
5442 ;; We nix out any glyphs over 126 that are not set already.
5444 (while (>= (setq i (1- i)) 127)
5445 ;; Only modify if the entry is nil.
5446 (or (aref gnus-summary-display-table i)
5447 (aset gnus-summary-display-table i [??])))))
5449 (defun gnus-summary-clear-local-variables ()
5450 (let ((locals gnus-summary-local-variables))
5452 (if (consp (car locals))
5453 (and (vectorp (car (car locals)))
5454 (set (car (car locals)) nil))
5455 (and (vectorp (car locals))
5456 (set (car locals) nil)))
5457 (setq locals (cdr locals)))))
5459 ;; Some summary mode macros.
5461 ;; Return a header specified by a NUMBER.
5462 (defun gnus-get-header-by-number (number)
5464 (set-buffer gnus-summary-buffer)
5465 (or gnus-newsgroup-headers-hashtb-by-number
5466 (gnus-make-headers-hashtable-by-number))
5467 (gnus-gethash (int-to-string number)
5468 gnus-newsgroup-headers-hashtb-by-number)))
5470 ;; Fast version of the function above.
5471 (defmacro gnus-get-header-by-num (number)
5472 (` (gnus-gethash (int-to-string (, number))
5473 gnus-newsgroup-headers-hashtb-by-number)))
5475 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5476 "Search for article forward.
5477 If UNREAD is non-nil, only unread articles are selected.
5478 If SUBJECT is non-nil, the article which has the same subject will be
5480 If BACKWARD is non-nil, the search will be performed backwards instead."
5481 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5483 (defmacro gnus-summary-search-backward (&optional unread subject)
5484 "Search for article backward.
5485 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5486 If 2nd optional argument SUBJECT is non-nil, the article which has
5487 the same subject will be searched for."
5488 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5490 (defmacro gnus-summary-article-number (&optional number-or-nil)
5491 "The article number of the article on the current line.
5492 If there isn's an article number here, then we return the current
5495 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5496 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5497 gnus-current-article)))
5499 (defmacro gnus-summary-thread-level ()
5500 "The thread level of the article on the current line."
5501 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5504 (defmacro gnus-summary-article-mark ()
5505 "The mark on the current line."
5506 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5508 (defun gnus-summary-subject-string ()
5509 "Return current subject string or nil if nothing."
5510 (let ((article (gnus-summary-article-number))
5513 (setq header (gnus-get-header-by-num article))
5515 (header-subject header))))
5518 (defun gnus-mouse-pick-article (e)
5521 (gnus-summary-next-page nil t))
5523 (defun gnus-summary-setup-buffer (group)
5524 "Initialize summary buffer."
5525 (let ((buffer (concat "*Summary " group "*")))
5526 (if (get-buffer buffer)
5529 (not gnus-newsgroup-begin))
5530 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5531 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5532 (gnus-add-current-to-buffer-list)
5533 (gnus-summary-mode group)
5534 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5535 (setq gnus-newsgroup-name group)
5538 (defun gnus-set-global-variables ()
5539 ;; Set the global equivalents of the summary buffer-local variables
5540 ;; to the latest values they had. These reflect the summary buffer
5541 ;; that was in action when the last article was fetched.
5542 (if (eq major-mode 'gnus-summary-mode)
5544 (setq gnus-summary-buffer (current-buffer))
5545 (let ((name gnus-newsgroup-name)
5546 (marked gnus-newsgroup-marked)
5547 (unread gnus-newsgroup-unreads)
5548 (headers gnus-current-headers)
5549 (score-file gnus-current-score-file))
5551 (set-buffer gnus-group-buffer)
5552 (setq gnus-newsgroup-name name)
5553 (setq gnus-newsgroup-marked marked)
5554 (setq gnus-newsgroup-unreads unread)
5555 (setq gnus-current-headers headers)
5556 (setq gnus-current-score-file score-file))))))
5558 (defun gnus-summary-insert-dummy-line (sformat subject number)
5560 (setq sformat gnus-summary-dummy-line-format-spec))
5564 (insert (eval sformat))
5565 (add-text-properties
5567 (list 'gnus-number number
5568 'gnus-mark gnus-dummy-mark
5571 (defvar gnus-thread-indent-array nil)
5572 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5573 (defun gnus-make-thread-indent-array ()
5575 (if (and gnus-thread-indent-array
5576 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5578 (setq gnus-thread-indent-array (make-vector 201 "")
5579 gnus-thread-indent-array-level gnus-thread-indent-level)
5581 (aset gnus-thread-indent-array n
5582 (make-string (* n gnus-thread-indent-level) ? ))
5585 (defun gnus-summary-insert-line
5586 (sformat header level current unread replied expirable subject-or-nil
5587 &optional dummy score)
5588 (or sformat (setq sformat gnus-summary-line-format-spec))
5589 (let* ((indentation (aref gnus-thread-indent-array level))
5590 (lines (header-lines header))
5591 (score (or score gnus-summary-default-score 0))
5593 (if (or (null gnus-summary-default-score)
5594 (<= (abs (- score gnus-summary-default-score))
5595 gnus-summary-zcore-fuzz)) ?
5596 (if (< score gnus-summary-default-score)
5597 gnus-score-below-mark gnus-score-over-mark)))
5598 (replied (if replied gnus-replied-mark ? ))
5599 (from (header-from header))
5601 ((string-match "(.+)" from)
5602 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5603 ((string-match "<[^>]+> *$" from)
5604 (let ((beg (match-beginning 0)))
5605 (or (and (string-match "^\"[^\"]*\"" from)
5606 (substring from (1+ (match-beginning 0))
5607 (1- (match-end 0))))
5608 (substring from 0 beg))))
5610 (subject (header-subject header))
5611 (number (header-number header))
5612 (opening-bracket (if dummy ?\< ?\[))
5613 (closing-bracket (if dummy ?\> ?\]))
5614 (buffer-read-only nil)
5615 (b (progn (beginning-of-line) (point))))
5616 (or (numberp lines) (setq lines 0))
5617 (insert (eval sformat))
5618 (add-text-properties
5619 b (1+ b) (list 'gnus-number number
5620 'gnus-mark (or unread gnus-unread-mark)
5621 'gnus-level level))))
5623 (defun gnus-summary-update-line (&optional dont-update)
5624 ;; Update summary line after change.
5625 (or (not gnus-summary-default-score)
5626 gnus-summary-inhibit-highlight
5627 (let ((gnus-summary-inhibit-highlight t)
5628 (article (gnus-summary-article-number)))
5631 (if (and gnus-summary-mark-below
5632 (< (gnus-summary-article-score)
5633 gnus-summary-mark-below))
5634 (and (not (memq article gnus-newsgroup-marked))
5635 (not (memq article gnus-newsgroup-dormant))
5636 (memq article gnus-newsgroup-unreads)
5637 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5638 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5639 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5641 (run-hooks 'gnus-summary-update-hook))))))
5643 (defun gnus-summary-update-lines (&optional beg end)
5644 ;; Mark article as read (or not) by taking into account scores.
5645 (let ((beg (or beg (point-min)))
5646 (end (or end (point-max))))
5647 (if (or (not gnus-summary-default-score)
5648 gnus-summary-inhibit-highlight)
5650 (let ((gnus-summary-inhibit-highlight t)
5653 (set-buffer gnus-summary-buffer)
5656 (while (and (not (eobp)) (< (point) end))
5657 (if (and gnus-summary-mark-below
5659 (setq article (get-text-property
5660 (point) 'gnus-number))
5661 gnus-newsgroup-scored))
5662 gnus-summary-default-score 0)
5663 gnus-summary-mark-below))
5664 ;; We want to possibly mark it as read...
5665 (and (not (memq article gnus-newsgroup-marked))
5666 (not (memq article gnus-newsgroup-dormant))
5667 (memq article gnus-newsgroup-unreads)
5668 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5669 ;; We want to possibly mark it as unread.
5670 (and (eq (get-text-property (point) 'gnus-mark)
5671 gnus-low-score-mark)
5672 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5673 ;; Do the visual highlights at the same time.
5674 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5675 (forward-line 1)))))))
5677 (defvar gnus-tmp-gathered nil)
5679 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5680 ;; Sum up all elements (and sub-elements) in a list.
5682 (if (and (consp thread) (cdr thread)
5683 (not (memq (header-number (car (car (cdr thread))))
5684 gnus-tmp-gathered)))
5686 '+ 1 (mapcar 'gnus-summary-number-of-articles-in-thread
5690 (if (> number 1) gnus-not-empty-thread-mark
5691 gnus-empty-thread-mark)
5694 (defun gnus-summary-read-group
5695 (group &optional show-all no-article kill-buffer)
5696 "Start reading news in newsgroup GROUP.
5697 If SHOW-ALL is non-nil, already read articles are also listed.
5698 If NO-ARTICLE is non-nil, no article is selected initially."
5699 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5700 (let* ((new-group (gnus-summary-setup-buffer group))
5701 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5703 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5706 (gnus-set-global-variables)
5707 (gnus-kill-buffer kill-buffer)
5708 (gnus-configure-windows 'summary)
5709 (gnus-set-mode-line 'summary)
5710 (gnus-summary-position-cursor)
5714 (and (eq major-mode 'gnus-summary-mode)
5715 (not (equal (current-buffer) kill-buffer))
5717 (kill-buffer (current-buffer))
5718 (if (not quit-config)
5720 (set-buffer gnus-group-buffer)
5721 (gnus-group-jump-to-group group)
5722 (gnus-group-next-unread-group 1))
5723 (if (not (buffer-name (car quit-config)))
5724 (gnus-configure-windows 'group 'force)
5725 (set-buffer (car quit-config))
5726 (and (eq major-mode 'gnus-summary-mode)
5727 (gnus-set-global-variables))
5728 (gnus-configure-windows (cdr quit-config))))))
5729 (message "Can't select group")
5731 ((eq did-select 'quit)
5732 (and (eq major-mode 'gnus-summary-mode)
5733 (not (equal (current-buffer) kill-buffer))
5734 (kill-buffer (current-buffer)))
5735 (gnus-kill-buffer kill-buffer)
5736 (if (not quit-config)
5738 (set-buffer gnus-group-buffer)
5739 (gnus-group-jump-to-group group)
5740 (gnus-group-next-unread-group 1)
5741 (gnus-configure-windows 'group 'force))
5742 (if (not (buffer-name (car quit-config)))
5743 (gnus-configure-windows 'group 'force)
5744 (set-buffer (car quit-config))
5745 (and (eq major-mode 'gnus-summary-mode)
5746 (gnus-set-global-variables))
5747 (gnus-configure-windows (cdr quit-config))))
5750 (gnus-set-global-variables)
5751 ;; Save the active value in effect when the group was entered.
5752 (setq gnus-newsgroup-active
5754 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5755 ;; You can change the subjects in this hook.
5756 (run-hooks 'gnus-select-group-hook)
5757 ;; Do score processing.
5758 (and gnus-use-scoring (gnus-possibly-score-headers))
5759 (gnus-update-format-specifications)
5760 ;; Generate the summary buffer.
5761 (gnus-summary-prepare)
5762 (if (zerop (buffer-size))
5763 (cond (gnus-newsgroup-dormant
5764 (gnus-summary-show-all-dormant))
5765 ((and gnus-newsgroup-scored show-all)
5766 (gnus-summary-show-all-expunged))))
5767 ;; Function `gnus-apply-kill-file' must be called in this hook.
5768 (run-hooks 'gnus-apply-kill-hook)
5769 (if (zerop (buffer-size))
5771 ;; This newsgroup is empty.
5772 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5773 (gnus-message 6 "No unread news")
5774 (gnus-kill-buffer kill-buffer)
5778 ;; (let ((gnus-summary-buffer kill-buffer))
5779 ;; (gnus-configure-windows 'group))))
5780 ;; Hide conversation thread subtrees. We cannot do this in
5781 ;; gnus-summary-prepare-hook since kill processing may not
5782 ;; work with hidden articles.
5783 (and gnus-show-threads
5784 gnus-thread-hide-subtree
5785 (gnus-summary-hide-all-threads))
5786 ;; Show first unread article if requested.
5787 (goto-char (point-min))
5788 (if (and (not no-article)
5789 gnus-auto-select-first
5790 (gnus-summary-first-unread-article))
5792 (gnus-configure-windows 'summary))
5793 (gnus-set-mode-line 'summary)
5794 (gnus-summary-position-cursor)
5795 ;; If in async mode, we send some info to the backend.
5796 (and gnus-newsgroup-async
5797 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5798 (gnus-request-asynchronous
5800 (if (and gnus-asynchronous-article-function
5801 (fboundp gnus-asynchronous-article-function))
5802 (funcall gnus-asynchronous-article-function
5803 gnus-newsgroup-threads)
5804 gnus-newsgroup-threads)))
5805 (gnus-kill-buffer kill-buffer)
5806 (if (not (get-buffer-window gnus-group-buffer))
5808 ;; gotta use windows, because recenter does wierd stuff if
5809 ;; the current buffer ain't the displayed window.
5810 (let ((owin (selected-window)))
5811 (select-window (get-buffer-window gnus-group-buffer))
5812 (and (gnus-group-goto-group group)
5814 (select-window owin))))
5817 (defun gnus-summary-prepare ()
5818 ;; Generate the summary buffer.
5819 (let ((buffer-read-only nil))
5821 (gnus-summary-prepare-threads
5822 (if gnus-show-threads
5823 (gnus-gather-threads
5825 (if (and gnus-summary-expunge-below
5826 (not gnus-fetch-old-headers))
5827 (gnus-make-threads-and-expunge)
5828 (gnus-make-threads))))
5829 gnus-newsgroup-headers)
5831 ;; Erase header retrieval message.
5832 (gnus-summary-update-lines)
5834 ;; Remove the final newline.
5835 ;;(goto-char (point-max))
5837 ;; Call hooks for modifying summary buffer.
5838 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5839 (goto-char (point-min))
5840 (run-hooks 'gnus-summary-prepare-hook)))
5842 (defun gnus-gather-threads (threads)
5843 "Gather threads that have lost their roots."
5844 (if (not gnus-summary-make-false-root)
5846 (let ((hashtb (gnus-make-hashtable 1023))
5849 subject hthread whole-subject)
5852 (setq subject (header-subject (car (car threads)))))
5853 (if gnus-summary-gather-subject-limit
5854 (or (and (numberp gnus-summary-gather-subject-limit)
5855 (> (length subject) gnus-summary-gather-subject-limit)
5857 (substring subject 0
5858 gnus-summary-gather-subject-limit)))
5859 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5860 (setq subject (gnus-simplify-subject-fuzzy subject))))
5861 (setq subject (gnus-simplify-subject-re subject)))
5863 (gnus-gethash subject hashtb))
5865 (or (stringp (car (car hthread)))
5866 (setcar hthread (list whole-subject (car hthread))))
5867 (setcdr (car hthread) (nconc (cdr (car hthread))
5868 (list (car threads))))
5869 (setcdr prev (cdr threads))
5870 (setq threads prev))
5871 (gnus-sethash subject threads hashtb))
5873 (setq threads (cdr threads)))
5876 (defun gnus-make-threads ()
5877 ;; This function takes the dependencies already made by
5878 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5879 ;; through the dependecies in the hash table and finds all the
5880 ;; roots. Roots do not refer back to any valid articles.
5882 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5883 (gnus-build-old-threads))
5886 (if (not (car (symbol-value refs)))
5887 (setq roots (append (cdr (symbol-value refs)) roots))
5888 ;; Ok, these refer back to valid articles, but if
5889 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5890 ;; the root has the same subject as its children. The children
5891 ;; that do not are made into roots and removed from the list
5893 (or gnus-thread-ignore-subject
5894 (let* ((prev (symbol-value refs))
5895 (subject (gnus-simplify-subject-re
5896 (header-subject (car prev))))
5897 (headers (cdr prev)))
5899 (if (not (string= subject
5900 (gnus-simplify-subject-re
5901 (header-subject (car headers)))))
5903 (setq roots (cons (car headers) roots))
5904 (setcdr prev (cdr headers)))
5905 (setq prev headers))
5906 (setq headers (cdr headers)))))))
5907 gnus-newsgroup-dependencies)
5909 (mapcar 'gnus-trim-thread
5911 (mapcar 'gnus-cut-thread
5912 (mapcar 'gnus-make-sub-thread roots))))))
5914 (defun gnus-make-threads-and-expunge ()
5915 ;; This function takes the dependencies already made by
5916 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5917 ;; through the dependecies in the hash table and finds all the
5918 ;; roots. Roots do not refer back to any valid articles.
5919 (let ((default (or gnus-summary-default-score 0))
5920 (below gnus-summary-expunge-below)
5922 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5923 (gnus-build-old-threads))
5926 (if (not (car (symbol-value refs)))
5927 ;; These articles do not refer back to any other articles -
5929 (let ((headers (cdr (symbol-value refs))))
5930 ;; We weed out the low-scored articles.
5932 (if (not (< (or (cdr (assq (header-number (car headers))
5933 gnus-newsgroup-scored)) default)
5936 (setq roots (cons (car headers) roots))
5937 ;; It is below, so we mark it as read.
5938 (setq gnus-newsgroup-unreads
5939 (delq (header-number (car headers))
5940 gnus-newsgroup-unreads)))
5941 (setq headers (cdr headers))))
5942 ;; Ok, these refer back to valid articles, but if
5943 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5944 ;; the root has the same subject as its children. The children
5945 ;; that do not are made into roots and removed from the list
5947 (or gnus-thread-ignore-subject
5948 (let* ((prev (symbol-value refs))
5949 (subject (gnus-simplify-subject-re
5950 (header-subject (car prev))))
5951 (headers (cdr prev)))
5953 (if (not (string= subject
5954 (gnus-simplify-subject-re
5955 (header-subject (car headers)))))
5957 (if (not (< (or (cdr (assq (header-number (car headers))
5958 gnus-newsgroup-scored))
5960 (setq roots (cons (car headers) roots))
5961 (setq gnus-newsgroup-unreads
5962 (delq (header-number (car headers))
5963 gnus-newsgroup-unreads)))
5964 (setcdr prev (cdr headers)))
5965 (setq prev headers))
5966 (setq headers (cdr headers)))))
5967 ;; If this article is expunged, some of the children might be
5969 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
5970 gnus-newsgroup-scored)) default)
5972 (let* ((prev (symbol-value refs))
5973 (headers (cdr prev)))
5975 (setq article (header-number (car headers)))
5976 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5978 (progn (setq roots (cons (car headers) roots))
5979 (setq prev headers))
5980 (setq gnus-newsgroup-unreads
5981 (delq article gnus-newsgroup-unreads))
5982 (setcdr prev (cdr headers)))
5983 (setq headers (cdr headers))))
5984 ;; It was not expunged, but we look at expunged children.
5985 (let* ((prev (symbol-value refs))
5986 (headers (cdr prev))
5989 (setq article (header-number (car headers)))
5990 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5993 (setq gnus-newsgroup-unreads
5994 (delq article gnus-newsgroup-unreads))
5995 (setcdr prev (cdr headers)))
5996 (setq headers (cdr headers)))))))
5997 gnus-newsgroup-dependencies)
5999 (mapcar 'gnus-trim-thread
6001 (mapcar 'gnus-cut-thread
6002 (mapcar 'gnus-make-sub-thread roots))))))
6004 (defun gnus-cut-thread (thread)
6005 ;; Remove leaf dormant or ancient articles from THREAD.
6006 (let ((head (car thread))
6007 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6008 (if (and (null tail)
6009 (let ((number (header-number head)))
6010 (or (memq number gnus-newsgroup-ancient)
6011 (memq number gnus-newsgroup-dormant)
6012 (and gnus-summary-expunge-below
6013 (eq gnus-fetch-old-headers 'some)
6014 (< (or (cdr (assq number gnus-newsgroup-scored))
6015 gnus-summary-default-score 0)
6016 gnus-summary-expunge-below)
6018 (setq gnus-newsgroup-unreads
6019 (delq number gnus-newsgroup-unreads))
6022 (list (cons head tail)))))
6024 (defun gnus-trim-thread (thread)
6025 ;; Remove root ancient articles with only one child from THREAD.
6026 (if (and (eq gnus-fetch-old-headers 'some)
6027 (memq (header-number (car thread)) gnus-newsgroup-ancient)
6028 (= (length thread) 2))
6029 (gnus-trim-thread (nth 1 thread))
6032 (defun gnus-make-sub-thread (root)
6033 ;; This function makes a sub-tree for a node in the tree.
6034 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
6035 gnus-newsgroup-dependencies)))))
6036 (cons root (mapcar 'gnus-make-sub-thread children))))
6038 (defun gnus-build-old-threads ()
6039 ;; Look at all the articles that refer back to old articles, and
6040 ;; fetch the headers for the articles that aren't there. This will
6041 ;; build complete threads - if the roots haven't been expired by the
6046 (if (not (car (symbol-value refs)))
6048 (setq heads (cdr (symbol-value refs)))
6050 (if (not (memq (header-number (car heads))
6051 gnus-newsgroup-dormant))
6053 (setq id (symbol-name refs))
6054 (while (and (setq id (gnus-build-get-header id))
6055 (not (car (gnus-gethash
6056 id gnus-newsgroup-dependencies)))))
6058 (setq heads (cdr heads)))))))
6059 gnus-newsgroup-dependencies)))
6061 (defun gnus-build-get-header (id)
6062 ;; Look through the buffer of NOV lines and find the header to
6063 ;; ID. Enter this line into the dependencies hash table, and return
6064 ;; the id of the parent article (if any).
6065 (let ((deps gnus-newsgroup-dependencies)
6069 (set-buffer nntp-server-buffer)
6070 (goto-char (point-min))
6071 (while (and (not found) (search-forward id nil t))
6073 (setq found (looking-at
6074 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6075 (regexp-quote id))))
6076 (or found (beginning-of-line 2)))
6081 (setq header (gnus-nov-parse-line
6082 (read (current-buffer)) deps))
6083 (setq ref (header-references header))
6084 (string-match "\\(<[^>]+>\\) *$" ref)
6085 (substring ref (match-beginning 1) (match-end 1))))))
6087 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6088 gnus-newsgroup-ancient (cons (header-number header)
6089 gnus-newsgroup-ancient))))))
6091 ;; Re-build the thread containing ID.
6092 (defun gnus-rebuild-thread (id)
6093 (let ((dep gnus-newsgroup-dependencies)
6094 (buffer-read-only nil)
6095 parent headers refs thread art)
6096 (while (and id (setq headers
6097 (car (setq art (gnus-gethash (downcase id) dep)))))
6099 (setq id (and (setq refs (header-references headers))
6100 (string-match "\\(<[^>]+>\\) *$" refs)
6101 (substring refs (match-beginning 1) (match-end 1)))))
6102 (setq thread (gnus-make-sub-thread (car parent)))
6103 (gnus-rebuild-remove-articles thread)
6104 (let ((beg (point)))
6105 (gnus-summary-prepare-threads (list thread))
6106 (gnus-summary-update-lines beg (point)))))
6108 ;; Delete all lines in the summary buffer that correspond to articles
6110 (defun gnus-rebuild-remove-articles (thread)
6111 (and (gnus-summary-goto-subject (header-number (car thread)))
6113 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6115 (defun gnus-sort-threads (threads)
6116 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6117 (let ((fun gnus-thread-sort-functions))
6119 (setq threads (sort threads (car fun))
6123 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6124 (defmacro gnus-thread-header (thread)
6125 ;; Return header of first article in THREAD.
6126 ;; Note that THREAD must never, evr be anything else than a variable -
6127 ;; using some other form will lead to serious barfage.
6128 (or (symbolp thread) (error "Wrong type argument: symbolp, THREAD"))
6129 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6130 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6133 (defun gnus-thread-sort-by-number (h1 h2)
6134 "Sort threads by root article number."
6135 (< (header-number (gnus-thread-header h1))
6136 (header-number (gnus-thread-header h2))))
6138 (defun gnus-thread-sort-by-author (h1 h2)
6139 "Sort threads by root author."
6141 (let ((extract (funcall
6142 gnus-extract-address-components
6143 (header-from (gnus-thread-header h1)))))
6144 (or (car extract) (cdr extract)))
6145 (let ((extract (funcall
6146 gnus-extract-address-components
6147 (header-from (gnus-thread-header h2)))))
6148 (or (car extract) (cdr extract)))))
6150 (defun gnus-thread-sort-by-subject (h1 h2)
6151 "Sort threads by root subject."
6153 (downcase (gnus-simplify-subject
6154 (header-subject (gnus-thread-header h1))))
6155 (downcase (gnus-simplify-subject
6156 (header-subject (gnus-thread-header h2))))))
6158 (defun gnus-thread-sort-by-date (h1 h2)
6159 "Sort threads by root article date."
6161 (gnus-sortable-date (header-date (gnus-thread-header h1)))
6162 (gnus-sortable-date (header-date (gnus-thread-header h2)))))
6164 (defun gnus-thread-sort-by-score (h1 h2)
6165 "Sort threads by root article score.
6166 Unscored articles will be counted as having a score of zero."
6167 (> (or (assq (header-number (gnus-thread-header h1))
6168 gnus-newsgroup-scored)
6169 gnus-summary-default-score 0)
6170 (or (assq (header-number (gnus-thread-header h2))
6171 gnus-newsgroup-scored)
6172 gnus-summary-default-score 0)))
6174 (defun gnus-thread-sort-by-total-score (h1 h2)
6175 "Sort threads by the sum of all scores in the thread.
6176 Unscored articles will be counted as having a score of zero."
6177 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6179 (defun gnus-thread-total-score (thread)
6180 ;; This function find the total score of THREAD.
6182 (if (stringp (car thread))
6183 (apply gnus-thread-score-function 0
6184 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6185 (gnus-thread-total-score-1 thread))
6186 (gnus-thread-total-score-1 (list thread))))
6188 (defun gnus-thread-total-score-1 (root)
6189 ;; This function find the total score of the thread below ROOT.
6190 (setq root (car root))
6191 (apply gnus-thread-score-function
6192 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
6193 gnus-summary-default-score 0)
6194 (mapcar 'gnus-thread-total-score
6195 (cdr (gnus-gethash (downcase (header-id root))
6196 gnus-newsgroup-dependencies)))))
6198 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6199 (defvar gnus-tmp-prev-subject "")
6201 (defun gnus-summary-prepare-threads (threads &optional cull)
6202 "Prepare summary buffer from THREADS and indentation LEVEL.
6203 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6204 or a straight list of headers."
6206 thread header number subject stack state gnus-tmp-gathered)
6207 (if (vectorp (car threads))
6208 ;; If this is a straight (sic) list of headers, then a
6209 ;; threaded summary display isn't required, so we just create
6210 ;; an unthreaded one.
6211 (gnus-summary-prepare-unthreaded threads)
6213 ;; Do the threaded display.
6215 (while (or threads stack)
6218 ;; If there are some threads, we do them before the
6219 ;; threads on the stack.
6220 (setq thread threads
6221 header (car (car thread)))
6222 ;; There were no current threads, so we pop something off
6224 (setq state (car stack)
6228 header (car (car thread))))
6230 (if (stringp header)
6232 ;; The header is a dummy root.
6234 ((eq gnus-summary-make-false-root 'adopt)
6235 ;; We let the first article adopt the rest.
6236 (let ((th (car (cdr (car thread)))))
6239 (setcdr th (cdr (cdr (car thread))))
6240 (setq gnus-tmp-gathered
6242 (lambda (h) (header-number (car h)))
6243 (cdr (cdr (car thread))))
6245 (setcdr (cdr (car thread)) nil))
6247 ((eq gnus-summary-make-false-root 'empty)
6248 ;; We print adopted articles with empty subject fields.
6249 (setq gnus-tmp-gathered
6251 (lambda (h) (header-number (car h)))
6252 (cdr (cdr (car thread))))
6255 ((eq gnus-summary-make-false-root 'dummy)
6256 ;; We output a dummy root.
6257 (gnus-summary-insert-dummy-line
6258 nil header (header-number (car (car (cdr (car thread)))))))
6260 ;; We do not make a root for the gathered
6261 ;; sub-threads at all.
6264 (setq number (header-number header)
6265 subject (header-subject header))
6267 ;; Do the async thing.
6268 (and gnus-newsgroup-async
6269 (setq gnus-newsgroup-threads
6270 (cons (cons number (header-lines header))
6271 gnus-newsgroup-threads)))
6273 ;; We may have to root out some bad articles...
6276 (cond ((memq (setq number (header-number header))
6277 gnus-newsgroup-dormant)
6279 ((and gnus-summary-expunge-below
6280 (< (or (cdr (assq number gnus-newsgroup-scored))
6281 gnus-summary-default-score 0)
6282 gnus-summary-expunge-below))
6284 (setq gnus-newsgroup-unreads
6285 (delq number gnus-newsgroup-unreads)))))
6291 (gnus-summary-insert-line
6292 nil header level nil
6294 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6295 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6296 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6297 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6298 (t gnus-ancient-mark))
6299 (memq number gnus-newsgroup-replied)
6300 (memq number gnus-newsgroup-expirable)
6301 (if (and (eq gnus-summary-make-false-root 'empty)
6302 (memq number gnus-tmp-gathered))
6303 gnus-summary-same-subject
6304 (if (or (zerop level)
6305 (and gnus-thread-ignore-subject
6307 (gnus-simplify-subject-re
6308 gnus-tmp-prev-subject)
6309 (gnus-simplify-subject-re
6312 gnus-summary-same-subject))
6313 (and (eq gnus-summary-make-false-root 'adopt)
6314 (memq number gnus-tmp-gathered))
6315 (cdr (assq number gnus-newsgroup-scored)))
6317 (setq gnus-tmp-prev-subject subject)))))
6320 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6321 (setq level (1+ level))
6322 (setq threads (cdr (car thread)))))))
6325 (defun gnus-summary-prepare-unthreaded (headers)
6326 (let (header number)
6328 ;; Do the async thing, if that is required.
6329 (if gnus-newsgroup-async
6330 (setq gnus-newsgroup-threads
6331 (mapcar (lambda (h) (cons (header-number h) (header-lines h)))
6335 (setq header (car headers)
6336 headers (cdr headers)
6337 number (header-number header))
6339 (gnus-summary-insert-line
6341 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6342 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6343 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6344 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6345 (t gnus-ancient-mark))
6346 (memq number gnus-newsgroup-replied)
6347 (memq number gnus-newsgroup-expirable)
6348 (header-subject header) nil
6349 (cdr (assq number gnus-newsgroup-scored))))))
6351 (defun gnus-select-newsgroup (group &optional read-all)
6352 "Select newsgroup GROUP.
6353 If READ-ALL is non-nil, all articles in the group are selected."
6354 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6355 (info (nth 2 entry))
6357 (gnus-check-news-server
6358 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6360 (or (gnus-server-opened gnus-current-select-method)
6361 (gnus-open-server gnus-current-select-method)
6362 (error "Couldn't open server"))
6364 (or (and (eq (car entry) t)
6365 (gnus-activate-newsgroup (car info)))
6366 (gnus-request-group group t)
6368 (kill-buffer (current-buffer))
6369 (error "Couldn't request group %s: %s"
6370 group (gnus-status-message group))))
6372 (setq gnus-newsgroup-name group)
6373 (setq gnus-newsgroup-unselected nil)
6374 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6376 (and gnus-asynchronous
6377 (gnus-check-backend-function
6378 'request-asynchronous gnus-newsgroup-name)
6379 (setq gnus-newsgroup-async
6380 (gnus-request-asynchronous gnus-newsgroup-name)))
6382 (setq articles (gnus-articles-to-read group read-all))
6386 (gnus-message 3 "Couldn't select newsgroup")
6388 ((eq articles 0) nil)
6390 ;; Init the dependencies hash table.
6391 (setq gnus-newsgroup-dependencies
6392 (gnus-make-hashtable (length articles)))
6393 ;; Retrieve the headers and read them in.
6394 (setq gnus-newsgroup-headers
6395 (if (eq 'nov (setq gnus-headers-retrieved-by
6396 (gnus-retrieve-headers
6397 (if (and gnus-fetch-old-headers
6398 (not (eq 1 (car articles))))
6401 gnus-newsgroup-name)))
6403 (gnus-get-newsgroup-headers-xover articles))
6404 ;; If we were to fetch old headers, but the backend didn't
6405 ;; support XOVER, then it is possible we fetched one article
6406 ;; that we shouldn't have. If that's the case, we pop it off the
6408 (if (not gnus-fetch-old-headers)
6411 (set-buffer nntp-server-buffer)
6412 (goto-char (point-min))
6413 (and (looking-at "[0-9]+[ \t]+1[ \t]")
6416 (search-forward "\n.\n" nil t)))))
6417 (gnus-get-newsgroup-headers)))
6418 ;; Remove canceled articles from the list of unread articles.
6419 (setq gnus-newsgroup-unreads
6420 (gnus-set-sorted-intersection
6421 gnus-newsgroup-unreads
6422 (mapcar (lambda (headers) (header-number headers))
6423 gnus-newsgroup-headers)))
6424 ;; Adjust and set lists of article marks.
6427 (gnus-adjust-marked-articles info)
6428 (setq gnus-newsgroup-marked
6430 (cdr (assq 'tick (setq marked (nth 3 info))))))
6431 (setq gnus-newsgroup-replied
6432 (copy-sequence (cdr (assq 'reply marked))))
6433 (setq gnus-newsgroup-expirable
6434 (copy-sequence (cdr (assq 'expire marked))))
6435 (setq gnus-newsgroup-killed
6436 (copy-sequence (cdr (assq 'killed marked))))
6437 (setq gnus-newsgroup-bookmarks
6438 (copy-sequence (cdr (assq 'bookmark marked))))
6439 (setq gnus-newsgroup-dormant
6440 (copy-sequence (cdr (assq 'dormant marked))))
6441 (setq gnus-newsgroup-scored
6442 (copy-sequence (cdr (assq 'score marked))))
6443 (setq gnus-newsgroup-processable nil)))
6444 ;; Create the header hashtb.
6445 (or gnus-newsgroup-headers-hashtb-by-number
6446 (gnus-make-headers-hashtable-by-number))
6447 ;; Check whether auto-expire is to be done in this group.
6448 (setq gnus-newsgroup-auto-expire
6449 (or (and (stringp gnus-auto-expirable-newsgroups)
6450 (string-match gnus-auto-expirable-newsgroups group))
6451 (memq 'auto-expire (nth 5 info))))
6452 ;; First and last article in this newsgroup.
6453 (and gnus-newsgroup-headers
6454 (setq gnus-newsgroup-begin
6455 (header-number (car gnus-newsgroup-headers)))
6456 (setq gnus-newsgroup-end
6457 (header-number (gnus-last-element gnus-newsgroup-headers))))
6458 (setq gnus-reffed-article-number -1)
6459 ;; GROUP is successfully selected.
6460 (or gnus-newsgroup-headers t)))))
6462 (defun gnus-articles-to-read (group read-all)
6463 ;; Find out what articles the user wants to read.
6465 ;; Select all articles if `read-all' is non-nil, or if all the
6466 ;; unread articles are dormant articles.
6467 (if (or (and read-all (not (numberp read-all)))
6468 (= (length gnus-newsgroup-unreads)
6469 (length gnus-newsgroup-dormant)))
6470 (gnus-uncompress-range
6471 (gnus-gethash group gnus-active-hashtb))
6472 gnus-newsgroup-unreads))
6473 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6474 (scored (length scored-list))
6475 (number (length articles))
6476 (marked (+ (length gnus-newsgroup-marked)
6477 (length gnus-newsgroup-dormant)))
6484 (cond ((and (or (<= scored marked)
6486 (numberp gnus-large-newsgroup)
6487 (> number gnus-large-newsgroup))
6491 "How many articles from %s (default %d): "
6492 gnus-newsgroup-name number))))
6493 (if (string-match "^[ \t]*$" input)
6495 ((and (> scored marked) (< scored number))
6499 "%s %s (%d scored, %d total): "
6500 "How many articles from"
6501 group scored number))))
6502 (if (string-match "^[ \t]*$" input)
6506 (setq select (if (stringp select) (string-to-number select) select))
6507 (if (or (null select) (zerop select))
6509 (if (and (not (zerop scored)) (<= (abs select) scored))
6511 (setq articles (sort scored-list '<))
6512 (setq number (length articles)))
6513 (setq articles (copy-sequence articles)))
6515 (if (< (abs select) number)
6517 ;; Select the N oldest articles.
6518 (setcdr (nthcdr (1- (abs select)) articles) nil)
6519 ;; Select the N most recent articles.
6520 (setq articles (nthcdr (- number select) articles))))
6521 (setq gnus-newsgroup-unselected
6522 (gnus-sorted-intersection
6523 gnus-newsgroup-unreads
6524 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6527 (defun gnus-killed-articles (killed articles)
6530 (if (inline (gnus-member-of-range (car articles) killed))
6531 (setq out (cons (car articles) out)))
6532 (setq articles (cdr articles)))
6535 (defun gnus-adjust-marked-articles (info &optional active)
6536 "Remove all marked articles that are no longer legal."
6537 (let ((marked-lists (nth 3 info))
6538 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6540 ;; There are many types of marked articles.
6542 (setq m (cdr (setq prev (car marked-lists))))
6543 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6544 ;; Make sure that all ticked articles are a subset of the
6545 ;; unread/unselected articles.
6547 (if (or (memq (car m) gnus-newsgroup-unreads)
6548 (memq (car m) gnus-newsgroup-unselected))
6550 (setcdr prev (cdr m)))
6552 ((eq 'score (car prev))
6553 ;; Scored articles should be a subset of
6554 ;; unread/unselected articles.
6556 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6557 (memq (car (car m)) gnus-newsgroup-unreads))
6559 (setcdr prev (cdr m)))
6561 ((eq 'bookmark (car prev))
6562 ;; Bookmarks should be a subset of active articles.
6564 (if (< (car (car m)) (car active))
6565 (setcdr prev (cdr m))
6568 ((eq 'killed (car prev))
6569 ;; Articles that have been through the kill process are
6570 ;; to be a subset of active articles.
6571 (while (and m (< (or (and (numberp (car m)) (car m))
6574 (setcdr prev (cdr m))
6576 (if (and m (< (or (and (numberp (car m)) (car m))
6579 (setcar (if (numberp (car m)) m (car m)) (car active))))
6580 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6581 ;; The replied and expirable articles have to be articles
6584 (if (< (car m) (car active))
6585 (setcdr prev (cdr m))
6588 (setq marked-lists (cdr marked-lists)))
6589 ;; Remove all lists that are empty.
6590 (setq marked-lists (nth 3 info))
6593 (while (= 1 (length (car marked-lists)))
6594 (setq marked-lists (cdr marked-lists)))
6595 (setq m (cdr (setq prev marked-lists)))
6597 (if (= 1 (length (car m)))
6598 (setcdr prev (cdr m))
6601 (setcar (nthcdr 3 info) marked-lists)))
6602 ;; Finally, if there are no marked lists at all left, and if there
6603 ;; are no elements after the lists in the info list, we just chop
6604 ;; the info list off before the marked lists.
6605 (and (null marked-lists)
6606 (not (nthcdr 4 info))
6607 (setcdr (nthcdr 2 info) nil)))
6610 (defun gnus-set-marked-articles
6611 (info ticked replied expirable killed dormant bookmark score)
6612 "Enter the various lists of marked articles into the newsgroup info list."
6614 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6615 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6616 (and expirable (setq newmarked (cons (cons 'expire expirable)
6618 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6619 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6620 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6622 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6625 (setcar (nthcdr 3 info) newmarked)
6626 (and (not newmarked)
6627 (not (nthcdr 4 info))
6628 (setcdr (nthcdr 2 info) nil)))
6630 (setcdr (nthcdr 2 info) (list newmarked))))))
6632 (defun gnus-add-marked-articles (group type articles &optional info force)
6633 ;; Add ARTICLES of TYPE to the info of GROUP.
6634 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6635 ;; add, but replace marked articles of TYPE with ARTICLES.
6636 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6639 (and (not (setq marked (nthcdr 3 info)))
6640 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6641 (and (not (setq m (assq type (car marked))))
6642 (setcar marked (cons (cons type articles) (car marked))))
6645 (nconc m articles)))))
6647 (defun gnus-set-mode-line (where)
6648 "This function sets the mode line of the article or summary buffers.
6649 If WHERE is `summary', the summary mode line format will be used."
6650 (if (memq where gnus-updated-mode-lines)
6653 (set-buffer gnus-summary-buffer)
6654 (let* ((mformat (if (eq where 'article)
6655 gnus-article-mode-line-format-spec
6656 gnus-summary-mode-line-format-spec))
6657 (group-name gnus-newsgroup-name)
6658 (article-number (or gnus-current-article 0))
6659 (unread (- (length gnus-newsgroup-unreads)
6660 (length gnus-newsgroup-dormant)))
6661 (unread-and-unticked
6662 (- unread (length gnus-newsgroup-marked)))
6663 (unselected (length gnus-newsgroup-unselected))
6664 (unread-and-unselected
6665 (cond ((and (zerop unread-and-unticked)
6666 (zerop unselected)) "")
6668 (format "{%d more}" unread-and-unticked))
6669 (t (format "{%d(+%d) more}"
6670 unread-and-unticked unselected))))
6672 (if gnus-current-headers
6673 (header-subject gnus-current-headers) ""))
6674 (max-len (and gnus-mode-non-string-length
6675 (- (frame-width) gnus-mode-non-string-length)))
6676 header) ;; passed as argument to any user-format-funcs
6677 (setq mode-string (eval mformat))
6678 (or (numberp max-len)
6679 (setq max-len (length mode-string)))
6680 (if (< max-len 4) (setq max-len 4))
6681 (if (> (length mode-string) max-len)
6682 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6683 ;; function `substring' might cut on a middle
6684 ;; of multi-octet character.
6686 (concat (gnus-truncate-string mode-string (- max-len 3))
6688 (setq mode-string (format (format "%%-%ds" max-len)
6690 (setq mode-line-buffer-identification mode-string)
6691 (set-buffer-modified-p t))))
6693 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6694 "Go through the HEADERS list and add all Xrefs to a hash table.
6695 The resulting hash table is returned, or nil if no Xrefs were found."
6696 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6698 (gnus-group-foreign-p from-newsgroup)
6700 (assoc (symbol-name (car from-method))
6701 gnus-valid-select-methods))))
6702 (gnus-group-real-prefix from-newsgroup)))
6703 (xref-hashtb (make-vector 63 0))
6704 start group entry number xrefs header)
6706 (setq header (car headers))
6707 (if (and (setq xrefs (header-xref header))
6708 (not (memq (header-number header) unreads)))
6711 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6712 (setq start (match-end 0))
6713 (setq group (concat prefix (substring xrefs (match-beginning 1)
6716 (string-to-int (substring xrefs (match-beginning 2)
6718 (if (setq entry (gnus-gethash group xref-hashtb))
6719 (setcdr entry (cons number (cdr entry)))
6720 (gnus-sethash group (cons number nil) xref-hashtb)))))
6721 (setq headers (cdr headers)))
6722 (if start xref-hashtb nil)))
6724 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6725 "Look through all the headers and mark the Xrefs as read."
6726 (let ((virtual (memq 'virtual
6727 (assoc (symbol-name (car (gnus-find-method-for-group
6729 gnus-valid-select-methods)))
6730 name entry info xref-hashtb idlist method
6733 (set-buffer gnus-group-buffer)
6734 (if (setq xref-hashtb
6735 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6738 (if (string= from-newsgroup (setq name (symbol-name group)))
6740 (setq idlist (symbol-value group))
6741 ;; Dead groups are not updated.
6743 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6745 (if (stringp (setq nth4 (nth 4 info)))
6746 (setq nth4 (gnus-server-to-method nth4))))
6747 ;; Only do the xrefs if the group has the same
6748 ;; select method as the group we have just read.
6749 (or (gnus-methods-equal-p
6750 nth4 (gnus-find-method-for-group from-newsgroup))
6753 (setq method (gnus-find-method-for-group
6755 (and (equal (car nth4) (car method))
6756 (equal (nth 1 nth4) (nth 1 method))))
6757 gnus-use-cross-reference
6758 (or (not (eq gnus-use-cross-reference t))
6760 ;; Only do cross-references on subscribed
6761 ;; groups, if that is what is wanted.
6762 (<= (nth 1 info) gnus-level-subscribed)))
6763 (gnus-group-make-articles-read name idlist expirable))))
6766 (defun gnus-group-make-articles-read (group articles expirable)
6768 (entry (gnus-gethash group gnus-newsrc-hashtb))
6769 (info (nth 2 entry))
6770 (active (gnus-gethash group gnus-active-hashtb))
6771 exps expirable range)
6772 ;; First peel off all illegal article numbers.
6774 (let ((ids articles)
6775 (ticked (cdr (assq 'tick (nth 3 info))))
6776 (dormant (cdr (assq 'dormant (nth 3 info))))
6781 (if (or (> id (cdr active))
6785 (setq articles (delq id articles)))
6786 (and (memq id expirable)
6787 (setq exps (cons id exps)))
6788 (setq ids (cdr ids)))))
6789 ;; Update expirable articles.
6790 (gnus-add-marked-articles nil 'expirable exps info)
6794 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6795 (setcar (nthcdr 2 info)
6799 (setq articles (sort articles '<)))))
6800 ;; Then we have to re-compute how many unread
6801 ;; articles there are in this group.
6806 (setq num (- (1+ (cdr active)) (car active))))
6807 ((not (listp (cdr range)))
6808 (setq num (- (cdr active) (- (1+ (cdr range))
6812 (if (numberp (car range))
6814 (setq num (+ num (- (1+ (cdr (car range)))
6815 (car (car range))))))
6816 (setq range (cdr range)))
6817 (setq num (- (cdr active) num))))
6818 ;; Update the number of unread articles.
6822 (length (cdr (assq 'tick (nth 3 info))))
6824 (cdr (assq 'dormant (nth 3 info)))))))
6825 ;; Update the group buffer.
6826 (gnus-group-update-group group t)))))
6828 (defun gnus-methods-equal-p (m1 m2)
6829 (let ((m1 (or m1 gnus-select-method))
6830 (m2 (or m2 gnus-select-method)))
6832 (and (eq (car m1) (car m2))
6833 (or (not (memq 'address (assoc (symbol-name (car m1))
6834 gnus-valid-select-methods)))
6835 (equal (nth 1 m1) (nth 1 m2)))))))
6837 (defsubst gnus-header-value ()
6838 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6840 (defvar gnus-newsgroup-none-id 0)
6842 (defun gnus-get-newsgroup-headers ()
6843 (setq gnus-article-internal-prepare-hook nil)
6844 (let ((cur nntp-server-buffer)
6845 (dependencies gnus-newsgroup-dependencies)
6846 headers id dep end ref)
6848 (set-buffer nntp-server-buffer)
6849 (goto-char (point-min))
6850 ;; Search to the beginning of the next header. Error messages
6851 ;; do not begin with 2 or 3.
6852 (while (re-search-forward "^[23][0-9]+ " nil t)
6853 (let ((header (make-vector 9 nil))
6854 (case-fold-search t)
6859 (header-set-number header (read cur))
6860 ;; This implementation of this function, with nine
6861 ;; search-forwards instead of the one re-search-forward and
6862 ;; a case (which basically was the old function) is actually
6863 ;; about twice as fast, even though it looks messier. You
6864 ;; can't have everything, I guess. Speed and elegance
6865 ;; doesn't always come hand in hand.
6867 (narrow-to-region (point) (or (save-excursion
6868 (search-forward "\n.\n" nil t))
6870 (if (search-forward "\nfrom: " nil t)
6871 (header-set-from header (gnus-header-value))
6872 (header-set-from header "(nobody)"))
6874 (if (search-forward "\nsubject: " nil t)
6875 (header-set-subject header (gnus-header-value))
6876 (header-set-subject header "(none)"))
6878 (and (search-forward "\nxref: " nil t)
6879 (header-set-xref header (gnus-header-value)))
6881 (or (numberp (and (search-forward "\nlines: " nil t)
6882 (header-set-lines header (read cur))))
6883 (header-set-lines header 0))
6885 (and (search-forward "\ndate: " nil t)
6886 (header-set-date header (gnus-header-value)))
6888 (if (search-forward "\nmessage-id: " nil t)
6889 (header-set-id header (setq id (gnus-header-value)))
6890 ;; If there was no message-id, we just fake one to make
6891 ;; subsequent routines simpler.
6894 (setq id (concat "none+"
6896 (setq gnus-newsgroup-none-id
6897 (1+ gnus-newsgroup-none-id)))))))
6899 (if (search-forward "\nreferences: " nil t)
6901 (header-set-references header (gnus-header-value))
6902 (setq end (match-end 0))
6909 (search-backward ">" end t)
6912 (search-backward "<" end t)
6914 ;; Get the references from the in-reply-to header if there
6915 ;; ware no references and the in-reply-to header looks
6917 (if (and (search-forward "\nin-reply-to: " nil t)
6918 (setq in-reply-to (gnus-header-value))
6919 (string-match "<[^>]+>" in-reply-to))
6921 (header-set-references
6923 (setq ref (substring in-reply-to (match-beginning 0)
6925 (setq ref (downcase ref)))
6927 ;; We do some threading while we read the headers. The
6928 ;; message-id and the last reference are both entered into
6929 ;; the same hash table. Some tippy-toeing around has to be
6930 ;; done in case an article has arrived before the article
6931 ;; which it refers to.
6932 (if (boundp (setq dep (intern (downcase id) dependencies)))
6933 (if (car (symbol-value dep))
6934 ;; An article with this Message-ID has already
6935 ;; been seen, so we ignore this one, except we add
6936 ;; any additional Xrefs (in case the two articles
6937 ;; came from different servers.
6940 (car (symbol-value dep))
6941 (concat (or (header-xref (car (symbol-value dep))) "")
6942 (or (header-xref header) "")))
6944 (setcar (symbol-value dep) header))
6945 (set dep (list header)))
6948 (if (boundp (setq dep (intern ref dependencies)))
6949 (setcdr (symbol-value dep)
6950 (cons header (cdr (symbol-value dep))))
6951 (set dep (list nil header)))
6952 (setq headers (cons header headers))))
6953 (goto-char (point-max))))))
6954 (nreverse headers)))
6956 ;; The following macros and functions were written by Felix Lee
6957 ;; <flee@cse.psu.edu>.
6959 (defmacro gnus-nov-read-integer ()
6961 (if (= (following-char) ?\t)
6963 (let ((num (condition-case nil (read buffer) (error nil))))
6964 (if (numberp num) num 0)))
6965 (or (eobp) (forward-char 1))))
6967 (defmacro gnus-nov-skip-field ()
6968 '(search-forward "\t" eol 'move))
6970 (defmacro gnus-nov-field ()
6971 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6973 ;; Goes through the xover lines and returns a list of vectors
6974 (defun gnus-get-newsgroup-headers-xover (sequence)
6975 "Parse the news overview data in the server buffer, and return a
6976 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6977 ;; Get the Xref when the users reads the articles since most/some
6978 ;; NNTP servers do not include Xrefs when using XOVER.
6979 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6980 (let ((cur nntp-server-buffer)
6981 (dependencies gnus-newsgroup-dependencies)
6982 number headers header)
6984 (set-buffer nntp-server-buffer)
6985 (goto-char (point-min))
6986 (while (and sequence (not (eobp)))
6987 (setq number (read cur))
6988 (while (and sequence (< (car sequence) number))
6989 (setq sequence (cdr sequence)))
6991 (eq number (car sequence))
6993 (setq sequence (cdr sequence))
6995 (inline (gnus-nov-parse-line number dependencies)))
6996 (setq headers (cons header headers)))))
6998 (setq headers (nreverse headers)))
7001 ;; This function has to be called with point after the article number
7002 ;; on the beginning of the line.
7003 (defun gnus-nov-parse-line (number dependencies)
7005 (eol (gnus-point-at-eol))
7006 (buffer (current-buffer))
7009 ;; overview: [num subject from date id refs chars lines misc]
7010 (narrow-to-region (point) eol)
7017 (gnus-nov-field) ; subject
7018 (gnus-nov-field) ; from
7019 (gnus-nov-field) ; date
7020 (setq id (or (gnus-nov-field)
7023 (setq none (1+ none)))))) ; id
7026 (let ((beg (point)))
7027 (search-forward "\t" eol)
7028 (if (search-backward ">" beg t)
7034 (search-backward "<" beg t)
7037 (gnus-nov-field)) ; refs
7038 (gnus-nov-read-integer) ; chars
7039 (gnus-nov-read-integer) ; lines
7040 (if (= (following-char) ?\n)
7042 (gnus-nov-field)) ; misc
7046 (message "Strange nov line.")
7052 ;; We build the thread tree.
7054 (if (boundp (setq dep (intern (downcase id) dependencies)))
7055 (if (car (symbol-value dep))
7056 ;; An article with this Message-ID has already been seen,
7057 ;; so we ignore this one, except we add any additional
7058 ;; Xrefs (in case the two articles came from different
7062 (car (symbol-value dep))
7063 (concat (or (header-xref (car (symbol-value dep))) "")
7064 (or (header-xref header) "")))
7066 (setcar (symbol-value dep) header))
7067 (set dep (list header))))
7070 (if (boundp (setq dep (intern (or ref "none")
7072 (setcdr (symbol-value dep)
7073 (cons header (cdr (symbol-value dep))))
7074 (set dep (list nil header)))))
7077 (defun gnus-article-get-xrefs ()
7078 "Fill in the Xref value in `gnus-current-headers', if necessary.
7079 This is meant to be called in `gnus-article-internal-prepare-hook'."
7080 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7081 gnus-current-headers)))
7082 (or (not gnus-use-cross-reference)
7084 (and (header-xref headers)
7085 (not (string= (header-xref headers) "")))
7086 (let ((case-fold-search t)
7089 (gnus-narrow-to-headers)
7090 (goto-char (point-min))
7091 (if (or (and (eq (downcase (following-char)) ?x)
7092 (looking-at "Xref:"))
7093 (search-forward "\nXref:" nil t))
7095 (goto-char (1+ (match-end 0)))
7096 (setq xref (buffer-substring (point)
7097 (progn (end-of-line) (point))))
7098 (header-set-xref headers xref))))))))
7100 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7101 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7103 (defun gnus-make-headers-hashtable-by-number ()
7104 "Make hashtable for the variable gnus-newsgroup-headers by number."
7106 (set-buffer gnus-summary-buffer)
7107 (let ((headers gnus-newsgroup-headers)
7109 (setq gnus-newsgroup-headers-hashtb-by-number
7110 (gnus-make-hashtable (length headers)))
7112 (setq header (car headers))
7113 (gnus-sethash (int-to-string (header-number header))
7114 header gnus-newsgroup-headers-hashtb-by-number)
7115 (setq headers (cdr headers))))))
7117 (defun gnus-more-header-backward ()
7118 "Find new header backward."
7119 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7120 (artnum gnus-newsgroup-begin)
7122 (while (and (not header)
7124 (setq artnum (1- artnum))
7125 (setq header (gnus-read-header artnum)))
7128 (defun gnus-more-header-forward (&optional backward)
7129 "Find new header forward.
7130 If BACKWARD, find new header backward instead."
7132 (gnus-more-header-backward)
7133 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7134 (artnum gnus-newsgroup-end)
7136 (while (and (not header)
7138 (setq artnum (1+ artnum))
7139 (setq header (gnus-read-header artnum)))
7142 (defun gnus-extend-newsgroup (header &optional backward)
7143 "Extend newsgroup selection with HEADER.
7144 Optional argument BACKWARD means extend toward backward."
7146 (let ((artnum (header-number header)))
7147 (setq gnus-newsgroup-headers
7149 (cons header gnus-newsgroup-headers)
7150 (nconc gnus-newsgroup-headers (list header))))
7151 (setq gnus-newsgroup-unselected
7152 (delq artnum gnus-newsgroup-unselected))
7153 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7154 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7156 (defun gnus-summary-work-articles (n)
7157 "Return a list of articles to be worked upon. The prefix argument,
7158 the list of process marked articles, and the current article will be
7159 taken into consideration."
7161 (if (and n (numberp n))
7162 (let ((backward (< n 0))
7166 (setq articles (cons (gnus-summary-article-number)
7168 (gnus-summary-search-forward nil nil backward))
7170 (sort articles (function <)))
7171 (or (reverse gnus-newsgroup-processable)
7172 (list (gnus-summary-article-number))))))
7174 (defun gnus-summary-search-group (&optional backward use-level)
7175 "Search for next unread newsgroup.
7176 If optional argument BACKWARD is non-nil, search backward instead."
7178 (set-buffer gnus-group-buffer)
7179 (if (gnus-group-search-forward
7180 backward nil (if use-level (gnus-group-group-level) nil))
7181 (gnus-group-group-name))))
7183 (defun gnus-summary-best-group (&optional exclude-group)
7184 "Find the name of the best unread group.
7185 If EXCLUDE-GROUP, do not go to this group."
7187 (set-buffer gnus-group-buffer)
7189 (gnus-group-best-unread-group exclude-group))))
7191 (defun gnus-subject-equal (s1 s2)
7193 ((null gnus-summary-gather-subject-limit)
7194 (equal (gnus-simplify-subject-re s1)
7195 (gnus-simplify-subject-re s2)))
7196 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7197 (equal (gnus-simplify-subject-fuzzy s1)
7198 (gnus-simplify-subject-fuzzy s2)))
7199 ((numberp gnus-summary-gather-subject-limit)
7200 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7201 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7205 (defun gnus-summary-search-subject (&optional backward unread subject)
7206 "Search for article forward.
7207 If BACKWARD is non-nil, search backward.
7208 If UNREAD is non-nil, only unread articles are selected.
7209 If SUBJECT is non-nil, the article which has the same subject will be
7211 (let ((func (if backward 'previous-single-property-change
7212 'next-single-property-change))
7217 (and gnus-summary-check-current unread
7218 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7222 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7225 (setq pos (funcall func (point) 'gnus-number))
7226 (goto-char (if backward (1- pos) pos))
7230 (eq (get-text-property (point) 'gnus-mark)
7233 (and (setq psubject (inline (gnus-summary-subject-string)))
7234 (inline (gnus-subject-equal subject psubject)))))))
7235 (if backward (if (bobp) nil (forward-char -1) t)
7236 (if (eobp) nil (forward-char 1) t)))))
7238 (progn (goto-char beg) nil)
7240 (get-text-property (point) 'gnus-number)
7241 (gnus-summary-position-cursor)))))
7243 (defun gnus-summary-pseudo-article ()
7244 "The thread level of the article on the current line."
7245 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7247 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7248 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7249 (defun gnus-summary-article-score ()
7250 "Return current article score."
7251 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7252 gnus-summary-default-score 0))
7254 (defun gnus-summary-recenter ()
7255 "Center point in the summary window.
7256 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7257 displayed, no centering will be performed."
7258 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7259 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7260 (let* ((top (cond ((< (window-height) 4) 0)
7261 ((< (window-height) 7) 1)
7263 (height (1- (window-height)))
7264 (bottom (save-excursion (goto-char (point-max))
7265 (forward-line (- height))
7267 (window (get-buffer-window (current-buffer))))
7269 ;; The user has to want it,
7270 gnus-auto-center-summary
7271 ;; the article buffer must be displayed,
7272 (get-buffer-window gnus-article-buffer)
7273 ;; Set the window start to either `bottom', which is the biggest
7274 ;; possible valid number, or the second line from the top,
7275 ;; whichever is the least.
7277 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7279 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7280 (defun gnus-short-group-name (group &optional levels)
7281 "Collapse GROUP name LEVELS."
7282 (let* ((name "") (foreign "") (depth -1) (skip 1)
7285 (while (string-match "\\." group skip)
7286 (setq skip (match-end 0)
7289 (if (string-match ":" group)
7290 (setq foreign (substring group 0 (match-end 0))
7291 group (substring group (match-end 0))))
7293 (if (and (string-match "\\." group) (> levels 0))
7294 (setq name (concat name (substring group 0 1))
7295 group (substring group (match-end 0))
7297 name (concat name "."))
7298 (setq name (concat foreign name group)
7302 (defun gnus-summary-jump-to-group (newsgroup)
7303 "Move point to NEWSGROUP in group mode buffer."
7304 ;; Keep update point of group mode buffer if visible.
7305 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7306 (save-window-excursion
7307 ;; Take care of tree window mode.
7308 (if (get-buffer-window gnus-group-buffer)
7309 (pop-to-buffer gnus-group-buffer))
7310 (gnus-group-jump-to-group newsgroup))
7312 ;; Take care of tree window mode.
7313 (if (get-buffer-window gnus-group-buffer)
7314 (pop-to-buffer gnus-group-buffer)
7315 (set-buffer gnus-group-buffer))
7316 (gnus-group-jump-to-group newsgroup))))
7318 ;; This function returns a list of article numbers based on the
7319 ;; difference between the ranges of read articles in this group and
7320 ;; the range of active articles.
7321 (defun gnus-list-of-unread-articles (group)
7322 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7323 (active (gnus-gethash group gnus-active-hashtb))
7326 ;; If none are read, then all are unread.
7328 (setq first (car active))
7329 ;; If the range of read articles is a single range, then the
7330 ;; first unread article is the article after the last read
7331 ;; article. Sounds logical, doesn't it?
7332 (if (not (listp (cdr read)))
7333 (setq first (1+ (cdr read)))
7334 ;; `read' is a list of ranges.
7335 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7336 (car (car read)))) 1)
7340 (while (< first nlast)
7341 (setq unread (cons first unread))
7342 (setq first (1+ first))))
7343 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7344 (setq nlast (if (atom (car (cdr read)))
7346 (car (car (cdr read)))))
7347 (setq read (cdr read)))))
7348 ;; And add the last unread articles.
7349 (while (<= first last)
7350 (setq unread (cons first unread))
7351 (setq first (1+ first)))
7352 ;; Return the list of unread articles.
7355 (defun gnus-list-of-read-articles (group)
7356 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7357 (active (gnus-gethash group gnus-active-hashtb)))
7359 (gnus-sorted-complement
7360 (gnus-uncompress-range active)
7361 (gnus-list-of-unread-articles group)))))
7363 ;; Various summary commands
7365 (defun gnus-summary-universal-argument ()
7366 "Perform any operation on all articles marked with the process mark."
7368 (gnus-set-global-variables)
7369 (let ((articles (reverse gnus-newsgroup-processable))
7371 (or articles (error "No articles marked"))
7372 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7373 (error "Undefined key"))
7375 (gnus-summary-goto-subject (car articles))
7376 (command-execute func)
7377 (gnus-summary-remove-process-mark (car articles))
7378 (setq articles (cdr articles)))))
7380 (defun gnus-summary-toggle-truncation (arg)
7381 "Toggle truncation of summary lines.
7382 With arg, turn line truncation on iff arg is positive."
7384 (setq truncate-lines
7385 (if (null arg) (not truncate-lines)
7386 (> (prefix-numeric-value arg) 0)))
7389 (defun gnus-summary-reselect-current-group (all)
7390 "Once exit and then reselect the current newsgroup.
7391 The prefix argument ALL means to select all articles."
7393 (gnus-set-global-variables)
7394 (let ((current-subject (gnus-summary-article-number))
7395 (group gnus-newsgroup-name))
7396 (setq gnus-newsgroup-begin nil)
7397 (gnus-summary-exit t)
7398 ;; We have to adjust the point of group mode buffer because the
7399 ;; current point was moved to the next unread newsgroup by
7401 (gnus-summary-jump-to-group group)
7402 (gnus-group-read-group all t)
7403 (gnus-summary-goto-subject current-subject)))
7405 (defun gnus-summary-rescan-group (all)
7406 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7408 (gnus-set-global-variables)
7409 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7410 (let ((group gnus-newsgroup-name))
7412 (gnus-summary-jump-to-group group)
7414 (set-buffer gnus-group-buffer)
7415 (gnus-group-get-new-news-this-group 1))
7416 (gnus-summary-jump-to-group group)
7417 (gnus-group-read-group all)))
7419 (defun gnus-summary-update-info ()
7420 (let* ((group gnus-newsgroup-name))
7421 (if gnus-newsgroup-kill-headers
7422 (setq gnus-newsgroup-killed
7423 (gnus-compress-sequence
7425 (gnus-set-sorted-intersection
7426 (gnus-uncompress-range gnus-newsgroup-killed)
7427 (setq gnus-newsgroup-unselected
7428 (sort gnus-newsgroup-unselected '<)))
7429 (setq gnus-newsgroup-unreads
7430 (sort gnus-newsgroup-unreads '<))) t)))
7431 (or (listp (cdr gnus-newsgroup-killed))
7432 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7433 (let ((headers gnus-newsgroup-headers))
7434 (gnus-close-group group)
7435 (run-hooks 'gnus-exit-group-hook)
7436 (gnus-update-read-articles
7437 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7438 gnus-newsgroup-marked
7439 t gnus-newsgroup-replied gnus-newsgroup-expirable
7440 gnus-newsgroup-killed gnus-newsgroup-dormant
7441 gnus-newsgroup-bookmarks
7442 (and gnus-save-score gnus-newsgroup-scored))
7443 (and gnus-use-cross-reference
7444 (gnus-mark-xrefs-as-read
7445 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7446 ;; Do adaptive scoring, and possibly save score files.
7447 (and gnus-newsgroup-adaptive
7448 (gnus-score-adaptive))
7449 (and gnus-use-scoring
7450 (fboundp 'gnus-score-save)
7451 (funcall 'gnus-score-save))
7452 ;; Do not switch windows but change the buffer to work.
7453 (set-buffer gnus-group-buffer)
7454 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7455 (gnus-group-update-group group)))))
7457 (defun gnus-summary-exit (&optional temporary)
7458 "Exit reading current newsgroup, and then return to group selection mode.
7459 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7461 (gnus-set-global-variables)
7462 (gnus-kill-save-kill-buffer)
7463 (let* ((group gnus-newsgroup-name)
7464 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7465 gnus-newsgroup-name))))
7467 (buf (current-buffer)))
7468 (run-hooks 'gnus-summary-exit-hook)
7469 (gnus-summary-update-info) ; Make all changes in this group permanent.
7471 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7472 ;; Make sure where I was, and go to next newsgroup.
7473 (set-buffer gnus-group-buffer)
7476 (gnus-group-jump-to-group group)
7477 (gnus-group-next-unread-group 1)))
7480 ;; We set all buffer-local variables to nil. It is unclear why
7481 ;; this is needed, but if we don't, buffer-local variables are
7482 ;; not garbage-collected, it seems. This would the lead to en
7483 ;; ever-growing Emacs.
7485 (gnus-summary-clear-local-variables)
7486 ;; We clear the global counterparts of the buffer-local
7487 ;; variables as well, just to be on the safe side.
7488 (gnus-configure-windows 'group 'force)
7489 (gnus-summary-clear-local-variables)
7490 ;; Return to group mode buffer.
7491 (if (eq mode 'gnus-summary-mode)
7492 (gnus-kill-buffer buf))
7493 (if (get-buffer gnus-article-buffer)
7494 (bury-buffer gnus-article-buffer))
7495 (setq gnus-current-select-method gnus-select-method)
7496 (pop-to-buffer gnus-group-buffer)
7497 (if (not quit-config)
7499 (gnus-group-jump-to-group group)
7500 (gnus-group-next-unread-group 1))
7501 (if (not (buffer-name (car quit-config)))
7502 (gnus-configure-windows 'group 'force)
7503 (set-buffer (car quit-config))
7504 (and (eq major-mode 'gnus-summary-mode)
7505 (gnus-set-global-variables))
7506 (gnus-configure-windows (cdr quit-config)))))))
7508 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7509 (defun gnus-summary-exit-no-update (&optional no-questions)
7510 "Quit reading current newsgroup without updating read article info."
7512 (gnus-set-global-variables)
7513 (let* ((group gnus-newsgroup-name)
7514 (quit-config (nth 1 (assoc 'quit-config
7515 (gnus-find-method-for-group group)))))
7516 (if (or no-questions
7518 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7520 (gnus-close-group group)
7521 (gnus-summary-clear-local-variables)
7522 (set-buffer gnus-group-buffer)
7523 (gnus-summary-clear-local-variables)
7524 ;; Return to group selection mode.
7525 (gnus-configure-windows 'group 'force)
7526 (if (get-buffer gnus-summary-buffer)
7527 (kill-buffer gnus-summary-buffer))
7528 (if (get-buffer gnus-article-buffer)
7529 (bury-buffer gnus-article-buffer))
7530 (if (equal (gnus-group-group-name) group)
7531 (gnus-group-next-unread-group 1))
7534 (if (not (buffer-name (car quit-config)))
7535 (gnus-configure-windows 'group 'force)
7536 (set-buffer (car quit-config))
7537 (and (eq major-mode 'gnus-summary-mode)
7538 (gnus-set-global-variables))
7539 (gnus-configure-windows (cdr quit-config)))))))))
7541 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7542 (defun gnus-summary-fetch-faq (group)
7543 "Fetch the FAQ for the current group."
7544 (interactive (list gnus-newsgroup-name))
7545 (let ((gnus-faq-buffer
7546 (find-file (concat gnus-group-faq-directory
7547 (gnus-group-real-name group)))))
7548 (and gnus-faq-buffer (gnus-configure-windows 'summary-faq))))
7550 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7551 (defun gnus-summary-describe-group (force)
7552 "Describe the current newsgroup."
7554 (gnus-group-describe-group force gnus-newsgroup-name))
7556 (defun gnus-summary-describe-briefly ()
7557 "Describe summary mode commands briefly."
7560 (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")))
7562 ;; Walking around group mode buffer from summary mode.
7564 (defun gnus-summary-next-group (&optional no-article target-group backward)
7565 "Exit current newsgroup and then select next unread newsgroup.
7566 If prefix argument NO-ARTICLE is non-nil, no article is selected
7567 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7568 previous group instead."
7570 (gnus-set-global-variables)
7571 (let ((current-group gnus-newsgroup-name)
7572 (current-buffer (current-buffer))
7574 ;; First we semi-exit this group to update Xrefs and all variables.
7575 ;; We can't do a real exit, because the window conf must remain
7576 ;; the same in case the user is prompted for info, and we don't
7577 ;; want the window conf to change before that...
7578 (gnus-summary-exit t)
7579 (while (not entered)
7580 ;; Then we find what group we are supposed to enter.
7581 (set-buffer gnus-group-buffer)
7582 (gnus-group-jump-to-group current-group)
7585 (if (eq gnus-keep-same-level 'best)
7586 (gnus-summary-best-group gnus-newsgroup-name)
7587 (gnus-summary-search-group backward gnus-keep-same-level))))
7588 (if (not target-group)
7589 ;; There are no further groups, so we return to the group
7592 (gnus-message 5 "Returning to the group buffer")
7594 (set-buffer current-buffer)
7595 (gnus-summary-exit))
7596 ;; We try to enter the target group.
7597 (gnus-group-jump-to-group target-group)
7598 (let ((unreads (gnus-group-group-unread)))
7599 (if (and (or (eq t unreads)
7600 (and unreads (not (zerop unreads))))
7601 (gnus-summary-read-group
7602 target-group nil no-article current-buffer))
7604 (setq current-group target-group
7605 target-group nil)))))))
7607 (defun gnus-summary-next-group-old (&optional no-article group backward)
7608 "Exit current newsgroup and then select next unread newsgroup.
7609 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7610 If BACKWARD, go to previous group instead."
7612 (gnus-set-global-variables)
7613 (let ((ingroup gnus-newsgroup-name)
7614 (sumbuf (current-buffer))
7616 (set-buffer gnus-group-buffer)
7618 (or (and (numberp (setq num (car (gnus-gethash
7619 group gnus-newsrc-hashtb))))
7623 (gnus-group-jump-to-group group)
7625 (gnus-group-jump-to-group ingroup))
7626 (gnus-summary-search-group backward)
7627 (let ((group (or group (gnus-summary-search-group backward))))
7629 (gnus-summary-exit t) ;Update all information.
7631 (gnus-summary-exit-no-update t)
7632 (gnus-group-jump-to-group ingroup)
7633 (setq group (gnus-summary-search-group backward))
7634 (gnus-message 5 "Selecting %s..." group)
7635 (set-buffer gnus-group-buffer)
7636 ;; We are now in group mode buffer.
7637 ;; Make sure group mode buffer point is on GROUP.
7638 (gnus-group-jump-to-group group)
7639 (if (not (eq gnus-auto-select-next 'quietly))
7641 (gnus-summary-read-group group nil no-article sumbuf)
7642 (and (string= gnus-newsgroup-name ingroup)
7643 (bufferp sumbuf) (buffer-name sumbuf)
7645 (set-buffer (setq gnus-summary-buffer sumbuf))
7646 (gnus-summary-exit-no-update t))))
7647 (let ((prevgroup group))
7648 (gnus-group-jump-to-group ingroup)
7649 (setq group (gnus-summary-search-group backward))
7650 (gnus-summary-read-group group nil no-article sumbuf)
7651 (while (and (string= gnus-newsgroup-name ingroup)
7653 (buffer-name sumbuf)
7654 (not (string= prevgroup (gnus-group-group-name))))
7655 (set-buffer gnus-group-buffer)
7656 (gnus-summary-read-group
7657 (setq prevgroup (gnus-group-group-name))
7658 nil no-article sumbuf))
7659 (and (string= prevgroup (gnus-group-group-name))
7660 ;; We have reached the final group in the group
7663 (if (buffer-name sumbuf)
7666 (gnus-summary-exit)))))))))))
7668 (defun gnus-summary-prev-group (no-article)
7669 "Exit current newsgroup and then select previous unread newsgroup.
7670 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7672 (gnus-summary-next-group no-article nil t))
7674 ;; Walking around summary lines.
7676 (defun gnus-summary-first-subject (unread)
7677 "Go to the first unread subject.
7678 If UNREAD is non-nil, go to the first unread article.
7679 Returns nil if there are no unread articles."
7683 (goto-char (point-min)))
7686 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7689 ;; There are no unread articles.
7690 (gnus-message 3 "No more unread articles")
7692 (gnus-summary-position-cursor)))
7694 (defun gnus-summary-next-subject (n &optional unread dont-display)
7695 "Go to next N'th summary line.
7696 If N is negative, go to the previous N'th subject line.
7697 If UNREAD is non-nil, only unread articles are selected.
7698 The difference between N and the actual number of steps taken is
7701 (let ((backward (< n 0))
7704 (gnus-summary-search-forward unread nil backward))
7706 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7707 (if unread " unread" "")))
7710 (gnus-summary-recenter)
7711 (gnus-summary-position-cursor)))
7714 (defun gnus-summary-next-unread-subject (n)
7715 "Go to next N'th unread summary line."
7717 (gnus-summary-next-subject n t))
7719 (defun gnus-summary-prev-subject (n &optional unread)
7720 "Go to previous N'th summary line.
7721 If optional argument UNREAD is non-nil, only unread article is selected."
7723 (gnus-summary-next-subject (- n) unread))
7725 (defun gnus-summary-prev-unread-subject (n)
7726 "Go to previous N'th unread summary line."
7728 (gnus-summary-next-subject (- n) t))
7730 (defun gnus-summary-goto-subject (article)
7731 "Go the subject line of ARTICLE."
7735 (completing-read "Article number: "
7739 (int-to-string (header-number headers))))
7740 gnus-newsgroup-headers)
7741 nil 'require-match))))
7742 (or article (error "No article number"))
7744 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
7745 'gnus-number article)))
7747 (gnus-summary-show-thread)
7748 ;; Skip dummy articles.
7749 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7756 (gnus-summary-position-cursor)))))
7758 ;; Walking around summary lines with displaying articles.
7760 (defun gnus-summary-expand-window (arg)
7761 "Make the summary buffer take up the entire Emacs frame.
7762 Given a prefix, will force an `article' buffer configuration."
7764 (gnus-set-global-variables)
7766 (gnus-configure-windows 'article 'force)
7767 (gnus-configure-windows 'summary 'force)))
7769 (defun gnus-summary-display-article (article &optional all-header)
7770 "Display ARTICLE in article buffer."
7771 (gnus-set-global-variables)
7775 (gnus-article-prepare article all-header)
7776 (gnus-summary-show-thread)
7777 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7780 (gnus-summary-position-cursor)))
7781 (run-hooks 'gnus-select-article-hook)
7782 (gnus-summary-recenter)
7783 (gnus-summary-goto-subject article)
7784 ;; Successfully display article.
7785 (gnus-summary-update-line)
7786 (gnus-article-set-window-start
7787 (cdr (assq article gnus-newsgroup-bookmarks)))
7790 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7791 "Select the current article.
7792 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7793 non-nil, the article will be re-fetched even if it already present in
7794 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7796 (and (not pseudo) (gnus-summary-pseudo-article)
7797 (error "This is a pseudo-article."))
7798 (let ((article (or article (gnus-summary-article-number)))
7799 (all-headers (not (not all-headers))) ;Must be T or NIL.
7803 (set-buffer gnus-summary-buffer)
7804 (if (or (null gnus-current-article)
7805 (null gnus-article-current)
7806 (null (get-buffer gnus-article-buffer))
7807 (not (eq article (cdr gnus-article-current)))
7808 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7810 ;; The requested article is different from the current article.
7812 (gnus-summary-display-article article all-headers)
7814 (if (or all-headers gnus-show-all-headers)
7815 (gnus-article-show-all-headers))
7818 (gnus-article-set-window-start
7819 (cdr (assq article gnus-newsgroup-bookmarks)))))))
7821 (defun gnus-summary-set-current-mark (&optional current-mark)
7822 "Obsolete function."
7825 (defun gnus-summary-next-article (unread &optional subject backward)
7826 "Select the next article.
7827 If UNREAD, only unread articles are selected.
7828 If SUBJECT, only articles with SUBJECT are selected.
7829 If BACKWARD, the previous article is selected instead of the next."
7831 (gnus-set-global-variables)
7834 ;; Is there such an article?
7835 ((gnus-summary-display-article
7836 (gnus-summary-search-forward unread subject backward))
7837 (gnus-summary-position-cursor))
7838 ;; If not, we try the first unread, if that is wanted.
7840 gnus-auto-select-same
7841 (gnus-summary-first-unread-article))
7842 (gnus-message 6 "Wrapped"))
7843 ;; Try to get next/previous article not displayed in this group.
7844 ((and gnus-auto-extend-newsgroup
7845 (not unread) (not subject)
7846 (setq header (gnus-more-header-forward backward)))
7847 (gnus-extend-newsgroup header backward)
7848 (let ((buffer-read-only nil))
7849 (goto-char (if backward (point-min) (point-max)))
7850 (gnus-summary-prepare-threads (list header)))
7851 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7852 gnus-newsgroup-end)))
7853 ;; Go to next/previous group.
7855 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7856 (gnus-summary-jump-to-group gnus-newsgroup-name))
7857 (let ((cmd (aref (this-command-keys) 0))
7859 (if (eq gnus-keep-same-level 'best)
7860 (gnus-summary-best-group gnus-newsgroup-name)
7861 (gnus-summary-search-group backward gnus-keep-same-level))))
7862 ;; For some reason, the group window gets selected. We change
7864 (select-window (get-buffer-window (current-buffer)))
7865 ;; Keep just the event type of CMD.
7866 (and (listp cmd) (setq cmd (car cmd)))
7867 ;; Select next unread newsgroup automagically.
7869 ((not gnus-auto-select-next)
7870 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7871 ((eq gnus-auto-select-next 'quietly)
7873 (if (assoc 'quit-config (gnus-find-method-for-group
7874 gnus-newsgroup-name))
7876 (gnus-message 7 "No more%s articles (%s)..."
7877 (if unread " unread" "")
7878 (if group (concat "selecting " group)
7880 (gnus-summary-next-group nil group backward)))
7882 (let ((keystrokes '(?\C-n ?\C-p))
7884 (while (or (null key) (memq key keystrokes))
7886 7 "No more%s articles%s" (if unread " unread" "")
7887 (if (and group (not (assoc 'quit-config
7888 (gnus-find-method-for-group
7889 gnus-newsgroup-name))))
7890 (format " (Type %s for %s [%s])"
7891 (single-key-description cmd) group
7892 (car (gnus-gethash group gnus-newsrc-hashtb)))
7893 (format " (Type %s to exit %s)"
7894 (single-key-description cmd)
7895 gnus-newsgroup-name)))
7896 ;; Confirm auto selection.
7897 (let* ((event (read-event)))
7898 (setq key (if (listp event) (car event) event))
7899 (if (memq key keystrokes)
7900 (let ((obuf (current-buffer)))
7901 (switch-to-buffer gnus-group-buffer)
7902 (gnus-group-jump-to-group group)
7903 (execute-kbd-macro (char-to-string key))
7904 (setq group (gnus-group-group-name))
7905 (switch-to-buffer obuf)))))
7907 (if (or (not group) (assoc 'quit-config
7908 (gnus-find-method-for-group
7909 gnus-newsgroup-name)))
7911 (gnus-summary-next-group nil group backward))
7912 (setq unread-command-events (list key)))))))))))
7914 (defun gnus-summary-next-unread-article ()
7915 "Select unread article after current one."
7917 (gnus-summary-next-article t (and gnus-auto-select-same
7918 (gnus-summary-subject-string))))
7920 (defun gnus-summary-prev-article (unread &optional subject)
7921 "Select the article after the current one.
7922 If UNREAD is non-nil, only unread articles are selected."
7924 (gnus-summary-next-article unread subject t))
7926 (defun gnus-summary-prev-unread-article ()
7927 "Select unred article before current one."
7929 (gnus-summary-prev-article t (and gnus-auto-select-same
7930 (gnus-summary-subject-string))))
7932 (defun gnus-summary-next-page (lines &optional circular)
7933 "Show next page of selected article.
7934 If end of article, select next article.
7935 Argument LINES specifies lines to be scrolled up.
7936 If CIRCULAR is non-nil, go to the start of the article instead of
7937 instead of selecting the next article when reaching the end of the
7940 (setq gnus-summary-buffer (current-buffer))
7941 (gnus-set-global-variables)
7942 (let ((article (gnus-summary-article-number))
7944 (gnus-configure-windows 'article)
7945 (if (or (null gnus-current-article)
7946 (null gnus-article-current)
7947 (/= article (cdr gnus-article-current))
7948 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7949 ;; Selected subject is different from current article's.
7950 (gnus-summary-display-article article)
7951 (gnus-eval-in-buffer-window
7953 (setq endp (gnus-article-next-page lines)))
7956 (gnus-summary-beginning-of-article))
7958 (gnus-message 3 "End of message"))
7960 (gnus-summary-next-unread-article)))))
7961 (gnus-summary-recenter)
7962 (gnus-summary-position-cursor)))
7964 (defun gnus-summary-prev-page (lines)
7965 "Show previous page of selected article.
7966 Argument LINES specifies lines to be scrolled down."
7968 (gnus-set-global-variables)
7969 (let ((article (gnus-summary-article-number)))
7970 (gnus-configure-windows 'article)
7971 (if (or (null gnus-current-article)
7972 (null gnus-article-current)
7973 (/= article (cdr gnus-article-current))
7974 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7975 ;; Selected subject is different from current article's.
7976 (gnus-summary-display-article article)
7977 (gnus-summary-recenter)
7978 (gnus-eval-in-buffer-window gnus-article-buffer
7979 (gnus-article-prev-page lines))))
7980 (gnus-summary-position-cursor))
7982 (defun gnus-summary-scroll-up (lines)
7983 "Scroll up (or down) one line current article.
7984 Argument LINES specifies lines to be scrolled up (or down if negative)."
7986 (gnus-set-global-variables)
7987 (gnus-configure-windows 'article)
7988 (or (gnus-summary-select-article nil nil 'pseudo)
7989 (gnus-eval-in-buffer-window
7992 (if (gnus-article-next-page lines)
7993 (gnus-message 3 "End of message")))
7995 (gnus-article-prev-page (- lines))))))
7996 (gnus-summary-recenter)
7997 (gnus-summary-position-cursor))
7999 (defun gnus-summary-next-same-subject ()
8000 "Select next article which has the same subject as current one."
8002 (gnus-set-global-variables)
8003 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8005 (defun gnus-summary-prev-same-subject ()
8006 "Select previous article which has the same subject as current one."
8008 (gnus-set-global-variables)
8009 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8011 (defun gnus-summary-next-unread-same-subject ()
8012 "Select next unread article which has the same subject as current one."
8014 (gnus-set-global-variables)
8015 (gnus-summary-next-article t (gnus-summary-subject-string)))
8017 (defun gnus-summary-prev-unread-same-subject ()
8018 "Select previous unread article which has the same subject as current one."
8020 (gnus-set-global-variables)
8021 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8023 (defun gnus-summary-first-unread-article ()
8024 "Select the first unread article.
8025 Return nil if there are no unread articles."
8027 (gnus-set-global-variables)
8029 (if (gnus-summary-first-subject t)
8030 (gnus-summary-display-article (gnus-summary-article-number)))
8031 (gnus-summary-position-cursor)))
8033 (defun gnus-summary-best-unread-article ()
8034 "Select the unread article with the highest score."
8036 (gnus-set-global-variables)
8037 (let ((scored gnus-newsgroup-scored)
8041 (or (> best (cdr (car scored)))
8042 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
8043 (not (memq art gnus-newsgroup-marked))
8044 (not (memq art gnus-newsgroup-dormant))
8045 (if (= best (cdr (car scored)))
8046 (setq article (min art article))
8048 (setq best (cdr (car scored))))))
8049 (setq scored (cdr scored)))
8051 (gnus-summary-goto-article article)
8052 (gnus-summary-first-unread-article))
8053 (gnus-summary-position-cursor)))
8055 (defun gnus-summary-goto-article (article &optional all-headers)
8056 "Fetch ARTICLE and display it if it exists.
8057 If ALL-HEADERS is non-nil, no header lines are hidden."
8063 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
8064 gnus-newsgroup-headers)
8065 nil 'require-match))))
8067 (and (gnus-summary-goto-subject article)
8068 (gnus-summary-display-article article all-headers))
8069 (gnus-summary-position-cursor)))
8071 (defun gnus-summary-goto-last-article ()
8072 "Go to the previously read article."
8075 (and gnus-last-article
8076 (gnus-summary-goto-article gnus-last-article))
8077 (gnus-summary-position-cursor)))
8079 (defun gnus-summary-pop-article (number)
8080 "Pop one article off the history and go to the previous.
8081 NUMBER articles will be popped off."
8084 (setq gnus-newsgroup-history
8085 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8087 (gnus-summary-goto-article (car to))
8088 (error "Article history empty")))
8089 (gnus-summary-position-cursor))
8091 ;; Summary article oriented commands
8093 (defun gnus-summary-refer-parent-article (n)
8094 "Refer parent article N times.
8095 The difference between N and the number of articles fetched is returned."
8097 (gnus-set-global-variables)
8101 (let ((ref (header-references (gnus-get-header-by-num
8102 (gnus-summary-article-number)))))
8103 (if (and ref (not (equal ref ""))
8104 (string-match "<[^<>]*>[ \t]*$" ref))
8105 (gnus-summary-refer-article
8106 (substring ref (match-beginning 0) (match-end 0)))
8107 (gnus-message 1 "No references in article %d"
8108 (gnus-summary-article-number))
8111 (gnus-summary-position-cursor)
8114 (defun gnus-summary-refer-article (message-id)
8115 "Refer article specified by MESSAGE-ID.
8116 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8117 (interactive "sMessage-ID: ")
8118 (if (or (not (stringp message-id))
8119 (zerop (length message-id)))
8121 ;; Construct the correct Message-ID if necessary.
8122 ;; Suggested by tale@pawl.rpi.edu.
8123 (or (string-match "^<" message-id)
8124 (setq message-id (concat "<" message-id)))
8125 (or (string-match ">$" message-id)
8126 (setq message-id (concat message-id ">")))
8127 (let ((header (car (gnus-gethash (downcase message-id)
8128 gnus-newsgroup-dependencies))))
8130 (or (gnus-summary-goto-article (header-number header))
8131 ;; The header has been read, but the article had been
8132 ;; expunged, so we insert it again.
8134 (gnus-summary-insert-line
8135 nil header 0 nil gnus-read-mark nil nil
8136 (header-subject header))
8138 (header-number header)))
8139 (let ((gnus-override-method gnus-refer-article-method)
8140 (gnus-ancient-mark gnus-read-mark)
8141 (tmp-point (window-start
8142 (get-buffer-window gnus-article-buffer)))
8144 (and gnus-refer-article-method
8145 (or (gnus-server-opened gnus-refer-article-method)
8146 (gnus-open-server gnus-refer-article-method)))
8147 ;; Save the old article buffer.
8149 (set-buffer gnus-article-buffer)
8150 (gnus-kill-buffer " *temp Article*")
8151 (setq tmp-buf (rename-buffer " *temp Article*")))
8153 (if (gnus-article-prepare
8154 message-id nil (gnus-read-header message-id))
8156 (setq number (header-number gnus-current-headers))
8157 (gnus-rebuild-thread message-id)
8158 (gnus-summary-goto-subject number)
8159 (gnus-summary-recenter)
8160 (gnus-article-set-window-start
8161 (cdr (assq number gnus-newsgroup-bookmarks)))
8163 ;; We restore the old article buffer.
8165 (kill-buffer gnus-article-buffer)
8166 (set-buffer tmp-buf)
8167 (rename-buffer gnus-article-buffer)
8168 (let ((buffer-read-only nil))
8170 (set-window-start (get-buffer-window (current-buffer))
8171 tmp-point)))))))))))
8173 (defun gnus-summary-enter-digest-group ()
8174 "Enter a digest group based on the current article."
8176 (gnus-set-global-variables)
8177 (gnus-summary-select-article)
8178 ;; We do not want a narrowed article.
8179 (gnus-summary-stop-page-breaking)
8180 (let ((name (format "%s-%d"
8181 (gnus-group-prefixed-name
8182 gnus-newsgroup-name (list 'nndoc ""))
8183 gnus-current-article))
8184 (ogroup gnus-newsgroup-name)
8185 (buf (current-buffer)))
8186 (if (gnus-group-read-ephemeral-group
8187 name (list 'nndoc name
8188 (list 'nndoc-address (get-buffer gnus-article-buffer))
8189 '(nndoc-article-type digest))
8191 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8192 (list (list (cons 'to-group ogroup))))
8193 (switch-to-buffer buf)
8194 (gnus-set-global-variables)
8195 (gnus-configure-windows 'summary)
8196 (gnus-message 3 "Article not a digest?"))))
8198 (defun gnus-summary-isearch-article ()
8199 "Do incremental search forward on current article."
8201 (gnus-set-global-variables)
8202 (gnus-summary-select-article)
8203 (gnus-eval-in-buffer-window
8204 gnus-article-buffer (isearch-forward)))
8206 (defun gnus-summary-search-article-forward (regexp &optional backward)
8207 "Search for an article containing REGEXP forward.
8208 If BACKWARD, search backward instead."
8211 (format "Search article %s (regexp%s): "
8212 (if current-prefix-arg "backward" "forward")
8213 (if gnus-last-search-regexp
8214 (concat ", default " gnus-last-search-regexp)
8216 current-prefix-arg))
8217 (gnus-set-global-variables)
8218 (if (string-equal regexp "")
8219 (setq regexp (or gnus-last-search-regexp ""))
8220 (setq gnus-last-search-regexp regexp))
8221 (if (gnus-summary-search-article regexp backward)
8222 (gnus-article-set-window-start
8223 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8224 (error "Search failed: \"%s\"" regexp)))
8226 (defun gnus-summary-search-article-backward (regexp)
8227 "Search for an article containing REGEXP backward."
8230 (format "Search article backward (regexp%s): "
8231 (if gnus-last-search-regexp
8232 (concat ", default " gnus-last-search-regexp)
8234 (gnus-summary-search-article-forward regexp 'backward))
8236 (defun gnus-summary-search-article (regexp &optional backward)
8237 "Search for an article containing REGEXP.
8238 Optional argument BACKWARD means do search for backward.
8239 gnus-select-article-hook is not called during the search."
8240 (let ((gnus-select-article-hook nil) ;Disable hook.
8241 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8244 (function re-search-backward) (function re-search-forward)))
8247 ;; Hidden thread subtrees must be searched for ,too.
8248 (gnus-summary-show-all-threads)
8249 (if (eobp) (forward-line -1))
8250 ;; First of all, search current article.
8251 ;; We don't want to read article again from NNTP server nor reset
8253 (gnus-summary-select-article)
8254 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8255 (setq last gnus-current-article)
8256 (gnus-eval-in-buffer-window gnus-article-buffer
8259 ;; Begin search from current point.
8260 (setq found (funcall re-search regexp nil t))))
8261 ;; Then search next articles.
8262 (while (and (not found)
8263 (gnus-summary-display-article
8264 (gnus-summary-search-subject backward nil nil)))
8265 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8266 (gnus-eval-in-buffer-window gnus-article-buffer
8269 (goto-char (if backward (point-max) (point-min)))
8270 (setq found (funcall re-search regexp nil t)))))
8272 ;; Adjust article pointer.
8273 (or (eq last gnus-current-article)
8274 (setq gnus-last-article last))
8275 ;; Return T if found such article.
8278 (defun gnus-summary-execute-command (header regexp command &optional backward)
8279 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8280 If HEADER is an empty string (or nil), the match is done on the entire
8281 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8283 (list (let ((completion-ignore-case t))
8286 (mapcar (lambda (string) (list string))
8287 '("Number" "Subject" "From" "Lines" "Date"
8288 "Message-ID" "Xref" "References"))
8289 nil 'require-match))
8290 (read-string "Regexp: ")
8291 (read-key-sequence "Command: ")
8292 current-prefix-arg))
8293 (gnus-set-global-variables)
8294 ;; Hidden thread subtrees must be searched as well.
8295 (gnus-summary-show-all-threads)
8296 ;; We don't want to change current point nor window configuration.
8298 (save-window-excursion
8299 (gnus-message 6 "Executing %s..." (key-description command))
8300 ;; We'd like to execute COMMAND interactively so as to give arguments.
8301 (gnus-execute header regexp
8303 (call-interactively '(, (key-binding command)))))
8305 (gnus-message 6 "Executing %s...done" (key-description command)))))
8307 (defun gnus-summary-beginning-of-article ()
8308 "Scroll the article back to the beginning."
8310 (gnus-set-global-variables)
8311 (gnus-summary-select-article)
8312 (gnus-configure-windows 'article)
8313 (gnus-eval-in-buffer-window
8316 (goto-char (point-min))
8317 (and gnus-break-pages (gnus-narrow-to-page))))
8319 (defun gnus-summary-end-of-article ()
8320 "Scroll to the end of the article."
8322 (gnus-set-global-variables)
8323 (gnus-summary-select-article)
8324 (gnus-configure-windows 'article)
8325 (gnus-eval-in-buffer-window
8328 (goto-char (point-max))
8329 (and gnus-break-pages (gnus-narrow-to-page))))
8331 (defun gnus-summary-show-article (no-refetch)
8332 "Force re-fetching of the current article.
8333 If the prefix argument NO-REFETCH is non-nil, no actual refetch will
8334 be performed. The current article will simply be redisplayed."
8336 (gnus-set-global-variables)
8337 (if (not no-refetch)
8338 (gnus-summary-select-article gnus-have-all-headers t)
8339 (or gnus-current-article
8340 (error "There is no current article"))
8341 (gnus-summary-goto-subject gnus-current-article)
8342 (gnus-configure-windows 'article)
8343 (gnus-summary-position-cursor)))
8345 (defun gnus-summary-verbose-headers (arg)
8346 "Toggle permanent full header display.
8347 If ARG is a positive number, turn header display on.
8348 If ARG is a negative number, turn header display off."
8350 (gnus-set-global-variables)
8351 (gnus-summary-toggle-header arg)
8352 (setq gnus-have-all-headers
8353 (cond ((or (not (numberp arg))
8355 (not gnus-have-all-headers))
8359 (defun gnus-summary-toggle-header (arg)
8360 "Show the headers if they are hidden, or hide them if they are shown.
8361 If ARG is a positive number, show the entire header.
8362 If ARG is a negative number, hide the unwanted header lines."
8364 (gnus-set-global-variables)
8366 (set-buffer gnus-article-buffer)
8367 (let ((buffer-read-only nil))
8369 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8370 gnus-hidden-properties)
8371 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8372 (if (text-property-any (point-min) (point-max) 'invisible t)
8373 (remove-text-properties (point-min) (point-max)
8374 gnus-hidden-properties)
8375 (let ((gnus-have-all-headers nil))
8376 (run-hooks 'gnus-article-display-hook))))
8377 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8379 (defun gnus-summary-show-all-headers ()
8380 "Make all header lines visible."
8382 (gnus-set-global-variables)
8383 (gnus-article-show-all-headers))
8385 (defun gnus-summary-toggle-mime (arg)
8386 "Toggle MIME processing.
8387 If ARG is a positive number, turn MIME processing on."
8389 (gnus-set-global-variables)
8390 (setq gnus-show-mime
8391 (if (null arg) (not gnus-show-mime)
8392 (> (prefix-numeric-value arg) 0)))
8393 (gnus-summary-select-article t 'force))
8395 (defun gnus-summary-caesar-message (arg)
8396 "Caesar rotate the current article by 13.
8397 The numerical prefix specifies how manu places to rotate each letter
8400 (gnus-set-global-variables)
8401 (gnus-summary-select-article)
8402 (let ((mail-header-separator ""))
8403 (gnus-eval-in-buffer-window
8407 (let ((last (point)))
8408 (news-caesar-buffer-body arg)
8412 (defun gnus-summary-stop-page-breaking ()
8413 "Stop page breaking in the current article."
8415 (gnus-set-global-variables)
8416 (gnus-summary-select-article)
8417 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8419 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8421 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
8422 "Move the current article to a different newsgroup.
8423 If N is a positive number, move the N next articles.
8424 If N is a negative number, move the N previous articles.
8425 If N is nil and any articles have been marked with the process mark,
8426 move those articles instead.
8427 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8428 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8429 re-spool using this method.
8430 For this function to work, both the current newsgroup and the
8431 newsgroup that you want to move to have to support the `request-move'
8432 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8434 (gnus-set-global-variables)
8435 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8436 (error "The current newsgroup does not support article moving"))
8437 (let ((articles (gnus-summary-work-articles n))
8438 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8439 art-group to-method sel-met)
8440 (if (and (not to-newsgroup) (not select-method))
8443 (format "Where do you want to move %s? %s"
8444 (if (> (length articles) 1)
8445 (format "these %d articles" (length articles))
8447 (if gnus-current-move-group
8448 (format "(%s default) " gnus-current-move-group)
8450 gnus-active-hashtb nil nil prefix)))
8453 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8454 (setq to-newsgroup (or gnus-current-move-group "")))
8455 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8456 (gnus-activate-newsgroup to-newsgroup)
8457 (error "No such group: %s" to-newsgroup))
8458 (setq gnus-current-move-group to-newsgroup)))
8459 (setq to-method (if select-method (list select-method "")
8460 (gnus-find-method-for-group to-newsgroup)))
8461 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8462 (error "%s does not support article copying" (car to-method)))
8463 (or (gnus-server-opened to-method)
8464 (gnus-open-server to-method)
8465 (error "Can't open server %s" (car to-method)))
8466 (gnus-message 6 "Moving to %s: %s..."
8467 (or select-method to-newsgroup) articles)
8470 (gnus-request-move-article
8471 (car articles) ; Article to move
8472 gnus-newsgroup-name ; From newsgrouo
8473 (nth 1 (gnus-find-method-for-group
8474 gnus-newsgroup-name)) ; Server
8475 (list 'gnus-request-accept-article
8477 (list 'quote select-method)
8479 (not (cdr articles))) ; Accept form
8480 (not (cdr articles)))) ; Only save nov last time
8481 (let* ((buffer-read-only nil)
8484 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8486 (gnus-group-prefixed-name
8488 (if select-method (list select-method "")
8489 (gnus-find-method-for-group to-newsgroup)))
8490 gnus-newsrc-hashtb)))
8491 (info (nth 2 entry))
8492 (article (car articles)))
8493 (gnus-summary-goto-subject article)
8495 (delete-region (point)
8496 (progn (forward-line 1) (point)))
8497 (if (not (memq article gnus-newsgroup-unreads))
8498 (setcar (cdr (cdr info))
8499 (gnus-add-to-range (nth 2 info)
8500 (list (cdr art-group)))))
8501 ;; Copy any marks over to the new group.
8502 (let ((marks '((tick . gnus-newsgroup-marked)
8503 (dormant . gnus-newsgroup-dormant)
8504 (expire . gnus-newsgroup-expirable)
8505 (bookmark . gnus-newsgroup-bookmarks)
8506 ; (score . gnus-newsgroup-scored)
8507 (reply . gnus-newsgroup-replied)))
8508 (to-article (cdr art-group)))
8510 (if (memq article (symbol-value (cdr (car marks))))
8511 (gnus-add-marked-articles
8512 (car info) (car (car marks)) (list to-article) info))
8513 (setq marks (cdr marks))))
8514 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8515 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8516 (setq gnus-newsgroup-dormant
8517 (delq article gnus-newsgroup-dormant)))
8518 (gnus-message 1 "Couldn't move article %s" (car articles)))
8519 (gnus-summary-remove-process-mark (car articles))
8520 (setq articles (cdr articles)))))
8522 (defun gnus-summary-respool-article (n &optional respool-method)
8523 "Respool the current article.
8524 The article will be squeezed through the mail spooling process again,
8525 which means that it will be put in some mail newsgroup or other
8526 depending on `nnmail-split-methods'.
8527 If N is a positive number, respool the N next articles.
8528 If N is a negative number, respool the N previous articles.
8529 If N is nil and any articles have been marked with the process mark,
8530 respool those articles instead.
8532 Respooling can be done both from mail groups and \"real\" newsgroups.
8533 In the former case, the articles in question will be moved from the
8534 current group into whatever groups they are destined to. In the
8535 latter case, they will be copied into the relevant groups."
8537 (gnus-set-global-variables)
8538 (let ((respool-methods (gnus-methods-using 'respool))
8540 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8542 (setq respool-method
8544 "What method do you want to use when respooling? "
8545 respool-methods nil t methname)))
8546 (or (string= respool-method "")
8547 (if (assoc (symbol-name
8548 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8550 (gnus-summary-move-article n nil (intern respool-method))
8551 (gnus-summary-copy-article n nil (intern respool-method))))))
8553 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8554 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
8555 "Move the current article to a different newsgroup.
8556 If N is a positive number, move the N next articles.
8557 If N is a negative number, move the N previous articles.
8558 If N is nil and any articles have been marked with the process mark,
8559 move those articles instead.
8560 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8561 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8562 re-spool using this method.
8563 For this function to work, the newsgroup that you want to move to have
8564 to support the `request-move' and `request-accept'
8565 functions. (Ie. mail newsgroups at present.)"
8567 (gnus-set-global-variables)
8568 (let ((articles (gnus-summary-work-articles n))
8569 (copy-buf (get-buffer-create "*copy work*"))
8570 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8571 art-group to-method)
8572 (buffer-disable-undo copy-buf)
8573 (if (and (not to-newsgroup) (not select-method))
8576 (format "Where do you want to copy %s? %s"
8577 (if (> (length articles) 1)
8578 (format "these %d articles" (length articles))
8580 (if gnus-current-move-group
8581 (format "(%s default) " gnus-current-move-group)
8583 gnus-active-hashtb nil nil prefix)))
8586 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8587 (setq to-newsgroup (or gnus-current-move-group "")))
8588 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8589 (gnus-activate-newsgroup to-newsgroup)
8590 (error "No such group: %s" to-newsgroup))
8591 (setq gnus-current-move-group to-newsgroup)))
8592 (setq to-method (if select-method (list select-method "")
8593 (gnus-find-method-for-group to-newsgroup)))
8594 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8595 (error "%s does not support article copying" (car to-method)))
8596 (or (gnus-server-opened to-method)
8597 (gnus-open-server to-method)
8598 (error "Can't open server %s" (car to-method)))
8600 (gnus-message 6 "Copying to %s: %s..."
8601 (or select-method to-newsgroup) articles)
8604 (set-buffer copy-buf)
8605 (gnus-request-article-this-buffer
8606 (car articles) gnus-newsgroup-name)
8607 (gnus-request-accept-article
8608 (if select-method (quote select-method) to-newsgroup)
8609 (not (cdr articles)))))
8612 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8614 (gnus-group-prefixed-name
8616 (if select-method (list select-method "")
8617 (gnus-find-method-for-group to-newsgroup)))
8618 gnus-newsrc-hashtb)))
8619 (info (nth 2 entry))
8620 (article (car articles)))
8621 (if (not (memq article gnus-newsgroup-unreads))
8622 (setcar (cdr (cdr info))
8623 (gnus-add-to-range (nth 2 info)
8624 (list (cdr art-group)))))
8625 ;; Copy any marks over to the new group.
8626 (let ((marks '((tick . gnus-newsgroup-marked)
8627 (dormant . gnus-newsgroup-dormant)
8628 (expire . gnus-newsgroup-expirable)
8629 (bookmark . gnus-newsgroup-bookmarks)
8630 ; (score . gnus-newsgroup-scored)
8631 (reply . gnus-newsgroup-replied)))
8632 (to-article (cdr art-group)))
8634 (if (memq article (symbol-value (cdr (car marks))))
8635 (gnus-add-marked-articles
8636 (car info) (car (car marks)) (list to-article) info))
8637 (setq marks (cdr marks)))))
8638 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8639 (gnus-summary-remove-process-mark (car articles))
8640 (setq articles (cdr articles)))
8641 (kill-buffer copy-buf)))
8643 (defun gnus-summary-import-article (file)
8644 "Import a random file into a mail newsgroup."
8645 (interactive "fImport file: ")
8646 (let ((group gnus-newsgroup-name)
8648 (or (gnus-check-backend-function 'request-accept-article group)
8649 (error "%s does not support article importing" group))
8650 (or (file-readable-p file)
8651 (not (file-regular-p file))
8652 (error "Can't read %s" file))
8654 (set-buffer (get-buffer-create " *import file*"))
8655 (buffer-disable-undo (current-buffer))
8657 (insert-file-contents file)
8658 (goto-char (point-min))
8659 (if (nnheader-article-p)
8661 (setq atts (file-attributes file))
8662 (insert "From: " (read-string "From: ") "\n"
8663 "Subject: " (read-string "Subject: ") "\n"
8664 "Date: " (current-time-string (nth 5 atts)) "\n"
8665 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8666 (gnus-request-accept-article group t)
8667 (kill-buffer (current-buffer)))))
8669 (defun gnus-summary-expire-articles ()
8670 "Expire all articles that are marked as expirable in the current group."
8672 (if (not (gnus-check-backend-function
8673 'request-expire-articles gnus-newsgroup-name))
8675 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
8676 gnus-newsrc-hashtb)))
8677 (total (memq 'total-expire (nth 5 info)))
8678 (expirable (if total
8679 (gnus-list-of-read-articles gnus-newsgroup-name)
8680 (setq gnus-newsgroup-expirable
8681 (sort gnus-newsgroup-expirable '<))))
8685 (gnus-message 6 "Expiring articles...")
8686 ;; The list of articles that weren't expired is returned.
8687 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
8688 (or total (setq gnus-newsgroup-expirable es))
8689 ;; We go through the old list of expirable, and mark all
8690 ;; really expired articles as non-existant.
8691 (or (eq es expirable) ; If nothing was expired, we don't mark.
8693 (or (memq (car expirable) es)
8694 (gnus-summary-mark-article
8695 (car expirable) gnus-canceled-mark))
8696 (setq expirable (cdr expirable))))
8697 (gnus-message 6 "Expiring articles...done")))))
8699 (defun gnus-summary-expire-articles-now ()
8700 "Expunge all expirable articles in the current group.
8701 This means that *all* articles that are marked as expirable will be
8702 deleted forever, right now."
8704 (or gnus-expert-user
8706 "Are you really, really, really sure you want to expunge? ")
8708 (let ((nnmail-expiry-wait -1)
8709 (nnmail-expiry-wait-function nil))
8710 (gnus-summary-expire-articles)))
8712 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8713 (defun gnus-summary-delete-article (n)
8714 "Delete the N next (mail) articles.
8715 This command actually deletes articles. This is not a marking
8716 command. The article will disappear forever from you life, never to
8718 If N is negative, delete backwards.
8719 If N is nil and articles have been marked with the process mark,
8720 delete these instead."
8722 (or (gnus-check-backend-function 'request-expire-articles
8723 gnus-newsgroup-name)
8724 (error "The current newsgroup does not support article deletion."))
8725 ;; Compute the list of articles to delete.
8726 (let ((articles (gnus-summary-work-articles n))
8728 (if (and gnus-novice-user
8730 (format "Do you really want to delete %s forever? "
8731 (if (> (length articles) 1) "these articles"
8734 ;; Delete the articles.
8735 (setq not-deleted (gnus-request-expire-articles
8736 articles gnus-newsgroup-name 'force))
8738 (gnus-summary-remove-process-mark (car articles))
8739 ;; The backend might not have been able to delete the article
8741 (or (memq (car articles) not-deleted)
8742 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8743 (setq articles (cdr articles))))
8744 (gnus-summary-position-cursor)
8747 (defun gnus-summary-edit-article ()
8748 "Enter into a buffer and edit the current article.
8749 This will have permanent effect only in mail groups."
8751 (or (gnus-check-backend-function
8752 'request-replace-article gnus-newsgroup-name)
8753 (error "The current newsgroup does not support article editing."))
8754 (gnus-summary-select-article t)
8755 (gnus-configure-windows 'article)
8756 (select-window (get-buffer-window gnus-article-buffer))
8757 (gnus-message 6 "C-c C-c to end edits")
8758 (setq buffer-read-only nil)
8760 (use-local-map (copy-keymap (current-local-map)))
8761 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8762 (buffer-enable-undo)
8764 (goto-char (point-min))
8765 (search-forward "\n\n" nil t))
8767 (defun gnus-summary-edit-article-done ()
8768 "Make edits to the current article permanent."
8770 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
8773 (if (not (gnus-request-replace-article
8774 (cdr gnus-article-current) (car gnus-article-current)
8776 (error "Couldn't replace article.")
8778 (use-local-map gnus-article-mode-map)
8779 (setq buffer-read-only t)
8780 (buffer-disable-undo (current-buffer))
8781 (gnus-configure-windows 'summary))))
8783 (defun gnus-summary-fancy-query ()
8784 "Query where the fancy respool algorithm would put this article."
8786 (gnus-summary-select-article)
8788 (set-buffer gnus-article-buffer)
8790 (goto-char (point-min))
8791 (search-forward "\n\n")
8792 (narrow-to-region (point-min) (point))
8793 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8795 ;; Summary score commands.
8797 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8799 (defun gnus-summary-raise-score (n)
8800 "Raise the score of the current article by N."
8802 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8804 (defun gnus-summary-lower-score (n)
8805 "Lower the score of the current article by N."
8807 (gnus-summary-raise-score (- n)))
8809 (defun gnus-summary-set-score (n)
8810 "Set the score of the current article to N."
8812 ;; Skip dummy header line.
8814 (gnus-summary-show-thread)
8815 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8817 (let ((buffer-read-only nil))
8819 (gnus-summary-update-mark
8820 (if (= n (or gnus-summary-default-score 0)) ?
8821 (if (< n (or gnus-summary-default-score 0))
8822 gnus-score-below-mark gnus-score-over-mark)) 'score))
8823 (let* ((article (gnus-summary-article-number))
8824 (score (assq article gnus-newsgroup-scored)))
8825 (if score (setcdr score n)
8826 (setq gnus-newsgroup-scored
8827 (cons (cons article n) gnus-newsgroup-scored))))
8828 (gnus-summary-update-line)))
8830 (defun gnus-summary-current-score ()
8831 "Return the score of the current article."
8833 (message "%s" (gnus-summary-article-score)))
8835 ;; Summary marking commands.
8837 (defun gnus-summary-raise-same-subject-and-select (score)
8838 "Raise articles which has the same subject with SCORE and select the next."
8840 (let ((subject (gnus-summary-subject-string)))
8841 (gnus-summary-raise-score score)
8842 (while (gnus-summary-search-subject nil nil subject)
8843 (gnus-summary-raise-score score))
8844 (gnus-summary-next-article t)))
8846 (defun gnus-summary-raise-same-subject (score)
8847 "Raise articles which has the same subject with SCORE."
8849 (let ((subject (gnus-summary-subject-string)))
8850 (gnus-summary-raise-score score)
8851 (while (gnus-summary-search-subject nil nil subject)
8852 (gnus-summary-raise-score score))
8853 (gnus-summary-next-subject 1 t)))
8855 (defun gnus-score-default (level)
8856 (if level (prefix-numeric-value level)
8857 gnus-score-interactive-default-score))
8859 (defun gnus-summary-raise-thread (score)
8860 "Raise the score of the articles in the current thread with SCORE."
8862 (setq score (1- (gnus-score-default score)))
8865 (let ((level (gnus-summary-thread-level)))
8866 (gnus-summary-raise-score score)
8867 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8868 (> (gnus-summary-thread-level) level))
8869 (gnus-summary-raise-score score))
8871 (let ((gnus-summary-check-current t))
8872 (or (zerop (gnus-summary-next-subject 1 t))
8874 (gnus-summary-recenter)
8875 (gnus-summary-position-cursor)
8876 (gnus-set-mode-line 'summary))
8878 (defun gnus-summary-lower-same-subject-and-select (score)
8879 "Raise articles which has the same subject with SCORE and select the next."
8881 (gnus-summary-raise-same-subject-and-select (- score)))
8883 (defun gnus-summary-lower-same-subject (score)
8884 "Raise articles which has the same subject with SCORE."
8886 (gnus-summary-raise-same-subject (- score)))
8888 (defun gnus-summary-lower-thread (score)
8889 "Lower score of articles in the current thread with SCORE."
8891 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8893 (defun gnus-summary-kill-same-subject-and-select (unmark)
8894 "Mark articles which has the same subject as read, and then select the next.
8895 If UNMARK is positive, remove any kind of mark.
8896 If UNMARK is negative, tick articles."
8899 (setq unmark (prefix-numeric-value unmark)))
8901 (gnus-summary-mark-same-subject
8902 (gnus-summary-subject-string) unmark)))
8903 ;; Select next unread article. If auto-select-same mode, should
8904 ;; select the first unread article.
8905 (gnus-summary-next-article t (and gnus-auto-select-same
8906 (gnus-summary-subject-string)))
8907 (gnus-message 7 "%d articles are marked as %s"
8908 count (if unmark "unread" "read"))))
8910 (defun gnus-summary-kill-same-subject (unmark)
8911 "Mark articles which has the same subject as read.
8912 If UNMARK is positive, remove any kind of mark.
8913 If UNMARK is negative, tick articles."
8916 (setq unmark (prefix-numeric-value unmark)))
8918 (gnus-summary-mark-same-subject
8919 (gnus-summary-subject-string) unmark)))
8920 ;; If marked as read, go to next unread subject.
8922 ;; Go to next unread subject.
8923 (gnus-summary-next-subject 1 t))
8924 (gnus-message 7 "%d articles are marked as %s"
8925 count (if unmark "unread" "read"))))
8927 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8928 "Mark articles with same SUBJECT as read, and return marked number.
8929 If optional argument UNMARK is positive, remove any kinds of marks.
8930 If optional argument UNMARK is negative, mark articles as unread instead."
8934 ((null unmark) ; Mark as read.
8936 (gnus-summary-mark-article-as-read gnus-killed-mark)
8937 (gnus-summary-search-forward nil subject))
8938 (setq count (1+ count))))
8939 ((> unmark 0) ; Tick.
8941 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8942 (gnus-summary-search-forward nil subject))
8943 (setq count (1+ count))))
8944 (t ; Mark as unread.
8946 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8947 (gnus-summary-search-forward nil subject))
8948 (setq count (1+ count)))))
8949 ;; Return the number of marked articles.
8952 (defun gnus-summary-mark-as-processable (n &optional unmark)
8953 "Set the process mark on the next N articles.
8954 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8955 the process mark instead. The difference between N and the actual
8956 number of articles marked is returned."
8958 (let ((backward (< n 0))
8963 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8964 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8965 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8967 (if (/= 0 n) (gnus-message 7 "No more articles"))
8968 (gnus-summary-recenter)
8969 (gnus-summary-position-cursor)
8972 (defun gnus-summary-unmark-as-processable (n)
8973 "Remove the process mark from the next N articles.
8974 If N is negative, mark backward instead. The difference between N and
8975 the actual number of articles marked is returned."
8977 (gnus-summary-mark-as-processable n t))
8979 (defun gnus-summary-unmark-all-processable ()
8980 "Remove the process mark from all articles."
8983 (while gnus-newsgroup-processable
8984 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8985 (gnus-summary-position-cursor))
8987 (defun gnus-summary-mark-as-expirable (n)
8988 "Mark N articles forward as expirable.
8989 If N is negative, mark backward instead. The difference between N and
8990 the actual number of articles marked is returned."
8992 (gnus-summary-mark-forward n gnus-expirable-mark))
8994 (defun gnus-summary-mark-article-as-replied (article)
8995 "Mark ARTICLE replied and update the summary line."
8996 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8997 (let ((buffer-read-only nil))
8998 (if (gnus-summary-goto-subject article)
9000 (gnus-summary-update-mark gnus-replied-mark 'replied)
9003 (defun gnus-summary-set-bookmark (article)
9004 "Set a bookmark in current article."
9005 (interactive (list (gnus-summary-article-number)))
9006 (if (or (not (get-buffer gnus-article-buffer))
9007 (not gnus-current-article)
9008 (not gnus-article-current)
9009 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9010 (error "No current article selected"))
9011 ;; Remove old bookmark, if one exists.
9012 (let ((old (assq article gnus-newsgroup-bookmarks)))
9013 (if old (setq gnus-newsgroup-bookmarks
9014 (delq old gnus-newsgroup-bookmarks))))
9015 ;; Set the new bookmark, which is on the form
9016 ;; (article-number . line-number-in-body).
9017 (setq gnus-newsgroup-bookmarks
9021 (set-buffer gnus-article-buffer)
9025 (goto-char (point-min))
9026 (search-forward "\n\n" nil t)
9029 gnus-newsgroup-bookmarks))
9030 (gnus-message 6 "A bookmark has been added to the current article."))
9032 (defun gnus-summary-remove-bookmark (article)
9033 "Remove the bookmark from the current article."
9034 (interactive (list (gnus-summary-article-number)))
9035 ;; Remove old bookmark, if one exists.
9036 (let ((old (assq article gnus-newsgroup-bookmarks)))
9039 (setq gnus-newsgroup-bookmarks
9040 (delq old gnus-newsgroup-bookmarks))
9041 (gnus-message 6 "Removed bookmark."))
9042 (gnus-message 6 "No bookmark in current article."))))
9044 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9045 (defun gnus-summary-mark-as-dormant (n)
9046 "Mark N articles forward as dormant.
9047 If N is negative, mark backward instead. The difference between N and
9048 the actual number of articles marked is returned."
9050 (gnus-summary-mark-forward n gnus-dormant-mark))
9052 (defun gnus-summary-set-process-mark (article)
9053 "Set the process mark on ARTICLE and update the summary line."
9054 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9055 (let ((buffer-read-only nil))
9056 (if (gnus-summary-goto-subject article)
9058 (gnus-summary-show-thread)
9059 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9061 (gnus-summary-update-mark gnus-process-mark 'replied)
9064 (defun gnus-summary-remove-process-mark (article)
9065 "Remove the process mark from ARTICLE and update the summary line."
9066 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9067 (let ((buffer-read-only nil))
9068 (if (gnus-summary-goto-subject article)
9070 (gnus-summary-show-thread)
9071 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9073 (gnus-summary-update-mark ? 'replied)
9074 (if (memq article gnus-newsgroup-replied)
9075 (gnus-summary-update-mark gnus-replied-mark 'replied))
9078 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9079 "Mark N articles as read forwards.
9080 If N is negative, mark backwards instead.
9081 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9083 The difference between N and the actual number of articles marked is
9086 (gnus-set-global-variables)
9087 (let ((backward (< n 0))
9088 (gnus-summary-goto-unread
9089 (and gnus-summary-goto-unread
9090 (not (memq mark (list gnus-unread-mark
9091 gnus-ticked-mark gnus-dormant-mark)))))
9093 (mark (or mark gnus-del-mark)))
9095 (gnus-summary-mark-article nil mark no-expire)
9096 (zerop (gnus-summary-next-subject
9097 (if backward -1 1) gnus-summary-goto-unread t)))
9099 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9100 (gnus-summary-recenter)
9101 (gnus-summary-position-cursor)
9102 (gnus-set-mode-line 'summary)
9105 (defun gnus-summary-mark-article-as-read (mark)
9106 "Mark the current article quickly as read with MARK."
9107 (let ((article (gnus-summary-article-number)))
9108 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9109 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9110 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9111 ;; Possibly remove from cache, if that is used.
9112 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9113 (and gnus-newsgroup-auto-expire
9114 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9115 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9116 (= mark gnus-read-mark))
9118 (setq mark gnus-expirable-mark)
9119 (setq gnus-newsgroup-expirable
9120 (cons article gnus-newsgroup-expirable))))
9121 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9124 (gnus-summary-update-mark mark 'unread)
9127 (defun gnus-summary-mark-article-as-unread (mark)
9128 "Mark the current article quickly as unread with MARK."
9129 (let ((article (gnus-summary-article-number)))
9130 (or (memq article gnus-newsgroup-unreads)
9131 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9132 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9133 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9134 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9135 (if (= mark gnus-ticked-mark)
9136 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9137 (if (= mark gnus-dormant-mark)
9138 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9140 ;; See whether the article is to be put in the cache.
9143 (gnus-cache-possibly-enter-article
9144 gnus-newsgroup-name article
9145 (gnus-get-header-by-num article)
9146 (= mark gnus-ticked-mark)
9147 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9149 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9152 (gnus-summary-update-mark mark 'unread)
9155 (defun gnus-summary-mark-article (&optional article mark no-expire)
9156 "Mark ARTICLE with MARK. MARK can be any character.
9157 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9158 (dormant) and `?E' (expirable).
9159 If MARK is nil, then the default character `?D' is used.
9160 If ARTICLE is nil, then the article on the current line will be
9163 (setq mark (aref mark 0)))
9164 ;; If no mark is given, then we check auto-expiring.
9165 (and (not no-expire)
9166 gnus-newsgroup-auto-expire
9169 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9170 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9171 (= mark gnus-read-mark))))
9172 (setq mark gnus-expirable-mark))
9173 (let* ((mark (or mark gnus-del-mark))
9174 (article (or article (gnus-summary-article-number))))
9175 (or article (error "No article on current line"))
9176 (if (or (= mark gnus-unread-mark)
9177 (= mark gnus-ticked-mark)
9178 (= mark gnus-dormant-mark))
9179 (gnus-mark-article-as-unread article mark)
9180 (gnus-mark-article-as-read article mark))
9182 ;; See whether the article is to be put in the cache.
9184 (not (= mark gnus-canceled-mark))
9186 (gnus-cache-possibly-enter-article
9187 gnus-newsgroup-name article
9188 (gnus-get-header-by-num article)
9189 (= mark gnus-ticked-mark)
9190 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9192 (if (gnus-summary-goto-subject article)
9193 (let ((buffer-read-only nil))
9194 (gnus-summary-show-thread)
9195 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9198 (gnus-summary-update-mark mark 'unread)
9201 (defun gnus-summary-update-mark (mark type)
9203 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9204 (buffer-read-only nil)
9208 (forward-char forward)
9209 (setq plist (text-properties-at (point)))
9212 (and plist (add-text-properties (1- (point)) (point) plist))
9213 (and (eq type 'unread)
9214 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9215 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9217 (defun gnus-mark-article-as-read (article &optional mark)
9218 "Enter ARTICLE in the pertinent lists and remove it from others."
9219 ;; Make the article expirable.
9220 (let ((mark (or mark gnus-del-mark)))
9221 (if (= mark gnus-expirable-mark)
9222 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9223 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9224 ;; Remove from unread and marked lists.
9225 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9226 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9227 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9228 ;; Possibly remove from cache, if that is used.
9229 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9231 (defun gnus-mark-article-as-unread (article &optional mark)
9232 "Enter ARTICLE in the pertinent lists and remove it from others."
9233 (let ((mark (or mark gnus-ticked-mark)))
9234 ;; Add to unread list.
9235 (or (memq article gnus-newsgroup-unreads)
9236 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9237 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9238 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9239 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9240 (if (= mark gnus-ticked-mark)
9241 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9242 (if (= mark gnus-dormant-mark)
9243 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9245 (defalias 'gnus-summary-mark-as-unread-forward
9246 'gnus-summary-tick-article-forward)
9247 (make-obsolete 'gnus-summary-mark-as-unread-forward
9248 'gnus-summary-tick-article-forward)
9249 (defun gnus-summary-tick-article-forward (n)
9250 "Tick N articles forwards.
9251 If N is negative, tick backwards instead.
9252 The difference between N and the number of articles ticked is returned."
9254 (gnus-summary-mark-forward n gnus-ticked-mark))
9256 (defalias 'gnus-summary-mark-as-unread-backward
9257 'gnus-summary-tick-article-backward)
9258 (make-obsolete 'gnus-summary-mark-as-unread-backward
9259 'gnus-summary-tick-article-backward)
9260 (defun gnus-summary-tick-article-backward (n)
9261 "Tick N articles backwards.
9262 The difference between N and the number of articles ticked is returned."
9264 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9266 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9267 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9268 (defun gnus-summary-tick-article (&optional article clear-mark)
9269 "Mark current article as unread.
9270 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9271 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9272 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9275 (defun gnus-summary-mark-as-read-forward (n)
9276 "Mark N articles as read forwards.
9277 If N is negative, mark backwards instead.
9278 The difference between N and the actual number of articles marked is
9281 (gnus-summary-mark-forward n gnus-del-mark t))
9283 (defun gnus-summary-mark-as-read-backward (n)
9284 "Mark the N articles as read backwards.
9285 The difference between N and the actual number of articles marked is
9288 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9290 (defun gnus-summary-mark-as-read (&optional article mark)
9291 "Mark current article as read.
9292 ARTICLE specifies the article to be marked as read.
9293 MARK specifies a string to be inserted at the beginning of the line."
9294 (gnus-summary-mark-article article mark))
9296 (defun gnus-summary-clear-mark-forward (n)
9297 "Clear marks from N articles forward.
9298 If N is negative, clear backward instead.
9299 The difference between N and the number of marks cleared is returned."
9301 (gnus-summary-mark-forward n gnus-unread-mark))
9303 (defun gnus-summary-clear-mark-backward (n)
9304 "Clear marks from N articles backward.
9305 The difference between N and the number of marks cleared is returned."
9307 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9309 (defun gnus-summary-mark-unread-as-read ()
9310 "Intended to be used by `gnus-summary-mark-article-hook'."
9311 (and (memq gnus-current-article gnus-newsgroup-unreads)
9312 (or (memq gnus-current-article gnus-newsgroup-marked)
9313 (memq gnus-current-article gnus-newsgroup-dormant)
9314 (memq gnus-current-article gnus-newsgroup-expirable)
9315 (gnus-summary-mark-article-as-read gnus-read-mark))))
9317 (defun gnus-summary-mark-region-as-read (point mark all)
9318 "Mark all unread articles between point and mark as read.
9319 If given a prefix, mark all articles between point and mark as read,
9320 even ticked and dormant ones."
9321 (interactive "r\nP")
9331 (not (memq (gnus-summary-article-number)
9332 gnus-newsgroup-marked))
9333 (not (memq (gnus-summary-article-number)
9334 gnus-newsgroup-dormant))))
9335 (gnus-summary-mark-article
9336 (gnus-summary-article-number) gnus-del-mark))
9338 (zerop (forward-line 1))))))
9340 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9341 (defalias 'gnus-summary-delete-marked-as-read
9342 'gnus-summary-remove-lines-marked-as-read)
9343 (make-obsolete 'gnus-summary-delete-marked-as-read
9344 'gnus-summary-remove-lines-marked-as-read)
9345 (defun gnus-summary-remove-lines-marked-as-read ()
9346 "Remove lines that are marked as read."
9348 (gnus-summary-remove-lines-marked-with
9350 (lambda (char) (char-to-string (symbol-value char)))
9351 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9352 gnus-killed-mark gnus-kill-file-mark
9353 gnus-low-score-mark gnus-expirable-mark
9357 (defalias 'gnus-summary-delete-marked-with
9358 'gnus-summary-remove-lines-marked-with)
9359 (make-obsolete 'gnus-summary-delete-marked-with
9360 'gnus-summary-remove-lines-marked-with)
9361 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9362 (defun gnus-summary-remove-lines-marked-with (marks)
9363 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9364 (interactive "sMarks: ")
9365 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9366 (gnus-set-global-variables)
9367 (let ((buffer-read-only nil)
9368 (marks (concat "^[" marks "]")))
9369 (goto-char (point-min))
9370 (if gnus-newsgroup-adaptive
9371 (gnus-score-remove-lines-adaptive marks)
9372 (while (re-search-forward marks nil t)
9373 (gnus-delete-line)))
9374 ;; If we use dummy roots, we have to do an additional sweep over
9376 (if (not (eq gnus-summary-make-false-root 'dummy))
9378 (goto-char (point-min))
9379 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9380 (while (re-search-forward marks nil t)
9381 (if (gnus-subject-equal
9382 (gnus-summary-subject-string)
9385 (gnus-summary-subject-string)))
9388 (gnus-delete-line)))))
9389 (or (zerop (buffer-size))
9391 (gnus-summary-prev-subject 1)
9392 (gnus-summary-position-cursor))))
9394 (defun gnus-summary-expunge-below (score)
9395 "Remove articles with score less than SCORE."
9397 (gnus-set-global-variables)
9398 (setq score (if score
9399 (prefix-numeric-value score)
9400 (or gnus-summary-default-score 0)))
9402 (set-buffer gnus-summary-buffer)
9403 (goto-char (point-min))
9404 (let ((buffer-read-only nil)
9407 (if (< (gnus-summary-article-score) score)
9411 (delete-region beg (point)))
9414 (or (zerop (buffer-size))
9416 (gnus-summary-prev-subject 1)
9417 (gnus-summary-position-cursor))))))
9419 (defun gnus-summary-mark-below (score mark)
9420 "Mark articles with score less than SCORE with MARK."
9421 (interactive "P\ncMark: ")
9422 (gnus-set-global-variables)
9423 (setq score (if score
9424 (prefix-numeric-value score)
9425 (or gnus-summary-default-score 0)))
9427 (set-buffer gnus-summary-buffer)
9428 (goto-char (point-min))
9430 (and (< (gnus-summary-article-score) score)
9431 (gnus-summary-mark-article nil mark))
9434 (defun gnus-summary-kill-below (score)
9435 "Mark articles with score below SCORE as read."
9437 (gnus-summary-mark-below score gnus-killed-mark))
9439 (defun gnus-summary-clear-above (score)
9440 "Clear all marks from articles with score above SCORE."
9442 (gnus-summary-mark-above score gnus-unread-mark))
9444 (defun gnus-summary-tick-above (score)
9445 "Tick all articles with score above SCORE."
9447 (gnus-summary-mark-above score gnus-ticked-mark))
9449 (defun gnus-summary-mark-above (score mark)
9450 "Mark articles with score over SCORE with MARK."
9451 (interactive "P\ncMark: ")
9452 (setq score (if score
9453 (prefix-numeric-value score)
9454 (or gnus-summary-default-score 0)))
9456 (set-buffer gnus-summary-buffer)
9457 (goto-char (point-min))
9459 (if (> (gnus-summary-article-score) score)
9461 (gnus-summary-mark-article nil mark)
9463 (forward-line 1)))))
9465 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9466 (defun gnus-summary-show-all-expunged ()
9467 "Display all the hidden articles that were expunged for low scores."
9469 (let ((buffer-read-only nil))
9470 (let ((scored gnus-newsgroup-scored)
9473 (or (gnus-summary-goto-subject (car (car scored)))
9474 (and (setq h (gnus-get-header-by-num (car (car scored))))
9475 (< (cdr (car scored)) gnus-summary-expunge-below)
9476 (setq headers (cons h headers))))
9477 (setq scored (cdr scored)))
9478 (or headers (error "No expunged articles hidden."))
9479 (goto-char (point-min))
9481 (gnus-summary-update-lines
9484 (gnus-summary-prepare-threads (nreverse headers))
9486 (goto-char (point-min))
9487 (gnus-summary-position-cursor)))
9489 (defun gnus-summary-show-all-dormant ()
9490 "Display all the hidden articles that are marked as dormant."
9492 (let ((buffer-read-only nil))
9493 (let ((dormant gnus-newsgroup-dormant)
9496 (or (gnus-summary-goto-subject (car dormant))
9497 (and (setq h (gnus-get-header-by-num (car dormant)))
9498 (setq headers (cons h headers))))
9499 (setq dormant (cdr dormant)))
9500 (or headers (error "No dormant articles hidden."))
9501 (goto-char (point-min))
9503 (gnus-summary-update-lines
9506 (gnus-summary-prepare-threads (nreverse headers))
9508 (goto-char (point-min))
9509 (gnus-summary-position-cursor)))
9511 (defun gnus-summary-hide-all-dormant ()
9512 "Hide all dormant articles."
9514 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9515 (gnus-summary-position-cursor))
9517 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
9518 "Mark all articles not marked as unread in this newsgroup as read.
9519 If prefix argument ALL is non-nil, all articles are marked as read.
9520 If QUIETLY is non-nil, no questions will be asked.
9521 If TO-HERE is non-nil, it should be a point in the buffer. All
9522 articles before this point will be marked as read.
9523 The number of articles marked as read is returned."
9527 (not gnus-interactive-catchup) ;Without confirmation?
9531 "Mark absolutely all articles as read? "
9532 "Mark all unread articles as read? ")))
9534 (not gnus-newsgroup-adaptive)
9535 (not gnus-newsgroup-auto-expire))
9537 (and all (setq gnus-newsgroup-marked nil
9538 gnus-newsgroup-dormant nil))
9539 (setq gnus-newsgroup-unreads
9540 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9541 ;; We actually mark all articles as canceled, which we
9542 ;; have to do when using auto-expiry or adaptive scoring.
9543 (let ((unreads (length gnus-newsgroup-unreads)))
9544 (gnus-summary-show-all-threads)
9545 (if (gnus-summary-first-subject (not all))
9546 (while (and (if to-here (< (point) to-here) t)
9547 (gnus-summary-mark-article-as-read
9549 (gnus-summary-search-subject nil (not all)))))
9550 (- unreads (length gnus-newsgroup-unreads))
9552 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9553 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9554 (if (and (not to-here) (eq 'nnvirtual (car method)))
9555 (nnvirtual-catchup-group
9556 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9557 (gnus-summary-position-cursor)))
9559 (defun gnus-summary-catchup-to-here (&optional all)
9560 "Mark all unticked articles before the current one as read.
9561 If ALL is non-nil, also mark ticked and dormant articles as read."
9564 (and (zerop (forward-line -1))
9567 (gnus-summary-catchup all t (point))
9568 (gnus-set-mode-line 'summary))))
9569 (gnus-summary-position-cursor))
9571 (defun gnus-summary-catchup-all (&optional quietly)
9572 "Mark all articles in this newsgroup as read."
9574 (gnus-summary-catchup t quietly))
9576 (defun gnus-summary-catchup-and-exit (all &optional quietly)
9577 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9578 If prefix argument ALL is non-nil, all articles are marked as read."
9580 (gnus-summary-catchup all quietly nil 'fast)
9581 ;; Select next newsgroup or exit.
9582 (if (eq gnus-auto-select-next 'quietly)
9583 (gnus-summary-next-group nil)
9584 (gnus-summary-exit)))
9586 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9587 "Mark all articles in this newsgroup as read, and then exit."
9589 (gnus-summary-catchup-and-exit t quietly))
9591 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9592 (defun gnus-summary-catchup-and-goto-next-group (all)
9593 "Mark all articles in this group as read and select the next group.
9594 If given a prefix, mark all articles, unread as well as ticked, as
9597 (gnus-summary-catchup all)
9598 (gnus-summary-next-group))
9600 ;; Thread-based commands.
9602 (defun gnus-summary-toggle-threads (arg)
9603 "Toggle showing conversation threads.
9604 If ARG is positive number, turn showing conversation threads on."
9606 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9607 (setq gnus-show-threads
9608 (if (null arg) (not gnus-show-threads)
9609 (> (prefix-numeric-value arg) 0)))
9610 (gnus-summary-prepare)
9611 (gnus-summary-goto-subject current)
9612 (gnus-summary-position-cursor)))
9614 (defun gnus-summary-show-all-threads ()
9618 (let ((buffer-read-only nil))
9619 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9620 (gnus-summary-position-cursor))
9622 (defun gnus-summary-show-thread ()
9623 "Show thread subtrees.
9624 Returns nil if no thread was there to be shown."
9628 (let ((buffer-read-only nil)
9629 ;; first goto end then to beg, to have point at beg after let
9630 (end (progn (end-of-line) (point)))
9631 (beg (progn (beginning-of-line) (point))))
9633 ;; Any hidden lines here?
9634 (search-forward "\r" end t)
9635 (subst-char-in-region beg end ?\^M ?\n t))))
9636 (gnus-summary-position-cursor)))
9638 (defun gnus-summary-hide-all-threads ()
9639 "Hide all thread subtrees."
9642 (goto-char (point-min))
9643 (gnus-summary-hide-thread)
9644 (while (and (not (eobp)) (zerop (forward-line 1)))
9645 (gnus-summary-hide-thread)))
9646 (gnus-summary-position-cursor))
9648 (defun gnus-summary-hide-thread ()
9649 "Hide thread subtrees.
9650 Returns nil if no threads were there to be hidden."
9652 (let ((buffer-read-only nil)
9654 (level (gnus-summary-thread-level))
9656 ;; Go forward until either the buffer ends or the subthread
9660 (while (and (zerop (forward-line 1))
9661 (> (gnus-summary-thread-level) level))
9666 (search-backward "\n" start t))
9667 (subst-char-in-region start end ?\n ?\^M t)
9668 (forward-line -1)))))
9670 (defun gnus-summary-go-to-next-thread (&optional previous)
9671 "Go to the same level (or less) next thread.
9672 If PREVIOUS is non-nil, go to previous thread instead.
9673 Return the article number moved to, or nil if moving was impossible."
9674 (let ((level (gnus-summary-thread-level))
9675 (article (gnus-summary-article-number)))
9677 (while (and (zerop (forward-line -1))
9678 (> (gnus-summary-thread-level) level)))
9679 (while (and (save-excursion
9682 (zerop (forward-line 1))
9683 (> (gnus-summary-thread-level) level))))
9684 (gnus-summary-recenter)
9685 (gnus-summary-position-cursor)
9686 (let ((oart (gnus-summary-article-number)))
9687 (and (/= oart article) oart))))
9689 (defun gnus-summary-next-thread (n)
9690 "Go to the same level next N'th thread.
9691 If N is negative, search backward instead.
9692 Returns the difference between N and the number of skips actually
9695 (let ((backward (< n 0))
9698 (gnus-summary-go-to-next-thread backward))
9700 (gnus-summary-position-cursor)
9701 (if (/= 0 n) (gnus-message 7 "No more threads"))
9704 (defun gnus-summary-prev-thread (n)
9705 "Go to the same level previous N'th thread.
9706 Returns the difference between N and the number of skips actually
9709 (gnus-summary-next-thread (- n)))
9711 (defun gnus-summary-go-down-thread (&optional same)
9712 "Go down one level in the current thread.
9713 If SAME is non-nil, also move to articles of the same level."
9714 (let ((level (gnus-summary-thread-level))
9716 (if (and (zerop (forward-line 1))
9717 (> (gnus-summary-thread-level) level))
9722 (defun gnus-summary-go-up-thread ()
9723 "Go up one level in the current thread."
9724 (let ((level (gnus-summary-thread-level))
9726 (while (and (zerop (forward-line -1))
9727 (>= (gnus-summary-thread-level) level)))
9728 (if (>= (gnus-summary-thread-level) level)
9734 (defun gnus-summary-down-thread (n)
9735 "Go down thread N steps.
9736 If N is negative, go up instead.
9737 Returns the difference between N and how many steps down that were
9743 (if up (gnus-summary-go-up-thread)
9744 (gnus-summary-go-down-thread)))
9746 (gnus-summary-position-cursor)
9747 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9750 (defun gnus-summary-up-thread (n)
9751 "Go up thread N steps.
9752 If N is negative, go up instead.
9753 Returns the difference between N and how many steps down that were
9756 (gnus-summary-down-thread (- n)))
9758 (defun gnus-summary-kill-thread (unmark)
9759 "Mark articles under current thread as read.
9760 If the prefix argument is positive, remove any kinds of marks.
9761 If the prefix argument is negative, tick articles instead."
9764 (setq unmark (prefix-numeric-value unmark)))
9766 (level (gnus-summary-thread-level)))
9769 ;; Mark the article...
9770 (cond ((null unmark) (gnus-summary-mark-article-as-read
9772 ((> unmark 0) (gnus-summary-mark-article-as-unread
9774 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9775 ;; ...and go forward until either the buffer ends or the subtree
9777 (if (not (and (zerop (forward-line 1))
9778 (> (gnus-summary-thread-level) level)))
9779 (setq killing nil))))
9780 ;; Hide killed subtrees.
9782 gnus-thread-hide-killed
9783 (gnus-summary-hide-thread))
9784 ;; If marked as read, go to next unread subject.
9786 ;; Go to next unread subject.
9787 (gnus-summary-next-subject 1 t)))
9788 (gnus-set-mode-line 'summary))
9790 ;; Summary sorting commands
9792 (defun gnus-summary-sort-by-number (&optional reverse)
9793 "Sort summary buffer by article number.
9794 Argument REVERSE means reverse order."
9797 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9799 (defun gnus-summary-sort-by-author (&optional reverse)
9800 "Sort summary buffer by author name alphabetically.
9801 If case-fold-search is non-nil, case of letters is ignored.
9802 Argument REVERSE means reverse order."
9807 (let ((extract (funcall
9808 gnus-extract-address-components
9809 (header-from (gnus-get-header-by-num
9810 (gnus-summary-article-number))))))
9811 (or (car extract) (cdr extract))))
9812 'gnus-thread-sort-by-author)
9815 (defun gnus-summary-sort-by-subject (&optional reverse)
9816 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9817 If case-fold-search is non-nil, case of letters is ignored.
9818 Argument REVERSE means reverse order."
9823 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9824 'gnus-thread-sort-by-subject)
9827 (defun gnus-summary-sort-by-date (&optional reverse)
9828 "Sort summary buffer by date.
9829 Argument REVERSE means reverse order."
9836 (gnus-get-header-by-num (gnus-summary-article-number)))))
9837 'gnus-thread-sort-by-date)
9840 (defun gnus-summary-sort-by-score (&optional reverse)
9841 "Sort summary buffer by score.
9842 Argument REVERSE means reverse order."
9845 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9848 (defvar gnus-summary-already-sorted nil)
9849 (defun gnus-summary-sort (predicate reverse)
9850 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9851 (if gnus-summary-already-sorted
9853 (let (buffer-read-only)
9854 (if (not gnus-show-threads)
9856 (goto-char (point-min))
9857 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9858 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9859 (gnus-summary-prepare-hook nil)
9860 (gnus-summary-already-sorted nil))
9861 (gnus-summary-prepare)
9862 (and gnus-show-threads
9863 gnus-thread-hide-subtree
9864 (gnus-summary-hide-all-threads))
9865 ;; If in async mode, we send some info to the backend.
9866 (and gnus-newsgroup-async
9867 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
9868 (gnus-request-asynchronous
9870 (if (and gnus-asynchronous-article-function
9871 (fboundp gnus-asynchronous-article-function))
9872 (funcall gnus-asynchronous-article-function
9873 gnus-newsgroup-threads)))))))))
9876 (defun gnus-sortable-date (date)
9877 "Make sortable string by string-lessp from DATE.
9878 Timezone package is used."
9879 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9880 (year (aref date 0))
9881 (month (aref date 1))
9882 (day (aref date 2)))
9883 (timezone-make-sortable-date
9885 (timezone-make-time-string
9886 (aref date 3) (aref date 4) (aref date 5)))))
9889 ;; Summary saving commands.
9891 (defun gnus-summary-save-article (n)
9892 "Save the current article using the default saver function.
9893 If N is a positive number, save the N next articles.
9894 If N is a negative number, save the N previous articles.
9895 If N is nil and any articles have been marked with the process mark,
9896 save those articles instead.
9897 The variable `gnus-default-article-saver' specifies the saver function."
9899 (let ((articles (gnus-summary-work-articles n)))
9901 (let ((header (gnus-get-header-by-num (car articles))))
9902 (if (vectorp header)
9904 (save-window-excursion
9905 (gnus-summary-select-article t nil nil (car articles)))
9906 (or gnus-save-all-headers
9907 (gnus-article-hide-headers t))
9908 ;; Remove any X-Gnus lines.
9911 (set-buffer gnus-article-buffer)
9912 (let ((buffer-read-only nil))
9913 (goto-char (point-min))
9914 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9916 (while (re-search-forward "^X-Gnus" nil t)
9918 (delete-region (point)
9919 (progn (forward-line 1) (point))))
9921 (save-window-excursion
9922 (if gnus-default-article-saver
9923 (funcall gnus-default-article-saver)
9924 (error "No default saver is defined."))))
9925 (if (assq 'name header)
9926 (gnus-copy-file (cdr (assq 'name header)))
9927 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9928 (gnus-summary-remove-process-mark (car articles))
9929 (setq articles (cdr articles)))
9930 (gnus-summary-position-cursor)
9933 (defun gnus-summary-pipe-output (arg)
9934 "Pipe the current article to a subprocess.
9935 If N is a positive number, pipe the N next articles.
9936 If N is a negative number, pipe the N previous articles.
9937 If N is nil and any articles have been marked with the process mark,
9938 pipe those articles instead."
9940 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9941 (gnus-summary-save-article arg)))
9943 (defun gnus-summary-save-article-mail (arg)
9944 "Append the current article to an mail file.
9945 If N is a positive number, save the N next articles.
9946 If N is a negative number, save the N previous articles.
9947 If N is nil and any articles have been marked with the process mark,
9948 save those articles instead."
9950 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9951 (gnus-summary-save-article arg)))
9953 (defun gnus-summary-save-article-rmail (arg)
9954 "Append the current article to an rmail file.
9955 If N is a positive number, save the N next articles.
9956 If N is a negative number, save the N previous articles.
9957 If N is nil and any articles have been marked with the process mark,
9958 save those articles instead."
9960 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9961 (gnus-summary-save-article arg)))
9963 (defun gnus-summary-save-article-file (arg)
9964 "Append the current article to a file.
9965 If N is a positive number, save the N next articles.
9966 If N is a negative number, save the N previous articles.
9967 If N is nil and any articles have been marked with the process mark,
9968 save those articles instead."
9970 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9971 (gnus-summary-save-article arg)))
9973 (defun gnus-read-save-file-name (prompt default-name)
9974 (let ((methods gnus-split-methods)
9976 (if (not gnus-split-methods)
9979 (set-buffer gnus-article-buffer)
9980 (gnus-narrow-to-headers)
9982 (goto-char (point-min))
9983 (and (condition-case ()
9984 (re-search-forward (car (car methods)) nil t)
9986 (setq split-name (cons (nth 1 (car methods)) split-name)))
9987 (setq methods (cdr methods)))
9989 (cond ((null split-name)
9991 (concat prompt " (default "
9992 (file-name-nondirectory default-name) ") ")
9993 (file-name-directory default-name)
9995 ((= 1 (length split-name))
9997 (concat prompt " (default " (car split-name) ") ")
9998 gnus-article-save-directory
9999 (concat gnus-article-save-directory (car split-name))))
10001 (setq split-name (mapcar (lambda (el) (list el))
10002 (nreverse split-name)))
10003 (let ((result (completing-read
10004 (concat prompt " ")
10005 split-name nil nil)))
10006 (concat gnus-article-save-directory
10007 (if (string= result "")
10008 (car (car split-name))
10011 (defun gnus-summary-save-in-rmail (&optional filename)
10012 "Append this article to Rmail file.
10013 Optional argument FILENAME specifies file name.
10014 Directory to save to is default to `gnus-article-save-directory' which
10015 is initialized from the SAVEDIR environment variable."
10017 (let ((default-name
10018 (funcall gnus-rmail-save-name gnus-newsgroup-name
10019 gnus-current-headers gnus-newsgroup-last-rmail)))
10021 (setq filename (gnus-read-save-file-name
10022 "Save in rmail file:" default-name)))
10023 (gnus-make-directory (file-name-directory filename))
10024 (gnus-eval-in-buffer-window
10025 gnus-article-buffer
10029 (gnus-output-to-rmail filename))))
10030 ;; Remember the directory name to save articles
10031 (setq gnus-newsgroup-last-rmail filename)))
10033 (defun gnus-summary-save-in-mail (&optional filename)
10034 "Append this article to Unix mail file.
10035 Optional argument FILENAME specifies file name.
10036 Directory to save to is default to `gnus-article-save-directory' which
10037 is initialized from the SAVEDIR environment variable."
10039 (let ((default-name
10040 (funcall gnus-mail-save-name gnus-newsgroup-name
10041 gnus-current-headers gnus-newsgroup-last-mail)))
10043 (setq filename (gnus-read-save-file-name
10044 "Save in Unix mail file:" default-name)))
10046 (expand-file-name filename
10048 (file-name-directory default-name))))
10049 (gnus-make-directory (file-name-directory filename))
10050 (gnus-eval-in-buffer-window
10051 gnus-article-buffer
10055 (if (and (file-readable-p filename) (rmail-file-p filename))
10056 (gnus-output-to-rmail filename)
10057 (rmail-output filename 1 t t)))))
10058 ;; Remember the directory name to save articles.
10059 (setq gnus-newsgroup-last-mail filename)))
10061 (defun gnus-summary-save-in-file (&optional filename)
10062 "Append this article to file.
10063 Optional argument FILENAME specifies file name.
10064 Directory to save to is default to `gnus-article-save-directory' which
10065 is initialized from the SAVEDIR environment variable."
10067 (let ((default-name
10068 (funcall gnus-file-save-name gnus-newsgroup-name
10069 gnus-current-headers gnus-newsgroup-last-file)))
10071 (setq filename (gnus-read-save-file-name
10072 "Save in file:" default-name)))
10073 (gnus-make-directory (file-name-directory filename))
10074 (gnus-eval-in-buffer-window
10075 gnus-article-buffer
10079 (gnus-output-to-file filename))))
10080 ;; Remember the directory name to save articles.
10081 (setq gnus-newsgroup-last-file filename)))
10083 (defun gnus-summary-save-in-pipe (&optional command)
10084 "Pipe this article to subprocess."
10086 (let ((command (read-string "Shell command on article: "
10087 gnus-last-shell-command)))
10088 (if (string-equal command "")
10089 (setq command gnus-last-shell-command))
10090 (gnus-eval-in-buffer-window
10091 gnus-article-buffer
10094 (shell-command-on-region (point-min) (point-max) command nil)))
10095 (setq gnus-last-shell-command command)))
10097 ;; Summary extract commands
10099 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10100 (let ((buffer-read-only nil)
10101 (article (gnus-summary-article-number))
10103 (or (gnus-summary-goto-subject article)
10104 (error (format "No such article: %d" article)))
10105 (or gnus-newsgroup-headers-hashtb-by-number
10106 (gnus-make-headers-hashtable-by-number))
10107 (gnus-summary-position-cursor)
10108 ;; If all commands are to be bunched up on one line, we collect
10110 (if gnus-view-pseudos-separately
10112 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10115 (setq action (cdr (assq 'action (car ps))))
10116 (setq files (list (cdr (assq 'name (car ps)))))
10117 (while (and ps (cdr ps)
10118 (string= (or action "1")
10119 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10120 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10121 (setcdr ps (cdr (cdr ps))))
10124 (if (not (string-match "%s" action))
10125 (setq files (cons " " files)))
10126 (setq files (cons " " files))
10127 (and (assq 'execute (car ps))
10128 (setcdr (assq 'execute (car ps))
10129 (funcall (if (string-match "%s" action)
10132 (mapconcat (lambda (f) f) files " ")))))
10133 (setq ps (cdr ps)))))
10134 (if (and gnus-view-pseudos (not not-view))
10136 (and (assq 'execute (car pslist))
10137 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10138 (eq gnus-view-pseudos 'not-confirm)))
10139 (setq pslist (cdr pslist)))
10142 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10143 (gnus-summary-article-number)))
10146 (insert " " (file-name-nondirectory
10147 (cdr (assq 'name (car pslist))))
10148 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10149 (add-text-properties
10150 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10151 'gnus-mark gnus-unread-mark
10153 'gnus-pseudo (car pslist)))
10155 (gnus-sethash (int-to-string gnus-reffed-article-number)
10156 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10157 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10158 (setq pslist (cdr pslist)))))))
10160 (defun gnus-pseudos< (p1 p2)
10161 (let ((c1 (cdr (assq 'action p1)))
10162 (c2 (cdr (assq 'action p2))))
10163 (and c1 c2 (string< c1 c2))))
10165 (defun gnus-request-pseudo-article (props)
10166 (cond ((assq 'execute props)
10167 (gnus-execute-command (cdr (assq 'execute props)))))
10168 (let ((gnus-current-article (gnus-summary-article-number)))
10169 (run-hooks 'gnus-mark-article-hook)))
10171 (defun gnus-execute-command (command &optional automatic)
10173 (gnus-article-setup-buffer)
10174 (set-buffer gnus-article-buffer)
10175 (let ((command (if automatic command (read-string "Command: " command)))
10176 (buffer-read-only nil))
10178 (insert "$ " command "\n\n")
10179 (if gnus-view-pseudo-asynchronously
10180 (start-process "gnus-execute" nil "sh" "-c" command)
10181 (call-process "sh" nil t nil "-c" command)))))
10183 (defun gnus-copy-file (file &optional to)
10186 (list (read-file-name "Copy file: " default-directory)
10187 (read-file-name "Copy file to: " default-directory)))
10188 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10189 (and (file-directory-p to)
10190 (setq to (concat (file-name-as-directory to)
10191 (file-name-nondirectory file))))
10192 (copy-file file to))
10194 ;; Summary kill commands.
10196 (defun gnus-summary-edit-global-kill (article)
10197 "Edit the \"global\" kill file."
10198 (interactive (list (gnus-summary-article-number)))
10199 (gnus-group-edit-global-kill article))
10201 (defun gnus-summary-edit-local-kill ()
10202 "Edit a local kill file applied to the current newsgroup."
10204 (setq gnus-current-headers
10206 (int-to-string (gnus-summary-article-number))
10207 gnus-newsgroup-headers-hashtb-by-number))
10208 (gnus-set-global-variables)
10209 (gnus-group-edit-local-kill
10210 (gnus-summary-article-number) gnus-newsgroup-name))
10214 ;;; Gnus article mode
10217 (put 'gnus-article-mode 'mode-class 'special)
10219 (if gnus-article-mode-map
10221 (setq gnus-article-mode-map (make-keymap))
10222 (suppress-keymap gnus-article-mode-map)
10223 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10224 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10225 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10226 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10227 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10228 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10229 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10230 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10231 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10232 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10233 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10234 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10236 ;; Duplicate almost all summary keystrokes in the article mode map.
10239 " " "\177" "p" "N" "P" "\M-\C-n" "\M-\C-p"
10240 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j" "^" "\M-^"
10241 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10242 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10243 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10244 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10245 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10246 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10247 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10248 "\C-c\C-i" "x" "X" "s" "t" "g" "?" "l"
10249 "\C-c\C-v\C-v" "\C-d" "v"
10250 ;; "Mt" "M!" "Md" "Mr"
10251 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10252 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10253 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10254 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10255 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10256 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10257 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10258 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10259 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10260 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10261 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10264 (define-key gnus-article-mode-map (car commands)
10265 'gnus-article-summary-command)
10266 (setq commands (cdr commands))))
10268 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10269 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10272 (define-key gnus-article-mode-map (car commands)
10273 'gnus-article-summary-command-nosave)
10274 (setq commands (cdr commands)))))
10277 (defun gnus-article-mode ()
10278 "Major mode for displaying an article.
10280 All normal editing commands are switched off.
10282 The following commands are available:
10284 \\<gnus-article-mode-map>
10285 \\[gnus-article-next-page]\t Scroll the article one page forwards
10286 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10287 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10288 \\[gnus-article-show-summary]\t Display the summary buffer
10289 \\[gnus-article-mail]\t Send a reply to the address near point
10290 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10291 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10292 \\[gnus-info-find-node]\t Go to the Gnus info node"
10294 (if gnus-visual (gnus-article-make-menu-bar))
10295 (kill-all-local-variables)
10296 (setq mode-line-modified "-- ")
10297 (make-local-variable 'mode-line-format)
10298 (setq mode-line-format (copy-sequence mode-line-format))
10299 (and (equal (nth 3 mode-line-format) " ")
10300 (setcar (nthcdr 3 mode-line-format) ""))
10301 (setq mode-name "Article")
10302 (setq major-mode 'gnus-article-mode)
10303 (make-local-variable 'minor-mode-alist)
10304 (or (assq 'gnus-show-mime minor-mode-alist)
10305 (setq minor-mode-alist
10306 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10307 (use-local-map gnus-article-mode-map)
10308 (make-local-variable 'page-delimiter)
10309 (setq page-delimiter gnus-page-delimiter)
10310 (buffer-disable-undo (current-buffer))
10311 (setq buffer-read-only t) ;Disable modification
10312 (run-hooks 'gnus-article-mode-hook))
10314 (defun gnus-article-setup-buffer ()
10315 "Initialize article mode buffer."
10316 (if (get-buffer gnus-article-buffer)
10318 (set-buffer gnus-article-buffer)
10319 (buffer-disable-undo (current-buffer))
10320 (setq buffer-read-only t)
10321 (gnus-add-current-to-buffer-list)
10322 (or (eq major-mode 'gnus-article-mode)
10323 (gnus-article-mode)))
10325 (set-buffer (get-buffer-create gnus-article-buffer))
10326 (gnus-add-current-to-buffer-list)
10327 (gnus-article-mode))))
10329 ;; Set article window start at LINE, where LINE is the number of lines
10330 ;; from the head of the article.
10331 (defun gnus-article-set-window-start (&optional line)
10333 (get-buffer-window gnus-article-buffer)
10335 (set-buffer gnus-article-buffer)
10336 (goto-char (point-min))
10339 (gnus-message 6 "Moved to bookmark")
10340 (search-forward "\n\n" nil t)
10341 (forward-line line)
10344 (defun gnus-request-article-this-buffer (article group)
10345 "Get an article and insert it into this buffer."
10346 (setq group (or group gnus-newsgroup-name))
10348 ;; Open server if it has closed.
10349 (gnus-check-news-server (gnus-find-method-for-group group))
10351 ;; Using `gnus-request-article' directly will insert the article into
10352 ;; `nntp-server-buffer' - so we'll save some time by not having to
10353 ;; copy it from the server buffer into the article buffer.
10355 ;; We only request an article by message-id when we do not have the
10356 ;; headers for it, so we'll have to get those.
10357 (and (stringp article)
10358 (let ((gnus-override-method gnus-refer-article-method))
10359 (gnus-read-header article)))
10361 ;; If the article number is negative, that means that this article
10362 ;; doesn't belong in this newsgroup (possibly), so we find its
10363 ;; message-id and request it by id instead of number.
10364 (if (not (numberp article))
10367 (set-buffer gnus-summary-buffer)
10368 (let ((header (gnus-get-header-by-num article)))
10370 (if (vectorp header)
10371 ;; It's a real article.
10372 (setq article (header-id header))
10373 ;; It is an extracted pseudo-article.
10374 (setq article 'pseudo)
10375 (gnus-request-pseudo-article header)))
10377 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10378 (if (not (eq (car method) 'nneething))
10380 (let ((dir (concat (file-name-as-directory (nth 1 method))
10381 (header-subject header))))
10382 (if (file-directory-p dir)
10384 (setq article 'nneething)
10385 (gnus-group-enter-directory dir)))))))))
10387 ;; Check the cache.
10388 (if (and gnus-use-cache
10390 (gnus-cache-request-article article group))
10392 ;; Get the article and into the article buffer.
10393 (if (or (stringp article) (numberp article))
10396 (let ((gnus-override-method
10397 (and (stringp article) gnus-refer-article-method)))
10398 (and (gnus-request-article article group (current-buffer))
10402 (defun gnus-read-header (id)
10403 "Read the headers of article ID and enter them into the Gnus system."
10404 (or gnus-newsgroup-headers-hashtb-by-number
10405 (gnus-make-headers-hashtable-by-number))
10407 (if (not (setq header
10408 (car (if (let ((gnus-nov-is-evil t))
10409 (gnus-retrieve-headers
10410 (list id) gnus-newsgroup-name))
10411 (gnus-get-newsgroup-headers)))))
10414 (header-set-number header gnus-reffed-article-number))
10415 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10416 (gnus-sethash (int-to-string (header-number header)) header
10417 gnus-newsgroup-headers-hashtb-by-number)
10419 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10420 (setq gnus-current-headers header)
10423 (defun gnus-article-prepare (article &optional all-headers header)
10424 "Prepare ARTICLE in article mode buffer.
10425 ARTICLE should either be an article number or a Message-ID.
10426 If ARTICLE is an id, HEADER should be the article headers.
10427 If ALL-HEADERS is non-nil, no headers are hidden."
10429 ;; Make sure we start in a summary buffer.
10430 (or (eq major-mode 'gnus-summary-mode)
10431 (set-buffer gnus-summary-buffer))
10432 (setq gnus-summary-buffer (current-buffer))
10433 ;; Make sure the connection to the server is alive.
10434 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10436 (gnus-check-news-server
10437 (gnus-find-method-for-group gnus-newsgroup-name))
10438 (gnus-request-group gnus-newsgroup-name t)))
10439 (or gnus-newsgroup-headers-hashtb-by-number
10440 (gnus-make-headers-hashtable-by-number))
10441 (let* ((article (if header (header-number header) article))
10442 (summary-buffer (current-buffer))
10443 (internal-hook gnus-article-internal-prepare-hook)
10444 (group gnus-newsgroup-name)
10447 (gnus-article-setup-buffer)
10448 (set-buffer gnus-article-buffer)
10449 (if (not (setq result (let ((buffer-read-only nil))
10450 (gnus-request-article-this-buffer
10452 ;; There is no such article.
10454 (if (not (numberp article))
10456 (setq gnus-article-current
10457 (cons gnus-newsgroup-name article))
10458 (set-buffer gnus-summary-buffer)
10459 (setq gnus-current-article article)
10460 (gnus-summary-mark-article article gnus-canceled-mark))
10461 (gnus-message 1 "No such article (may be canceled)")
10464 (if (or (eq result 'pseudo) (eq result 'nneething))
10467 (set-buffer summary-buffer)
10468 (setq gnus-last-article gnus-current-article
10469 gnus-newsgroup-history (cons gnus-current-article
10470 gnus-newsgroup-history)
10471 gnus-current-article 0
10472 gnus-current-headers nil
10473 gnus-article-current nil)
10474 (if (eq result 'nneething)
10475 (gnus-configure-windows 'summary)
10476 (gnus-configure-windows 'article))
10477 (gnus-set-global-variables))
10478 (gnus-set-mode-line 'article))
10479 ;; The result from the `request' was an actual article -
10480 ;; or at least some text that is now displayed in the
10482 (if (and (numberp article)
10483 (not (eq article gnus-current-article)))
10484 ;; Seems like a new article has been selected.
10485 ;; `gnus-current-article' must be an article number.
10487 (set-buffer summary-buffer)
10488 (setq gnus-last-article gnus-current-article
10489 gnus-newsgroup-history (cons gnus-current-article
10490 gnus-newsgroup-history)
10491 gnus-current-article article
10492 gnus-current-headers
10493 (gnus-get-header-by-num gnus-current-article)
10494 gnus-article-current
10495 (cons gnus-newsgroup-name gnus-current-article))
10496 (gnus-summary-show-thread)
10497 (run-hooks 'gnus-mark-article-hook)
10498 (gnus-set-mode-line 'summary)
10500 (run-hooks 'gnus-visual-mark-article-hook))
10501 ;; Set the global newsgroup variables here.
10502 ;; Suggested by Jim Sisolak
10503 ;; <sisolak@trans4.neep.wisc.edu>.
10504 (gnus-set-global-variables)
10505 (setq gnus-have-all-headers
10506 (or all-headers gnus-show-all-headers))
10507 (and gnus-use-cache
10508 (gnus-cache-possibly-enter-article
10510 (gnus-get-header-by-number article)
10511 (memq article gnus-newsgroup-marked)
10512 (memq article gnus-newsgroup-dormant)
10513 (memq article gnus-newsgroup-unreads)))))
10514 ;; Hooks for getting information from the article.
10515 ;; This hook must be called before being narrowed.
10516 (let (buffer-read-only)
10517 (run-hooks 'internal-hook)
10518 (run-hooks 'gnus-article-prepare-hook)
10519 ;; Decode MIME message.
10520 (if (and gnus-show-mime
10521 (or (not gnus-strict-mime)
10522 (gnus-fetch-field "Mime-Version")))
10523 (funcall gnus-show-mime-method))
10524 ;; Perform the article display hooks.
10525 (run-hooks 'gnus-article-display-hook))
10527 (goto-char (point-min))
10528 (and gnus-break-pages (gnus-narrow-to-page))
10529 (gnus-set-mode-line 'article)
10530 (gnus-configure-windows 'article)
10531 (goto-char (point-min))
10534 (defun gnus-article-show-all-headers ()
10535 "Show all article headers in article mode buffer."
10537 (gnus-article-setup-buffer)
10538 (set-buffer gnus-article-buffer)
10539 (let ((buffer-read-only nil))
10540 (remove-text-properties (point-min) (point-max)
10541 gnus-hidden-properties))))
10543 (defun gnus-article-hide-headers-if-wanted ()
10544 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10545 Provided for backwards compatability."
10546 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10547 (gnus-article-hide-headers)))
10549 (defun gnus-article-hide-headers (&optional delete)
10550 "Hide unwanted headers and possibly sort them as well."
10553 (set-buffer gnus-article-buffer)
10555 (let ((sorted gnus-sorted-header-list)
10556 (buffer-read-only nil)
10557 want-list beg want-l)
10558 ;; First we narrow to just the headers.
10560 (goto-char (point-min))
10561 ;; Hide any "From " lines at the beginning of (mail) articles.
10562 (while (looking-at "From ")
10565 (add-text-properties (point-min) (point) gnus-hidden-properties))
10566 ;; Then treat the rest of the header lines.
10569 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10570 ;; Then we use the two regular expressions
10571 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10572 ;; select which header lines is to remain visible in the
10574 (goto-char (point-min))
10575 (while (re-search-forward "^[^ \t]*:" nil t)
10576 (beginning-of-line)
10577 ;; We add the headers we want to keep to a list and delete
10578 ;; them from the buffer.
10579 (if (or (and (stringp gnus-visible-headers)
10580 (looking-at gnus-visible-headers))
10581 (and (not (stringp gnus-visible-headers))
10582 (stringp gnus-ignored-headers)
10583 (not (looking-at gnus-ignored-headers))))
10587 ;; Be sure to get multi-line headers...
10588 (re-search-forward "^[^ \t]*:" nil t)
10589 (beginning-of-line)
10591 (cons (buffer-substring beg (point)) want-list))
10592 (delete-region beg (point))
10595 ;; Next we perform the sorting by looking at
10596 ;; `gnus-sorted-header-list'.
10597 (goto-char (point-min))
10598 (while (and sorted want-list)
10599 (setq want-l want-list)
10601 (not (string-match (car sorted) (car want-l))))
10602 (setq want-l (cdr want-l)))
10605 (insert (car want-l))
10606 (setq want-list (delq (car want-l) want-list))))
10607 (setq sorted (cdr sorted)))
10608 ;; Any headers that were not matched by the sorted list we
10609 ;; just tack on the end of the visible header list.
10611 (insert (car want-list))
10612 (setq want-list (cdr want-list)))
10613 ;; And finally we make the unwanted headers invisible.
10615 (delete-region (point) (point-max))
10616 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10617 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10619 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10620 (defun gnus-article-treat-overstrike ()
10621 "Translate overstrikes into bold text."
10624 (set-buffer gnus-article-buffer)
10625 (let ((buffer-read-only nil))
10626 (while (search-forward "\b" nil t)
10627 (let ((next (following-char))
10628 (previous (char-after (- (point) 2))))
10629 (cond ((eq next previous)
10630 (delete-region (- (point) 2) (point))
10631 (put-text-property (point) (1+ (point))
10634 (delete-region (1- (point)) (1+ (point)))
10635 (put-text-property (1- (point)) (point)
10638 (delete-region (- (point) 2) (point))
10639 (put-text-property (point) (1+ (point))
10640 'face 'underline))))))))
10642 (defun gnus-article-word-wrap ()
10643 "Format too long lines."
10646 (set-buffer gnus-article-buffer)
10647 (let ((buffer-read-only nil))
10648 (goto-char (point-min))
10649 (search-forward "\n\n" nil t)
10651 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
10652 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
10653 (adaptive-fill-mode t))
10654 (while (not (eobp))
10655 (and (>= (current-column) (min fill-column (window-width)))
10656 (/= (preceding-char) ?:)
10657 (fill-paragraph nil))
10658 (end-of-line 2))))))
10660 (defun gnus-article-remove-cr ()
10661 "Remove carriage returns from an article."
10664 (set-buffer gnus-article-buffer)
10665 (let ((buffer-read-only nil))
10666 (goto-char (point-min))
10667 (while (search-forward "\r" nil t)
10668 (replace-match "" t t)))))
10670 (defun gnus-article-display-x-face (&optional force)
10671 "Look for an X-Face header and display it if present."
10672 (interactive (list 'force))
10674 (set-buffer gnus-article-buffer)
10675 (let ((inhibit-point-motion-hooks t)
10676 (case-fold-search nil))
10678 (goto-char (point-min))
10679 (search-forward "\n\n")
10680 (narrow-to-region (point-min) (point))
10681 (goto-char (point-min))
10682 (if (or (not gnus-article-x-face-command)
10684 (or (not gnus-article-x-face-too-ugly)
10685 (string-match gnus-article-x-face-too-ugly
10686 (mail-fetch-field "from"))))
10688 (goto-char (point-min))
10689 (not (re-search-forward "^X-Face: " nil t))))
10691 (let ((beg (point))
10692 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
10693 (if (symbolp gnus-article-x-face-command)
10694 (and (or (fboundp gnus-article-x-face-command)
10695 (error "%s is not a function"
10696 gnus-article-x-face-command))
10697 (funcall gnus-article-x-face-command beg end))
10698 (call-process-region beg end "sh" nil 0 nil
10699 "-c" gnus-article-x-face-command))))))))
10701 (defun gnus-article-de-quoted-unreadable (&optional force)
10702 "Do a naïve translation of a quoted-printable-encoded article.
10703 This is in no way, shape or form meant as a replacement for real MIME
10704 processing, but is simply a stop-gap measure until MIME support is
10706 If FORCE, decode the article whether it is marked as quoted-printable
10708 (interactive (list 'force))
10710 (set-buffer gnus-article-buffer)
10711 (let ((case-fold-search t)
10712 (buffer-read-only nil)
10713 (type (gnus-fetch-field "content-transfer-encoding")))
10714 (if (or force (and type (string-match "quoted-printable" type)))
10716 (goto-char (point-min))
10717 (search-forward "\n\n" nil 'move)
10718 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
10720 (defun gnus-mime-decode-quoted-printable (from to)
10721 ;; Decode quoted-printable from region between FROM and TO.
10724 (while (search-forward "=" to t)
10725 (cond ((eq (following-char) ?\n)
10728 ((looking-at "[0-9A-F][0-9A-F]")
10730 (insert (hexl-hex-string-to-integer
10731 (buffer-substring (point) (+ 2 (point)))))
10733 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
10735 (defvar gnus-article-time-units
10736 (list (cons 'year (* 365.25 24 60 60))
10737 (cons 'week (* 7 24 60 60))
10738 (cons 'day (* 24 60 60))
10739 (cons 'hour (* 60 60))
10743 (defun gnus-article-date-ut (&optional type)
10744 "Convert DATE date to universal time in the current article.
10745 If TYPE is `local', convert to local time; if it is `lapsed', output
10746 how much time has lapsed since DATE."
10747 (interactive (list 'ut))
10748 (let ((date (header-date (or gnus-current-headers
10749 (gnus-get-header-by-number
10750 (gnus-summary-article-number))"")))
10751 (date-regexp "^Date: \\|^X-Sent: "))
10756 (set-buffer gnus-article-buffer)
10757 (let ((buffer-read-only nil))
10758 (goto-char (point-min))
10759 (if (and (re-search-forward date-regexp nil t)
10761 (beginning-of-line)
10762 (looking-at date-regexp)))
10763 (delete-region (gnus-point-at-bol)
10764 (progn (end-of-line) (1+ (point))))
10765 (goto-char (point-min))
10766 (goto-char (- (search-forward "\n\n") 2)))
10770 (concat "Date: " (condition-case ()
10771 (timezone-make-date-arpa-standard date)
10777 (timezone-make-date-arpa-standard date nil "UT")
10781 ;; If the date is seriously mangled, the timezone
10782 ;; functions are liable to bug out, so we condition-case
10783 ;; the entire thing.
10784 (let* ((sec (condition-case ()
10785 (max (- (gnus-seconds-since-epoch
10786 (timezone-make-date-arpa-standard
10787 (current-time-string)
10788 (current-time-zone) "UT"))
10789 (gnus-seconds-since-epoch
10790 (timezone-make-date-arpa-standard
10799 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
10801 (setq sec (- sec (* num (cdr unit))))
10803 (concat (if prev ", " "") (int-to-string (floor num))
10804 " " (symbol-name (car unit))
10805 (if (> num 1) "s" ""))
10807 gnus-article-time-units "")
10810 (error "Unknown conversion type: %s" type)))))))))
10812 (defun gnus-article-date-local ()
10813 "Convert the current article date to the local timezone."
10815 (gnus-article-date-ut 'local))
10817 (defun gnus-article-date-lapsed ()
10818 "Convert the current article date to time lapsed since it was sent."
10820 (gnus-article-date-ut 'lapsed))
10822 (defun gnus-article-maybe-highlight ()
10823 (if gnus-visual (gnus-article-highlight)))
10827 (defun gnus-output-to-rmail (file-name)
10828 "Append the current article to an Rmail file named FILE-NAME."
10830 ;; Most of these codes are borrowed from rmailout.el.
10831 (setq file-name (expand-file-name file-name))
10832 (setq rmail-default-rmail-file file-name)
10833 (let ((artbuf (current-buffer))
10834 (tmpbuf (get-buffer-create " *Gnus-output*")))
10836 (or (get-file-buffer file-name)
10837 (file-exists-p file-name)
10838 (if (gnus-yes-or-no-p
10839 (concat "\"" file-name "\" does not exist, create it? "))
10840 (let ((file-buffer (create-file-buffer file-name)))
10842 (set-buffer file-buffer)
10843 (rmail-insert-rmail-file-header)
10844 (let ((require-final-newline nil))
10845 (write-region (point-min) (point-max) file-name t 1)))
10846 (kill-buffer file-buffer))
10847 (error "Output file does not exist")))
10848 (set-buffer tmpbuf)
10849 (buffer-disable-undo (current-buffer))
10851 (insert-buffer-substring artbuf)
10852 (gnus-convert-article-to-rmail)
10853 ;; Decide whether to append to a file or to an Emacs buffer.
10854 (let ((outbuf (get-file-buffer file-name)))
10856 (append-to-file (point-min) (point-max) file-name)
10857 ;; File has been visited, in buffer OUTBUF.
10858 (set-buffer outbuf)
10859 (let ((buffer-read-only nil)
10860 (msg (and (boundp 'rmail-current-message)
10861 (symbol-value 'rmail-current-message))))
10862 ;; If MSG is non-nil, buffer is in RMAIL mode.
10865 (narrow-to-region (point-max) (point-max))))
10866 (insert-buffer-substring tmpbuf)
10869 (goto-char (point-min))
10871 (search-backward "\^_")
10872 (narrow-to-region (point) (point-max))
10873 (goto-char (1+ (point-min)))
10874 (rmail-count-new-messages t)
10875 (rmail-show-message msg)))))))
10876 (kill-buffer tmpbuf)))
10878 (defun gnus-output-to-file (file-name)
10879 "Append the current article to a file named FILE-NAME."
10880 (setq file-name (expand-file-name file-name))
10881 (let ((artbuf (current-buffer))
10882 (tmpbuf (get-buffer-create " *Gnus-output*")))
10884 (set-buffer tmpbuf)
10885 (buffer-disable-undo (current-buffer))
10887 (insert-buffer-substring artbuf)
10888 ;; Append newline at end of the buffer as separator, and then
10889 ;; save it to file.
10890 (goto-char (point-max))
10892 (append-to-file (point-min) (point-max) file-name))
10893 (kill-buffer tmpbuf)))
10895 (defun gnus-convert-article-to-rmail ()
10896 "Convert article in current buffer to Rmail message format."
10897 (let ((buffer-read-only nil))
10898 ;; Convert article directly into Babyl format.
10899 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10900 (goto-char (point-min))
10901 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10902 (while (search-forward "\n\^_" nil t) ;single char
10903 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10904 (goto-char (point-max))
10907 (defun gnus-narrow-to-page (&optional arg)
10908 "Make text outside current page invisible except for page delimiter.
10909 A numeric arg specifies to move forward or backward by that many pages,
10910 thus showing a page other than the one point was originally in."
10912 (setq arg (if arg (prefix-numeric-value arg) 0))
10914 (forward-page -1) ;Beginning of current page.
10919 (forward-page (1- arg))))
10920 ;; Find the end of the page.
10922 ;; If we stopped due to end of buffer, stay there.
10923 ;; If we stopped after a page delimiter, put end of restriction
10924 ;; at the beginning of that line.
10925 ;; These are commented out.
10926 ;; (if (save-excursion (beginning-of-line)
10927 ;; (looking-at page-delimiter))
10928 ;; (beginning-of-line))
10929 (narrow-to-region (point)
10931 ;; Find the top of the page.
10933 ;; If we found beginning of buffer, stay there.
10934 ;; If extra text follows page delimiter on same line,
10936 ;; Otherwise, show text starting with following line.
10937 (if (and (eolp) (not (bobp)))
10941 (defun gnus-gmt-to-local ()
10942 "Rewrite Date header described in GMT to local in current buffer.
10943 Intended to be used with gnus-article-prepare-hook."
10947 (goto-char (point-min))
10948 (narrow-to-region (point-min)
10949 (progn (search-forward "\n\n" nil 'move) (point)))
10950 (goto-char (point-min))
10951 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10952 (let ((buffer-read-only nil)
10953 (date (buffer-substring-no-properties
10954 (match-beginning 1) (match-end 1))))
10955 (delete-region (match-beginning 1) (match-end 1))
10957 (timezone-make-date-arpa-standard
10958 date nil (current-time-zone))))))))
10961 ;; Article mode commands
10963 (defun gnus-article-next-page (lines)
10964 "Show next page of current article.
10965 If end of article, return non-nil. Otherwise return nil.
10966 Argument LINES specifies lines to be scrolled up."
10968 (move-to-window-line -1)
10969 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10970 (if (save-excursion
10972 (and (pos-visible-in-window-p) ;Not continuation line.
10974 ;; Nothing in this page.
10975 (if (or (not gnus-break-pages)
10978 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10980 (gnus-narrow-to-page 1) ;Go to next page.
10982 ;; More in this page.
10986 ;; Long lines may cause an end-of-buffer error.
10987 (goto-char (point-max))))
10990 (defun gnus-article-prev-page (lines)
10991 "Show previous page of current article.
10992 Argument LINES specifies lines to be scrolled down."
10994 (move-to-window-line 0)
10995 (if (and gnus-break-pages
10997 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10999 (gnus-narrow-to-page -1) ;Go to previous page.
11000 (goto-char (point-max))
11002 (scroll-down lines)))
11004 (defun gnus-article-refer-article ()
11005 "Read article specified by message-id around point."
11007 (search-forward ">" nil t) ;Move point to end of "<....>".
11008 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11010 (buffer-substring (match-beginning 1) (match-end 1))))
11011 (set-buffer gnus-summary-buffer)
11012 (gnus-summary-refer-article message-id))
11013 (error "No references around point")))
11015 (defun gnus-article-show-summary ()
11016 "Reconfigure windows to show summary buffer."
11018 (gnus-configure-windows 'article)
11019 (gnus-summary-goto-subject gnus-current-article))
11021 (defun gnus-article-describe-briefly ()
11022 "Describe article mode commands briefly."
11025 (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")))
11027 (defun gnus-article-summary-command ()
11028 "Execute the last keystroke in the summary buffer."
11030 (let ((obuf (current-buffer))
11031 (owin (current-window-configuration))
11033 (switch-to-buffer gnus-summary-buffer 'norecord)
11034 (setq func (lookup-key (current-local-map) (this-command-keys)))
11035 (call-interactively func)
11037 (set-window-configuration owin)
11038 (set-window-start (get-buffer-window (current-buffer)) (point))))
11040 (defun gnus-article-summary-command-nosave ()
11041 "Execute the last keystroke in the summary buffer."
11044 (pop-to-buffer gnus-summary-buffer 'norecord)
11045 (setq func (lookup-key (current-local-map) (this-command-keys)))
11046 (call-interactively func)))
11049 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11052 (defalias 'gnus-batch-kill 'gnus-batch-score)
11054 (defun gnus-batch-score ()
11055 "Run batched scoring.
11056 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11057 Newsgroups is a list of strings in Bnews format. If you want to score
11058 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11059 score the alt hierarchy, you'd say \"!alt.all\"."
11062 (gnus-newsrc-parse-options
11063 (apply (function concat)
11064 (mapcar (lambda (g) (concat g " "))
11065 command-line-args-left))))
11066 (gnus-expert-user t)
11067 (nnmail-spool-file nil)
11068 (gnus-use-dribble-file nil)
11069 (yes (car yes-and-no))
11070 (no (cdr yes-and-no))
11072 ;; Disable verbose message.
11073 gnus-novice-user gnus-large-newsgroup)
11074 ;; Eat all arguments.
11075 (setq command-line-args-left nil)
11078 ;; Apply kills to specified newsgroups in command line arguments.
11079 (setq newsrc (cdr gnus-newsrc-alist))
11081 (setq group (car (car newsrc)))
11082 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11083 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11085 (or (eq (car entry) t)
11086 (not (zerop (car entry)))))
11087 (if yes (string-match yes group) t)
11088 (or (null no) (not (string-match no group))))
11090 (gnus-summary-read-group group nil t)
11091 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11092 (gnus-summary-exit))))
11093 (setq newsrc (cdr newsrc)))
11095 (switch-to-buffer gnus-group-buffer)
11096 (gnus-group-save-newsrc)))
11098 (defun gnus-apply-kill-file ()
11099 "Apply a kill file to the current newsgroup.
11100 Returns the number of articles marked as read."
11101 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11102 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11103 (gnus-apply-kill-file-internal)
11106 (defun gnus-kill-save-kill-buffer ()
11108 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11109 (if (get-file-buffer file)
11111 (set-buffer (get-file-buffer file))
11112 (and (buffer-modified-p) (save-buffer))
11113 (kill-buffer (current-buffer)))))))
11115 (defvar gnus-kill-file-name "KILL"
11116 "Suffix of the kill files.")
11118 (defun gnus-newsgroup-kill-file (newsgroup)
11119 "Return the name of a kill file name for NEWSGROUP.
11120 If NEWSGROUP is nil, return the global kill file name instead."
11121 (cond ((or (null newsgroup)
11122 (string-equal newsgroup ""))
11123 ;; The global KILL file is placed at top of the directory.
11124 (expand-file-name gnus-kill-file-name
11125 (or gnus-kill-files-directory "~/News")))
11126 ((gnus-use-long-file-name 'not-kill)
11127 ;; Append ".KILL" to newsgroup name.
11128 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
11129 (or gnus-kill-files-directory "~/News")))
11131 ;; Place "KILL" under the hierarchical directory.
11132 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11133 "/" gnus-kill-file-name)
11134 (or gnus-kill-files-directory "~/News")))))
11141 (defvar gnus-dribble-ignore nil)
11143 (defun gnus-dribble-file-name ()
11144 (concat gnus-startup-file "-dribble"))
11146 (defun gnus-dribble-open ()
11149 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
11150 (buffer-disable-undo (current-buffer))
11151 (bury-buffer gnus-dribble-buffer)
11153 (goto-char (point-max))))
11155 (defun gnus-dribble-enter (string)
11156 (if (and (not gnus-dribble-ignore)
11157 gnus-dribble-buffer
11158 (buffer-name gnus-dribble-buffer))
11159 (let ((obuf (current-buffer)))
11160 (set-buffer gnus-dribble-buffer)
11161 (insert string "\n")
11162 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11163 (set-buffer obuf))))
11165 (defun gnus-dribble-read-file ()
11166 (let ((dribble-file (gnus-dribble-file-name)))
11168 (set-buffer (setq gnus-dribble-buffer
11170 (file-name-nondirectory dribble-file))))
11171 (gnus-add-current-to-buffer-list)
11173 (set-visited-file-name dribble-file)
11174 (buffer-disable-undo (current-buffer))
11175 (bury-buffer (current-buffer))
11176 (set-buffer-modified-p nil)
11177 (let ((auto (make-auto-save-file-name))
11178 (gnus-dribble-ignore t))
11179 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11181 (if (file-newer-than-file-p auto dribble-file)
11182 (setq dribble-file auto))
11183 (insert-file-contents dribble-file)
11184 (if (not (zerop (buffer-size)))
11185 (set-buffer-modified-p t))
11187 "Auto-save file exists. Do you want to read it? ")
11189 (gnus-message 5 "Reading %s..." dribble-file)
11190 (eval-buffer (current-buffer))
11191 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
11193 (defun gnus-dribble-delete-file ()
11194 (if (file-exists-p (gnus-dribble-file-name))
11195 (delete-file (gnus-dribble-file-name)))
11196 (if gnus-dribble-buffer
11198 (set-buffer gnus-dribble-buffer)
11199 (let ((auto (make-auto-save-file-name)))
11200 (if (file-exists-p auto)
11201 (delete-file auto))
11203 (set-buffer-modified-p nil)))))
11205 (defun gnus-dribble-save ()
11206 (if (and gnus-dribble-buffer
11207 (buffer-name gnus-dribble-buffer))
11209 (set-buffer gnus-dribble-buffer)
11212 (defun gnus-dribble-clear ()
11214 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11216 (set-buffer gnus-dribble-buffer)
11218 (set-buffer-modified-p nil)
11219 (setq buffer-saved-size (buffer-size))))))
11222 ;;; Server Communication
11225 ;; All the Gnus backends have the same interface, and should return
11226 ;; data in a similar format. Below is an overview of what functions
11227 ;; these packages must supply and what results they should return.
11231 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11234 ;; Functions for the imaginary backend `choke':
11236 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11237 ;; Should return all headers for all ARTICLES, or return NOV lines for
11240 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11241 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11242 ;; must be returned.
11244 ;; `choke-close-group GROUP &optional SERVER'
11245 ;; Close group. Most backends won't have to do anything with this
11246 ;; call, but it is an opportunity to clean up, if that is needed. It
11247 ;; is called when Gnus exits a group.
11249 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11250 ;; Return ARTICLE, which is either an article number or
11251 ;; message-id. Note that not all backends can return articles based on
11254 ;; `choke-request-list SERVER'
11255 ;; Return a list of all newsgroups on SERVER.
11257 ;; `choke-request-list-newsgroups SERVER'
11258 ;; Return a list of descriptions of all newsgroups on SERVER.
11260 ;; `choke-request-newgroups DATE &optional SERVER'
11261 ;; Return a list of all groups that have arrived after DATE on
11262 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11263 ;; always check whether the groups are old or not. Backends that do
11264 ;; not store date information may just return the entire list of
11265 ;; groups, although this might not be a good idea in general.
11267 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11268 ;; Should return a buffer that is suitable for "posting". nnspool and
11269 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11270 ;; buffer. This function should fill out the appropriate headers.
11272 ;; `choke-request-post &optional SERVER'
11273 ;; Function that will be called from a buffer to be posted.
11275 ;; `choke-open-server SERVER &optional ARGUMENT'
11276 ;; Open a connection to SERVER.
11278 ;; `choke-close-server &optional SERVER'
11279 ;; Close the connection to SERVER.
11281 ;; `choke-server-opened &optional SERVER'
11282 ;; Whether the conenction to SERVER is opened or not.
11284 ;; `choke-server-status &optional SERVER'
11285 ;; Should return a status string (not in the nntp buffer, but as the
11286 ;; result of the function).
11288 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11289 ;; Optional function for retrieving active file info on all groups in
11290 ;; GROUPS. Two return formats are supported: The normal active file
11291 ;; format, and a list of GROUP lines. This function should return (as
11292 ;; a function value) either `active' or `group', depending on what
11293 ;; format it returns.
11295 ;; The following functions are optional and apply only to backends
11296 ;; that are able to control the contents of their groups totally
11297 ;; (ie. mail backends.) Backends that aren't able to do that
11298 ;; shouldn't define these functions at all. Gnus will check for their
11299 ;; presence before attempting to call them.
11301 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11302 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11303 ;; backends will not be able to expire articles. Should return a list
11304 ;; of all articles that were not expired.
11306 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11307 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11308 ;; Removes any information it has added to the article (extra headers,
11309 ;; whatever - make it as clean as possible), and then passes the
11310 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11311 ;; function described below. If the ACCEPT-FORM returns a non-nil
11312 ;; value, the article should then be deleted. If LAST is nil, that
11313 ;; means that there will be further calls to this function. This might
11314 ;; be taken as an advice not to save buffers/internal variables just
11315 ;; yet, but wait until the last call to speed things up.
11317 ;; `choke-request-accept-article GROUP &optional LAST'
11318 ;; The contents of the current buffer will be put into GROUP. There
11319 ;; should, of course, be an article in the current buffer. This
11320 ;; function is normally only called by the function described above,
11321 ;; and LAST works the same way as in that function.
11323 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11324 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11325 ;; This provides an easy interface for allowing editing of
11326 ;; articles. Note that even headers may be edited, so the backend has
11327 ;; to update any tables (nov buffers, etc) that it maintains after
11328 ;; replacing the article.
11330 ;; `choke-request-create-group GROUP &optional SERVER'
11331 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11332 ;; might be a group that already exists, but hasn't been registered
11335 ;; All these functions must return nil if they couldn't service the
11336 ;; request. If the optional arguments are not supplied, some "current"
11337 ;; or "default" values should be used. In short, one should emulate an
11338 ;; NNTP server, in a way.
11340 ;; If you want to write a new backend, you just have to supply the
11341 ;; functions listed above. In addition, you must enter the new backend
11342 ;; into the list of valid select methods:
11343 ;; (setq gnus-valid-select-methods
11344 ;; (cons '("choke" mail) gnus-valid-select-methods))
11345 ;; The first element in this list is the name of the backend. Other
11346 ;; elemnets may be `mail' (for mail groups), `post' (for news
11347 ;; groups), `none' (neither), `respool' (for groups that can control
11348 ;; their contents).
11350 (defun gnus-start-news-server (&optional confirm)
11351 "Open a method for getting news.
11352 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11354 (if gnus-current-select-method
11355 ;; Stream is already opened.
11357 ;; Open NNTP server.
11358 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11361 ;; Read server name with completion.
11362 (setq gnus-nntp-server
11363 (completing-read "NNTP server: "
11364 (mapcar (lambda (server) (list server))
11365 (cons (list gnus-nntp-server)
11366 gnus-secondary-servers))
11367 nil nil gnus-nntp-server))))
11369 (if (and gnus-nntp-server
11370 (stringp gnus-nntp-server)
11371 (not (string= gnus-nntp-server "")))
11372 (setq gnus-select-method
11373 (cond ((or (string= gnus-nntp-server "")
11374 (string= gnus-nntp-server "::"))
11375 (list 'nnspool (system-name)))
11376 ((string-match "^:" gnus-nntp-server)
11377 (list 'nnmh gnus-nntp-server
11378 (list 'nnmh-directory
11379 (file-name-as-directory
11381 (concat "~/" (substring
11382 gnus-nntp-server 1)))))
11383 (list 'nnmh-get-new-mail nil)))
11385 (list 'nntp gnus-nntp-server)))))
11387 (setq how (car gnus-select-method))
11388 (cond ((eq how 'nnspool)
11390 (gnus-message 5 "Looking up local news spool..."))
11393 (gnus-message 5 "Looking up mh spool..."))
11396 (setq gnus-current-select-method gnus-select-method)
11397 (run-hooks 'gnus-open-server-hook)
11399 ;; gnus-open-server-hook might have opened it
11400 (gnus-server-opened gnus-select-method)
11401 (gnus-open-server gnus-select-method)
11404 "%s server on %s can't be opened. Continue? "
11405 (car gnus-select-method) (nth 1 gnus-select-method)))
11407 (gnus-message 1 "Couldn't open server on %s"
11408 (nth 1 gnus-select-method))
11412 (defun gnus-check-news-server (&optional method)
11413 "If the news server is down, start it up again."
11414 (let ((method (if method method gnus-select-method)))
11415 (and (stringp method)
11416 (setq method (gnus-server-to-method method)))
11417 (if (gnus-server-opened method)
11418 ;; Stream is already opened.
11421 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11422 (run-hooks 'gnus-open-server-hook)
11423 (or (gnus-server-opened method)
11424 (gnus-open-server method))
11427 (defun gnus-nntp-message (&optional message)
11428 "Check the status of the NNTP server.
11429 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11430 is returned insted of the status string."
11431 (let ((status (gnus-status-message (gnus-find-method-for-group
11432 gnus-newsgroup-name)))
11433 (message (or message "")))
11434 (if (and (stringp status) (> (length status) 0))
11437 (defun gnus-get-function (method function)
11438 (and (stringp method)
11439 (setq method (gnus-server-to-method method)))
11440 (let ((func (intern (format "%s-%s" (car method) function))))
11441 (if (not (fboundp func))
11443 (require (car method))
11444 (if (not (fboundp func))
11445 (error "No such function: %s" func))))
11448 ;;; Interface functions to the backends.
11450 (defun gnus-open-server (method)
11451 (funcall (gnus-get-function method 'open-server)
11452 (nth 1 method) (nthcdr 2 method)))
11454 (defun gnus-close-server (method)
11455 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11457 (defun gnus-request-list (method)
11458 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11460 (defun gnus-request-list-newsgroups (method)
11461 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11463 (defun gnus-request-newgroups (date method)
11464 (funcall (gnus-get-function method 'request-newgroups)
11465 date (nth 1 method)))
11467 (defun gnus-server-opened (method)
11468 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11470 (defun gnus-status-message (method)
11471 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11473 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11475 (defun gnus-request-group (group &optional dont-check)
11476 (let ((method (gnus-find-method-for-group group)))
11477 ; (and t (message "%s GROUP %s" (car method) group))
11478 (funcall (gnus-get-function method 'request-group)
11479 (gnus-group-real-name group) (nth 1 method) dont-check)))
11481 (defun gnus-request-asynchronous (group &optional articles)
11482 (let ((method (gnus-find-method-for-group group)))
11483 (funcall (gnus-get-function method 'request-asynchronous)
11484 (gnus-group-real-name group) (nth 1 method) articles)))
11486 (defun gnus-list-active-group (group)
11487 (let ((method (gnus-find-method-for-group group))
11488 (func 'list-active-group))
11489 (and (gnus-check-backend-function func group)
11490 (funcall (gnus-get-function method func)
11491 (gnus-group-real-name group) (nth 1 method)))))
11493 (defun gnus-request-group-description (group)
11494 (let ((method (gnus-find-method-for-group group))
11495 (func 'request-group-description))
11496 (and (gnus-check-backend-function func group)
11497 (funcall (gnus-get-function method func)
11498 (gnus-group-real-name group) (nth 1 method)))))
11500 (defun gnus-close-group (group)
11501 (let ((method (gnus-find-method-for-group group)))
11502 (funcall (gnus-get-function method 'close-group)
11503 (gnus-group-real-name group) (nth 1 method))))
11505 (defun gnus-retrieve-headers (articles group)
11506 (let ((method (gnus-find-method-for-group group)))
11507 (if (and gnus-use-cache (numberp (car articles)))
11508 (gnus-cache-retrieve-headers articles group)
11509 (funcall (gnus-get-function method 'retrieve-headers)
11510 articles (gnus-group-real-name group) (nth 1 method)))))
11512 (defun gnus-retrieve-groups (groups method)
11513 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11515 (defun gnus-request-article (article group &optional buffer)
11516 (let ((method (gnus-find-method-for-group group)))
11517 (funcall (gnus-get-function method 'request-article)
11518 article (gnus-group-real-name group) (nth 1 method) buffer)))
11520 (defun gnus-request-head (article group)
11521 (let ((method (gnus-find-method-for-group group)))
11522 (funcall (gnus-get-function method 'request-head)
11523 article (gnus-group-real-name group) (nth 1 method))))
11525 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11526 (defun gnus-request-post-buffer (post group subject header artbuf
11527 info follow-to respect-poster)
11528 (let* ((info (or info (and group (nth 2 (gnus-gethash
11529 group gnus-newsrc-hashtb)))))
11531 (if (and gnus-post-method
11532 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11534 (format "%s" (car (gnus-find-method-for-group
11535 gnus-newsgroup-name)))
11536 gnus-valid-select-methods)))
11538 (gnus-find-method-for-group gnus-newsgroup-name))))
11539 (or (gnus-server-opened method)
11540 (gnus-open-server method)
11541 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11542 (let ((mail-self-blind nil)
11543 (mail-archive-file-name nil))
11544 (funcall (gnus-get-function method 'request-post-buffer)
11545 post group subject header artbuf info follow-to
11548 (defun gnus-request-post (method &optional force)
11549 (and (stringp method)
11550 (setq method (gnus-server-to-method method)))
11551 (and (not force) gnus-post-method
11552 (memq 'post (assoc (format "%s" (car method))
11553 gnus-valid-select-methods))
11554 (setq method gnus-post-method))
11555 (funcall (gnus-get-function method 'request-post)
11558 (defun gnus-request-expire-articles (articles group &optional force)
11559 (let ((method (gnus-find-method-for-group group)))
11560 (funcall (gnus-get-function method 'request-expire-articles)
11561 articles (gnus-group-real-name group) (nth 1 method)
11564 (defun gnus-request-move-article
11565 (article group server accept-function &optional last)
11566 (let ((method (gnus-find-method-for-group group)))
11567 (funcall (gnus-get-function method 'request-move-article)
11568 article (gnus-group-real-name group)
11569 (nth 1 method) accept-function last)))
11571 (defun gnus-request-accept-article (group &optional last)
11572 (let ((func (if (symbolp group) group
11573 (car (gnus-find-method-for-group group)))))
11574 (funcall (intern (format "%s-request-accept-article" func))
11575 (if (stringp group) (gnus-group-real-name group) group)
11578 (defun gnus-request-replace-article (article group buffer)
11579 (let ((func (car (gnus-find-method-for-group group))))
11580 (funcall (intern (format "%s-request-replace-article" func))
11581 article (gnus-group-real-name group) buffer)))
11583 (defun gnus-request-create-group (group)
11584 (let ((method (gnus-find-method-for-group group)))
11585 (funcall (gnus-get-function method 'request-create-group)
11586 (gnus-group-real-name group) (nth 1 method))))
11588 (defun gnus-member-of-valid (symbol group)
11589 (memq symbol (assoc
11590 (format "%s" (car (gnus-find-method-for-group group)))
11591 gnus-valid-select-methods)))
11593 (defsubst gnus-secondary-method-p (method)
11594 (member method gnus-secondary-select-methods))
11596 (defun gnus-find-method-for-group (group &optional info)
11597 (or gnus-override-method
11599 gnus-select-method)
11600 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11603 (not (setq method (nth 4 info))))
11604 (setq method gnus-select-method)
11606 (cond ((stringp method)
11607 (gnus-server-to-method method))
11608 ((stringp (car method))
11609 (gnus-server-extend-method group method))
11612 (gnus-server-add-address method))))
11614 (defun gnus-check-backend-function (func group)
11615 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11617 (fboundp (intern (format "%s-%s" method func)))))
11619 (defun gnus-methods-using (method)
11620 (let ((valids gnus-valid-select-methods)
11623 (if (memq method (car valids))
11624 (setq outs (cons (car valids) outs)))
11625 (setq valids (cdr valids)))
11629 ;;; Active & Newsrc File Handling
11632 ;; Newsrc related functions.
11633 ;; Gnus internal format of gnus-newsrc-alist:
11634 ;; (("alt.general" 3 (1 . 1))
11635 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11636 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11637 ;; The first item is the group name; the second is the subscription
11638 ;; level; the third is either a range of a list of ranges of read
11639 ;; articles, the optional fourth element is a list of marked articles,
11640 ;; the optional fifth element is the select method.
11642 ;; Gnus internal format of gnus-newsrc-hashtb:
11643 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11644 ;; This is the entry for "alt.misc". The first element is the number
11645 ;; of unread articles in "alt.misc". The cdr of this entry is the
11646 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11647 ;; trivial to remove or add new elements into gnus-newsrc-alist
11648 ;; without scanning the entire list. So, to get the actual information
11649 ;; of "alt.misc", you'd say something like
11650 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11652 ;; Gnus internal format of gnus-active-hashtb:
11656 ;; The only element in each entry in this hash table is a range of
11657 ;; (possibly) available articles. (Articles in this range may have
11658 ;; been expired or canceled.)
11660 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11661 ;; ("alt.misc" "alt.test" "alt.general" ...)
11663 (defun gnus-setup-news (&optional rawfile level)
11664 "Setup news information.
11665 If RAWFILE is non-nil, the .newsrc file will also be read.
11666 If LEVEL is non-nil, the news will be set up at level LEVEL."
11667 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
11668 ;; Clear some variables to re-initialize news information.
11669 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
11671 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11672 (if init (gnus-read-newsrc-file rawfile))
11674 ;; Read the active file and create `gnus-active-hashtb'.
11675 ;; If `gnus-read-active-file' is nil, then we just create an empty
11676 ;; hash table. The partial filling out of the hash table will be
11677 ;; done in `gnus-get-unread-articles'.
11678 (if (and gnus-read-active-file
11680 (gnus-read-active-file)
11681 (setq gnus-active-hashtb (make-vector 4095 0)))
11683 (and init gnus-use-dribble-file (gnus-dribble-read-file))
11685 ;; Find the number of unread articles in each non-dead group.
11686 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
11687 ;; Find new newsgroups and treat them.
11688 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
11689 (gnus-server-opened gnus-select-method))
11690 (gnus-find-new-newsgroups))
11691 (if (and init gnus-check-bogus-newsgroups
11692 gnus-read-active-file (not level)
11693 (gnus-server-opened gnus-select-method))
11694 (gnus-check-bogus-newsgroups))))
11696 (defun gnus-find-new-newsgroups ()
11697 "Search for new newsgroups and add them.
11698 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11699 The `-n' option line from .newsrc is respected."
11701 (or (gnus-check-first-time-used)
11702 (if (or (consp gnus-check-new-newsgroups)
11703 (eq gnus-check-new-newsgroups 'ask-server))
11704 (gnus-ask-server-for-new-groups)
11706 group new-newsgroups)
11707 (or gnus-have-read-active-file (gnus-read-active-file))
11708 (setq gnus-newsrc-last-checked-date (current-time-string))
11709 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11710 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11711 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11714 (setq group (symbol-name sym))
11715 (if (or (gnus-gethash group gnus-killed-hashtb)
11716 (gnus-gethash group gnus-newsrc-hashtb))
11718 (let ((do-sub (gnus-matches-options-n group)))
11719 (cond ((eq do-sub 'subscribe)
11720 (setq groups (1+ groups))
11721 (gnus-sethash group group gnus-killed-hashtb)
11723 gnus-subscribe-options-newsgroup-method group))
11724 ((eq do-sub 'ignore)
11727 (setq groups (1+ groups))
11728 (gnus-sethash group group gnus-killed-hashtb)
11729 (if gnus-subscribe-hierarchical-interactive
11730 (setq new-newsgroups (cons group new-newsgroups))
11731 (funcall gnus-subscribe-newsgroup-method group)))))))
11732 gnus-active-hashtb)
11734 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11735 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11737 (gnus-message 6 "%d new newsgroup%s arrived."
11738 groups (if (> groups 1) "s have" " has")))))))
11740 (defun gnus-matches-options-n (group)
11741 ;; Returns `subscribe' if the group is to be uncoditionally
11742 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
11743 ;; no match for the group.
11745 ;; First we check the two user variables.
11747 ((and gnus-options-subscribe
11748 (string-match gnus-options-subscribe group))
11750 ((and gnus-options-not-subscribe
11751 (string-match gnus-options-not-subscribe group))
11753 ;; Then we go through the list that was retrieved from the .newsrc
11754 ;; file. This list has elements on the form
11755 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11756 ;; is in the reverse order of the options line) is returned.
11758 (let ((regs gnus-newsrc-options-n))
11760 (not (string-match (car (car regs)) group)))
11761 (setq regs (cdr regs)))
11762 (and regs (cdr (car regs)))))))
11764 (defun gnus-ask-server-for-new-groups ()
11765 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11766 (methods (cons gnus-select-method
11768 (and (consp gnus-check-new-newsgroups)
11769 gnus-check-new-newsgroups)
11770 gnus-secondary-select-methods)))
11772 (new-date (current-time-string))
11773 hashtb group new-newsgroups got-new)
11774 ;; Go thorugh both primary and secondary select methods and
11775 ;; request new newsgroups.
11777 (and (or (gnus-server-opened (car methods))
11778 (gnus-open-server (car methods)))
11779 (gnus-request-newgroups date (car methods))
11782 (set-buffer nntp-server-buffer)
11783 (or hashtb (setq hashtb (gnus-make-hashtable
11784 (count-lines (point-min) (point-max)))))
11785 ;; Enter all the new groups in a hashtable.
11786 (gnus-active-to-gnus-format (car methods) hashtb 'ignore)))
11787 (setq methods (cdr methods)))
11788 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11789 ;; Now all new groups from all select methods are in `hashtb'.
11791 (lambda (group-sym)
11792 (setq group (symbol-name group-sym))
11793 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11794 (member group gnus-zombie-list)
11795 (member group gnus-killed-list))
11796 ;; The group is already known.
11798 (and (symbol-value group-sym)
11799 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
11800 (let ((do-sub (gnus-matches-options-n group)))
11801 (cond ((eq do-sub 'subscribe)
11802 (setq groups (1+ groups))
11803 (gnus-sethash group group gnus-killed-hashtb)
11805 gnus-subscribe-options-newsgroup-method group))
11806 ((eq do-sub 'ignore)
11809 (setq groups (1+ groups))
11810 (gnus-sethash group group gnus-killed-hashtb)
11811 (if gnus-subscribe-hierarchical-interactive
11812 (setq new-newsgroups (cons group new-newsgroups))
11813 (funcall gnus-subscribe-newsgroup-method group)))))))
11816 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11817 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11819 (gnus-message 6 "%d new newsgroup%s arrived."
11820 groups (if (> groups 1) "s have" " has")))
11823 (defun gnus-check-first-time-used ()
11824 (if (or (> (length gnus-newsrc-alist) 1)
11825 (file-exists-p gnus-startup-file)
11826 (file-exists-p (concat gnus-startup-file ".el"))
11827 (file-exists-p (concat gnus-startup-file ".eld")))
11829 (gnus-message 6 "First time user; subscribing you to default groups")
11830 (or gnus-have-read-active-file (gnus-read-active-file))
11831 (setq gnus-newsrc-last-checked-date (current-time-string))
11832 (let ((groups gnus-default-subscribed-newsgroups)
11836 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11839 (setq group (symbol-name sym))
11840 (let ((do-sub (gnus-matches-options-n group)))
11841 (cond ((eq do-sub 'subscribe)
11842 (gnus-sethash group group gnus-killed-hashtb)
11844 gnus-subscribe-options-newsgroup-method group))
11845 ((eq do-sub 'ignore)
11848 (setq gnus-killed-list (cons group gnus-killed-list))))))
11849 gnus-active-hashtb)
11851 (if (gnus-gethash (car groups) gnus-active-hashtb)
11852 (gnus-group-change-level
11853 (car groups) gnus-level-default-subscribed gnus-level-killed))
11854 (setq groups (cdr groups)))
11855 (gnus-group-make-help-group)
11856 (and gnus-novice-user
11857 (gnus-message 7 "`A k' to list killed groups"))))))
11859 (defun gnus-subscribe-group (group previous &optional method)
11860 (gnus-group-change-level
11862 (list t group gnus-level-default-subscribed nil nil method)
11864 gnus-level-default-subscribed gnus-level-killed previous t))
11866 ;; `gnus-group-change-level' is the fundamental function for changing
11867 ;; subscription levels of newsgroups. This might mean just changing
11868 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11869 ;; again, which subscribes/unsubscribes a group, which is equally
11870 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11871 ;; from 8-9 to 1-7 means that you remove the group from the list of
11872 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11873 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11874 ;; which is trivial.
11875 ;; ENTRY can either be a string (newsgroup name) or a list (if
11876 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11877 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11879 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11880 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11882 (defun gnus-group-change-level (entry level &optional oldlevel
11883 previous fromkilled)
11884 (let (group info active num)
11885 ;; Glean what info we can from the arguments
11887 (if fromkilled (setq group (nth 1 entry))
11888 (setq group (car (nth 2 entry))))
11889 (setq group entry))
11890 (if (and (stringp entry)
11892 (< oldlevel gnus-level-zombie))
11893 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11894 (if (and (not oldlevel)
11896 (setq oldlevel (car (cdr (nth 2 entry)))))
11897 (if (stringp previous)
11898 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11900 (gnus-dribble-enter
11901 (format "(gnus-group-change-level %S %S %S %S %S)"
11902 group level oldlevel (car (nth 2 previous)) fromkilled))
11904 ;; Then we remove the newgroup from any old structures, if needed.
11905 ;; If the group was killed, we remove it from the killed or zombie
11906 ;; list. If not, and it is in fact going to be killed, we remove
11907 ;; it from the newsrc hash table and assoc.
11908 (cond ((>= oldlevel gnus-level-zombie)
11909 (if (= oldlevel gnus-level-zombie)
11910 (setq gnus-zombie-list (delete group gnus-zombie-list))
11911 (setq gnus-killed-list (delete group gnus-killed-list))))
11913 (if (and (>= level gnus-level-zombie)
11916 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
11918 (setcdr (gnus-gethash (car (nth 3 entry))
11919 gnus-newsrc-hashtb)
11921 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11923 ;; Finally we enter (if needed) the list where it is supposed to
11924 ;; go, and change the subscription level. If it is to be killed,
11925 ;; we enter it into the killed or zombie list.
11926 (cond ((>= level gnus-level-zombie)
11927 ;; Remove from the hash table.
11928 (gnus-sethash group nil gnus-newsrc-hashtb)
11929 (or (gnus-group-foreign-p group)
11930 ;; We do not enter foreign groups into the list of dead
11932 (if (= level gnus-level-zombie)
11933 (setq gnus-zombie-list (cons group gnus-zombie-list))
11934 (setq gnus-killed-list (cons group gnus-killed-list)))))
11936 ;; If the list is to be entered into the newsrc assoc, and
11937 ;; it was killed, we have to create an entry in the newsrc
11938 ;; hashtb format and fix the pointers in the newsrc assoc.
11939 (if (>= oldlevel gnus-level-zombie)
11943 (setq info (cdr entry))
11944 (setq num (car entry)))
11945 (setq active (gnus-gethash group gnus-active-hashtb))
11946 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11947 ;; Check whether the group is foreign. If so, the
11948 ;; foreign select method has to be entered into the
11950 (let ((method (gnus-group-method-name group)))
11951 (if (eq method gnus-select-method)
11952 (setq info (list group level nil))
11953 (setq info (list group level nil nil method)))))
11956 (let ((p gnus-newsrc-alist))
11957 (while (cdr (cdr p))
11960 (setq entry (cons info (cdr (cdr previous))))
11963 (setcdr (cdr previous) entry)
11964 (gnus-sethash group (cons num (cdr previous))
11965 gnus-newsrc-hashtb))
11966 (setcdr previous entry)
11967 (gnus-sethash group (cons num previous)
11968 gnus-newsrc-hashtb))
11970 (setcdr (gnus-gethash (car (car (cdr entry)))
11971 gnus-newsrc-hashtb)
11973 ;; It was alive, and it is going to stay alive, so we
11974 ;; just change the level and don't change any pointers or
11975 ;; hash table entries.
11976 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11978 (defun gnus-kill-newsgroup (newsgroup)
11979 "Obsolete function. Kills a newsgroup."
11980 (gnus-group-change-level
11981 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11983 (defun gnus-check-bogus-newsgroups (&optional confirm)
11984 "Remove bogus newsgroups.
11985 If CONFIRM is non-nil, the user has to confirm the deletion of every
11987 (let ((newsrc (cdr gnus-newsrc-alist))
11989 (gnus-message 5 "Checking bogus newsgroups...")
11990 (or gnus-have-read-active-file (gnus-read-active-file))
11991 ;; Find all bogus newsgroup that are subscribed.
11993 (setq group (car (car newsrc)))
11994 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
11995 (nth 4 (car newsrc)) ; Foreign
11997 (not (gnus-y-or-n-p
11998 (format "Remove bogus newsgroup: %s " group)))))
12001 ;; Found a bogus newsgroup.
12002 (setq bogus (cons group bogus)))
12003 (setq newsrc (cdr newsrc)))
12004 ;; Remove all bogus subscribed groups by first killing them, and
12005 ;; then removing them from the list of killed groups.
12007 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12009 (gnus-group-change-level entry gnus-level-killed)
12010 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12011 (setq bogus (cdr bogus)))
12012 ;; Then we remove all bogus groups from the list of killed and
12013 ;; zombie groups. They are are removed without confirmation.
12014 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12017 (setq killed (symbol-value (car dead-lists)))
12019 (setq group (car killed))
12020 (or (gnus-gethash group gnus-active-hashtb)
12021 ;; The group is bogus.
12022 (set (car dead-lists)
12023 (delete group (symbol-value (car dead-lists)))))
12024 (setq killed (cdr killed)))
12025 (setq dead-lists (cdr dead-lists))))
12026 (gnus-message 5 "Checking bogus newsgroups...done")))
12028 (defun gnus-check-duplicate-killed-groups ()
12029 "Remove duplicates from the list of killed groups."
12031 (let ((killed gnus-killed-list))
12033 (gnus-message 9 "%d" (length killed))
12034 (setcdr killed (delete (car killed) (cdr killed)))
12035 (setq killed (cdr killed)))))
12037 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12038 ;; and compute how many unread articles there are in each group.
12039 (defun gnus-get-unread-articles (&optional level)
12040 (let* ((newsrc (cdr gnus-newsrc-alist))
12041 (level (or level (1+ gnus-level-subscribed)))
12044 (cond ((and gnus-activate-foreign-newsgroups
12045 (not (numberp gnus-activate-foreign-newsgroups)))
12046 (1+ gnus-level-subscribed))
12047 ((numberp gnus-activate-foreign-newsgroups)
12048 gnus-activate-foreign-newsgroups)
12051 info group active virtuals method)
12052 (gnus-message 5 "Checking new news...")
12055 (setq info (car newsrc)
12057 active (gnus-gethash group gnus-active-hashtb))
12059 ;; Check newsgroups. If the user doesn't want to check them, or
12060 ;; they can't be checked (for instance, if the news server can't
12061 ;; be reached) we just set the number of unread articles in this
12062 ;; newsgroup to t. This means that Gnus thinks that there are
12063 ;; unread articles, but it has no idea how many.
12064 (if (and (setq method (nth 4 info))
12065 (not (gnus-server-equal gnus-select-method
12066 (gnus-server-get-method nil method)))
12067 (not (gnus-secondary-method-p method)))
12068 ;; These groups are foreign. Check the level.
12069 (if (<= (nth 1 info) foreign-level)
12070 (if (eq (car (if (stringp method)
12071 (gnus-server-to-method method)
12072 (nth 4 info))) 'nnvirtual)
12073 ;; We have to activate the virtual groups after all
12074 ;; the others, so we just pop them on a list for
12076 (setq virtuals (cons info virtuals))
12077 (and (setq active (gnus-activate-newsgroup (car info)))
12078 ;; Close the groups as we look at them!
12079 (gnus-close-group group))))
12081 ;; These groups are native or secondary.
12082 (if (and (not gnus-have-read-active-file)
12083 (<= (nth 1 info) level))
12084 (setq active (gnus-activate-newsgroup (car info)))))
12087 (gnus-get-unread-articles-in-group info active)
12088 ;; The group couldn't be reached, so we nix out the number of
12089 ;; unread articles and stuff.
12090 (gnus-sethash group nil gnus-active-hashtb)
12091 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12093 (setq newsrc (cdr newsrc)))
12095 ;; Activate the virtual groups. This has to be done after all the
12097 ;; !!! If one virtual group contains another virtual group, even
12098 ;; doing it this way might cause problems.
12100 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
12101 (gnus-get-unread-articles-in-group (car virtuals) active))
12102 (setq virtuals (cdr virtuals)))
12104 (gnus-message 5 "Checking new news...done")))
12106 ;; Create a hash table out of the newsrc alist. The `car's of the
12107 ;; alist elements are used as keys.
12108 (defun gnus-make-hashtable-from-newsrc-alist ()
12109 (let ((alist gnus-newsrc-alist)
12110 (ohashtb gnus-newsrc-hashtb)
12112 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12114 (setq prev (setq gnus-newsrc-alist
12115 (if (equal (car (car gnus-newsrc-alist))
12118 (cons (list "dummy.group" 0 nil) alist)))))
12120 (gnus-sethash (car (car alist))
12121 (cons (and ohashtb (car (gnus-gethash
12122 (car (car alist)) ohashtb)))
12123 prev) gnus-newsrc-hashtb)
12125 alist (cdr alist)))))
12127 (defun gnus-make-hashtable-from-killed ()
12128 "Create a hash table from the killed and zombie lists."
12129 (let ((lists '(gnus-killed-list gnus-zombie-list))
12131 (setq gnus-killed-hashtb
12132 (gnus-make-hashtable
12133 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12135 (setq list (symbol-value (car lists)))
12136 (setq lists (cdr lists))
12138 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12139 (setq list (cdr list))))))
12141 (defun gnus-get-unread-articles-in-group (info active)
12142 (let* ((range (nth 2 info))
12144 (marked (nth 3 info)))
12145 ;; If a cache is present, we may have to alter the active info.
12146 (and gnus-use-cache
12147 (gnus-cache-possibly-alter-active (car info) active))
12148 ;; Modify the list of read articles according to what articles
12149 ;; are available; then tally the unread articles and add the
12150 ;; number to the group hash table entry.
12151 (cond ((zerop (cdr active))
12154 (setq num (- (1+ (cdr active)) (car active))))
12155 ((not (listp (cdr range)))
12156 ;; Fix a single (num . num) range according to the
12157 ;; active hash table.
12158 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12159 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12160 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12161 ;; Compute number of unread articles.
12162 (setq num (max 0 (- (cdr active)
12163 (- (1+ (cdr range)) (car range))))))
12165 ;; The read list is a list of ranges. Fix them according to
12166 ;; the active hash table.
12167 ;; First peel off any elements that are below the lower
12169 (while (and (cdr range)
12171 (or (and (atom (car (cdr range))) (car (cdr range)))
12172 (car (car (cdr range))))))
12173 (if (numberp (car range))
12176 (or (and (numberp (car (cdr range)))
12178 (cdr (car (cdr range))))))
12179 (setcdr (car range)
12180 (or (and (numberp (nth 1 range)) (nth 1 range))
12181 (cdr (car (cdr range))))))
12182 (setcdr range (cdr (cdr range))))
12183 ;; Adjust the first element to be the same as the lower limit.
12184 (if (and (not (atom (car range)))
12185 (< (cdr (car range)) (car active)))
12186 (setcdr (car range) (1- (car active))))
12187 ;; Then we want to peel off any elements that are higher
12188 ;; than the upper active limit.
12189 (let ((srange range))
12190 ;; Go past all legal elements.
12191 (while (and (cdr srange)
12192 (<= (or (and (atom (car (cdr srange)))
12193 (car (cdr srange)))
12194 (car (car (cdr srange)))) (cdr active)))
12195 (setq srange (cdr srange)))
12197 ;; Nuke all remaining illegal elements.
12198 (setcdr srange nil))
12200 ;; Adjust the final element.
12201 (if (and (not (atom (car srange)))
12202 (> (cdr (car srange)) (cdr active)))
12203 (setcdr (car srange) (cdr active))))
12204 ;; Compute the number of unread articles.
12206 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12207 (cdr (car range))))
12208 (or (and (atom (car range)) (car range))
12209 (car (car range))))))
12210 (setq range (cdr range)))
12211 (setq num (max 0 (- (cdr active) num)))))
12214 (and (assq 'tick marked)
12215 (inline (gnus-remove-illegal-marked-articles
12216 (assq 'tick marked) (nth 2 info))))
12217 (and (assq 'dormant marked)
12218 (inline (gnus-remove-illegal-marked-articles
12219 (assq 'dormant marked) (nth 2 info))))
12221 (gnus-gethash (car info) gnus-newsrc-hashtb)
12222 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12223 (length (cdr (assq 'dormant marked)))))))))
12226 (defun gnus-remove-illegal-marked-articles (marked ranges)
12227 (let ((m (cdr marked)))
12228 ;; Make sure that all ticked articles are a subset of the unread
12231 (if (gnus-member-of-range (car m) ranges)
12232 (setcdr marked (cdr m))
12234 (setq m (cdr m)))))
12236 (defun gnus-activate-newsgroup (group)
12237 (let ((method (gnus-find-method-for-group group))
12239 (and (or (gnus-server-opened method) (gnus-open-server method))
12240 (gnus-request-group group)
12242 (set-buffer nntp-server-buffer)
12243 (goto-char (point-min))
12244 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12246 (goto-char (match-beginning 1))
12248 group (setq active (cons (read (current-buffer))
12249 (read (current-buffer))))
12250 gnus-active-hashtb))
12253 (defun gnus-update-read-articles
12254 (group unread unselected ticked &optional domarks replied expirable killed
12255 dormant bookmark score)
12256 "Update the list of read and ticked articles in GROUP using the
12257 UNREAD and TICKED lists.
12258 Note: UNSELECTED has to be sorted over `<'.
12259 Returns whether the updating was successful."
12260 (let* ((active (or gnus-newsgroup-active
12261 (gnus-gethash group gnus-active-hashtb)))
12262 (entry (gnus-gethash group gnus-newsrc-hashtb))
12263 (info (nth 2 entry))
12264 (marked (nth 3 info))
12266 (unread (sort (copy-sequence unread) (function <)))
12268 (if (or (not info) (not active))
12269 ;; There is no info on this group if it was, in fact,
12270 ;; killed. Gnus stores no information on killed groups, so
12271 ;; there's nothing to be done.
12272 ;; One could store the information somewhere temporarily,
12273 ;; perhaps... Hmmm...
12275 ;; Remove any negative articles numbers.
12276 (while (and unread (< (car unread) 0))
12277 (setq unread (cdr unread)))
12278 ;; Remove any expired article numbers
12279 (while (and unread (< (car unread) (car active)))
12280 (setq unread (cdr unread)))
12281 (while (and ticked (< (car ticked) (car active)))
12282 (setq ticked (cdr ticked)))
12283 (while (and dormant (< (car dormant) (car active)))
12284 (setq dormant (cdr dormant)))
12285 (setq unread (sort (append unselected unread) '<))
12286 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12287 (setcar entry (max 0 (- (length unread) (length ticked)
12288 (length dormant))))
12289 ;; Compute the ranges of read articles by looking at the list of
12290 ;; unread articles.
12292 (if (/= (car unread) prev)
12293 (setq read (cons (if (= prev (1- (car unread))) prev
12294 (cons prev (1- (car unread)))) read)))
12295 (setq prev (1+ (car unread)))
12296 (setq unread (cdr unread)))
12297 (if (<= prev (cdr active))
12298 (setq read (cons (cons prev (cdr active)) read)))
12299 ;; Enter this list into the group info.
12300 (setcar (cdr (cdr info))
12301 (if (> (length read) 1) (nreverse read) read))
12302 ;; Enter the list of ticked articles.
12303 (gnus-set-marked-articles
12305 (if domarks replied (cdr (assq 'reply marked)))
12306 (if domarks expirable (cdr (assq 'expire marked)))
12307 (if domarks killed (cdr (assq 'killed marked)))
12308 (if domarks dormant (cdr (assq 'dormant marked)))
12309 (if domarks bookmark (cdr (assq 'bookmark marked)))
12310 (if domarks score (cdr (assq 'score marked))))
12313 (defun gnus-make-articles-unread (group articles)
12314 "Mark ARTICLES in GROUP as unread."
12315 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12316 (gnus-gethash (gnus-group-real-name group)
12317 gnus-newsrc-hashtb))))
12318 (ranges (nth 2 info))
12321 (and (gnus-member-of-range (car articles) ranges)
12322 (setq news (cons (car articles) news)))
12323 (setq articles (cdr articles)))
12326 (setcar (nthcdr 2 info)
12327 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12328 (gnus-group-update-group group t))))
12330 ;; Get the active file(s) from the backend(s).
12331 (defun gnus-read-active-file ()
12332 (gnus-group-set-mode-line)
12333 (let ((methods (if (or (gnus-server-opened gnus-select-method)
12334 (gnus-open-server gnus-select-method))
12335 ;; The native server is available.
12336 (cons gnus-select-method gnus-secondary-select-methods)
12337 ;; The native server is down, so we just do the
12339 gnus-secondary-select-methods))
12341 (setq gnus-have-read-active-file nil)
12343 (set-buffer nntp-server-buffer)
12345 (let* ((where (nth 1 (car methods)))
12346 (mesg (format "Reading active file%s via %s..."
12347 (if (and where (not (zerop (length where))))
12348 (concat " from " where) "")
12349 (car (car methods)))))
12350 (gnus-message 5 mesg)
12351 (gnus-check-news-server (car methods))
12353 ((and (eq gnus-read-active-file 'some)
12354 (gnus-check-backend-function
12355 'retrieve-groups (car (car methods))))
12356 (let ((newsrc (cdr gnus-newsrc-alist))
12359 (and (gnus-server-equal
12360 (gnus-find-method-for-group
12361 (car (car newsrc)) (car newsrc))
12362 (gnus-server-get-method nil (car methods)))
12363 (setq groups (cons (car (car newsrc)) groups)))
12364 (setq newsrc (cdr newsrc)))
12365 (setq list-type (gnus-retrieve-groups groups (car methods)))
12366 (cond ((not list-type)
12368 1 "Cannot read partial active file from %s server."
12369 (car (car methods)))
12372 ((eq list-type 'active)
12373 (gnus-active-to-gnus-format (car methods)))
12375 (gnus-groups-to-gnus-format (car methods))))))
12377 (if (not (gnus-request-list (car methods)))
12379 (gnus-message 1 "Cannot read active file from %s server."
12380 (car (car methods)))
12382 (gnus-active-to-gnus-format (car methods))
12383 (setq gnus-have-read-active-file t)
12384 (gnus-message 5 "%sdone" mesg)))))
12385 (setq methods (cdr methods))))))
12387 ;; Read an active file and place the results in `gnus-active-hashtb'.
12388 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12389 (let ((cur (current-buffer))
12391 (if (and gnus-active-hashtb
12392 (not (equal method gnus-select-method)))
12394 (setq gnus-active-hashtb
12395 (if (equal method gnus-select-method)
12396 (gnus-make-hashtable
12397 (count-lines (point-min) (point-max)))
12398 (gnus-make-hashtable 4096)))))))
12399 ;; Delete unnecessary lines.
12400 (goto-char (point-min))
12401 (while (search-forward "\nto." nil t)
12402 (delete-region (1+ (match-beginning 0))
12403 (progn (forward-line 1) (point))))
12404 (or (string= gnus-ignored-newsgroups "")
12406 (goto-char (point-min))
12407 (delete-matching-lines gnus-ignored-newsgroups)))
12408 ;; If these are groups from a foreign select method, we insert the
12409 ;; group prefix in front of the group names.
12410 (and method (not (eq method gnus-select-method))
12411 (let ((prefix (gnus-group-prefixed-name "" method)))
12412 (goto-char (point-min))
12413 (while (and (not (eobp))
12414 (progn (insert prefix)
12415 (zerop (forward-line 1)))))))
12416 (goto-char (point-min))
12417 ;; Store active file in hashtable.
12418 (goto-char (point-min))
12419 (if (string-match "%[oO]" gnus-group-line-format)
12420 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12421 ;; If we want information on moderated groups, we use this
12423 (let* ((mod-hashtb (make-vector 7 0))
12424 (m (intern "m" mod-hashtb))
12426 (while (not (eobp))
12427 (condition-case nil
12429 (narrow-to-region (point) (gnus-point-at-eol))
12430 (setq group (let ((obarray hashtb)) (read cur)))
12431 (if (and (numberp (setq max (read cur)))
12432 (numberp (setq min (read cur))))
12433 (set group (cons min max))
12435 ;; Enter moderated groups into a list.
12436 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12437 (setq gnus-moderated-list
12438 (cons (symbol-name group) gnus-moderated-list))))
12442 ;; And if we do not care about moderation, we use this loop,
12443 ;; which is faster.
12444 (let (group max min)
12445 (while (not (eobp))
12448 (narrow-to-region (point) (gnus-point-at-eol))
12449 ;; group gets set to a symbol interned in the hash table
12451 (setq group (let ((obarray hashtb)) (read cur)))
12452 (if (and (numberp (setq max (read cur)))
12453 (numberp (setq min (read cur))))
12454 (set group (cons min max))
12461 (gnus-message 3 "Warning - illegal active: %s"
12463 (gnus-point-at-bol) (gnus-point-at-eol)))
12466 (forward-line 1))))))
12468 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12469 ;; Parse a "groups" active file.
12470 (let ((cur (current-buffer))
12474 (setq gnus-active-hashtb
12475 (gnus-make-hashtable
12476 (count-lines (point-min) (point-max)))))))
12477 (prefix (and method (not (eq method gnus-select-method))
12478 (gnus-group-prefixed-name "" method))))
12480 (goto-char (point-min))
12482 ;; We split this into to separate loops, one with the prefix
12483 ;; and one without to speed the reading up somewhat.
12485 (let (min max opoint)
12486 (while (not (eobp))
12487 (read cur) (read cur)
12488 (setq min (read cur)
12491 (skip-chars-forward " \t")
12494 (set (let ((obarray hashtb)) (read cur))
12498 (while (not (eobp))
12499 (if (= (following-char) ?2)
12501 (read cur) (read cur)
12502 (setq min (read cur)
12504 (set (let ((obarray hashtb)) (read cur))
12506 (forward-line 1))))
12508 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
12510 (defun gnus-read-newsrc-file (&optional force)
12511 "Read startup file.
12512 If FORCE is non-nil, the .newsrc file is read."
12513 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12514 ;; Reset variables that might be defined in the .newsrc.eld file.
12515 (let ((variables gnus-variable-list))
12517 (set (car variables) nil)
12518 (setq variables (cdr variables))))
12519 (let* ((newsrc-file gnus-current-startup-file)
12520 (quick-file (concat newsrc-file ".el")))
12522 ;; We always load the .newsrc.eld file. If always contains
12523 ;; much information that can not be gotten from the .newsrc
12524 ;; file (ticked articles, killed groups, foreign methods, etc.)
12525 (gnus-read-newsrc-el-file quick-file)
12528 (and (file-newer-than-file-p newsrc-file quick-file)
12529 (file-newer-than-file-p newsrc-file
12530 (concat quick-file "d")))
12531 (not gnus-newsrc-alist))
12532 ;; We read the .newsrc file. Note that if there if a
12533 ;; .newsrc.eld file exists, it has already been read, and
12534 ;; the `gnus-newsrc-hashtb' has been created. While reading
12535 ;; the .newsrc file, Gnus will only use the information it
12536 ;; can find there for changing the data already read -
12537 ;; ie. reading the .newsrc file will not trash the data
12538 ;; already read (except for read articles).
12540 (gnus-message 5 "Reading %s..." newsrc-file)
12541 (set-buffer (find-file-noselect newsrc-file))
12542 (buffer-disable-undo (current-buffer))
12543 (gnus-newsrc-to-gnus-format)
12544 (kill-buffer (current-buffer))
12545 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12547 (defun gnus-read-newsrc-el-file (file)
12548 (let ((ding-file (concat file "d")))
12549 ;; We always, always read the .eld file.
12550 (gnus-message 5 "Reading %s..." ding-file)
12551 (let (gnus-newsrc-assoc)
12552 (condition-case nil
12553 (load ding-file t t t)
12555 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12556 (let ((inhibit-quit t))
12557 (gnus-uncompress-newsrc-alist))
12558 (gnus-make-hashtable-from-newsrc-alist)
12559 (if (not (file-newer-than-file-p file ding-file))
12561 ;; Old format quick file
12562 (gnus-message 5 "Reading %s..." file)
12563 ;; The .el file is newer than the .eld file, so we read that one
12565 (gnus-read-old-newsrc-el-file file))))
12567 ;; Parse the old-style quick startup file
12568 (defun gnus-read-old-newsrc-el-file (file)
12569 (let (newsrc killed marked group m)
12571 (let ((gnus-killed-assoc nil)
12572 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12574 (condition-case nil
12577 (setq newsrc gnus-newsrc-assoc
12578 killed gnus-killed-assoc
12579 marked gnus-marked-assoc)))
12580 (setq gnus-newsrc-alist nil)
12582 (setq group (car newsrc))
12583 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12586 (setcar (nthcdr 2 info) (cdr (cdr group)))
12588 (if (nth 1 group) gnus-level-default-subscribed
12589 gnus-level-default-unsubscribed))
12590 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
12591 (setq gnus-newsrc-alist
12595 (if (nth 1 group) gnus-level-default-subscribed
12596 gnus-level-default-unsubscribed)
12597 (cdr (cdr group))))
12598 gnus-newsrc-alist)))
12599 (if (setq m (assoc (car group) marked))
12600 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12601 (setq newsrc (cdr newsrc)))
12602 (setq newsrc killed)
12604 (setcar newsrc (car (car newsrc)))
12605 (setq newsrc (cdr newsrc)))
12606 (setq gnus-killed-list killed))
12607 ;; The .el file version of this variable does not begin with
12608 ;; "options", while the .eld version does, so we just add it if it
12611 gnus-newsrc-options
12613 (and (not (string-match "^ *options" gnus-newsrc-options))
12614 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
12615 (and (not (string-match "\n$" gnus-newsrc-options))
12616 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))))
12617 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
12618 (gnus-make-hashtable-from-newsrc-alist)))
12620 (defun gnus-make-newsrc-file (file)
12621 "Make server dependent file name by catenating FILE and server host name."
12622 (let* ((file (expand-file-name file nil))
12623 (real-file (concat file "-" (nth 1 gnus-select-method))))
12624 (if (or (file-exists-p real-file)
12625 (file-exists-p (concat real-file ".el"))
12626 (file-exists-p (concat real-file ".eld")))
12629 (defun gnus-uncompress-newsrc-alist ()
12630 ;; Uncompress all lists of marked articles in the newsrc assoc.
12631 (let ((newsrc gnus-newsrc-alist)
12634 (if (not (setq marked (nth 3 (car newsrc))))
12637 (or (eq 'score (car (car marked)))
12638 (eq 'bookmark (car (car marked)))
12639 (eq 'killed (car (car marked)))
12640 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12641 (setq marked (cdr marked))))
12642 (setq newsrc (cdr newsrc)))))
12644 (defun gnus-compress-newsrc-alist ()
12645 ;; Compress all lists of marked articles in the newsrc assoc.
12646 (let ((newsrc gnus-newsrc-alist)
12649 (if (not (setq marked (nth 3 (car newsrc))))
12652 (or (eq 'score (car (car marked)))
12653 (eq 'bookmark (car (car marked)))
12654 (eq 'killed (car (car marked)))
12655 (setcdr (car marked)
12657 (gnus-compress-sequence
12658 (sort (cdr (car marked)) '<) t)
12659 (error (cdr (car marked))))))
12660 (setq marked (cdr marked))))
12661 (setq newsrc (cdr newsrc)))))
12663 (defun gnus-newsrc-to-gnus-format ()
12664 (setq gnus-newsrc-options "")
12665 (setq gnus-newsrc-options-n nil)
12667 (or gnus-active-hashtb
12668 (setq gnus-active-hashtb (make-vector 4095 0)))
12669 (let ((buf (current-buffer))
12670 (already-read (> (length gnus-newsrc-alist) 1))
12671 group subscribed options-symbol newsrc Options-symbol
12673 (goto-char (point-min))
12674 ;; We intern the symbol `options' in the active hashtb so that we
12675 ;; can `eq' against it later.
12676 (setq options-symbol (intern "options" gnus-active-hashtb))
12677 (setq Options-symbol (intern "Options" gnus-active-hashtb))
12679 (while (not (eobp))
12680 ;; We first read the first word on the line by narrowing and
12681 ;; then reading into `gnus-active-hashtb'. Most groups will
12682 ;; already exist in that hashtb, so this will save some string
12686 (progn (skip-chars-forward "^ \t!:\n") (point)))
12687 (goto-char (point-min))
12689 (and (/= (point-min) (point-max))
12690 (let ((obarray gnus-active-hashtb)) (read buf))))
12692 ;; Now, the symbol we have read is either `options' or a group
12693 ;; name. If it is an options line, we just add it to a string.
12695 ((or (eq symbol options-symbol)
12696 (eq symbol Options-symbol))
12697 (setq gnus-newsrc-options
12698 ;; This concatting is quite inefficient, but since our
12699 ;; thorough studies show that approx 99.37% of all
12700 ;; .newsrc files only contain a single options line, we
12701 ;; don't give a damn, frankly, my dear.
12702 (concat gnus-newsrc-options
12704 (gnus-point-at-bol)
12705 ;; Options may continue on the next line.
12706 (or (and (re-search-forward "^[^ \t]" nil 'move)
12707 (progn (beginning-of-line) (point)))
12710 ;; It was a group name.
12711 (setq subscribed (= (following-char) ?:)
12712 group (symbol-name symbol)
12715 ;; If the line ends here, this is clearly a buggy line, so
12716 ;; we put point a the beginning of line and let the cond
12717 ;; below do the error handling.
12718 (beginning-of-line)
12719 ;; We skip to the beginning of the ranges.
12720 (skip-chars-forward "!: \t"))
12721 ;; We are now at the beginning of the list of read articles.
12722 ;; We read them range by range.
12725 ((looking-at "[0-9]+")
12726 ;; We narrow and read a number instead of buffer-substring/
12727 ;; string-to-int because it's faster. narrow/widen is
12728 ;; faster than save-restriction/narrow, and save-restriction
12729 ;; produces a garbage object.
12731 (narrow-to-region (match-beginning 0) (match-end 0))
12734 ;; If the next character is a dash, then this is a range.
12735 (if (= (following-char) ?-)
12737 ;; We read the upper bound of the range.
12739 (if (not (looking-at "[0-9]+"))
12740 ;; This is a buggy line, by we pretend that
12741 ;; it's kinda OK. Perhaps the user should be
12743 (setq reads (cons num1 reads))
12747 (narrow-to-region (match-beginning 0)
12752 ;; It was just a simple number, so we add it to the
12754 (setq reads (cons num1 reads)))
12755 ;; If the next char in ?\n, then we have reached the end
12756 ;; of the line and return nil.
12757 (/= (following-char) ?\n))
12758 ((= (following-char) ?\n)
12759 ;; End of line, so we end.
12762 ;; Not numbers and not eol, so this might be a buggy
12764 (or (eobp) ; If it was eob instead of ?\n, we allow it.
12766 ;; The line was buggy.
12768 (gnus-message 3 "Mangled line: %s"
12769 (buffer-substring (gnus-point-at-bol)
12770 (gnus-point-at-eol)))
12774 ;; Skip past ", ". Spaces are illegal in these ranges, but
12775 ;; we allow them, because it's a common mistake to put a
12776 ;; space after the comma.
12777 (skip-chars-forward ", "))
12779 ;; We have already read .newsrc.eld, so we gently update the
12780 ;; data in the hash table with the information we have just
12784 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12787 ;; There is an entry for this file in the alist.
12789 (setcar (nthcdr 2 info) (nreverse reads))
12790 ;; We update the level very gently. In fact, we
12791 ;; only change it if there's been a status change
12792 ;; from subscribed to unsubscribed, or vice versa.
12793 (setq level (nth 1 info))
12794 (cond ((and (<= level gnus-level-subscribed)
12796 (setq level (if reads
12797 gnus-level-default-unsubscribed
12798 (1+ gnus-level-default-unsubscribed))))
12799 ((and (> level gnus-level-subscribed) subscribed)
12800 (setq level gnus-level-default-subscribed)))
12801 (setcar (cdr info) level))
12802 ;; This is a new group.
12803 (setq info (list group
12805 gnus-level-default-subscribed
12807 (1+ gnus-level-subscribed)
12808 gnus-level-default-unsubscribed))
12809 (nreverse reads))))
12810 (setq newsrc (cons info newsrc))))))
12813 (setq newsrc (nreverse newsrc))
12815 (if (not already-read)
12817 ;; We now have two newsrc lists - `newsrc', which is what we
12818 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
12819 ;; what we've read from .newsrc.eld. We have to merge these
12820 ;; lists. We do this by "attaching" any (foreign) groups in the
12821 ;; gnus-newsrc-alist to the (native) group that precedes them.
12822 (let ((rc (cdr gnus-newsrc-alist))
12823 (prev gnus-newsrc-alist)
12826 (or (null (nth 4 (car rc))) ; It's a native group.
12827 (assoc (car (car rc)) newsrc) ; It's already in the alist.
12828 (if (setq entry (assoc (car (car prev)) newsrc))
12829 (setcdr (setq mentry (memq entry newsrc))
12830 (cons (car rc) (cdr mentry)))
12831 (setq newsrc (cons (car rc) newsrc))))
12835 (setq gnus-newsrc-alist newsrc)
12836 ;; We make the newsrc hashtb.
12837 (gnus-make-hashtable-from-newsrc-alist)
12839 ;; Finally, if we read some options lines, we parse them.
12840 (or (string= gnus-newsrc-options "")
12841 (gnus-newsrc-parse-options gnus-newsrc-options))))
12843 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12844 ;; The return value will be a list on the form
12845 ;; ((regexp1 . ignore)
12846 ;; (regexp2 . subscribe)...)
12847 ;; When handling new newsgroups, groups that match a `ignore' regexp
12848 ;; will be ignored, and groups that match a `subscribe' regexp will be
12849 ;; subscribed. A line like
12850 ;; options -n !all rec.all
12851 ;; will lead to a list that looks like
12852 ;; (("^rec\\..+" . subscribe)
12853 ;; ("^.+" . ignore))
12854 ;; So all "rec.*" groups will be subscribed, while all the other
12855 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12856 ;; different from "options -n rec.all !all".
12857 (defun gnus-newsrc-parse-options (options)
12860 (gnus-set-work-buffer)
12861 (insert (regexp-quote options))
12862 ;; First we treat all continuation lines.
12863 (goto-char (point-min))
12864 (while (re-search-forward "\n[ \t]+" nil t)
12865 (replace-match " " t t))
12866 ;; Then we transform all "all"s into ".+"s.
12867 (goto-char (point-min))
12868 (while (re-search-forward "\\ball\\b" nil t)
12869 (replace-match ".+" t t))
12870 (goto-char (point-min))
12871 ;; We remove all other options than the "-n" ones.
12872 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12873 (replace-match " ")
12875 (goto-char (point-min))
12877 ;; We are only interested in "options -n" lines - we
12878 ;; ignore the other option lines.
12879 (while (re-search-forward "[ \t]-n" nil t)
12881 (or (save-excursion
12882 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12884 (gnus-point-at-eol)))
12885 ;; Search for all "words"...
12886 (while (re-search-forward "[^ \t,\n]+" eol t)
12887 (if (= (char-after (match-beginning 0)) ?!)
12888 ;; If the word begins with a bang (!), this is a "not"
12889 ;; spec. We put this spec (minus the bang) and the
12890 ;; symbol `ignore' into the list.
12891 (setq out (cons (cons (concat
12892 "^" (buffer-substring
12893 (1+ (match-beginning 0))
12896 ;; There was no bang, so this is a "yes" spec.
12897 (setq out (cons (cons (concat
12898 "^" (buffer-substring (match-beginning 0)
12900 'subscribe) out)))))
12902 (setq gnus-newsrc-options-n out))))
12905 (defun gnus-save-newsrc-file ()
12906 "Save .newsrc file."
12907 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12908 ;; from the variable gnus-newsrc-alist.
12909 (and (or gnus-newsrc-alist gnus-killed-list)
12910 gnus-current-startup-file
12912 (run-hooks 'gnus-save-newsrc-hook)
12914 (if (or (not gnus-dribble-buffer)
12915 (not (buffer-name gnus-dribble-buffer))
12916 (zerop (save-excursion
12917 (set-buffer gnus-dribble-buffer)
12919 (gnus-message 4 "(No changes need to be saved)")
12920 (if gnus-save-newsrc-file
12922 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12923 ;; Make backup file of master newsrc.
12924 (gnus-gnus-to-newsrc-format)
12925 (gnus-message 5 "Saving %s...done"
12926 gnus-current-startup-file)))
12927 ;; Quickly loadable .newsrc.
12928 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12929 (set-visited-file-name (concat gnus-current-startup-file ".eld"))
12930 (gnus-add-current-to-buffer-list)
12931 (buffer-disable-undo (current-buffer))
12933 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12934 (gnus-gnus-to-quick-newsrc-format)
12936 (kill-buffer (current-buffer))
12937 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
12938 (gnus-dribble-delete-file))))))
12940 (defun gnus-gnus-to-quick-newsrc-format ()
12941 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12942 (insert ";; (ding) Gnus startup file.\n")
12943 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12944 (insert ";; to read .newsrc.\n")
12945 (let ((variables gnus-variable-list)
12947 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12949 ;; insert lisp expressions.
12950 (gnus-compress-newsrc-alist)
12952 (setq variable (car variables))
12953 (and (boundp variable)
12954 (symbol-value variable)
12955 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12956 (insert "(setq " (symbol-name variable) " '"
12957 (prin1-to-string (symbol-value variable))
12959 (setq variables (cdr variables)))
12960 (gnus-uncompress-newsrc-alist)))
12963 (defun gnus-gnus-to-newsrc-format ()
12964 ;; Generate and save the .newsrc file.
12965 (let ((newsrc (cdr gnus-newsrc-alist))
12968 (set-buffer (create-file-buffer gnus-current-startup-file))
12969 (set-visited-file-name gnus-current-startup-file)
12970 (buffer-disable-undo (current-buffer))
12973 (if gnus-newsrc-options (insert gnus-newsrc-options))
12974 ;; Write subscribed and unsubscribed.
12976 (setq info (car newsrc))
12977 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12979 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12981 (if (setq ranges (nth 2 info))
12984 (if (not (listp (cdr ranges)))
12985 (if (= (car ranges) (cdr ranges))
12986 (insert (int-to-string (car ranges)))
12987 (insert (int-to-string (car ranges)) "-"
12988 (int-to-string (cdr ranges))))
12990 (setq range (car ranges)
12991 ranges (cdr ranges))
12992 (if (or (atom range) (= (car range) (cdr range)))
12993 (insert (int-to-string
12994 (or (and (atom range) range)
12996 (insert (int-to-string (car range)) "-"
12997 (int-to-string (cdr range))))
12998 (if ranges (insert ","))))))
13000 (setq newsrc (cdr newsrc)))
13002 (kill-buffer (current-buffer)))))
13004 (defun gnus-read-all-descriptions-files ()
13005 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13007 (gnus-read-descriptions-file (car methods))
13008 (setq methods (cdr methods)))
13011 (defun gnus-read-descriptions-file (&optional method)
13012 (let ((method (or method gnus-select-method)))
13013 ;; We create the hashtable whether we manage to read the desc file
13014 ;; to avoid trying to re-read after a failed read.
13015 (or gnus-description-hashtb
13016 (setq gnus-description-hashtb
13017 (gnus-make-hashtable (length gnus-active-hashtb))))
13018 ;; Mark this method's desc file as read.
13019 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13020 gnus-description-hashtb)
13022 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13024 ((not (or (gnus-server-opened method)
13025 (gnus-open-server method)))
13026 (gnus-message 1 "Couldn't open server")
13028 ((not (gnus-request-list-newsgroups method))
13029 (gnus-message 1 "Couldn't read newsgroups descriptions")
13035 (set-buffer nntp-server-buffer)
13036 (goto-char (point-min))
13037 (if (or (search-forward "\n.\n" nil t)
13038 (goto-char (point-max)))
13040 (beginning-of-line)
13041 (narrow-to-region (point-min) (point))))
13042 (goto-char (point-min))
13043 (while (not (eobp))
13044 ;; If we get an error, we set group to 0, which is not a
13048 (let ((obarray gnus-description-hashtb))
13049 ;; Group is set to a symbol interned in this
13051 (read nntp-server-buffer))
13053 (skip-chars-forward " \t")
13054 ;; ... which leads to this line being effectively ignored.
13055 (and (symbolp group)
13056 (set group (buffer-substring
13057 (point) (progn (end-of-line) (point)))))
13058 (forward-line 1))))
13059 (gnus-message 5 "Reading descriptions file...done")
13062 (defun gnus-group-get-description (group)
13063 ;; Get the description of a group by sending XGTITLE to the server.
13064 (and (gnus-request-group-description group)
13066 (set-buffer nntp-server-buffer)
13067 (goto-char (point-min))
13068 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13069 (buffer-substring (match-beginning 1) (match-end 1))))))
13075 (defvar gnus-server-mode-hook nil
13076 "Hook run in `gnus-server-mode' buffers.")
13078 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13079 "Format of server lines.
13080 It works along the same lines as a normal formatting string,
13081 with some simple extensions.")
13083 (defvar gnus-server-mode-line-format "(ding) List of servers"
13084 "The format specification for the server mode line.")
13086 (defconst gnus-server-line-format-alist
13087 (list (list ?h 'how ?s)
13089 (list ?w 'where ?s)
13092 (defconst gnus-server-mode-line-format-alist
13093 (list (list ?S 'news-server ?s)
13094 (list ?M 'news-method ?s)
13095 (list ?u 'user-defined ?s)))
13097 (defvar gnus-server-line-format-spec nil)
13098 (defvar gnus-server-mode-line-format-spec nil)
13099 (defvar gnus-server-killed-servers nil)
13101 (defvar gnus-server-mode-map nil)
13102 (put 'gnus-server-mode 'mode-class 'special)
13104 (if gnus-server-mode-map
13106 (setq gnus-server-mode-map (make-sparse-keymap))
13107 (suppress-keymap gnus-server-mode-map)
13108 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13109 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13110 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13111 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13112 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13113 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13114 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13115 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13116 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13117 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13119 (defun gnus-server-mode ()
13120 "Major mode for listing and editing servers.
13122 All normal editing commands are switched off.
13123 \\<gnus-server-mode-map>
13125 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13127 The following commands are available:
13129 \\{gnus-server-mode-map}"
13131 (if gnus-visual (gnus-server-make-menu-bar))
13132 (kill-all-local-variables)
13133 (setq mode-line-modified "-- ")
13134 (make-local-variable 'mode-line-format)
13135 (setq mode-line-format (copy-sequence mode-line-format))
13136 (and (equal (nth 3 mode-line-format) " ")
13137 (setcar (nthcdr 3 mode-line-format) ""))
13138 (setq major-mode 'gnus-server-mode)
13139 (setq mode-name "Server")
13140 ; (gnus-group-set-mode-line)
13141 (setq mode-line-process nil)
13142 (use-local-map gnus-server-mode-map)
13143 (buffer-disable-undo (current-buffer))
13144 (setq truncate-lines t)
13145 (setq buffer-read-only t)
13146 (run-hooks 'gnus-server-mode-hook))
13148 (defun gnus-server-insert-server-line (sformat name method)
13149 (let* ((sformat (or sformat gnus-server-line-format-spec))
13151 (where (nth 1 method))
13153 (beginning-of-line)
13155 ;; Insert the text.
13156 (insert (eval sformat))
13157 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13159 (defun gnus-server-setup-buffer ()
13160 (if (get-buffer gnus-server-buffer)
13163 (set-buffer (get-buffer-create gnus-server-buffer))
13165 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13167 (defun gnus-server-prepare ()
13168 (setq gnus-server-mode-line-format-spec
13169 (gnus-parse-format gnus-server-mode-line-format
13170 gnus-server-mode-line-format-alist))
13171 (setq gnus-server-line-format-spec
13172 (gnus-parse-format gnus-server-line-format
13173 gnus-server-line-format-alist))
13174 (let ((alist gnus-server-alist)
13175 (buffer-read-only nil))
13178 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13179 (setq alist (cdr alist))))
13180 (goto-char (point-min))
13181 (gnus-server-position-cursor))
13183 (defun gnus-server-server-name ()
13184 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13185 (and server (symbol-name server))))
13187 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13189 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13191 (defun gnus-server-update-server (server)
13193 (set-buffer gnus-server-buffer)
13194 (let ((buffer-read-only nil)
13195 (info (cdr (assoc server gnus-server-alist))))
13196 (gnus-dribble-enter
13197 (concat "(gnus-server-set-info \"" server "\" '"
13198 (prin1-to-string info) ")"))
13199 ;; Buffer may be narrowed.
13202 (if (gnus-server-goto-server server)
13203 (delete-region (progn (beginning-of-line) (point))
13204 (progn (forward-line 1) (point))))
13205 (let ((entry (assoc server gnus-server-alist)))
13206 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13207 (gnus-server-position-cursor))))))
13209 (defun gnus-server-set-info (server info)
13210 ;; Enter a select method into the virtual server alist.
13211 (gnus-dribble-enter
13212 (concat "(gnus-server-set-info \"" server "\" '"
13213 (prin1-to-string info) ")"))
13214 (let* ((server (nth 1 info))
13215 (entry (assoc server gnus-server-alist)))
13216 (if entry (setcdr entry info)
13217 (setq gnus-server-alist
13218 (nconc gnus-server-alist (list (cons server info)))))))
13220 (defun gnus-server-to-method (server)
13221 ;; Map virtual server names to select methods.
13222 (or (and (equal server "native") gnus-select-method)
13223 (cdr (assoc server gnus-server-alist))))
13225 (defun gnus-server-extend-method (group method)
13226 ;; This function "extends" a virtual server. If the server is
13227 ;; "hello", and the select method is ("hello" (my-var "something"))
13228 ;; in the group "alt.alt", this will result in a new virtual server
13229 ;; called "helly+alt.alt".
13231 (gnus-copy-sequence
13232 (if (equal (car method) "native") gnus-select-method
13233 (cdr (assoc (car method) gnus-server-alist))))))
13234 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13235 (nconc entry (cdr method))))
13237 (defun gnus-server-get-method (group method)
13238 ;; Input either a server name, and extended server name, or a
13239 ;; select method, and return a select method.
13240 (cond ((stringp method)
13241 (gnus-server-to-method method))
13242 ((stringp (car method))
13243 (gnus-server-extend-method group method))
13245 (gnus-server-add-address method))))
13247 (defun gnus-server-add-address (method)
13248 (let ((method-name (symbol-name (car method))))
13249 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13250 (not (assq (intern (concat method-name "-address")) method)))
13251 (append method (list (list (intern (concat method-name "-address"))
13255 (defun gnus-server-equal (s1 s2)
13257 (and (= (length s1) (length s2))
13259 (while (and s1 (member (car s1) s2))
13260 (setq s1 (cdr s1)))
13263 ;;; Interactive server functions.
13265 (defun gnus-server-kill-server (server)
13266 "Kill the server on the current line."
13267 (interactive (list (gnus-server-server-name)))
13268 (or (gnus-server-goto-server server)
13269 (if server (error "No such server: %s" server)
13270 (error "No server on the current line")))
13271 (let ((buffer-read-only nil))
13272 (delete-region (progn (beginning-of-line) (point))
13273 (progn (forward-line 1) (point))))
13274 (setq gnus-server-killed-servers
13275 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13276 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13277 gnus-server-alist))
13278 (gnus-server-position-cursor))
13280 (defun gnus-server-yank-server ()
13281 "Yank the previously killed server."
13283 (or gnus-server-killed-servers
13284 (error "No killed servers to be yanked"))
13285 (let ((alist gnus-server-alist)
13286 (server (gnus-server-server-name))
13287 (killed (car gnus-server-killed-servers)))
13289 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13290 (if (string= server (car (car gnus-server-alist)))
13291 (setq gnus-server-alist (cons killed gnus-server-alist))
13292 (while (and (cdr alist)
13293 (not (string= server (car (car (cdr alist))))))
13294 (setq alist (cdr alist)))
13295 (setcdr alist (cons killed (cdr alist)))))
13296 (gnus-server-update-server (car killed))
13297 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13298 (gnus-server-position-cursor)))
13300 (defun gnus-server-exit ()
13301 "Return to the group buffer."
13303 (kill-buffer (current-buffer))
13304 (switch-to-buffer gnus-group-buffer))
13306 (defun gnus-server-list-servers ()
13307 "List all available servers."
13309 (let ((cur (gnus-server-server-name)))
13310 (gnus-server-prepare)
13311 (if cur (gnus-server-goto-server cur)
13312 (goto-char (point-max))
13314 (gnus-server-position-cursor)))
13316 (defun gnus-server-copy-server (from to)
13319 (or (gnus-server-server-name)
13320 (error "No server on the current line"))
13321 (read-string "Copy to: ")))
13322 (or from (error "No server on current line"))
13323 (or (and to (not (string= to ""))) (error "No name to copy to"))
13324 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13325 (or (assoc from gnus-server-alist)
13326 (error "%s: no such server" from))
13327 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13328 (setcar to-entry to)
13329 (setcar (nthcdr 2 to-entry) to)
13330 (setq gnus-server-killed-servers
13331 (cons to-entry gnus-server-killed-servers))
13332 (gnus-server-yank-server)))
13334 (defun gnus-server-add-server (how where)
13336 (list (intern (completing-read "Server method: "
13337 gnus-valid-select-methods nil t))
13338 (read-string "Server name: ")))
13339 (setq gnus-server-killed-servers
13340 (cons (list where how where) gnus-server-killed-servers))
13341 (gnus-server-yank-server))
13343 (defun gnus-server-goto-server (server)
13344 "Jump to a server line."
13346 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13347 (let ((to (text-property-any (point-min) (point-max)
13348 'gnus-server (intern server))))
13352 (gnus-server-position-cursor)))))
13354 (defun gnus-server-edit-server (server)
13355 "Edit the server on the current line."
13356 (interactive (list (gnus-server-server-name)))
13358 (error "No server on current line"))
13359 (let ((winconf (current-window-configuration)))
13360 (get-buffer-create gnus-server-edit-buffer)
13361 (gnus-configure-windows 'edit-server)
13362 (gnus-add-current-to-buffer-list)
13364 (make-local-variable 'gnus-prev-winconf)
13365 (setq gnus-prev-winconf winconf)
13366 (use-local-map (copy-keymap (current-local-map)))
13367 (let ((done-func '(lambda ()
13368 "Exit editing mode and update the information."
13370 (gnus-server-edit-server-done 'group))))
13371 (setcar (cdr (nth 4 done-func)) server)
13372 (local-set-key "\C-c\C-c" done-func))
13374 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13375 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13377 (defun gnus-server-edit-server-done (server)
13379 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13380 (goto-char (point-min))
13381 (let ((form (read (current-buffer)))
13382 (winconf gnus-prev-winconf))
13383 (gnus-server-set-info server form)
13384 (kill-buffer (current-buffer))
13385 (and winconf (set-window-configuration winconf))
13386 (set-buffer gnus-server-buffer)
13387 (gnus-server-update-server (gnus-server-server-name))
13388 (gnus-server-position-cursor)))
13390 (defun gnus-server-read-server (server)
13392 (interactive (list (gnus-server-server-name)))
13393 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13395 (defun gnus-mouse-pick-server (e)
13397 (mouse-set-point e)
13398 (gnus-server-read-server (gnus-server-server-name)))
13401 ;;; entry points into gnus-score.el
13404 ;;; Finding score files.
13406 (defvar gnus-global-score-files nil
13407 "*List of global score files and directories.
13408 Set this variable if you want to use people's score files. One entry
13409 for each score file or each score file directory. Gnus will decide
13410 by itself what score files are applicable to which group.
13412 Say you want to use the single score file
13413 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13414 score files in the \"/ftp.some-where:/pub/score\" directory.
13416 (setq gnus-global-score-files
13417 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13418 \"/ftp.some-where:/pub/score\"))")
13420 (defun gnus-score-score-files (group)
13421 "Return a list of all possible score files."
13422 ;; Search and set any global score files.
13423 (and gnus-global-score-files
13424 (or gnus-internal-global-score-files
13425 (gnus-score-search-global-directories gnus-global-score-files)))
13426 ;; Fix the kill-file dir variable.
13427 (setq gnus-kill-files-directory
13428 (file-name-as-directory
13429 (or gnus-kill-files-directory "~/News/")))
13430 ;; If we can't read it, there are no score files.
13431 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13432 (setq gnus-score-file-list nil)
13433 (if (gnus-use-long-file-name 'not-score)
13434 ;; We want long file names.
13435 (if (or (not gnus-score-file-list)
13436 (not (car gnus-score-file-list))
13437 (gnus-file-newer-than gnus-kill-files-directory
13438 (car gnus-score-file-list)))
13439 (setq gnus-score-file-list
13440 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13443 gnus-kill-files-directory t
13444 (gnus-score-file-regexp))))))
13445 ;; We do not use long file names, so we have to do some
13446 ;; directory traversing.
13447 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13448 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13451 (setq dir (expand-file-name
13452 (concat gnus-kill-files-directory
13453 (gnus-replace-chars-in-string group ?. ?/))))
13454 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13455 (setq suffix (car suffixes)
13456 suffixes (cdr suffixes))
13457 (if (file-exists-p (concat dir "/" suffix))
13458 (setq files (cons (concat dir "/" suffix) files)))
13459 (while (>= (1+ (length dir)) mdir)
13460 (and (file-exists-p (concat dir "/all/" suffix))
13461 (setq files (cons (concat dir "/all/" suffix) files)))
13462 (string-match "/[^/]*$" dir)
13463 (setq dir (substring dir 0 (match-beginning 0)))))
13464 (setq gnus-score-file-list
13465 (cons nil (nreverse files)))))
13466 (cdr gnus-score-file-list)))
13468 (defun gnus-score-file-regexp ()
13469 (concat "\\(" gnus-score-file-suffix
13470 "\\|" gnus-adaptive-file-suffix "\\)$"))
13472 (defun gnus-score-find-bnews (group)
13473 "Return a list of score files for GROUP.
13474 The score files are those files in the ~/News directory which matches
13475 GROUP using BNews sys file syntax."
13476 (let* ((sfiles (append (gnus-score-score-files group)
13477 gnus-internal-global-score-files))
13478 (kill-dir (file-name-as-directory
13479 (expand-file-name gnus-kill-files-directory)))
13480 (klen (length kill-dir))
13481 ofiles not-match regexp)
13483 (set-buffer (get-buffer-create "*gnus score files*"))
13484 (buffer-disable-undo (current-buffer))
13485 ;; Go through all score file names and create regexp with them
13489 (insert (car sfiles))
13490 (goto-char (point-min))
13491 ;; First remove the suffix itself.
13492 (re-search-forward (concat "." (gnus-score-file-regexp)))
13493 (replace-match "" t t)
13494 (goto-char (point-min))
13495 (if (looking-at (regexp-quote kill-dir))
13496 ;; If the file name was just "SCORE", `klen' is one character
13498 (delete-char (min (1- (point-max)) klen))
13499 (goto-char (point-max))
13500 (search-backward "/")
13501 (delete-region (1+ (point)) (point-min)))
13502 ;; If short file names were used, we have to translate slashes.
13503 (goto-char (point-min))
13504 (while (re-search-forward "[/:]" nil t)
13505 (replace-match "." t t))
13506 ;; Translate "all" to ".*".
13507 (while (search-forward "all" nil t)
13508 (replace-match ".*" t t))
13509 (goto-char (point-min))
13510 ;; Deal with "not."s.
13511 (if (looking-at "not.")
13514 (setq regexp (buffer-substring 5 (point-max))))
13515 (setq regexp (buffer-substring 1 (point-max)))
13516 (setq not-match nil))
13517 ;; Finally - if this resulting regexp matches the group name,
13518 ;; we add this score file to the list of score files
13519 ;; applicable to this group.
13520 (if (or (and not-match
13521 (not (string-match regexp group)))
13522 (and (not not-match)
13523 (string-match regexp group)))
13524 (setq ofiles (cons (car sfiles) ofiles)))
13525 (setq sfiles (cdr sfiles)))
13526 (kill-buffer (current-buffer))
13527 ;; Slight kludge here - the last score file returned should be
13528 ;; the local score file, whether it exists or not. This is so
13529 ;; that any score commands the user enters will go to the right
13530 ;; file, and not end up in some global score file.
13533 (if (gnus-use-long-file-name 'not-score)
13534 (concat gnus-kill-files-directory group "."
13535 gnus-score-file-suffix)
13536 (concat gnus-kill-files-directory
13537 (gnus-replace-chars-in-string group ?. ?/)
13538 "/" gnus-score-file-suffix)))))
13539 (and (member localscore ofiles)
13540 (delete localscore ofiles))
13541 (setq ofiles (cons localscore ofiles)))
13542 (nreverse ofiles))))
13544 (defun gnus-score-find-single (group)
13545 "Return list containing the score file for GROUP."
13546 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13547 (gnus-score-file-name group)))
13549 (defun gnus-score-find-hierarchical (group)
13550 "Return list of score files for GROUP.
13551 This includes the score file for the group and all its parents."
13552 (let ((all (copy-sequence '(nil)))
13554 (while (string-match "\\." group (1+ start))
13555 (setq start (match-beginning 0))
13556 (setq all (cons (substring group 0 start) all)))
13557 (setq all (cons group all))
13559 (mapcar (lambda (newsgroup)
13560 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
13561 (setq all (nreverse all)))
13562 (mapcar 'gnus-score-file-name all))))
13564 (defvar gnus-score-file-alist-cache nil)
13566 (defun gnus-score-find-alist (group)
13567 "Return list of score files for GROUP.
13568 The list is determined from the variable gnus-score-file-alist."
13569 (let ((alist gnus-score-file-multiple-match-alist)
13571 ;; if this group has been seen before, return the cached entry
13572 (if (setq score-files (assoc group gnus-score-file-alist-cache))
13573 (cdr score-files) ; ensures caching of groups with no matches
13574 ;; handle the multiple match alist
13576 (and (string-match (car (car alist)) group)
13578 (nconc score-files (cdr (car alist)))))
13579 (setq alist (cdr alist)))
13580 (setq alist gnus-score-file-single-match-alist)
13581 ;; handle the single match alist
13584 (and (string-match (car (car alist)) group)
13585 ;; progn used just in case ("regexp") has no files
13586 ;; and score-files is still nil. -sj
13587 ;; this can be construed as a "stop searching here" feature :>
13588 ;; and used to simplify regexps in the single-alist
13591 (append score-files (cdr (car alist))))
13592 (throw 'done nil)))
13593 (setq alist (cdr alist))))
13594 ;; cache the score files
13595 (setq gnus-score-file-alist-cache
13596 (cons (cons group score-files) gnus-score-file-alist-cache))
13600 (defun gnus-possibly-score-headers (&optional trace)
13601 (let ((func gnus-score-find-score-files-function)
13603 (and func (not (listp func))
13604 (setq func (list func)))
13605 ;; Go through all the functions for finding score files (or actual
13606 ;; scores) and add them to a list.
13607 (setq score-files (copy-sequence
13608 (gnus-score-find-alist gnus-newsgroup-name)))
13610 (and (symbolp (car func))
13611 (fboundp (car func))
13613 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
13614 (setq func (cdr func)))
13615 (if score-files (gnus-score-headers score-files trace))))
13617 (defun gnus-score-file-name (newsgroup &optional suffix)
13618 "Return the name of a score file for NEWSGROUP."
13619 (let ((suffix (or suffix gnus-score-file-suffix)))
13620 (cond ((or (null newsgroup)
13621 (string-equal newsgroup ""))
13622 ;; The global score file is placed at top of the directory.
13624 suffix (or gnus-kill-files-directory "~/News")))
13625 ((gnus-use-long-file-name 'not-score)
13626 ;; Append ".SCORE" to newsgroup name.
13627 (expand-file-name (concat newsgroup "." suffix)
13628 (or gnus-kill-files-directory "~/News")))
13630 ;; Place "SCORE" under the hierarchical directory.
13631 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13633 (or gnus-kill-files-directory "~/News"))))))
13635 (defun gnus-score-search-global-directories (files)
13636 "Scan all global score directories for score files."
13637 ;; Set the variable `gnus-internal-global-score-files' to all
13638 ;; available global score files.
13639 (interactive (list gnus-global-score-files))
13642 (if (string-match "/$" (car files))
13643 (setq out (nconc (directory-files
13645 (concat (gnus-score-file-regexp) "$"))))
13646 (setq out (cons (car files) out)))
13647 (setq files (cdr files)))
13648 (setq gnus-internal-global-score-files out)))
13650 ;; Allow redefinition of Gnus functions.
13652 (gnus-ems-redefine)
13656 ;;; gnus.el ends here