1 ;;; (ding) Gnus --- 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
67 In any case, if the string (either in the variable, in the environment
68 variable, or returned by the function) is a file name, the contents of
69 this file will be used as the organization.")
71 (defvar gnus-use-generic-from nil
72 "If nil, the full host name will be the system name prepended to the domain name.
73 If this is a string, the full host name will be this string.
74 If this is non-nil, non-string, the domain name will be used as the
77 (defvar gnus-use-generic-path nil
78 "If nil, use the NNTP server name in the Path header.
79 If stringp, use this; if non-nil, use no host name (user name only).")
82 ;; Customization variables
84 (defvar gnus-select-method
85 (list 'nntp (or (getenv "NNTPSERVER")
86 (if (and gnus-default-nntp-server
87 (not (string= gnus-default-nntp-server "")))
88 gnus-default-nntp-server)
90 "*Default method for selecting a newsgroup.
91 This variable should be a list, where the first element is how the
92 news is to be fetched, the second is the address.
94 For instance, if you want to get your news via NNTP from
95 \"flab.flab.edu\", you could say:
97 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
99 If you want to use your local spool, say:
101 (setq gnus-select-method (list 'nnspool (system-name)))
103 If you use this variable, you must set `gnus-nntp-server' to nil.
105 There is a lot more to know about select methods and virtual servers -
106 see the manual for details.")
108 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
109 (defvar gnus-post-method nil
110 "*Preferred method for posting USENET news.
111 If this variable is nil, Gnus will use the current method to decide
112 which method to use when posting. If it is non-nil, it will override
113 the current method. This method will not be used in mail groups and
114 the like, only in \"real\" newsgroups.
116 The value must be a valid method as discussed in the documentation of
117 `gnus-select-method'.")
119 (defvar gnus-refer-article-method nil
120 "*Preferred method for fetching an article by Message-ID.
121 If you are reading news from the local spool (with nnspool), fetching
122 articles by Message-ID is painfully slow. By setting this method to an
123 nntp method, you might get acceptable results.
125 The value of this variable must be a valid select method as discussed
126 in the documentation of `gnus-select-method'")
128 (defvar gnus-secondary-select-methods nil
129 "*A list of secondary methods that will be used for reading news.
130 This is a list where each element is a complete select methdod (see
131 `gnus-select-method').
133 If, for instance, you want to read your mail with the nnml backend,
134 you could set this variable:
136 (setq gnus-secondary-select-methods '((nnml \"\"))")
138 (defvar gnus-secondary-servers nil
139 "*List of NNTP servers that the user can choose between interactively.
140 To make Gnus query you for a server, you have to give `gnus' a
141 non-numeric prefix - `C-u M-x gnus', in short.")
143 (defvar gnus-nntp-server nil
144 "*The name of the host running the NNTP server.
145 This variable is semi-obsolete. Use the `gnus-select-method'
148 (defvar gnus-nntp-service "nntp"
149 "*NNTP service name (\"nntp\" or 119).
150 This is an obsolete variable, which is scarcely used. If you use an
151 nntp server for your newsgroup and want to change the port number
152 used to 899, you would say something along these lines:
154 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
156 (defvar gnus-startup-file "~/.newsrc"
157 "*Your `.newsrc' file.
158 `.newsrc-SERVER' will be used instead if that exists.")
160 (defvar gnus-signature-file "~/.signature"
161 "*Your signature file.
162 If the variable is a string that doesn't correspond to a file, the
163 string itself is inserted.")
165 (defvar gnus-signature-function nil
166 "*A function that should return a signature file name.
167 The function will be called with the name of the newsgroup being
169 If the function returns a string that doesn't correspond to a file, the
170 string itself is inserted.
171 If the function returns nil, the `gnus-signature-file' variable will
174 (defvar gnus-init-file "~/.gnus"
175 "*Your Gnus elisp startup file.
176 If a file with the .el or .elc suffixes exist, it will be read
179 (defvar gnus-group-faq-directory
180 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
181 "*Directory where the group FAQs are stored.
182 This will most commonly be on a remote machine, and the file will be
183 fetched by ange-ftp.")
185 (defvar gnus-group-archive-directory
186 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
187 "*The address of the (ding) archives.")
189 (defvar gnus-default-subscribed-newsgroups nil
190 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
191 It should be a list of strings.
192 If it is `t', Gnus will not do anything special the first time it is
193 started; it'll just use the normal newsgroups subscription methods.")
195 (defvar gnus-post-prepare-function nil
196 "*Function that is run after a post buffer has been prepared.
197 It is called with the name of the newsgroup that is posted to. It
198 might be used, for instance, for inserting signatures based on the
199 newsgroup name. (In that case, `gnus-signature-file' and
200 `mail-signature' should both be set to nil).")
202 (defvar gnus-use-cross-reference t
203 "*Non-nil means that cross referenced articles will be marked as read.
204 If nil, ignore cross references. If t, mark articles as read in
205 subscribed newsgroups. If neither t nor nil, mark as read in all
208 (defvar gnus-use-dribble-file t
209 "*Non-nil means that Gnus will use a dribble file to store user updates.
210 If Emacs should crash without saving the .newsrc files, complete
211 information can be restored from the dribble file.")
213 (defvar gnus-use-followup-to 'use
214 "*Specifies what to do with Followup-To header.
215 If nil, ignore the header. If it is t, use its value, but ignore
216 `poster'. If it is neither nil nor t, which is the default, always use
219 (defvar gnus-followup-to-function nil
220 "*A variable that contains a function that returns a followup address.
221 The function will be called in the buffer of the article that is being
222 followed up. The buffer will be narrowed to the headers of the
223 article. To pick header headers, one might use `mail-fetch-field'. The
224 function will be called with the name of the current newsgroup as the
227 Here's an example `gnus-followup-to-function':
229 (setq gnus-followup-to-function
231 (cond ((string= group \"mail.list\")
232 (or (mail-fetch-field \"sender\")
233 (mail-fetch-field \"from\")))
235 (or (mail-fetch-field \"reply-to\")
236 (mail-fetch-field \"from\"))))))")
238 (defvar gnus-reply-to-function nil
239 "*A variable that contains a function that returns a reply address.
240 See the `gnus-followup-to-function' variable for an explanation of how
241 this variable is used.
243 This function should return a string that will be used to fill in the
244 header. This function may also return a list. In that case, every
245 list element should be a cons where the first car should be a string
246 with the header name, and the cdr should be a string with the header
249 (defvar gnus-asynchronous nil
250 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
252 (defvar gnus-asynchronous-article-function nil
253 "*Function for picking articles to pre-fetch, possibly.")
255 (defvar gnus-large-newsgroup 200
256 "*The number of articles which indicates a large newsgroup.
257 If the number of articles in a newsgroup is greater than this value,
258 confirmation is required for selecting the newsgroup.")
260 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
261 (defvar gnus-no-groups-message "No news is horrible news"
262 "*Message displayed by Gnus when no groups are available.")
264 (defvar gnus-author-copy (getenv "AUTHORCOPY")
265 "*Save outgoing articles in this file.
266 Initialized from the AUTHORCOPY environment variable.
268 If this variable begins with the character \"|\", outgoing articles
269 will be piped to the named program. It is possible to save an article
270 in an MH folder as follows:
272 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
274 If the first character is not a pipe, articles are saved using the
275 function specified by the `gnus-author-copy-saver' variable.")
277 (defvar gnus-mail-self-blind nil
278 "*Non-nil means insert a BCC header in all outgoing articles.
279 This will result in having a copy of the article mailed to yourself.
280 The BCC header is inserted when the post buffer is initialized, so you
281 can remove or alter the BCC header to override the default.")
283 (defvar gnus-author-copy-saver (function rmail-output)
284 "*A function called to save outgoing articles.
285 This function will be called with the same of the file to store the
286 article in. The default function is `rmail-output' which saves in Unix
289 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
290 "*Non-nil means that the default name of a file to save articles in is the group name.
291 If it's nil, the directory form of the group name is used instead.
293 If this variable is a list, and the list contains the element
294 `not-score', long file names will not be used for score files; if it
295 contains the element `not-save', long file names will not be used for
296 saving; and if it contains the element `not-kill', long file names
297 will not be used for kill files.")
299 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
300 "*Name of the directory articles will be saved in (default \"~/News\").
301 Initialized from the SAVEDIR environment variable.")
303 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
304 "*Name of the directory where kill files will be stored (default \"~/News\").
305 Initialized from the SAVEDIR environment variable.")
307 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
308 "*A function to save articles in your favorite format.
309 The function must be interactively callable (in other words, it must
310 be an Emacs command).
312 Gnus provides the following functions:
314 * gnus-summary-save-in-rmail (Rmail format)
315 * gnus-summary-save-in-mail (Unix mail format)
316 * gnus-summary-save-in-folder (MH folder)
317 * gnus-summary-save-in-file (article format).")
319 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
320 "*A function generating a file name to save articles in Rmail format.
321 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
323 (defvar gnus-mail-save-name (function gnus-plain-save-name)
324 "*A function generating a file name to save articles in Unix mail format.
325 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
327 (defvar gnus-folder-save-name (function gnus-folder-save-name)
328 "*A function generating a file name to save articles in MH folder.
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
331 (defvar gnus-file-save-name (function gnus-numeric-save-name)
332 "*A function generating a file name to save articles in article format.
333 The function is called with NEWSGROUP, HEADERS, and optional
336 (defvar gnus-split-methods nil
337 "*Variable used to suggest where articles are to be saved.
338 The syntax of this variable is the same as `nnmail-split-methods'.
340 For instance, if you would like to save articles related to Gnus in
341 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
342 you could set this variable to something like:
344 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
345 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
347 (defvar gnus-score-interactive-default-score 1000
348 "*Scoring commands will raise/lower the score with this number as the default.")
350 (defvar gnus-save-score nil
351 "*If non-nil, save group scoring info.")
353 (defvar gnus-score-file-suffix "SCORE"
354 "*Suffix of the score files.")
356 (defvar gnus-use-adaptive-scoring nil
357 "*If non-nil, use some adaptive scoring scheme.")
359 (defvar gnus-fetch-old-headers nil
360 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
361 If an unread article in the group refers to an older, already read (or
362 just marked as read) article, the old article will not normally be
363 displayed in the Summary buffer. If this variable is non-nil, Gnus
364 will attempt to grab the headers to the old articles, and thereby
365 build complete threads. If it has the value `some', only enough
366 headers to connect otherwise loose threads will be displayed.
368 The server has to support XOVER for any of this to work.")
370 (defvar gnus-visual t
371 "*If non-nil, will do various highlighting.
372 If nil, no mouse highlights (or any other highlights) will be
373 performed. This might speed up Gnus some when generating large group
374 and summary buffers.")
376 (defvar gnus-novice-user t
377 "*Non-nil means that you are a usenet novice.
378 If non-nil, verbose messages may be displayed and confirmations may be
381 (defvar gnus-expert-user nil
382 "*Non-nil means that you will never be asked for confirmation about anything.
383 And that means *anything*.")
385 (defvar gnus-keep-same-level nil
386 "*Non-nil means that the next newsgroup after the current will be on the same level.
387 When you type, for instance, `n' after reading the last article in the
388 current newsgroup, you will go to the next newsgroup. If this variable
389 is nil, the next newsgroup will be the next from the group
391 If this variable is non-nil, Gnus will either put you in the
392 next newsgroup with the same level, or, if no such newsgroup is
393 available, the next newsgroup with the lowest possible level higher
394 than the current level.
395 If this variable is `best', Gnus will make the next newsgroup the one
396 with the best level.")
398 (defvar gnus-summary-make-false-root 'adopt
399 "*nil means that Gnus won't gather loose threads.
400 If the root of a thread has expired or been read in a previous
401 session, the information necessary to build a complete thread has been
402 lost. Instead of having many small sub-threads from this original thread
403 scattered all over the summary buffer, Gnus can gather them.
405 If non-nil, Gnus will try to gather all loose sub-threads from an
406 original thread into one large thread.
408 If this variable is non-nil, it should be one of `none', `adopt',
411 If this variable is `none', Gnus will not make a false root, but just
412 present the sub-threads after another.
413 If this variable is `dummy', Gnus will create a dummy root that will
414 have all the sub-threads as children.
415 If this variable is `adopt', Gnus will make one of the \"children\"
416 the parent and mark all the step-children as such.
417 If this variable is `empty', the \"children\" are printed with empty
418 subject fields. (Or rather, they will be printed with a string
419 given by the `gnus-summary-same-subject' variable.)")
421 (defvar gnus-summary-gather-subject-limit nil
422 "*Maximum length of subject comparisons when gathering loose threads.
423 Use nil to compare full subjects. Setting this variable to a low
424 number will help gather threads that have been corrupted by
425 newsreaders chopping off subject lines, but it might also mean that
426 unrelated articles that have subject that happen to begin with the
427 same few characters will be incorrectly gathered.
429 If this variable is `fuzzy', Gnus will use a fuzzy algortihm when
430 comparing subjects.")
432 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
433 (defvar gnus-summary-same-subject ""
434 "*String indicating that the current article has the same subject as the previous.
435 This variable will only be used if the value of
436 `gnus-summary-make-false-root' is `empty'.")
438 (defvar gnus-summary-goto-unread nil
439 "*If non-nil, marking commands will go to the next unread article.")
441 (defvar gnus-check-new-newsgroups t
442 "*Non-nil means that Gnus will add new newsgroups at startup.
443 If this variable is `ask-server', Gnus will ask the server for new
444 groups since the last time it checked. This means that the killed list
445 is no longer necessary, so you could set `gnus-save-killed-list' to
448 A variant is to have this variable be a list of select methods. Gnus
449 will then use the `ask-server' method on all these select methods to
450 query for new groups from all those servers.
453 (setq gnus-check-new-newsgroups
454 '((nntp \"some.server\") (nntp \"other.server\")))
456 If this variable is nil, then you have to tell Gnus explicitly to
457 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
459 (defvar gnus-check-bogus-newsgroups nil
460 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
461 If this variable is nil, then you have to tell Gnus explicitly to
462 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
464 (defvar gnus-read-active-file t
465 "*Non-nil means that Gnus will read the entire active file at startup.
466 If this variable is nil, Gnus will only know about the groups in your
469 If this variable is `some', Gnus will try to only read the relevant
470 parts of the active file from the server. Not all servers support
471 this, and it might be quite slow with other servers, but this should
472 generally be faster than both the t and nil value.
474 If you set this variable to nil or `some', you probably still want to
475 be told about new newsgroups that arrive. To do that, set
476 `gnus-check-new-newsgroups' to `ask-server'. This may not work
477 properly with all servers.")
479 (defvar gnus-level-subscribed 5
480 "*Groups with levels less than or equal to this variable are subscribed.")
482 (defvar gnus-level-unsubscribed 7
483 "*Groups with levels less than or equal to this variable are unsubscribed.
484 Groups with levels less than `gnus-level-subscribed', which should be
485 less than thiss variable, are subscribed.")
487 (defvar gnus-level-zombie 8
488 "*Groups with this level are zombie groups.")
490 (defvar gnus-level-killed 9
491 "*Groups with this level are killed.")
493 (defvar gnus-level-default-subscribed 3
494 "*New subscribed groups will be subscribed at this level.")
496 (defvar gnus-level-default-unsubscribed 6
497 "*New unsubscribed groups will be unsubscribed at this level.")
499 (defvar gnus-activate-foreign-newsgroups nil
500 "*If nil, Gnus will not check foreign newsgroups at startup.
501 If it is non-nil, it should be a number between one and nine. Foreign
502 newsgroups that have a level lower or equal to this number will be
503 activated on startup. For instance, if you want to active all
504 subscribed newsgroups, but not the rest, you'd set this variable to
505 `gnus-level-subscribed'.
507 If you subscribe to lots of newsgroups from different servers, startup
508 might take a while. By setting this variable to nil, you'll save time,
509 but you won't be told how many unread articles there are in the
512 (defvar gnus-save-newsrc-file t
513 "*Non-nil means that Gnus will save the `.newsrc' file.
514 Gnus always saves its own startup file, which is called
515 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
516 be readily understood by other newsreaders. If you don't plan on
517 using other newsreaders, set this variable to nil to save some time on
520 (defvar gnus-save-killed-list t
521 "*If non-nil, save the list of killed groups to the startup file.
522 This will save both time (when starting and quitting) and space (both
523 memory and disk), but it will also mean that Gnus has no record of
524 which groups are new and which are old, so the automatic new
525 newsgroups subscription methods become meaningless. You should always
526 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
529 (defvar gnus-interactive-catchup t
530 "*If non-nil, require your confirmation when catching up a group.")
532 (defvar gnus-interactive-post t
533 "*If non-nil, group name will be asked for when posting.")
535 (defvar gnus-interactive-exit t
536 "*If non-nil, require your confirmation when exiting Gnus.")
538 (defvar gnus-kill-killed nil
539 "*If non-nil, Gnus will apply kill files to already killed articles.
540 If it is nil, Gnus will never apply kill files to articles that have
541 already been through the scoring process, which might very well save lots
544 (defvar gnus-extract-address-components 'gnus-extract-address-components
545 "*Function for extracting address components from a From header.
546 Two pre-defined function exist: `gnus-extract-address-components',
547 which is the default, quite fast, and too simplistic solution, and
548 `mail-extract-address-components', which works much better, but is
551 (defvar gnus-summary-default-score 0
552 "*Default article score level.
553 If this variable is nil, scoring will be disabled.")
555 (defvar gnus-group-default-list-level gnus-level-subscribed
556 "*Default listing level.")
558 (defvar gnus-group-always-list-unread gnus-level-subscribed
559 "*Always list groups less than this variable with unread articles.
560 If nil, use parameter to specify.")
562 (defvar gnus-user-login-name nil
563 "*The login name of the user.
564 Got from the function `user-login-name' if undefined.")
566 (defvar gnus-user-full-name nil
567 "*The full name of the user.
568 Got from the NAME environment variable if undefined.")
570 (defvar gnus-user-from-line nil
571 "*Your full, complete e-mail address.
572 Overrides the other Gnus variables if it is non-nil.
574 Here are two example values of this variable:
576 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
580 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
582 The first version is recommended, but the name has to be quoted if it
583 contains non-alphanumerical characters.")
585 (defvar gnus-show-mime nil
586 "*If non-ni, do mime processing of articles.
587 The articles will simply be fed to the function given by
588 `gnus-show-mime-method'.")
590 (defvar gnus-show-mime-method (function metamail-buffer)
591 "*Function to process a MIME message.
592 The function is called from the article buffer.")
594 (defvar gnus-show-threads t
595 "*If non-nil, display threads in summary mode.")
597 (defvar gnus-thread-hide-subtree nil
598 "*If non-nil, hide all threads initially.
599 If threads are hidden, you have to run the command
600 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
601 to expose hidden threads.")
603 (defvar gnus-thread-hide-killed t
604 "*If non-nil, hide killed threads automatically.")
606 (defvar gnus-thread-ignore-subject nil
607 "*If non-nil, ignore subjects and do all threading based on the Reference header.
608 If nil, which is the default, articles that have different subjects
609 from their parents will start separate threads.")
611 (defvar gnus-thread-indent-level 4
612 "*Number that says how much each sub-thread should be indented.")
614 ;; jwz: nuke newsgroups whose name is all digits - that means that
615 ;; some loser has let articles get into the root of the news spool,
616 ;; which is toxic. Lines beginning with whitespace also tend to be
618 (defvar gnus-ignored-newsgroups
619 (purecopy (mapconcat 'identity
620 '("^to\\." ; not "real" groups
621 "^[0-9. \t]+ " ; all digits in name
622 "[][\"#'() ;\\]" ; bogus characters
625 "*A regexp to match uninteresting newsgroups in the active file.
626 Any lines in the active file matching this regular expression are
627 removed from the newsgroup list before anything else is done to it,
628 thus making them effectively non-existant.")
630 (defvar gnus-ignored-headers
631 "^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:"
632 "*All headers that match this regexp will be hidden.
633 Also see `gnus-visible-headers'.")
635 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
636 "*All headers that do not match this regexp will be hidden.
637 Also see `gnus-ignored-headers'.")
639 (defvar gnus-sorted-header-list
640 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
641 "^Cc:" "^Date:" "^Organization:")
642 "*This variable is a list of regular expressions.
643 If it is non-nil, headers that match the regular expressions will
644 be placed first in the article buffer in the sequence specified by
647 (defvar gnus-check-before-posting t
648 "In non-nil, Gnus will attempt to run some checks on outgoing posts.")
650 (defvar gnus-required-headers
651 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
652 "*Headers to be generated or prompted for when posting an article.
653 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
654 Message-ID. Organization, Lines and X-Newsreader are optional. If
655 you want Gnus not to insert some header, remove it from this list.")
657 (defvar gnus-show-all-headers nil
658 "*If non-nil, don't hide any headers.")
660 (defvar gnus-save-all-headers t
661 "*If non-nil, don't remove any headers before saving.")
663 (defvar gnus-inhibit-startup-message nil
664 "*If non-nil, the startup message will not be displayed.")
666 (defvar gnus-auto-extend-newsgroup t
667 "*If non-nil, extend newsgroup forward and backward when requested.")
669 (defvar gnus-auto-select-first t
670 "*If non-nil, select the first unread article when entering a group.
671 If you want to prevent automatic selection of the first unread article
672 in some newsgroups, set the variable to nil in
673 `gnus-select-group-hook'.")
675 (defvar gnus-auto-select-next t
676 "*If non-nil, offer to go to the next group from the end of the previous.
677 If the value is t and the next newsgroup is empty, Gnus will exit
678 summary mode and go back to group mode. If the value is neither nil
679 nor t, Gnus will select the following unread newsgroup. In
680 particular, if the value is the symbol `quietly', the next unread
681 newsgroup will be selected without any confirmations.")
683 (defvar gnus-auto-select-same nil
684 "*If non-nil, select the next article with the same subject.")
686 (defvar gnus-summary-check-current nil
687 "*If non-nil, consider the current article when moving.
688 The \"unread\" movement commands will stay on the same line if the
689 current article is unread.")
691 (defvar gnus-auto-center-summary t
692 "*If non-nil, always center the current summary buffer.")
694 (defvar gnus-auto-mail-to-author nil
695 "*If non-nil, mail the authors of articles a copy of your follow-ups.
696 If this variable is `ask', the user will be prompted for whether to
697 mail a copy. The string given by `gnus-mail-courtesy-message' will be
698 inserted at the beginning of the mail copy.
700 Mail is sent using the function specified by the
701 `gnus-mail-send-method' variable.")
703 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
704 (defvar gnus-mail-courtesy-message
705 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
706 "*This is inserted at the start of a mailed copy of a posted message.
707 If this variable is nil, no such courtesy message will be added.")
709 (defvar gnus-break-pages t
710 "*If non-nil, do page breaking on articles.
711 The page delimiter is specified by the `gnus-page-delimiter'
714 (defvar gnus-page-delimiter "^\^L"
715 "*Regexp describing what to use as article page delimiters.
716 The default value is \"^\^L\", which is a form linefeed at the
717 beginning of a line.")
719 (defvar gnus-use-full-window t
720 "*If non-nil, use the entire Emacs screen.")
722 ; for split windows. maybe a better way?
723 (defvar gnus-split-window nil
724 "*If non-nil, put the article buffer in left-hand side of the window .")
726 (defvar gnus-window-configuration
727 '((newsgroups (1 0 0))
730 "*Specify window configurations for each action.
731 The format of the variable is either a list of (ACTION (G S A)), where
732 G, S, and A are the relative height of group, summary, and article
733 windows, respectively, or a list of (ACTION FUNCTION), where FUNCTION
734 is a function that will be called with ACTION as an argument. ACTION
735 can be `summary', `newsgroups', or `article'.")
737 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
738 "*Function to compose a reply.
739 Two pre-made functions are `gnus-mail-reply-using-mail' (sendmail) and
740 `gnus-mail-reply-using-mhe' (MH-E).")
742 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
743 "*Function to forward the current message to another user.
744 Two pre-made functions are `gnus-mail-forward-using-mail' (sendmail)
745 and `gnus-mail-forward-using-mhe' (MH-E).")
747 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
748 "*Function to compose mail in the other window.
749 Two pre-made functions are `gnus-mail-other-window-using-mail'
750 (sendmail) and `gnus-mail-other-window-using-mhe' (MH-E).")
752 (defvar gnus-mail-send-method send-mail-function
753 "*Function to mail a message which is also being posted as an article.
754 The message must have To or Cc header. The default is copied from
755 the variable `send-mail-function'.")
757 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
758 "*Function called with a group name when new group is detected.
759 A few pre-made functions are supplied: `gnus-subscribe-randomly'
760 inserts new groups at the beginning of the list of groups;
761 `gnus-subscribe-alphabetically' inserts new groups in strict
762 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
763 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
766 ;; Suggested by a bug report by Hallvard B Furuseth.
767 ;; <h.b.furuseth@usit.uio.no>.
768 (defvar gnus-subscribe-options-newsgroup-method
769 (function gnus-subscribe-alphabetically)
770 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
771 If, for instance, you want to subscribe to all newsgroups in the
772 \"no\" and \"alt\" hierarchies, you'd put the following in your
775 options -n no.all alt.all
777 Gnus will the subscribe all new newsgroups in these hierarchies with
778 the subscription method in this variable.")
780 (defvar gnus-subscribe-hierarchical-interactive nil
781 "*If non-nil, Gnus will offer to subscribe hierarchically.
782 When a new hierarchy appears, Gnus will ask the user:
784 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
786 If the user pressed `d', Gnus will descend the hierarchy, `y' will
787 subscribe to all newsgroups in the hierarchy and `s' will skip this
788 hierarchy in its entirety.")
790 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
791 "*Function used for sorting the group buffer.
792 This function will be called with group info entries as the arguments
793 for the groups to be sorted. Pre-made functions include
794 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
795 `gnus-sort-by-level'")
797 ;; Mark variables suggested by Thomas Michanek
798 ;; <Thomas.Michanek@telelogic.se>.
799 (defvar gnus-unread-mark ?
800 "*Mark used for unread articles.")
801 (defvar gnus-ticked-mark ?!
802 "*Mark used for ticked articles.")
803 (defvar gnus-dormant-mark ??
804 "*Mark used for dormant articles.")
805 (defvar gnus-del-mark ?D
806 "*Mark used for del'd articles.")
807 (defvar gnus-read-mark ?d
808 "*Mark used for read articles.")
809 (defvar gnus-expirable-mark ?E
810 "*Mark used for expirable articles.")
811 (defvar gnus-killed-mark ?K
812 "*Mark used for killed articles.")
813 (defvar gnus-kill-file-mark ?X
814 "*Mark used for articles killed by kill files.")
815 (defvar gnus-low-score-mark ?Y
816 "*Mark used for articles with a low score.")
817 (defvar gnus-catchup-mark ?C
818 "*Mark used for articles that are caught up.")
819 (defvar gnus-replied-mark ?R
820 "*Mark used for articles that have been replied to.")
821 (defvar gnus-process-mark ?#
823 (defvar gnus-ancient-mark ?A
824 "*Mark used for ancient articles.")
825 (defvar gnus-canceled-mark ?G
826 "*Mark used for cancelled articles.")
827 (defvar gnus-score-over-mark ?+
828 "*Score mark used for articles with high scores.")
829 (defvar gnus-score-below-mark ?-
830 "*Score mark used for articles with low scores.")
831 (defvar gnus-empty-thread-mark ?
832 "*There is no thread under the article.")
833 (defvar gnus-not-empty-thread-mark ?=
834 "*There is a thread under the article.")
836 (defvar gnus-view-pseudo-asynchronously nil
837 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
839 (defvar gnus-view-pseudos nil
840 "*If `automatic', pseudo-articles will be viewed automatically.
841 If `not-confirm', pseudos will be viewed automatically, and the user
842 will not be asked to confirm the command.")
844 (defvar gnus-view-pseudos-separately t
845 "*If non-nil, one pseudo-article will be created for each file to be viewed.
846 If nil, all files that use the same viewing command will be given as a
847 list of parameters to that command.")
849 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
850 "*Format of group lines.
851 It works along the same lines as a normal formatting string,
852 with some simple extensions.
854 %M Only marked articles (character, \"*\" or \" \")
855 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
856 %L Level of subscribedness (integer)
857 %N Number of unread articles (integer)
858 %I Number of dormant articles (integer)
859 %i Number of ticked and dormant (integer)
860 %T Number of ticked articles (integer)
861 %R Number of read articles (integer)
862 %t Total number of articles (integer)
863 %y Number of unread, unticked articles (integer)
864 %G Group name (string)
865 %g Qualified group name (string)
866 %D Group description (string)
867 %s Select method (string)
868 %o Moderated group (char, \"m\")
869 %O Moderated group (string, \"(m)\" or \"\")
870 %n Select from where (string)
871 %z A string that look like `<%s:%n>' if a foreign select method is used
872 %u User defined specifier. The next character in the format string should
873 be a letter. Gnus will call the function gnus-user-format-function-X,
874 where X is the letter following %u. The function will be passed the
875 current header as argument. The function should return a string, which
876 will be inserted into the buffer just like information from any other
879 Text between %( and %) will be highlighted with `gnus-mouse-face' when
880 the mouse point move inside the area. There can only be one such area.
882 Note that this format specification is not always respected. For
883 reasons of efficiency, when listing killed groups, this specification
884 is ignored altogether. If the spec is changed considerably, your
885 output may end up looking strange when listing both alive and killed
888 If you use %o or %O, reading the active file will be slower and quite
889 a bit of extra memory will be used. %D will also worsen performance.
890 Also note that if you change the format specification to include any
891 of these specs, you must probably re-start Gnus to see them go into
894 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
895 "*The format specification of the lines in the summary buffer.
897 It works along the same lines as a normal formatting string,
898 with some simple extensions.
900 %N Article number, left padded with spaces (string)
902 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
903 %n Name of the poster (string)
904 %A Address of the poster (string)
905 %F Contents of the From: header (string)
906 %x Contents of the Xref: header (string)
907 %D Date of the article (string)
908 %d Date of the article (string) in DD-MMM format
909 %M Message-id of the article (string)
910 %r References of the article (string)
911 %c Number of characters in the article (integer)
912 %L Number of lines in the article (integer)
913 %I Indentation based on thread level (a string of spaces)
914 %T A string with two possible values: 80 spaces if the article
915 is on thread level two or larger and 0 spaces on level one
916 %R \"R\" if this article has been replied to, \" \" otherwise (character)
917 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
918 %[ Opening bracket (character, \"[\" or \"<\")
919 %] Closing bracket (character, \"]\" or \">\")
920 %> Spaces of length thread-level (string)
921 %< Spaces of length (- 20 thread-level) (string)
922 %i Article score (number)
923 %z Article zcore (character)
924 %t Number of articles under the current thread (number).
925 %e Whether the thread is empty or not (character).
926 %u User defined specifier. The next character in the format string should
927 be a letter. Gnus will call the function gnus-user-format-function-X,
928 where X is the letter following %u. The function will be passed the
929 current header as argument. The function should return a string, which
930 will be inserted into the summary just like information from any other
933 Text between %( and %) will be highlighted with `gnus-mouse-face'
934 when the mouse point is placed inside the area. There can only be one
937 The %U (status), %R (replied) and %z (zcore) specs have to be handled
938 with care. For reasons of efficiency, Gnus will compute what column
939 these characters will end up in, and \"hard-code\" that. This means that
940 it is illegal to have these specs after a variable-length spec. Well,
941 you might not be arrested, but your summary buffer will look strange,
944 The smart choice is to have these specs as for to the left as
947 This restriction may disappear in later versions of Gnus.")
949 (defvar gnus-summary-dummy-line-format "* : : %S\n"
950 "*The format specification for the dummy roots in the summary buffer.
951 It works along the same lines as a normal formatting string,
952 with some simple extensions.
956 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
957 "*The format specification for the summary mode line.")
959 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
960 "*The format specification for the article mode line.")
962 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
963 "*The format specification for the group mode line.")
965 (defvar gnus-valid-select-methods
966 '(("nntp" post address prompt-address)
968 ("nnvirtual" none virtual prompt-address)
969 ("nnmbox" mail respool)
970 ("nnml" mail respool)
971 ("nnmh" mail respool)
972 ("nndir" none prompt-address address)
974 ("nndoc" none prompt-address)
975 ("nnbabyl" mail respool)
976 ("nnkiboze" none virtual)
977 ("nnfolder" mail respool))
978 "An alist of valid select methods.
979 The first element of each list lists should be a string with the name
980 of the select method. The other elements may be be the category of
981 this method (ie. `post', `mail', `none' or whatever) or other
982 properties that this method has (like being respoolable).
983 If you implement a new select method, all you should have to change is
984 this variable. I think.")
986 (defvar gnus-updated-mode-lines '(group article summary)
987 "*List of buffers that should update their mode lines.
988 The list may contain the symbols `group', `article' and `summary'. If
989 the corresponding symbol is present, Gnus will keep that mode line
990 updated with information that may be pertinent.
991 If this variable is nil, screen refresh may be quicker.")
993 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
994 (defvar gnus-mode-non-string-length 21
995 "*Max length of mode-line non-string contents.
996 If this is nil, Gnus will take space as is needed, leaving the rest
997 of the modeline intact.")
999 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
1000 (defvar gnus-mouse-face 'highlight
1001 "*Face used for mouse highlighting in Gnus.
1002 No mouse highlights will be done if `gnus-visual' is nil.")
1004 (defvar gnus-summary-mark-below nil
1005 "*Mark all articles with a score below this variable as read.
1006 This variable is local to each summary buffer and usually set by the
1009 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1010 "*List of functions used for sorting threads in the summary buffer.
1011 By default, threads are sorted by article number.
1013 Each function takes two threads and return non-nil if the first thread
1014 should be sorted before the other. If you use more than one function,
1015 the primary sort function should be the last.
1017 Ready-mady functions include `gnus-thread-sort-by-number',
1018 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1019 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1020 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1022 (defvar gnus-thread-score-function '+
1023 "*Function used for calculating the total score of a thread.
1025 The function is called with the scores of the article and each
1026 subthread and should then return the score of the thread.
1028 Some functions you can use are `+', `max', or `min'.")
1030 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
1031 "*Function used to find SCORE files.
1032 The function will be called with the group name as the argument, and
1033 should return a list of score files to apply to that group. The score
1034 files do not actually have to exist.
1036 Predefined values are:
1038 gnus-score-find-single: Only apply the group's own SCORE file.
1039 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
1040 gnus-score-find-bnews: Apply SCORE files whose names matches.
1042 See the documentation to these functions for more information.
1044 This variable can also be a list of functions to be called. Each
1045 function should either return a list of score files, or a list of
1048 (defvar gnus-options-subscribe nil
1049 "*All new groups matching this regexp will be subscribed unconditionally.
1050 Note that this variable deals only with new newsgroups. This variable
1051 does not affect old newsgroups.")
1053 (defvar gnus-options-not-subscribe nil
1054 "*All new groups matching this regexp will be ignored.
1055 Note that this variable deals only with new newsgroups. This variable
1056 does not affect old (already subscribed) newsgroups.")
1058 (defvar gnus-auto-expirable-newsgroups nil
1059 "*Groups in which to automatically mark read articles as expirable.
1060 If non-nil, this should be a regexp that should match all groups in
1061 which to perform auto-expiry. This only makes sense for mail groups.")
1066 (defvar gnus-group-mode-hook nil
1067 "*A hook for Gnus group mode.")
1069 (defvar gnus-summary-mode-hook nil
1070 "*A hook for Gnus summary mode.")
1072 (defvar gnus-article-mode-hook nil
1073 "*A hook for Gnus article mode.")
1075 (defvar gnus-open-server-hook nil
1076 "*A hook called just before opening connection to the news server.")
1078 (defvar gnus-startup-hook nil
1079 "*A hook called at startup.
1080 This hook is called after Gnus is connected to the NNTP server.")
1082 (defvar gnus-get-new-news-hook nil
1083 "*A hook run just before Gnus checks for new news.")
1085 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1086 "*A function that is called to generate the group buffer.
1087 The function is called with three arguments: The first is a number;
1088 all group with a level less or equal to that number should be listed,
1089 if the second is non-nil, empty groups should also be displayed. If
1090 the third is non-nil, it is a number. No groups with a level lower
1091 than this number should be displayed.
1093 The only current function implemented is `gnus-group-prepare-flat'.")
1095 (defvar gnus-group-prepare-hook nil
1096 "*A hook called after the group buffer has been generated.
1097 If you want to modify the group buffer, you can use this hook.")
1099 (defvar gnus-summary-prepare-hook nil
1100 "*A hook called after the summary buffer has been generated.
1101 If you want to modify the summary buffer, you can use this hook.")
1103 (defvar gnus-article-prepare-hook nil
1104 "*A hook called after an article has been prepared in the article buffer.
1105 If you want to run a special decoding program like nkf, use this hook.")
1107 (defvar gnus-article-display-hook nil
1108 "*A hook called after the article is displayed in the article buffer.
1109 The hook is designed to change the contents of the article
1110 buffer. Typical functions that this hook may contain are
1111 `gnus-article-hide-headers' (hide selected headers),
1112 `gnus-article-hide-signature' (hide signature) and
1113 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1114 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1115 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1117 (defvar gnus-article-x-face-command
1118 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -"
1119 "String or function to be executed to display an X-Face header.
1120 If it is a string, the command will be executed in a sub-shell
1121 asynchronously. The compressed face will be piped to this command.")
1123 (defvar gnus-select-group-hook nil
1124 "*A hook called when a newsgroup is selected.
1126 If you'd like to simplify subjects like the
1127 `gnus-summary-next-same-subject' command does, you can use the
1130 (setq gnus-select-group-hook
1133 (mapcar (lambda (header)
1136 (gnus-simplify-subject
1137 (header-subject header) 're-only)))
1138 gnus-newsgroup-headers))))")
1140 (defvar gnus-select-article-hook
1141 '(gnus-summary-show-thread)
1142 "*A hook called when an article is selected.
1143 The default hook shows conversation thread subtrees of the selected
1144 article automatically using `gnus-summary-show-thread'.")
1146 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1147 "*A hook called to apply kill files to a group.
1148 This hook is intended to apply a kill file to the selected newsgroup.
1149 The function `gnus-apply-kill-file' is called by default.
1151 Since a general kill file is too heavy to use only for a few
1152 newsgroups, I recommend you to use a lighter hook function. For
1153 example, if you'd like to apply a kill file to articles which contains
1154 a string `rmgroup' in subject in newsgroup `control', you can use the
1157 \(setq gnus-apply-kill-hook
1160 (cond ((string-match \"control\" gnus-newsgroup-name)
1161 (gnus-kill \"Subject\" \"rmgroup\")
1162 (gnus-expunge \"X\"))))))")
1164 (defvar gnus-visual-mark-article-hook
1165 (list 'gnus-visual-highlight-selected-summary)
1166 "*Hook run after selecting an article in the summary buffer.
1167 It is meant to be used for highlighting the article in some way. It
1168 is not run if `gnus-visual' is nil.")
1170 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1171 "*A hook called after preparing body, but before preparing header headers.
1172 The default hook (`gnus-inews-insert-signature') inserts a signature
1173 file specified by the variable `gnus-signature-file'.")
1175 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
1176 "*A hook called before finally posting an article.
1177 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
1178 the article to a file).")
1180 (defvar gnus-inews-article-header-hook nil
1181 "*A hook called after inserting the headers in an article to be posted.
1182 The hook is called from the *post-news* buffer, narrowed to the
1185 (defvar gnus-exit-group-hook nil
1186 "*A hook called when exiting (not quitting) summary mode.")
1188 (defvar gnus-suspend-gnus-hook nil
1189 "*A hook called when suspending (not exiting) Gnus.")
1191 (defvar gnus-exit-gnus-hook nil
1192 "*A hook called when exiting Gnus.")
1194 (defvar gnus-save-newsrc-hook nil
1195 "*A hook called when saving the newsrc file.")
1197 (defvar gnus-visual-summary-update-hook
1198 (list 'gnus-visual-summary-highlight-line)
1199 "*A hook called when a summary line is changed.
1200 The hook will not be called if `gnus-visual' is nil.
1202 The default function `gnus-visual-summary-highlight-line' will
1203 highlight the line according to the `gnus-visual-summary-highlight'
1206 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1207 "*A hook called when an article is selected for the first time.
1208 The hook is intended to mark an article as read (or unread)
1209 automatically when it is selected.")
1212 ;; Internal variables
1214 (defvar gnus-internal-global-score-files nil)
1215 (defvar gnus-score-file-list nil)
1217 ;; Avoid highlighting in kill files.
1218 (defvar gnus-summary-inhibit-highlight nil)
1219 (defvar gnus-newsgroup-selected-overlay nil)
1221 (defvar gnus-article-mode-map nil)
1222 (defvar caesar-translate-table nil)
1223 (defvar gnus-dribble-buffer nil)
1224 (defvar gnus-headers-retrieved-by nil)
1225 (defvar gnus-article-reply nil)
1226 (defvar gnus-override-method nil)
1227 (defvar gnus-article-check-size nil)
1229 (defvar gnus-current-move-group nil)
1231 (defvar gnus-newsgroup-dependencies nil)
1232 (defvar gnus-newsgroup-threads nil)
1233 (defvar gnus-newsgroup-async nil)
1234 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1236 (defconst gnus-group-line-format-alist
1237 (list (list ?M 'marked ?c)
1238 (list ?S 'subscribed ?c)
1240 (list ?N 'number ?s)
1241 (list ?I 'number-of-dormant ?d)
1242 (list ?T 'number-of-ticked ?d)
1243 (list ?R 'number-of-read ?s)
1244 (list ?t 'number-total ?d)
1245 (list ?y 'number-of-unread-unticked ?s)
1246 (list ?i 'number-of-ticked-and-dormant ?d)
1248 (list ?G 'qualified-group ?s)
1249 (list ?D 'newsgroup-description ?s)
1250 (list ?o 'moderated ?c)
1251 (list ?O 'moderated-string ?s)
1252 (list ?s 'news-server ?s)
1253 (list ?n 'news-method ?s)
1254 (list ?z 'news-method-string ?s)
1255 (list ?u 'user-defined ?s)))
1257 (defconst gnus-summary-line-format-alist
1258 (list (list ?N 'number ?s)
1259 (list ?S 'subject ?s)
1260 (list ?s 'subject-or-nil ?s)
1262 (list ?A 'address ?s)
1264 (list ?x (macroexpand '(header-xref header)) ?s)
1265 (list ?D (macroexpand '(header-date header)) ?s)
1266 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1267 (list ?M (macroexpand '(header-id header)) ?s)
1268 (list ?r (macroexpand '(header-references header)) ?s)
1269 (list ?c (macroexpand '(header-chars header)) ?d)
1271 (list ?I 'indentation ?s)
1272 (list ?T '(if (< level 1) "" (make-string (frame-width) ? )) ?s)
1273 (list ?R 'replied ?c)
1274 (list ?\[ 'opening-bracket ?c)
1275 (list ?\] 'closing-bracket ?c)
1276 (list ?\> '(make-string level ? ) ?s)
1277 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1279 (list ?z 'score-char ?c)
1280 (list ?U 'unread ?c)
1281 (list ?t '(gnus-summary-number-of-articles-in-thread
1282 (if (boundp 'thread) (symbol-value 'thread)) nil) ?d)
1283 (list ?e '(gnus-summary-number-of-articles-in-thread
1284 (if (boundp 'thread) (symbol-value 'thread)) t) ?c)
1285 (list ?u 'user-defined ?s))
1286 "An alist of format specifications that can appear in summary lines,
1287 and what variables they correspond with, along with the type of the
1288 variable (string, integer, character, etc).")
1290 (defconst gnus-summary-dummy-line-format-alist
1291 (list (list ?S 'subject ?s)
1292 (list ?N 'number ?d)
1293 (list ?u 'user-defined ?s)))
1295 (defconst gnus-summary-mode-line-format-alist
1296 (list (list ?G 'group-name ?s)
1297 (list ?g '(gnus-short-group-name group-name) ?s)
1298 (list ?A 'article-number ?d)
1299 (list ?Z 'unread-and-unselected ?s)
1300 (list ?V 'gnus-version ?s)
1301 (list ?U 'unread ?d)
1302 (list ?S 'subject ?s)
1303 (list ?e 'unselected ?d)
1304 (list ?u 'user-defined ?s)
1305 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1307 (defconst gnus-group-mode-line-format-alist
1308 (list (list ?S 'news-server ?s)
1309 (list ?M 'news-method ?s)
1310 (list ?u 'user-defined ?s)))
1312 (defvar gnus-have-read-active-file nil)
1314 (defconst gnus-maintainer "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
1315 "The mail address of the Gnus maintainer.")
1317 (defconst gnus-version "(ding) Gnus v0.60"
1318 "Version number for this version of Gnus.")
1320 (defvar gnus-info-nodes
1321 '((gnus-group-mode "(gnus)The Group Buffer")
1322 (gnus-summary-mode "(gnus)The Summary Buffer")
1323 (gnus-article-mode "(gnus)The Article Buffer"))
1324 "Assoc list of major modes and related Info nodes.")
1326 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1327 "The location of the (ding) Gnus documentation group.")
1329 (defvar gnus-group-buffer "*Group*")
1330 (defvar gnus-summary-buffer "*Summary*")
1331 (defvar gnus-article-buffer "*Article*")
1332 (defvar gnus-server-buffer "*Server*")
1334 (defvar gnus-work-buffer " *gnus work*")
1336 (defvar gnus-buffer-list nil
1337 "Gnus buffers that should be killed on exit.")
1339 (defvar gnus-server-alist nil
1340 "List of available servers.")
1342 (defvar gnus-variable-list
1343 '(gnus-newsrc-options gnus-newsrc-options-n
1344 gnus-newsrc-last-checked-date
1345 gnus-newsrc-alist gnus-server-alist
1346 gnus-killed-list gnus-zombie-list)
1347 "Gnus variables saved in the quick startup file.")
1349 (defvar gnus-overload-functions
1350 '((news-inews gnus-inews-news "rnewspost")
1351 (caesar-region gnus-caesar-region "rnews"))
1352 "Functions overloaded by gnus.
1353 It is a list of `(original overload &optional file)'.")
1355 (defvar gnus-newsrc-options nil
1356 "Options line in the .newsrc file.")
1358 (defvar gnus-newsrc-options-n nil
1359 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1361 (defvar gnus-newsrc-last-checked-date nil
1362 "Date Gnus last asked server for new newsgroups.")
1364 (defvar gnus-newsrc-alist nil
1365 "Assoc list of read articles.
1366 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1368 (defvar gnus-newsrc-hashtb nil
1369 "Hashtable of gnus-newsrc-alist.")
1371 (defvar gnus-killed-list nil
1372 "List of killed newsgroups.")
1374 (defvar gnus-killed-hashtb nil
1375 "Hash table equivalent of gnus-killed-list.")
1377 (defvar gnus-zombie-list nil
1378 "List of almost dead newsgroups.")
1380 (defvar gnus-description-hashtb nil
1381 "Descriptions of newsgroups.")
1383 (defvar gnus-list-of-killed-groups nil
1384 "List of newsgroups that have recently been killed by the user.")
1386 (defvar gnus-active-hashtb nil
1387 "Hashtable of active articles.")
1389 (defvar gnus-moderated-list nil
1390 "List of moderated newsgroups.")
1392 (defvar gnus-current-startup-file nil
1393 "Startup file for the current host.")
1395 (defvar gnus-last-search-regexp nil
1396 "Default regexp for article search command.")
1398 (defvar gnus-last-shell-command nil
1399 "Default shell command on article.")
1401 (defvar gnus-current-select-method nil
1402 "The current method for selecting a newsgroup.")
1404 (defvar gnus-have-all-newsgroups nil)
1406 (defvar gnus-article-internal-prepare-hook nil)
1408 (defvar gnus-newsgroup-name nil)
1409 (defvar gnus-newsgroup-begin nil)
1410 (defvar gnus-newsgroup-end nil)
1411 (defvar gnus-newsgroup-last-rmail nil)
1412 (defvar gnus-newsgroup-last-mail nil)
1413 (defvar gnus-newsgroup-last-folder nil)
1414 (defvar gnus-newsgroup-last-file nil)
1415 (defvar gnus-newsgroup-auto-expire nil)
1416 (defvar gnus-newsgroup-active nil)
1418 (defvar gnus-newsgroup-unreads nil
1419 "List of unread articles in the current newsgroup.")
1421 (defvar gnus-newsgroup-unselected nil
1422 "List of unselected unread articles in the current newsgroup.")
1424 (defvar gnus-newsgroup-marked nil
1425 "List of ticked articles in the current newsgroup (a subset of unread art).")
1427 (defvar gnus-newsgroup-killed nil
1428 "List of ranges of articles that have been through the scoring process.")
1430 (defvar gnus-newsgroup-kill-headers nil)
1432 (defvar gnus-newsgroup-replied nil
1433 "List of articles that have been replied to in the current newsgroup.")
1435 (defvar gnus-newsgroup-expirable nil
1436 "List of articles in the current newsgroup that can be expired.")
1438 (defvar gnus-newsgroup-processable nil
1439 "List of articles in the current newsgroup that can be processed.")
1441 (defvar gnus-newsgroup-bookmarks nil
1442 "List of articles in the current newsgroup that have bookmarks.")
1444 (defvar gnus-newsgroup-dormant nil
1445 "List of dormant articles in the current newsgroup.")
1447 (defvar gnus-newsgroup-scored nil
1448 "List of scored articles in the current newsgroup.")
1450 (defvar gnus-newsgroup-headers nil
1451 "List of article headers in the current newsgroup.")
1452 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1454 (defvar gnus-newsgroup-ancient nil
1455 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1457 (defvar gnus-current-article nil)
1458 (defvar gnus-article-current nil)
1459 (defvar gnus-current-headers nil)
1460 (defvar gnus-have-all-headers nil)
1461 (defvar gnus-last-article nil)
1462 (defvar gnus-newsgroup-history nil)
1463 (defvar gnus-current-kill-article nil)
1465 ;; Save window configuration.
1466 (defvar gnus-winconf-edit-group nil)
1469 (defvar gnus-summary-line-format-spec nil)
1470 (defvar gnus-summary-dummy-line-format-spec nil)
1471 (defvar gnus-group-line-format-spec nil)
1472 (defvar gnus-summary-mode-line-format-spec nil)
1473 (defvar gnus-article-mode-line-format-spec nil)
1474 (defvar gnus-group-mode-line-format-spec nil)
1475 (defvar gnus-summary-mark-positions nil)
1477 (defvar gnus-summary-expunge-below nil)
1478 (defvar gnus-reffed-article-number nil)
1480 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1481 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1483 (defconst gnus-summary-local-variables
1484 '(gnus-newsgroup-name
1485 gnus-newsgroup-begin gnus-newsgroup-end
1486 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1487 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1488 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1489 gnus-newsgroup-unselected gnus-newsgroup-marked
1490 gnus-newsgroup-replied gnus-newsgroup-expirable
1491 gnus-newsgroup-processable gnus-newsgroup-killed
1492 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1493 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1494 gnus-current-article gnus-current-headers gnus-have-all-headers
1495 gnus-last-article gnus-article-internal-prepare-hook
1496 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1497 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1498 gnus-newsgroup-threads gnus-newsgroup-async
1499 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1500 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1501 gnus-newsgroup-history gnus-newsgroup-ancient)
1502 "Variables that are buffer-local to the summary buffers.")
1504 ;;; End of variables.
1506 ;; Define some autoload functions Gnus might use.
1508 (autoload 'metamail-buffer "metamail")
1509 (autoload 'Info-goto-node "info")
1510 (autoload 'hexl-hex-string-to-integer "hexl")
1512 (autoload 'timezone-make-date-arpa-standard "timezone")
1513 (autoload 'timezone-fix-time "timezone")
1514 (autoload 'timezone-make-sortable-date "timezone")
1515 (autoload 'timezone-make-time-string "timezone")
1517 (autoload 'rmail-output "rmailout")
1518 (autoload 'mail-position-on-field "sendmail")
1519 (autoload 'mail-setup "sendmail")
1520 (autoload 'news-mail-other-window "rnewspost")
1521 (autoload 'news-reply-yank-original "rnewspost")
1523 (autoload 'rmail-insert-rmail-file-header "rmail")
1524 (autoload 'rmail-count-new-messages "rmail")
1525 (autoload 'rmail-show-message "rmail")
1527 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1528 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1529 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1530 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1531 (autoload 'gnus-Folder-save-name "gnus-mh")
1532 (autoload 'gnus-folder-save-name "gnus-mh")
1534 (autoload 'gnus-group-make-menu-bar "gnus-visual")
1535 (autoload 'gnus-summary-make-menu-bar "gnus-visual")
1536 (autoload 'gnus-article-make-menu-bar "gnus-visual")
1537 (autoload 'gnus-visual-highlight-selected-summary "gnus-visual")
1538 (autoload 'gnus-visual-summary-highlight-line "gnus-visual")
1540 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1541 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1542 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1543 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1544 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1545 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1546 (autoload 'gnus-uu-post-news "gnus-uu" nil t)
1547 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1548 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1550 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1551 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1552 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1553 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1554 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1555 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1556 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1557 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1558 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1559 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1560 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1561 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1562 (autoload 'gnus-uu-decode-postscript "gnus-uu" nil t)
1563 (autoload 'gnus-uu-decode-postscript-and-save "gnus-uu" nil t)
1564 (autoload 'gnus-uu-decode-postscript-view "gnus-uu" nil t)
1565 (autoload 'gnus-uu-decode-postscript-and-save-view "gnus-uu" nil t)
1567 (autoload 'gnus-kill "gnus-kill")
1568 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1569 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1570 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1571 (autoload 'gnus-execute "gnus-kill")
1572 (autoload 'gnus-expunge "gnus-kill")
1575 (autoload 'pp-to-string "pp")
1576 (autoload 'mail-extract-address-components "mail-extr")
1578 (autoload 'gnus-summary-increase-map "gnus-score" nil nil 'keymap)
1579 (autoload 'gnus-summary-lower-map "gnus-score" nil nil 'keymap)
1580 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1581 (autoload 'gnus-score-save "gnus-score")
1582 (autoload 'gnus-score-headers "gnus-score")
1583 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1584 (autoload 'gnus-score-adaptive "gnus-score")
1585 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1587 (autoload 'gnus-summary-send-map "gnus-message" nil nil 'keymap)
1588 (autoload 'gnus-group-post-news "gnus-message" nil t)
1589 (autoload 'gnus-summary-post-news "gnus-message" nil t)
1590 (autoload 'gnus-summary-followup "gnus-message" nil t)
1591 (autoload 'gnus-summary-followup-with-original "gnus-message" nil t)
1592 (autoload 'gnus-summary-followup-and-reply "gnus-message" nil t)
1593 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-message" nil t)
1594 (autoload 'gnus-summary-cancel-article "gnus-message" nil t)
1595 (autoload 'gnus-summary-supersede-article "gnus-message" nil t)
1596 (autoload 'gnus-post-news "gnus-message" nil t)
1597 (autoload 'gnus-inews-news "gnus-message" nil t)
1598 (autoload 'gnus-cancel-news "gnus-message" nil t)
1599 (autoload 'gnus-summary-reply "gnus-message" nil t)
1600 (autoload 'gnus-summary-reply-with-original "gnus-message" nil t)
1601 (autoload 'gnus-summary-mail-forward "gnus-message" nil t)
1602 (autoload 'gnus-summary-mail-other-window "gnus-message" nil t)
1603 (autoload 'gnus-mail-reply-using-mail "gnus-message")
1604 (autoload 'gnus-mail-yank-original "gnus-message")
1605 (autoload 'gnus-mail-send-and-exit "gnus-message")
1606 (autoload 'gnus-mail-forward-using-mail "gnus-message")
1607 (autoload 'gnus-mail-other-window-using-mail "gnus-message")
1613 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1614 ;; If you want the cursor to go somewhere else, set these two
1615 ;; functions in some startup hook to whatever you want.
1616 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1617 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1619 ;; Cruft to make Gnus work under GNU XEmacs.
1620 (defconst gnus-xemacs (not (not (string-match "XEmacs\\|Lucid" emacs-version)))
1621 "Non-nil if Gnus is running under GNU XEmacs.")
1625 (or (memq 'underline (funcall 'list-faces))
1626 (make-face 'underline))
1627 (or (face-differs-from-default-p 'underline)
1628 (set-face-underline-p 'underline t))
1629 (or (fboundp 'set-text-properties)
1630 (defun set-text-properties (start end props &optional buffer)
1632 (put-text-property start end (car props)
1633 (funcall (intern "cadr") props) buffer)
1634 (remove-text-properties start end ()))))))
1636 ;;; Various macros and substs.
1638 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1639 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1640 (` (let ((GnusStartBufferWindow (selected-window)))
1643 (pop-to-buffer (, buffer))
1645 (select-window GnusStartBufferWindow)))))
1647 (defmacro gnus-gethash (string hashtable)
1648 "Get hash value of STRING in HASHTABLE."
1649 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1650 ;;(` (abbrev-expansion (, string) (, hashtable)))
1651 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1653 (defmacro gnus-sethash (string value hashtable)
1654 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1655 ;; We cannot use define-abbrev since it only accepts string as value.
1656 ;; (set (intern string hashtable) value))
1657 (` (set (intern (, string) (, hashtable)) (, value))))
1659 (defsubst gnus-buffer-substring (beg end)
1660 (buffer-substring (match-beginning beg) (match-end end)))
1662 (defsubst gnus-simplify-subject-re (subject)
1663 "Remove \"Re:\" from subject lines."
1664 (let ((case-fold-search t))
1665 (if (string-match "^re: *" subject)
1666 (substring subject (match-end 0))
1669 (defsubst gnus-goto-char (point)
1670 (and point (goto-char point)))
1672 (defmacro gnus-buffer-exists-p (buffer)
1674 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1677 (defmacro gnus-kill-buffer (buffer)
1678 (` (if (gnus-buffer-exists-p (, buffer))
1679 (kill-buffer (, buffer)))))
1681 (defsubst gnus-point-at-bol ()
1682 "Return point at the beginning of line."
1689 (defsubst gnus-point-at-eol ()
1690 "Return point at the beginning of line."
1699 ;;; Gnus Utility Functions
1702 (defun gnus-extract-address-components (from)
1704 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1705 (setq address (substring from (match-beginning 0) (match-end 0))))
1707 (string-match (concat "<" (regexp-quote address) ">") from)
1708 (setq name (substring from 0 (1- (match-beginning 0)))))
1710 (and (string-match "(.+)" from)
1711 (setq name (substring from (1+ (match-beginning 0))
1712 (1- (match-end 0))))))
1713 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1714 (list (or name from) (or address from))))
1716 (defun gnus-fetch-field (field)
1717 "Return the value of the header FIELD of current article."
1720 (gnus-narrow-to-headers)
1721 (mail-fetch-field field))))
1723 (defun gnus-goto-colon ()
1725 (search-forward ":" (gnus-point-at-eol) t))
1727 (defun gnus-narrow-to-headers ()
1731 (if (search-forward "\n\n")
1732 (narrow-to-region 1 (1- (point))))))
1734 (defun gnus-update-format-specifications ()
1735 (setq gnus-summary-line-format-spec
1737 gnus-summary-line-format gnus-summary-line-format-alist))
1738 (gnus-update-summary-mark-positions)
1739 (setq gnus-summary-dummy-line-format-spec
1740 (gnus-parse-format gnus-summary-dummy-line-format
1741 gnus-summary-dummy-line-format-alist))
1742 (setq gnus-group-line-format-spec
1744 gnus-group-line-format
1745 gnus-group-line-format-alist))
1746 (if (and (string-match "%D" gnus-group-line-format)
1747 (not gnus-description-hashtb)
1748 gnus-read-active-file)
1749 (gnus-read-descriptions-file))
1750 (setq gnus-summary-mode-line-format-spec
1751 (gnus-parse-format gnus-summary-mode-line-format
1752 gnus-summary-mode-line-format-alist))
1753 (setq gnus-article-mode-line-format-spec
1754 (gnus-parse-format gnus-article-mode-line-format
1755 gnus-summary-mode-line-format-alist))
1756 (setq gnus-group-mode-line-format-spec
1757 (gnus-parse-format gnus-group-mode-line-format
1758 gnus-group-mode-line-format-alist)))
1760 (defun gnus-update-summary-mark-positions ()
1762 (let ((gnus-replied-mark 129)
1763 (gnus-score-below-mark 130)
1764 (gnus-score-over-mark 130)
1767 (gnus-set-work-buffer)
1768 (gnus-summary-insert-line
1769 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1770 (goto-char (point-min))
1771 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1773 (goto-char (point-min))
1774 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1775 (- (point) 2))) pos))
1776 (goto-char (point-min))
1777 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1778 (- (point) 2))) pos))
1779 (setq gnus-summary-mark-positions pos))))
1781 (defun gnus-format-max-width (var length)
1784 (if (> (length (setq result (if (numberp val) (int-to-string val) val)))
1786 (format "%s" (substring result 0 length))
1787 (format "%s" result))))
1789 (defun gnus-set-mouse-face (string)
1790 ;; Set mouse face property on STRING.
1792 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string))
1795 (defun gnus-parse-format (format spec-alist)
1796 ;; This function parses the FORMAT string with the help of the
1797 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1798 ;; string. If the FORMAT string contains the specifiers %( and %)
1799 ;; the text between them will have the mouse-face text property.
1800 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1801 (if (and gnus-visual gnus-mouse-face)
1802 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1803 (button (substring format (match-beginning 2) (match-end 2)))
1804 (post (substring format (match-beginning 3) (match-end 3))))
1806 (gnus-parse-simple-format pre spec-alist)
1807 (list 'gnus-set-mouse-face
1808 (gnus-parse-simple-format button spec-alist))
1809 (gnus-parse-simple-format post spec-alist)))
1810 (gnus-parse-simple-format
1811 (concat (substring format (match-beginning 1) (match-end 1))
1812 (substring format (match-beginning 2) (match-end 2))
1813 (substring format (match-beginning 3) (match-end 3)))
1815 (gnus-parse-simple-format format spec-alist)))
1817 (defun gnus-parse-simple-format (format spec-alist)
1818 ;; This function parses the FORMAT string with the help of the
1819 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1820 ;; string. The list will consist of the symbol `format', a format
1821 ;; specification string, and a list of forms depending on the
1824 spec flist fstring b newspec max-width elem beg)
1826 (gnus-set-work-buffer)
1829 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1830 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1832 ;; First check if there are any specs that look anything like
1833 ;; "%12,12A", ie. with a "max width specification". These have
1834 ;; to be treated specially.
1835 (if (setq beg (match-beginning 1))
1838 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1840 (setq beg (match-beginning 2)))
1841 ;; Find the specification from `spec-alist'.
1842 (if (not (setq elem (cdr (assq spec spec-alist))))
1843 (setq elem '("*" ?s)))
1844 ;; Treat user defined format specifiers specially
1845 (and (eq (car elem) 'user-defined)
1848 (list (intern (concat "gnus-user-format-function-"
1854 (delete-region (match-beginning 3) (match-end 3)))
1855 (if (not (zerop max-width))
1856 (let ((el (car elem)))
1857 (cond ((= (car (cdr elem)) ?c)
1858 (setq el (list 'char-to-string el)))
1859 ((= (car (cdr elem)) ?d)
1860 (numberp el) (setq el (list 'int-to-string el))))
1861 (setq flist (cons (list 'gnus-format-max-width
1865 (setq flist (cons (car elem) flist))
1866 (setq newspec (car (cdr elem))))
1867 ;; Remove the old specification (and possibly a ",12" string).
1868 (delete-region beg (match-end 2))
1869 ;; Insert the new specification.
1872 (setq fstring (buffer-substring 1 (point-max))))
1873 (cons 'format (cons fstring (nreverse flist)))))
1875 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1876 (defun gnus-read-init-file ()
1878 (or (and (file-exists-p gnus-init-file)
1879 ;; Don't try to load a directory.
1880 (not (file-directory-p gnus-init-file)))
1881 (file-exists-p (concat gnus-init-file ".el"))
1882 (file-exists-p (concat gnus-init-file ".elc")))
1883 (load gnus-init-file nil t)))
1885 (defun gnus-set-work-buffer ()
1886 (if (get-buffer gnus-work-buffer)
1888 (set-buffer gnus-work-buffer)
1889 (gnus-add-current-to-buffer-list)
1891 (set-buffer (get-buffer-create gnus-work-buffer))
1892 (buffer-disable-undo (current-buffer))))
1894 ;; Article file names when saving.
1896 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1897 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1898 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1899 Otherwise, it is like ~/News/news/group/num."
1902 (concat (if (gnus-use-long-file-name 'not-save)
1903 (gnus-capitalize-newsgroup newsgroup)
1904 (gnus-newsgroup-directory-form newsgroup))
1905 "/" (int-to-string (header-number headers)))
1906 (or gnus-article-save-directory "~/News"))))
1908 (string-equal (file-name-directory default)
1909 (file-name-directory last-file))
1910 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1912 (or last-file default))))
1914 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1915 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1916 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1917 Otherwise, it is like ~/News/news/group/num."
1920 (concat (if (gnus-use-long-file-name 'not-save)
1922 (gnus-newsgroup-directory-form newsgroup))
1923 "/" (int-to-string (header-number headers)))
1924 (or gnus-article-save-directory "~/News"))))
1926 (string-equal (file-name-directory default)
1927 (file-name-directory last-file))
1928 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1930 (or last-file default))))
1932 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1933 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1934 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1935 Otherwise, it is like ~/News/news/group/news."
1938 (if (gnus-use-long-file-name 'not-save)
1939 (gnus-capitalize-newsgroup newsgroup)
1940 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1941 (or gnus-article-save-directory "~/News"))))
1943 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1944 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1945 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1946 Otherwise, it is like ~/News/news/group/news."
1949 (if (gnus-use-long-file-name 'not-save)
1951 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1952 (or gnus-article-save-directory "~/News"))))
1954 ;; For subscribing new newsgroup
1956 (defun gnus-subscribe-hierarchical-interactive (groups)
1957 (let ((groups (sort groups 'string<))
1958 prefixes prefix start rest ans group starts)
1960 (setq prefixes (list "^"))
1961 (while (and groups prefixes)
1962 (while (not (string-match (car prefixes) (car groups)))
1963 (setq prefixes (cdr prefixes)))
1964 (setq prefix (car prefixes))
1965 (setq start (1- (length prefix)))
1966 (if (and (string-match "[^\\.]\\." (car groups) start)
1969 (concat "^" (substring (car groups) 0 (match-end 0))))
1970 (string-match prefix (car (cdr groups))))
1972 (setq prefixes (cons prefix prefixes))
1973 (message "Descend hierarchy %s? ([y]nsq): "
1974 (substring prefix 1 (1- (length prefix))))
1975 (setq ans (read-char))
1978 (string-match prefix
1979 (setq group (car groups))))
1980 (setq gnus-killed-list
1981 (cons group gnus-killed-list))
1982 (gnus-sethash group group gnus-killed-hashtb)
1983 (setq groups (cdr groups)))
1984 (setq starts (cdr starts)))
1987 (string-match prefix
1988 (setq group (car groups))))
1989 (gnus-sethash group group gnus-killed-hashtb)
1990 (gnus-subscribe-alphabetically (car groups))
1991 (setq groups (cdr groups)))
1992 (setq starts (cdr starts)))
1995 (setq group (car groups))
1996 (setq gnus-killed-list (cons group gnus-killed-list))
1997 (gnus-sethash group group gnus-killed-hashtb)
1998 (setq groups (cdr groups))))
2000 (message "Subscribe %s? ([n]yq)" (car groups))
2001 (setq ans (read-char))
2002 (setq group (car groups))
2004 (gnus-subscribe-alphabetically (car groups))
2005 (gnus-sethash group group gnus-killed-hashtb))
2008 (setq group (car groups))
2009 (setq gnus-killed-list (cons group gnus-killed-list))
2010 (gnus-sethash group group gnus-killed-hashtb)
2011 (setq groups (cdr groups))))
2013 (setq gnus-killed-list (cons group gnus-killed-list))
2014 (gnus-sethash group group gnus-killed-hashtb)))
2015 (setq groups (cdr groups)))))))
2017 (defun gnus-subscribe-randomly (newsgroup)
2018 "Subscribe new NEWSGROUP by making it the first newsgroup."
2019 (gnus-subscribe-newsgroup newsgroup))
2021 (defun gnus-subscribe-alphabetically (newgroup)
2022 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2023 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2024 (let ((groups (cdr gnus-newsrc-alist))
2026 (while (and (not before) groups)
2027 (if (string< newgroup (car (car groups)))
2028 (setq before (car (car groups)))
2029 (setq groups (cdr groups))))
2030 (gnus-subscribe-newsgroup newgroup before)))
2032 (defun gnus-subscribe-hierarchically (newgroup)
2033 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2034 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2036 (set-buffer (find-file-noselect gnus-current-startup-file))
2037 (let ((groupkey newgroup)
2039 (while (and (not before) groupkey)
2040 (goto-char (point-min))
2042 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2043 (while (and (re-search-forward groupkey-re nil t)
2045 (setq before (buffer-substring
2046 (match-beginning 1) (match-end 1)))
2047 (string< before newgroup)))))
2048 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2050 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2051 (substring groupkey (match-beginning 1) (match-end 1)))))
2052 (gnus-subscribe-newsgroup newgroup before))))
2054 (defun gnus-subscribe-interactively (newsgroup)
2055 "Subscribe new NEWSGROUP interactively.
2056 It is inserted in hierarchical newsgroup order if subscribed. If not,
2058 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2059 (gnus-subscribe-hierarchically newsgroup)
2060 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2062 (defun gnus-subscribe-zombies (newsgroup)
2063 "Make new NEWSGROUP a zombie group."
2064 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2066 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2067 "Subscribe new NEWSGROUP.
2068 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2069 the first newsgroup."
2070 ;; We subscribe the group by changing its level to `subscribed'.
2071 (gnus-group-change-level
2072 newsgroup gnus-level-default-subscribed
2073 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2074 (message "Subscribe newsgroup: %s" newsgroup))
2078 (defun gnus-newsgroup-directory-form (newsgroup)
2079 "Make hierarchical directory name from NEWSGROUP name."
2080 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2081 (len (length newsgroup))
2083 ;; Replace all occurrences of `.' with `/'.
2085 (if (= (aref newsgroup idx) ?.)
2086 (aset newsgroup idx ?/))
2087 (setq idx (1+ idx)))
2091 (defun gnus-make-directory (dir)
2092 "Make DIRECTORY recursively."
2093 (let* ((dir (expand-file-name dir default-directory))
2095 (if (string-match "/$" dir)
2096 (setq dir (substring dir 0 (match-beginning 0))))
2097 (while (not (file-exists-p dir))
2098 (setq dirs (cons dir dirs))
2099 (string-match "/[^/]+$" dir)
2100 (setq dir (substring dir 0 (match-beginning 0))))
2102 (make-directory (car dirs))
2103 (setq dirs (cdr dirs)))))
2105 (defun gnus-capitalize-newsgroup (newsgroup)
2106 "Capitalize NEWSGROUP name."
2107 (and (not (zerop (length newsgroup)))
2108 (concat (char-to-string (upcase (aref newsgroup 0)))
2109 (substring newsgroup 1))))
2113 (defun gnus-simplify-subject (subject &optional re-only)
2114 "Remove `Re:' and words in parentheses.
2115 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2116 (let ((case-fold-search t)) ;Ignore case.
2117 ;; Remove `Re:' and `Re^N:'.
2118 (if (string-match "^re:[ \t]*" subject)
2119 (setq subject (substring subject (match-end 0))))
2120 ;; Remove words in parentheses from end.
2122 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2123 (setq subject (substring subject 0 (match-beginning 0)))))
2124 ;; Return subject string.
2127 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2129 (defun gnus-simplify-subject-fuzzy (subject)
2130 (let ((case-fold-search t))
2132 (gnus-set-work-buffer)
2134 (goto-char (point-min))
2135 (and (looking-at "^[ \t]*re:[ \t]*")
2136 (replace-match "" t t))
2137 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*\\'" nil t)
2138 (replace-match "" t t)
2139 (goto-char (point-min)))
2140 (while (re-search-forward "[ \t]+" nil 'move)
2141 (replace-match " " t t))
2142 ;; the 'move above makes sure we are at (point-max)
2143 (and (= (preceding-char) ? )
2147 ;; Add the current buffer to the list of buffers to be killed on exit.
2148 (defun gnus-add-current-to-buffer-list ()
2149 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2151 (defun gnus-string> (s1 s2)
2152 (not (or (string< s1 s2)
2155 ;; Functions accessing headers.
2156 ;; Functions are more convenient than macros in some cases.
2158 (defun gnus-header-number (header)
2159 (header-number header))
2161 (defun gnus-header-subject (header)
2162 (header-subject header))
2164 (defun gnus-header-from (header)
2165 (header-from header))
2167 (defun gnus-header-xref (header)
2168 (header-xref header))
2170 (defun gnus-header-lines (header)
2171 (header-lines header))
2173 (defun gnus-header-date (header)
2174 (header-date header))
2176 (defun gnus-header-id (header)
2179 (defun gnus-header-references (header)
2180 (header-references header))
2182 ;;; General various misc type functions.
2184 (defun gnus-clear-system ()
2185 "Clear all variables and buffers."
2186 ;; Clear Gnus variables.
2187 (let ((variables gnus-variable-list))
2189 (set (car variables) nil)
2190 (setq variables (cdr variables))))
2191 ;; Clear other internal variables.
2192 (setq gnus-list-of-killed-groups nil
2193 gnus-have-read-active-file nil
2194 gnus-newsrc-alist nil
2195 gnus-newsrc-hashtb nil
2196 gnus-killed-list nil
2197 gnus-zombie-list nil
2198 gnus-killed-hashtb nil
2199 gnus-active-hashtb nil
2200 gnus-moderated-list nil
2201 gnus-description-hashtb nil
2202 gnus-newsgroup-headers nil
2203 gnus-newsgroup-headers-hashtb-by-number nil
2204 gnus-newsgroup-name nil
2205 gnus-server-alist nil
2206 gnus-internal-global-score-files nil
2207 gnus-current-select-method nil)
2208 ;; Reset any score variables.
2209 (and (boundp 'gnus-score-cache)
2210 (set 'gnus-score-cache nil))
2211 ;; Kill the startup file.
2212 (and gnus-current-startup-file
2213 (get-file-buffer gnus-current-startup-file)
2214 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2215 ;; Clear the dribble buffer.
2216 (gnus-dribble-clear)
2217 ;; Kill global KILL file buffer.
2218 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2219 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2220 (gnus-kill-buffer nntp-server-buffer)
2221 ;; Kill Gnus buffers.
2222 (while gnus-buffer-list
2223 (gnus-kill-buffer (car gnus-buffer-list))
2224 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2226 (defun gnus-configure-windows (action &optional force)
2227 "Configure Gnus windows according to the next ACTION.
2228 The ACTION is either a symbol, such as `summary', or a
2229 configuration list such as `(1 1 2)'. If ACTION is not a list,
2230 configuration list is got from the variable gnus-window-configuration.
2231 If FORCE is non-nil, the updating will be done whether it is necessary
2234 (if (listp action) action
2235 (if (listp gnus-window-configuration)
2236 (car (cdr (assq action gnus-window-configuration)))
2237 gnus-window-configuration)))
2238 (grpwin (get-buffer-window gnus-group-buffer))
2239 (subwin (get-buffer-window gnus-summary-buffer))
2240 (artwin (get-buffer-window gnus-article-buffer))
2246 ;; Make split-window-vertically leave focus in upper window.
2247 (split-window-keep-point t))
2248 (if (and (symbolp windows) (fboundp windows))
2249 (funcall windows action)
2250 (if (and (not force)
2251 (or (null windows) ;No configuration is specified.
2252 (and (eq (null grpwin)
2253 (zerop (nth 0 windows)))
2255 (zerop (nth 1 windows)))
2257 (zerop (nth 2 windows))))))
2258 ;; No need to change window configuration.
2260 (select-window (or grpwin subwin artwin (selected-window)))
2261 ;; First of all, compute the height of each window.
2262 (cond (gnus-use-full-window
2263 ;; Take up the entire screen.
2264 (delete-other-windows)
2265 (setq height (window-height (selected-window))))
2267 (setq height (+ (if grpwin (window-height grpwin) 0)
2268 (if subwin (window-height subwin) 0)
2269 (if artwin (window-height artwin) 0)))))
2270 ;; The group buffer exits always. So, use it to extend the
2271 ;; group window so as to get enough window space.
2272 (switch-to-buffer gnus-group-buffer 'norecord)
2273 (and (get-buffer gnus-summary-buffer)
2274 (delete-windows-on gnus-summary-buffer))
2275 (and (get-buffer gnus-article-buffer)
2276 (delete-windows-on gnus-article-buffer))
2277 ;; Compute expected window height.
2278 (setq winsum (apply (function +) windows))
2279 (if (not (zerop (nth 0 windows)))
2280 (setq grpheight (max window-min-height
2281 (/ (* height (nth 0 windows)) winsum))))
2282 (if (not (zerop (nth 1 windows)))
2283 (setq subheight (max window-min-height
2284 (/ (* height (nth 1 windows)) winsum))))
2285 (if (not (zerop (nth 2 windows)))
2286 (if gnus-split-window ;hack by erik
2287 (setq artheight height)
2288 (setq artheight (max window-min-height
2289 (/ (* height (nth 2 windows)) winsum)))))
2290 (setq height (+ grpheight subheight artheight))
2291 (enlarge-window (max 0 (- height (window-height (selected-window)))))
2292 ;; Then split the window.
2293 (if (and (not (zerop artheight))
2294 (or (not (zerop grpheight))
2295 (not (zerop subheight))))
2296 (if gnus-split-window
2297 (split-window-horizontally)
2298 (split-window-vertically (+ grpheight subheight))))
2299 (and (not (zerop grpheight))
2300 (not (zerop subheight))
2301 (split-window-vertically grpheight))
2302 ;; Then select buffers in each window.
2303 (or (zerop grpheight)
2305 (switch-to-buffer gnus-group-buffer 'norecord)
2307 (or (zerop subheight)
2309 (switch-to-buffer gnus-summary-buffer 'norecord)
2311 (or (zerop artheight)
2313 ;; If article buffer does not exist, it will be created
2315 (gnus-article-setup-buffer)
2316 (switch-to-buffer gnus-article-buffer 'norecord)
2317 (setq buffer-read-only t) ; !!! Why!?!
2318 (bury-buffer gnus-summary-buffer)
2319 (bury-buffer gnus-group-buffer)))
2320 (or (zerop subheight)
2322 (pop-to-buffer gnus-summary-buffer)
2323 ;; It seems that some code in this function will set
2324 ;; buffer-read-only to nil. I have absolutely no idea
2326 (setq buffer-read-only t))))))) ; !!! Why!?!
2328 (defun gnus-window-configuration-split (action)
2329 (switch-to-buffer gnus-group-buffer t)
2330 (delete-other-windows)
2331 (split-window-horizontally)
2332 (cond ((memq action '(newsgoups summary))
2333 (if (gnus-buffer-exists-p gnus-summary-buffer)
2334 (switch-to-buffer-other-window gnus-summary-buffer)))
2335 ((eq action 'article)
2336 (switch-to-buffer gnus-summary-buffer t)
2338 (gnus-article-setup-buffer)
2339 (switch-to-buffer gnus-article-buffer t))))
2341 (defun gnus-version ()
2342 "Version numbers of this version of Gnus."
2344 (let ((methods gnus-valid-select-methods)
2347 ;; Go through all the legal select methods and add their version
2348 ;; numbers to the total version string. Only the backends that are
2349 ;; currently in use will have their message numbers taken into
2352 (setq meth (intern (concat (car (car methods)) "-version")))
2354 (stringp (symbol-value meth))
2355 (setq mess (concat mess "; " (symbol-value meth))))
2356 (setq methods (cdr methods)))
2359 (defun gnus-info-find-node ()
2360 "Find Info documentation of Gnus."
2362 ;; Enlarge info window if needed.
2363 (cond ((eq major-mode 'gnus-group-mode)
2364 (gnus-configure-windows '(1 0 0)) ;Take all windows.
2365 (pop-to-buffer gnus-group-buffer))
2366 ((eq major-mode 'gnus-summary-mode)
2367 (gnus-configure-windows '(0 1 0)) ;Take all windows.
2368 (pop-to-buffer gnus-summary-buffer)))
2369 (Info-goto-node (car (cdr (assq major-mode gnus-info-nodes)))))
2372 "Send a bug report to the Gnus maintainers."
2374 (pop-to-buffer "*Gnus Bug*")
2377 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2378 (goto-char (point-min))
2379 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2381 (insert (format "%s\n%s\n\n" (gnus-version) (emacs-version)))
2385 (defun gnus-debug ()
2386 "Attemps to go through the Gnus source file and report what variables have been changed.
2387 The source file has to be in the Emacs load path."
2389 (let ((dirs load-path)
2392 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2395 (set-buffer (get-buffer-create "*gnus bug info*"))
2396 (buffer-disable-undo (current-buffer))
2398 (insert-file-contents file)
2399 (goto-char (point-min))
2400 (or (search-forward "\n;; Internal variables" nil t)
2401 (error "Malformed sources"))
2402 (narrow-to-region (point-min) (point))
2403 (goto-char (point-min))
2404 (while (setq expr (condition-case ()
2405 (read (current-buffer)) (error nil)))
2406 (and (eq (car expr) 'defvar)
2407 (stringp (nth 3 expr))
2408 (not (equal (eval (nth 2 expr))
2409 (and (boundp (nth 1 expr))
2410 (symbol-value (nth 1 expr)))))
2411 (setq olist (cons (nth 1 expr) olist))))
2412 (kill-buffer (current-buffer)))
2413 (setq dirs (cdr dirs))))
2415 (insert "(setq " (symbol-name (car olist)) " '"
2416 (prin1-to-string (symbol-value (car olist))) ")\n")
2417 (setq olist (cdr olist)))
2420 (defun gnus-overload-functions (&optional overloads)
2421 "Overload functions specified by optional argument OVERLOADS.
2422 If nothing is specified, use the variable gnus-overload-functions."
2424 (overloads (or overloads gnus-overload-functions)))
2426 (setq defs (car overloads))
2427 (setq overloads (cdr overloads))
2428 ;; Load file before overloading function if necessary. Make
2429 ;; sure we cannot use `require' always.
2430 (and (not (fboundp (car defs)))
2431 (car (cdr (cdr defs)))
2432 (load (car (cdr (cdr defs))) nil 'nomessage))
2433 (fset (car defs) (car (cdr defs))))))
2435 (defun gnus-replace-chars-in-string (string from to)
2436 "Replace characters in STRING from FROM to TO."
2437 (let ((string (substring string 0)) ;Copy string.
2438 (len (length string))
2440 ;; Replace all occurrences of FROM with TO.
2442 (if (= (aref string idx) from)
2443 (aset string idx to))
2444 (setq idx (1+ idx)))
2447 (defun gnus-days-between (date1 date2)
2448 ;; Return the number of days between date1 and date2.
2449 (- (gnus-day-number date1) (gnus-day-number date2)))
2451 (defun gnus-day-number (date)
2452 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2453 (timezone-parse-date date))))
2454 (timezone-absolute-from-gregorian
2455 (nth 1 dat) (nth 2 dat) (car dat))))
2457 ;; Returns a floating point number that says how many seconds have
2458 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2459 (defun gnus-seconds-since-epoch (date)
2460 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2461 (timezone-parse-date date)))
2462 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2463 (timezone-parse-time
2464 (aref (timezone-parse-date date) 3))))
2465 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2466 (timezone-parse-date "Jan 1 12:00:00 1970")))
2467 (tday (- (timezone-absolute-from-gregorian
2468 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2469 (timezone-absolute-from-gregorian
2470 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2472 (* (nth 1 ttime) 60)
2473 (* 1.0 (nth 0 ttime) 60 60)
2474 (* 1.0 tday 60 60 24))))
2476 (defun gnus-file-newer-than (file date)
2477 (let ((fdate (nth 5 (file-attributes file))))
2478 (or (> (car fdate) (car date))
2479 (and (= (car fdate) (car date))
2480 (> (nth 1 fdate) (nth 1 date))))))
2482 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2484 (defun gnus-y-or-n-p (prompt)
2489 (defun gnus-yes-or-no-p (prompt)
2491 (yes-or-no-p prompt)
2494 ;; Return a string of length POS+1 representing NUMber in reverse
2495 ;; BASE. The resulting string will be left padded with zeds.
2496 (defun gnus-number-base-x (num pos base)
2501 (aref "zyxwvutsrqponmlkjihgfedcba9876543210" (/ num (expt base pos))))
2503 (% num (expt base pos)) (1- pos) base))))
2505 ;; Check whether to use long file names.
2506 (defun gnus-use-long-file-name (symbol)
2507 ;; The variable has to be set...
2508 (and gnus-use-long-file-name
2509 ;; If it isn't a list, then we return t.
2510 (or (not (listp gnus-use-long-file-name))
2511 ;; If it is a list, and the list contains `symbol', we
2513 (not (memq symbol gnus-use-long-file-name)))))
2515 ;; I suspect there's a better way, but I haven't taken the time to do
2516 ;; it yet. -erik selberg@cs.washington.edu
2517 (defun gnus-dd-mmm (messy-date)
2518 "Return a string like DD-MMM from a big messy string"
2519 (let ((datevec (timezone-parse-date messy-date)))
2521 (or (aref datevec 2) "??")
2524 (nth (1- (string-to-number (aref datevec 1)))
2525 timezone-months-assoc))
2528 ;; Make a hash table (default and minimum size is 255).
2529 ;; Optional argument HASHSIZE specifies the table size.
2530 (defun gnus-make-hashtable (&optional hashsize)
2531 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2533 ;; Make a number that is suitable for hashing; bigger than MIN and one
2535 (defun gnus-create-hash-size (min)
2541 ;;; List and range functions
2543 (defun gnus-last-element (list)
2544 "Return last element of LIST."
2546 (setq list (cdr list)))
2549 (defun gnus-copy-sequence (list)
2550 "Do a complete, total copy of a list."
2551 (if (and (consp list) (not (consp (cdr list))))
2552 (cons (car list) (cdr list))
2553 (mapcar (lambda (elem) (if (consp elem)
2554 (if (consp (cdr elem))
2555 (gnus-copy-sequence elem)
2556 (cons (car elem) (cdr elem)))
2560 (defun gnus-set-difference (list1 list2)
2561 "Return a list of elements of LIST1 that do not appear in LIST2."
2562 (let ((list1 (copy-sequence list1)))
2564 (setq list1 (delq (car list2) list1))
2565 (setq list2 (cdr list2)))
2568 (defun gnus-sorted-complement (list1 list2)
2569 "Return a list of elements of LIST1 that do not appear in LIST2.
2570 Both lists have to be sorted over <."
2572 (while (and list1 list2)
2573 (cond ((= (car list1) (car list2))
2574 (setq list1 (cdr list1)
2576 ((< (car list1) (car list2))
2577 (setq out (cons (car list1) out))
2578 (setq list1 (cdr list1)))
2580 (setq out (cons (car list2) out))
2581 (setq list2 (cdr list2)))))
2582 (nreverse (append (or list1 list2) out))))
2584 (defun gnus-intersection (list1 list2)
2587 (if (memq (car list2) list1)
2588 (setq result (cons (car list2) result)))
2589 (setq list2 (cdr list2)))
2592 (defun gnus-sorted-intersection (list1 list2)
2593 ;; LIST1 and LIST2 have to be sorted over <.
2595 (while (and list1 list2)
2596 (cond ((= (car list1) (car list2))
2597 (setq out (cons (car list1) out)
2600 ((< (car list1) (car list2))
2601 (setq list1 (cdr list1)))
2603 (setq list2 (cdr list2)))))
2606 (defun gnus-set-sorted-intersection (list1 list2)
2607 ;; LIST1 and LIST2 have to be sorted over <.
2608 ;; This function modifies LIST1.
2609 (let* ((top (cons nil list1))
2611 (while (and list1 list2)
2612 (cond ((= (car list1) (car list2))
2616 ((< (car list1) (car list2))
2617 (setcdr prev (cdr list1))
2618 (setq list1 (cdr list1)))
2620 (setq list2 (cdr list2)))))
2624 (defun gnus-compress-sequence (numbers &optional always-list)
2625 "Convert list of numbers to a list of ranges or a single range.
2626 If ALWAYS-LIST is non-nil, this function will always release a list of
2628 (let* ((first (car numbers))
2629 (last (car numbers))
2633 (if (not (listp (cdr numbers)))
2636 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2637 ((= (1+ last) (car numbers)) ;Still in sequence
2638 (setq last (car numbers)))
2639 (t ;End of one sequence
2641 (cons (if (= first last) first
2642 (cons first last)) result))
2643 (setq first (car numbers))
2644 (setq last (car numbers))))
2645 (setq numbers (cdr numbers)))
2646 (if (and (not always-list) (null result))
2647 (if (= first last) (list first) (cons first last))
2648 (nreverse (cons (if (= first last) first (cons first last))
2651 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2652 (defun gnus-uncompress-range (ranges)
2653 "Expand a list of ranges into a list of numbers.
2654 RANGES is either a single range on the form `(num . num)' or a list of
2656 (let (first last result)
2660 ((not (listp (cdr ranges)))
2661 (setq first (car ranges))
2662 (setq last (cdr ranges))
2663 (while (<= first last)
2664 (setq result (cons first result))
2665 (setq first (1+ first)))
2669 (if (atom (car ranges))
2670 (if (numberp (car ranges))
2671 (setq result (cons (car ranges) result)))
2672 (setq first (car (car ranges)))
2673 (setq last (cdr (car ranges)))
2674 (while (<= first last)
2675 (setq result (cons first result))
2676 (setq first (1+ first))))
2677 (setq ranges (cdr ranges)))
2678 (nreverse result)))))
2680 (defun gnus-add-to-range (ranges list)
2681 "Return a list of ranges that has all articles from both RANGES and LIST.
2682 Note: LIST has to be sorted over `<'."
2684 (gnus-compress-sequence list t)
2685 (setq list (copy-sequence list))
2686 (or (listp (cdr ranges))
2687 (setq ranges (list ranges)))
2689 ilist lowest highest temp)
2690 (while (and ranges list)
2692 (setq lowest (or (and (atom (car ranges)) (car ranges))
2693 (car (car ranges))))
2694 (while (and list (cdr list) (< (car (cdr list)) lowest))
2695 (setq list (cdr list)))
2696 (if (< (car ilist) lowest)
2699 (setq list (cdr list))
2701 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2702 (setq highest (or (and (atom (car ranges)) (car ranges))
2703 (cdr (car ranges))))
2704 (while (and list (<= (car list) highest))
2705 (setq list (cdr list)))
2706 (setq ranges (cdr ranges)))
2708 (setq out (nconc (gnus-compress-sequence list t) out)))
2709 (setq out (sort out (lambda (r1 r2)
2710 (< (or (and (atom r1) r1) (car r1))
2711 (or (and (atom r2) r2) (car r2))))))
2714 (if (atom (car ranges))
2716 (if (atom (car (cdr ranges)))
2717 (if (= (1+ (car ranges)) (car (cdr ranges)))
2719 (setcar ranges (cons (car ranges)
2720 (car (cdr ranges))))
2721 (setcdr ranges (cdr (cdr ranges)))))
2722 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2724 (setcar (car (cdr ranges)) (car ranges))
2725 (setcar ranges (car (cdr ranges)))
2726 (setcdr ranges (cdr (cdr ranges)))))))
2728 (if (atom (car (cdr ranges)))
2729 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2731 (setcdr (car ranges) (car (cdr ranges)))
2732 (setcdr ranges (cdr (cdr ranges)))))
2733 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2735 (setcdr (car ranges) (cdr (car (cdr ranges))))
2736 (setcdr ranges (cdr (cdr ranges))))))))
2737 (setq ranges (cdr ranges)))
2740 (defun gnus-remove-from-range (ranges list)
2741 "Return a list of ranges that has all articles from LIST removed from RANGES.
2742 Note: LIST has to be sorted over `<'."
2743 ;; !!! This function shouldn't look like this, but I've got a headache.
2744 (gnus-compress-sequence
2745 (gnus-sorted-complement
2746 (gnus-uncompress-range ranges) list)))
2748 (defun gnus-member-of-range (number ranges)
2749 (if (not (listp (cdr ranges)))
2750 (and (>= number (car ranges))
2751 (<= number (cdr ranges)))
2754 (if (numberp (car ranges))
2755 (>= number (car ranges))
2756 (>= number (car (car ranges))))
2758 (if (if (numberp (car ranges))
2759 (= number (car ranges))
2760 (and (>= number (car (car ranges)))
2761 (<= number (cdr (car ranges)))))
2762 (setq not-stop nil))
2763 (setq ranges (cdr ranges)))
2771 (defvar gnus-group-mode-map nil)
2772 (defvar gnus-group-make-map nil)
2773 (defvar gnus-group-list-map nil)
2774 (defvar gnus-group-sub-map nil)
2775 (put 'gnus-group-mode 'mode-class 'special)
2777 (if gnus-group-mode-map
2779 (setq gnus-group-mode-map (make-keymap))
2780 (suppress-keymap gnus-group-mode-map)
2781 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2782 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2783 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2784 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2785 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2786 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2787 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2788 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2789 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2790 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2791 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2792 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2793 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2794 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2795 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2796 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2797 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2798 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2799 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2800 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2801 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2802 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2803 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2804 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2805 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2806 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2807 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2808 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2809 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2810 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2811 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2812 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2813 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2814 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2815 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2816 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2817 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2818 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2819 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2820 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2821 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2822 (define-key gnus-group-mode-map "V" 'gnus-version)
2823 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2824 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2825 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2826 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2827 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2828 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2829 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2830 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2831 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
2832 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2833 (define-key gnus-group-mode-map
2834 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-group)
2835 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
2836 (define-key gnus-group-mode-map ">" 'end-of-buffer)
2838 (define-prefix-command 'gnus-group-make-map)
2839 (define-key gnus-group-mode-map "M" 'gnus-group-make-map)
2840 (define-key gnus-group-make-map "d" 'gnus-group-make-directory-group)
2841 (define-key gnus-group-make-map "h" 'gnus-group-make-help-group)
2842 (define-key gnus-group-make-map "a" 'gnus-group-make-archive-group)
2843 (define-key gnus-group-make-map "k" 'gnus-group-make-kiboze-group)
2844 (define-key gnus-group-make-map "m" 'gnus-group-make-group)
2845 (define-key gnus-group-make-map "E" 'gnus-group-edit-group)
2846 (define-key gnus-group-make-map "e" 'gnus-group-edit-group-method)
2847 (define-key gnus-group-make-map "p" 'gnus-group-edit-group-parameters)
2849 (define-prefix-command 'gnus-group-list-map)
2850 (define-key gnus-group-mode-map "G" 'gnus-group-list-map)
2851 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2852 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2853 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2854 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2855 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2856 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2857 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2858 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2860 (define-prefix-command 'gnus-group-sub-map)
2861 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2862 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2863 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2864 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2865 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2866 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2867 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
2868 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
2870 (defun gnus-group-mode ()
2871 "Major mode for reading news.
2873 All normal editing commands are switched off.
2874 \\<gnus-group-mode-map>
2875 The group buffer lists (some of) the groups available. For instance,
2876 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2877 lists all zombie groups.
2879 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2880 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2882 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2884 The following commands are available:
2886 \\{gnus-group-mode-map}"
2888 (if gnus-visual (gnus-group-make-menu-bar))
2889 (kill-all-local-variables)
2890 (setq mode-line-modified "-- ")
2891 (make-local-variable 'mode-line-format)
2892 (setq mode-line-format (copy-sequence mode-line-format))
2893 (and (equal (nth 3 mode-line-format) " ")
2894 (setcar (nthcdr 3 mode-line-format) ""))
2895 (setq major-mode 'gnus-group-mode)
2896 (setq mode-name "Group")
2897 (gnus-group-set-mode-line)
2898 (setq mode-line-process nil)
2899 (use-local-map gnus-group-mode-map)
2900 (buffer-disable-undo (current-buffer))
2901 (setq truncate-lines t)
2902 (setq buffer-read-only t)
2903 (run-hooks 'gnus-group-mode-hook))
2905 (defun gnus-mouse-pick-group (e)
2908 (gnus-group-read-group nil))
2911 (defun gnus-no-server (&optional arg)
2913 If ARG is a positive number, Gnus will use that as the
2914 startup level. If ARG is nil, Gnus will be started at level 2.
2915 If ARG is non-nil and not a positive number, Gnus will
2916 prompt the user for the name of an NNTP server to use.
2917 As opposed to `gnus', this command will not connect to the local server."
2919 (gnus (or arg (1- gnus-level-default-subscribed)) t))
2921 (defalias '\(ding\) 'gnus)
2924 (defun gnus (&optional arg dont-connect)
2926 If ARG is non-nil and a positive number, Gnus will use that as the
2927 startup level. If ARG is non-nil and not a positive number, Gnus will
2928 prompt the user for the name of an NNTP server to use."
2930 (if (get-buffer gnus-group-buffer)
2932 (switch-to-buffer gnus-group-buffer)
2933 (gnus-group-get-new-news))
2935 (gnus-read-init-file)
2936 (let ((level (and arg (numberp arg) (> arg 0) arg))
2940 (switch-to-buffer gnus-group-buffer)
2941 (gnus-add-current-to-buffer-list)
2945 (gnus-start-news-server (and arg (not level))))))
2946 (if (and (not dont-connect)
2949 (run-hooks 'gnus-startup-hook)
2950 ;; NNTP server is successfully open.
2951 (gnus-update-format-specifications)
2952 (let ((buffer-read-only nil))
2954 (if (not gnus-inhibit-startup-message)
2956 (gnus-group-startup-message)
2958 (gnus-setup-news nil level)
2959 (and gnus-use-dribble-file (gnus-dribble-open))
2960 (or t (not gnus-novice-user)
2962 (gnus-group-describe-briefly)) ;Show brief help message.
2963 (gnus-group-list-groups level))))))
2965 (defun gnus-group-startup-message (&optional x y)
2966 "Insert startup message in current buffer."
2967 ;; Insert the message.
2984 ;; And then hack it.
2985 ;; 18 is the longest line.
2986 (indent-rigidly (point-min) (point-max)
2987 (/ (max (- (window-width) (or x 28)) 0) 2))
2988 (goto-char (point-min))
2989 ;; +4 is fuzzy factor.
2990 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2992 (defun gnus-group-setup-buffer ()
2993 (or (get-buffer gnus-group-buffer)
2995 (switch-to-buffer gnus-group-buffer)
2996 (gnus-add-current-to-buffer-list)
2997 (gnus-group-mode))))
2999 (defun gnus-group-list-groups (level &optional unread)
3000 "List newsgroups with level LEVEL or lower that have unread alticles.
3001 Default is all subscribed groups.
3002 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3003 (interactive (list (and current-prefix-arg
3004 (prefix-numeric-value current-prefix-arg))))
3005 (setq level (or level gnus-group-default-list-level gnus-level-subscribed))
3006 (gnus-group-setup-buffer) ;May call from out of group buffer
3007 (let ((case-fold-search nil)
3008 (group (gnus-group-group-name)))
3009 (funcall gnus-group-prepare-function level unread nil)
3010 (if (zerop (buffer-size))
3011 (message gnus-no-groups-message)
3012 (goto-char (point-min))
3014 ;; Go to the first group with unread articles.
3015 (gnus-group-search-forward nil nil nil t)
3016 ;; Find the right group to put point on. If the current group
3017 ;; has disapeared in the new listing, try to find the next
3018 ;; one. If no next one can be found, just leave point at the
3019 ;; first newsgroup in the buffer.
3020 (if (not (gnus-goto-char
3021 (text-property-any (point-min) (point-max)
3022 'gnus-group (intern group))))
3023 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3025 (not (gnus-goto-char
3027 (point-min) (point-max) 'gnus-group
3028 (intern (car (car newsrc)))))))
3029 (setq newsrc (cdr newsrc)))
3030 (or newsrc (progn (goto-char (point-max))
3031 (forward-line -1))))))
3032 ;; Adjust cursor point.
3033 (gnus-group-position-cursor))))
3035 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3036 "List all newsgroups with unread articles of level LEVEL or lower.
3037 If ALL is non-nil, list groups that have no unread articles.
3038 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3039 If REGEXP, only list groups matching REGEXP."
3040 (set-buffer gnus-group-buffer)
3041 (let ((buffer-read-only nil)
3042 (newsrc (cdr gnus-newsrc-alist))
3043 (lowest (or lowest 1))
3044 info clevel unread group)
3046 (if (< lowest gnus-level-zombie)
3047 ;; List living groups.
3049 (setq info (car newsrc)
3052 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3053 (and unread ; This group might be bogus
3055 (string-match regexp group))
3056 (<= (setq clevel (car (cdr info))) level)
3058 (or all ; We list all groups?
3059 (eq unread t) ; We list unactivated groups
3060 (> unread 0) ; We list groups with unread articles
3061 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3062 (gnus-group-insert-group-line
3063 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3065 ;; List dead groups.
3066 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3067 (gnus-group-prepare-flat-list-dead
3068 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3069 gnus-level-zombie ?Z
3071 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3072 (gnus-group-prepare-flat-list-dead
3073 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3074 gnus-level-killed ?K regexp))
3076 (gnus-group-set-mode-line)
3077 (setq gnus-have-all-newsgroups all)
3078 (run-hooks 'gnus-group-prepare-hook)))
3080 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3081 ;; List zombies and killed lists somehwat faster, which was
3082 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3083 ;; this by ignoring the group format specification altogether.
3086 (setq group (car groups)
3087 groups (cdr groups))
3088 (if (or (not regexp)
3089 (string-match regexp group))
3092 (insert (format " %c *: %s\n" mark group))
3093 (add-text-properties
3095 (list 'gnus-group (intern group)
3097 'gnus-level level)))))))
3099 (defun gnus-group-real-name (group)
3100 "Find the real name of a foreign newsgroup."
3101 (if (string-match "^[^:]+:" group)
3102 (substring group (match-end 0))
3105 (defun gnus-group-prefixed-name (group method)
3106 "Return the whole name from GROUP and METHOD."
3107 (and (stringp method) (setq method (gnus-server-to-method method)))
3108 (concat (format "%s" (car method))
3110 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3111 (not (string= (nth 1 method) "")))
3112 (concat "+" (nth 1 method)))
3115 (defun gnus-group-real-prefix (group)
3116 "Return the prefix of the current group name."
3117 (if (string-match "^[^:]+:" group)
3118 (substring group 0 (match-end 0))
3121 (defun gnus-group-method-name (group)
3122 "Return the method used for selecting GROUP."
3123 (let ((prefix (gnus-group-real-prefix group)))
3124 (if (equal prefix "")
3126 (if (string-match "^[^\\+]+\\+" prefix)
3127 (list (intern (substring prefix 0 (1- (match-end 0))))
3128 (substring prefix (match-end 0) (1- (length prefix))))
3129 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3131 (defun gnus-group-foreign-p (group)
3132 "Return nil if GROUP is native, non-nil if it is foreign."
3133 (string-match ":" group))
3135 (defun gnus-group-set-info (info &optional method-only-group part)
3136 (let* ((entry (gnus-gethash
3137 (or method-only-group (car info)) gnus-newsrc-hashtb))
3139 (info (if method-only-group (nth 2 entry) info)))
3140 (if (not method-only-group)
3143 (error "Trying to change non-existant group %s" method-only-group))
3144 ;; We have recevied parts of the actual group info - either the
3145 ;; select method or the group parameters. We first check
3146 ;; whether we have to extend the info, and if so, do that.
3147 (let ((len (length info))
3148 (total (if (eq part 'method) 5 6)))
3150 (setcdr (nthcdr (1- len) info)
3151 (make-list (- total len) nil)))
3152 ;; Then we enter the new info.
3153 (setcar (nthcdr (1- total) info) part-info)))
3154 ;; We uncompress some lists of marked articles.
3156 (if (not (setq marked (nth 3 info)))
3159 (or (eq 'score (car (car marked)))
3160 (eq 'bookmark (car (car marked)))
3161 (eq 'killed (car (car marked)))
3162 (setcdr (car marked)
3163 (gnus-uncompress-range (cdr (car marked)))))
3164 (setq marked (cdr marked)))))
3167 ;; This is a new group, so we just create it.
3169 (set-buffer gnus-group-buffer)
3171 ;; It's a foreign group...
3172 (gnus-group-make-group
3173 (gnus-group-real-name (car info))
3174 (prin1-to-string (car (nth 4 info)))
3175 (nth 1 (nth 4 info)))
3176 ;; It's a native group.
3177 (gnus-group-make-group
3179 (prin1-to-string (car gnus-select-method))
3180 (nth 1 gnus-select-method)))
3181 (message "Note: New group created")
3183 (gnus-gethash (gnus-group-prefixed-name
3184 (gnus-group-real-name (car info))
3185 (or (nth 4 info) gnus-select-method))
3186 gnus-newsrc-hashtb))))
3187 ;; Whether it was a new group or not, we now have the entry, so we
3188 ;; can do the update.
3191 (setcar (nthcdr 2 entry) info)
3192 (if (and (not (eq (car entry) t))
3193 (gnus-gethash (car info) gnus-active-hashtb))
3194 (let ((marked (nth 3 info)))
3196 (max 0 (- (length (gnus-list-of-unread-articles
3198 (length (cdr (assq 'tick marked)))
3199 (length (cdr (assq 'dormant marked)))))))))
3200 (error "No such group: %s" (car info)))))
3202 (defun gnus-group-set-method-info (group select-method)
3203 (gnus-group-set-info select-method group 'method))
3205 (defun gnus-group-set-params-info (group params)
3206 (gnus-group-set-info params group 'params))
3208 (defun gnus-group-update-group-line ()
3209 "This function updates the current line in the newsgroup buffer and
3210 moves the point to the colon."
3211 (let* ((buffer-read-only nil)
3212 (group (gnus-group-group-name))
3213 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3216 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3219 (delete-region (point) (progn (forward-line 1) (point)))
3220 (gnus-group-insert-group-line-info group)
3222 (gnus-group-position-cursor)))
3224 (defun gnus-group-insert-group-line-info (group)
3225 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3229 (setq info (nth 2 entry))
3230 (gnus-group-insert-group-line
3231 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3232 (setq active (gnus-gethash group gnus-active-hashtb))
3233 (gnus-group-insert-group-line
3234 nil group (if (member group gnus-zombie-list) gnus-level-zombie
3236 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3238 (defun gnus-group-insert-group-line (gformat group level marked number method)
3239 (let* ((gformat (or gformat gnus-group-line-format-spec))
3240 (active (gnus-gethash group gnus-active-hashtb))
3241 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3242 (number-of-dormant (length (cdr (assq 'dormant marked))))
3243 (number-of-ticked (length (cdr (assq 'tick marked))))
3244 (number-of-ticked-and-dormant
3245 (+ number-of-ticked number-of-dormant))
3246 (number-of-unread-unticked
3247 (if (numberp number) (int-to-string (max 0 number))
3250 (if (numberp number)
3251 (max 0 (- number-total number))
3253 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3254 ((<= level gnus-level-unsubscribed) ?U)
3255 ((= level gnus-level-zombie) ?Z)
3257 (qualified-group (gnus-group-real-name group))
3258 (newsgroup-description
3259 (if gnus-description-hashtb
3260 (or (gnus-gethash group gnus-description-hashtb) "")
3262 (moderated (if (member group gnus-moderated-list) ?m ? ))
3263 (moderated-string (if (eq moderated ?m) "(m)" ""))
3264 (method (gnus-server-get-method group method))
3265 (news-server (or (car (cdr method)) ""))
3266 (news-method (or (car method) ""))
3268 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3272 (> number-of-ticked 0))
3274 (number (if (eq number t) "*" (+ number number-of-dormant
3276 (buffer-read-only nil)
3281 (insert (eval gformat))
3283 (add-text-properties
3284 b (1+ b) (list 'gnus-group (intern group)
3285 'gnus-unread (if (numberp number)
3286 (string-to-int number-of-unread-unticked)
3289 'gnus-level level))))
3291 (defun gnus-group-update-group (group &optional visible-only)
3292 "Update newsgroup info of GROUP.
3293 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3295 (set-buffer gnus-group-buffer)
3296 (let ((buffer-read-only nil)
3298 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3301 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3303 ;; Buffer may be narrowed.
3306 ;; Search a line to modify. If the buffer is large, the search
3307 ;; takes long time. In most cases, current point is on the line
3308 ;; we are looking for. So, first of all, check current line.
3311 (eq (get-text-property (point) 'gnus-group)
3316 (point-min) (point-max) 'gnus-group (intern group)))))
3317 ;; GROUP is listed in current buffer. So, delete old line.
3321 (delete-region (point) (progn (forward-line 1) (point))))
3322 ;; No such line in the buffer, find out where it's supposed to
3323 ;; go, and insert it there (or at the end of the buffer).
3324 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3326 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3331 (point-min) (point-max)
3332 'gnus-group (intern (car (car entry)))))))
3333 (setq entry (cdr entry)))
3334 (or entry (goto-char (point-max)))))))
3335 (if (or visible (not visible-only))
3336 (gnus-group-insert-group-line-info group))
3337 (gnus-group-set-mode-line))))
3339 (defun gnus-group-set-mode-line ()
3340 (if (memq 'group gnus-updated-mode-lines)
3341 (let* ((gformat (or gnus-group-mode-line-format-spec
3342 (setq gnus-group-mode-line-format-spec
3344 gnus-group-mode-line-format
3345 gnus-group-mode-line-format-alist))))
3346 (news-server (car (cdr gnus-select-method)))
3347 (news-method (car gnus-select-method))
3348 (mode-string (eval gformat))
3350 (if (> (length mode-string) max-len)
3351 (setq mode-string (substring mode-string 0 (- max-len 4))))
3352 (setq mode-line-buffer-identification mode-string)
3353 (set-buffer-modified-p t))))
3355 (defun gnus-group-group-name ()
3356 "Get the name of the newsgroup on the current line."
3357 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3358 (and group (symbol-name group))))
3360 (defun gnus-group-group-level ()
3361 "Get the level of the newsgroup on the current line."
3362 (get-text-property (gnus-point-at-bol) 'gnus-level))
3364 (defun gnus-group-search-forward (&optional backward all level first-too)
3365 "Find the next newsgroup with unread articles.
3366 If BACKWARD is non-nil, find the previous newsgroup instead.
3367 If ALL is non-nil, just find any newsgroup.
3368 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3370 If FIRST-TOO, the current line is also eligeble as a target."
3371 (let ((way (if backward -1 1))
3375 (or first-too (forward-line way))
3383 (get-text-property (point) 'gnus-unread)))
3384 (or (eq unread t) (and unread (> unread 0))))
3385 (let ((lev (get-text-property
3386 (point) 'gnus-level)))
3387 (and lev (<= (get-text-property
3388 (point) 'gnus-level)
3389 gnus-level-subscribed)))))
3391 (let ((lev (get-text-property (point) 'gnus-level)))
3392 (if (and lev (<= lev level))
3397 (setq pos (point))))
3399 (zerop (forward-line way))))
3401 (progn (gnus-group-position-cursor) t)
3402 (if pos (goto-char pos) (goto-char beg))
3405 ;; Gnus group mode commands
3407 (defun gnus-group-read-group (all &optional no-article group)
3408 "Read news in this newsgroup.
3409 If argument ALL is non-nil, already read articles become readable.
3410 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3412 (let ((group (or group (gnus-group-group-name)))
3413 number active marked entry)
3414 (or group (error "No group on current line"))
3416 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3417 ;; This group might be a dead group. In that case we have to get
3418 ;; the number of unread articles from `gnus-active-hashtb'.
3420 (setq number (car entry))
3421 (if (setq active (gnus-gethash group gnus-active-hashtb))
3422 (setq number (- (1+ (cdr active)) (car active)))))
3423 (gnus-summary-read-group
3424 group (or all (and (numberp number)
3425 (zerop (+ number (length (cdr (assq 'tick marked)))
3426 (length (cdr (assq 'dormant marked)))))))
3429 (defun gnus-group-select-group (all)
3430 "Select this newsgroup.
3431 No article is selected automatically.
3432 If argument ALL is non-nil, already read articles become readable."
3434 (gnus-group-read-group all t))
3436 (defun gnus-group-jump-to-group (group)
3437 "Jump to newsgroup GROUP."
3438 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3439 (not (not gnus-read-active-file)))))
3441 (if (equal group "")
3442 (error "empty group name"))
3444 (let ((b (text-property-any (point-min) (point-max)
3445 'gnus-group (intern group))))
3447 ;; Either go to the line in the group buffer...
3449 ;; ... or insert the line.
3451 (gnus-gethash group gnus-active-hashtb)
3452 (gnus-activate-newsgroup group)
3453 (error "%s error: %s" group (gnus-status-message group)))
3455 (gnus-group-update-group group)
3456 (goto-char (text-property-any (point-min) (point-max)
3457 'gnus-group (intern group)))))
3458 ;; Adjust cursor point.
3459 (gnus-group-position-cursor))
3461 (defun gnus-group-next-group (n)
3462 "Go to next N'th newsgroup.
3463 If N is negative, search backward instead.
3464 Returns the difference between N and the number of skips actually
3467 (gnus-group-next-unread-group n t))
3469 (defun gnus-group-next-unread-group (n &optional all level)
3470 "Go to next N'th unread newsgroup.
3471 If N is negative, search backward instead.
3472 If ALL is non-nil, choose any newsgroup, unread or not.
3473 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3474 such group can be found, the next group with a level higher than
3476 Returns the difference between N and the number of skips actually
3479 (let ((backward (< n 0))
3482 (gnus-group-search-forward backward all level))
3484 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
3485 (if level " on this level or higher" "")))
3488 (defun gnus-group-prev-group (n)
3489 "Go to previous N'th newsgroup.
3490 Returns the difference between N and the number of skips actually
3493 (gnus-group-next-unread-group (- n) t))
3495 (defun gnus-group-prev-unread-group (n)
3496 "Go to previous N'th unread newsgroup.
3497 Returns the difference between N and the number of skips actually
3500 (gnus-group-next-unread-group (- n)))
3502 (defun gnus-group-next-unread-group-same-level (n)
3503 "Go to next N'th unread newsgroup on the same level.
3504 If N is negative, search backward instead.
3505 Returns the difference between N and the number of skips actually
3508 (gnus-group-next-unread-group n t (gnus-group-group-level))
3509 (gnus-group-position-cursor))
3511 (defun gnus-group-prev-unread-group-same-level (n)
3512 "Go to next N'th unread newsgroup on the same level.
3513 Returns the difference between N and the number of skips actually
3516 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3517 (gnus-group-position-cursor))
3519 (defun gnus-group-best-unread-group (&optional exclude-group)
3520 "Go to the group with the highest level.
3521 If EXCLUDE-GROUP, do not go to that group."
3523 (goto-char (point-min))
3526 (while (setq unread (get-text-property (point) 'gnus-unread))
3527 (if (and (numberp unread) (> unread 0))
3529 (or best-point (setq best-point (point)))
3530 (if (and (< (get-text-property (point) 'gnus-level) best)
3531 (or (not exclude-group)
3532 (not (equal exclude-group (gnus-group-group-name)))))
3534 (setq best (get-text-property (point) 'gnus-level))
3535 (setq best-point (point))))))
3537 (if best-point (goto-char best-point))
3538 (gnus-summary-position-cursor)
3539 (and best-point (gnus-group-group-name))))
3541 (defun gnus-group-first-unread-group ()
3542 "Go to the first group with unread articles."
3544 (goto-char (point-min))
3545 (or (get-text-property (point) 'gnus-unread)
3546 (gnus-group-next-unread-group 1))
3547 (gnus-group-position-cursor))
3549 (defun gnus-group-enter-server-mode ()
3550 "Jump to the server buffer."
3552 (gnus-server-setup-buffer)
3553 (switch-to-buffer gnus-server-buffer)
3554 (gnus-server-prepare))
3556 (defun gnus-group-make-group (name method address)
3557 "Add a new newsgroup.
3558 The user will be prompted for a NAME, for a select METHOD, and an
3562 (read-string "Group name: ")
3565 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3567 (if (assoc method gnus-valid-select-methods)
3569 (if (memq 'prompt-address
3570 (assoc method gnus-valid-select-methods))
3571 (read-string "Address: ")
3573 (list method nil)))))
3575 (let* ((meth (if address (list (intern method) address) method))
3576 (nname (gnus-group-prefixed-name name meth))
3578 (and (gnus-gethash nname gnus-newsrc-hashtb)
3579 (error "Group %s already exists" nname))
3580 (gnus-group-change-level
3581 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3582 gnus-level-default-subscribed gnus-level-killed
3583 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3584 gnus-newsrc-hashtb) t)
3585 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3587 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3588 (gnus-group-insert-group-line-info nname)
3590 (and (gnus-check-backend-function 'request-create-group nname)
3591 (gnus-request-create-group nname))))
3593 (defun gnus-group-edit-group (group &optional part)
3594 "Edit the group on the current line."
3595 (interactive (list (gnus-group-group-name)))
3596 (let ((done-func (lambda ()
3597 "Exit editing mode and update the information."
3599 (gnus-group-edit-group-done 'part 'group)))
3600 (part (or part 'info))
3602 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3603 (error "No group on current line"))
3604 (setq gnus-winconf-edit-group (current-window-configuration))
3605 (pop-to-buffer gnus-group-edit-buffer)
3606 (gnus-add-current-to-buffer-list)
3608 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3609 (use-local-map (copy-keymap emacs-lisp-mode-map))
3610 (local-set-key "\C-c\C-c" done-func)
3611 ;; We modify the func to let it know what part it is editing.
3612 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3613 (setcar (cdr (cdr (nth 4 done-func))) group)
3618 ";; Type `C-c C-c' after editing the select method.\n\n")
3620 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3622 ";; Type `C-c C-c' after editing the group info.\n\n")))
3623 (let ((cinfo (gnus-copy-sequence info))
3625 (if (not (setq marked (nth 3 cinfo)))
3628 (or (eq 'score (car (car marked)))
3629 (eq 'bookmark (car (car marked)))
3630 (eq 'killed (car (car marked)))
3631 (setcdr (car marked)
3632 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3633 (setq marked (cdr marked))))
3636 (cond ((eq part 'method)
3637 (or (nth 4 info) "native"))
3644 (defun gnus-group-edit-group-method (group)
3645 "Edit the select method of GROUP."
3646 (interactive (list (gnus-group-group-name)))
3647 (gnus-group-edit-group group 'method))
3649 (defun gnus-group-edit-group-parameters (group)
3650 "Edit the group parameters of GROUP."
3651 (interactive (list (gnus-group-group-name)))
3652 (gnus-group-edit-group group 'params))
3654 (defun gnus-group-edit-group-done (part group)
3655 "Get info from buffer, update variables and jump to the group buffer."
3656 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3657 (goto-char (point-min))
3658 (let ((form (read (current-buffer))))
3660 (gnus-group-set-info form)
3661 (gnus-group-set-info form group part))
3662 (kill-buffer (current-buffer))
3663 (and gnus-winconf-edit-group
3664 (set-window-configuration gnus-winconf-edit-group))
3665 (setq gnus-winconf-edit-group nil)
3666 (set-buffer gnus-group-buffer)
3667 (gnus-group-update-group (gnus-group-group-name))
3668 (gnus-group-position-cursor)))
3670 (defun gnus-group-make-help-group ()
3671 "Create the (ding) Gnus documentation group."
3673 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3675 (error "Documentation group already exists"))
3676 (let ((path load-path))
3678 (not (file-exists-p (concat (file-name-as-directory (car path))
3680 (setq path (cdr path)))
3681 (or path (error "Couldn't find doc group"))
3682 (gnus-group-make-group
3684 (concat (file-name-as-directory (car path)) "doc.txt"))
3685 (gnus-group-position-cursor)))
3687 (defun gnus-group-make-archive-group ()
3688 "Create the (ding) Gnus archive group."
3690 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3692 (error "Archive group already exists"))
3693 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3694 (gnus-group-position-cursor))
3696 (defun gnus-group-make-directory-group (dir)
3697 "Create an nndir group.
3698 The user will be prompted for a directory. The contents of this
3699 directory will be used as a newsgroup. The directory should contain
3700 mail messages or news articles in files that have numeric names."
3702 (list (read-file-name "Create group from directory: ")))
3703 (or (file-exists-p dir) (error "No such directory"))
3704 (or (file-directory-p dir) (error "Not a directory"))
3705 (gnus-group-make-group dir "nndir" dir)
3706 (gnus-group-position-cursor))
3708 (defun gnus-group-make-kiboze-group (group address scores)
3709 "Create an nnkiboze group.
3710 The user will be prompted for a name, a regexp to match groups, and
3711 score file entries for articles to include in the group."
3714 (read-string "nnkiboze group name: ")
3715 (read-string "Source groups (regexp): ")
3716 (let ((headers (mapcar (lambda (group) (list group))
3717 '("subject" "from" "number" "date" "message-id"
3718 "references" "chars" "lines" "xref")))
3719 scores header regexp regexps)
3720 (while (not (equal "" (setq header (completing-read
3721 "Match on header: " headers nil t))))
3723 (while (not (equal "" (setq regexp (read-string
3724 (format "Match on %s (string): "
3726 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3727 (setq scores (cons (cons header regexps) scores)))
3729 (gnus-group-make-group group "nnkiboze" address)
3731 (gnus-set-work-buffer)
3732 (let (emacs-lisp-mode-hook)
3733 (pp (list 'setq 'gnus-score-alist
3734 (list 'quote (list scores)))
3736 (write-region (point-min) (point-max)
3737 (concat (or gnus-kill-files-directory "~/News")
3738 "nnkiboze:" group "." gnus-score-file-suffix)))
3739 (gnus-group-position-cursor))
3741 ;; Group sorting commands
3742 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3744 (defun gnus-group-sort-groups ()
3745 "Sort the group buffer using `gnus-group-sort-function'."
3747 (setq gnus-newsrc-alist
3748 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
3749 (gnus-make-hashtable-from-newsrc-alist)
3750 (gnus-get-unread-articles (1+ gnus-level-subscribed))
3751 (gnus-group-list-groups nil))
3753 (defun gnus-group-sort-by-alphabet (info1 info2)
3754 (string< (car info1) (car info2)))
3756 (defun gnus-group-sort-by-unread (info1 info2)
3757 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3758 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3759 (< (or (and (numberp n1) n1) 0)
3760 (or (and (numberp n2) n2) 0))))
3762 (defun gnus-group-sort-by-level (info1 info2)
3763 (< (nth 1 info1) (nth 1 info2)))
3765 ;; Group catching up.
3767 (defun gnus-group-catchup-current (n &optional all)
3768 "Mark all articles not marked as unread in current newsgroup as read.
3769 If prefix argument N is numeric, the ARG next newsgroups will be
3770 caught up. If ALL is non-nil, marked articles will also be marked as
3771 read. Cross references (Xref: header) of articles are ignored.
3772 The difference between N and actual number of newsgroups that were
3773 caught up is returned."
3775 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3779 "Do you really want to mark all articles as read? "
3780 "Mark all unread articles as read? ")))
3786 (gnus-group-catchup (gnus-group-group-name) all)
3787 (gnus-group-update-group-line)
3789 (zerop (gnus-group-next-unread-group 1))))))
3792 (defun gnus-group-catchup-current-all (n)
3793 "Mark all articles in current newsgroup as read.
3794 Cross references (Xref: header) of articles are ignored."
3796 (gnus-group-catchup-current n 'all))
3798 (defun gnus-group-catchup (group &optional all)
3799 "Mark all articles in GROUP as read.
3800 If ALL is non-nil, all articles are marked as read.
3801 The return value is the number of articles that were marked as read,
3802 or nil if no action could be taken."
3803 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3805 (marked (nth 3 (nth 2 entry)))
3807 (if (not (numberp (car entry)))
3808 (message "Can't catch up; non-active group")
3809 ;; Do the updating only if the newsgroup isn't killed
3812 (setq ticked (if all nil (cdr (assq 'tick marked))))
3813 (gnus-update-read-articles group ticked nil ticked)
3814 (if (and all marked)
3815 (setcar (nthcdr 3 (nth 2 entry))
3816 (delq (assq 'dormant marked) marked))))))
3819 (defun gnus-group-expire-articles (newsgroup)
3820 "Expire all expirable articles in the current newsgroup."
3821 (interactive (list (gnus-group-group-name)))
3822 (if (not newsgroup) (error "No current newsgroup"))
3824 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3825 gnus-newsrc-hashtb))))))
3827 (gnus-check-backend-function 'request-expire-articles newsgroup)
3829 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3831 (defun gnus-group-expire-all-groups ()
3832 "Expire all expirable articles in all newsgroups."
3834 (message "Expiring...")
3835 (let ((newsrc (cdr gnus-newsrc-alist)))
3837 (gnus-group-expire-articles (car (car newsrc)))
3838 (setq newsrc (cdr newsrc))))
3839 (message "Expiring...done"))
3841 (defun gnus-group-set-current-level (n level)
3842 "Set the level of the next N groups to LEVEL."
3843 (interactive "p\nnLevel: ")
3844 (or (and (>= level 1) (<= level gnus-level-killed))
3845 (error "Illegal level: %d" level))
3848 (setq group (gnus-group-group-name)))
3849 (and (setq group (gnus-group-group-name))
3850 (message "Changed level of %s from %d to %d"
3851 group (gnus-group-group-level) level)
3852 (gnus-group-change-level group level
3853 (gnus-group-group-level))
3854 (gnus-group-update-group-line))
3857 (gnus-group-position-cursor)
3860 (defun gnus-group-unsubscribe-current-group (arg)
3861 "Toggle subscribe from/to unsubscribe current group."
3863 (let ((group (gnus-group-group-name)))
3864 (or group (error "No newsgroup on current line"))
3865 (or arg (setq arg (if (<= (gnus-group-group-level) gnus-level-subscribed)
3866 gnus-level-default-unsubscribed
3867 gnus-level-default-subscribed)))
3868 (gnus-group-unsubscribe-group group arg)
3869 (gnus-group-next-group 1)))
3871 (defun gnus-group-unsubscribe-group (group &optional level)
3872 "Toggle subscribe from/to unsubscribe GROUP.
3873 New newsgroup is added to .newsrc automatically."
3875 (list (completing-read "Group: " gnus-active-hashtb nil
3876 gnus-have-read-active-file)))
3877 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3879 ;; Toggle subscription flag.
3880 (gnus-group-change-level
3881 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
3882 gnus-level-subscribed)
3883 (1+ gnus-level-subscribed)
3884 gnus-level-default-subscribed)))
3885 (gnus-group-update-group group))
3886 ((and (stringp group)
3887 (or (not gnus-have-read-active-file)
3888 (gnus-gethash group gnus-active-hashtb)))
3889 ;; Add new newsgroup.
3890 (gnus-group-change-level
3892 (if level level gnus-level-default-subscribed)
3893 (or (and (member group gnus-zombie-list)
3896 (or (and (gnus-group-group-name)
3897 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3898 (gnus-gethash (car (car gnus-newsrc-alist))
3899 gnus-newsrc-hashtb)))
3900 (gnus-group-update-group group))
3901 (t (error "No such newsgroup: %s" group)))
3902 (gnus-group-position-cursor)))
3904 (defun gnus-group-transpose-groups (arg)
3905 "Exchange current newsgroup and previous newsgroup.
3906 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3908 ;; BUG: last newsgroup and the last but one cannot be transposed
3909 ;; since gnus-group-search-forward does not move forward beyond the
3910 ;; last. If we instead use forward-line, no problem, but I don't
3911 ;; want to use it for later extension.
3913 (gnus-group-search-forward t t)
3914 (gnus-group-kill-group 1)
3915 (gnus-group-search-forward nil t)
3916 (gnus-group-yank-group)
3917 (gnus-group-search-forward nil t)
3918 (setq arg (1- arg))))
3920 (defun gnus-group-kill-all-zombies ()
3921 "Kill all zombie newsgroups."
3923 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3924 (setq gnus-zombie-list nil)
3925 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
3926 (goto-char (point-min))
3927 (gnus-group-position-cursor))
3929 (defun gnus-group-kill-region (begin end)
3930 "Kill newsgroups in current region (excluding current point).
3931 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3934 ;; Exclude a line where current point is on.
3948 (beginning-of-line) ;Important when LINES < 1
3949 (gnus-group-kill-group lines)))
3951 (defun gnus-group-kill-group (n)
3952 "The the next N groups.
3953 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3954 However, only groups that were alive can be yanked; already killed
3955 groups or zombie groups can't be yanked.
3956 The return value is the name of the (last) newsgroup that was killed."
3958 (let ((buffer-read-only nil)
3960 (while (>= (setq n (1- n)) 0)
3961 (setq group (gnus-group-group-name))
3963 (signal 'end-of-buffer nil))
3964 (setq level (gnus-group-group-level))
3966 (delete-region (point) (progn (forward-line 1) (point)))
3967 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3968 (setq gnus-list-of-killed-groups
3969 (cons (cons (car entry) (nth 2 entry))
3970 gnus-list-of-killed-groups)))
3971 (gnus-group-change-level
3972 (if entry entry group) gnus-level-killed (if entry nil level)))
3975 (gnus-group-position-cursor)
3978 (defun gnus-group-yank-group (&optional arg)
3979 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3980 inserting it before the current newsgroup. The numeric ARG specifies
3981 how many newsgroups are to be yanked. The name of the (last)
3982 newsgroup yanked is returned."
3984 (if (not arg) (setq arg 1))
3985 (let (info group prev)
3986 (while (>= (setq arg (1- arg)) 0)
3987 (if (not (setq info (car gnus-list-of-killed-groups)))
3988 (error "No more newsgroups to yank"))
3989 (setq group (nth 2 info))
3990 ;; Find which newsgroup to insert this one before - search
3991 ;; backward until something suitable is found. If there are no
3992 ;; other newsgroups in this buffer, just make this newsgroup the
3994 (while (and (not (setq prev (gnus-group-group-name)))
3995 (zerop (forward-line -1))))
3997 (setq prev (car (car gnus-newsrc-alist))))
3998 (gnus-group-change-level
3999 info (nth 2 info) gnus-level-killed
4000 (gnus-gethash prev gnus-newsrc-hashtb)
4002 (gnus-group-insert-group-line-info (nth 1 info))
4003 (setq gnus-list-of-killed-groups
4004 (cdr gnus-list-of-killed-groups)))
4006 (gnus-group-position-cursor)
4009 (defun gnus-group-list-all-groups (arg)
4010 "List all newsgroups with level ARG or lower.
4011 Default is 7, which lists all subscribed and most unsubscribed groups."
4013 (setq arg (or arg 7))
4014 (gnus-group-list-groups arg t))
4016 (defun gnus-group-list-killed ()
4017 "List all killed newsgroups in the group buffer."
4019 (if (not gnus-killed-list)
4020 (message "No killed groups")
4021 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4022 (goto-char (point-min)))
4023 (gnus-group-position-cursor))
4025 (defun gnus-group-list-zombies ()
4026 "List all zombie newsgroups in the group buffer."
4028 (if (not gnus-zombie-list)
4029 (message "No zombie groups")
4030 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4031 (goto-char (point-min)))
4032 (gnus-group-position-cursor))
4034 (defun gnus-group-get-new-news (&optional arg)
4035 "Get newly arrived articles.
4036 If ARG is non-nil, it should be a number between one and nine to
4037 specify which levels you are interested in re-scanning."
4039 (run-hooks 'gnus-get-new-news-hook)
4040 (if (and gnus-read-active-file (not arg))
4042 (gnus-read-active-file)
4043 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4044 (let ((gnus-read-active-file nil))
4045 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4046 (gnus-group-list-groups
4047 (or gnus-group-always-list-unread arg gnus-level-subscribed)
4048 gnus-have-all-newsgroups))
4050 (defun gnus-group-get-new-news-this-group (n)
4051 "Check for newly arrived news in the current group (and the N-1 next groups).
4052 The difference between N and the number of newsgroup checked is returned.
4053 If N is negative, this group and the N-1 previous groups will be checked."
4055 (let ((way (if (< n 0) -1 1))
4057 (w-p (window-start))
4061 (or (gnus-get-new-news-in-group
4062 (setq group (gnus-group-group-name)))
4065 (message "%s error: %s"
4066 group (gnus-status-message group))))
4068 (zerop (gnus-group-next-group way)))
4070 (if (/= 0 n) (message "No more newsgroups"))
4071 ;; !!! I don't know why the buffer scrolls forward when updating
4072 ;; the first line in the group buffer, but it does. So we set the
4073 ;; window start forcibly.
4074 (set-window-start (get-buffer-window (current-buffer)) w-p)
4077 (defun gnus-get-new-news-in-group (group)
4079 (gnus-activate-newsgroup group)
4081 (gnus-get-unread-articles-in-group
4082 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4083 (gnus-gethash group gnus-active-hashtb))
4084 (gnus-group-update-group-line)
4087 (defun gnus-group-fetch-faq (group)
4088 "Fetch the FAQ for the current group."
4089 (interactive (list (gnus-group-group-name)))
4090 (or group (error "No group name given"))
4091 (let ((file (concat gnus-group-faq-directory group)))
4092 (if (not (file-exists-p file))
4093 (error "No such file: %s" file)
4096 (defun gnus-group-describe-group (force &optional group)
4097 "Display a description of the current newsgroup."
4099 (and force (setq gnus-description-hashtb nil))
4100 (let ((group (or group (gnus-group-group-name)))
4102 (or group (message "No group name given"))
4103 (and (or gnus-description-hashtb
4104 (setq desc (gnus-group-get-description group))
4105 (gnus-read-descriptions-file))
4107 (or desc (gnus-gethash group gnus-description-hashtb)
4108 "No description available")))))
4110 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4111 (defun gnus-group-describe-all-groups (force)
4112 "Pop up a buffer with descriptons of all newsgroups."
4114 (and force (setq gnus-description-hashtb nil))
4115 (if (not (or gnus-description-hashtb
4116 (gnus-read-descriptions-file)))
4117 (error "Couldn't request descriptions file"))
4118 (let ((buffer-read-only nil)
4124 (insert (format " *: %-20s %s\n" (symbol-name group)
4125 (symbol-value group)))
4126 (add-text-properties
4127 b (1+ b) (list 'gnus-group group
4128 'gnus-unread t 'gnus-marked nil
4129 'gnus-level (1+ gnus-level-subscribed))))
4130 gnus-description-hashtb)
4131 (goto-char (point-min))
4132 (gnus-group-position-cursor)))
4134 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4135 (defun gnus-group-apropos (regexp &optional search-description)
4136 "List all newsgroups that have names that match a regexp."
4137 (interactive "sGnus apropos (regexp): ")
4139 (obuf (current-buffer))
4141 ;; Go through all newsgroups that are known to Gnus.
4144 (and (string-match regexp (symbol-name group))
4145 (setq groups (cons (symbol-name group) groups))))
4147 ;; Go through all descriptions that are known to Gnus.
4148 (if search-description
4151 (and (string-match regexp (symbol-value group))
4152 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4153 (setq groups (cons (symbol-name group) groups))))
4154 gnus-description-hashtb))
4156 (message "No groups matched \"%s\"." regexp)
4157 ;; Print out all the groups.
4159 (pop-to-buffer "*Gnus Help*")
4160 (buffer-disable-undo (current-buffer))
4162 (setq groups (sort groups 'string<))
4164 ;; Groups may be entered twice into the list of groups.
4165 (if (not (string= (car groups) prev))
4167 (insert (setq prev (car groups)) "\n")
4168 (if (and gnus-description-hashtb
4169 (setq des (gnus-gethash (car groups)
4170 gnus-description-hashtb)))
4171 (insert " " des "\n"))))
4172 (setq groups (cdr groups)))
4174 (pop-to-buffer obuf)))
4176 (defun gnus-group-description-apropos (regexp)
4177 "List all newsgroups that have names or desccriptions that match a regexp."
4178 (interactive "sGnus description apropos (regexp): ")
4179 (if (not (or gnus-description-hashtb
4180 (gnus-read-descriptions-file)))
4181 (error "Couldn't request descriptions file"))
4182 (gnus-group-apropos regexp t))
4184 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4185 (defun gnus-group-list-matching (level regexp &optional all lowest)
4186 "List all groups with unread articles that match REGEXP.
4187 If the prefix LEVEL is non-nil, it should be a number that says which
4188 level to cut off listing groups.
4189 If ALL, also list groups with no unread articles.
4190 If LOWEST, don't list groups with level lower than LOWEST."
4191 (interactive "P\nsList newsgroups matching: ")
4192 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4193 all (or lowest 1) regexp)
4194 (goto-char (point-min))
4195 (gnus-group-position-cursor))
4197 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4198 "List all groups that match REGEXP.
4199 If the prefix LEVEL is non-nil, it should be a number that says which
4200 level to cut off listing groups.
4201 If LOWEST, don't list groups with level lower than LOWEST."
4202 (interactive "P\nsList newsgroups matching: ")
4203 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4205 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4206 (defun gnus-group-save-newsrc ()
4207 "Save the Gnus startup files."
4209 (gnus-save-newsrc-file))
4211 (defun gnus-group-restart (&optional arg)
4212 "Force Gnus to read the .newsrc file."
4214 (gnus-save-newsrc-file)
4215 (gnus-setup-news 'force)
4216 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4218 (defun gnus-group-read-init-file ()
4219 "Read the Gnus elisp init file."
4221 (gnus-read-init-file))
4223 (defun gnus-group-check-bogus-groups ()
4224 "Check bogus newsgroups."
4226 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4227 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4229 (defun gnus-group-mail ()
4230 "Start composing a mail."
4234 (defun gnus-group-edit-global-kill (article &optional group)
4235 "Edit the global kill file.
4236 If GROUP, edit that local kill file instead."
4238 (setq gnus-current-kill-article article)
4239 (gnus-kill-file-edit-file group)
4241 (substitute-command-keys
4242 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4244 (defun gnus-group-edit-local-kill (article group)
4245 "Edit a local kill file."
4246 (interactive (list nil (gnus-group-group-name)))
4247 (gnus-group-edit-global-kill article group))
4249 (defun gnus-group-force-update ()
4250 "Update `.newsrc' file."
4252 (gnus-save-newsrc-file))
4254 (defun gnus-group-suspend ()
4255 "Suspend the current Gnus session.
4256 In fact, cleanup buffers except for group mode buffer.
4257 The hook gnus-suspend-gnus-hook is called before actually suspending."
4259 (run-hooks 'gnus-suspend-gnus-hook)
4260 ;; Kill Gnus buffers except for group mode buffer.
4261 (let ((group-buf (get-buffer gnus-group-buffer)))
4262 ;; Do this on a separate list in case the user does a ^G before we finish
4263 (let ((gnus-buffer-list
4264 (delq group-buf (delq gnus-dribble-buffer
4265 (append gnus-buffer-list nil)))))
4266 (while gnus-buffer-list
4267 (gnus-kill-buffer (car gnus-buffer-list))
4268 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4271 (setq gnus-buffer-list (list group-buf))
4272 (bury-buffer group-buf)
4273 (delete-windows-on group-buf t)))))
4275 (defun gnus-group-clear-dribble ()
4276 "Clear all information from the dribble buffer."
4278 (gnus-dribble-clear))
4280 (defun gnus-group-exit ()
4281 "Quit reading news after updating .newsrc.eld and .newsrc.
4282 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4284 (if (or noninteractive ;For gnus-batch-kill
4285 (zerop (buffer-size)) ;No news is good news.
4286 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4287 (not gnus-interactive-exit) ;Without confirmation
4289 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4291 (run-hooks 'gnus-exit-gnus-hook)
4292 (gnus-save-newsrc-file)
4293 (gnus-close-backends)
4294 (gnus-clear-system))))
4296 (defun gnus-close-backends ()
4297 ;; Send a close request to all backends that support such a request.
4298 (let ((methods gnus-valid-select-methods)
4301 (if (fboundp (setq func (intern (concat (car (car methods))
4302 "-request-close"))))
4304 (setq methods (cdr methods)))))
4306 (defun gnus-group-quit ()
4307 "Quit reading news without updating .newsrc.eld or .newsrc.
4308 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4310 (if (or noninteractive ;For gnus-batch-kill
4311 (zerop (buffer-size))
4312 (not (gnus-server-opened gnus-select-method))
4314 (not gnus-current-startup-file)
4316 (format "Quit reading news without saving %s? "
4317 (file-name-nondirectory gnus-current-startup-file))))
4319 (run-hooks 'gnus-exit-gnus-hook)
4321 (gnus-close-backends)
4322 (gnus-clear-system))))
4324 (defun gnus-group-describe-briefly ()
4325 "Give a one line description of the group mode commands."
4328 (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")))
4330 (defun gnus-group-browse-foreign-server (method)
4331 "Browse a foreign news server.
4332 If called interactively, this function will ask for a select method
4333 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4334 If not, METHOD should be a list where the first element is the method
4335 and the second element is the address."
4337 (list (list (intern (completing-read
4339 gnus-valid-select-methods nil t "nntp"))
4340 ;; Suggested by mapjph@bath.ac.uk.
4343 (mapcar (lambda (server) (list server))
4344 gnus-secondary-servers)))))
4345 (gnus-browse-foreign-server method))
4349 ;;; Browse Server Mode
4352 (defvar gnus-browse-server-mode-hook nil)
4353 (defvar gnus-browse-server-mode-map nil)
4354 (put 'gnus-browse-server-mode 'mode-class 'special)
4356 (if gnus-browse-server-mode-map
4358 (setq gnus-browse-server-mode-map (make-keymap))
4359 (suppress-keymap gnus-browse-server-mode-map)
4360 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
4361 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
4362 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
4363 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
4364 (define-key gnus-browse-server-mode-map "\177" 'gnus-browse-prev-group)
4365 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
4366 (define-key gnus-browse-server-mode-map "P" 'gnus-browse-prev-group)
4367 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
4368 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
4369 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
4370 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4371 (define-key gnus-browse-server-mode-map "l" 'gnus-browse-exit)
4372 (define-key gnus-browse-server-mode-map "L" 'gnus-browse-exit)
4373 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
4374 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
4375 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-exit)
4376 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
4377 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
4380 (defvar gnus-browse-current-method nil)
4382 (defun gnus-browse-foreign-server (method)
4383 (setq gnus-browse-current-method method)
4384 (let ((gnus-select-method method)
4386 (message "Connecting to %s..." (nth 1 method))
4387 (or (gnus-server-opened method)
4388 (gnus-open-server method)
4389 (error "Unable to contact server: %s" (gnus-status-message method)))
4390 (or (gnus-request-list method)
4391 (error "Couldn't request list: %s" (gnus-status-message method)))
4392 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
4393 (gnus-add-current-to-buffer-list)
4394 (buffer-disable-undo (current-buffer))
4395 (let ((buffer-read-only nil))
4397 (gnus-browse-server-mode)
4398 (setq mode-line-buffer-identification
4400 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4402 (set-buffer nntp-server-buffer)
4403 (let ((cur (current-buffer)))
4405 (delete-matching-lines gnus-ignored-newsgroups)
4406 (while (re-search-forward
4407 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4408 (goto-char (match-end 1))
4409 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4411 (max 0 (- (1+ (read cur)) (read cur))))
4413 (setq groups (sort groups
4415 (string< (car l1) (car l2)))))
4416 (let ((buffer-read-only nil))
4418 (setq group (car groups))
4420 (format "K%7d: %s\n" (cdr group) (car group)))
4421 (setq groups (cdr groups))))
4422 (switch-to-buffer (current-buffer))
4424 (gnus-group-position-cursor)))
4426 (defun gnus-browse-server-mode ()
4427 "Major mode for browsing a foreign server."
4429 (kill-all-local-variables)
4430 (setq mode-line-modified "-- ")
4431 (make-local-variable 'mode-line-format)
4432 (setq mode-line-format (copy-sequence mode-line-format))
4433 (and (equal (nth 3 mode-line-format) " ")
4434 (setcar (nthcdr 3 mode-line-format) ""))
4435 (setq major-mode 'gnus-browse-server-mode)
4436 (setq mode-name "Browse Server")
4437 (setq mode-line-process nil)
4438 (use-local-map gnus-browse-server-mode-map)
4439 (buffer-disable-undo (current-buffer))
4440 (setq truncate-lines t)
4441 (setq buffer-read-only t)
4442 (run-hooks 'gnus-browse-server-mode-hook))
4444 (defun gnus-browse-read-group ()
4445 "Not implemented, and will probably never be."
4447 (error "You can't read while browsing"))
4449 (defun gnus-browse-next-group (n)
4450 "Go to the next group."
4454 (gnus-group-position-cursor)))
4456 (defun gnus-browse-prev-group (n)
4457 "Go to the next group."
4459 (gnus-browse-next-group (- n)))
4461 (defun gnus-browse-unsubscribe-current-group (arg)
4462 "(Un)subscribe to the next ARG groups."
4465 (error "No group at current line."))
4466 (let ((ward (if (< arg 0) -1 1))
4468 (while (and (> arg 0)
4470 (gnus-browse-unsubscribe-group)
4471 (zerop (gnus-browse-next-group ward)))
4472 (setq arg (1- arg)))
4473 (gnus-group-position-cursor)
4474 (if (/= 0 arg) (message "No more newsgroups"))
4477 (defun gnus-browse-unsubscribe-group ()
4479 (buffer-read-only nil)
4483 (if (= (following-char) ?K) (setq sub t))
4484 (re-search-forward ": \\(.*\\)$" nil t)
4485 (setq group (gnus-group-prefixed-name
4486 (buffer-substring (match-beginning 1) (match-end 1))
4487 gnus-browse-current-method))
4492 (gnus-group-change-level
4493 (list t group gnus-level-default-subscribed
4494 nil nil gnus-browse-current-method)
4495 gnus-level-default-subscribed gnus-level-killed
4496 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
4499 (gnus-group-change-level
4500 group gnus-level-killed gnus-level-default-subscribed)
4504 (defun gnus-browse-exit ()
4505 "Quit browsing and return to the group buffer."
4507 (if (eq major-mode 'gnus-browse-server-mode)
4508 (kill-buffer (current-buffer)))
4509 (switch-to-buffer gnus-group-buffer)
4510 (gnus-group-list-groups nil))
4512 (defun gnus-browse-describe-briefly ()
4513 "Give a one line description of the group mode commands."
4516 (substitute-command-keys "\\<gnus-browse-server-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")))
4520 ;;; Gnus summary mode
4523 (defvar gnus-summary-mode-map nil)
4524 (defvar gnus-summary-mark-map nil)
4525 (defvar gnus-summary-mscore-map nil)
4526 (defvar gnus-summary-extract-map nil)
4527 (defvar gnus-summary-extract-view-map nil)
4528 (defvar gnus-summary-article-map nil)
4529 (defvar gnus-summary-thread-map nil)
4530 (defvar gnus-summary-goto-map nil)
4531 (defvar gnus-summary-exit-map nil)
4532 (defvar gnus-summary-various-map nil)
4533 (defvar gnus-summary-interest-map nil)
4534 (defvar gnus-summary-process-map nil)
4535 (defvar gnus-summary-sort-map nil)
4536 (defvar gnus-summary-mgroup-map nil)
4537 (defvar gnus-summary-vsave-map nil)
4539 (put 'gnus-summary-mode 'mode-class 'special)
4541 (if gnus-summary-mode-map
4543 (setq gnus-summary-mode-map (make-keymap))
4544 (suppress-keymap gnus-summary-mode-map)
4546 ;; Non-orthogonal keys
4548 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4549 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4550 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4551 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4552 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4553 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4554 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4555 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4556 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4557 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4558 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4559 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4560 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4561 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4562 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4563 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4564 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4565 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4566 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4567 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4568 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4569 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4570 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4571 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4572 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4573 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4574 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4575 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4576 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4577 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4578 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4579 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4580 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4581 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4582 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4583 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4584 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4585 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4586 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4587 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4588 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4589 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4590 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4591 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4592 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4593 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4594 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4595 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4596 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4597 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4598 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4599 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4600 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4601 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4602 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4603 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4604 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4605 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4606 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4607 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4608 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4609 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4610 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4611 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4612 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4613 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4614 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4615 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4616 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4617 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4618 (define-key gnus-summary-mode-map "V" 'gnus-version)
4619 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4620 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4621 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4622 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4623 (define-key gnus-summary-mode-map
4624 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-article)
4625 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4626 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4627 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
4628 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4629 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4630 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4631 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4632 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4633 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4634 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4635 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4638 ;; Sort of orthogonal keymap
4639 (define-prefix-command 'gnus-summary-mark-map)
4640 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4641 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4642 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4643 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4644 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4645 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4646 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4647 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4648 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4649 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4650 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4651 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4652 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4653 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4654 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4655 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4656 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4657 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4658 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4659 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4660 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4661 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4662 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4663 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4665 (define-prefix-command 'gnus-summary-mscore-map)
4666 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4667 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4668 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4669 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4670 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4672 (define-prefix-command 'gnus-summary-process-map)
4673 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
4674 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
4675 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
4676 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
4677 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
4678 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
4679 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
4680 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
4681 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
4682 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
4684 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4686 (define-prefix-command 'gnus-summary-goto-map)
4687 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4688 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4689 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4690 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4691 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4692 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4693 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4694 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4695 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4696 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4697 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4698 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4699 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4700 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4703 (define-prefix-command 'gnus-summary-thread-map)
4704 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4705 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4706 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4707 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4708 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4709 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4710 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4711 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4712 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4713 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4714 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4715 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4716 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4717 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4720 (define-prefix-command 'gnus-summary-exit-map)
4721 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4722 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4723 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4724 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4725 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4726 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4727 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4730 (define-prefix-command 'gnus-summary-article-map)
4731 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4732 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4733 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4734 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4735 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4736 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4737 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4738 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4739 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4740 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4741 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4742 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4743 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4744 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4745 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4746 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4747 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4748 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4749 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4750 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4751 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4752 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4753 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4754 (define-key gnus-summary-article-map "hf" 'gnus-article-display-x-face)
4755 (define-key gnus-summary-article-map "ht" 'gnus-article-date-ut)
4756 (define-key gnus-summary-article-map "h\C-t" 'gnus-article-date-local)
4757 (define-key gnus-summary-article-map "hT" 'gnus-article-date-lapsed)
4758 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4759 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4762 (define-prefix-command 'gnus-summary-extract-map)
4763 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4764 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4765 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4766 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4767 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4768 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4769 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4770 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4771 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4772 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4773 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4774 (define-key gnus-summary-extract-map "p" 'gnus-uu-decode-postscript)
4775 (define-key gnus-summary-extract-map "P" 'gnus-uu-decode-postscript-and-save)
4778 (define-prefix-command 'gnus-summary-extract-view-map)
4779 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4780 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4781 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4782 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4783 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4784 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4785 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4786 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4787 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4788 (define-key gnus-summary-extract-view-map "p" 'gnus-uu-decode-postscript-view)
4789 (define-key gnus-summary-extract-view-map "P" 'gnus-uu-decode-postscript-and-save-view)
4792 (define-prefix-command 'gnus-summary-various-map)
4793 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4794 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4795 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4796 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4797 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4798 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4799 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4800 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4801 (define-key gnus-summary-various-map "S" 'gnus-summary-reselect-current-group)
4802 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4803 (define-key gnus-summary-various-map "V" 'gnus-version)
4804 (define-key gnus-summary-various-map "f" 'gnus-summary-fetch-faq)
4805 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4806 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4807 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4808 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4809 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4810 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4812 (define-prefix-command 'gnus-summary-vsave-map)
4813 (define-key gnus-summary-various-map "o" 'gnus-summary-vsave-map)
4814 (define-key gnus-summary-vsave-map "o" 'gnus-summary-save-article)
4815 (define-key gnus-summary-vsave-map "m" 'gnus-summary-save-article-mail)
4816 (define-key gnus-summary-vsave-map "r" 'gnus-summary-save-article-rmail)
4817 (define-key gnus-summary-vsave-map "f" 'gnus-summary-save-article-file)
4818 (define-key gnus-summary-vsave-map "h" 'gnus-summary-save-article-folder)
4819 (define-key gnus-summary-vsave-map "p" 'gnus-summary-pipe-output)
4821 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4823 (define-prefix-command 'gnus-summary-sort-map)
4824 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4825 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4826 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4827 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4828 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4829 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4831 (define-prefix-command 'gnus-summary-mgroup-map)
4832 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4833 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4834 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4835 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4836 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4837 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4838 (define-key gnus-summary-mgroup-map "c" 'gnus-summary-copy-article)
4840 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4841 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4847 (defun gnus-summary-mode ()
4848 "Major mode for reading articles.
4850 All normal editing commands are switched off.
4851 \\<gnus-summary-mode-map>
4852 Each line in this buffer represents one article. To read an
4853 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4854 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4857 You can also post articles and send mail from this buffer. To
4858 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4859 of an article, type `\\[gnus-summary-reply]'.
4861 There are approx. one gazillion commands you can execute in this
4862 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
4864 The following commands are available:
4866 \\{gnus-summary-mode-map}"
4868 (if gnus-visual (gnus-summary-make-menu-bar))
4869 (kill-all-local-variables)
4870 (let ((locals gnus-summary-local-variables))
4872 (if (consp (car locals))
4874 (make-local-variable (car (car locals)))
4875 (set (car (car locals)) (eval (cdr (car locals)))))
4876 (make-local-variable (car locals))
4877 (set (car locals) nil))
4878 (setq locals (cdr locals))))
4879 (gnus-update-format-specifications)
4880 (setq mode-line-modified "-- ")
4881 (make-local-variable 'mode-line-format)
4882 (setq mode-line-format (copy-sequence mode-line-format))
4883 (and (equal (nth 3 mode-line-format) " ")
4884 (setcar (nthcdr 3 mode-line-format) ""))
4885 (setq major-mode 'gnus-summary-mode)
4886 (setq mode-name "Summary")
4887 (make-local-variable 'minor-mode-alist)
4888 (gnus-set-mode-line 'summary)
4889 (use-local-map gnus-summary-mode-map)
4890 (buffer-disable-undo (current-buffer))
4891 (setq buffer-read-only t) ;Disable modification
4892 (setq truncate-lines t)
4893 (setq selective-display t)
4894 (setq selective-display-ellipses t) ;Display `...'
4895 (run-hooks 'gnus-summary-mode-hook))
4897 (defun gnus-summary-clear-local-variables ()
4898 (let ((locals gnus-summary-local-variables))
4900 (if (consp (car locals))
4901 (set (car (car locals)) nil)
4902 (set (car locals) nil))
4903 (setq locals (cdr locals)))))
4905 (defun gnus-mouse-pick-article (e)
4908 (gnus-summary-next-page nil t))
4910 (defun gnus-summary-setup-buffer (group)
4911 "Initialize summary buffer."
4912 (let ((buffer (concat "*Summary " group "*")))
4913 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
4914 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
4915 (gnus-add-current-to-buffer-list)
4916 (gnus-summary-mode)))
4918 (defun gnus-set-global-variables ()
4919 ;; Set the global equivalents of the summary buffer-local variables
4920 ;; to the latest values they had. These reflect the summary buffer
4921 ;; that was in action when the last article was fetched.
4922 (if (eq major-mode 'gnus-summary-mode)
4924 (setq gnus-summary-buffer (current-buffer))
4925 (let ((name gnus-newsgroup-name)
4926 (marked gnus-newsgroup-marked)
4927 (unread gnus-newsgroup-unreads)
4928 (headers gnus-current-headers))
4930 (set-buffer gnus-group-buffer)
4931 (setq gnus-newsgroup-name name)
4932 (setq gnus-newsgroup-marked marked)
4933 (setq gnus-newsgroup-unreads unread)
4934 (setq gnus-current-headers headers))))))
4936 (defun gnus-summary-insert-dummy-line (sformat subject number)
4938 (setq sformat gnus-summary-dummy-line-format-spec))
4942 (insert (eval sformat))
4943 (add-text-properties
4945 (list 'gnus-subject (gnus-simplify-subject-re subject)
4950 (defun gnus-summary-insert-line
4951 (sformat header level current unread replied expirable subject-or-nil
4952 &optional dummy score)
4953 (or sformat (setq sformat gnus-summary-line-format-spec))
4955 (make-string (* level gnus-thread-indent-level) ? ))
4956 (lines (or (header-lines header) 0))
4957 (score (or score gnus-summary-default-score 0))
4958 (score-char (if (or (null gnus-summary-default-score)
4959 (= score gnus-summary-default-score)) ?
4960 (if (< score gnus-summary-default-score)
4961 gnus-score-below-mark gnus-score-over-mark)))
4962 (replied (if replied gnus-replied-mark ? ))
4963 (from (header-from header))
4964 (name-address (funcall gnus-extract-address-components from))
4965 (address (car (cdr name-address)))
4966 (name (or (car name-address) (car (cdr name-address))))
4967 (number (header-number header))
4968 (subject (header-subject header))
4969 (buffer-read-only nil)
4970 (opening-bracket (if dummy ?\< ?\[))
4971 (closing-bracket (if dummy ?\> ?\]))
4973 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
4974 (if (not (numberp lines)) (setq lines 0))
4977 (insert (eval sformat))
4978 (add-text-properties
4980 (list 'gnus-subject (gnus-simplify-subject-re subject)
4982 'gnus-mark (or unread gnus-unread-mark ? )
4983 'gnus-thread level))))
4985 (defun gnus-summary-update-line (&optional dont-update)
4986 ;; Update summary line after change.
4987 (or (not gnus-summary-default-score)
4988 gnus-summary-inhibit-highlight
4989 (let ((gnus-summary-inhibit-highlight t)
4990 (article (gnus-summary-article-number)))
4993 (if (and gnus-summary-mark-below
4994 (< (gnus-summary-article-score)
4995 gnus-summary-mark-below))
4996 (and (not (memq article gnus-newsgroup-marked))
4997 (not (memq article gnus-newsgroup-dormant))
4998 (memq article gnus-newsgroup-unreads)
4999 (gnus-summary-mark-article nil gnus-low-score-mark))
5000 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5001 (gnus-summary-mark-article nil gnus-unread-mark))))
5003 (run-hooks 'gnus-visual-summary-update-hook))))))
5005 (defun gnus-summary-update-lines ()
5006 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5007 (and (save-excursion
5008 (set-buffer gnus-summary-buffer)
5009 (goto-char (point-min))
5011 (gnus-summary-update-line)
5012 (forward-line 1)))))
5014 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5015 ;; Sum up all elements (and sub-elements) in a list.
5019 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5022 (if (> number 1) gnus-not-empty-thread-mark
5023 gnus-empty-thread-mark)
5026 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5027 "Start reading news in newsgroup GROUP.
5028 If SHOW-ALL is non-nil, already read articles are also listed.
5029 If NO-ARTICLE is non-nil, no article is selected initially."
5030 (message "Retrieving newsgroup: %s..." group)
5031 (gnus-summary-setup-buffer group)
5032 (let ((did-select (gnus-select-newsgroup group show-all)))
5035 (and (eq major-mode 'gnus-summary-mode)
5036 (not (equal (current-buffer) kill-buffer))
5038 (kill-buffer (current-buffer))
5039 (switch-to-buffer (or kill-buffer gnus-group-buffer))
5040 (gnus-group-next-unread-group 1)))
5042 ((eq did-select 'quit)
5043 (and (eq major-mode 'gnus-summary-mode)
5044 (not (equal (current-buffer) kill-buffer))
5045 (kill-buffer (current-buffer)))
5046 (gnus-kill-buffer kill-buffer)
5047 (switch-to-buffer gnus-group-buffer)
5048 (gnus-group-next-unread-group 1)
5051 (gnus-set-global-variables)
5052 ;; Save the active value in effect when the group was entered.
5053 (setq gnus-newsgroup-active
5055 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5056 ;; You can change the subjects in this hook.
5057 (run-hooks 'gnus-select-group-hook)
5058 ;; Do score processing.
5059 (gnus-possibly-score-headers)
5060 ;; Update the format specifiers.
5061 (gnus-update-format-specifications)
5062 ;; Generate the summary buffer.
5063 (gnus-summary-prepare)
5064 (if (zerop (buffer-size))
5065 (cond (gnus-newsgroup-dormant
5066 (gnus-summary-show-all-dormant))
5067 ((and gnus-newsgroup-scored show-all)
5068 (gnus-summary-show-all-expunged))))
5069 ;; Function `gnus-apply-kill-file' must be called in this hook.
5070 (run-hooks 'gnus-apply-kill-hook)
5071 (if (zerop (buffer-size))
5073 ;; This newsgroup is empty.
5074 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5075 (message "No unread news")
5076 (gnus-kill-buffer kill-buffer))
5079 (let ((gnus-summary-buffer kill-buffer))
5080 (gnus-configure-windows 'newsgroups t))))
5081 ;; Hide conversation thread subtrees. We cannot do this in
5082 ;; gnus-summary-prepare-hook since kill processing may not
5083 ;; work with hidden articles.
5084 (and gnus-show-threads
5085 gnus-thread-hide-subtree
5086 (gnus-summary-hide-all-threads))
5087 ;; Show first unread article if requested.
5088 (goto-char (point-min))
5089 (if (and (not no-article)
5090 gnus-auto-select-first
5091 (gnus-summary-first-unread-article))
5092 (gnus-configure-windows 'article)
5093 (gnus-configure-windows 'summary))
5094 (pop-to-buffer gnus-summary-buffer)
5095 (gnus-set-mode-line 'summary)
5096 (gnus-summary-position-cursor)
5097 ;; If in async mode, we send some info to the backend.
5098 (and gnus-newsgroup-async
5099 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5100 (gnus-request-asynchronous
5102 (if (and gnus-asynchronous-article-function
5103 (fboundp gnus-asynchronous-article-function))
5104 (funcall gnus-asynchronous-article-function
5105 gnus-newsgroup-threads)
5106 gnus-newsgroup-threads)))
5107 (gnus-kill-buffer kill-buffer))))))
5109 (defun gnus-summary-prepare ()
5110 ;; Generate the summary buffer.
5111 (let ((buffer-read-only nil))
5113 (gnus-summary-prepare-threads
5114 (if gnus-show-threads
5115 (gnus-gather-threads
5117 (if gnus-summary-expunge-below
5118 (gnus-make-threads-and-expunge)
5119 (gnus-make-threads))))
5120 gnus-newsgroup-headers)
5122 ;; Erase header retrieval message.
5123 (gnus-summary-update-lines)
5125 ;; Call hooks for modifying summary buffer.
5126 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5127 (goto-char (point-min))
5128 (run-hooks 'gnus-summary-prepare-hook)))
5130 (defun gnus-gather-threads (threads)
5131 "Gather threads that have lost their roots."
5132 (if (not gnus-summary-make-false-root)
5134 (let ((hashtb (gnus-make-hashtable 1023))
5137 thread subject hthread unre-subject whole-subject)
5139 (setq subject (header-subject (car (car threads)))
5140 whole-subject subject)
5141 (and gnus-summary-gather-subject-limit
5142 (or (and (numberp gnus-summary-gather-subject-limit)
5143 (> (length subject) gnus-summary-gather-subject-limit)
5145 (substring subject 0
5146 gnus-summary-gather-subject-limit)))
5147 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5148 (setq subject (gnus-simplify-subject-fuzzy subject)))))
5151 (setq unre-subject (gnus-simplify-subject-re subject))
5154 (or (stringp (car (car hthread)))
5155 (setcar hthread (list whole-subject (car hthread))))
5156 (setcdr (car hthread) (nconc (cdr (car hthread))
5157 (list (car threads))))
5158 (setcdr prev (cdr threads))
5159 (setq threads prev))
5160 (gnus-sethash unre-subject threads hashtb))
5162 (setq threads (cdr threads)))
5165 (defun gnus-make-threads ()
5166 ;; This function takes the dependencies already made by
5167 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5168 ;; through the dependecies in the hash table and finds all the
5169 ;; roots. Roots do not refer back to any valid articles.
5171 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5172 (gnus-build-old-threads))
5175 (if (not (car (symbol-value refs)))
5176 (setq roots (append (cdr (symbol-value refs)) roots))
5177 ;; Ok, these refer back to valid articles, but if
5178 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5179 ;; the root has the same subject as its children. The children
5180 ;; that do not are made into roots and removed from the list
5182 (or gnus-thread-ignore-subject
5183 (let* ((prev (symbol-value refs))
5184 (subject (gnus-simplify-subject-re
5185 (header-subject (car prev))))
5186 (headers (cdr prev)))
5188 (if (not (string= subject
5189 (gnus-simplify-subject-re
5190 (header-subject (car headers)))))
5192 (setq roots (cons (car headers) roots))
5193 (setcdr prev (cdr headers)))
5194 (setq prev headers))
5195 (setq headers (cdr headers)))))))
5196 gnus-newsgroup-dependencies)
5198 (mapcar 'gnus-trim-thread
5200 (mapcar 'gnus-cut-thread
5201 (mapcar 'gnus-make-sub-thread roots))))))
5203 (defun gnus-make-threads-and-expunge ()
5204 ;; This function takes the dependencies already made by
5205 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5206 ;; through the dependecies in the hash table and finds all the
5207 ;; roots. Roots do not refer back to any valid articles.
5209 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5210 (gnus-build-old-threads))
5213 (if (not (car (symbol-value refs)))
5214 (if (and gnus-summary-expunge-below
5215 (not gnus-fetch-old-headers))
5216 (let ((headers (cdr (symbol-value refs))))
5218 (if (not (< (or (cdr (assq (header-number (car headers))
5219 gnus-newsgroup-scored))
5220 gnus-summary-default-score 0)
5221 gnus-summary-expunge-below))
5222 (setq roots (cons (car headers) roots))
5223 (setq gnus-newsgroup-unreads
5224 (delq (header-number (car headers))
5225 gnus-newsgroup-unreads)))
5226 (setq headers (cdr headers))))
5227 (setq roots (append (cdr (symbol-value refs)) roots)))
5228 ;; Ok, these refer back to valid articles, but if
5229 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5230 ;; the root has the same subject as its children. The children
5231 ;; that do not are made into roots and removed from the list
5233 (or gnus-thread-ignore-subject
5234 (let* ((prev (symbol-value refs))
5235 (subject (gnus-simplify-subject-re
5236 (header-subject (car prev))))
5237 (headers (cdr prev)))
5239 (if (not (string= subject
5240 (gnus-simplify-subject-re
5241 (header-subject (car headers)))))
5243 (setq roots (cons (car headers) roots))
5244 (setcdr prev (cdr headers)))
5245 (setq prev headers))
5246 (setq headers (cdr headers)))))
5247 (and gnus-summary-expunge-below
5248 (not gnus-fetch-old-headers)
5249 (let* ((prev (symbol-value refs))
5250 (headers (cdr prev))
5253 (if (not (< (or (cdr (assq (header-number (car headers))
5254 gnus-newsgroup-scored))
5255 gnus-summary-default-score 0)
5256 gnus-summary-expunge-below))
5257 (setq prev (cdr prev))
5258 (setq gnus-newsgroup-unreads
5259 (delq (header-number (car headers))
5260 gnus-newsgroup-unreads))
5261 (setcdr prev (cdr headers))
5262 (setq id (gnus-gethash (header-id (car headers))
5263 gnus-newsgroup-dependencies))
5266 (if (not (< (or (cdr (assq (header-number (car h))
5267 gnus-newsgroup-scored))
5268 gnus-summary-default-score 0)
5269 gnus-summary-expunge-below))
5270 (setq roots (cons (car h) roots)))
5272 (setq headers (cdr headers)))))))
5273 gnus-newsgroup-dependencies)
5275 (mapcar 'gnus-trim-thread
5277 (mapcar 'gnus-cut-thread
5278 (mapcar 'gnus-make-sub-thread roots))))))
5280 (defun gnus-cut-thread (thread)
5281 ;; Remove leaf dormant or ancient articles from THREAD.
5282 (let ((head (car thread))
5283 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5284 (if (and (null tail)
5285 (let ((number (header-number head)))
5286 (or (memq number gnus-newsgroup-ancient)
5287 (memq number gnus-newsgroup-dormant)
5288 (and gnus-summary-expunge-below
5289 (eq gnus-fetch-old-headers 'some)
5290 (< (or (cdr (assq number gnus-newsgroup-scored))
5291 gnus-summary-default-score 0)
5292 gnus-summary-expunge-below)
5294 (setq gnus-newsgroup-unreads
5295 (delq number gnus-newsgroup-unreads))
5298 (list (cons head tail)))))
5300 (defun gnus-trim-thread (thread)
5301 ;; Remove root ancient articles with only one child from THREAD.
5302 (if (and (eq gnus-fetch-old-headers 'some)
5303 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5304 (= (length thread) 2))
5305 (gnus-trim-thread (nth 1 thread))
5308 (defun gnus-make-sub-thread (root)
5309 ;; This function makes a sub-tree for a node in the tree.
5310 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5311 gnus-newsgroup-dependencies)))))
5312 (cons root (mapcar 'gnus-make-sub-thread children))))
5314 (defun gnus-build-old-threads ()
5315 ;; Look at all the articles that refer back to old articles, and
5316 ;; fetch the headers for the articles that aren't there. This will
5317 ;; build complete threads - if the roots haven't been expired by the
5322 (if (not (car (symbol-value refs)))
5324 (setq heads (cdr (symbol-value refs)))
5326 (if (not (memq (header-number (car heads))
5327 gnus-newsgroup-dormant))
5329 (setq id (symbol-name refs))
5330 (while (and (setq id (gnus-build-get-header id))
5331 (not (car (gnus-gethash
5332 id gnus-newsgroup-dependencies)))))
5334 (setq heads (cdr heads)))))))
5335 gnus-newsgroup-dependencies)))
5337 (defun gnus-build-get-header (id)
5338 ;; Look through the buffer of NOV lines and find the header to
5339 ;; ID. Enter this line into the dependencies hash table, and return
5340 ;; the id of the parent article (if any).
5341 (let ((deps gnus-newsgroup-dependencies)
5345 (set-buffer nntp-server-buffer)
5346 (goto-char (point-min))
5347 (while (and (not found) (search-forward id nil t))
5349 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5350 (regexp-quote id))))
5351 (or found (beginning-of-line 2)))
5356 (setq header (gnus-nov-parse-line
5357 (read (current-buffer)) deps))
5358 (setq ref (header-references header))
5359 (string-match "\\(<[^>]+>\\) *$" ref)
5360 (substring ref (match-beginning 1) (match-end 1))))))
5362 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5363 gnus-newsgroup-ancient (cons (header-number header)
5364 gnus-newsgroup-ancient))))))
5366 (defun gnus-sort-threads (threads)
5367 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5368 (let ((fun gnus-thread-sort-functions))
5370 (setq threads (sort threads (car fun))
5374 (defun gnus-thread-header (thread)
5375 ;; Return header of first article in THREAD.
5377 (if (stringp (car thread))
5378 (car (car (cdr thread)))
5382 (defun gnus-thread-sort-by-number (h1 h2)
5383 "Sort threads by root article number."
5384 (let ((h1 (gnus-thread-header h1))
5385 (h2 (gnus-thread-header h2)))
5386 (< (header-number h1) (header-number h2))))
5388 (defun gnus-thread-sort-by-author (h1 h2)
5389 "Sort threads by root author."
5390 (let ((h1 (gnus-thread-header h1))
5391 (h2 (gnus-thread-header h2)))
5393 (let ((extract (funcall
5394 gnus-extract-address-components (header-from h1))))
5395 (or (car extract) (cdr extract)))
5396 (let ((extract (funcall
5397 gnus-extract-address-components (header-from h2))))
5398 (or (car extract) (cdr extract))))))
5400 (defun gnus-thread-sort-by-subject (h1 h2)
5401 "Sort threads by root subject."
5402 (let ((h1 (gnus-thread-header h1))
5403 (h2 (gnus-thread-header h2)))
5405 (downcase (gnus-simplify-subject (header-subject h1)))
5406 (downcase (gnus-simplify-subject (header-subject h2))))))
5408 (defun gnus-thread-sort-by-date (h1 h2)
5409 "Sort threads by root article date."
5410 (let ((h1 (gnus-thread-header h1))
5411 (h2 (gnus-thread-header h2)))
5413 (gnus-sortable-date (header-date h1))
5414 (gnus-sortable-date (header-date h2)))))
5416 (defun gnus-thread-sort-by-score (h1 h2)
5417 "Sort threads by root article score.
5418 Unscored articles will be counted as havin a score of zero."
5419 (let ((h1 (gnus-thread-header h1))
5420 (h2 (gnus-thread-header h2)))
5421 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5422 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5423 (> (or (cdr s1) gnus-summary-default-score 0)
5424 (or (cdr s2) gnus-summary-default-score 0)))))
5426 (defun gnus-thread-sort-by-total-score (h1 h2)
5427 "Sort threads by the sum of all scores in the thread.
5428 Unscored articles will be counted as havin a score of zero."
5429 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5431 (defun gnus-thread-total-score (thread)
5432 ;; This function find the total score of THREAD.
5434 (if (stringp (car thread))
5435 (apply gnus-thread-score-function 0
5436 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5437 (gnus-thread-total-score-1 thread))
5438 (gnus-thread-total-score-1 (list thread))))
5440 (defun gnus-thread-total-score-1 (root)
5441 ;; This function find the total score of the thread below ROOT.
5442 (setq root (car root))
5443 (apply gnus-thread-score-function
5444 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5445 gnus-summary-default-score 0)
5446 (mapcar 'gnus-thread-total-score
5447 (cdr (gnus-gethash (downcase (header-id root))
5448 gnus-newsgroup-dependencies)))))
5450 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5451 (defvar gnus-tmp-prev-subject "")
5453 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5454 (defun gnus-summary-prepare-threads
5455 (threads level &optional not-child no-subject cull)
5456 "Prepare summary buffer from THREADS and indentation LEVEL.
5457 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5458 or a straight list of headers."
5459 (let (thread header number subject clevel)
5461 (setq thread (car threads)
5462 threads (cdr threads))
5463 ;; If `thread' is a cons, hierarchical threads are used. If not,
5464 ;; `thread' is the header.
5466 (setq header (car thread))
5467 (setq header thread)
5469 (or (memq (setq number (header-number header))
5470 gnus-newsgroup-dormant)
5471 (and gnus-summary-expunge-below
5472 (< (or (cdr (assq number gnus-newsgroup-scored))
5473 gnus-summary-default-score 0)
5474 gnus-summary-expunge-below)))
5477 (setq gnus-newsgroup-unreads
5478 (delq number gnus-newsgroup-unreads)))))
5481 ;; The header is a dummy root.
5482 (cond ((eq gnus-summary-make-false-root 'adopt)
5483 ;; We let the first article adopt the rest.
5484 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5485 (setq thread (cdr (cdr thread)))
5487 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5488 (setq thread (cdr thread))))
5489 ((eq gnus-summary-make-false-root 'dummy)
5490 ;; We output a dummy root.
5491 (gnus-summary-insert-dummy-line
5492 nil header (header-number (car (car (cdr thread)))))
5494 ((eq gnus-summary-make-false-root 'empty)
5495 ;; We print the articles with empty subject fields.
5496 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5497 (setq thread (cdr (cdr thread)))
5499 (gnus-summary-prepare-threads
5500 (list (car thread)) 0 nil
5501 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5503 (gnus-simplify-subject-re
5504 (header-subject (car (car thread))))
5505 (gnus-simplify-subject-re header))))))
5506 (setq thread (cdr thread))))
5508 ;; We do not make a root for the gathered
5509 ;; sub-threads at all.
5511 ;; Print the sub-threads.
5512 (and (consp thread) (cdr thread)
5513 (gnus-summary-prepare-threads (cdr thread) clevel)))
5514 ;; The header is a real article.
5516 (setq number (header-number header)
5517 subject (header-subject header))
5518 (and gnus-newsgroup-async
5519 (setq gnus-newsgroup-threads
5520 (cons (cons (header-number header)
5521 (header-lines header)) gnus-newsgroup-threads)))
5522 (gnus-summary-insert-line
5523 nil header level nil
5524 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5525 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5526 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5527 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5528 (t gnus-ancient-mark))
5529 (memq number gnus-newsgroup-replied)
5530 (memq number gnus-newsgroup-expirable)
5532 gnus-summary-same-subject
5533 (if (or (zerop level)
5534 (and gnus-thread-ignore-subject
5536 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5537 (gnus-simplify-subject-re subject)))))
5539 gnus-summary-same-subject))
5541 (cdr (assq number gnus-newsgroup-scored)))
5542 (setq gnus-tmp-prev-subject subject)
5543 ;; Recursively print subthreads.
5544 (and (consp thread) (cdr thread)
5545 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5547 (defun gnus-select-newsgroup (group &optional read-all)
5548 "Select newsgroup GROUP.
5549 If READ-ALL is non-nil, all articles in the group are selected."
5550 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5551 (info (nth 2 entry))
5552 articles header-marks)
5553 (gnus-check-news-server
5554 (setq gnus-current-select-method (gnus-find-method-for-group group)))
5556 (or (gnus-server-opened gnus-current-select-method)
5557 (gnus-open-server gnus-current-select-method)
5558 (error "Couldn't open server"))
5560 (or (and (eq (car entry) t)
5561 (gnus-activate-newsgroup (car info)))
5562 (gnus-request-group group t)
5564 (kill-buffer (current-buffer))
5565 (error "Couldn't request group %s: %s"
5566 group (gnus-status-message group))))
5568 (setq gnus-newsgroup-name group)
5569 (setq gnus-newsgroup-unselected nil)
5570 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5572 (and gnus-asynchronous
5573 (gnus-check-backend-function
5574 'request-asynchronous gnus-newsgroup-name)
5575 (setq gnus-newsgroup-async
5576 (gnus-request-asynchronous gnus-newsgroup-name)))
5578 (setq articles (gnus-articles-to-read group read-all))
5582 (message "Couldn't select newsgroup")
5584 ((eq articles 0) nil)
5586 ;; Init the dependencies hash table.
5587 (setq gnus-newsgroup-dependencies
5588 (gnus-make-hashtable (length articles)))
5589 ;; Retrieve the headers and read them in.
5590 (setq gnus-newsgroup-headers
5591 (if (eq 'nov (setq gnus-headers-retrieved-by
5592 (gnus-retrieve-headers
5593 (if gnus-fetch-old-headers
5594 (cons 1 articles) articles)
5595 gnus-newsgroup-name)))
5597 (gnus-get-newsgroup-headers-xover articles))
5598 (gnus-get-newsgroup-headers)))
5599 ;; If we were to fetch old headers, but the backend didn't
5600 ;; support XOVER, then it is possible we fetched one article
5601 ;; that we shouldn't have. If that's the case, we pop it off the
5603 (and (not (eq gnus-headers-retrieved-by 'nov))
5604 gnus-fetch-old-headers
5605 gnus-newsgroup-headers
5606 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5607 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5608 ;; Remove cancelled articles from the list of unread articles.
5609 (setq gnus-newsgroup-unreads
5610 (gnus-set-sorted-intersection
5611 gnus-newsgroup-unreads
5612 (mapcar (lambda (headers) (header-number headers))
5613 gnus-newsgroup-headers)))
5614 ;; Adjust and set lists of article marks.
5617 (gnus-adjust-marked-articles info)
5618 (setq gnus-newsgroup-marked
5619 (cdr (assq 'tick (setq marked (nth 3 info)))))
5620 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5621 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5622 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5623 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5624 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5625 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5626 (setq gnus-newsgroup-processable nil)))
5627 ;; Check whether auto-expire is to be done in this group.
5628 (setq gnus-newsgroup-auto-expire
5629 (or (and (stringp gnus-auto-expirable-newsgroups)
5630 (string-match gnus-auto-expirable-newsgroups group))
5631 (memq 'auto-expire (nth 5 info))))
5632 ;; First and last article in this newsgroup.
5633 (and gnus-newsgroup-headers
5634 (setq gnus-newsgroup-begin
5635 (header-number (car gnus-newsgroup-headers)))
5636 (setq gnus-newsgroup-end
5637 (header-number (gnus-last-element gnus-newsgroup-headers))))
5638 (setq gnus-reffed-article-number -1)
5639 ;; GROUP is successfully selected.
5640 (or gnus-newsgroup-headers t)))))
5642 (defun gnus-articles-to-read (group read-all)
5643 ;; Find out what articles the user wants to read.
5645 ;; Select all articles if `read-all' is non-nil, or if all the
5646 ;; unread articles are dormant articles.
5648 (= (length gnus-newsgroup-unreads)
5649 (length gnus-newsgroup-dormant)))
5650 (gnus-uncompress-range
5651 (gnus-gethash group gnus-active-hashtb))
5652 gnus-newsgroup-unreads))
5653 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5654 (scored (length scored-list))
5655 (number (length articles))
5656 (marked (+ (length gnus-newsgroup-marked)
5657 (length gnus-newsgroup-dormant)))
5660 (cond ((and (or (<= scored marked)
5662 (numberp gnus-large-newsgroup)
5663 (> number gnus-large-newsgroup))
5667 "How many articles from %s (default %d): "
5668 gnus-newsgroup-name number))))
5669 (if (string-equal input "")
5671 ((and (> scored marked) (< scored number))
5675 "%s %s (%d scored, %d total): "
5676 "How many articles from"
5677 group scored number))))
5678 (if (string-equal input "")
5683 (setq select (if (stringp select) (string-to-number select) select))
5684 (if (or (null select) (zerop select))
5686 (if (and (not (zerop scored)) (<= (abs select) scored))
5688 (setq articles (sort scored-list '<))
5689 (setq number (length articles)))
5690 (setq articles (copy-sequence articles)))
5692 (setq total-articles articles)
5694 (if (< (abs select) number)
5696 ;; Select the N oldest articles.
5697 (setcdr (nthcdr (1- (abs select)) articles) nil)
5698 ;; Select the N most recent articles.
5699 (setq articles (nthcdr (- number select) articles))))
5700 (setq gnus-newsgroup-unselected
5701 (gnus-sorted-intersection
5702 gnus-newsgroup-unreads
5703 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
5706 (defun gnus-killed-articles (killed articles)
5709 (if (inline (gnus-member-of-range (car articles) killed))
5710 (setq out (cons (car articles) out)))
5711 (setq articles (cdr articles)))
5714 (defun gnus-adjust-marked-articles (info &optional active)
5715 "Remove all marked articles that are no longer legal."
5716 (let ((marked-lists (nth 3 info))
5717 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5719 ;; There are many types of marked articles.
5721 (setq m (cdr (setq prev (car marked-lists))))
5722 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5723 ;; Make sure that all ticked articles are a subset of the
5724 ;; unread/unselected articles.
5726 (if (or (memq (car m) gnus-newsgroup-unreads)
5727 (memq (car m) gnus-newsgroup-unselected))
5729 (setcdr prev (cdr m)))
5731 ((eq 'score (car prev))
5732 ;; Scored articles should be a subset of
5733 ;; unread/unselected articles.
5735 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5736 (memq (car (car m)) gnus-newsgroup-unreads))
5738 (setcdr prev (cdr m)))
5740 ((eq 'bookmark (car prev))
5741 ;; Bookmarks should be a subset of active articles.
5743 (if (< (car (car m)) (car active))
5744 (setcdr prev (cdr m))
5747 ((eq 'killed (car prev))
5748 ;; Articles that have been through the kill process are
5749 ;; to be a subset of active articles.
5750 (while (and m (< (or (and (numberp (car m)) (car m))
5753 (setcdr prev (cdr m))
5755 (if (and m (< (or (and (numberp (car m)) (car m))
5758 (setcar (if (numberp (car m)) m (car m)) (car active))))
5759 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
5760 ;; The replied and expirable articles have to be articles
5763 (if (< (car m) (car active))
5764 (setcdr prev (cdr m))
5767 (setq marked-lists (cdr marked-lists)))
5768 ;; Remove all lists that are empty.
5769 (setq marked-lists (nth 3 info))
5772 (while (= 1 (length (car marked-lists)))
5773 (setq marked-lists (cdr marked-lists)))
5774 (setq m (cdr (setq prev marked-lists)))
5776 (if (= 1 (length (car m)))
5777 (setcdr prev (cdr m))
5780 (setcar (nthcdr 3 info) marked-lists)))
5781 ;; Finally, if there are no marked lists at all left, and if there
5782 ;; are no elements after the lists in the info list, we just chop
5783 ;; the info list off before the marked lists.
5784 (and (null marked-lists)
5785 (not (nthcdr 4 info))
5786 (setcdr (nthcdr 2 info) nil)))
5789 (defun gnus-set-marked-articles
5790 (info ticked replied expirable killed dormant bookmark score)
5791 "Enter the various lists of marked articles into the newsgroup info list."
5793 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5794 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5795 (and expirable (setq newmarked (cons (cons 'expire expirable)
5797 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5798 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5799 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5801 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5804 (setcar (nthcdr 3 info) newmarked)
5805 (if (not (nthcdr 4 info))
5806 (setcdr (nthcdr 2 info) nil)
5807 (setcar (nthcdr 3 info) nil)))
5809 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5811 (defun gnus-add-marked-articles (group type articles &optional info force)
5812 ;; Add ARTICLES of TYPE to the info of GROUP.
5813 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5814 ;; add, but replace marked articles of TYPE with ARTICLES.
5815 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5818 (and (not (setq marked (nthcdr 3 info)))
5819 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5820 (and (not (setq m (assq type (car marked))))
5821 (setcar marked (cons (cons type articles) (car marked))))
5824 (nconc m articles)))))
5826 (defun gnus-set-mode-line (where)
5827 "This function sets the mode line of the article or summary buffers.
5828 If WHERE is `summary', the summary mode line format will be used."
5829 (if (memq where gnus-updated-mode-lines)
5832 (set-buffer gnus-summary-buffer)
5833 (let* ((mformat (if (eq where 'article)
5834 gnus-article-mode-line-format-spec
5835 gnus-summary-mode-line-format-spec))
5836 (group-name gnus-newsgroup-name)
5837 (article-number (or gnus-current-article 0))
5838 (unread (- (length gnus-newsgroup-unreads)
5839 (length gnus-newsgroup-dormant)))
5840 (unread-and-unticked
5841 (- unread (length gnus-newsgroup-marked)))
5842 (unselected (length gnus-newsgroup-unselected))
5843 (unread-and-unselected
5844 (cond ((and (zerop unread-and-unticked)
5845 (zerop unselected)) "")
5847 (format "{%d more}" unread-and-unticked))
5848 (t (format "{%d(+%d) more}"
5849 unread-and-unticked unselected))))
5851 (if gnus-current-headers
5852 (header-subject gnus-current-headers) ""))
5853 (max-len (and gnus-mode-non-string-length
5854 (- (frame-width) gnus-mode-non-string-length)))
5855 header) ;; passed as argument to any user-format-funcs
5856 (setq mode-string (eval mformat))
5857 (if (< max-len 4) (setq max-len 4))
5858 (and (numberp max-len)
5860 (if (> (length mode-string) max-len)
5862 (concat (substring mode-string 0 (- max-len 3))
5864 (setq mode-string (format (format "%%-%ds" max-len)
5866 (setq mode-line-buffer-identification mode-string)
5867 (set-buffer-modified-p t))))
5869 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5870 "Go through the HEADERS list and add all Xrefs to a hash table.
5871 The resulting hash table is returned, or nil if no Xrefs were found."
5872 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5874 (gnus-group-foreign-p from-newsgroup)
5876 (assoc (symbol-name (car from-method))
5877 gnus-valid-select-methods))))
5878 (gnus-group-real-prefix from-newsgroup)))
5879 (xref-hashtb (make-vector 63 0))
5880 start group entry number xrefs header)
5882 (setq header (car headers))
5883 (if (and (setq xrefs (header-xref header))
5884 (not (memq (header-number header) unreads)))
5887 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5888 (setq start (match-end 0))
5889 (setq group (concat prefix (substring xrefs (match-beginning 1)
5892 (string-to-int (substring xrefs (match-beginning 2)
5894 (if (setq entry (gnus-gethash group xref-hashtb))
5895 (setcdr entry (cons number (cdr entry)))
5896 (gnus-sethash group (cons number nil) xref-hashtb)))))
5897 (setq headers (cdr headers)))
5898 (if start xref-hashtb nil)))
5900 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
5901 "Look through all the headers and mark the Xrefs as read."
5902 (let ((virtual (memq 'virtual
5903 (assoc (symbol-name (car (gnus-find-method-for-group
5905 gnus-valid-select-methods)))
5906 name entry read info xref-hashtb idlist active num range exps method
5909 (set-buffer gnus-group-buffer)
5910 (if (setq xref-hashtb
5911 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5914 (if (string= from-newsgroup (setq name (symbol-name group)))
5916 (setq idlist (symbol-value group))
5917 ;; Dead groups are not updated.
5919 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5921 (if (stringp (setq nth4 (nth 4 info)))
5922 (setq nth4 (gnus-server-to-method nth4))))
5923 ;; Only do the xrefs if the group has the same
5924 ;; select method as the group we have just read.
5925 (or (gnus-methods-equal-p
5926 nth4 (gnus-find-method-for-group from-newsgroup))
5929 (setq method (gnus-find-method-for-group
5931 (and (equal (car nth4) (car method))
5932 (equal (nth 1 nth4) (nth 1 method))))
5933 gnus-use-cross-reference
5934 (or (not (eq gnus-use-cross-reference t))
5936 ;; Only do cross-references on subscribed
5937 ;; groups, if that is what is wanted.
5938 (<= (nth 1 info) gnus-level-subscribed)))
5941 ;; Set the new list of read articles in this group.
5942 (setq active (gnus-gethash name gnus-active-hashtb))
5943 ;; First peel off all illegal article numbers.
5946 (ticked (cdr (assq 'tick (nth 3 info))))
5947 (dormant (cdr (assq 'dormant (nth 3 info))))
5952 (if (or (> id (cdr active))
5956 (setq idlist (delq id idlist)))
5957 (and (memq id expirable)
5958 (setq exps (cons id exps)))
5959 (setq ids (cdr ids)))))
5960 ;; Update expirable articles.
5961 (gnus-add-marked-articles nil 'expirable exps info)
5962 (and (null (nth 2 info))
5964 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
5965 (setcar (nthcdr 2 info)
5969 (setq idlist (sort idlist '<)))))
5970 ;; Then we have to re-compute how many unread
5971 ;; articles there are in this group.
5976 (setq num (- (1+ (cdr active)) (car active))))
5977 ((not (listp (cdr range)))
5978 (setq num (- (cdr active) (- (1+ (cdr range))
5982 (if (numberp (car range))
5984 (setq num (+ num (- (1+ (cdr (car range)))
5985 (car (car range))))))
5986 (setq range (cdr range)))
5987 (setq num (- (cdr active) num))))
5988 ;; Update the number of unread articles.
5992 (length (cdr (assq 'tick (nth 3 info))))
5994 (cdr (assq 'dormant (nth 3 info)))))))
5995 ;; Update the group buffer.
5996 (gnus-group-update-group name t)))))))
5999 (defun gnus-methods-equal-p (m1 m2)
6000 (let ((m1 (or m1 gnus-select-method))
6001 (m2 (or m2 gnus-select-method)))
6003 (and (eq (car m1) (car m2))
6004 (or (not (memq 'address (assoc (symbol-name (car m1))
6005 gnus-valid-select-methods)))
6006 (equal (nth 1 m1) (nth 1 m2)))))))
6008 (defsubst gnus-header-value ()
6009 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6011 (defun gnus-get-newsgroup-headers ()
6012 (setq gnus-article-internal-prepare-hook nil)
6013 (let ((cur nntp-server-buffer)
6014 (dependencies gnus-newsgroup-dependencies)
6016 headers char article id dep end)
6018 (set-buffer nntp-server-buffer)
6020 ;; Search to the beginning of the next header. Error messages
6021 ;; do not begin with 2 or 3.
6022 (while (re-search-forward "^[23][0-9]+ " nil t)
6023 (let ((header (make-vector 9 nil))
6024 (c (following-char))
6025 (case-fold-search t)
6027 from subject in-reply-to references ref)
6033 (header-set-number header (setq article (read cur)))
6034 ;; This implementation of this function, with nine
6035 ;; search-forwards instead of the one re-search-forward and
6036 ;; a case (which basically was the old function) is actually
6037 ;; about twice as fast, even though it looks messier. You
6038 ;; can't have everything, I guess. Speed and elegance
6039 ;; doesn't always come hand in hand.
6041 (narrow-to-region (point) (save-excursion
6042 (search-forward "\n.\n" nil t)))
6043 (if (search-forward "\nfrom: " nil t)
6044 (header-set-from header (gnus-header-value))
6045 (header-set-from header "(nobody)"))
6047 (if (search-forward "\nsubject: " nil t)
6048 (header-set-subject header (gnus-header-value))
6049 (header-set-subject header "(none)"))
6051 (and (search-forward "\nxref: " nil t)
6052 (header-set-xref header (gnus-header-value)))
6054 (and (search-forward "\nlines: " nil t)
6055 (header-set-lines header (read cur)))
6057 (and (search-forward "\ndate: " nil t)
6058 (header-set-date header (gnus-header-value)))
6060 (if (search-forward "\nmessage-id: " nil t)
6061 (header-set-id header (setq id (gnus-header-value)))
6062 ;; If there was no message-id, we just fake one to make
6063 ;; subsequent routines simpler.
6066 (setq id (concat "none+" (int-to-string
6067 (setq none-id (1+ none-id)))))))
6069 (if (search-forward "\nreferences: " nil t)
6071 (header-set-references header (gnus-header-value))
6072 (setq end (match-end 0))
6079 (search-backward ">" end t)
6082 (search-backward "<" end t)
6084 ;; Get the references from the in-reply-to header if there
6085 ;; ware no references and the in-reply-to header looks
6087 (if (and (search-forward "\nin-reply-to: " nil t)
6088 (setq in-reply-to (gnus-header-value))
6089 (string-match "<[^>]+>" in-reply-to))
6091 (header-set-references
6093 (setq ref (substring in-reply-to (match-beginning 0)
6095 (setq ref (downcase ref)))
6097 ;; We do some threading while we read the headers. The
6098 ;; message-id and the last reference are both entered into
6099 ;; the same hash table. Some tippy-toeing around has to be
6100 ;; done in case an article has arrived before the article
6101 ;; which it refers to.
6102 (if (boundp (setq dep (intern (downcase id) dependencies)))
6103 (if (car (symbol-value dep))
6104 ;; An article with this Message-ID has already
6105 ;; been seen, so we ignore this one, except we add
6106 ;; any additional Xrefs (in case the two articles
6107 ;; came from different servers.
6110 (car (symbol-value dep))
6111 (concat (or (header-xref (car (symbol-value dep))) "")
6112 (or (header-xref header) "")))
6114 (setcar (symbol-value dep) header))
6115 (set dep (list header)))
6118 (if (boundp (setq dep (intern ref dependencies)))
6119 (setcdr (symbol-value dep)
6120 (cons header (cdr (symbol-value dep))))
6121 (set dep (list nil header)))
6122 (setq headers (cons header headers))))
6123 (goto-char (point-max))))))
6124 (nreverse headers)))
6126 ;; The following macros and functions were written by Felix Lee
6127 ;; <flee@cse.psu.edu>.
6129 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
6130 ;; primarily because of garbage collection. -jwz
6131 (defmacro gnus-read-integer (&optional point move-p)
6132 (` ((, (if move-p 'progn 'save-excursion))
6133 (,@ (if point (list (list 'goto-char point))))
6134 (if (and (<= (following-char) ?9)
6135 (>= (following-char) ?0))
6136 (read (current-buffer))
6139 (defmacro gnus-nov-skip-field ()
6140 '(search-forward "\t" eol 'end))
6142 (defmacro gnus-nov-field ()
6145 (progn (gnus-nov-skip-field) (1- (point)))))
6147 ;; Goes through the xover lines and returns a list of vectors
6148 (defun gnus-get-newsgroup-headers-xover (sequence)
6149 "Parse the news overview data in the server buffer, and return a
6150 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6151 ;; Get the Xref when the users reads the articles since most/some
6152 ;; NNTP servers do not include Xrefs when using XOVER.
6153 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6154 (let ((cur nntp-server-buffer)
6155 (dependencies gnus-newsgroup-dependencies)
6157 number headers header)
6159 (set-buffer nntp-server-buffer)
6160 (goto-char (point-min))
6161 (while (and sequence (not (eobp)))
6162 (setq number (read cur))
6163 (while (and sequence (< (car sequence) number))
6164 (setq sequence (cdr sequence)))
6166 (eq number (car sequence))
6168 (setq sequence (cdr sequence))
6170 (inline (gnus-nov-parse-line number dependencies)))
6171 (setq headers (cons header headers)))))
6173 (setq headers (nreverse headers)))
6176 (defun gnus-nov-parse-line (number dependencies)
6177 "Point has to be after the number on the beginning of the line."
6179 header (eol (gnus-point-at-eol)) ref id dep)
6181 ;; overview: [num subject from date id refs chars lines misc]
6183 (narrow-to-region (point) eol)
6188 (gnus-nov-field) ; subject
6189 (gnus-nov-field) ; from
6190 (gnus-nov-field) ; date
6191 (setq id (or (gnus-nov-field)
6194 (setq none (1+ none)))))) ; id
6197 (let ((beg (point)))
6198 (search-forward "\t" eol)
6199 (if (search-backward ">" beg t)
6205 (search-backward "<" beg t)
6208 (gnus-nov-field)) ; refs
6209 (read (current-buffer)) ; chars
6210 (read (current-buffer)) ; lines
6211 (if (/= (following-char) ?\t)
6214 (gnus-nov-field)) ; misc
6219 ;; We build the thread tree.
6221 (if (boundp (setq dep (intern (downcase id) dependencies)))
6222 (if (car (symbol-value dep))
6223 ;; An article with this Message-ID has already been seen,
6224 ;; so we ignore this one, except we add any additional
6225 ;; Xrefs (in case the two articles came from different
6229 (car (symbol-value dep))
6230 (concat (or (header-xref (car (symbol-value dep))) "")
6231 (or (header-xref header) "")))
6233 (setcar (symbol-value dep) header))
6234 (set dep (list header))))
6237 (if (boundp (setq dep (intern (or ref "none")
6239 (setcdr (symbol-value dep)
6240 (cons header (cdr (symbol-value dep))))
6241 (set dep (list nil header)))))
6244 (defun gnus-article-get-xrefs ()
6245 "Fill in the Xref value in `gnus-current-headers', if necessary.
6246 This is meant to be called in `gnus-article-internal-prepare-hook'."
6247 (or (not gnus-use-cross-reference)
6248 (header-xref gnus-current-headers)
6249 (let ((case-fold-search t)
6252 (gnus-narrow-to-headers)
6253 (goto-char (point-min))
6254 (if (or (and (eq (downcase (following-char)) ?x)
6255 (looking-at "Xref:"))
6256 (search-forward "\nXref:" nil t))
6258 (goto-char (1+ (match-end 0)))
6259 (setq xref (buffer-substring (point)
6260 (progn (end-of-line) (point))))
6262 (set-buffer gnus-summary-buffer)
6263 (header-set-xref gnus-current-headers xref))))))))
6265 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6266 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6268 ;; Return a header specified by a NUMBER.
6269 (defun gnus-get-header-by-number (number)
6271 (set-buffer gnus-summary-buffer)
6272 (or gnus-newsgroup-headers-hashtb-by-number
6273 (gnus-make-headers-hashtable-by-number))
6274 (gnus-gethash (int-to-string number)
6275 gnus-newsgroup-headers-hashtb-by-number)))
6277 (defun gnus-make-headers-hashtable-by-number ()
6278 "Make hashtable for the variable gnus-newsgroup-headers by number."
6280 (set-buffer gnus-summary-buffer)
6281 (let ((headers gnus-newsgroup-headers)
6283 (setq gnus-newsgroup-headers-hashtb-by-number
6284 (gnus-make-hashtable (length headers)))
6286 (setq header (car headers))
6287 (gnus-sethash (int-to-string (header-number header))
6288 header gnus-newsgroup-headers-hashtb-by-number)
6289 (setq headers (cdr headers))))))
6291 (defun gnus-more-header-backward ()
6292 "Find new header backward."
6293 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6294 (artnum gnus-newsgroup-begin)
6296 (while (and (not header)
6298 (setq artnum (1- artnum))
6299 (setq header (gnus-read-header artnum)))
6302 (defun gnus-more-header-forward (&optional backward)
6303 "Find new header forward.
6304 If BACKWARD, find new header backward instead."
6306 (gnus-more-header-backward)
6307 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6308 (artnum gnus-newsgroup-end)
6310 (while (and (not header)
6312 (setq artnum (1+ artnum))
6313 (setq header (gnus-read-header artnum)))
6316 (defun gnus-extend-newsgroup (header &optional backward)
6317 "Extend newsgroup selection with HEADER.
6318 Optional argument BACKWARD means extend toward backward."
6320 (let ((artnum (header-number header)))
6321 (setq gnus-newsgroup-headers
6323 (cons header gnus-newsgroup-headers)
6324 (nconc gnus-newsgroup-headers (list header))))
6325 (setq gnus-newsgroup-unselected
6326 (delq artnum gnus-newsgroup-unselected))
6327 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6328 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6330 (defun gnus-summary-work-articles (n)
6331 "Return a list of articles to be worked upon. The prefix argument,
6332 the list of process marked articles, and the current article will be
6333 taken into consideration."
6335 (if (and n (numberp n))
6336 (let ((backward (< n 0))
6340 (setq articles (cons (gnus-summary-article-number)
6342 (gnus-summary-search-forward nil nil backward))
6344 (sort articles (function <)))
6345 (or (reverse gnus-newsgroup-processable)
6346 (list (gnus-summary-article-number))))))
6348 (defun gnus-summary-search-group (&optional backward use-level)
6349 "Search for next unread newsgroup.
6350 If optional argument BACKWARD is non-nil, search backward instead."
6352 (set-buffer gnus-group-buffer)
6354 ;; We don't want to alter current point of group mode buffer.
6355 (if (gnus-group-search-forward
6357 (if use-level (gnus-group-group-level) nil))
6358 (gnus-group-group-name)))))
6360 (defun gnus-summary-best-group (&optional exclude-group)
6361 "Find the name of the best unread group.
6362 If EXCLUDE-GROUP, do not go to this group."
6364 (set-buffer gnus-group-buffer)
6366 (gnus-group-best-unread-group exclude-group))))
6368 (defun gnus-summary-search-subject (&optional backward unread subject)
6369 "Search for article forward.
6370 If BACKWARD is non-nil, search backward.
6371 If UNREAD is non-nil, only unread articles are selected.
6372 If SUBJECT is non-nil, the article which has the same subject will be
6374 (let ((func (if backward 'previous-single-property-change
6375 'next-single-property-change))
6380 (and gnus-summary-check-current unread
6381 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
6385 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6388 (setq pos (funcall func (point) 'gnus-number))
6389 (goto-char (if backward (1- pos) pos))
6393 (eq (get-text-property (point) 'gnus-mark)
6396 (equal (gnus-simplify-subject-re subject)
6397 (gnus-simplify-subject-re
6398 (get-text-property (point)
6399 'gnus-subject)))))))
6400 (if backward (if (bobp) nil (forward-char -1) t)
6401 (if (eobp) nil (forward-char 1) t)))))
6403 (progn (goto-char beg) nil)
6405 (get-text-property (point) 'gnus-number)
6406 (gnus-summary-position-cursor)))))
6408 (defun gnus-summary-search-forward (&optional unread subject backward)
6409 "Search for article forward.
6410 If UNREAD is non-nil, only unread articles are selected.
6411 If SUBJECT is non-nil, the article which has the same subject will be
6413 If BACKWARD is non-nil, the search will be performed backwards instead."
6414 (gnus-summary-search-subject backward unread subject))
6416 (defun gnus-summary-search-backward (&optional unread subject)
6417 "Search for article backward.
6418 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6419 If 2nd optional argument SUBJECT is non-nil, the article which has
6420 the same subject will be searched for."
6421 (gnus-summary-search-forward unread subject t))
6423 (defun gnus-summary-article-number (&optional number-or-nil)
6424 "The article number of the article on the current line.
6425 If there isn's an article number here, then we return the current
6428 (number (get-text-property
6429 (progn (beginning-of-line) (prog1 (point) (goto-char p)))
6431 (if number-or-nil number (or number gnus-current-article))))
6433 (defun gnus-summary-thread-level ()
6434 "The thread level of the article on the current line."
6435 (or (get-text-property (gnus-point-at-bol) 'gnus-thread)
6438 (defun gnus-summary-pseudo-article ()
6439 "The thread level of the article on the current line."
6440 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
6442 (defun gnus-summary-article-mark ()
6443 "The mark on the current line."
6444 (get-text-property (gnus-point-at-bol) 'gnus-mark))
6446 (defun gnus-summary-subject-string ()
6447 "Return current subject string or nil if nothing."
6448 (get-text-property (gnus-point-at-bol) 'gnus-subject))
6450 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6451 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6452 (defun gnus-summary-article-score ()
6453 "Return current article score."
6454 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6455 gnus-summary-default-score 0))
6457 ;; Written by Sudish Joseph <joseph@cis.ohio-state.edu>.
6458 (defun gnus-summary-recenter-new ()
6459 "Center point in the summary window.
6460 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6461 displayed, no centering will be performed."
6462 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6463 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6465 (and gnus-auto-center-summary
6466 (get-buffer-window gnus-article-buffer)
6467 (let* ((height (window-height))
6468 (w-end (window-end))
6469 (top (cond ((< height 4) 0)
6472 (and (= w-end (point-max))
6473 ;; adjust for blank lines at the bottom of the window
6474 (setq top (+ (count-lines (window-start) (point))
6475 (- height (count-lines (window-start) w-end) 2))))
6478 (defun gnus-summary-recenter ()
6479 "Center point in the summary window.
6480 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6481 displayed, no centering will be performed."
6482 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6483 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6484 (let ((top (cond ((< (window-height) 4) 0)
6485 ((< (window-height) 6) 1)
6488 ;; The user has to want it,
6489 gnus-auto-center-summary
6490 ;; the article buffer must be displayed,
6491 (get-buffer-window gnus-article-buffer)
6492 ;; there must be lines left to scroll forward,
6493 (zerop (save-excursion (forward-line (- (window-height) 1 top))))
6496 (get-buffer-window (current-buffer))
6497 (save-excursion (forward-line (- top)) (point))))))
6499 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6500 (defun gnus-short-group-name (newsgroup)
6501 "Convert a long group name to an initialized form.
6502 The last part of the name is left intact: \"rec.arts.anime\" becomes
6506 (if (string-match "\\." newsgroup)
6508 (setq name (concat name (substring newsgroup 0 1))
6509 newsgroup (substring newsgroup (match-end 0))
6510 name (concat name ".")))
6511 (setq name (concat name newsgroup)
6516 (defun gnus-summary-jump-to-group (newsgroup)
6517 "Move point to NEWSGROUP in group mode buffer."
6518 ;; Keep update point of group mode buffer if visible.
6519 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6520 (save-window-excursion
6521 ;; Take care of tree window mode.
6522 (if (get-buffer-window gnus-group-buffer)
6523 (pop-to-buffer gnus-group-buffer))
6524 (gnus-group-jump-to-group newsgroup))
6526 ;; Take care of tree window mode.
6527 (if (get-buffer-window gnus-group-buffer)
6528 (pop-to-buffer gnus-group-buffer)
6529 (set-buffer gnus-group-buffer))
6530 (gnus-group-jump-to-group newsgroup))))
6532 ;; This function returns a list of article numbers based on the
6533 ;; difference between the ranges of read articles in this group and
6534 ;; the range of active articles.
6535 (defun gnus-list-of-unread-articles (group)
6536 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6537 (active (gnus-gethash group gnus-active-hashtb))
6539 unread first nlast unread)
6540 ;; If none are read, then all are unread.
6542 (setq first (car active))
6543 ;; If the range of read articles is a single range, then the
6544 ;; first unread article is the article after the last read
6545 ;; article. Sounds logical, doesn't it?
6546 (if (not (listp (cdr read)))
6547 (setq first (1+ (cdr read)))
6548 ;; `read' is a list of ranges.
6549 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6550 (car (car read)))) 1)
6554 (while (< first nlast)
6555 (setq unread (cons first unread))
6556 (setq first (1+ first))))
6557 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6558 (setq nlast (if (atom (car (cdr read)))
6560 (car (car (cdr read)))))
6561 (setq read (cdr read)))))
6562 ;; And add the last unread articles.
6563 (while (<= first last)
6564 (setq unread (cons first unread))
6565 (setq first (1+ first)))
6566 ;; Return the list of unread articles.
6570 ;; Various summary commands
6572 (defun gnus-summary-universal-argument ()
6573 "Perform any operation on all articles marked with the process mark."
6575 (gnus-set-global-variables)
6576 (let ((articles (reverse gnus-newsgroup-processable))
6578 (or articles (error "No articles marked"))
6579 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6580 (error "Undefined key"))
6582 (gnus-summary-goto-subject (car articles))
6583 (command-execute func)
6584 (gnus-summary-remove-process-mark (car articles))
6585 (setq articles (cdr articles)))))
6587 (defun gnus-summary-toggle-truncation (arg)
6588 "Toggle truncation of summary lines.
6589 With arg, turn line truncation on iff arg is positive."
6591 (setq truncate-lines
6592 (if (null arg) (not truncate-lines)
6593 (> (prefix-numeric-value arg) 0)))
6596 (defun gnus-summary-reselect-current-group (all)
6597 "Once exit and then reselect the current newsgroup.
6598 The prefix argument ALL means to select all articles."
6600 (gnus-set-global-variables)
6601 (let ((current-subject (gnus-summary-article-number)))
6602 (gnus-summary-exit t)
6603 ;; We have to adjust the point of group mode buffer because the
6604 ;; current point was moved to the next unread newsgroup by
6606 (gnus-summary-jump-to-group gnus-newsgroup-name)
6607 (gnus-group-read-group all t)
6608 (gnus-summary-goto-subject current-subject)))
6610 (defun gnus-summary-rescan-group (all)
6611 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6613 (gnus-set-global-variables)
6614 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6615 (let ((group gnus-newsgroup-name))
6616 (gnus-summary-exit t)
6617 (gnus-summary-jump-to-group group)
6619 (set-buffer gnus-group-buffer)
6620 (gnus-group-get-new-news-this-group 1))
6621 (gnus-summary-jump-to-group group)
6622 (gnus-group-read-group all)))
6624 (defun gnus-summary-exit (&optional temporary)
6625 "Exit reading current newsgroup, and then return to group selection mode.
6626 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6628 (gnus-set-global-variables)
6629 (gnus-kill-save-kill-buffer)
6630 (let* ((group gnus-newsgroup-name)
6631 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6632 gnus-newsgroup-name))))
6634 (method (car (gnus-find-method-for-group group)))
6635 (buf (current-buffer)))
6636 (if gnus-newsgroup-kill-headers
6637 (setq gnus-newsgroup-killed
6638 (gnus-compress-sequence
6640 (gnus-set-sorted-intersection
6641 (gnus-uncompress-range gnus-newsgroup-killed)
6642 (setq gnus-newsgroup-unselected
6643 (sort gnus-newsgroup-unselected '<)))
6644 (setq gnus-newsgroup-unreads
6645 (sort gnus-newsgroup-unreads '<))) t)))
6646 (or (listp (cdr gnus-newsgroup-killed))
6647 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6649 (headers gnus-newsgroup-headers))
6650 (gnus-close-group group)
6651 (run-hooks 'gnus-exit-group-hook)
6652 (gnus-update-read-articles
6653 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6654 gnus-newsgroup-marked
6655 t gnus-newsgroup-replied gnus-newsgroup-expirable
6656 gnus-newsgroup-killed gnus-newsgroup-dormant
6657 gnus-newsgroup-bookmarks
6658 (and gnus-save-score gnus-newsgroup-scored))
6659 (and gnus-use-cross-reference
6660 (gnus-mark-xrefs-as-read
6661 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6662 ;; Do adaptive scoring, and possibly save score files.
6663 (and gnus-use-adaptive-scoring
6664 (gnus-score-adaptive))
6665 (and (fboundp 'gnus-score-save)
6666 (funcall 'gnus-score-save))
6667 ;; Do not switch windows but change the buffer to work.
6668 (set-buffer gnus-group-buffer)
6669 (or (eq 'nndigest method)
6670 (gnus-group-update-group group)))
6671 ;; Make sure where I was, and go to next newsgroup.
6672 (if (eq method 'nndigest)
6674 (gnus-group-jump-to-group group)
6675 (gnus-group-next-unread-group 1))
6677 ;; If exiting temporary, caller should adjust group mode
6678 ;; buffer point by itself.
6680 ;; We set all buffer-local variables to nil. It is unclear why
6681 ;; this is needed, but if we don't, buffer-local variables are
6682 ;; not garbage-collected, it seems. This would the lead to en
6683 ;; ever-growing Emacs.
6685 (gnus-summary-clear-local-variables)
6686 ;; We clear the global counterparts of the buffer-local
6687 ;; variables as well, just to be on the safe side.
6688 (set-buffer gnus-group-buffer)
6689 (gnus-summary-clear-local-variables)
6690 (gnus-configure-windows 'article)
6691 (gnus-configure-windows 'newsgroups)
6692 ;; Return to group mode buffer.
6693 (if (eq mode 'gnus-summary-mode)
6694 (gnus-kill-buffer buf))
6695 (if (get-buffer gnus-article-buffer)
6696 (bury-buffer gnus-article-buffer))
6697 (setq gnus-current-select-method gnus-select-method)
6698 (pop-to-buffer gnus-group-buffer)
6699 (gnus-group-jump-to-group group)
6700 (gnus-group-next-group 1)
6701 (if (gnus-buffer-exists-p quit-buffer)
6703 (switch-to-buffer quit-buffer)
6704 (gnus-set-global-variables)
6705 (gnus-configure-windows 'summary))))))
6707 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6708 (defun gnus-summary-exit-no-update (&optional no-questions)
6709 "Quit reading current newsgroup without updating read article info."
6711 (let* ((group gnus-newsgroup-name)
6712 (quit-buffer (cdr (assoc 'quit-buffer
6713 (gnus-find-method-for-group group)))))
6714 (if (or no-questions
6716 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6718 (gnus-close-group group)
6719 (gnus-summary-clear-local-variables)
6720 (set-buffer gnus-group-buffer)
6721 (gnus-summary-clear-local-variables)
6722 ;; Return to group selection mode.
6723 (gnus-configure-windows 'newsgroups)
6724 (if (get-buffer gnus-summary-buffer)
6725 (kill-buffer gnus-summary-buffer))
6726 (if (get-buffer gnus-article-buffer)
6727 (bury-buffer gnus-article-buffer))
6728 (pop-to-buffer gnus-group-buffer)
6729 (if (equal (gnus-group-group-name) group)
6730 (gnus-group-next-group 1))
6731 (if (gnus-buffer-exists-p quit-buffer)
6733 (switch-to-buffer quit-buffer)
6734 (gnus-configure-windows 'summary)))))))
6736 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6737 (defun gnus-summary-fetch-faq (group)
6738 "Fetch the FAQ for the current group."
6739 (interactive (list gnus-newsgroup-name))
6740 (gnus-configure-windows 'article)
6741 (pop-to-buffer gnus-article-buffer)
6742 (find-file (concat gnus-group-faq-directory group)))
6744 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6745 (defun gnus-summary-describe-group (force)
6746 "Describe the current newsgroup."
6748 (gnus-group-describe-group force gnus-newsgroup-name))
6750 (defun gnus-summary-describe-briefly ()
6751 "Describe summary mode commands briefly."
6754 (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")))
6756 ;; Walking around group mode buffer from summary mode.
6758 (defun gnus-summary-next-group (&optional no-article group backward)
6759 "Exit current newsgroup and then select next unread newsgroup.
6760 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6761 If BACKWARD, go to previous group instead."
6763 (gnus-set-global-variables)
6764 (let ((ingroup gnus-newsgroup-name)
6765 (sumbuf (current-buffer))
6767 (gnus-summary-exit t) ;Update all information.
6769 (or (and (numberp (setq num (car (gnus-gethash
6770 group gnus-newsrc-hashtb))))
6774 (gnus-group-jump-to-group group)
6776 (gnus-group-jump-to-group ingroup))
6777 (gnus-summary-search-group backward)
6778 (let ((group (or group (gnus-summary-search-group backward)))
6779 (buf gnus-summary-buffer))
6781 (gnus-summary-exit-no-update t)
6782 (message "Selecting %s..." group)
6783 ;; We are now in group mode buffer.
6784 ;; Make sure group mode buffer point is on GROUP.
6785 (gnus-group-jump-to-group group)
6786 (if (not (eq gnus-auto-select-next 'quietly))
6788 (gnus-summary-read-group group nil no-article buf)
6789 (and (string= gnus-newsgroup-name ingroup)
6790 (bufferp sumbuf) (buffer-name sumbuf)
6792 (set-buffer (setq gnus-summary-buffer sumbuf))
6793 (gnus-summary-exit-no-update t))))
6794 (gnus-summary-read-group group nil no-article buf)
6795 (while (and (string= gnus-newsgroup-name ingroup)
6796 (bufferp sumbuf) (buffer-name sumbuf))
6797 (set-buffer gnus-group-buffer)
6798 (gnus-group-next-unread-group 1)
6800 (gnus-summary-read-group
6801 (gnus-group-group-name) nil no-article buf)))))))
6804 (defun gnus-summary-prev-group (no-article)
6805 "Exit current newsgroup and then select previous unread newsgroup.
6806 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6808 (gnus-summary-next-group no-article nil t))
6810 ;; Walking around summary lines.
6812 (defun gnus-summary-first-subject (unread)
6813 "Go to the first unread subject.
6814 If UNREAD is non-nil, go to the first unread article.
6815 Returns nil if there are no unread articles."
6817 (let ((begin (point)))
6819 (if (not (gnus-goto-char
6820 (text-property-any (point-min) (point-max)
6821 'gnus-mark gnus-unread-mark)))
6823 ;; If there is no unread articles, stay where you are.
6825 (message "No more unread articles")
6828 (goto-char (point-min)))))
6830 (defun gnus-summary-next-subject (n &optional unread dont-display)
6831 "Go to next N'th summary line.
6832 If N is negative, go to the previous N'th subject line.
6833 If UNREAD is non-nil, only unread articles are selected.
6834 The difference between N and the actual number of steps taken is
6837 (let ((backward (< n 0))
6840 (gnus-summary-search-forward unread nil backward))
6842 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6845 (gnus-summary-recenter)
6846 (gnus-summary-position-cursor)))
6849 (defun gnus-summary-next-unread-subject (n)
6850 "Go to next N'th unread summary line."
6852 (gnus-summary-next-subject n t))
6854 (defun gnus-summary-prev-subject (n &optional unread)
6855 "Go to previous N'th summary line.
6856 If optional argument UNREAD is non-nil, only unread article is selected."
6858 (gnus-summary-next-subject (- n) unread))
6860 (defun gnus-summary-prev-unread-subject (n)
6861 "Go to previous N'th unread summary line."
6863 (gnus-summary-next-subject (- n) t))
6865 (defun gnus-summary-goto-subject (article)
6866 "Go the subject line of ARTICLE."
6870 (completing-read "Article number: "
6874 (int-to-string (header-number headers))))
6875 gnus-newsgroup-headers)
6876 nil 'require-match))))
6877 (or article (error "No article number"))
6878 (if (or (eq article (gnus-summary-article-number t))
6881 (point-min) (point-max) 'gnus-number article)))
6884 ;; Walking around summary lines with displaying articles.
6886 (defun gnus-summary-expand-window ()
6887 "Expand summary window to show headers full window."
6889 (gnus-set-global-variables)
6890 (gnus-configure-windows 'summary)
6891 (pop-to-buffer gnus-summary-buffer))
6893 (defun gnus-summary-display-article (article &optional all-header)
6894 "Display ARTICLE in article buffer."
6895 (gnus-set-global-variables)
6898 (gnus-article-prepare article all-header)
6899 (if (eq (gnus-summary-article-mark) ?Z)
6902 (gnus-summary-position-cursor)))
6903 (run-hooks 'gnus-select-article-hook)
6904 (gnus-summary-recenter)
6905 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6907 (gnus-summary-goto-subject article)
6908 ;; Successfully display article.
6909 (gnus-summary-update-line)
6912 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6913 "Select the current article.
6914 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6915 non-nil, the article will be re-fetched even if it already present in
6916 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6918 (and (not pseudo) (gnus-summary-pseudo-article)
6919 (error "This is a pseudo-article."))
6920 (let ((article (or article (gnus-summary-article-number)))
6921 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6922 (if (or (null gnus-current-article)
6923 (null gnus-article-current)
6924 (/= article (cdr gnus-article-current))
6925 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6927 ;; The requested article is different from the current article.
6929 (gnus-summary-display-article article all-headers)
6931 (if all-headers (gnus-article-show-all-headers))
6932 (gnus-configure-windows 'article)
6933 (pop-to-buffer gnus-summary-buffer)
6936 (defun gnus-summary-set-current-mark (&optional current-mark)
6937 "Obsolete function."
6940 (defun gnus-summary-next-article (unread &optional subject backward)
6941 "Select the next article.
6942 If UNREAD, only unread articles are selected.
6943 If SUBJECT, only articles with SUBJECT are selected.
6944 If BACKWARD, the previous article is selected instead of the next."
6946 (let ((opoint (point))
6947 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
6950 ;; Is there such an article?
6951 ((gnus-summary-display-article
6952 (gnus-summary-search-forward unread subject backward))
6953 (gnus-summary-position-cursor))
6954 ;; If not, we try the first unread, if that is wanted.
6956 gnus-auto-select-same
6957 (gnus-summary-first-unread-article))
6958 (message "Wrapped"))
6959 ;; Try to get next/previous article not displayed in this group.
6960 ((and gnus-auto-extend-newsgroup
6961 (not unread) (not subject)
6962 (setq header (gnus-more-header-forward backward)))
6963 (gnus-extend-newsgroup header backward)
6964 (let ((buffer-read-only nil))
6965 (goto-char (if backward (point-min) (point-max)))
6966 (gnus-summary-prepare-threads (list header) 0))
6967 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
6968 gnus-newsgroup-end)))
6969 ;; Go to next/previous group.
6971 (gnus-summary-jump-to-group gnus-newsgroup-name)
6972 (let ((cmd (aref (this-command-keys) 0))
6974 (if (eq gnus-keep-same-level 'best)
6975 (gnus-summary-best-group gnus-newsgroup-name)
6976 (gnus-summary-search-group backward gnus-keep-same-level))))
6977 ;; Keep just the event type of CMD.
6978 (and (listp cmd) (setq cmd (car cmd)))
6979 ;; Select next unread newsgroup automagically.
6981 ((not gnus-auto-select-next)
6982 (message "No more%s articles" (if unread " unread" "")))
6983 ((eq gnus-auto-select-next 'quietly)
6985 (if (eq method 'nndigest)
6987 (message "No more%s articles (%s)..."
6988 (if unread " unread" "")
6989 (if group (concat "selecting " group)
6991 (gnus-summary-next-group nil group backward)))
6993 (let ((keystrokes '(?\C-n ?\C-p))
6995 (while (or (null key) (memq key keystrokes))
6997 "No more%s articles%s" (if unread " unread" "")
6998 (if (and group (not (eq method 'nndigest)))
6999 (format " (Type %s for %s [%s])"
7000 (single-key-description cmd) group
7001 (car (gnus-gethash group gnus-newsrc-hashtb)))
7002 (format " (Type %s to exit %s)"
7003 (single-key-description cmd)
7004 gnus-newsgroup-name)))
7005 ;; Confirm auto selection.
7006 (let* ((event (read-event)))
7007 (setq key (if (listp event) (car event) event))
7008 (if (member key keystrokes)
7009 (let ((obuf (current-buffer)))
7010 (switch-to-buffer gnus-group-buffer)
7011 (gnus-group-jump-to-group group)
7012 (execute-kbd-macro (char-to-string key))
7013 (setq group (gnus-group-group-name))
7014 (switch-to-buffer obuf)))))
7016 (if (or (not group) (eq method 'nndigest))
7018 (gnus-summary-next-group nil group backward))
7019 (setq unread-command-events (list key)))))))))))
7021 (defun gnus-summary-next-unread-article ()
7022 "Select unread article after current one."
7024 (gnus-summary-next-article t (and gnus-auto-select-same
7025 (gnus-summary-subject-string))))
7027 (defun gnus-summary-prev-article (unread &optional subject)
7028 "Select the article after the current one.
7029 If UNREAD is non-nil, only unread articles are selected."
7031 (gnus-summary-next-article unread subject t))
7033 (defun gnus-summary-prev-unread-article ()
7034 "Select unred article before current one."
7036 (gnus-summary-prev-article t (and gnus-auto-select-same
7037 (gnus-summary-subject-string))))
7039 (defun gnus-summary-next-page (lines &optional circular)
7040 "Show next page of selected article.
7041 If end of article, select next article.
7042 Argument LINES specifies lines to be scrolled up.
7043 If CIRCULAR is non-nil, go to the start of the article instead of
7044 instead of selecting the next article when reaching the end of the
7047 (setq gnus-summary-buffer (current-buffer))
7048 (gnus-set-global-variables)
7049 (let ((article (gnus-summary-article-number))
7051 (if (or (null gnus-current-article)
7052 (null gnus-article-current)
7053 (/= article (cdr gnus-article-current))
7054 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7055 ;; Selected subject is different from current article's.
7056 (gnus-summary-display-article article)
7057 (gnus-configure-windows 'article)
7058 (gnus-eval-in-buffer-window
7060 (setq endp (gnus-article-next-page lines)))
7063 (gnus-summary-beginning-of-article))
7065 (message "End of message"))
7067 (gnus-summary-next-unread-article))))
7068 (and gnus-summary-buffer
7069 (buffer-name gnus-summary-buffer)
7071 (pop-to-buffer gnus-summary-buffer)
7072 (gnus-summary-position-cursor))))))
7074 (defun gnus-summary-prev-page (lines)
7075 "Show previous page of selected article.
7076 Argument LINES specifies lines to be scrolled down."
7078 (let ((article (gnus-summary-article-number)))
7079 (if (or (null gnus-current-article)
7080 (null gnus-article-current)
7081 (/= article (cdr gnus-article-current))
7082 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7083 ;; Selected subject is different from current article's.
7084 (gnus-summary-display-article article)
7085 (gnus-configure-windows 'article)
7086 (pop-to-buffer gnus-summary-buffer)
7087 (gnus-eval-in-buffer-window gnus-article-buffer
7088 (gnus-article-prev-page lines))))
7089 (gnus-summary-position-cursor))
7091 (defun gnus-summary-scroll-up (lines)
7092 "Scroll up (or down) one line current article.
7093 Argument LINES specifies lines to be scrolled up (or down if negative)."
7095 (or (gnus-summary-select-article nil nil 'pseudo)
7096 (gnus-eval-in-buffer-window
7099 (if (gnus-article-next-page lines)
7100 (message "End of message")))
7102 (gnus-article-prev-page (- lines))))))
7103 (gnus-summary-position-cursor))
7105 (defun gnus-summary-next-same-subject ()
7106 "Select next article which has the same subject as current one."
7108 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7110 (defun gnus-summary-prev-same-subject ()
7111 "Select previous article which has the same subject as current one."
7113 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7115 (defun gnus-summary-next-unread-same-subject ()
7116 "Select next unread article which has the same subject as current one."
7118 (gnus-summary-next-article t (gnus-summary-subject-string)))
7120 (defun gnus-summary-prev-unread-same-subject ()
7121 "Select previous unread article which has the same subject as current one."
7123 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7125 (defun gnus-summary-first-unread-article ()
7126 "Select the first unread article.
7127 Return nil if there are no unread articles."
7130 (if (gnus-summary-first-subject t)
7131 (gnus-summary-display-article (gnus-summary-article-number)))
7132 (gnus-summary-position-cursor)))
7134 (defun gnus-summary-best-unread-article ()
7135 "Select the unread article with the highest score."
7137 (gnus-set-global-variables)
7138 (let ((scored gnus-newsgroup-scored)
7142 (or (> best (cdr (car scored)))
7143 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7144 (not (memq art gnus-newsgroup-marked))
7145 (not (memq art gnus-newsgroup-dormant))
7146 (if (= best (cdr (car scored)))
7147 (setq article (min art article))
7149 (setq best (cdr (car scored))))))
7150 (setq scored (cdr scored)))
7152 (gnus-summary-goto-article article)
7153 (gnus-summary-first-unread-article))
7154 (gnus-summary-position-cursor)))
7156 (defun gnus-summary-goto-article (article &optional all-headers)
7157 "Fetch ARTICLE and display it if it exists.
7158 If ALL-HEADERS is non-nil, no header lines are hidden."
7164 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7165 gnus-newsgroup-headers)
7166 nil 'require-match))))
7167 (if (gnus-summary-goto-subject article)
7168 (gnus-summary-display-article article all-headers))
7169 (gnus-summary-position-cursor))
7171 (defun gnus-summary-goto-last-article ()
7172 "Go to the last article."
7174 (if gnus-last-article
7175 (gnus-summary-goto-article gnus-last-article))
7176 (gnus-summary-position-cursor))
7178 (defun gnus-summary-pop-article (number)
7179 "Pop one article off the history and go to the previous.
7180 NUMBER articles will be popped off."
7183 (setq gnus-newsgroup-history
7184 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7186 (gnus-summary-goto-article (car to))
7187 (error "Article history empty")))
7188 (gnus-summary-position-cursor))
7190 ;; Summary article oriented commands
7192 (defun gnus-summary-refer-parent-article (n)
7193 "Refer parent article N times.
7194 The difference between N and the number of articles fetched is returned."
7196 (gnus-set-global-variables)
7200 (let ((ref (header-references (gnus-get-header-by-number
7201 (gnus-summary-article-number)))))
7202 (if (and ref (not (equal ref ""))
7203 (string-match "<[^<>]*>[ \t]*$" ref))
7204 (gnus-summary-refer-article
7205 (substring ref (match-beginning 0) (match-end 0))))))
7207 (or (zerop n) (message "No references in article or expired article."))
7208 (gnus-summary-position-cursor)
7211 (defun gnus-summary-refer-article (message-id)
7212 "Refer article specified by MESSAGE-ID.
7213 NOTE: This command only works with newsgroup that use NNTP."
7214 (interactive "sMessage-ID: ")
7215 (if (or (not (stringp message-id))
7216 (zerop (length message-id)))
7218 ;; Construct the correct Message-ID if necessary.
7219 ;; Suggested by tale@pawl.rpi.edu.
7220 (or (string-match "^<" message-id)
7221 (setq message-id (concat "<" message-id)))
7222 (or (string-match ">$" message-id)
7223 (setq message-id (concat message-id ">")))
7224 (let ((header (car (gnus-gethash (downcase message-id)
7225 gnus-newsgroup-dependencies))))
7227 (gnus-summary-goto-article (header-number header))
7228 (let ((gnus-override-method gnus-refer-article-method))
7229 (and gnus-refer-article-method
7230 (or (gnus-server-opened gnus-refer-article-method)
7231 (gnus-open-server gnus-refer-article-method)))
7232 (if (gnus-article-prepare
7233 message-id nil (gnus-read-header message-id))
7235 (gnus-summary-insert-line
7236 nil gnus-current-headers 0 nil gnus-read-mark nil nil
7237 (header-subject gnus-current-headers))
7239 (gnus-summary-position-cursor)
7240 (gnus-summary-update-line)
7242 (message "No such references")
7245 (defun gnus-summary-enter-digest-group ()
7246 "Enter a digest group based on the current article."
7248 (gnus-summary-select-article)
7249 (let ((name (format "%s/%d"
7250 (gnus-group-prefixed-name
7251 gnus-newsgroup-name (list 'nndigest ""))
7252 gnus-current-article))
7253 (buf (current-buffer)))
7254 (set-buffer gnus-group-buffer)
7257 (list t nil (list name gnus-level-default-subscribed nil nil
7258 (list 'nndigest gnus-article-buffer
7259 (cons 'quit-buffer buf))))
7261 (gnus-group-read-group t nil name)))
7263 (defun gnus-summary-isearch-article ()
7264 "Do incremental search forward on current article."
7266 (gnus-summary-select-article)
7267 (gnus-eval-in-buffer-window gnus-article-buffer
7270 (defun gnus-summary-search-article-forward (regexp)
7271 "Search for an article containing REGEXP forward.
7272 gnus-select-article-hook is not called during the search."
7275 (concat "Search forward (regexp): "
7276 (if gnus-last-search-regexp
7277 (concat "(default " gnus-last-search-regexp ") "))))))
7278 (if (string-equal regexp "")
7279 (setq regexp (or gnus-last-search-regexp ""))
7280 (setq gnus-last-search-regexp regexp))
7281 (if (gnus-summary-search-article regexp nil)
7282 (gnus-eval-in-buffer-window
7285 (error "Search failed: \"%s\"" regexp)))
7287 (defun gnus-summary-search-article-backward (regexp)
7288 "Search for an article containing REGEXP backward.
7289 gnus-select-article-hook is not called during the search."
7292 (concat "Search backward (regexp): "
7293 (if gnus-last-search-regexp
7294 (concat "(default " gnus-last-search-regexp ") "))))))
7295 (if (string-equal regexp "")
7296 (setq regexp (or gnus-last-search-regexp ""))
7297 (setq gnus-last-search-regexp regexp))
7298 (if (gnus-summary-search-article regexp t)
7299 (gnus-eval-in-buffer-window
7302 (error "Search failed: \"%s\"" regexp)))
7304 (defun gnus-summary-search-article (regexp &optional backward)
7305 "Search for an article containing REGEXP.
7306 Optional argument BACKWARD means do search for backward.
7307 gnus-select-article-hook is not called during the search."
7308 (let ((gnus-select-article-hook nil) ;Disable hook.
7309 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7312 (function re-search-backward) (function re-search-forward)))
7315 ;; Hidden thread subtrees must be searched for ,too.
7316 (gnus-summary-show-all-threads)
7317 (if (eobp) (forward-line -1))
7318 ;; First of all, search current article.
7319 ;; We don't want to read article again from NNTP server nor reset
7321 (gnus-summary-select-article)
7322 (message "Searching article: %d..." gnus-current-article)
7323 (setq last gnus-current-article)
7324 (gnus-eval-in-buffer-window gnus-article-buffer
7327 ;; Begin search from current point.
7328 (setq found (funcall re-search regexp nil t))))
7329 ;; Then search next articles.
7330 (while (and (not found)
7331 (gnus-summary-display-article
7332 (gnus-summary-search-subject backward nil nil)))
7333 (message "Searching article: %d..." gnus-current-article)
7334 (gnus-eval-in-buffer-window gnus-article-buffer
7337 (goto-char (if backward (point-max) (point-min)))
7338 (setq found (funcall re-search regexp nil t)))))
7340 ;; Adjust article pointer.
7341 (or (eq last gnus-current-article)
7342 (setq gnus-last-article last))
7343 ;; Return T if found such article.
7346 (defun gnus-summary-execute-command (header regexp command &optional backward)
7347 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7348 If HEADER is an empty string (or nil), the match is done on the entire
7349 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7351 (list (let ((completion-ignore-case t))
7354 (mapcar (string) (list string)
7355 '("Number" "Subject" "From" "Lines" "Date"
7356 "Message-ID" "Xref" "References")
7357 nil 'require-match)))
7358 (read-string "Regexp: ")
7359 (read-key-sequence "Command: ")
7360 current-prefix-arg))
7361 ;; Hidden thread subtrees must be searched as well.
7362 (gnus-summary-show-all-threads)
7363 ;; We don't want to change current point nor window configuration.
7365 (save-window-excursion
7366 (message "Executing %s..." (key-description command))
7367 ;; We'd like to execute COMMAND interactively so as to give arguments.
7368 (gnus-execute header regexp
7370 (call-interactively '(, (key-binding command)))))
7372 (message "Executing %s... done" (key-description command)))))
7374 (defun gnus-summary-beginning-of-article ()
7375 "Scroll the article back to the beginning."
7377 (gnus-summary-select-article)
7378 (gnus-eval-in-buffer-window
7381 (goto-char (point-min))
7382 (and gnus-break-pages (gnus-narrow-to-page))))
7384 (defun gnus-summary-end-of-article ()
7385 "Scroll to the end of the article."
7387 (gnus-summary-select-article)
7388 (gnus-eval-in-buffer-window
7391 (goto-char (point-max))
7392 (and gnus-break-pages (gnus-narrow-to-page))))
7394 (defun gnus-summary-show-article ()
7395 "Force re-fetching of the current article."
7397 (gnus-summary-select-article gnus-have-all-headers t t))
7399 (defun gnus-summary-toggle-header (arg)
7400 "Show the headers if they are hidden, or hide them if they are shown.
7401 If ARG is a positive number, show the entire header.
7402 If ARG is a negative number, hide the unwanted header lines."
7404 (gnus-set-global-variables)
7406 (set-buffer gnus-article-buffer)
7407 (let ((buffer-read-only nil))
7409 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
7410 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7411 (if (text-property-any 1 (point-max) 'invisible t)
7412 (remove-text-properties 1 (point-max) '(invisible t))
7413 (let ((gnus-have-all-headers nil))
7414 (run-hooks 'gnus-article-display-hook))))
7415 (set-window-point (get-buffer-window (current-buffer)) 1))))
7417 (defun gnus-summary-show-all-headers ()
7418 "Make all header lines visible."
7420 (gnus-article-show-all-headers))
7422 (defun gnus-summary-toggle-mime (arg)
7423 "Toggle MIME processing.
7424 If ARG is a positive number, turn MIME processing on."
7426 (setq gnus-show-mime
7427 (if (null arg) (not gnus-show-mime)
7428 (> (prefix-numeric-value arg) 0)))
7429 (gnus-summary-select-article t 'force))
7431 (defun gnus-summary-caesar-message (rotnum)
7432 "Caesar rotates all letters of current message by 13/47 places.
7433 With prefix arg, specifies the number of places to rotate each letter forward.
7434 Caesar rotates Japanese letters by 47 places in any case."
7436 (gnus-summary-select-article)
7437 (let ((mail-header-separator "")) ; !!! Is this necessary?
7438 (gnus-overload-functions)
7439 (gnus-eval-in-buffer-window
7443 ;; We don't want to jump to the beginning of the message.
7444 ;; `save-excursion' does not do its job.
7445 (move-to-window-line 0)
7446 (let ((last (point)))
7447 (news-caesar-buffer-body rotnum)
7451 (defun gnus-summary-stop-page-breaking ()
7452 "Stop page breaking in the current article."
7454 (gnus-summary-select-article)
7455 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7457 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7459 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7460 "Move the current article to a different newsgroup.
7461 If N is a positive number, move the N next articles.
7462 If N is a negative number, move the N previous articles.
7463 If N is nil and any articles have been marked with the process mark,
7464 move those articles instead.
7465 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7466 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7467 re-spool using this method.
7468 For this function to work, both the current newsgroup and the
7469 newsgroup that you want to move to have to support the `request-move'
7470 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7472 (gnus-set-global-variables)
7473 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7474 (error "The current newsgroup does not support article moving"))
7475 (let ((articles (gnus-summary-work-articles n))
7476 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7478 (if (and (not to-newsgroup) (not select-method))
7481 (format "Where do you want to move %s? %s"
7482 (if (> (length articles) 1)
7483 (format "these %d articles" (length articles))
7485 (if gnus-current-move-group
7486 (format "(%s default) " gnus-current-move-group)
7488 gnus-active-hashtb nil nil prefix)))
7491 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7492 (setq to-newsgroup (or gnus-current-move-group "")))
7493 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7494 (gnus-activate-newsgroup to-newsgroup)
7495 (error "No such group: %s" to-newsgroup))
7496 (setq gnus-current-move-group to-newsgroup)))
7497 (or (gnus-check-backend-function 'request-accept-article
7498 (or select-method to-newsgroup))
7499 (error "%s does not support article moving" to-newsgroup))
7500 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7503 (gnus-request-move-article
7504 (car articles) ; Article to move
7505 gnus-newsgroup-name ; From newsgrouo
7506 (nth 1 (gnus-find-method-for-group
7507 gnus-newsgroup-name)) ; Server
7508 (list 'gnus-request-accept-article
7510 (quote select-method)
7512 (not (cdr articles))) ; Accept form
7513 (not (cdr articles)))) ; Only save nov last time
7514 (let* ((buffer-read-only nil)
7517 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7519 (gnus-group-prefixed-name
7521 (if select-method (list select-method "")
7522 (gnus-find-method-for-group to-newsgroup)))
7523 gnus-newsrc-hashtb)))
7524 (info (nth 2 entry))
7525 (article (car articles))
7526 (marked (nth 3 info)))
7527 (gnus-summary-goto-subject article)
7529 (delete-region (point)
7530 (progn (forward-line 1) (point)))
7531 (if (not (memq article gnus-newsgroup-unreads))
7532 (setcar (cdr (cdr info))
7533 (gnus-add-to-range (nth 2 info)
7534 (list (cdr art-group)))))
7535 ;; Copy any marks over to the new group.
7536 (let ((marks '((tick . gnus-newsgroup-marked)
7537 (dormant . gnus-newsgroup-dormant)
7538 (expire . gnus-newsgroup-expirable)
7539 (bookmark . gnus-newsgroup-bookmarks)
7540 ; (score . gnus-newsgroup-scored)
7541 (reply . gnus-newsgroup-replied)))
7542 (to-article (cdr art-group)))
7544 (if (memq article (symbol-value (cdr (car marks))))
7545 (gnus-add-marked-articles
7546 (car info) (car (car marks)) (list to-article) info))
7547 (setq marks (cdr marks))))
7548 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7549 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7550 (setq gnus-newsgroup-dormant
7551 (delq article gnus-newsgroup-dormant)))
7552 (message "Couldn't move article %s" (car articles)))
7553 (gnus-summary-remove-process-mark (car articles))
7554 (setq articles (cdr articles)))))
7556 (defun gnus-summary-respool-article (n &optional respool-method)
7557 "Respool the current article.
7558 The article will be squeezed through the mail spooling process again,
7559 which means that it will be put in some mail newsgroup or other
7560 depending on `nnmail-split-methods'.
7561 If N is a positive number, respool the N next articles.
7562 If N is a negative number, respool the N previous articles.
7563 If N is nil and any articles have been marked with the process mark,
7564 respool those articles instead.
7566 Respooling can be done both from mail groups and \"real\" newsgroups.
7567 In the former case, the articles in question will be moved from the
7568 current group into whatever groups they are destined to. In the
7569 latter case, they will be copied into the relevant groups."
7571 (gnus-set-global-variables)
7572 (let ((respool-methods (gnus-methods-using 'respool)))
7574 (setq respool-method
7576 "What method do you want to use when respooling? "
7577 respool-methods nil t)))
7578 (if (assoc (symbol-name
7579 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7581 (gnus-summary-move-article n nil (intern respool-method)))
7582 (gnus-summary-copy-article n nil (intern respool-method))))
7584 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7585 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7586 "Move the current article to a different newsgroup.
7587 If N is a positive number, move the N next articles.
7588 If N is a negative number, move the N previous articles.
7589 If N is nil and any articles have been marked with the process mark,
7590 move those articles instead.
7591 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7592 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7593 re-spool using this method.
7594 For this function to work, the newsgroup that you want to move to have
7595 to support the `request-move' and `request-accept'
7596 functions. (Ie. mail newsgroups at present.)"
7598 (gnus-set-global-variables)
7599 (let ((articles (gnus-summary-work-articles n))
7600 (copy-buf (get-buffer-create "*copy work*"))
7601 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7603 (buffer-disable-undo copy-buf)
7604 (if (and (not to-newsgroup) (not select-method))
7607 (format "Where do you want to copy %s? %s"
7608 (if (> (length articles) 1)
7609 (format "these %d articles" (length articles))
7611 (if gnus-current-move-group
7612 (format "(%s default) " gnus-current-move-group)
7614 gnus-active-hashtb nil nil prefix)))
7617 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7618 (setq to-newsgroup (or gnus-current-move-group "")))
7619 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7620 (gnus-activate-newsgroup to-newsgroup)
7621 (error "No such group: %s" to-newsgroup))
7622 (setq gnus-current-move-group to-newsgroup)))
7623 (or (gnus-check-backend-function 'request-accept-article
7624 (or select-method to-newsgroup))
7625 (error "%s does not support article copying" to-newsgroup))
7626 (message "Copying to %s: %s..." (or select-method to-newsgroup) articles)
7630 (set-buffer copy-buf)
7631 (gnus-request-article-this-buffer
7632 (car articles) gnus-newsgroup-name)
7633 (gnus-request-accept-article
7634 (if select-method (quote select-method) to-newsgroup)
7635 (not (cdr articles)))))
7638 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7640 (gnus-group-prefixed-name
7642 (if select-method (list select-method "")
7643 (gnus-find-method-for-group to-newsgroup)))
7644 gnus-newsrc-hashtb)))
7645 (info (nth 2 entry))
7646 (article (car articles))
7647 (marked (nth 3 info)))
7648 (if (not (memq article gnus-newsgroup-unreads))
7649 (setcar (cdr (cdr info))
7650 (gnus-add-to-range (nth 2 info)
7651 (list (cdr art-group)))))
7652 ;; Copy any marks over to the new group.
7653 (let ((marks '((tick . gnus-newsgroup-marked)
7654 (dormant . gnus-newsgroup-dormant)
7655 (expire . gnus-newsgroup-expirable)
7656 (bookmark . gnus-newsgroup-bookmarks)
7657 ; (score . gnus-newsgroup-scored)
7658 (reply . gnus-newsgroup-replied)))
7659 (to-article (cdr art-group)))
7661 (if (memq article (symbol-value (cdr (car marks))))
7662 (gnus-add-marked-articles
7663 (car info) (car (car marks)) (list to-article) info))
7664 (setq marks (cdr marks)))))
7665 (message "Couldn't copy article %s" (car articles)))
7666 (gnus-summary-remove-process-mark (car articles))
7667 (setq articles (cdr articles)))
7668 (kill-buffer copy-buf)))
7670 (defun gnus-summary-expire-articles ()
7671 "Expire all articles that are marked as expirable in the current group."
7673 (if (and gnus-newsgroup-expirable
7674 (gnus-check-backend-function
7675 'request-expire-articles gnus-newsgroup-name))
7676 (let ((expirable gnus-newsgroup-expirable))
7677 ;; The list of articles that weren't expired is returned.
7678 (setq gnus-newsgroup-expirable
7679 (gnus-request-expire-articles gnus-newsgroup-expirable
7680 gnus-newsgroup-name))
7681 ;; We go through the old list of expirable, and mark all
7682 ;; really expired articles as non-existant.
7684 (or (memq (car expirable) gnus-newsgroup-expirable)
7685 (gnus-summary-mark-as-read (car expirable) "%"))
7686 (setq expirable (cdr expirable))))))
7688 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7689 (defun gnus-summary-delete-article (n)
7690 "Delete the N next (mail) articles.
7691 This command actually deletes articles. This is not a marking
7692 command. The article will disappear forever from you life, never to
7694 If N is negative, delete backwards.
7695 If N is nil and articles have been marked with the process mark,
7696 delete these instead."
7698 (or (gnus-check-backend-function 'request-expire-articles
7699 gnus-newsgroup-name)
7700 (error "The current newsgroup does not support article deletion."))
7701 ;; Compute the list of articles to delete.
7702 (let ((articles (gnus-summary-work-articles n)))
7703 (if (and gnus-novice-user
7705 (format "Do you really want to delete %s forever? "
7706 (if (> (length articles) 1) "these articles"
7709 ;; Delete the articles.
7710 (setq gnus-newsgroup-expirable
7711 (gnus-request-expire-articles
7712 articles gnus-newsgroup-name 'force))
7714 (gnus-summary-remove-process-mark (car articles))
7715 ;; The backend might not have been able to delete the article
7717 (or (memq (car articles) gnus-newsgroup-expirable)
7718 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7719 (setq articles (cdr articles)))))
7720 (gnus-summary-position-cursor))
7722 (defun gnus-summary-edit-article ()
7723 "Enter into a buffer and edit the current article.
7724 This will have permanent effect only in mail groups."
7726 (or (gnus-check-backend-function
7727 'request-replace-article gnus-newsgroup-name)
7728 (error "The current newsgroup does not support article editing."))
7729 (gnus-summary-select-article t)
7731 (message "C-c C-c to end edits")
7732 (setq buffer-read-only nil)
7734 (use-local-map (copy-keymap (current-local-map)))
7735 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7737 (search-forward "\n\n" nil t))
7739 (defun gnus-summary-edit-article-done ()
7740 "Make edits to the current article permanent."
7742 (if (not (gnus-request-replace-article
7743 (cdr gnus-article-current) (car gnus-article-current)
7745 (error "Couldn't replace article.")
7747 (use-local-map gnus-article-mode-map)
7748 (setq buffer-read-only t)
7749 (pop-to-buffer gnus-summary-buffer)))
7751 ;; Summary score commands.
7753 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
7755 (defun gnus-summary-raise-score (n)
7756 "Raise the score of the current article by N."
7758 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
7760 (defun gnus-summary-lower-score (n)
7761 "Lower the score of the current article by N."
7763 (gnus-summary-raise-score (- n)))
7765 (defun gnus-summary-set-score (n)
7766 "Set the score of the current article to N."
7768 ;; Skip dummy header line.
7770 (if (eq (gnus-summary-article-mark) ?Z)
7772 (let ((buffer-read-only nil))
7774 (gnus-summary-update-mark
7775 (if (= n (or gnus-summary-default-score 0)) ?
7776 (if (< n (or gnus-summary-default-score 0))
7777 gnus-score-below-mark gnus-score-over-mark)) 'score))
7778 (let* ((article (gnus-summary-article-number))
7779 (score (assq article gnus-newsgroup-scored)))
7780 (if score (setcdr score n)
7781 (setq gnus-newsgroup-scored
7782 (cons (cons article n) gnus-newsgroup-scored))))
7783 (gnus-summary-update-line)))
7785 ;; Summary marking commands.
7787 (defun gnus-summary-raise-same-subject-and-select (score)
7788 "Raise articles which has the same subject with SCORE and select the next."
7790 (let ((subject (gnus-summary-subject-string)))
7791 (gnus-summary-raise-score score)
7792 (while (gnus-summary-search-subject nil nil subject)
7793 (gnus-summary-raise-score score))
7794 (gnus-summary-next-article t)))
7796 (defun gnus-summary-raise-same-subject (score)
7797 "Raise articles which has the same subject with SCORE."
7799 (let ((subject (gnus-summary-subject-string)))
7800 (gnus-summary-raise-score score)
7801 (while (gnus-summary-search-subject nil nil subject)
7802 (gnus-summary-raise-score score))
7803 (gnus-summary-next-subject 1 t)))
7805 (defun gnus-summary-raise-thread (score)
7806 "Raise articles under current thread with SCORE."
7808 (setq score (1- (gnus-score-default score)))
7811 (let ((level (gnus-summary-thread-level)))
7812 (gnus-summary-raise-score score)
7813 (while (and (zerop (gnus-summary-next-subject 1 nil t))
7814 (> (gnus-summary-thread-level) level))
7815 (gnus-summary-raise-score score))
7817 (or (zerop (gnus-summary-next-subject 1 t))
7819 (gnus-summary-recenter)
7820 (gnus-summary-position-cursor)
7821 (gnus-set-mode-line 'summary))
7823 (defun gnus-summary-lower-same-subject-and-select (score)
7824 "Raise articles which has the same subject with SCORE and select the next."
7826 (gnus-summary-raise-same-subject-and-select (- score)))
7828 (defun gnus-summary-lower-same-subject (score)
7829 "Raise articles which has the same subject with SCORE."
7831 (gnus-summary-raise-same-subject (- score)))
7833 (defun gnus-summary-lower-thread (score)
7834 "Raise articles under current thread with SCORE."
7836 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
7838 (defun gnus-summary-kill-same-subject-and-select (unmark)
7839 "Mark articles which has the same subject as read, and then select the next.
7840 If UNMARK is positive, remove any kind of mark.
7841 If UNMARK is negative, tick articles."
7844 (setq unmark (prefix-numeric-value unmark)))
7846 (gnus-summary-mark-same-subject
7847 (gnus-summary-subject-string) unmark)))
7848 ;; Select next unread article. If auto-select-same mode, should
7849 ;; select the first unread article.
7850 (gnus-summary-next-article t (and gnus-auto-select-same
7851 (gnus-summary-subject-string)))
7852 (message "%d articles are marked as %s"
7853 count (if unmark "unread" "read"))))
7855 (defun gnus-summary-kill-same-subject (unmark)
7856 "Mark articles which has the same subject as read.
7857 If UNMARK is positive, remove any kind of mark.
7858 If UNMARK is negative, tick articles."
7861 (setq unmark (prefix-numeric-value unmark)))
7863 (gnus-summary-mark-same-subject
7864 (gnus-summary-subject-string) unmark)))
7865 ;; If marked as read, go to next unread subject.
7867 ;; Go to next unread subject.
7868 (gnus-summary-next-subject 1 t))
7869 (message "%d articles are marked as %s"
7870 count (if unmark "unread" "read"))))
7872 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7873 "Mark articles with same SUBJECT as read, and return marked number.
7874 If optional argument UNMARK is positive, remove any kinds of marks.
7875 If optional argument UNMARK is negative, mark articles as unread instead."
7878 (cond ((null unmark)
7879 (gnus-summary-mark-as-read nil gnus-killed-mark))
7881 (gnus-summary-tick-article nil t))
7883 (gnus-summary-tick-article)))
7885 (gnus-summary-search-forward nil subject))
7886 (cond ((null unmark)
7887 (gnus-summary-mark-as-read nil gnus-killed-mark))
7889 (gnus-summary-tick-article nil t))
7891 (gnus-summary-tick-article)))
7892 (setq count (1+ count))))
7893 ;; Hide killed thread subtrees. Does not work properly always.
7894 ;;(and (null unmark)
7895 ;; gnus-thread-hide-killed
7896 ;; (gnus-summary-hide-thread))
7897 ;; Return number of articles marked as read.
7900 (defun gnus-summary-mark-as-processable (n &optional unmark)
7901 "Set the process mark on the next N articles.
7902 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7903 the process mark instead. The difference between N and the actual
7904 number of articles marked is returned."
7906 (let ((backward (< n 0))
7911 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7912 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7913 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7915 (if (/= 0 n) (message "No more articles"))
7916 (gnus-summary-recenter)
7917 (gnus-summary-position-cursor)
7920 (defun gnus-summary-unmark-as-processable (n)
7921 "Remove the process mark from the next N articles.
7922 If N is negative, mark backward instead. The difference between N and
7923 the actual number of articles marked is returned."
7925 (gnus-summary-mark-as-processable n t))
7927 (defun gnus-summary-unmark-all-processable ()
7928 "Remove the process mark from all articles."
7931 (while gnus-newsgroup-processable
7932 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7933 (gnus-summary-position-cursor))
7935 (defun gnus-summary-mark-as-expirable (n)
7936 "Mark N articles forward as expirable.
7937 If N is negative, mark backward instead. The difference between N and
7938 the actual number of articles marked is returned."
7940 (gnus-summary-mark-forward n gnus-expirable-mark))
7942 (defun gnus-summary-mark-article-as-replied (article)
7943 "Mark ARTICLE replied and update the summary line."
7944 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7945 (let ((buffer-read-only nil))
7946 (if (gnus-summary-goto-subject article)
7948 (gnus-summary-update-mark gnus-replied-mark 'replied)
7951 (defun gnus-summary-set-bookmark (article)
7952 "Set a bookmark in current article."
7953 (interactive (list (gnus-summary-article-number)))
7954 (if (or (not (get-buffer gnus-article-buffer))
7955 (not gnus-current-article)
7956 (not gnus-article-current)
7957 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7958 (error "No current article selected"))
7959 ;; Remove old bookmark, if one exists.
7960 (let ((old (assq article gnus-newsgroup-bookmarks)))
7961 (if old (setq gnus-newsgroup-bookmarks
7962 (delq old gnus-newsgroup-bookmarks))))
7963 ;; Set the new bookmark, which is on the form
7964 ;; (article-number . line-number-in-body).
7965 (setq gnus-newsgroup-bookmarks
7969 (set-buffer gnus-article-buffer)
7974 (search-forward "\n\n" nil t)
7977 gnus-newsgroup-bookmarks))
7978 (message "A bookmark has been added to the current article."))
7980 (defun gnus-summary-remove-bookmark (article)
7981 "Remove the bookmark from the current article."
7982 (interactive (list (gnus-summary-article-number)))
7983 ;; Remove old bookmark, if one exists.
7984 (let ((old (assq article gnus-newsgroup-bookmarks)))
7987 (setq gnus-newsgroup-bookmarks
7988 (delq old gnus-newsgroup-bookmarks))
7989 (message "Removed bookmark."))
7990 (message "No bookmark in current article."))))
7992 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7993 (defun gnus-summary-mark-as-dormant (n)
7994 "Mark N articles forward as dormant.
7995 If N is negative, mark backward instead. The difference between N and
7996 the actual number of articles marked is returned."
7998 (gnus-summary-mark-forward n gnus-dormant-mark))
8000 (defun gnus-summary-set-process-mark (article)
8001 "Set the process mark on ARTICLE and update the summary line."
8002 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8003 (let ((buffer-read-only nil))
8004 (if (gnus-summary-goto-subject article)
8006 (and (eq (gnus-summary-article-mark) ?Z)
8008 (gnus-summary-update-mark gnus-process-mark 'replied)
8011 (defun gnus-summary-remove-process-mark (article)
8012 "Remove the process mark from ARTICLE and update the summary line."
8013 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8014 (let ((buffer-read-only nil))
8015 (if (gnus-summary-goto-subject article)
8017 (and (eq (gnus-summary-article-mark) ?Z)
8019 (gnus-summary-update-mark ? 'replied)
8020 (if (memq article gnus-newsgroup-replied)
8021 (gnus-summary-update-mark gnus-replied-mark 'replied))
8024 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8025 "Mark N articles as read forwards.
8026 If N is negative, mark backwards instead.
8027 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8029 The difference between N and the actual number of articles marked is
8032 (gnus-set-global-variables)
8033 (let ((backward (< n 0))
8035 (mark (or mark gnus-del-mark)))
8037 (gnus-summary-mark-article nil mark no-expire)
8038 (zerop (gnus-summary-next-subject
8039 (if backward -1 1) gnus-summary-goto-unread t)))
8041 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
8042 (gnus-summary-recenter)
8043 (gnus-summary-position-cursor)
8044 (gnus-set-mode-line 'summary)
8047 (defun gnus-summary-mark-article (&optional article mark no-expire)
8048 "Mark ARTICLE with MARK.
8049 MARK can be any character.
8050 Five MARK strings are reserved: ? (unread),
8051 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8052 If MARK is nil, then the default character ?D is used.
8053 If ARTICLE is nil, then the article on the current line will be
8055 ;; If no mark is given, then we check auto-expiring.
8056 (and (not no-expire)
8057 gnus-newsgroup-auto-expire
8059 (and (numberp mark) (or (= mark gnus-killed-mark)
8060 (= mark gnus-del-mark)
8061 (= mark gnus-catchup-mark)
8062 (= mark gnus-low-score-mark)
8063 (= mark gnus-read-mark))))
8064 (setq mark gnus-expirable-mark))
8065 (let* ((buffer-read-only nil)
8066 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8067 (article (or article (gnus-summary-article-number))))
8068 (if (or (= mark gnus-unread-mark)
8069 (= mark gnus-ticked-mark)
8070 (= mark gnus-dormant-mark))
8071 (gnus-mark-article-as-unread article mark)
8072 (gnus-mark-article-as-read article mark))
8073 (if (gnus-summary-goto-subject article)
8075 (gnus-summary-show-thread)
8077 (and (eq (gnus-summary-article-mark) ?Z)
8080 (gnus-summary-update-mark mark 'unread)
8083 (defun gnus-summary-update-mark (mark type)
8085 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8089 (forward-char forward)
8090 (setq plist (text-properties-at (point)))
8092 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
8094 (and plist (add-text-properties (1- (point)) (point) plist))
8095 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8097 (defun gnus-mark-article-as-read (article &optional mark)
8098 "Enter ARTICLE in the pertinent lists and remove it from others."
8099 ;; Make the article expirable.
8100 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
8101 (if (= mark gnus-expirable-mark)
8102 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8103 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8104 ;; Remove from unread and marked lists.
8105 (setq gnus-newsgroup-unreads
8106 (delq article gnus-newsgroup-unreads))
8107 (setq gnus-newsgroup-marked
8108 (delq article gnus-newsgroup-marked))
8109 (setq gnus-newsgroup-dormant
8110 (delq article gnus-newsgroup-dormant))))
8112 (defun gnus-mark-article-as-unread (article &optional mark)
8113 "Enter ARTICLE in the pertinent lists and remove it from others."
8114 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8115 ;; Add to unread list.
8116 (or (memq article gnus-newsgroup-unreads)
8117 (setq gnus-newsgroup-unreads
8118 (cons article gnus-newsgroup-unreads)))
8119 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
8120 ;; list. Otherwise, it must be added to the list.
8121 (setq gnus-newsgroup-marked
8122 (delq article gnus-newsgroup-marked))
8123 (setq gnus-newsgroup-dormant
8124 (delq article gnus-newsgroup-dormant))
8125 (setq gnus-newsgroup-expirable
8126 (delq article gnus-newsgroup-expirable))
8127 (if (= mark gnus-ticked-mark)
8128 (setq gnus-newsgroup-marked
8129 (cons article gnus-newsgroup-marked)))
8130 (if (= mark gnus-dormant-mark)
8131 (setq gnus-newsgroup-dormant
8132 (cons article gnus-newsgroup-dormant)))))
8134 (defalias 'gnus-summary-mark-as-unread-forward
8135 'gnus-summary-tick-article-forward)
8136 (make-obsolete 'gnus-summary-mark-as-unread-forward
8137 'gnus-summary-tick-article-forward)
8138 (defun gnus-summary-tick-article-forward (n)
8139 "Tick N articles forwards.
8140 If N is negative, tick backwards instead.
8141 The difference between N and the number of articles ticked is returned."
8143 (gnus-summary-mark-forward n gnus-ticked-mark))
8145 (defalias 'gnus-summary-mark-as-unread-backward
8146 'gnus-summary-tick-article-backward)
8147 (make-obsolete 'gnus-summary-mark-as-unread-backward
8148 'gnus-summary-tick-article-backward)
8149 (defun gnus-summary-tick-article-backward (n)
8150 "Tick N articles backwards.
8151 The difference between N and the number of articles ticked is returned."
8153 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8155 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8156 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8157 (defun gnus-summary-tick-article (&optional article clear-mark)
8158 "Mark current article as unread.
8159 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8160 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8161 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8164 (defun gnus-summary-mark-as-read-forward (n)
8165 "Mark N articles as read forwards.
8166 If N is negative, mark backwards instead.
8167 The difference between N and the actual number of articles marked is
8170 (gnus-summary-mark-forward n gnus-del-mark t))
8172 (defun gnus-summary-mark-as-read-backward (n)
8173 "Mark the N articles as read backwards.
8174 The difference between N and the actual number of articles marked is
8177 (gnus-summary-mark-forward (- n) gnus-del-mark t))
8179 (defun gnus-summary-mark-as-read (&optional article mark)
8180 "Mark current article as read.
8181 ARTICLE specifies the article to be marked as read.
8182 MARK specifies a string to be inserted at the beginning of the line."
8183 (gnus-summary-mark-article article mark))
8185 (defun gnus-summary-clear-mark-forward (n)
8186 "Clear marks from N articles forward.
8187 If N is negative, clear backward instead.
8188 The difference between N and the number of marks cleared is returned."
8190 (gnus-summary-mark-forward n gnus-unread-mark))
8192 (defun gnus-summary-clear-mark-backward (n)
8193 "Clear marks from N articles backward.
8194 The difference between N and the number of marks cleared is returned."
8196 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8198 (defun gnus-summary-mark-unread-as-read ()
8199 "Intended to be used by `gnus-summary-mark-article-hook'."
8200 (or (memq gnus-current-article gnus-newsgroup-marked)
8201 (memq gnus-current-article gnus-newsgroup-dormant)
8202 (memq gnus-current-article gnus-newsgroup-expirable)
8203 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8205 (defun gnus-summary-mark-region-as-read (point mark all)
8206 "Mark all unread articles between point and mark as read.
8207 If given a prefix, mark all articles between point and mark as read,
8208 even ticked and dormant ones."
8209 (interactive "r\nP")
8219 (not (memq (gnus-summary-article-number)
8220 gnus-newsgroup-marked))
8221 (not (memq (gnus-summary-article-number)
8222 gnus-newsgroup-dormant))))
8223 (gnus-summary-mark-article
8224 (gnus-summary-article-number) gnus-del-mark))
8226 (zerop (forward-line 1))))))
8228 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8229 (defalias 'gnus-summary-delete-marked-as-read
8230 'gnus-summary-remove-lines-marked-as-read)
8231 (make-obsolete 'gnus-summary-delete-marked-as-read
8232 'gnus-summary-remove-lines-marked-as-read)
8233 (defun gnus-summary-remove-lines-marked-as-read ()
8234 "Remove lines that are marked as read."
8236 (gnus-summary-remove-lines-marked-with
8238 (lambda (char) (char-to-string (symbol-value char)))
8239 '(gnus-del-mark gnus-read-mark
8240 gnus-killed-mark gnus-kill-file-mark
8241 gnus-low-score-mark gnus-expirable-mark)
8244 (defalias 'gnus-summary-delete-marked-with
8245 'gnus-summary-remove-lines-marked-with)
8246 (make-obsolete 'gnus-summary-delete-marked-with
8247 'gnus-summary-remove-lines-marked-with)
8248 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8249 (defun gnus-summary-remove-lines-marked-with (marks)
8250 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8251 (interactive "sMarks: ")
8252 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8254 (set-buffer gnus-summary-buffer)
8255 (let ((buffer-read-only nil)
8256 (marks (concat "^[" marks "]")))
8257 (goto-char (point-min))
8258 (if gnus-use-adaptive-scoring
8259 (gnus-score-remove-lines-adaptive marks)
8260 (while (re-search-forward marks (point-max) t)
8262 (delete-region (point)
8263 (progn (forward-line 1) (point))))))
8264 (or (zerop (buffer-size))
8266 (gnus-summary-prev-subject 1)
8267 (gnus-summary-position-cursor)))))
8269 (defun gnus-summary-expunge-below (score)
8270 "Remove articles with score less than SCORE."
8272 (setq score (if score
8273 (prefix-numeric-value score)
8274 (or gnus-summary-default-score 0)))
8276 (set-buffer gnus-summary-buffer)
8277 (goto-char (point-min))
8278 (let ((buffer-read-only nil)
8281 (if (< (gnus-summary-article-score) score)
8285 (delete-region beg (point)))
8288 (or (zerop (buffer-size))
8290 (gnus-summary-prev-subject 1)
8291 (gnus-summary-position-cursor))))))
8293 (defun gnus-summary-mark-below (score mark)
8294 "Mark articles with score less than SCORE with MARK."
8295 (interactive "P\ncMark: ")
8296 (setq score (if score
8297 (prefix-numeric-value score)
8298 (or gnus-summary-default-score 0)))
8300 (set-buffer gnus-summary-buffer)
8301 (goto-char (point-min))
8303 (and (< (gnus-summary-article-score) score)
8304 (gnus-summary-mark-article nil mark))
8307 (defun gnus-summary-kill-below (score)
8308 "Mark articles with score below SCORE as read."
8310 (gnus-summary-mark-below score gnus-killed-mark))
8312 (defun gnus-summary-clear-above (score)
8313 "Clear all marks from articles with score above SCORE."
8315 (gnus-summary-mark-above score gnus-unread-mark))
8317 (defun gnus-summary-tick-above (score)
8318 "Tick all articles with score above SCORE."
8320 (gnus-summary-mark-above score gnus-ticked-mark))
8322 (defun gnus-summary-mark-above (score mark)
8323 "Mark articles with score over SCORE with MARK."
8324 (interactive "P\ncMark: ")
8325 (setq score (if score
8326 (prefix-numeric-value score)
8327 (or gnus-summary-default-score 0)))
8329 (set-buffer gnus-summary-buffer)
8330 (goto-char (point-min))
8332 (if (> (gnus-summary-article-score) score)
8334 (gnus-summary-mark-article nil mark)
8336 (forward-line 1)))))
8338 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8339 (defun gnus-summary-show-all-expunged ()
8340 "Display all the hidden articles that were expunged for low scores."
8342 (let ((buffer-read-only nil))
8343 (let ((scored gnus-newsgroup-scored)
8346 (or (gnus-summary-goto-subject (car (car scored)))
8347 (and (setq h (gnus-get-header-by-number (car (car scored))))
8348 (< (cdr (car scored)) gnus-summary-expunge-below)
8349 (setq headers (cons h headers))))
8350 (setq scored (cdr scored)))
8351 (or headers (error "No expunged articles hidden."))
8352 (goto-char (point-min))
8354 (gnus-summary-prepare-threads (nreverse headers) 0)))
8355 (goto-char (point-min))
8356 (gnus-summary-position-cursor)))
8358 (defun gnus-summary-show-all-dormant ()
8359 "Display all the hidden articles that are marked as dormant."
8361 (let ((buffer-read-only nil))
8362 (goto-char (point-min))
8363 (let ((dormant gnus-newsgroup-dormant)
8366 (or (gnus-summary-goto-subject (car dormant))
8367 (and (setq h (gnus-get-header-by-number (car dormant)))
8368 (setq headers (cons h headers))))
8369 (setq dormant (cdr dormant)))
8370 (or headers (error "No dormant articles hidden."))
8371 (save-excursion (gnus-summary-prepare-threads (nreverse headers) 0)))
8372 (goto-char (point-min))
8373 (gnus-summary-position-cursor)))
8375 (defun gnus-summary-hide-all-dormant ()
8376 "Hide all dormant articles."
8378 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8379 (gnus-summary-position-cursor))
8381 (defun gnus-summary-catchup (all &optional quietly to-here)
8382 "Mark all articles not marked as unread in this newsgroup as read.
8383 If prefix argument ALL is non-nil, all articles are marked as read.
8384 If QUIETLY is non-nil, no questions will be asked.
8385 If TO-HERE is non-nil, it should be a point in the buffer. All
8386 articles before this point will be marked as read.
8387 The number of articles marked as read is returned."
8391 (not gnus-interactive-catchup) ;Without confirmation?
8395 "Mark absolutely all articles as read? "
8396 "Mark all unread articles as read? ")))
8397 (let ((unreads (length gnus-newsgroup-unreads)))
8398 (if (gnus-summary-first-subject (not all))
8399 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8400 (if to-here (< (point) to-here) t)
8401 (gnus-summary-search-subject nil (not all)))))
8402 (- unreads (length gnus-newsgroup-unreads))
8404 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))))
8405 (gnus-summary-position-cursor)))
8407 (defun gnus-summary-catchup-to-here (&optional all)
8408 "Mark all unticked articles before the current one as read.
8409 If ALL is non-nil, also mark ticked and dormant articles as read."
8412 (gnus-summary-catchup all t (point))
8413 (gnus-summary-position-cursor))
8415 (defun gnus-summary-catchup-all (&optional quietly)
8416 "Mark all articles in this newsgroup as read."
8418 (gnus-summary-catchup t quietly))
8420 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8421 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8422 If prefix argument ALL is non-nil, all articles are marked as read."
8424 (gnus-summary-catchup all quietly)
8425 ;; Select next newsgroup or exit.
8426 (if (eq gnus-auto-select-next 'quietly)
8427 (gnus-summary-next-group nil)
8428 (gnus-summary-exit)))
8430 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8431 "Mark all articles in this newsgroup as read, and then exit."
8433 (gnus-summary-catchup-and-exit t quietly))
8435 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8436 (defun gnus-summary-catchup-and-goto-next-group (all)
8437 "Mark all articles in this group as read and select the next group.
8438 If given a prefix, mark all articles, unread as well as ticked, as
8441 (gnus-summary-catchup all)
8442 (gnus-summary-next-group))
8444 ;; Thread-based commands.
8446 (defun gnus-summary-toggle-threads (arg)
8447 "Toggle showing conversation threads.
8448 If ARG is positive number, turn showing conversation threads on."
8450 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8451 (setq gnus-show-threads
8452 (if (null arg) (not gnus-show-threads)
8453 (> (prefix-numeric-value arg) 0)))
8454 (gnus-summary-prepare)
8455 (gnus-summary-goto-subject current)
8456 (gnus-summary-position-cursor)))
8458 (defun gnus-summary-show-all-threads ()
8462 (let ((buffer-read-only nil))
8463 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8464 (gnus-summary-position-cursor))
8466 (defun gnus-summary-show-thread ()
8467 "Show thread subtrees.
8468 Returns nil if no thread was there to be shown."
8472 (let ((buffer-read-only nil)
8473 ;; first goto end then to beg, to have point at beg after let
8474 (end (progn (end-of-line) (point)))
8475 (beg (progn (beginning-of-line) (point))))
8477 ;; Any hidden lines here?
8478 (search-forward "\r" end t)
8479 (subst-char-in-region beg end ?\^M ?\n t))))
8480 (gnus-summary-position-cursor)))
8482 (defun gnus-summary-hide-all-threads ()
8483 "Hide all thread subtrees."
8486 (goto-char (point-min))
8487 (gnus-summary-hide-thread)
8488 (while (and (not (eobp)) (zerop (forward-line 1)))
8489 (gnus-summary-hide-thread)))
8490 (gnus-summary-position-cursor))
8492 (defun gnus-summary-hide-thread ()
8493 "Hide thread subtrees.
8494 Returns nil if no threads were there to be hidden."
8496 (let ((buffer-read-only nil)
8498 (level (gnus-summary-thread-level))
8500 ;; Go forward until either the buffer ends or the subthread
8504 (while (and (zerop (forward-line 1))
8505 (> (gnus-summary-thread-level) level))
8510 (search-backward "\n" start t))
8511 (subst-char-in-region start end ?\n ?\^M t)
8512 (forward-line -1)))))
8514 (defun gnus-summary-go-to-next-thread (&optional previous)
8515 "Go to the same level (or less) next thread.
8516 If PREVIOUS is non-nil, go to previous thread instead.
8517 Return the article number moved to, or nil if moving was impossible."
8518 (let ((level (gnus-summary-thread-level))
8519 (article (gnus-summary-article-number)))
8521 (while (and (zerop (gnus-summary-prev-subject 1))
8522 (> (gnus-summary-thread-level) level)))
8523 (while (and (zerop (gnus-summary-next-subject 1))
8524 (> (gnus-summary-thread-level) level))))
8525 (gnus-summary-recenter)
8526 (gnus-summary-position-cursor)
8527 (let ((oart (gnus-summary-article-number)))
8528 (and (/= oart article) oart))))
8530 (defun gnus-summary-next-thread (n)
8531 "Go to the same level next N'th thread.
8532 If N is negative, search backward instead.
8533 Returns the difference between N and the number of skips actually
8536 (let ((backward (< n 0))
8539 (gnus-summary-go-to-next-thread backward))
8541 (gnus-summary-position-cursor)
8542 (if (/= 0 n) (message "No more threads"))
8545 (defun gnus-summary-prev-thread (n)
8546 "Go to the same level previous N'th thread.
8547 Returns the difference between N and the number of skips actually
8550 (gnus-summary-next-thread (- n)))
8552 (defun gnus-summary-go-down-thread (&optional same)
8553 "Go down one level in the current thread.
8554 If SAME is non-nil, also move to articles of the same level."
8555 (let ((level (gnus-summary-thread-level))
8557 (if (and (zerop (forward-line 1))
8558 (> (gnus-summary-thread-level) level))
8563 (defun gnus-summary-go-up-thread ()
8564 "Go up one level in the current thread."
8565 (let ((level (gnus-summary-thread-level))
8567 (while (and (zerop (forward-line -1))
8568 (>= (gnus-summary-thread-level) level)))
8569 (if (>= (gnus-summary-thread-level) level)
8575 (defun gnus-summary-down-thread (n)
8576 "Go down thread N steps.
8577 If N is negative, go up instead.
8578 Returns the difference between N and how many steps down that were
8584 (if up (gnus-summary-go-up-thread)
8585 (gnus-summary-go-down-thread)))
8587 (gnus-summary-position-cursor)
8588 (if (/= 0 n) (message "Can't go further"))
8591 (defun gnus-summary-up-thread (n)
8592 "Go up thread N steps.
8593 If N is negative, go up instead.
8594 Returns the difference between N and how many steps down that were
8597 (gnus-summary-down-thread (- n)))
8599 (defun gnus-summary-kill-thread (unmark)
8600 "Mark articles under current thread as read.
8601 If the prefix argument is positive, remove any kinds of marks.
8602 If the prefix argument is negative, tick articles instead."
8605 (setq unmark (prefix-numeric-value unmark)))
8607 (level (gnus-summary-thread-level)))
8610 ;; Mark the article...
8611 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8612 ((> unmark 0) (gnus-summary-tick-article nil t))
8613 (t (gnus-summary-tick-article)))
8614 ;; ...and go forward until either the buffer ends or the subtree
8616 (if (not (and (zerop (forward-line 1))
8617 (> (gnus-summary-thread-level) level)))
8618 (setq killing nil))))
8619 ;; Hide killed subtrees.
8621 gnus-thread-hide-killed
8622 (gnus-summary-hide-thread))
8623 ;; If marked as read, go to next unread subject.
8625 ;; Go to next unread subject.
8626 (gnus-summary-next-subject 1 t)))
8627 (gnus-set-mode-line 'summary))
8629 ;; Summary sorting commands
8631 (defun gnus-summary-sort-by-number (reverse)
8632 "Sort summary buffer by article number.
8633 Argument REVERSE means reverse order."
8636 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8638 (defun gnus-summary-sort-by-author (reverse)
8639 "Sort summary buffer by author name alphabetically.
8640 If case-fold-search is non-nil, case of letters is ignored.
8641 Argument REVERSE means reverse order."
8646 (let ((extract (funcall
8647 gnus-extract-address-components
8648 (header-from (gnus-get-header-by-number
8649 (gnus-summary-article-number))))))
8650 (or (car extract) (cdr extract))))
8651 'gnus-thread-sort-by-author)
8654 (defun gnus-summary-sort-by-subject (reverse)
8655 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8656 If case-fold-search is non-nil, case of letters is ignored.
8657 Argument REVERSE means reverse order."
8662 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8663 'gnus-thread-sort-by-subject)
8666 (defun gnus-summary-sort-by-date (reverse)
8667 "Sort summary buffer by date.
8668 Argument REVERSE means reverse order."
8675 (gnus-get-header-by-number (gnus-summary-article-number)))))
8676 'gnus-thread-sort-by-date)
8679 (defun gnus-summary-sort-by-score (reverse)
8680 "Sort summary buffer by score.
8681 Argument REVERSE means reverse order."
8684 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
8687 (defvar gnus-summary-already-sorted nil)
8688 (defun gnus-summary-sort (predicate reverse)
8689 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
8690 (if gnus-summary-already-sorted
8692 (let (buffer-read-only)
8693 (if (not gnus-show-threads)
8695 (goto-char (point-min))
8696 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
8697 (let ((gnus-thread-sort-functions (list (cdr predicate)))
8698 (gnus-summary-already-sorted nil))
8699 (gnus-summary-prepare))))))
8701 (defun gnus-sortable-date (date)
8702 "Make sortable string by string-lessp from DATE.
8703 Timezone package is used."
8704 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
8705 (year (aref date 0))
8706 (month (aref date 1))
8707 (day (aref date 2)))
8708 (timezone-make-sortable-date
8710 (timezone-make-time-string
8711 (aref date 3) (aref date 4) (aref date 5)))))
8714 ;; Summary saving commands.
8716 (defun gnus-summary-save-article (n)
8717 "Save the current article using the default saver function.
8718 If N is a positive number, save the N next articles.
8719 If N is a negative number, save the N previous articles.
8720 If N is nil and any articles have been marked with the process mark,
8721 save those articles instead.
8722 The variable `gnus-default-article-saver' specifies the saver function."
8724 (let (articles process)
8725 (if (and n (numberp n))
8726 (let ((backward (< n 0))
8730 (setq articles (cons (gnus-summary-article-number)
8732 (gnus-summary-search-forward nil nil backward))
8734 (setq articles (sort articles (function <))))
8735 (if gnus-newsgroup-processable
8737 (setq articles (setq gnus-newsgroup-processable
8738 (nreverse gnus-newsgroup-processable)))
8740 (setq articles (list (gnus-summary-article-number)))))
8742 (let ((header (gnus-gethash (int-to-string (car articles))
8743 gnus-newsgroup-headers-hashtb-by-number)))
8744 (if (vectorp header)
8746 (gnus-summary-select-article t nil nil (car articles))
8747 (or gnus-save-all-headers
8748 (gnus-article-hide-headers t))
8749 ;; Remove any X-Gnus lines.
8752 (set-buffer gnus-article-buffer)
8753 (let ((buffer-read-only nil))
8754 (goto-char (point-min))
8755 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
8757 (while (re-search-forward "^X-Gnus" nil t)
8759 (delete-region (point)
8760 (progn (forward-line 1) (point))))
8762 (if gnus-default-article-saver
8763 (funcall gnus-default-article-saver)
8764 (error "No default saver is defined.")))
8765 (if (assq 'name header)
8766 (gnus-copy-file (cdr (assq 'name header)))
8767 (message "Article %d is unsaveable" (car articles)))))
8769 (gnus-summary-remove-process-mark (car articles)))
8770 (setq articles (cdr articles)))
8771 (if process (setq gnus-newsgroup-processable
8772 (nreverse gnus-newsgroup-processable)))
8773 (gnus-summary-position-cursor)
8776 (defun gnus-summary-pipe-output (arg)
8777 "Pipe the current article to a subprocess.
8778 If N is a positive number, pipe the N next articles.
8779 If N is a negative number, pipe the N previous articles.
8780 If N is nil and any articles have been marked with the process mark,
8781 pipe those articles instead."
8783 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8784 (gnus-summary-save-article arg)))
8786 (defun gnus-summary-save-article-mail (arg)
8787 "Append the current article to an mail file.
8788 If N is a positive number, save the N next articles.
8789 If N is a negative number, save the N previous articles.
8790 If N is nil and any articles have been marked with the process mark,
8791 save those articles instead."
8793 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8794 (gnus-summary-save-article arg)))
8796 (defun gnus-summary-save-article-rmail (arg)
8797 "Append the current article to an rmail file.
8798 If N is a positive number, save the N next articles.
8799 If N is a negative number, save the N previous articles.
8800 If N is nil and any articles have been marked with the process mark,
8801 save those articles instead."
8803 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8804 (gnus-summary-save-article arg)))
8806 (defun gnus-summary-save-article-file (arg)
8807 "Append the current article to a file.
8808 If N is a positive number, save the N next articles.
8809 If N is a negative number, save the N previous articles.
8810 If N is nil and any articles have been marked with the process mark,
8811 save those articles instead."
8813 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8814 (gnus-summary-save-article arg)))
8816 (defun gnus-summary-save-article-folder (arg)
8817 "Append the current article to an mh folder.
8818 If N is a positive number, save the N next articles.
8819 If N is a negative number, save the N previous articles.
8820 If N is nil and any articles have been marked with the process mark,
8821 save those articles instead."
8823 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
8824 (gnus-summary-save-article arg)))
8826 (defun gnus-read-save-file-name (prompt default-name)
8827 (let ((methods gnus-split-methods)
8829 (if (not gnus-split-methods)
8832 (set-buffer gnus-article-buffer)
8833 (gnus-narrow-to-headers)
8835 (goto-char (point-min))
8836 (and (condition-case ()
8837 (re-search-forward (car (car methods)) nil t)
8839 (setq split-name (cons (nth 1 (car methods)) split-name)))
8840 (setq methods (cdr methods)))
8842 (cond ((null split-name)
8844 (concat prompt " (default "
8845 (file-name-nondirectory default-name) ") ")
8846 (file-name-directory default-name)
8848 ((= 1 (length split-name))
8850 (concat prompt " (default " (car split-name) ") ")
8851 gnus-article-save-directory
8852 (concat gnus-article-save-directory (car split-name))))
8854 (setq split-name (mapcar (lambda (el) (list el))
8855 (nreverse split-name)))
8856 (let ((result (completing-read
8858 split-name nil nil)))
8859 (concat gnus-article-save-directory
8860 (if (string= result "")
8861 (car (car split-name))
8864 (defun gnus-summary-save-in-rmail (&optional filename)
8865 "Append this article to Rmail file.
8866 Optional argument FILENAME specifies file name.
8867 Directory to save to is default to `gnus-article-save-directory' which
8868 is initialized from the SAVEDIR environment variable."
8871 (funcall gnus-rmail-save-name gnus-newsgroup-name
8872 gnus-current-headers gnus-newsgroup-last-rmail)))
8874 (setq filename (gnus-read-save-file-name
8875 "Save in rmail file:" default-name)))
8876 (gnus-make-directory (file-name-directory filename))
8877 (gnus-eval-in-buffer-window
8882 (gnus-output-to-rmail filename))))
8883 ;; Remember the directory name to save articles.
8884 (setq gnus-newsgroup-last-rmail filename)))
8886 (defun gnus-summary-save-in-mail (&optional filename)
8887 "Append this article to Unix mail file.
8888 Optional argument FILENAME specifies file name.
8889 Directory to save to is default to `gnus-article-save-directory' which
8890 is initialized from the SAVEDIR environment variable."
8893 (funcall gnus-mail-save-name gnus-newsgroup-name
8894 gnus-current-headers gnus-newsgroup-last-mail)))
8896 (setq filename (gnus-read-save-file-name
8897 "Save in Unix mail file:" default-name)))
8899 (expand-file-name filename
8901 (file-name-directory default-name))))
8902 (gnus-make-directory (file-name-directory filename))
8903 (gnus-eval-in-buffer-window
8908 (if (and (file-readable-p filename) (rmail-file-p filename))
8909 (gnus-output-to-rmail filename)
8910 (rmail-output filename 1 t t)))))
8911 ;; Remember the directory name to save articles.
8912 (setq gnus-newsgroup-last-mail filename)))
8914 (defun gnus-summary-save-in-file (&optional filename)
8915 "Append this article to file.
8916 Optional argument FILENAME specifies file name.
8917 Directory to save to is default to `gnus-article-save-directory' which
8918 is initialized from the SAVEDIR environment variable."
8921 (funcall gnus-file-save-name gnus-newsgroup-name
8922 gnus-current-headers gnus-newsgroup-last-file)))
8924 (setq filename (gnus-read-save-file-name
8925 "Save in file:" default-name)))
8926 (gnus-make-directory (file-name-directory filename))
8927 (gnus-eval-in-buffer-window
8932 (gnus-output-to-file filename))))
8933 ;; Remember the directory name to save articles.
8934 (setq gnus-newsgroup-last-file filename)))
8936 (defun gnus-summary-save-in-pipe (&optional command)
8937 "Pipe this article to subprocess."
8939 (let ((command (read-string "Shell command on article: "
8940 gnus-last-shell-command)))
8941 (if (string-equal command "")
8942 (setq command gnus-last-shell-command))
8943 (gnus-eval-in-buffer-window
8947 (shell-command-on-region (point-min) (point-max) command nil)))
8948 (setq gnus-last-shell-command command)))
8950 ;; Summary extract commands
8952 (defun gnus-summary-insert-pseudos (pslist)
8953 (let ((buffer-read-only nil)
8954 (article (gnus-summary-article-number))
8956 (or (gnus-summary-goto-subject article)
8957 (error (format "No such article: %d" article)))
8958 (or gnus-newsgroup-headers-hashtb-by-number
8959 (gnus-make-headers-hashtable-by-number))
8960 (gnus-summary-position-cursor)
8961 ;; If all commands are to be bunched up on one line, we collect
8963 (if gnus-view-pseudos-separately
8965 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8968 (setq action (cdr (assq 'action (car ps))))
8969 (setq files (list (cdr (assq 'name (car ps)))))
8970 (while (and ps (cdr ps)
8971 (string= (or action "1")
8972 (or (cdr (assq 'action (car (cdr ps)))) "2")))
8973 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
8974 (setcdr ps (cdr (cdr ps))))
8977 (if (not (string-match "%s" action))
8978 (setq files (cons " " files)))
8979 (setq files (cons " " files))
8980 (and (assq 'execute (car ps))
8981 (setcdr (assq 'execute (car ps))
8982 (funcall (if (string-match "%s" action)
8985 (mapconcat (lambda (f) f) files " ")))))
8986 (setq ps (cdr ps)))))
8987 (if gnus-view-pseudos
8989 (and (assq 'execute (car pslist))
8990 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8991 (eq gnus-view-pseudos 'not-confirm)))
8992 (setq pslist (cdr pslist)))
8995 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
8996 (gnus-summary-article-number)))
8999 (insert " " (file-name-nondirectory
9000 (cdr (assq 'name (car pslist))))
9001 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9002 (add-text-properties
9003 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
9004 'gnus-number gnus-reffed-article-number
9005 'gnus-mark gnus-unread-mark
9006 'gnus-pseudo (car pslist)
9009 (gnus-sethash (int-to-string gnus-reffed-article-number)
9010 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9011 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9012 (setq pslist (cdr pslist)))))))
9014 (defun gnus-pseudos< (p1 p2)
9015 (let ((c1 (cdr (assq 'action p1)))
9016 (c2 (cdr (assq 'action p2))))
9017 (and c1 c2 (string< c1 c2))))
9019 (defun gnus-request-pseudo-article (props)
9020 (cond ((assq 'execute props)
9021 (gnus-execute-command (cdr (assq 'execute props)))))
9022 (let ((gnus-current-article (gnus-summary-article-number)))
9023 (run-hooks 'gnus-mark-article-hook)))
9025 (defun gnus-execute-command (command &optional automatic)
9027 (gnus-article-setup-buffer)
9028 (set-buffer gnus-article-buffer)
9029 (let ((command (if automatic command (read-string "Command: " command)))
9030 (buffer-read-only nil))
9032 (insert "$ " command "\n\n")
9033 (if gnus-view-pseudo-asynchronously
9034 (start-process "gnus-execute" nil "sh" "-c" command)
9035 (call-process "sh" nil t nil "-c" command)))))
9037 (defun gnus-copy-file (file &optional to)
9040 (list (read-file-name "Copy file: " default-directory)
9041 (read-file-name "Copy file to: " default-directory)))
9042 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9043 (and (file-directory-p to)
9044 (setq to (concat (file-name-as-directory to)
9045 (file-name-nondirectory file))))
9046 (copy-file file to))
9048 ;; Summary kill commands.
9050 (defun gnus-summary-edit-global-kill (article)
9051 "Edit the \"global\" kill file."
9052 (interactive (list (gnus-summary-article-number)))
9053 (gnus-group-edit-global-kill article))
9055 (defun gnus-summary-edit-local-kill ()
9056 "Edit a local kill file applied to the current newsgroup."
9058 (setq gnus-current-headers
9060 (int-to-string (gnus-summary-article-number))
9061 gnus-newsgroup-headers-hashtb-by-number))
9062 (gnus-set-global-variables)
9063 (gnus-group-edit-local-kill
9064 (gnus-summary-article-number) gnus-newsgroup-name))
9068 ;;; Gnus article mode
9071 (put 'gnus-article-mode 'mode-class 'special)
9073 (if gnus-article-mode-map
9075 (setq gnus-article-mode-map (make-keymap))
9076 (suppress-keymap gnus-article-mode-map)
9077 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9078 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9079 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9080 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9081 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9082 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9083 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9084 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9086 ;; Duplicate almost all summary keystrokes in the article mode map.
9088 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
9089 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9090 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9091 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
9092 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9094 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "M"
9097 (define-key gnus-article-mode-map (car commands)
9098 'gnus-article-summary-command)
9099 (setq commands (cdr commands))))
9101 (let ((commands (list "q" "Q" "r" "R" "\C-c\C-f" "m" "a" "f" "F")))
9103 (define-key gnus-article-mode-map (car commands)
9104 'gnus-article-summary-command-nosave)
9105 (setq commands (cdr commands)))))
9108 (defun gnus-article-mode ()
9109 "Major mode for displaying an article.
9111 All normal editing commands are switched off.
9113 The following commands are available:
9115 \\<gnus-article-mode-map>
9116 \\[gnus-article-next-page]\t Scroll the article one page forwards
9117 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9118 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9119 \\[gnus-article-show-summary]\t Display the summary buffer
9120 \\[gnus-article-mail]\t Send a reply to the address near point
9121 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9122 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9123 \\[gnus-info-find-node]\t Go to the Gnus info node"
9125 (if gnus-visual (gnus-article-make-menu-bar))
9126 (kill-all-local-variables)
9127 (setq mode-line-modified "-- ")
9128 (make-local-variable 'mode-line-format)
9129 (setq mode-line-format (copy-sequence mode-line-format))
9130 (and (equal (nth 3 mode-line-format) " ")
9131 (setcar (nthcdr 3 mode-line-format) ""))
9132 (setq mode-name "Article")
9133 (setq major-mode 'gnus-article-mode)
9134 (make-local-variable 'minor-mode-alist)
9135 (or (assq 'gnus-show-mime minor-mode-alist)
9136 (setq minor-mode-alist
9137 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9138 (use-local-map gnus-article-mode-map)
9139 (make-local-variable 'page-delimiter)
9140 (setq page-delimiter gnus-page-delimiter)
9141 (buffer-disable-undo (current-buffer))
9142 (setq buffer-read-only t) ;Disable modification
9143 (run-hooks 'gnus-article-mode-hook))
9145 (defun gnus-article-setup-buffer ()
9146 "Initialize article mode buffer."
9147 (or (get-buffer gnus-article-buffer)
9149 (set-buffer (get-buffer-create gnus-article-buffer))
9150 (gnus-add-current-to-buffer-list)
9151 (gnus-article-mode))))
9153 (defun gnus-request-article-this-buffer (article &optional group)
9154 "Get an article and insert it into this buffer."
9155 (setq group (or group gnus-newsgroup-name))
9156 ;; Using `gnus-request-article' directly will insert the article into
9157 ;; `nntp-server-buffer' - so we'll save some time by not having to
9158 ;; copy it from the server buffer into the article buffer.
9160 ;; We only request an article by message-id when we do not have the
9161 ;; headers for it, so we'll have to get those.
9162 (and (stringp article)
9163 (let ((gnus-override-method gnus-refer-article-method))
9164 (gnus-read-header article)))
9166 ;; If the article number is negative, that means that this article
9167 ;; doesn't belong in this newsgroup (possibly), so we find its
9168 ;; message-id and request it by id instead of number.
9169 (if (and (numberp article) (< article 0))
9171 (set-buffer gnus-summary-buffer)
9172 (let ((header (gnus-gethash (int-to-string article)
9173 gnus-newsgroup-headers-hashtb-by-number)))
9174 (if (vectorp header)
9175 ;; It's a real article.
9176 (setq article (header-id header))
9177 ;; It is an extracted pseudo-article.
9179 (gnus-request-pseudo-article header)))))
9180 ;; Get the article and into the article buffer.
9184 (let ((gnus-override-method
9185 (and (stringp article) gnus-refer-article-method)))
9186 (and (gnus-request-article article group (current-buffer))
9190 (defun gnus-read-header (id)
9191 "Read the headers of article ID and enter them into the Gnus system."
9192 (or gnus-newsgroup-headers-hashtb-by-number
9193 (gnus-make-headers-hashtable-by-number))
9195 (if (not (setq header
9196 (car (if (let ((gnus-nov-is-evil t))
9197 (gnus-retrieve-headers
9198 (list id) gnus-newsgroup-name))
9199 (gnus-get-newsgroup-headers)))))
9202 (header-set-number header gnus-reffed-article-number))
9203 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9204 (gnus-sethash (int-to-string (header-number header)) header
9205 gnus-newsgroup-headers-hashtb-by-number)
9207 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9208 (setq gnus-current-headers header)
9211 (defun gnus-article-prepare (article &optional all-headers header)
9212 "Prepare ARTICLE in article mode buffer.
9213 ARTICLE should either be an article number or a Message-ID.
9214 If ARTICLE is an id, HEADER should be the article headers.
9215 If ALL-HEADERS is non-nil, no headers are hidden."
9217 ;; Make sure we start in a summary buffer.
9218 (or (eq major-mode 'gnus-summary-mode)
9219 (set-buffer gnus-summary-buffer))
9220 (setq gnus-summary-buffer (current-buffer))
9221 ;; Make sure the connection to the server is alive.
9222 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9224 (gnus-check-news-server
9225 (gnus-find-method-for-group gnus-newsgroup-name))
9226 (gnus-request-group gnus-newsgroup-name t)))
9227 (or gnus-newsgroup-headers-hashtb-by-number
9228 (gnus-make-headers-hashtable-by-number))
9229 (let* ((article (if header (header-number header) article))
9230 (summary-buffer (current-buffer))
9231 (internal-hook gnus-article-internal-prepare-hook)
9232 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
9233 (group gnus-newsgroup-name)
9236 (gnus-article-setup-buffer)
9237 (set-buffer gnus-article-buffer)
9238 (let ((buffer-read-only nil))
9239 (if (not (setq result (gnus-request-article-this-buffer
9241 ;; There is no such article.
9244 (set-buffer gnus-summary-buffer)
9245 (setq gnus-current-article 0)
9246 (and (numberp article)
9247 (gnus-summary-mark-as-read article gnus-canceled-mark))
9248 (message "No such article (may be canceled)")
9249 (and (numberp article)
9250 (setq gnus-current-article article))
9252 (and (numberp article)
9253 (setq gnus-article-current
9254 (cons gnus-newsgroup-name article)))
9256 (if (not (eq result 'article))
9259 (set-buffer summary-buffer)
9260 (setq gnus-last-article gnus-current-article
9261 gnus-newsgroup-history (cons gnus-current-article
9262 gnus-newsgroup-history)
9263 gnus-current-article 0
9264 gnus-current-headers nil
9265 gnus-article-current nil)
9266 (gnus-configure-windows 'article)
9267 (gnus-set-global-variables))
9268 (gnus-set-mode-line 'article))
9269 ;; The result from the `request' was an actual article -
9270 ;; or at least some text that is now displayed in the
9272 (if (and (numberp article)
9273 (not (eq article gnus-current-article)))
9274 ;; Seems like a new article has been selected.
9275 ;; `gnus-current-article' must be an article number.
9277 (set-buffer summary-buffer)
9278 (setq gnus-last-article gnus-current-article
9279 gnus-newsgroup-history (cons gnus-current-article
9280 gnus-newsgroup-history)
9281 gnus-current-article article
9282 gnus-current-headers
9283 (gnus-get-header-by-number gnus-current-article)
9284 gnus-article-current
9285 (cons gnus-newsgroup-name gnus-current-article))
9286 (run-hooks 'gnus-mark-article-hook)
9287 (gnus-set-mode-line 'summary)
9289 (run-hooks 'gnus-visual-mark-article-hook))
9290 ;; Set the global newsgroup variables here.
9291 ;; Suggested by Jim Sisolak
9292 ;; <sisolak@trans4.neep.wisc.edu>.
9293 (gnus-set-global-variables)))
9294 ;; gnus-have-all-headers must be either T or NIL.
9295 (setq gnus-have-all-headers
9296 (not (not (or all-headers gnus-show-all-headers))))
9297 ;; Hooks for getting information from the article.
9298 ;; This hook must be called before being narrowed.
9299 (run-hooks 'internal-hook)
9300 (run-hooks 'gnus-article-prepare-hook)
9301 ;; Decode MIME message.
9302 (if (and gnus-show-mime
9303 (gnus-fetch-field "Mime-Version"))
9304 (funcall gnus-show-mime-method))
9305 ;; Perform the article display hooks.
9306 (let ((buffer-read-only nil))
9307 (run-hooks 'gnus-article-display-hook))
9309 (goto-char (point-min))
9310 (and gnus-break-pages (gnus-narrow-to-page))
9311 (gnus-set-mode-line 'article)
9312 (gnus-configure-windows 'article)
9315 (get-buffer-window gnus-article-buffer)
9317 (message "Moved to bookmark")
9318 (search-forward "\n\n" nil t)
9319 (forward-line bookmark)
9325 (defun gnus-article-show-all-headers ()
9326 "Show all article headers in article mode buffer."
9328 (setq gnus-have-all-headers t)
9329 (gnus-article-setup-buffer)
9330 (set-buffer gnus-article-buffer)
9331 (let ((buffer-read-only nil))
9332 (remove-text-properties 1 (point-max) '(invisible t)))))
9334 (defun gnus-article-hide-headers-if-wanted ()
9335 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9336 Provided for backwards compatability."
9337 (or gnus-have-all-headers
9338 (gnus-article-hide-headers)))
9340 (defun gnus-article-hide-headers (&optional delete)
9341 "Hide unwanted headers and possibly sort them as well."
9344 (set-buffer gnus-article-buffer)
9346 (let ((sorted gnus-sorted-header-list)
9347 (buffer-read-only nil)
9348 want want-list beg want-l)
9349 ;; First we narrow to just the headers.
9352 ;; Hide any "From " lines at the beginning of (mail) articles.
9353 (while (looking-at "From ")
9356 (add-text-properties 1 (point) '(invisible t)))
9357 ;; Then treat the rest of the header lines.
9360 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9361 ;; Then we use the two regular expressions
9362 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9363 ;; select which header lines is to remain visible in the
9366 (while (re-search-forward "^[^ \t]*:" nil t)
9368 ;; We add the headers we want to keep to a list and delete
9369 ;; them from the buffer.
9370 (if (or (and (stringp gnus-visible-headers)
9371 (looking-at gnus-visible-headers))
9372 (and (not (stringp gnus-visible-headers))
9373 (stringp gnus-ignored-headers)
9374 (not (looking-at gnus-ignored-headers))))
9378 ;; Be sure to get multi-line headers...
9379 (re-search-forward "^[^ \t]*:" nil t)
9382 (cons (buffer-substring beg (point)) want-list))
9383 (delete-region beg (point))
9386 ;; Next we perform the sorting by looking at
9387 ;; `gnus-sorted-header-list'.
9389 (while (and sorted want-list)
9390 (setq want-l want-list)
9392 (not (string-match (car sorted) (car want-l))))
9393 (setq want-l (cdr want-l)))
9396 (insert (car want-l))
9397 (setq want-list (delq (car want-l) want-list))))
9398 (setq sorted (cdr sorted)))
9399 ;; Any headers that were not matched by the sorted list we
9400 ;; just tack on the end of the visible header list.
9402 (insert (car want-list))
9403 (setq want-list (cdr want-list)))
9404 ;; And finally we make the unwanted headers invisible.
9406 (delete-region (point) (point-max))
9407 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9408 (add-text-properties (point) (point-max) '(invisible t)))))))
9410 (defun gnus-article-hide-signature ()
9411 "Hides the signature in an article.
9412 It does this by hiding everyting after \"^-- *$\", which is what all
9413 signatures should be preceded by. Note that this may mean that parts
9414 of an article may disappear if the article has such a line in the
9415 middle of the text."
9418 (set-buffer gnus-article-buffer)
9419 (let ((buffer-read-only nil))
9420 (goto-char (point-max))
9421 (if (re-search-backward "^-- *$" nil t)
9423 (add-text-properties (point) (point-max) '(invisible t)))))))
9425 (defun gnus-article-hide-citation ()
9426 "Hide all cited text.
9427 This function uses the famous, extremely intelligent \"shoot in foot\"
9428 algorithm - which is simply deleting all lines that start with
9429 \">\". Your mileage may vary. If you come up with anything better,
9430 please do mail it to me."
9433 (set-buffer gnus-article-buffer)
9434 (let ((buffer-read-only nil))
9436 (search-forward "\n\n" nil t)
9438 (if (looking-at ">")
9439 (add-text-properties
9440 (point) (save-excursion (forward-line 1) (point))
9442 (forward-line 1)))))
9444 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9445 (defun gnus-article-treat-overstrike ()
9446 "Translate overstrikes into bold text."
9449 (set-buffer gnus-article-buffer)
9450 (let ((buffer-read-only nil))
9451 (while (search-forward "\b" nil t)
9452 (let ((next (following-char))
9453 (previous (char-after (- (point) 2))))
9454 (cond ((eq next previous)
9455 (delete-region (- (point) 2) (point))
9456 (put-text-property (point) (1+ (point))
9459 (delete-region (1- (point)) (1+ (point)))
9460 (put-text-property (1- (point)) (point)
9463 (delete-region (- (point) 2) (point))
9464 (put-text-property (point) (1+ (point))
9465 'face 'underline))))))))
9467 (defun gnus-article-word-wrap ()
9468 "Format too long lines."
9471 (set-buffer gnus-article-buffer)
9472 (let ((buffer-read-only nil))
9474 (search-forward "\n\n" nil t)
9476 (let ((paragraph-start "^\\W"))
9478 (and (>= (current-column) (window-width))
9479 (/= (preceding-char) ?:)
9480 (fill-paragraph nil))
9481 (end-of-line 2))))))
9483 (defun gnus-article-remove-cr ()
9484 "Remove carriage returns from an article."
9487 (set-buffer gnus-article-buffer)
9488 (let ((buffer-read-only nil))
9489 (goto-char (point-min))
9490 (while (search-forward "\r" nil t)
9491 (replace-match "" t t)))))
9493 (defun gnus-article-display-x-face ()
9494 "Look for an X-Face header and display it if present."
9497 (set-buffer gnus-article-buffer)
9498 (goto-char (point-min))
9499 (if (or (not gnus-article-x-face-command)
9500 (and (re-search-forward "^\\($\\|X-Face: \\)" nil t)
9508 (while (and (looking-at "[ \t]")
9509 (zerop (forward-line 1))))
9511 (command gnus-article-x-face-command))
9512 (if (symbolp command)
9513 (and (or (fboundp command) (error "%s is not a function" command))
9514 (funcall command face))
9515 (let ((process (start-process "gnus-x-face" nil "sh" "-c" command)))
9518 (process-send-string process face)
9519 (process-send-eof process))
9520 (error "Couldn't start process"))))))))
9523 (defun gnus-mime-decode-quoted-printable (from to)
9524 ;; Decode quoted-printable from region between FROM and TO.
9527 (while (search-forward "=" to t)
9528 (cond ((eq (following-char) ?\n)
9531 ((looking-at "[0-9A-F][0-9A-F]")
9533 (insert (hexl-hex-string-to-integer
9534 (buffer-substring (point) (+ 2 (point)))))
9536 ((message "Malformed MIME quoted-printable message"))))))
9538 (defun gnus-article-de-quoted-unreadable ()
9539 "Do a naive translation of a quoted-printable-encoded article.
9540 This is in no way, shape or form meant as a replacement for real MIME
9541 processing, but is simply a stop-gap measure until MIME support is
9543 ;; Unquote quoted-printable from news articles.
9545 (set-buffer gnus-article-buffer)
9546 (let ((case-fold-search t)
9547 (type (gnus-fetch-field "content-transfer-encoding")))
9548 (cond ((and (stringp type) (string-match "quoted-printable" type))
9549 (goto-char (point-min))
9550 (search-forward "\n\n" nil 'move)
9551 (message "MIME Unquoting printable...")
9552 (gnus-mime-decode-quoted-printable (point) (point-max))
9553 (message "MIME Unquoting printable...done")))
9554 (set-buffer gnus-summary-buffer))))
9556 (defun gnus-article-date-ut (date type)
9557 "Convert DATE date to universal time in the current article.
9558 If TYPE is `local', convert to local time; if it is `lapsed', output
9559 how much time has lapsed since DATE."
9560 (interactive (list (header-date gnus-current-headers) 'ut))
9564 (set-buffer gnus-article-buffer)
9565 (let ((buffer-read-only nil))
9566 (goto-char (point-min))
9567 (if (re-search-forward "^Date: \\|^X-Sent: " nil t)
9568 (delete-region (gnus-point-at-bol)
9569 (progn (forward-line 1) (point)))
9570 (- (search-forward "\n\n") 2))
9574 (concat "Date: " (timezone-make-date-arpa-standard date) "\n"))
9576 (concat "Date: " (timezone-make-date-arpa-standard date nil "UT")
9579 (let* ((sec (- (gnus-seconds-since-epoch (current-time-string))
9580 (gnus-seconds-since-epoch date)))
9581 (units (list (cons 'year (* 1.0 365 24 60 60))
9582 (cons 'week (* 7 24 60 60))
9583 (cons 'day (* 24 60 60))
9584 (cons 'hour (* 60 60))
9592 (if (zerop (setq num (floor (/ sec (cdr unit)))))
9594 (setq sec (- sec (* num (cdr unit))))
9596 (concat (if prev ", " "") (int-to-string num)
9597 " " (symbol-name (car unit))
9598 (if (> num 1) "s" ""))
9603 (error "Unknown conversion type: %s" type))))))))
9605 (defun gnus-article-date-local (date)
9606 "Convert the current article date to the local timezone."
9607 (interactive (list (header-date gnus-current-headers)))
9608 (gnus-article-date-ut date 'local))
9610 (defun gnus-article-date-lapsed (date)
9611 "Convert the current article date to time lapsed since it was sent."
9612 (interactive (list (header-date gnus-current-headers)))
9613 (gnus-article-date-ut date 'lapsed))
9618 (defun gnus-output-to-rmail (file-name)
9619 "Append the current article to an Rmail file named FILE-NAME."
9621 ;; Most of these codes are borrowed from rmailout.el.
9622 (setq file-name (expand-file-name file-name))
9623 (setq rmail-default-rmail-file file-name)
9624 (let ((artbuf (current-buffer))
9625 (tmpbuf (get-buffer-create " *Gnus-output*")))
9627 (or (get-file-buffer file-name)
9628 (file-exists-p file-name)
9629 (if (gnus-yes-or-no-p
9630 (concat "\"" file-name "\" does not exist, create it? "))
9631 (let ((file-buffer (create-file-buffer file-name)))
9633 (set-buffer file-buffer)
9634 (rmail-insert-rmail-file-header)
9635 (let ((require-final-newline nil))
9636 (write-region (point-min) (point-max) file-name t 1)))
9637 (kill-buffer file-buffer))
9638 (error "Output file does not exist")))
9640 (buffer-disable-undo (current-buffer))
9642 (insert-buffer-substring artbuf)
9643 (gnus-convert-article-to-rmail)
9644 ;; Decide whether to append to a file or to an Emacs buffer.
9645 (let ((outbuf (get-file-buffer file-name)))
9647 (append-to-file (point-min) (point-max) file-name)
9648 ;; File has been visited, in buffer OUTBUF.
9650 (let ((buffer-read-only nil)
9651 (msg (and (boundp 'rmail-current-message)
9652 (symbol-value 'rmail-current-message))))
9653 ;; If MSG is non-nil, buffer is in RMAIL mode.
9656 (narrow-to-region (point-max) (point-max))))
9657 (insert-buffer-substring tmpbuf)
9660 (goto-char (point-min))
9662 (search-backward "\^_")
9663 (narrow-to-region (point) (point-max))
9664 (goto-char (1+ (point-min)))
9665 (rmail-count-new-messages t)
9666 (rmail-show-message msg)))))))
9667 (kill-buffer tmpbuf)))
9669 (defun gnus-output-to-file (file-name)
9670 "Append the current article to a file named FILE-NAME."
9671 (setq file-name (expand-file-name file-name))
9672 (let ((artbuf (current-buffer))
9673 (tmpbuf (get-buffer-create " *Gnus-output*")))
9676 (buffer-disable-undo (current-buffer))
9678 (insert-buffer-substring artbuf)
9679 ;; Append newline at end of the buffer as separator, and then
9681 (goto-char (point-max))
9683 (append-to-file (point-min) (point-max) file-name))
9684 (kill-buffer tmpbuf)))
9686 (defun gnus-convert-article-to-rmail ()
9687 "Convert article in current buffer to Rmail message format."
9688 (let ((buffer-read-only nil))
9689 ;; Convert article directly into Babyl format.
9690 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9691 (goto-char (point-min))
9692 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9693 (while (search-forward "\n\^_" nil t) ;single char
9694 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
9695 (goto-char (point-max))
9698 (defun gnus-narrow-to-page (&optional arg)
9699 "Make text outside current page invisible except for page delimiter.
9700 A numeric arg specifies to move forward or backward by that many pages,
9701 thus showing a page other than the one point was originally in."
9703 (setq arg (if arg (prefix-numeric-value arg) 0))
9705 (forward-page -1) ;Beginning of current page.
9710 (forward-page (1- arg))))
9711 ;; Find the end of the page.
9713 ;; If we stopped due to end of buffer, stay there.
9714 ;; If we stopped after a page delimiter, put end of restriction
9715 ;; at the beginning of that line.
9716 ;; These are commented out.
9717 ;; (if (save-excursion (beginning-of-line)
9718 ;; (looking-at page-delimiter))
9719 ;; (beginning-of-line))
9720 (narrow-to-region (point)
9722 ;; Find the top of the page.
9724 ;; If we found beginning of buffer, stay there.
9725 ;; If extra text follows page delimiter on same line,
9727 ;; Otherwise, show text starting with following line.
9728 (if (and (eolp) (not (bobp)))
9732 (defun gnus-gmt-to-local ()
9733 "Rewrite Date header described in GMT to local in current buffer.
9734 Intended to be used with gnus-article-prepare-hook."
9738 (goto-char (point-min))
9739 (narrow-to-region (point-min)
9740 (progn (search-forward "\n\n" nil 'move) (point)))
9741 (goto-char (point-min))
9742 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
9743 (let ((buffer-read-only nil)
9744 (date (buffer-substring (match-beginning 1) (match-end 1))))
9745 (delete-region (match-beginning 1) (match-end 1))
9747 (timezone-make-date-arpa-standard
9748 date nil (current-time-zone))))))))
9751 ;; Article mode commands
9753 (defun gnus-article-next-page (lines)
9754 "Show next page of current article.
9755 If end of article, return non-nil. Otherwise return nil.
9756 Argument LINES specifies lines to be scrolled up."
9758 (move-to-window-line -1)
9759 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
9762 (and (pos-visible-in-window-p) ;Not continuation line.
9764 ;; Nothing in this page.
9765 (if (or (not gnus-break-pages)
9768 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
9770 (gnus-narrow-to-page 1) ;Go to next page.
9772 ;; More in this page.
9776 ;; Long lines may cause an end-of-buffer error.
9777 (goto-char (point-max))))
9780 (defun gnus-article-prev-page (lines)
9781 "Show previous page of current article.
9782 Argument LINES specifies lines to be scrolled down."
9784 (move-to-window-line 0)
9785 (if (and gnus-break-pages
9787 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
9789 (gnus-narrow-to-page -1) ;Go to previous page.
9790 (goto-char (point-max))
9792 (scroll-down lines)))
9794 (defun gnus-article-refer-article ()
9795 "Read article specified by message-id around point."
9797 (search-forward ">" nil t) ;Move point to end of "<....>".
9798 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
9800 (buffer-substring (match-beginning 1) (match-end 1))))
9801 (set-buffer gnus-summary-buffer)
9802 (gnus-summary-refer-article message-id))
9803 (error "No references around point")))
9805 (defun gnus-article-mail (yank)
9806 "Send a reply to the address near point.
9807 If YANK is non-nil, include the original article."
9811 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
9812 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
9815 (switch-to-buffer gnus-summary-buffer)
9816 (funcall gnus-mail-reply-method yank address)))))
9818 (defun gnus-article-mail-with-original ()
9819 "Send a reply to the address near point and include the original article."
9821 (gnus-article-mail 'yank))
9823 (defun gnus-article-show-summary ()
9824 "Reconfigure windows to show summary buffer."
9826 (gnus-configure-windows 'article)
9827 (pop-to-buffer gnus-summary-buffer)
9828 (gnus-summary-goto-subject gnus-current-article))
9830 (defun gnus-article-describe-briefly ()
9831 "Describe article mode commands briefly."
9834 (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")))
9836 (defun gnus-article-summary-command ()
9837 "Execute the last keystroke in the summary buffer."
9839 (let ((obuf (current-buffer))
9840 (owin (current-window-configuration)))
9841 (switch-to-buffer gnus-summary-buffer 'norecord)
9842 (execute-kbd-macro (this-command-keys))
9844 (let ((npoint (point)))
9845 (set-window-configuration owin)
9846 (set-window-start (get-buffer-window (current-buffer)) (point)))))
9848 (defun gnus-article-summary-command-nosave ()
9849 "Execute the last keystroke in the summary buffer."
9851 (let ((obuf (current-buffer))
9852 (owin (current-window-configuration)))
9853 (switch-to-buffer gnus-summary-buffer 'norecord)
9854 (execute-kbd-macro (this-command-keys))))
9856 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
9857 ;; Modified by tower@prep Nov 86
9858 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
9860 (defun gnus-caesar-region (&optional n)
9861 "Caesar rotation of region by N, default 13, for decrypting netnews.
9862 ROT47 will be performed for Japanese text in any case."
9863 (interactive (if current-prefix-arg ; Was there a prefix arg?
9864 (list (prefix-numeric-value current-prefix-arg))
9866 (cond ((not (numberp n)) (setq n 13))
9867 (t (setq n (mod n 26)))) ;canonicalize N
9868 (if (not (zerop n)) ; no action needed for a rot of 0
9870 (if (or (not (boundp 'caesar-translate-table))
9871 (not caesar-translate-table)
9872 (/= (aref caesar-translate-table ?a) (+ ?a n)))
9874 (lower "abcdefghijklmnopqrstuvwxyz")
9876 (message "Building caesar-translate-table...")
9877 (setq caesar-translate-table (make-vector 256 0))
9879 (aset caesar-translate-table i i)
9881 (setq lower (concat lower lower)
9882 upper (upcase lower)
9885 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
9886 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
9888 ;; ROT47 for Japanese text.
9889 ;; Thanks to ichikawa@flab.fujitsu.junet.
9891 (let ((t1 (logior ?O 128))
9892 (t2 (logior ?! 128))
9893 (t3 (logior ?~ 128)))
9895 (aset caesar-translate-table i
9896 (let ((v (aref caesar-translate-table i)))
9897 (if (<= v t1) (if (< v t2) v (+ v 47))
9898 (if (<= v t3) (- v 47) v))))
9900 (message "Building caesar-translate-table... done")))
9901 (let ((from (region-beginning))
9904 (setq str (buffer-substring from to))
9905 (setq len (length str))
9907 (aset str i (aref caesar-translate-table (aref str i)))
9910 (delete-region from to)
9914 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
9917 (defalias 'gnus-batch-kill 'gnus-batch-score)
9919 (defun gnus-batch-score ()
9920 "Run batched scoring.
9921 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
9922 Newsgroups is a list of strings in Bnews format. If you want to score
9923 the comp hierarchy, you'd say \"comp.all\". If you would not like to
9924 score the alt hierarchy, you'd say \"!alt.all\"."
9927 (gnus-parse-n-options
9928 (apply (function concat)
9929 (mapcar (lambda (g) (concat g " "))
9930 command-line-args-left))))
9931 (gnus-expert-user t)
9932 (nnmail-spool-file nil)
9933 (gnus-use-dribble-file nil)
9934 (yes (car yes-and-no))
9935 (no (cdr yes-and-no))
9936 group subscribed newsrc entry
9937 ;; Disable verbose message.
9938 gnus-novice-user gnus-large-newsgroup)
9939 ;; Eat all arguments.
9940 (setq command-line-args-left nil)
9943 ;; Apply kills to specified newsgroups in command line arguments.
9944 (setq newsrc (cdr gnus-newsrc-alist))
9946 (setq group (car (car newsrc)))
9947 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
9948 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
9950 (or (eq (car entry) t)
9951 (not (zerop (car entry)))))
9952 (if yes (string-match yes group) t)
9953 (or (null no) (not (string-match no group))))
9955 (gnus-summary-read-group group nil t)
9956 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
9957 (gnus-summary-exit))))
9958 (setq newsrc (cdr newsrc)))
9960 (switch-to-buffer gnus-group-buffer)
9961 (gnus-group-save-newsrc)))
9963 (defun gnus-apply-kill-file ()
9964 "Apply a kill file to the current newsgroup.
9965 Returns the number of articles marked as read."
9966 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
9967 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9968 (gnus-apply-kill-file-internal)
9971 (defun gnus-kill-save-kill-buffer ()
9973 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9974 (if (get-file-buffer file)
9976 (set-buffer (get-file-buffer file))
9977 (and (buffer-modified-p) (save-buffer))
9978 (kill-buffer (current-buffer)))))))
9980 (defvar gnus-kill-file-name "KILL"
9981 "Suffix of the kill files.")
9983 (defun gnus-newsgroup-kill-file (newsgroup)
9984 "Return the name of a kill file name for NEWSGROUP.
9985 If NEWSGROUP is nil, return the global kill file name instead."
9986 (cond ((or (null newsgroup)
9987 (string-equal newsgroup ""))
9988 ;; The global KILL file is placed at top of the directory.
9989 (expand-file-name gnus-kill-file-name
9990 (or gnus-kill-files-directory "~/News")))
9991 ((gnus-use-long-file-name 'not-kill)
9992 ;; Append ".KILL" to newsgroup name.
9993 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
9994 (or gnus-kill-files-directory "~/News")))
9996 ;; Place "KILL" under the hierarchical directory.
9997 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9998 "/" gnus-kill-file-name)
9999 (or gnus-kill-files-directory "~/News")))))
10006 (defvar gnus-dribble-ignore nil)
10008 (defun gnus-dribble-file-name ()
10009 (concat gnus-startup-file "-dribble"))
10011 (defun gnus-dribble-open ()
10014 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10015 (buffer-disable-undo (current-buffer))
10016 (bury-buffer gnus-dribble-buffer)
10018 (goto-char (point-max))))
10020 (defun gnus-dribble-enter (string)
10021 (if (and (not gnus-dribble-ignore)
10022 gnus-dribble-buffer
10023 (buffer-name gnus-dribble-buffer))
10024 (let ((obuf (current-buffer)))
10025 (set-buffer gnus-dribble-buffer)
10026 (insert string "\n")
10027 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10028 (set-buffer obuf))))
10030 (defun gnus-dribble-read-file ()
10031 (let ((dribble-file (gnus-dribble-file-name)))
10033 (set-buffer (setq gnus-dribble-buffer
10035 (file-name-nondirectory dribble-file))))
10036 (gnus-add-current-to-buffer-list)
10038 (set-visited-file-name dribble-file)
10039 (buffer-disable-undo (current-buffer))
10040 (bury-buffer (current-buffer))
10041 (set-buffer-modified-p nil)
10042 (let ((auto (make-auto-save-file-name))
10043 (gnus-dribble-ignore t))
10044 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10046 (if (file-newer-than-file-p auto dribble-file)
10047 (setq dribble-file auto))
10048 (insert-file-contents dribble-file)
10049 (if (not (zerop (buffer-size)))
10050 (set-buffer-modified-p t))
10052 "Auto-save file exists. Do you want to read it? ")
10054 (message "Reading %s..." dribble-file)
10055 (eval-current-buffer)
10056 (message "Reading %s...done" dribble-file)))))))))
10058 (defun gnus-dribble-delete-file ()
10059 (if (file-exists-p (gnus-dribble-file-name))
10060 (delete-file (gnus-dribble-file-name)))
10061 (if gnus-dribble-buffer
10063 (set-buffer gnus-dribble-buffer)
10064 (let ((auto (make-auto-save-file-name)))
10065 (if (file-exists-p auto)
10066 (delete-file auto))
10068 (set-buffer-modified-p nil)))))
10070 (defun gnus-dribble-save ()
10071 (if (and gnus-dribble-buffer
10072 (buffer-name gnus-dribble-buffer))
10074 (set-buffer gnus-dribble-buffer)
10077 (defun gnus-dribble-clear ()
10079 (if (gnus-buffer-exists-p gnus-dribble-buffer)
10081 (set-buffer gnus-dribble-buffer)
10083 (set-buffer-modified-p nil)
10084 (setq buffer-saved-size (buffer-size))))))
10087 ;;; Server Communication
10090 ;; All the Gnus backends have the same interface, and should return
10091 ;; data in a similar format. Below is an overview of what functions
10092 ;; these packages must supply and what results they should return.
10096 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
10099 ;; Functions for the imaginary backend `choke':
10101 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
10102 ;; Should return all headers for all ARTICLES, or return NOV lines for
10105 ;; `choke-request-group GROUP &optional SERVER DISCARD'
10106 ;; Switch to GROUP. If DISCARD is nil, active information on the group
10107 ;; must be returned.
10109 ;; `choke-close-group GROUP &optional SERVER'
10110 ;; Close group. Most backends won't have to do anything with this
10111 ;; call, but it is an opportunity to clean up, if that is needed. It
10112 ;; is called when Gnus exits a group.
10114 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
10115 ;; Return ARTICLE, which is either an article number or
10116 ;; message-id. Note that not all backends can return articles based on
10119 ;; `choke-request-list SERVER'
10120 ;; Return a list of all newsgroups on SERVER.
10122 ;; `choke-request-list-newsgroups SERVER'
10123 ;; Return a list of descriptions of all newsgroups on SERVER.
10125 ;; `choke-request-newgroups DATE &optional SERVER'
10126 ;; Return a list of all groups that have arrived after DATE on
10127 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
10128 ;; always check whether the groups are old or not. Backends that do
10129 ;; not store date information may just return the entire list of
10130 ;; groups, although this might not be a good idea in general.
10132 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
10133 ;; Should return a buffer that is suitable for "posting". nnspool and
10134 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
10135 ;; buffer. This function should fill out the appropriate headers.
10137 ;; `choke-request-post &optional SERVER'
10138 ;; Function that will be called from a buffer to be posted.
10140 ;; `choke-open-server SERVER &optional ARGUMENT'
10141 ;; Open a connection to SERVER.
10143 ;; `choke-close-server &optional SERVER'
10144 ;; Close the connection to SERVER.
10146 ;; `choke-server-opened &optional SERVER'
10147 ;; Whether the conenction to SERVER is opened or not.
10149 ;; `choke-server-status &optional SERVER'
10150 ;; Should return a status string (not in the nntp buffer, but as the
10151 ;; result of the function).
10153 ;; `choke-retrieve-groups GROUPS &optional SERVER'
10154 ;; Optional function for retrieving active file info on all groups in
10155 ;; GROUPS. Two return formats are supported: The normal active file
10156 ;; format, and a list of GROUP lines. This function should return (as
10157 ;; a function value) either `active' or `group', depending on what
10158 ;; format it returns.
10160 ;; The following functions are optional and apply only to backends
10161 ;; that are able to control the contents of their groups totally
10162 ;; (ie. mail backends.) Backends that aren't able to do that
10163 ;; shouldn't define these functions at all. Gnus will check for their
10164 ;; presence before attempting to call them.
10166 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
10167 ;; Should expire (according to some aging scheme) all ARTICLES. Most
10168 ;; backends will not be able to expire articles. Should return a list
10169 ;; of all articles that were not expired.
10171 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
10172 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
10173 ;; Removes any information it has added to the article (extra headers,
10174 ;; whatever - make it as clean as possible), and then passes the
10175 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
10176 ;; function described below. If the ACCEPT-FORM returns a non-nil
10177 ;; value, the article should then be deleted. If LAST is nil, that
10178 ;; means that there will be further calls to this function. This might
10179 ;; be taken as an advice not to save buffers/internal variables just
10180 ;; yet, but wait until the last call to speed things up.
10182 ;; `choke-request-accept-article GROUP &optional LAST'
10183 ;; The contents of the current buffer will be put into GROUP. There
10184 ;; should, of course, be an article in the current buffer. This
10185 ;; function is normally only called by the function described above,
10186 ;; and LAST works the same way as in that function.
10188 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
10189 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
10190 ;; This provides an easy interface for allowing editing of
10191 ;; articles. Note that even headers may be edited, so the backend has
10192 ;; to update any tables (nov buffers, etc) that it maintains after
10193 ;; replacing the article.
10195 ;; `choke-request-create-group GROUP &optional SERVER'
10196 ;; Create GROUP on SERVER. This might be a new, empty group, or it
10197 ;; might be a group that already exists, but hasn't been registered
10200 ;; All these functions must return nil if they couldn't service the
10201 ;; request. If the optional arguments are not supplied, some "current"
10202 ;; or "default" values should be used. In short, one should emulate an
10203 ;; NNTP server, in a way.
10205 ;; If you want to write a new backend, you just have to supply the
10206 ;; functions listed above. In addition, you must enter the new backend
10207 ;; into the list of valid select methods:
10208 ;; (setq gnus-valid-select-methods
10209 ;; (cons '("choke" mail) gnus-valid-select-methods))
10210 ;; The first element in this list is the name of the backend. Other
10211 ;; elemnets may be `mail' (for mail groups), `post' (for news
10212 ;; groups), `none' (neither), `respool' (for groups that can control
10213 ;; their contents).
10215 (defun gnus-start-news-server (&optional confirm)
10216 "Open a method for getting news.
10217 If CONFIRM is non-nil, the user will be asked for an NNTP server."
10219 (if gnus-current-select-method
10220 ;; Stream is already opened.
10222 ;; Open NNTP server.
10223 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
10226 ;; Read server name with completion.
10227 (setq gnus-nntp-server
10228 (completing-read "NNTP server: "
10229 (mapcar (lambda (server) (list server))
10230 (cons (list gnus-nntp-server)
10231 gnus-secondary-servers))
10232 nil nil gnus-nntp-server))))
10234 (if (and gnus-nntp-server
10235 (stringp gnus-nntp-server)
10236 (not (string= gnus-nntp-server "")))
10237 (setq gnus-select-method
10238 (cond ((or (string= gnus-nntp-server "")
10239 (string= gnus-nntp-server "::"))
10240 (list 'nnspool (system-name)))
10241 ((string-match "^:" gnus-nntp-server)
10242 (list 'nnmh gnus-nntp-server
10243 (list 'nnmh-directory
10244 (file-name-as-directory
10246 (concat "~/" (substring
10247 gnus-nntp-server 1)))))))
10249 (list 'nntp gnus-nntp-server)))))
10251 (setq how (car gnus-select-method))
10252 (setq where (car (cdr gnus-select-method)))
10253 (cond ((eq how 'nnspool)
10255 (message "Looking up local news spool..."))
10258 (message "Looking up mh spool..."))
10261 (setq gnus-current-select-method gnus-select-method)
10262 (run-hooks 'gnus-open-server-hook)
10264 ;; gnus-open-server-hook might have opened it
10265 (gnus-server-opened gnus-select-method)
10266 (gnus-open-server gnus-select-method)
10269 "%s server on %s can't be opened. Continue? "
10270 (car gnus-select-method) (nth 1 gnus-select-method)))
10272 (message "Couldn't open server on %s" (nth 1 gnus-select-method))
10276 (defun gnus-check-news-server (method)
10277 "If the news server is down, start it up again."
10278 (let ((method (if method method gnus-select-method)))
10279 (and (stringp method)
10280 (setq method (gnus-server-to-method method)))
10281 (if (gnus-server-opened method)
10282 ;; Stream is already opened.
10285 (message "Opening server %s on %s..." (car method) (nth 1 method))
10286 (run-hooks 'gnus-open-server-hook)
10287 (or (gnus-server-opened method)
10288 (gnus-open-server method))
10291 (defun gnus-nntp-message (&optional message)
10292 "Check the status of the NNTP server.
10293 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
10294 is returned insted of the status string."
10295 (let ((status (gnus-status-message (gnus-find-method-for-group
10296 gnus-newsgroup-name)))
10297 (message (or message "")))
10298 (if (and (stringp status) (> (length status) 0))
10301 (defun gnus-get-function (method function)
10302 (and (stringp method)
10303 (setq method (gnus-server-to-method method)))
10304 (let ((func (intern (format "%s-%s" (car method) function))))
10305 (if (not (fboundp func))
10307 (require (car method))
10308 (if (not (fboundp func))
10309 (error "No such function: %s" func))))
10312 ;;; Interface functions to the backends.
10314 (defun gnus-open-server (method)
10315 (funcall (gnus-get-function method 'open-server)
10316 (nth 1 method) (nthcdr 2 method)))
10318 (defun gnus-close-server (method)
10319 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
10321 (defun gnus-request-list (method)
10322 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
10324 (defun gnus-request-list-newsgroups (method)
10325 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
10327 (defun gnus-request-newgroups (date method)
10328 (funcall (gnus-get-function method 'request-newgroups)
10329 date (nth 1 method)))
10331 (defun gnus-server-opened (method)
10332 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
10334 (defun gnus-status-message (method)
10335 (let ((method (if (stringp method) (gnus-find-method-for-group method)
10337 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
10339 (defun gnus-request-group (group &optional dont-check)
10340 (let ((method (gnus-find-method-for-group group)))
10341 (funcall (gnus-get-function method 'request-group)
10342 (gnus-group-real-name group) (nth 1 method) dont-check)))
10344 (defun gnus-request-asynchronous (group &optional articles)
10345 (let ((method (gnus-find-method-for-group group)))
10346 (funcall (gnus-get-function method 'request-asynchronous)
10347 (gnus-group-real-name group) (nth 1 method) articles)))
10349 (defun gnus-list-active-group (group)
10350 (let ((method (gnus-find-method-for-group group))
10351 (func 'list-active-group))
10352 (and (gnus-check-backend-function func group)
10353 (funcall (gnus-get-function method func)
10354 (gnus-group-real-name group) (nth 1 method)))))
10356 (defun gnus-request-group-description (group)
10357 (let ((method (gnus-find-method-for-group group))
10358 (func 'request-group-description))
10359 (and (gnus-check-backend-function func group)
10360 (funcall (gnus-get-function method func)
10361 (gnus-group-real-name group) (nth 1 method)))))
10363 (defun gnus-close-group (group)
10364 (let ((method (gnus-find-method-for-group group)))
10365 (funcall (gnus-get-function method 'close-group)
10366 (gnus-group-real-name group) (nth 1 method))))
10368 (defun gnus-retrieve-headers (articles group)
10369 (let ((method (gnus-find-method-for-group group)))
10370 (funcall (gnus-get-function method 'retrieve-headers)
10371 articles (gnus-group-real-name group) (nth 1 method))))
10373 (defun gnus-retrieve-groups (groups method)
10374 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
10376 (defun gnus-request-article (article group &optional buffer)
10377 (let ((method (gnus-find-method-for-group group)))
10378 (funcall (gnus-get-function method 'request-article)
10379 article (gnus-group-real-name group) (nth 1 method) buffer)))
10381 (defun gnus-request-head (article group)
10382 (let ((method (gnus-find-method-for-group group)))
10383 (funcall (gnus-get-function method 'request-head)
10384 article (gnus-group-real-name group) (nth 1 method))))
10386 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10387 (defun gnus-request-post-buffer (post group subject header artbuf
10388 info follow-to respect-poster)
10389 (let* ((info (or info (and group (nth 2 (gnus-gethash
10390 group gnus-newsrc-hashtb)))))
10392 (if (and gnus-post-method
10393 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10395 (format "%s" (car (gnus-find-method-for-group
10396 gnus-newsgroup-name)))
10397 gnus-valid-select-methods)))
10399 (gnus-find-method-for-group gnus-newsgroup-name))))
10400 (or (gnus-server-opened method)
10401 (gnus-open-server method)
10402 (error "Can't open server %s:%s" (car method) (nth 1 method)))
10403 (let ((mail-self-blind nil)
10404 (mail-archive-file-name nil))
10405 (funcall (gnus-get-function method 'request-post-buffer)
10406 post group subject header artbuf info follow-to
10409 (defun gnus-request-post (method &optional force)
10410 (and (stringp method)
10411 (setq method (gnus-server-to-method method)))
10412 (and (not force) gnus-post-method
10413 (memq 'post (assoc (format "%s" (car method))
10414 gnus-valid-select-methods))
10415 (setq method gnus-post-method))
10416 (funcall (gnus-get-function method 'request-post)
10419 (defun gnus-request-expire-articles (articles group &optional force)
10420 (let ((method (gnus-find-method-for-group group)))
10421 (funcall (gnus-get-function method 'request-expire-articles)
10422 articles (gnus-group-real-name group) (nth 1 method)
10425 (defun gnus-request-move-article
10426 (article group server accept-function &optional last)
10427 (let ((method (gnus-find-method-for-group group)))
10428 (funcall (gnus-get-function method 'request-move-article)
10429 article (gnus-group-real-name group)
10430 (nth 1 method) accept-function last)))
10432 (defun gnus-request-accept-article (group &optional last)
10433 (let ((func (if (symbolp group) group
10434 (car (gnus-find-method-for-group group)))))
10435 (funcall (intern (format "%s-request-accept-article" func))
10436 (if (stringp group) (gnus-group-real-name group) group)
10439 (defun gnus-request-replace-article (article group buffer)
10440 (let ((func (car (gnus-find-method-for-group group))))
10441 (funcall (intern (format "%s-request-replace-article" func))
10442 article (gnus-group-real-name group) buffer)))
10444 (defun gnus-request-create-group (group)
10445 (let ((method (gnus-find-method-for-group group)))
10446 (funcall (gnus-get-function method 'request-create-group)
10447 (gnus-group-real-name group) (nth 1 method))))
10449 (defun gnus-find-method-for-group (group &optional info)
10450 (or gnus-override-method
10452 gnus-select-method)
10453 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
10456 (not (setq method (nth 4 info))))
10457 (setq method gnus-select-method)
10459 (cond ((stringp method)
10460 (gnus-server-to-method method))
10461 ((stringp (car method))
10462 (gnus-server-extend-method group method))
10465 (gnus-server-add-address method))))
10467 (defun gnus-check-backend-function (func group)
10468 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
10470 (fboundp (intern (format "%s-%s" method func)))))
10472 (defun gnus-methods-using (method)
10473 (let ((valids gnus-valid-select-methods)
10476 (if (memq method (car valids))
10477 (setq outs (cons (car valids) outs)))
10478 (setq valids (cdr valids)))
10482 ;;; Active & Newsrc File Handling
10485 ;; Newsrc related functions.
10486 ;; Gnus internal format of gnus-newsrc-alist:
10487 ;; (("alt.general" 3 (1 . 1))
10488 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
10489 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
10490 ;; The first item is the group name; the second is the subscription
10491 ;; level; the third is either a range of a list of ranges of read
10492 ;; articles, the optional fourth element is a list of marked articles,
10493 ;; the optional fifth element is the select method.
10495 ;; Gnus internal format of gnus-newsrc-hashtb:
10496 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
10497 ;; This is the entry for "alt.misc". The first element is the number
10498 ;; of unread articles in "alt.misc". The cdr of this entry is the
10499 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
10500 ;; trivial to remove or add new elements into gnus-newsrc-alist
10501 ;; without scanning the entire list. So, to get the actual information
10502 ;; of "alt.misc", you'd say something like
10503 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
10505 ;; Gnus internal format of gnus-active-hashtb:
10509 ;; The only element in each entry in this hash table is a range of
10510 ;; (possibly) available articles. (Articles in this range may have
10511 ;; been expired or cancelled.)
10513 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
10514 ;; ("alt.misc" "alt.test" "alt.general" ...)
10516 (defun gnus-setup-news (&optional rawfile level)
10517 "Setup news information.
10518 If RAWFILE is non-nil, the .newsrc file will also be read.
10519 If LEVEL is non-nil, the news will be set up at level LEVEL."
10520 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
10521 ;; Clear some variables to re-initialize news information.
10522 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
10524 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
10525 (if init (gnus-read-newsrc-file rawfile))
10527 ;; Read the active file and create `gnus-active-hashtb'.
10528 ;; If `gnus-read-active-file' is nil, then we just create an empty
10529 ;; hash table. The partial filling out of the hash table will be
10530 ;; done in `gnus-get-unread-articles'.
10531 (if (and gnus-read-active-file
10533 (gnus-server-opened gnus-select-method))
10534 (gnus-read-active-file)
10535 (setq gnus-active-hashtb (make-vector 4095 0)))
10537 (and init gnus-use-dribble-file (gnus-dribble-read-file))
10539 ;; Find the number of unread articles in each non-dead group.
10540 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
10541 ;; Find new newsgroups and treat them.
10542 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
10543 (gnus-server-opened gnus-select-method))
10544 (gnus-find-new-newsgroups))
10545 (if (and init gnus-check-bogus-newsgroups
10546 gnus-read-active-file (not level)
10547 (gnus-server-opened gnus-select-method))
10548 (gnus-check-bogus-newsgroups))))
10550 (defun gnus-find-new-newsgroups ()
10551 "Search for new newsgroups and add them.
10552 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
10553 The `-n' option line from .newsrc is respected."
10555 (or (gnus-check-first-time-used)
10556 (if (or (consp gnus-check-new-newsgroups)
10557 (eq gnus-check-new-newsgroups 'ask-server))
10558 (gnus-ask-server-for-new-groups)
10560 group new-newsgroups)
10561 (or gnus-have-read-active-file (gnus-read-active-file))
10562 (setq gnus-newsrc-last-checked-date (current-time-string))
10563 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
10564 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
10565 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
10568 (setq group (symbol-name sym))
10569 (if (or (gnus-gethash group gnus-killed-hashtb)
10570 (gnus-gethash group gnus-newsrc-hashtb))
10572 (let ((do-sub (gnus-matches-options-n group)))
10573 (cond ((eq do-sub 'subscribe)
10574 (setq groups (1+ groups))
10575 (gnus-sethash group group gnus-killed-hashtb)
10577 gnus-subscribe-options-newsgroup-method group))
10578 ((eq do-sub 'ignore)
10581 (setq groups (1+ groups))
10582 (gnus-sethash group group gnus-killed-hashtb)
10583 (if gnus-subscribe-hierarchical-interactive
10584 (setq new-newsgroups (cons group new-newsgroups))
10585 (funcall gnus-subscribe-newsgroup-method group)))))))
10586 gnus-active-hashtb)
10588 (gnus-subscribe-hierarchical-interactive new-newsgroups))
10589 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10591 (message "%d new newsgroup%s arrived."
10592 groups (if (> groups 1) "s have" " has")))))))
10594 (defun gnus-matches-options-n (group)
10595 ;; Returns `subscribe' if the group is to be uncoditionally
10596 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
10597 ;; no match for the group.
10599 ;; First we check the two user variables.
10601 ((and gnus-options-not-subscribe
10602 (string-match gnus-options-not-subscribe group))
10604 ((and gnus-options-subscribe
10605 (string-match gnus-options-subscribe group))
10607 ;; Then we go through the list that was retrieved from the .newsrc
10608 ;; file. This list has elements on the form
10609 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
10610 ;; is in the reverse order of the options line) is returned.
10612 (let ((regs gnus-newsrc-options-n))
10614 (not (string-match (car (car gnus-newsrc-options-n)) group)))
10615 (setq regs (cdr regs)))
10616 (and regs (cdr (car regs)))))))
10618 (defun gnus-ask-server-for-new-groups ()
10619 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
10620 (methods (cons gnus-select-method
10622 (and (consp gnus-check-new-newsgroups)
10623 gnus-check-new-newsgroups)
10624 gnus-secondary-select-methods)))
10626 (new-date (current-time-string))
10627 hashtb group new-newsgroups got-new)
10628 ;; Go thorugh both primary and secondary select methods and
10629 ;; request new newsgroups.
10631 (if (gnus-request-newgroups date (car methods))
10634 (or hashtb (setq hashtb (gnus-make-hashtable
10635 (count-lines (point-min) (point-max)))))
10636 (set-buffer nntp-server-buffer)
10637 ;; Enter all the new groups in a hashtable.
10638 (gnus-active-to-gnus-format (car methods) hashtb)))
10639 (setq methods (cdr methods)))
10640 (and got-new (setq gnus-newsrc-last-checked-date new-date))
10641 ;; Now all new groups from all select methods are in `hashtb'.
10643 (lambda (group-sym)
10644 (setq group (symbol-name group-sym))
10645 (if (or (gnus-gethash group gnus-newsrc-hashtb)
10646 (member group gnus-zombie-list)
10647 (member group gnus-killed-list))
10648 ;; The group is already known.
10650 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
10651 (let ((do-sub (gnus-matches-options-n group)))
10652 (cond ((eq do-sub 'subscribe)
10653 (setq groups (1+ groups))
10654 (gnus-sethash group group gnus-killed-hashtb)
10656 gnus-subscribe-options-newsgroup-method group))
10657 ((eq do-sub 'ignore)
10660 (setq groups (1+ groups))
10661 (gnus-sethash group group gnus-killed-hashtb)
10662 (if gnus-subscribe-hierarchical-interactive
10663 (setq new-newsgroups (cons group new-newsgroups))
10664 (funcall gnus-subscribe-newsgroup-method group)))))))
10667 (gnus-subscribe-hierarchical-interactive new-newsgroups))
10668 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10670 (message "%d new newsgroup%s arrived."
10671 groups (if (> groups 1) "s have" " has")))
10674 (defun gnus-check-first-time-used ()
10675 (if (or (> (length gnus-newsrc-alist) 1)
10676 (file-exists-p gnus-startup-file)
10677 (file-exists-p (concat gnus-startup-file ".el"))
10678 (file-exists-p (concat gnus-startup-file ".eld")))
10680 (message "First time user; subscribing you to default groups")
10681 (or gnus-have-read-active-file (gnus-read-active-file))
10682 (setq gnus-newsrc-last-checked-date (current-time-string))
10683 (let ((groups gnus-default-subscribed-newsgroups)
10687 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
10690 (setq group (symbol-name sym))
10691 (let ((do-sub (gnus-matches-options-n group)))
10692 (cond ((eq do-sub 'subscribe)
10693 (gnus-sethash group group gnus-killed-hashtb)
10695 gnus-subscribe-options-newsgroup-method group))
10696 ((eq do-sub 'ignore)
10699 (setq gnus-killed-list (cons group gnus-killed-list))))))
10700 gnus-active-hashtb)
10702 (if (gnus-gethash (car groups) gnus-active-hashtb)
10703 (gnus-group-change-level
10704 (car groups) gnus-level-default-subscribed gnus-level-killed))
10705 (setq groups (cdr groups)))
10706 (gnus-group-make-help-group)
10707 (and gnus-novice-user
10708 (message (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups")))))))
10710 ;; `gnus-group-change-level' is the fundamental function for changing
10711 ;; subscription levels of newsgroups. This might mean just changing
10712 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
10713 ;; again, which subscribes/unsubscribes a group, which is equally
10714 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
10715 ;; from 8-9 to 1-7 means that you remove the group from the list of
10716 ;; killed (or zombie) groups and add them to the (kinda) subscribed
10717 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
10718 ;; which is trivial.
10719 ;; ENTRY can either be a string (newsgroup name) or a list (if
10720 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
10721 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
10723 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
10724 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
10726 (defun gnus-group-change-level (entry level &optional oldlevel
10727 previous fromkilled)
10728 (let ((pinfo entry)
10729 group info active num)
10730 ;; Glean what info we can from the arguments
10732 (if fromkilled (setq group (nth 1 entry))
10733 (setq group (car (nth 2 entry))))
10734 (setq group entry))
10735 (if (and (stringp entry)
10737 (< oldlevel gnus-level-zombie))
10738 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
10739 (if (and (not oldlevel)
10741 (setq oldlevel (car (cdr (nth 2 entry)))))
10742 (if (stringp previous)
10743 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
10745 (gnus-dribble-enter
10746 (format "(gnus-group-change-level %S %S %S %S %S)"
10747 group level oldlevel (car (nth 2 previous)) fromkilled))
10749 ;; Then we remove the newgroup from any old structures, if needed.
10750 ;; If the group was killed, we remove it from the killed or zombie
10751 ;; list. If not, and it is in fact going to be killed, we remove
10752 ;; it from the newsrc hash table and assoc.
10753 (cond ((>= oldlevel gnus-level-zombie)
10754 (if (= oldlevel gnus-level-zombie)
10755 (setq gnus-zombie-list (delete group gnus-zombie-list))
10756 (setq gnus-killed-list (delete group gnus-killed-list))))
10758 (if (>= level gnus-level-zombie)
10760 (gnus-sethash (car (nth 2 entry))
10761 nil gnus-newsrc-hashtb)
10763 (setcdr (gnus-gethash (car (nth 3 entry))
10764 gnus-newsrc-hashtb)
10766 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
10768 ;; Finally we enter (if needed) the list where it is supposed to
10769 ;; go, and change the subscription level. If it is to be killed,
10770 ;; we enter it into the killed or zombie list.
10771 (cond ((>= level gnus-level-zombie)
10772 (and (string= group (gnus-group-real-name group))
10773 (if (= level gnus-level-zombie)
10774 (setq gnus-zombie-list (cons group gnus-zombie-list))
10775 (setq gnus-killed-list (cons group gnus-killed-list)))))
10777 ;; If the list is to be entered into the newsrc assoc, and
10778 ;; it was killed, we have to create an entry in the newsrc
10779 ;; hashtb format and fix the pointers in the newsrc assoc.
10780 (if (>= oldlevel gnus-level-zombie)
10784 (setq info (cdr entry))
10785 (setq num (car entry)))
10786 (setq active (gnus-gethash group gnus-active-hashtb))
10787 (setq num (if active (- (1+ (cdr active)) (car active)) t))
10788 ;; Check whether the group is foreign. If so, the
10789 ;; foreign select method has to be entered into the
10791 (let ((method (gnus-group-method-name group)))
10792 (if (eq method gnus-select-method)
10793 (setq info (list group level nil))
10794 (setq info (list group level nil nil method)))))
10795 (setq entry (cons info (if previous (cdr (cdr previous))
10796 (cdr gnus-newsrc-alist))))
10797 (setcdr (if previous (cdr previous) gnus-newsrc-alist)
10799 (gnus-sethash group (cons num (if previous (cdr previous)
10800 gnus-newsrc-alist))
10801 gnus-newsrc-hashtb)
10803 (setcdr (gnus-gethash (car (car (cdr entry)))
10804 gnus-newsrc-hashtb)
10806 ;; It was alive, and it is going to stay alive, so we
10807 ;; just change the level and don't change any pointers or
10808 ;; hash table entries.
10809 (setcar (cdr (car (cdr (cdr entry)))) level))))))
10811 (defun gnus-kill-newsgroup (newsgroup)
10812 "Obsolete function. Kills a newsgroup."
10813 (gnus-group-change-level
10814 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
10816 (defun gnus-check-bogus-newsgroups (&optional confirm)
10817 "Remove bogus newsgroups.
10818 If CONFIRM is non-nil, the user has to confirm the deletion of every
10820 (let ((newsrc (cdr gnus-newsrc-alist))
10822 (message "Checking bogus newsgroups...")
10823 (or gnus-have-read-active-file (gnus-read-active-file))
10824 ;; Find all bogus newsgroup that are subscribed.
10826 (setq group (car (car newsrc)))
10827 (if (or (gnus-gethash group gnus-active-hashtb)
10828 (nth 4 (car newsrc))
10830 (not (gnus-y-or-n-p
10831 (format "Remove bogus newsgroup: %s " group)))))
10832 ;; Active newsgroup.
10834 ;; Found a bogus newsgroup.
10835 (setq bogus (cons group bogus)))
10836 (setq newsrc (cdr newsrc)))
10837 ;; Remove all bogus subscribed groups by first killing them, and
10838 ;; then removing them from the list of killed groups.
10840 (gnus-group-change-level
10841 (gnus-gethash (car bogus) gnus-newsrc-hashtb) gnus-level-killed)
10842 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
10843 (setq bogus (cdr bogus)))
10844 ;; Then we remove all bogus groups from the list of killed and
10845 ;; zombie groups. They are are removed without confirmation.
10846 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
10849 (setq killed (symbol-value (car dead-lists)))
10851 (setq group (car killed))
10852 (or (gnus-gethash group gnus-active-hashtb)
10853 ;; The group is bogus.
10854 (set (car dead-lists)
10855 (delete group (symbol-value (car dead-lists)))))
10856 (setq killed (cdr killed)))
10857 (setq dead-lists (cdr dead-lists))))
10858 (message "Checking bogus newsgroups... done")))
10860 (defun gnus-check-duplicate-killed-groups ()
10861 "Remove duplicates from the list of killed groups."
10863 (let ((killed gnus-killed-list))
10865 (message "%d" (length killed))
10866 (setcdr killed (delete (car killed) (cdr killed)))
10867 (setq killed (cdr killed)))))
10869 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
10870 ;; and compute how many unread articles there are in each group.
10871 (defun gnus-get-unread-articles (&optional level)
10872 (let ((newsrc (cdr gnus-newsrc-alist))
10873 (level (or level (1+ gnus-level-subscribed)))
10874 info group active virtuals)
10875 (message "Checking new news...")
10877 (setq info (car newsrc))
10878 (setq group (car info))
10879 (setq active (gnus-gethash group gnus-active-hashtb))
10881 ;; Check newsgroups. If the user doesn't want to check them, or
10882 ;; they can't be checked (for instance, if the news server can't
10883 ;; be reached) we just set the number of unread articles in this
10884 ;; newsgroup to t. This means that Gnus thinks that there are
10885 ;; unread articles, but it has no idea how many.
10887 (if (or (and gnus-activate-foreign-newsgroups
10888 (not (numberp gnus-activate-foreign-newsgroups)))
10889 (and (numberp gnus-activate-foreign-newsgroups)
10890 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
10891 (<= (nth 1 info) level)))
10892 (if (eq (car (nth 4 info)) 'nnvirtual)
10893 (setq virtuals (cons info virtuals))
10894 (setq active (gnus-activate-newsgroup (car info)))))
10895 (if (and (not gnus-read-active-file)
10896 (<= (nth 1 info) level))
10898 (setq active (gnus-activate-newsgroup (car info))))))
10900 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
10901 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
10903 (gnus-get-unread-articles-in-group info active)
10904 ;; Close the groups as we look at them!
10905 (gnus-close-group group))
10906 (setq newsrc (cdr newsrc)))
10908 ;; Activate the virtual groups. This has to be done after all the
10910 ;; !!! If one virtual group contains another virtual group, even
10911 ;; doing it this way might cause problems.
10913 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
10914 (gnus-get-unread-articles-in-group (car virtuals) active))
10915 (setq virtuals (cdr virtuals)))
10917 (message "Checking new news... done")))
10919 ;; Create a hash table out of the newsrc alist. The `car's of the
10920 ;; alist elements are used as keys.
10921 (defun gnus-make-hashtable-from-newsrc-alist ()
10922 (let ((alist gnus-newsrc-alist)
10924 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
10926 (setq prev (setq gnus-newsrc-alist
10927 (cons (list "dummy.group" 0 nil) alist))))
10929 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
10931 (setq alist (cdr alist)))))
10933 (defun gnus-make-hashtable-from-killed ()
10934 "Create a hash table from the killed and zombie lists."
10935 (let ((lists '(gnus-killed-list gnus-zombie-list))
10937 (setq gnus-killed-hashtb
10938 (gnus-make-hashtable
10939 (+ (length gnus-killed-list) (length gnus-zombie-list))))
10941 (setq list (symbol-value (car lists)))
10942 (setq lists (cdr lists))
10944 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
10945 (setq list (cdr list))))))
10947 (defun gnus-get-unread-articles-in-group (info active)
10948 (let* ((range (nth 2 info))
10950 (marked (nth 3 info))
10951 srange lowest group highest)
10952 ;; Modify the list of read articles according to what articles
10953 ;; are available; then tally the unread articles and add the
10954 ;; number to the group hash table entry.
10955 (cond ((zerop (cdr active))
10958 (setq num (- (1+ (cdr active)) (car active))))
10959 ((not (listp (cdr range)))
10960 ;; Fix a single (num . num) range according to the
10961 ;; active hash table.
10962 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
10963 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
10964 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
10965 ;; Compute number of unread articles.
10966 (setq num (max 0 (- (cdr active)
10967 (- (1+ (cdr range)) (car range))))))
10969 ;; The read list is a list of ranges. Fix them according to
10970 ;; the active hash table.
10971 ;; First peel off any elements that are below the lower
10973 (while (and (cdr range)
10975 (or (and (atom (car (cdr range))) (car (cdr range)))
10976 (car (car (cdr range))))))
10977 (if (numberp (car range))
10980 (or (and (numberp (car (cdr range)))
10982 (cdr (car (cdr range))))))
10983 (setcdr (car range)
10984 (or (and (numberp (nth 1 range)) (nth 1 range))
10985 (cdr (car (cdr range))))))
10986 (setcdr range (cdr (cdr range))))
10987 ;; Adjust the first element to be the same as the lower limit.
10988 (if (and (not (atom (car range)))
10989 (< (cdr (car range)) (car active)))
10990 (setcdr (car range) (1- (car active))))
10991 ;; Then we want to peel off any elements that are higher
10992 ;; than the upper active limit.
10993 (let ((srange range))
10994 ;; Go past all legal elements.
10995 (while (and (cdr srange)
10996 (<= (or (and (atom (car (cdr srange)))
10997 (car (cdr srange)))
10998 (car (car (cdr srange)))) (cdr active)))
10999 (setq srange (cdr srange)))
11001 ;; Nuke all remaining illegal elements.
11002 (setcdr srange nil))
11004 ;; Adjust the final element.
11005 (if (and (not (atom (car srange)))
11006 (> (cdr (car srange)) (cdr active)))
11007 (setcdr (car srange) (cdr active))))
11008 ;; Compute the number of unread articles.
11010 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
11011 (cdr (car range))))
11012 (or (and (atom (car range)) (car range))
11013 (car (car range))))))
11014 (setq range (cdr range)))
11015 (setq num (max 0 (- (cdr active) num)))))
11018 (and (assq 'tick marked)
11019 (inline (gnus-remove-illegal-marked-articles
11020 (assq 'tick marked) (nth 2 info))))
11021 (and (assq 'dormant marked)
11022 (inline (gnus-remove-illegal-marked-articles
11023 (assq 'dormant marked) (nth 2 info))))
11025 (gnus-gethash (car info) gnus-newsrc-hashtb)
11026 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
11027 (length (cdr (assq 'dormant marked)))))))))
11030 (defun gnus-remove-illegal-marked-articles (marked ranges)
11031 (let ((m (cdr marked)))
11032 ;; Make sure that all ticked articles are a subset of the unread
11035 (if (gnus-member-of-range (car m) ranges)
11036 (setcdr marked (cdr m))
11038 (setq m (cdr m)))))
11040 (defun gnus-activate-newsgroup (group)
11041 (let ((method (gnus-find-method-for-group group))
11043 (and (or (gnus-server-opened method) (gnus-open-server method))
11044 (gnus-request-group group)
11046 (set-buffer nntp-server-buffer)
11048 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
11050 (goto-char (match-beginning 1))
11052 group (setq active (cons (read (current-buffer))
11053 (read (current-buffer))))
11054 gnus-active-hashtb))
11057 (defun gnus-update-read-articles
11058 (group unread unselected ticked &optional domarks replied expirable killed
11059 dormant bookmark score)
11060 "Update the list of read and ticked articles in GROUP using the
11061 UNREAD and TICKED lists.
11062 Note: UNSELECTED has to be sorted over `<'.
11063 Returns whether the updating was successful."
11064 (let* ((active (or gnus-newsgroup-active
11065 (gnus-gethash group gnus-active-hashtb)))
11066 (entry (gnus-gethash group gnus-newsrc-hashtb))
11067 (number (car entry))
11068 (info (nth 2 entry))
11069 (marked (nth 3 info))
11071 (unread (sort (copy-sequence unread) (function <)))
11073 (if (or (not info) (not active))
11074 ;; There is no info on this group if it was, in fact,
11075 ;; killed. Gnus stores no information on killed groups, so
11076 ;; there's nothing to be done.
11077 ;; One could store the information somewhere temporarily,
11078 ;; perhaps... Hmmm...
11080 ;; Remove any negative articles numbers.
11081 (while (and unread (< (car unread) 0))
11082 (setq unread (cdr unread)))
11083 (setq unread (sort (append unselected unread) '<))
11084 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11085 (setcar entry (max 0 (- (length unread) (length ticked)
11086 (length dormant))))
11087 ;; Compute the ranges of read articles by looking at the list of
11088 ;; unread articles.
11090 (if (/= (car unread) prev)
11091 (setq read (cons (if (= prev (1- (car unread))) prev
11092 (cons prev (1- (car unread)))) read)))
11093 (setq prev (1+ (car unread)))
11094 (setq unread (cdr unread)))
11095 (if (<= prev (cdr active))
11096 (setq read (cons (cons prev (cdr active)) read)))
11097 ;; Enter this list into the group info.
11098 (setcar (cdr (cdr info))
11099 (if (> (length read) 1) (nreverse read) read))
11100 ;; Enter the list of ticked articles.
11101 (gnus-set-marked-articles
11103 (if domarks replied (cdr (assq 'reply marked)))
11104 (if domarks expirable (cdr (assq 'expire marked)))
11105 (if domarks killed (cdr (assq 'killed marked)))
11106 (if domarks dormant (cdr (assq 'dormant marked)))
11107 (if domarks bookmark (cdr (assq 'bookmark marked)))
11108 (if domarks score (cdr (assq 'score marked))))
11111 (defun gnus-make-articles-unread (group articles)
11112 "Mark ARTICLES in GROUP as unread."
11113 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
11114 (gnus-gethash (gnus-group-real-name group)
11115 gnus-newsrc-hashtb)))))
11116 (setcar (nthcdr 2 info)
11117 (gnus-remove-from-range (nth 2 info) articles))
11118 (gnus-group-update-group group t)))
11120 (defun gnus-read-active-file ()
11121 "Get active file from NNTP server."
11122 (gnus-group-set-mode-line)
11123 (let ((methods (cons gnus-select-method gnus-secondary-select-methods))
11125 (setq gnus-have-read-active-file nil)
11127 (set-buffer nntp-server-buffer)
11129 (let* ((where (nth 1 (car methods)))
11130 (mesg (format "Reading active file%s via %s..."
11131 (if (and where (not (zerop (length where))))
11132 (concat " from " where) "")
11133 (car (car methods)))))
11135 (gnus-check-news-server (car methods))
11137 ((and (eq gnus-read-active-file 'some)
11138 (gnus-check-backend-function
11139 'retrieve-groups (car (car methods))))
11140 (let ((newsrc (cdr gnus-newsrc-alist))
11143 (and (gnus-server-equal
11144 (gnus-find-method-for-group
11145 (car (car newsrc)) (car newsrc))
11146 (gnus-server-get-method nil (car methods)))
11147 (setq groups (cons (car (car newsrc)) groups)))
11148 (setq newsrc (cdr newsrc)))
11149 (setq list-type (gnus-retrieve-groups groups (car methods)))
11150 (cond ((not list-type)
11151 (message "Cannot read partial active file from %s server."
11152 (car (car methods)))
11155 ((eq list-type 'active)
11156 (gnus-active-to-gnus-format
11157 (and gnus-have-read-active-file (car methods)))
11158 (setq gnus-have-read-active-file t))
11160 (gnus-groups-to-gnus-format
11161 (and gnus-have-read-active-file (car methods)))
11162 (setq gnus-have-read-active-file t)))))
11164 (if (not (gnus-request-list (car methods)))
11166 (message "Cannot read active file from %s server."
11167 (car (car methods)))
11169 (gnus-active-to-gnus-format
11170 (and gnus-have-read-active-file (car methods)))
11171 (setq gnus-have-read-active-file t)
11172 (message "%s...done" mesg)))))
11173 (setq methods (cdr methods))))))
11175 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
11176 ;; Further rewrites by lmi.
11177 (defun gnus-active-to-gnus-format (method &optional hashtb)
11178 "Convert active file format to internal format.
11179 Lines matching `gnus-ignored-newsgroups' are ignored."
11180 (let ((cur (current-buffer))
11184 (setq gnus-active-hashtb
11185 (gnus-make-hashtable
11186 (count-lines (point-min) (point-max))))))))
11187 ;; Delete unnecessary lines.
11188 (goto-char (point-min))
11189 (delete-matching-lines gnus-ignored-newsgroups)
11190 (and method (not (eq method gnus-select-method))
11191 (let ((prefix (gnus-group-prefixed-name "" method)))
11192 (goto-char (point-min))
11193 (while (and (not (eobp))
11194 (null (insert prefix))
11195 (zerop (forward-line 1))))))
11196 (goto-char (point-min))
11197 ;; Store active file in hashtable.
11199 (if (or (re-search-forward "\n.\r?$" nil t)
11200 (goto-char (point-max)))
11202 (beginning-of-line)
11203 (narrow-to-region (point-min) (point))))
11204 (goto-char (point-min))
11205 (if (string-match "%[oO]" gnus-group-line-format)
11206 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
11207 ;; If we want information on moderated groups, we use this
11210 (let ((mod-hashtb (make-vector 7 0))
11212 (while (not (eobp))
11213 (setq group (let ((obarray hashtb))
11215 (setq max (read cur))
11216 (set group (cons (read cur) max))
11217 ;; Enter moderated groups into a list.
11219 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
11221 (setq gnus-moderated-list
11222 (cons (symbol-name group) gnus-moderated-list)))
11225 (progn (ding) (message "Possible error in active file."))))
11226 ;; And if we do not care about moderation, we use this loop,
11227 ;; which is faster.
11230 (while (not (eobp))
11231 ;; group gets set to a symbol interned in the hash table
11233 (setq group (let ((obarray hashtb)) (read cur)))
11234 (setq max (read cur))
11235 (set group (cons (read cur) max))
11238 (progn (ding) (message "Possible error in active file."))))))))
11240 (defun gnus-groups-to-gnus-format (method &optional hashtb)
11241 ;; Parse a "groups" active file.
11242 (let ((cur (current-buffer))
11246 (setq gnus-active-hashtb
11247 (gnus-make-hashtable
11248 (count-lines (point-min) (point-max)))))))
11249 (prefix (and method (not (eq method gnus-select-method))
11250 (gnus-group-prefixed-name "" method))))
11252 (goto-char (point-min))
11254 ;; We split this into to separate loops, one with the prefix
11255 ;; and one without to speed the reading up somewhat.
11257 (let (min max opoint)
11258 (while (not (eobp))
11259 (read cur) (read cur)
11260 (setq min (read cur)
11263 (skip-chars-forward " \t")
11266 (set (let ((obarray hashtb)) (read cur))
11269 (let (min max opoint)
11270 (while (not (eobp))
11271 (if (= (following-char) ?2)
11273 (read cur) (read cur)
11274 (setq min (read cur)
11276 (set (let ((obarray hashtb)) (read cur))
11278 (forward-line 1))))
11280 (progn (ding) (message "Possible error in active file."))))))
11282 (defun gnus-read-newsrc-file (&optional force)
11283 "Read startup file.
11284 If FORCE is non-nil, the .newsrc file is read."
11285 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
11286 ;; Reset variables that might be defined in the .newsrc.eld file.
11287 (let ((variables gnus-variable-list))
11289 (set (car variables) nil)
11290 (setq variables (cdr variables))))
11291 (let* ((newsrc-file gnus-current-startup-file)
11292 (quick-file (concat newsrc-file ".el")))
11294 ;; We always load the .newsrc.eld file. If always contains
11295 ;; much information that can not be gotten from the .newsrc
11296 ;; file (ticked articles, killed groups, foreign methods, etc.)
11297 (gnus-read-newsrc-el-file quick-file)
11300 (and (file-newer-than-file-p newsrc-file quick-file)
11301 (file-newer-than-file-p newsrc-file
11302 (concat quick-file "d")))
11303 (not gnus-newsrc-alist))
11304 ;; We read the .newsrc file. Note that if there if a
11305 ;; .newsrc.eld file exists, it has already been read, and
11306 ;; the `gnus-newsrc-hashtb' has been created. While reading
11307 ;; the .newsrc file, Gnus will only use the information it
11308 ;; can find there for changing the data already read -
11309 ;; ie. reading the .newsrc file will not trash the data
11310 ;; already read (except for read articles).
11312 (message "Reading %s..." newsrc-file)
11313 (set-buffer (find-file-noselect newsrc-file))
11314 (buffer-disable-undo (current-buffer))
11315 (gnus-newsrc-to-gnus-format)
11316 (kill-buffer (current-buffer))
11317 (message "Reading %s... done" newsrc-file))))))
11319 (defun gnus-read-newsrc-el-file (file)
11320 (let ((ding-file (concat file "d")))
11321 ;; We always, always read the .eld file.
11322 (message "Reading %s..." ding-file)
11323 (let (gnus-newsrc-assoc)
11324 (condition-case nil
11325 (load ding-file t t t)
11327 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
11328 (gnus-uncompress-newsrc-assoc)
11329 (gnus-make-hashtable-from-newsrc-alist)
11330 (if (not (file-newer-than-file-p file ding-file))
11332 ;; Old format quick file
11333 (message "Reading %s..." file)
11334 ;; The .el file is newer than the .eld file, so we read that one
11336 (gnus-read-old-newsrc-el-file file))))
11338 ;; Parse the old-style quick startup file
11339 (defun gnus-read-old-newsrc-el-file (file)
11340 (let (newsrc killed marked group g m len info)
11342 (let ((gnus-killed-assoc nil)
11343 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
11345 (condition-case nil
11348 (setq newsrc gnus-newsrc-alist
11349 killed gnus-killed-assoc
11350 marked gnus-marked-assoc)))
11351 (setq gnus-newsrc-alist nil)
11353 (setq group (car newsrc))
11354 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
11357 (setcar (nthcdr 2 info) (cdr (cdr group)))
11359 (if (nth 1 group) gnus-level-default-subscribed
11360 gnus-level-default-unsubscribed))
11361 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
11362 (setq gnus-newsrc-alist
11366 (if (nth 1 group) gnus-level-default-subscribed
11367 gnus-level-default-unsubscribed)
11368 (cdr (cdr group))))
11369 gnus-newsrc-alist)))
11370 (if (setq m (assoc (car group) marked))
11371 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
11372 (setq newsrc (cdr newsrc)))
11373 (setq newsrc killed)
11375 (setcar newsrc (car (car newsrc)))
11376 (setq newsrc (cdr newsrc)))
11377 (setq gnus-killed-list killed))
11378 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
11379 (gnus-make-hashtable-from-newsrc-alist)))
11381 (defun gnus-make-newsrc-file (file)
11382 "Make server dependent file name by catenating FILE and server host name."
11383 (let* ((file (expand-file-name file nil))
11384 (real-file (concat file "-" (nth 1 gnus-select-method))))
11385 (if (file-exists-p real-file)
11388 (defun gnus-uncompress-newsrc-assoc ()
11389 ;; Uncompress all lists of marked articles in the newsrc assoc.
11390 (let ((newsrc gnus-newsrc-alist)
11393 (if (not (setq marked (nth 3 (car newsrc))))
11396 (or (eq 'score (car (car marked)))
11397 (eq 'bookmark (car (car marked)))
11398 (eq 'killed (car (car marked)))
11399 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
11400 (setq marked (cdr marked))))
11401 (setq newsrc (cdr newsrc)))))
11403 (defun gnus-compress-newsrc-assoc ()
11404 ;; Compress all lists of marked articles in the newsrc assoc.
11405 (let ((newsrc gnus-newsrc-alist)
11408 (if (not (setq marked (nth 3 (car newsrc))))
11411 (or (eq 'score (car (car marked)))
11412 (eq 'bookmark (car (car marked)))
11413 (eq 'killed (car (car marked)))
11414 (setcdr (car marked)
11415 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
11416 (setq marked (cdr marked))))
11417 (setq newsrc (cdr newsrc)))))
11419 ;; jwz: rewrote this function to be much more efficient, and not be
11420 ;; subject to regexp overflow errors when it encounters very long
11421 ;; lines -- the old behavior was to blow off the rest of the *file*
11422 ;; when a line was encountered that was too long to match!! Now it
11423 ;; uses only simple looking-at calls, and doesn't create as many
11424 ;; temporary strings. It also now handles multiple consecutive
11425 ;; options lines (before it only handled the first.)
11426 ;; Tiny rewrite by lmi.
11427 (defun gnus-newsrc-to-gnus-format ()
11428 "Parse current buffer as .newsrc file."
11429 ;; We have to re-initialize these variables (except for
11430 ;; gnus-killed-list) because the quick startup file may contain bogus
11432 (setq gnus-newsrc-options nil)
11433 (setq gnus-newsrc-options-n nil)
11434 (gnus-parse-options-lines)
11435 (gnus-parse-newsrc-body))
11437 (defun gnus-parse-options-lines ()
11438 ;; newsrc.5 seems to indicate that the options line can come anywhere
11439 ;; in the file, and that there can be any number of them:
11441 ;; An options line starts with the word options (left-
11442 ;; justified). Then there are the list of options just as
11443 ;; they would be on the readnews command line. For instance:
11445 ;; options -n all !net.sf-lovers !mod.human-nets -r
11448 ;; A string of lines beginning with a space or tab after the
11449 ;; initial options line will be considered continuation
11452 ;; For now, we only accept it at the beginning of the file.
11454 (goto-char (point-min))
11455 (skip-chars-forward " \t\n")
11456 (setq gnus-newsrc-options nil)
11457 (while (looking-at "^options[ \t]*\\(.*\\)\n")
11458 ;; handle consecutive options lines
11459 (setq gnus-newsrc-options (concat gnus-newsrc-options
11460 (if gnus-newsrc-options "\n\t")
11461 (buffer-substring (match-beginning 1)
11464 (while (looking-at "[ \t]+\\(.*\\)\n")
11465 ;; handle subsequent continuation lines of this options line
11466 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
11467 (buffer-substring (match-beginning 1)
11470 ;; Gather all "-n" options lines.
11473 (if gnus-newsrc-options
11474 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
11475 gnus-newsrc-options
11477 (setq start (match-end 0)))
11478 (setq result (concat result
11480 (substring gnus-newsrc-options
11481 (match-beginning 1)
11484 (and result (gnus-parse-n-options result))
11487 (defun gnus-parse-newsrc-body ()
11488 ;; Point has been positioned after the options lines. We shouldn't
11489 ;; see any more in here.
11491 (let ((subscribe nil)
11493 (line (1+ (count-lines (point-min) (point))))
11497 (skip-chars-forward " \t")
11498 (while (not (eobp))
11500 ((= (following-char) ?\n)
11501 ;; skip blank lines
11505 (skip-chars-forward "^:!\n")
11506 (if (= (following-char) ?\n)
11507 (error "line %d is unparsable in %s" line (buffer-name)))
11509 (skip-chars-backward " \t")
11511 ;; #### note: we could avoid consing a string here by binding obarray
11512 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
11513 ;; then setq'ing newsgroup to symbol-name of that, like we do in
11514 ;; gnus-active-to-gnus-format.
11515 (setq newsgroup (buffer-substring p (point)))
11518 (setq subscribe (= (following-char) ?:))
11519 (setq read-list nil)
11521 (forward-char 1) ; after : or !
11522 (skip-chars-forward " \t")
11523 (while (not (= (following-char) ?\n))
11524 (skip-chars-forward " \t")
11527 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
11532 ;; faster that buffer-substring/string-to-int
11533 (narrow-to-region (point-min) (match-end 1))
11534 (read (current-buffer)))
11536 (narrow-to-region (point-min) (match-end 2))
11537 (forward-char) ; skip over "-"
11539 (read (current-buffer))
11543 ((looking-at "[0-9]+")
11544 ;; faster that buffer-substring/string-to-int
11545 (narrow-to-region (point-min) (match-end 0))
11546 (setq p (read (current-buffer)))
11548 (setq read-list (cons (cons p p) read-list))
11551 ;; bogus chars in ranges
11554 (goto-char (match-end 0))
11555 (skip-chars-forward " \t")
11556 (cond ((= (following-char) ?,)
11559 ((= (following-char) ?\n)
11562 ;; bogus char after range
11564 ;; if we get here, the parse failed
11566 (end-of-line) ; give up on this line
11568 (message "Ignoring bogus line %d for %s in %s"
11569 line newsgroup (buffer-name))
11571 ;; We have already read .newsrc.eld, so we gently update the
11572 ;; data in the hash table with the information we have just
11574 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb)))
11578 (setcar (nthcdr 2 info) (nreverse read-list))
11579 ;; We update the level very gently. In fact, we
11580 ;; only change it if there's been a status change
11581 ;; from subscribed to unsubscribed, or vice versa.
11582 (setq level (nth 1 info))
11583 (cond ((and (<= level gnus-level-subscribed) (not subscribe))
11584 (setq level (if read-list
11585 gnus-level-default-unsubscribed
11586 (1+ gnus-level-default-unsubscribed))))
11587 ((and (> level gnus-level-subscribed) subscribe)
11588 (setq level gnus-level-default-subscribed)))
11589 (setcar (cdr info) level))
11590 (setq gnus-newsrc-alist
11591 (cons (list newsgroup
11593 gnus-level-default-subscribed
11594 (if read-list gnus-level-default-subscribed
11595 (1+ gnus-level-default-subscribed)))
11596 (nreverse read-list))
11597 gnus-newsrc-alist))))))
11598 (setq line (1+ line))
11599 (forward-line 1))))
11600 (setq gnus-newsrc-alist (cdr gnus-newsrc-alist))
11601 (gnus-make-hashtable-from-newsrc-alist)
11604 (defun gnus-parse-n-options (options)
11605 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
11606 (let (yes no yes-or-no out newsgroup)
11607 ;; Parse each newsgroup description such as "comp.all". Commas
11608 ;; and white spaces can be a newsgroup separator.
11610 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
11612 (substring options (match-beginning 1) (match-end 1)))
11616 (match-beginning 2) (match-end 2))))
11617 (setq options (substring options (match-end 2)))
11618 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
11620 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
11622 (concat (substring newsgroup 0 (match-end 1))
11624 (substring newsgroup (match-beginning 2)))))
11625 ;; It is yes or no.
11626 (setq out (cons (cons (if (string= yes-or-no "!") 'ignore 'subscribe)
11627 (concat "^" newsgroup "$"))
11629 (setq gnus-newsrc-options-n out)))
11631 (defun gnus-save-newsrc-file ()
11632 "Save .newsrc file."
11633 ;; Note: We cannot save .newsrc file if all newsgroups are removed
11634 ;; from the variable gnus-newsrc-alist.
11635 (and (or gnus-newsrc-alist gnus-killed-list)
11636 gnus-current-startup-file
11637 (let ((make-backup-files t)
11638 (version-control nil)
11639 (require-final-newline t)) ;Don't ask even if requested.
11640 ;; You can stop or change version control of backup file.
11641 ;; Suggested by jason@violet.berkeley.edu.
11642 (run-hooks 'gnus-save-newsrc-hook)
11644 (if (or (not gnus-dribble-buffer)
11645 (not (buffer-name gnus-dribble-buffer))
11646 (zerop (save-excursion
11647 (set-buffer gnus-dribble-buffer)
11649 (message "(No changes need to be saved)")
11650 (if gnus-save-newsrc-file
11652 (message "Saving %s..." gnus-current-startup-file)
11653 ;; Make backup file of master newsrc.
11654 (gnus-gnus-to-newsrc-format)
11655 (message "Saving %s... done" gnus-current-startup-file)))
11656 ;; Quickly loadable .newsrc.
11657 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
11658 (gnus-add-current-to-buffer-list)
11659 (buffer-disable-undo (current-buffer))
11661 (message "Saving %s.eld..." gnus-current-startup-file)
11662 (gnus-gnus-to-quick-newsrc-format)
11663 (write-region 1 (point-max)
11664 (concat gnus-current-startup-file ".eld")
11666 (kill-buffer (current-buffer))
11667 (message "Saving %s.eld... done" gnus-current-startup-file)
11668 (gnus-dribble-delete-file))))))
11670 (defun gnus-gnus-to-quick-newsrc-format ()
11671 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
11672 (insert ";; (ding) Gnus startup file.\n")
11673 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
11674 (insert ";; to read .newsrc.\n")
11675 (let ((variables gnus-variable-list)
11676 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
11678 ;; insert lisp expressions.
11679 (gnus-compress-newsrc-assoc)
11681 (setq variable (car variables))
11682 (and (boundp variable)
11683 (symbol-value variable)
11684 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
11685 (insert "(setq " (symbol-name variable) " '"
11686 (prin1-to-string (symbol-value variable))
11688 (setq variables (cdr variables)))
11689 (gnus-uncompress-newsrc-assoc)))
11692 (defun gnus-gnus-to-newsrc-format ()
11693 ;; Generate and save the .newsrc file.
11694 (let ((newsrc (cdr gnus-newsrc-alist))
11697 (set-buffer (create-file-buffer gnus-startup-file))
11698 (buffer-disable-undo (current-buffer))
11701 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
11702 ;; Write subscribed and unsubscribed.
11704 (setq info (car newsrc))
11705 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
11707 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
11709 (if (setq ranges (nth 2 info))
11712 (if (not (listp (cdr ranges)))
11713 (if (= (car ranges) (cdr ranges))
11714 (insert (int-to-string (car ranges)))
11715 (insert (int-to-string (car ranges)) "-"
11716 (int-to-string (cdr ranges))))
11718 (setq range (car ranges)
11719 ranges (cdr ranges))
11720 (if (or (atom range) (= (car range) (cdr range)))
11721 (insert (int-to-string
11722 (or (and (atom range) range)
11724 (insert (int-to-string (car range)) "-"
11725 (int-to-string (cdr range))))
11726 (if ranges (insert ","))))))
11728 (setq newsrc (cdr newsrc)))
11729 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
11730 (kill-buffer (current-buffer)))))
11732 (defun gnus-read-descriptions-file ()
11733 (message "Reading descriptions file...")
11734 (if (not (gnus-request-list-newsgroups gnus-select-method))
11736 (message "Couldn't read newsgroups descriptions")
11739 (setq gnus-description-hashtb
11740 (gnus-make-hashtable (length gnus-active-hashtb)))
11743 (set-buffer nntp-server-buffer)
11744 (goto-char (point-min))
11745 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
11746 (goto-char (point-min))
11747 (if (or (search-forward "\n.\n" nil t)
11748 (goto-char (point-max)))
11750 (beginning-of-line)
11751 (narrow-to-region (point-min) (point))))
11752 (goto-char (point-min))
11753 (while (not (eobp))
11754 (setq group (let ((obarray gnus-description-hashtb))
11755 (read (current-buffer))))
11756 (skip-chars-forward " \t")
11757 (set group (buffer-substring
11758 (point) (gnus-point-at-eol)))
11759 (forward-line 1))))
11760 (message "Reading descriptions file...done")
11763 (defun gnus-group-get-description (group)
11764 ;; Get the description of a group by sending XGTITLE to the server.
11765 (and (gnus-request-group-description group)
11767 (set-buffer nntp-server-buffer)
11768 (goto-char (point-min))
11769 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
11770 (buffer-substring (match-beginning 1) (match-end 1))))))
11776 (defvar gnus-server-mode-hook nil
11777 "Hook run in `gnus-server-mode' buffers.")
11779 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
11780 "Format of server lines.
11781 It works along the same lines as a normal formatting string,
11782 with some simple extensions.")
11784 (defvar gnus-server-mode-line-format "(ding) List of servers"
11785 "The format specification for the server mode line.")
11787 (defconst gnus-server-line-format-alist
11788 (list (list ?h 'how ?s)
11790 (list ?w 'where ?s)
11793 (defconst gnus-server-mode-line-format-alist
11794 (list (list ?S 'news-server ?s)
11795 (list ?M 'news-method ?s)
11796 (list ?u 'user-defined ?s)))
11798 (defvar gnus-server-line-format-spec nil)
11799 (defvar gnus-server-mode-line-format-spec nil)
11800 (defvar gnus-server-killed-servers nil)
11802 (defvar gnus-server-mode-map nil)
11803 (put 'gnus-server-mode 'mode-class 'special)
11805 (if gnus-server-mode-map
11807 (setq gnus-server-mode-map (make-sparse-keymap))
11808 (suppress-keymap gnus-server-mode-map)
11809 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
11810 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
11811 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
11812 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
11813 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
11814 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
11815 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
11816 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
11818 (defun gnus-server-mode ()
11819 "Major mode for listing and editing servers.
11821 All normal editing commands are switched off.
11822 \\<gnus-server-mode-map>
11824 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
11826 The following commands are available:
11828 \\{gnus-server-mode-map}"
11830 ; (if gnus-visual (gnus-server-make-menu-bar))
11831 (kill-all-local-variables)
11832 (setq mode-line-modified "-- ")
11833 (make-local-variable 'mode-line-format)
11834 (setq mode-line-format (copy-sequence mode-line-format))
11835 (and (equal (nth 3 mode-line-format) " ")
11836 (setcar (nthcdr 3 mode-line-format) ""))
11837 (setq major-mode 'gnus-server-mode)
11838 (setq mode-name "Server")
11839 ; (gnus-group-set-mode-line)
11840 (setq mode-line-process nil)
11841 (use-local-map gnus-server-mode-map)
11842 (buffer-disable-undo (current-buffer))
11843 (setq truncate-lines t)
11844 (setq buffer-read-only t)
11845 (run-hooks 'gnus-server-mode-hook))
11847 (defun gnus-server-insert-server-line (sformat name method)
11848 (let* ((sformat (or sformat gnus-server-line-format-spec))
11850 (where (nth 1 method))
11852 (beginning-of-line)
11854 ;; Insert the text.
11855 (insert (eval sformat))
11856 (add-text-properties
11857 b (1+ b) (list 'gnus-server (intern name)))))
11859 (defun gnus-server-setup-buffer ()
11860 (if (get-buffer gnus-server-buffer)
11863 (set-buffer (get-buffer-create gnus-server-buffer))
11864 (gnus-server-mode))))
11866 (defun gnus-server-prepare ()
11867 (setq gnus-server-mode-line-format-spec
11868 (gnus-parse-format gnus-server-mode-line-format
11869 gnus-server-mode-line-format-alist))
11870 (setq gnus-server-line-format-spec
11871 (gnus-parse-format gnus-server-line-format
11872 gnus-server-line-format-alist))
11873 (let ((alist gnus-server-alist)
11874 (buffer-read-only nil))
11877 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
11878 (setq alist (cdr alist))))
11879 (goto-char (point-min))
11880 (gnus-server-position-cursor))
11882 (defun gnus-server-server-name ()
11883 (let ((server (get-text-property
11884 (save-excursion (beginning-of-line) (point)) 'gnus-server)))
11885 (and server (symbol-name server))))
11887 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
11889 (defvar gnus-winconf-edit-server nil)
11890 (defconst gnus-server-edit-buffer "*Gnus edit server*")
11892 (defun gnus-server-update-server (server)
11894 (set-buffer gnus-server-buffer)
11895 (let ((buffer-read-only nil)
11896 (info (cdr (assoc server gnus-server-alist))))
11897 (gnus-dribble-enter
11898 (concat "(gnus-server-set-info \"" server "\" '"
11899 (prin1-to-string info) ")"))
11900 ;; Buffer may be narrowed.
11903 (if (gnus-server-goto-server server)
11904 (delete-region (progn (beginning-of-line) (point))
11905 (progn (forward-line 1) (point))))
11906 (let ((entry (assoc server gnus-server-alist)))
11907 (gnus-server-insert-server-line nil (car entry) (cdr entry))
11908 (gnus-server-position-cursor))))))
11910 (defun gnus-server-set-info (info)
11911 ;; Enter a select method into the virtual server alist.
11912 (gnus-dribble-enter
11913 (concat "(gnus-server-set-info '"
11914 (prin1-to-string info) ")"))
11915 (let* ((server (nth 1 info))
11916 (entry (assoc server gnus-server-alist)))
11917 (if entry (setcdr entry info)
11918 (setq gnus-server-alist
11919 (nconc gnus-server-alist (list (cons server info)))))))
11921 (defun gnus-server-to-method (server)
11922 ;; Map virtual server names to select methods.
11923 (or (and (equal server "native") gnus-select-method)
11924 (cdr (assoc server gnus-server-alist))))
11926 (defun gnus-server-extend-method (group method)
11927 ;; This function "extends" a virtual server. If the server is
11928 ;; "hello", and the select method is ("hello" (my-var "something"))
11929 ;; in the group "alt.alt", this will result in a new virtual server
11930 ;; called "helly+alt.alt".
11932 (gnus-copy-sequence
11933 (if (equal (car method) "native") gnus-select-method
11934 (cdr (assoc (car method) gnus-server-alist))))))
11935 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
11936 (nconc entry (cdr method))))
11938 (defun gnus-server-get-method (group method)
11939 ;; Input either a server name, and extended server name, or a
11940 ;; select method, and return a select method.
11941 (cond ((stringp method)
11942 (gnus-server-to-method method))
11943 ((stringp (car method))
11944 (gnus-server-extend-method group method))
11946 (gnus-server-add-address method))))
11948 (defun gnus-server-add-address (method)
11949 (let ((method-name (symbol-name (car method))))
11950 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
11951 (not (assq (intern (concat method-name "-address")) method)))
11952 (append method (list (list (intern (concat method-name "-address"))
11956 (defun gnus-server-equal (s1 s2)
11958 (and (= (length s1) (length s2))
11960 (while (and s1 (member (car s1) s2))
11961 (setq s1 (cdr s1)))
11964 ;;; Interactive server functions.
11966 (defun gnus-server-kill-server (server)
11967 "Kill the server on the current line."
11968 (interactive (list (gnus-server-server-name)))
11969 (or (gnus-server-goto-server server)
11970 (if server (error "No such server: %s" server)
11971 (error "No server on the current line")))
11972 (let ((buffer-read-only nil))
11973 (delete-region (progn (beginning-of-line) (point))
11974 (progn (forward-line 1) (point))))
11975 (setq gnus-server-killed-servers
11976 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
11977 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
11978 gnus-server-alist))
11979 (gnus-server-position-cursor))
11981 (defun gnus-server-yank-server ()
11982 "Yank the previously killed server."
11984 (or gnus-server-killed-servers
11985 (error "No killed servers to be yanked"))
11986 (let ((alist gnus-server-alist)
11987 (server (gnus-server-server-name))
11988 (killed (car gnus-server-killed-servers)))
11990 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
11991 (if (string= server (car (car gnus-server-alist)))
11992 (setq gnus-server-alist (cons killed gnus-server-alist))
11993 (while (and (cdr alist)
11994 (not (string= server (car (car (cdr alist))))))
11995 (setq alist (cdr alist)))
11996 (setcdr alist (cons killed (cdr alist)))))
11997 (gnus-server-update-server (car killed))
11998 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
11999 (gnus-server-position-cursor)))
12001 (defun gnus-server-exit ()
12002 "Return to the group buffer."
12004 (kill-buffer (current-buffer))
12005 (switch-to-buffer gnus-group-buffer))
12007 (defun gnus-server-list-servers ()
12008 "List all available servers."
12010 (let ((cur (gnus-server-server-name)))
12011 (gnus-server-prepare)
12012 (if cur (gnus-server-goto-server cur)
12013 (goto-char (point-max))
12015 (gnus-server-position-cursor)))
12017 (defun gnus-server-copy-server (from to)
12020 (or (gnus-server-server-name)
12021 (error "No server on the current line"))
12022 (read-string "Copy to: ")))
12023 (or from (error "No server on current line"))
12024 (or (and to (not (string= to ""))) (error "No name to copy to"))
12025 (and (assoc to gnus-server-alist) (error "%s already exists" to))
12026 (or (assoc from gnus-server-alist)
12027 (error "%s: no such server" from))
12028 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
12029 (setcar to-entry to)
12030 (setcar (nthcdr 2 to-entry) to)
12031 (setq gnus-server-killed-servers
12032 (cons to-entry gnus-server-killed-servers))
12033 (gnus-server-yank-server)))
12035 (defun gnus-server-add-server (how where)
12037 (list (intern (completing-read "Server method: "
12038 gnus-valid-select-methods nil t))
12039 (read-string "Server name: ")))
12040 (setq gnus-server-killed-servers
12041 (cons (list where how where) gnus-server-killed-servers))
12042 (gnus-server-yank-server))
12044 (defun gnus-server-goto-server (server)
12045 "Jump to a server line."
12047 (list (completing-read "Goto server: " gnus-server-alist nil t)))
12048 (let ((to (text-property-any (point-min) (point-max)
12049 'gnus-server (intern server))))
12053 (gnus-server-position-cursor)))))
12055 (defun gnus-server-edit-server (server)
12056 "Edit the server on the current line."
12057 (interactive (list (gnus-server-server-name)))
12059 (error "No server on current line"))
12060 (setq gnus-winconf-edit-server (current-window-configuration))
12061 (pop-to-buffer gnus-server-edit-buffer)
12062 (gnus-add-current-to-buffer-list)
12064 (use-local-map (copy-keymap (current-local-map)))
12065 (local-set-key "\C-c\C-c" 'gnus-server-edit-server-done)
12067 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
12068 (insert "(gnus-server-set-info \n "
12069 (pp-to-string (list 'quote (cdr (assoc server gnus-server-alist))))
12072 (defun gnus-server-edit-server-done ()
12074 (set-buffer (get-buffer-create gnus-server-edit-buffer))
12075 (eval-current-buffer)
12076 (kill-buffer (current-buffer))
12077 (and gnus-winconf-edit-server
12078 (set-window-configuration gnus-winconf-edit-server))
12079 (setq gnus-winconf-edit-server nil)
12080 (set-buffer gnus-server-buffer)
12081 (gnus-server-update-server (gnus-server-server-name))
12082 (gnus-server-position-cursor))
12084 ;;; Gnus score functions.
12086 (defvar gnus-global-score-files nil
12087 "*List of global score files and directories.
12088 Set this variable if you want to use people's score files. One entry
12089 for each score file or each score file directory. Gnus will decide
12090 by itself what score files are applicable to which group.
12092 Say you want to use the single score file
12093 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
12094 score files in the \"/ftp.some-where:/pub/score\" directory.
12096 (setq gnus-global-score-files
12097 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
12098 \"/ftp.some-where:/pub/score\"))")
12100 (defun gnus-score-score-files (group)
12101 "Return a list of all possible score files."
12102 (and gnus-global-score-files
12103 (or gnus-internal-global-score-files
12104 (gnus-score-search-global-directories gnus-global-score-files)))
12105 (setq gnus-kill-files-directory
12106 (file-name-as-directory
12107 (or gnus-kill-files-directory "~/News/")))
12108 (if (not (file-readable-p gnus-kill-files-directory))
12109 (setq gnus-score-file-list nil)
12110 (if (gnus-use-long-file-name 'not-score)
12111 (if (or (not gnus-score-file-list)
12112 (gnus-file-newer-than gnus-kill-files-directory
12113 (car gnus-score-file-list)))
12114 (setq gnus-score-file-list
12115 (cons (nth 5 (file-attributes gnus-kill-files-directory))
12118 gnus-kill-files-directory t
12119 (concat gnus-score-file-suffix "$"))))))
12120 (let ((dir (expand-file-name
12121 (concat gnus-kill-files-directory
12122 (gnus-replace-chars-in-string group ?. ?/))))
12123 (mdir (length (expand-file-name gnus-kill-files-directory)))
12125 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
12126 (setq files (list (concat dir "/" gnus-score-file-suffix))))
12127 (while (>= (1+ (length dir)) mdir)
12128 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
12129 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
12131 (string-match "/[^/]*$" dir)
12132 (setq dir (substring dir 0 (match-beginning 0))))
12133 (setq gnus-score-file-list
12134 (cons nil (nreverse files)))))
12135 (cdr gnus-score-file-list)))
12137 (defun gnus-score-find-bnews (group)
12138 "Return a list of score files for GROUP.
12139 The score files are those files in the ~/News directory which matches
12140 GROUP using BNews sys file syntax."
12141 (let* ((sfiles (append (gnus-score-score-files group)
12142 gnus-internal-global-score-files))
12143 (kill-dir (file-name-as-directory
12144 (expand-file-name gnus-kill-files-directory)))
12145 (klen (length kill-dir))
12146 ofiles not-match regexp)
12148 (set-buffer (get-buffer-create "*gnus score files*"))
12149 (buffer-disable-undo (current-buffer))
12150 ;; Go through all score file names and create regexp with them
12154 (insert (car sfiles))
12156 ;; First remove the suffix itself.
12157 (re-search-forward (concat "." gnus-score-file-suffix "$"))
12158 (replace-match "" t t)
12160 (if (looking-at (regexp-quote kill-dir))
12161 ;; If the file name was just "SCORE", `klen' is one character
12163 (delete-char (min (1- (point-max)) klen))
12164 (goto-char (point-max))
12165 (search-backward "/")
12166 (delete-region (1+ (point)) (point-min)))
12167 ;; Translate "all" to ".*".
12168 (while (search-forward "all" nil t)
12169 (replace-match ".*" t t))
12171 ;; Deal with "not."s.
12172 (if (looking-at "not.")
12175 (setq regexp (buffer-substring 5 (point-max))))
12176 (setq regexp (buffer-substring 1 (point-max)))
12177 (setq not-match nil))
12178 ;; Finally - if this resulting regexp matches the group name,
12179 ;; we add this score file to the list of score files
12180 ;; applicable to this group.
12181 (if (or (and not-match
12182 (not (string-match regexp group)))
12183 (and (not not-match)
12184 (string-match regexp group)))
12185 (setq ofiles (cons (car sfiles) ofiles)))
12186 (setq sfiles (cdr sfiles)))
12187 (kill-buffer (current-buffer))
12188 ;; Slight kludge here - the last score file returned should be
12189 ;; the local score file, whether it exists or not. This is so
12190 ;; that any score commands the user enters will go to the right
12191 ;; file, and not end up in some global score file.
12194 (if (gnus-use-long-file-name 'not-score)
12195 (concat gnus-kill-files-directory group "."
12196 gnus-score-file-suffix)
12197 (concat gnus-kill-files-directory
12198 (gnus-replace-chars-in-string group ?. ?/)
12199 "/" gnus-score-file-suffix)))))
12200 (and (member localscore ofiles)
12201 (delete localscore ofiles))
12202 (setq ofiles (cons localscore ofiles)))
12203 (nreverse ofiles))))
12205 (defun gnus-score-find-single (group)
12206 "Return list containing the score file for GROUP."
12207 (list (gnus-score-file-name group)))
12209 (defun gnus-score-find-hierarchical (group)
12210 "Return list of score files for GROUP.
12211 This includes the score file for the group and all its parents."
12212 (let ((all (copy-sequence '(nil)))
12214 (while (string-match "\\." group (1+ start))
12215 (setq start (match-beginning 0))
12216 (setq all (cons (substring group 0 start) all)))
12217 (setq all (cons group all))
12218 (mapcar 'gnus-score-file-name (nreverse all))))
12220 (defun gnus-possibly-score-headers ()
12221 (let ((func gnus-score-find-score-files-function)
12222 score-files scores)
12223 (and func (not (listp func))
12224 (setq func (list func)))
12225 ;; Go through all the functions for finding score files (or actual
12226 ;; scores) and add them to a list.
12228 (and (symbolp (car func))
12229 (fboundp (car func))
12231 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
12232 (setq func (cdr func)))
12233 (if score-files (gnus-score-headers score-files))))
12235 (defun gnus-score-file-name (newsgroup)
12236 "Return the name of a score file for NEWSGROUP."
12237 (cond ((or (null newsgroup)
12238 (string-equal newsgroup ""))
12239 ;; The global score file is placed at top of the directory.
12240 (expand-file-name gnus-score-file-suffix
12241 (or gnus-kill-files-directory "~/News")))
12242 ((gnus-use-long-file-name 'not-score)
12243 ;; Append ".SCORE" to newsgroup name.
12244 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
12245 (or gnus-kill-files-directory "~/News")))
12247 ;; Place "SCORE" under the hierarchical directory.
12248 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
12249 "/" gnus-score-file-suffix)
12250 (or gnus-kill-files-directory "~/News")))))
12252 (defun gnus-score-search-global-directories (files)
12253 "Scan all global score directories for score files."
12254 ;; Set the variable `gnus-internal-global-score-files' to all
12255 ;; available global score files.
12256 (interactive (list gnus-global-score-files))
12259 (if (string-match "/$" (car files))
12260 (setq out (nconc (directory-files
12262 (concat gnus-score-file-suffix "$"))))
12263 (setq out (cons (car files) out)))
12264 (setq files (cdr files)))
12265 (setq gnus-internal-global-score-files out)))
12267 (defun gnus-score-default (level)
12268 (if level (prefix-numeric-value level)
12269 gnus-score-interactive-default-score))
12273 ;;; gnus.el ends here