1 ;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although (ding) Gnus looks suspiciously like GNUS, it isn't quite
27 ;; the same beast. Most internal structures have been changed. If you
28 ;; have written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
40 ;; Site dependent variables. These variables should be defined in
43 (defvar gnus-default-nntp-server nil
44 "Specify a default NNTP server.
45 This variable should be defined in paths.el, and should never be set
47 If you want to change servers, you should use `gnus-select-method'.
48 See the documentation to that variable.")
50 (defconst gnus-backup-default-subscribed-newsgroups
51 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
52 "Default default new newsgroups the first time Gnus is run.
53 Should be set in paths.el, and shouldn't be touched by the user.")
55 (defvar gnus-local-domain nil
56 "Local domain name without a host name.
57 The DOMAINNAME environment variable is used instead if it is defined.
58 If the `system-name' function returns the full Internet name, there is
59 no need to set this variable.")
61 (defvar gnus-local-organization nil
62 "String with a description of what organization (if any) the user belongs to.
63 The ORGANIZATION environment variable is used instead if it is defined.
64 If this variable contains a function, this function will be called
65 with the current newsgroup name as the argument. The function should
68 In any case, if the string (either in the variable, in the environment
69 variable, or returned by the function) is a file name, the contents of
70 this file will be used as the organization.")
72 (defvar gnus-use-generic-from nil
73 "If nil, the full host name will be the system name prepended to the domain name.
74 If this is a string, the full host name will be this string.
75 If this is non-nil, non-string, the domain name will be used as the
78 (defvar gnus-use-generic-path nil
79 "If nil, use the NNTP server name in the Path header.
80 If stringp, use this; if non-nil, use no host name (user name only).")
83 ;; Customization variables
85 (defvar gnus-select-method
86 (list 'nntp (or (getenv "NNTPSERVER")
87 (if (and gnus-default-nntp-server
88 (not (string= gnus-default-nntp-server "")))
89 gnus-default-nntp-server)
91 "*Default method for selecting a newsgroup.
92 This variable should be a list, where the first element is how the
93 news is to be fetched, the second is the address.
95 For instance, if you want to get your news via NNTP from
96 \"flab.flab.edu\", you could say:
98 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
100 If you want to use your local spool, say:
102 (setq gnus-select-method (list 'nnspool (system-name)))
104 If you use this variable, you must set `gnus-nntp-server' to nil.
106 There is a lot more to know about select methods and virtual servers -
107 see the manual for details.")
109 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
110 (defvar gnus-post-method nil
111 "*Preferred method for posting USENET news.
112 If this variable is nil, Gnus will use the current method to decide
113 which method to use when posting. If it is non-nil, it will override
114 the current method. This method will not be used in mail groups and
115 the like, only in \"real\" newsgroups.
117 The value must be a valid method as discussed in the documentation of
118 `gnus-select-method'.")
120 (defvar gnus-refer-article-method nil
121 "*Preferred method for fetching an article by Message-ID.
122 If you are reading news from the local spool (with nnspool), fetching
123 articles by Message-ID is painfully slow. By setting this method to an
124 nntp method, you might get acceptable results.
126 The value of this variable must be a valid select method as discussed
127 in the documentation of `gnus-select-method'")
129 (defvar gnus-secondary-select-methods nil
130 "*A list of secondary methods that will be used for reading news.
131 This is a list where each element is a complete select method (see
132 `gnus-select-method').
134 If, for instance, you want to read your mail with the nnml backend,
135 you could set this variable:
137 (setq gnus-secondary-select-methods '((nnml \"\"))")
139 (defvar gnus-secondary-servers nil
140 "*List of NNTP servers that the user can choose between interactively.
141 To make Gnus query you for a server, you have to give `gnus' a
142 non-numeric prefix - `C-u M-x gnus', in short.")
144 (defvar gnus-nntp-server nil
145 "*The name of the host running the NNTP server.
146 This variable is semi-obsolete. Use the `gnus-select-method'
149 (defvar gnus-nntp-service "nntp"
150 "*NNTP service name (\"nntp\" or 119).
151 This is an obsolete variable, which is scarcely used. If you use an
152 nntp server for your newsgroup and want to change the port number
153 used to 899, you would say something along these lines:
155 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
157 (defvar gnus-startup-file "~/.newsrc"
158 "*Your `.newsrc' file.
159 `.newsrc-SERVER' will be used instead if that exists.")
161 (defvar gnus-init-file "~/.gnus"
162 "*Your Gnus elisp startup file.
163 If a file with the .el or .elc suffixes exist, it will be read
166 (defvar gnus-group-faq-directory
167 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
168 "*Directory where the group FAQs are stored.
169 This will most commonly be on a remote machine, and the file will be
170 fetched by ange-ftp.")
172 (defvar gnus-group-archive-directory
173 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
174 "*The address of the (ding) archives.")
176 (defvar gnus-default-subscribed-newsgroups nil
177 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
178 It should be a list of strings.
179 If it is `t', Gnus will not do anything special the first time it is
180 started; it'll just use the normal newsgroups subscription methods.")
182 (defvar gnus-use-cross-reference t
183 "*Non-nil means that cross referenced articles will be marked as read.
184 If nil, ignore cross references. If t, mark articles as read in
185 subscribed newsgroups. If neither t nor nil, mark as read in all
188 (defvar gnus-use-dribble-file t
189 "*Non-nil means that Gnus will use a dribble file to store user updates.
190 If Emacs should crash without saving the .newsrc files, complete
191 information can be restored from the dribble file.")
193 (defvar gnus-asynchronous nil
194 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
196 (defvar gnus-asynchronous-article-function nil
197 "*Function for picking articles to pre-fetch, possibly.")
199 (defvar gnus-score-file-single-match-alist nil
200 "*Alist mapping regexps to lists of score files.
201 Each element of this alist should be of the form
202 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
204 If the name of a group is matched by REGEXP, the corresponding scorefiles
205 will be used for that group.
206 The first match found is used, subsequent matching entries are ignored (to
207 use multiple matches, see gnus-score-file-multiple-match-alist).
209 These score files are loaded in addition to any files returned by
210 gnus-score-find-score-files-function (which see).")
212 (defvar gnus-score-file-multiple-match-alist nil
213 "*Alist mapping regexps to lists of score files.
214 Each element of this alist should be of the form
215 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
217 If the name of a group is matched by REGEXP, the corresponding scorefiles
218 will be used for that group.
219 If multiple REGEXPs match a group, the score files corresponding to each
220 match will be used (for only one match to be used, see
221 gnus-score-file-single-match-alist).
223 These score files are loaded in addition to any files returned by
224 gnus-score-find-score-files-function (which see).")
227 (defvar gnus-score-file-suffix "SCORE"
228 "*Suffix of the score files.")
230 (defvar gnus-adaptive-file-suffix "ADAPT"
231 "*Suffix of the adaptive score files.")
233 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
234 "*Function used to find SCORE files.
235 The function will be called with the group name as the argument, and
236 should return a list of score files to apply to that group. The score
237 files do not actually have to exist.
239 Predefined values are:
241 gnus-score-find-single: Only apply the group's own SCORE file.
242 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
243 gnus-score-find-bnews: Apply SCORE files whose names matches.
245 See the documentation to these functions for more information.
247 This variable can also be a list of functions to be called. Each
248 function should either return a list of score files, or a list of
251 (defvar gnus-score-interactive-default-score 1000
252 "*Scoring commands will raise/lower the score with this number as the default.")
254 (defvar gnus-large-newsgroup 200
255 "*The number of articles which indicates a large newsgroup.
256 If the number of articles in a newsgroup is greater than this value,
257 confirmation is required for selecting the newsgroup.")
259 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
260 (defvar gnus-no-groups-message "No news is horrible news"
261 "*Message displayed by Gnus when no groups are available.")
263 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
264 "*Non-nil means that the default name of a file to save articles in is the group name.
265 If it's nil, the directory form of the group name is used instead.
267 If this variable is a list, and the list contains the element
268 `not-score', long file names will not be used for score files; if it
269 contains the element `not-save', long file names will not be used for
270 saving; and if it contains the element `not-kill', long file names
271 will not be used for kill files.")
273 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
274 "*Name of the directory articles will be saved in (default \"~/News\").
275 Initialized from the SAVEDIR environment variable.")
277 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
278 "*Name of the directory where kill files will be stored (default \"~/News\").
279 Initialized from the SAVEDIR environment variable.")
281 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
282 "*A function to save articles in your favorite format.
283 The function must be interactively callable (in other words, it must
284 be an Emacs command).
286 Gnus provides the following functions:
288 * gnus-summary-save-in-rmail (Rmail format)
289 * gnus-summary-save-in-mail (Unix mail format)
290 * gnus-summary-save-in-folder (MH folder)
291 * gnus-summary-save-in-file (article format).
292 * gnus-summary-save-in-vm (use VM's folder format).")
294 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
295 "*A function generating a file name to save articles in Rmail format.
296 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
298 (defvar gnus-mail-save-name (function gnus-plain-save-name)
299 "*A function generating a file name to save articles in Unix mail format.
300 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
302 (defvar gnus-folder-save-name (function gnus-folder-save-name)
303 "*A function generating a file name to save articles in MH folder.
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
306 (defvar gnus-file-save-name (function gnus-numeric-save-name)
307 "*A function generating a file name to save articles in article format.
308 The function is called with NEWSGROUP, HEADERS, and optional
311 (defvar gnus-split-methods nil
312 "*Variable used to suggest where articles are to be saved.
313 The syntax of this variable is the same as `nnmail-split-methods'.
315 For instance, if you would like to save articles related to Gnus in
316 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
317 you could set this variable to something like:
319 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
320 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
322 (defvar gnus-save-score nil
323 "*If non-nil, save group scoring info.")
325 (defvar gnus-use-adaptive-scoring nil
326 "*If non-nil, use some adaptive scoring scheme.")
328 (defvar gnus-use-cache nil
329 "*If non-nil, Gnus will cache (some) articles locally.")
331 (defvar gnus-use-scoring t
332 "*If non-nil, enable scoring.")
334 (defvar gnus-fetch-old-headers nil
335 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
336 If an unread article in the group refers to an older, already read (or
337 just marked as read) article, the old article will not normally be
338 displayed in the Summary buffer. If this variable is non-nil, Gnus
339 will attempt to grab the headers to the old articles, and thereby
340 build complete threads. If it has the value `some', only enough
341 headers to connect otherwise loose threads will be displayed.
343 The server has to support XOVER for any of this to work.")
345 (defvar gnus-visual t
346 "*If non-nil, will do various highlighting.
347 If nil, no mouse highlights (or any other highlights) will be
348 performed. This might speed up Gnus some when generating large group
349 and summary buffers.")
351 (defvar gnus-novice-user t
352 "*Non-nil means that you are a usenet novice.
353 If non-nil, verbose messages may be displayed and confirmations may be
356 (defvar gnus-expert-user nil
357 "*Non-nil means that you will never be asked for confirmation about anything.
358 And that means *anything*.")
360 (defvar gnus-verbose 7
361 "*Integer that says how verbose Gnus should be.
362 The higher the number, the more messages Gnus will flash to say what
363 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
364 display most important messages; and at ten, Gnus will keep on
365 jabbering all the time.")
367 (defvar gnus-keep-same-level nil
368 "*Non-nil means that the next newsgroup after the current will be on the same level.
369 When you type, for instance, `n' after reading the last article in the
370 current newsgroup, you will go to the next newsgroup. If this variable
371 is nil, the next newsgroup will be the next from the group
373 If this variable is non-nil, Gnus will either put you in the
374 next newsgroup with the same level, or, if no such newsgroup is
375 available, the next newsgroup with the lowest possible level higher
376 than the current level.
377 If this variable is `best', Gnus will make the next newsgroup the one
378 with the best level.")
380 (defvar gnus-summary-make-false-root 'adopt
381 "*nil means that Gnus won't gather loose threads.
382 If the root of a thread has expired or been read in a previous
383 session, the information necessary to build a complete thread has been
384 lost. Instead of having many small sub-threads from this original thread
385 scattered all over the summary buffer, Gnus can gather them.
387 If non-nil, Gnus will try to gather all loose sub-threads from an
388 original thread into one large thread.
390 If this variable is non-nil, it should be one of `none', `adopt',
393 If this variable is `none', Gnus will not make a false root, but just
394 present the sub-threads after another.
395 If this variable is `dummy', Gnus will create a dummy root that will
396 have all the sub-threads as children.
397 If this variable is `adopt', Gnus will make one of the \"children\"
398 the parent and mark all the step-children as such.
399 If this variable is `empty', the \"children\" are printed with empty
400 subject fields. (Or rather, they will be printed with a string
401 given by the `gnus-summary-same-subject' variable.)")
403 (defvar gnus-summary-gather-subject-limit nil
404 "*Maximum length of subject comparisons when gathering loose threads.
405 Use nil to compare full subjects. Setting this variable to a low
406 number will help gather threads that have been corrupted by
407 newsreaders chopping off subject lines, but it might also mean that
408 unrelated articles that have subject that happen to begin with the
409 same few characters will be incorrectly gathered.
411 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
412 comparing subjects.")
414 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
415 (defvar gnus-summary-same-subject ""
416 "*String indicating that the current article has the same subject as the previous.
417 This variable will only be used if the value of
418 `gnus-summary-make-false-root' is `empty'.")
420 (defvar gnus-summary-goto-unread t
421 "*If non-nil, marking commands will go to the next unread article.")
423 (defvar gnus-group-goto-unread t
424 "*If non-nil, movement commands will go to the next unread and subscribed group.")
426 (defvar gnus-check-new-newsgroups t
427 "*Non-nil means that Gnus will add new newsgroups at startup.
428 If this variable is `ask-server', Gnus will ask the server for new
429 groups since the last time it checked. This means that the killed list
430 is no longer necessary, so you could set `gnus-save-killed-list' to
433 A variant is to have this variable be a list of select methods. Gnus
434 will then use the `ask-server' method on all these select methods to
435 query for new groups from all those servers.
438 (setq gnus-check-new-newsgroups
439 '((nntp \"some.server\") (nntp \"other.server\")))
441 If this variable is nil, then you have to tell Gnus explicitly to
442 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
444 (defvar gnus-check-bogus-newsgroups nil
445 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
446 If this variable is nil, then you have to tell Gnus explicitly to
447 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
449 (defvar gnus-read-active-file t
450 "*Non-nil means that Gnus will read the entire active file at startup.
451 If this variable is nil, Gnus will only know about the groups in your
454 If this variable is `some', Gnus will try to only read the relevant
455 parts of the active file from the server. Not all servers support
456 this, and it might be quite slow with other servers, but this should
457 generally be faster than both the t and nil value.
459 If you set this variable to nil or `some', you probably still want to
460 be told about new newsgroups that arrive. To do that, set
461 `gnus-check-new-newsgroups' to `ask-server'. This may not work
462 properly with all servers.")
464 (defvar gnus-level-subscribed 5
465 "*Groups with levels less than or equal to this variable are subscribed.")
467 (defvar gnus-level-unsubscribed 7
468 "*Groups with levels less than or equal to this variable are unsubscribed.
469 Groups with levels less than `gnus-level-subscribed', which should be
470 less than this variable, are subscribed.")
472 (defvar gnus-level-zombie 8
473 "*Groups with this level are zombie groups.")
475 (defvar gnus-level-killed 9
476 "*Groups with this level are killed.")
478 (defvar gnus-level-default-subscribed 3
479 "*New subscribed groups will be subscribed at this level.")
481 (defvar gnus-level-default-unsubscribed 6
482 "*New unsubscribed groups will be unsubscribed at this level.")
484 (defvar gnus-activate-foreign-newsgroups nil
485 "*If nil, Gnus will not check foreign newsgroups at startup.
486 If it is non-nil, it should be a number between one and nine. Foreign
487 newsgroups that have a level lower or equal to this number will be
488 activated on startup. For instance, if you want to active all
489 subscribed newsgroups, but not the rest, you'd set this variable to
490 `gnus-level-subscribed'.
492 If you subscribe to lots of newsgroups from different servers, startup
493 might take a while. By setting this variable to nil, you'll save time,
494 but you won't be told how many unread articles there are in the
497 (defvar gnus-save-newsrc-file t
498 "*Non-nil means that Gnus will save the `.newsrc' file.
499 Gnus always saves its own startup file, which is called
500 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
501 be readily understood by other newsreaders. If you don't plan on
502 using other newsreaders, set this variable to nil to save some time on
505 (defvar gnus-save-killed-list t
506 "*If non-nil, save the list of killed groups to the startup file.
507 This will save both time (when starting and quitting) and space (both
508 memory and disk), but it will also mean that Gnus has no record of
509 which groups are new and which are old, so the automatic new
510 newsgroups subscription methods become meaningless. You should always
511 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
514 (defvar gnus-interactive-catchup t
515 "*If non-nil, require your confirmation when catching up a group.")
517 (defvar gnus-interactive-post t
518 "*If non-nil, group name will be asked for when posting.")
520 (defvar gnus-interactive-exit t
521 "*If non-nil, require your confirmation when exiting Gnus.")
523 (defvar gnus-kill-killed nil
524 "*If non-nil, Gnus will apply kill files to already killed articles.
525 If it is nil, Gnus will never apply kill files to articles that have
526 already been through the scoring process, which might very well save lots
529 (defvar gnus-extract-address-components 'gnus-extract-address-components
530 "*Function for extracting address components from a From header.
531 Two pre-defined function exist: `gnus-extract-address-components',
532 which is the default, quite fast, and too simplistic solution, and
533 `mail-extract-address-components', which works much better, but is
536 (defvar gnus-summary-default-score 0
537 "*Default article score level.
538 If this variable is nil, scoring will be disabled.")
540 (defvar gnus-summary-zcore-fuzz 0
541 "*Fuzziness factor for the zcore in the summary buffer.
542 Articles with scores closer than this to `gnus-summary-default-score'
543 will not be marked.")
545 (defvar gnus-simplify-subject-fuzzy-regexp nil
546 "*Regular expression that will be removed from subject strings if
547 fuzzy subject simplification is selected.")
549 (defvar gnus-group-default-list-level gnus-level-subscribed
550 "*Default listing level.
551 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
553 (defvar gnus-group-use-permanent-levels nil
554 "*If non-nil, once you set a level, Gnus will use this level.")
556 (defvar gnus-show-mime nil
557 "*If non-nil, do mime processing of articles.
558 The articles will simply be fed to the function given by
559 `gnus-show-mime-method'.")
561 (defvar gnus-strict-mime t
562 "*If nil, decode MIME header even if there is not Mime-Version field.")
564 (defvar gnus-show-mime-method (function metamail-buffer)
565 "*Function to process a MIME message.
566 The function is called from the article buffer.")
568 (defvar gnus-show-threads t
569 "*If non-nil, display threads in summary mode.")
571 (defvar gnus-thread-hide-subtree nil
572 "*If non-nil, hide all threads initially.
573 If threads are hidden, you have to run the command
574 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
575 to expose hidden threads.")
577 (defvar gnus-thread-hide-killed t
578 "*If non-nil, hide killed threads automatically.")
580 (defvar gnus-thread-ignore-subject nil
581 "*If non-nil, ignore subjects and do all threading based on the Reference header.
582 If nil, which is the default, articles that have different subjects
583 from their parents will start separate threads.")
585 (defvar gnus-thread-indent-level 4
586 "*Number that says how much each sub-thread should be indented.")
588 (defvar gnus-ignored-newsgroups ""
589 "*A regexp to match uninteresting newsgroups in the active file.
590 Any lines in the active file matching this regular expression are
591 removed from the newsgroup list before anything else is done to it,
592 thus making them effectively non-existent.")
594 (defvar gnus-ignored-headers
595 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
596 "*All headers that match this regexp will be hidden.
597 Also see `gnus-visible-headers'.")
599 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
600 "*All headers that do not match this regexp will be hidden.
601 Also see `gnus-ignored-headers'.")
603 (defvar gnus-sorted-header-list
604 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
605 "^Cc:" "^Date:" "^Organization:")
606 "*This variable is a list of regular expressions.
607 If it is non-nil, headers that match the regular expressions will
608 be placed first in the article buffer in the sequence specified by
611 (defvar gnus-show-all-headers nil
612 "*If non-nil, don't hide any headers.")
614 (defvar gnus-save-all-headers t
615 "*If non-nil, don't remove any headers before saving.")
617 (defvar gnus-inhibit-startup-message nil
618 "*If non-nil, the startup message will not be displayed.")
620 (defvar gnus-signature-separator "^-- *$"
621 "Regexp matching signature separator.")
623 (defvar gnus-auto-extend-newsgroup t
624 "*If non-nil, extend newsgroup forward and backward when requested.")
626 (defvar gnus-auto-select-first t
627 "*If non-nil, select the first unread article when entering a group.
628 If you want to prevent automatic selection of the first unread article
629 in some newsgroups, set the variable to nil in
630 `gnus-select-group-hook'.")
632 (defvar gnus-auto-select-next t
633 "*If non-nil, offer to go to the next group from the end of the previous.
634 If the value is t and the next newsgroup is empty, Gnus will exit
635 summary mode and go back to group mode. If the value is neither nil
636 nor t, Gnus will select the following unread newsgroup. In
637 particular, if the value is the symbol `quietly', the next unread
638 newsgroup will be selected without any confirmations.")
640 (defvar gnus-auto-select-same nil
641 "*If non-nil, select the next article with the same subject.")
643 (defvar gnus-summary-check-current nil
644 "*If non-nil, consider the current article when moving.
645 The \"unread\" movement commands will stay on the same line if the
646 current article is unread.")
648 (defvar gnus-auto-center-summary t
649 "*If non-nil, always center the current summary buffer.")
651 (defvar gnus-break-pages t
652 "*If non-nil, do page breaking on articles.
653 The page delimiter is specified by the `gnus-page-delimiter'
656 (defvar gnus-page-delimiter "^\^L"
657 "*Regexp describing what to use as article page delimiters.
658 The default value is \"^\^L\", which is a form linefeed at the
659 beginning of a line.")
661 (defvar gnus-use-full-window t
662 "*If non-nil, use the entire Emacs screen.")
664 (defvar gnus-window-configuration nil
665 "Obsolete variable. See `gnus-buffer-configuration'.")
667 (defvar gnus-buffer-configuration
668 '((group ([group 1.0 point]
669 (if gnus-carpal [group-carpal 4])))
670 (summary ([summary 1.0 point]
671 (if gnus-carpal [summary-carpal 4])))
672 (article ([summary 0.25 point]
673 (if gnus-carpal [summary-carpal 4])
675 (server ([server 1.0 point]
676 (if gnus-carpal [server-carpal 2])))
677 (browse ([browse 1.0 point]
678 (if gnus-carpal [browse-carpal 2])))
679 (group-mail ([mail 1.0 point]))
680 (summary-mail ([mail 1.0 point]))
681 (summary-reply ([article 0.5]
683 (info ([nil 1.0 point]))
684 (summary-faq ([summary 0.25]
686 (edit-group ([group 0.5]
687 [edit-group 1.0 point]))
688 (edit-server ([server 0.5]
689 [edit-server 1.0 point]))
690 (edit-score ([summary 0.25]
691 [edit-score 1.0 point]))
692 (post ([post 1.0 point]))
693 (reply ([article 0.5]
695 (mail-forward ([mail 1.0 point]))
696 (post-forward ([post 1.0 point]))
697 (reply-yank ([mail 1.0 point]))
698 (followup ([article 0.5]
700 (followup-yank ([post 1.0 point])))
701 "Window configuration for all possible Gnus buffers.
702 This variable is a list of lists. Each of these lists has a NAME and
703 a RULE. The NAMEs are commonsense names like `group', which names a
704 rule used when displaying the group buffer; `summary', which names a
705 rule for what happens when you enter a group and do not display an
706 article buffer; and so on. See the value of this variable for a
707 complete list of NAMEs.
709 Each RULE is a list of vectors. The first element in this vector is
710 the name of the buffer to be displayed; the second element is the
711 percentage of the screen this buffer is to occupy (a number in the
712 0.0-0.99 range); the optional third element is `point', which should
713 be present to denote which buffer point is to go to after making this
714 buffer configuration.")
716 (defvar gnus-window-to-buffer
717 '((group . gnus-group-buffer)
718 (summary . gnus-summary-buffer)
719 (article . gnus-article-buffer)
720 (server . gnus-server-buffer)
721 (browse . "*Gnus Browse Server*")
722 (edit-group . gnus-group-edit-buffer)
723 (edit-server . gnus-server-edit-buffer)
724 (group-carpal . gnus-carpal-group-buffer)
725 (summary-carpal . gnus-carpal-summary-buffer)
726 (server-carpal . gnus-carpal-server-buffer)
727 (browse-carpal . gnus-carpal-browse-buffer)
728 (edit-score . gnus-score-edit-buffer)
729 (mail . gnus-mail-buffer)
730 (post . gnus-post-news-buffer)
731 (faq . gnus-faq-buffer))
732 "Mapping from short symbols to buffer names or buffer variables.")
734 (defvar gnus-carpal nil
735 "*If non-nil, display clickable icons.")
737 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
738 "*Function called with a group name when new group is detected.
739 A few pre-made functions are supplied: `gnus-subscribe-randomly'
740 inserts new groups at the beginning of the list of groups;
741 `gnus-subscribe-alphabetically' inserts new groups in strict
742 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
743 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
746 ;; Suggested by a bug report by Hallvard B Furuseth.
747 ;; <h.b.furuseth@usit.uio.no>.
748 (defvar gnus-subscribe-options-newsgroup-method
749 (function gnus-subscribe-alphabetically)
750 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
751 If, for instance, you want to subscribe to all newsgroups in the
752 \"no\" and \"alt\" hierarchies, you'd put the following in your
755 options -n no.all alt.all
757 Gnus will the subscribe all new newsgroups in these hierarchies with
758 the subscription method in this variable.")
760 (defvar gnus-subscribe-hierarchical-interactive nil
761 "*If non-nil, Gnus will offer to subscribe hierarchically.
762 When a new hierarchy appears, Gnus will ask the user:
764 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
766 If the user pressed `d', Gnus will descend the hierarchy, `y' will
767 subscribe to all newsgroups in the hierarchy and `s' will skip this
768 hierarchy in its entirety.")
770 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
771 "*Function used for sorting the group buffer.
772 This function will be called with group info entries as the arguments
773 for the groups to be sorted. Pre-made functions include
774 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
775 `gnus-sort-by-level'")
777 ;; Mark variables suggested by Thomas Michanek
778 ;; <Thomas.Michanek@telelogic.se>.
779 (defvar gnus-unread-mark ?
780 "*Mark used for unread articles.")
781 (defvar gnus-ticked-mark ?!
782 "*Mark used for ticked articles.")
783 (defvar gnus-dormant-mark ??
784 "*Mark used for dormant articles.")
785 (defvar gnus-del-mark ?r
786 "*Mark used for del'd articles.")
787 (defvar gnus-read-mark ?R
788 "*Mark used for read articles.")
789 (defvar gnus-expirable-mark ?E
790 "*Mark used for expirable articles.")
791 (defvar gnus-killed-mark ?K
792 "*Mark used for killed articles.")
793 (defvar gnus-kill-file-mark ?X
794 "*Mark used for articles killed by kill files.")
795 (defvar gnus-low-score-mark ?Y
796 "*Mark used for articles with a low score.")
797 (defvar gnus-catchup-mark ?C
798 "*Mark used for articles that are caught up.")
799 (defvar gnus-replied-mark ?A
800 "*Mark used for articles that have been replied to.")
801 (defvar gnus-process-mark ?#
803 (defvar gnus-ancient-mark ?O
804 "*Mark used for ancient articles.")
805 (defvar gnus-canceled-mark ?G
806 "*Mark used for canceled articles.")
807 (defvar gnus-score-over-mark ?+
808 "*Score mark used for articles with high scores.")
809 (defvar gnus-score-below-mark ?-
810 "*Score mark used for articles with low scores.")
811 (defvar gnus-empty-thread-mark ?
812 "*There is no thread under the article.")
813 (defvar gnus-not-empty-thread-mark ?=
814 "*There is a thread under the article.")
815 (defvar gnus-dummy-mark ?Z
816 "*This is a dummy article.")
818 (defvar gnus-view-pseudo-asynchronously nil
819 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
821 (defvar gnus-view-pseudos nil
822 "*If `automatic', pseudo-articles will be viewed automatically.
823 If `not-confirm', pseudos will be viewed automatically, and the user
824 will not be asked to confirm the command.")
826 (defvar gnus-view-pseudos-separately t
827 "*If non-nil, one pseudo-article will be created for each file to be viewed.
828 If nil, all files that use the same viewing command will be given as a
829 list of parameters to that command.")
831 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
832 "*Format of group lines.
833 It works along the same lines as a normal formatting string,
834 with some simple extensions.
836 %M Only marked articles (character, \"*\" or \" \")
837 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
838 %L Level of subscribedness (integer)
839 %N Number of unread articles (integer)
840 %I Number of dormant articles (integer)
841 %i Number of ticked and dormant (integer)
842 %T Number of ticked articles (integer)
843 %R Number of read articles (integer)
844 %t Total number of articles (integer)
845 %y Number of unread, unticked articles (integer)
846 %G Group name (string)
847 %g Qualified group name (string)
848 %D Group description (string)
849 %s Select method (string)
850 %o Moderated group (char, \"m\")
851 %p Process mark (char)
852 %O Moderated group (string, \"(m)\" or \"\")
853 %n Select from where (string)
854 %z A string that look like `<%s:%n>' if a foreign select method is used
855 %u User defined specifier. The next character in the format string should
856 be a letter. Gnus will call the function gnus-user-format-function-X,
857 where X is the letter following %u. The function will be passed the
858 current header as argument. The function should return a string, which
859 will be inserted into the buffer just like information from any other
862 Text between %( and %) will be highlighted with `gnus-mouse-face' when
863 the mouse point move inside the area. There can only be one such area.
865 Note that this format specification is not always respected. For
866 reasons of efficiency, when listing killed groups, this specification
867 is ignored altogether. If the spec is changed considerably, your
868 output may end up looking strange when listing both alive and killed
871 If you use %o or %O, reading the active file will be slower and quite
872 a bit of extra memory will be used. %D will also worsen performance.
873 Also note that if you change the format specification to include any
874 of these specs, you must probably re-start Gnus to see them go into
877 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
878 "*The format specification of the lines in the summary buffer.
880 It works along the same lines as a normal formatting string,
881 with some simple extensions.
883 %N Article number, left padded with spaces (string)
885 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
886 %n Name of the poster (string)
887 %a Extracted name of the poster (string)
888 %A Extracted address of the poster (string)
889 %F Contents of the From: header (string)
890 %x Contents of the Xref: header (string)
891 %D Date of the article (string)
892 %d Date of the article (string) in DD-MMM format
893 %M Message-id of the article (string)
894 %r References of the article (string)
895 %c Number of characters in the article (integer)
896 %L Number of lines in the article (integer)
897 %I Indentation based on thread level (a string of spaces)
898 %T A string with two possible values: 80 spaces if the article
899 is on thread level two or larger and 0 spaces on level one
900 %R \"R\" if this article has been replied to, \" \" otherwise (character)
901 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
902 %[ Opening bracket (character, \"[\" or \"<\")
903 %] Closing bracket (character, \"]\" or \">\")
904 %> Spaces of length thread-level (string)
905 %< Spaces of length (- 20 thread-level) (string)
906 %i Article score (number)
907 %z Article zcore (character)
908 %t Number of articles under the current thread (number).
909 %e Whether the thread is empty or not (character).
910 %u User defined specifier. The next character in the format string should
911 be a letter. Gnus will call the function gnus-user-format-function-X,
912 where X is the letter following %u. The function will be passed the
913 current header as argument. The function should return a string, which
914 will be inserted into the summary just like information from any other
917 Text between %( and %) will be highlighted with `gnus-mouse-face'
918 when the mouse point is placed inside the area. There can only be one
921 The %U (status), %R (replied) and %z (zcore) specs have to be handled
922 with care. For reasons of efficiency, Gnus will compute what column
923 these characters will end up in, and \"hard-code\" that. This means that
924 it is illegal to have these specs after a variable-length spec. Well,
925 you might not be arrested, but your summary buffer will look strange,
928 The smart choice is to have these specs as for to the left as
931 This restriction may disappear in later versions of Gnus.")
933 (defvar gnus-summary-dummy-line-format "* : : %S\n"
934 "*The format specification for the dummy roots in the summary buffer.
935 It works along the same lines as a normal formatting string,
936 with some simple extensions.
940 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
941 "*The format specification for the summary mode line.")
943 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
944 "*The format specification for the article mode line.")
946 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
947 "*The format specification for the group mode line.")
949 (defvar gnus-valid-select-methods
950 '(("nntp" post address prompt-address)
952 ("nnvirtual" none virtual prompt-address)
953 ("nnmbox" mail respool)
954 ("nnml" mail respool)
955 ("nnmh" mail respool)
956 ("nndir" none prompt-address address)
957 ("nneething" none prompt-address)
959 ("nndoc" none prompt-address)
960 ("nnbabyl" mail respool)
961 ("nnkiboze" post virtual)
963 ("nnfolder" mail respool))
964 "An alist of valid select methods.
965 The first element of each list lists should be a string with the name
966 of the select method. The other elements may be be the category of
967 this method (ie. `post', `mail', `none' or whatever) or other
968 properties that this method has (like being respoolable).
969 If you implement a new select method, all you should have to change is
970 this variable. I think.")
972 (defvar gnus-updated-mode-lines '(group article summary)
973 "*List of buffers that should update their mode lines.
974 The list may contain the symbols `group', `article' and `summary'. If
975 the corresponding symbol is present, Gnus will keep that mode line
976 updated with information that may be pertinent.
977 If this variable is nil, screen refresh may be quicker.")
979 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
980 (defvar gnus-mode-non-string-length 21
981 "*Max length of mode-line non-string contents.
982 If this is nil, Gnus will take space as is needed, leaving the rest
983 of the modeline intact.")
985 (defvar gnus-mouse-face 'highlight
986 "*Face used for mouse highlighting in Gnus.
987 No mouse highlights will be done if `gnus-visual' is nil.")
989 (defvar gnus-summary-mark-below nil
990 "*Mark all articles with a score below this variable as read.
991 This variable is local to each summary buffer and usually set by the
994 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
995 "*List of functions used for sorting threads in the summary buffer.
996 By default, threads are sorted by article number.
998 Each function takes two threads and return non-nil if the first thread
999 should be sorted before the other. If you use more than one function,
1000 the primary sort function should be the last.
1002 Ready-mady functions include `gnus-thread-sort-by-number',
1003 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1004 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1005 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1007 (defvar gnus-thread-score-function '+
1008 "*Function used for calculating the total score of a thread.
1010 The function is called with the scores of the article and each
1011 subthread and should then return the score of the thread.
1013 Some functions you can use are `+', `max', or `min'.")
1015 (defvar gnus-options-subscribe nil
1016 "*All new groups matching this regexp will be subscribed unconditionally.
1017 Note that this variable deals only with new newsgroups. This variable
1018 does not affect old newsgroups.")
1020 (defvar gnus-options-not-subscribe nil
1021 "*All new groups matching this regexp will be ignored.
1022 Note that this variable deals only with new newsgroups. This variable
1023 does not affect old (already subscribed) newsgroups.")
1025 (defvar gnus-auto-expirable-newsgroups nil
1026 "*Groups in which to automatically mark read articles as expirable.
1027 If non-nil, this should be a regexp that should match all groups in
1028 which to perform auto-expiry. This only makes sense for mail groups.")
1030 (defvar gnus-hidden-properties '(invisible t intangible t)
1031 "Property list to use for hiding text.")
1035 (defvar gnus-group-mode-hook nil
1036 "*A hook for Gnus group mode.")
1038 (defvar gnus-summary-mode-hook nil
1039 "*A hook for Gnus summary mode.
1040 This hook is run before any variables are set in the summary buffer.")
1042 (defvar gnus-article-mode-hook nil
1043 "*A hook for Gnus article mode.")
1045 (defun gnus-summary-prepare-exit-hook nil
1046 "*A hook called when preparing to exit from the summary buffer.
1047 It calls `gnus-summary-expire-articles' by default.")
1048 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1050 (defun gnus-summary-exit-hook nil
1051 "*A hook called on exit from the summary buffer.")
1053 (defvar gnus-open-server-hook nil
1054 "*A hook called just before opening connection to the news server.")
1056 (defvar gnus-startup-hook nil
1057 "*A hook called at startup.
1058 This hook is called after Gnus is connected to the NNTP server.")
1060 (defvar gnus-get-new-news-hook nil
1061 "*A hook run just before Gnus checks for new news.")
1063 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1064 "*A function that is called to generate the group buffer.
1065 The function is called with three arguments: The first is a number;
1066 all group with a level less or equal to that number should be listed,
1067 if the second is non-nil, empty groups should also be displayed. If
1068 the third is non-nil, it is a number. No groups with a level lower
1069 than this number should be displayed.
1071 The only current function implemented is `gnus-group-prepare-flat'.")
1073 (defvar gnus-group-prepare-hook nil
1074 "*A hook called after the group buffer has been generated.
1075 If you want to modify the group buffer, you can use this hook.")
1077 (defvar gnus-summary-prepare-hook nil
1078 "*A hook called after the summary buffer has been generated.
1079 If you want to modify the summary buffer, you can use this hook.")
1081 (defvar gnus-article-prepare-hook nil
1082 "*A hook called after an article has been prepared in the article buffer.
1083 If you want to run a special decoding program like nkf, use this hook.")
1085 (defvar gnus-article-display-hook nil
1086 "*A hook called after the article is displayed in the article buffer.
1087 The hook is designed to change the contents of the article
1088 buffer. Typical functions that this hook may contain are
1089 `gnus-article-hide-headers' (hide selected headers),
1090 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1091 `gnus-article-hide-signature' (hide signature) and
1092 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1093 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1094 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1096 (defvar gnus-article-x-face-command
1097 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1098 "String or function to be executed to display an X-Face header.
1099 If it is a string, the command will be executed in a sub-shell
1100 asynchronously. The compressed face will be piped to this command.")
1102 (defvar gnus-article-x-face-too-ugly nil
1103 "Regexp matching posters whose face shouldn't be shown automatically.")
1105 (defvar gnus-select-group-hook nil
1106 "*A hook called when a newsgroup is selected.
1108 If you'd like to simplify subjects like the
1109 `gnus-summary-next-same-subject' command does, you can use the
1112 (setq gnus-select-group-hook
1115 (mapcar (lambda (header)
1118 (gnus-simplify-subject
1119 (header-subject header) 're-only)))
1120 gnus-newsgroup-headers))))")
1122 (defvar gnus-select-article-hook
1123 '(gnus-summary-show-thread)
1124 "*A hook called when an article is selected.
1125 The default hook shows conversation thread subtrees of the selected
1126 article automatically using `gnus-summary-show-thread'.")
1128 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1129 "*A hook called to apply kill files to a group.
1130 This hook is intended to apply a kill file to the selected newsgroup.
1131 The function `gnus-apply-kill-file' is called by default.
1133 Since a general kill file is too heavy to use only for a few
1134 newsgroups, I recommend you to use a lighter hook function. For
1135 example, if you'd like to apply a kill file to articles which contains
1136 a string `rmgroup' in subject in newsgroup `control', you can use the
1139 \(setq gnus-apply-kill-hook
1142 (cond ((string-match \"control\" gnus-newsgroup-name)
1143 (gnus-kill \"Subject\" \"rmgroup\")
1144 (gnus-expunge \"X\"))))))")
1146 (defvar gnus-visual-mark-article-hook
1147 (list 'gnus-highlight-selected-summary)
1148 "*Hook run after selecting an article in the summary buffer.
1149 It is meant to be used for highlighting the article in some way. It
1150 is not run if `gnus-visual' is nil.")
1152 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1153 "*A hook called after preparing body, but before preparing header headers.
1154 The default hook (`gnus-inews-insert-signature') inserts a signature
1155 file specified by the variable `gnus-signature-file'.")
1157 (defvar gnus-exit-group-hook nil
1158 "*A hook called when exiting (not quitting) summary mode.")
1160 (defvar gnus-suspend-gnus-hook nil
1161 "*A hook called when suspending (not exiting) Gnus.")
1163 (defvar gnus-exit-gnus-hook nil
1164 "*A hook called when exiting Gnus.")
1166 (defvar gnus-save-newsrc-hook nil
1167 "*A hook called when saving the newsrc file.")
1169 (defvar gnus-summary-update-hook
1170 (list 'gnus-summary-highlight-line)
1171 "*A hook called when a summary line is changed.
1172 The hook will not be called if `gnus-visual' is nil.
1174 The default function `gnus-summary-highlight-line' will
1175 highlight the line according to the `gnus-summary-highlight'
1178 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1179 "*A hook called when an article is selected for the first time.
1180 The hook is intended to mark an article as read (or unread)
1181 automatically when it is selected.")
1183 ;; Remove any hilit infestation.
1184 (add-hook 'gnus-startup-hook
1186 (remove-hook 'gnus-summary-prepare-hook
1187 'hilit-rehighlight-buffer-quietly)
1188 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1189 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1190 (remove-hook 'gnus-article-prepare-hook
1191 'hilit-rehighlight-buffer-quietly)))
1195 ;; Internal variables
1197 ;; Avoid highlighting in kill files.
1198 (defvar gnus-summary-inhibit-highlight nil)
1199 (defvar gnus-newsgroup-selected-overlay nil)
1201 (defvar gnus-article-mode-map nil)
1202 (defvar gnus-dribble-buffer nil)
1203 (defvar gnus-headers-retrieved-by nil)
1204 (defvar gnus-article-reply nil)
1205 (defvar gnus-override-method nil)
1206 (defvar gnus-article-check-size nil)
1208 (defvar gnus-current-score-file nil)
1209 (defvar gnus-internal-global-score-files nil)
1210 (defvar gnus-score-file-list nil)
1213 (defvar gnus-current-move-group nil)
1215 (defvar gnus-newsgroup-dependencies nil)
1216 (defvar gnus-newsgroup-threads nil)
1217 (defvar gnus-newsgroup-async nil)
1218 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1220 (defvar gnus-newsgroup-adaptive nil)
1222 (defvar gnus-summary-display-table nil)
1224 (defconst gnus-group-line-format-alist
1225 (list (list ?M 'marked ?c)
1226 (list ?S 'subscribed ?c)
1228 (list ?N 'number ?s)
1229 (list ?I 'number-of-dormant ?d)
1230 (list ?T 'number-of-ticked ?d)
1231 (list ?R 'number-of-read ?s)
1232 (list ?t 'number-total ?d)
1233 (list ?y 'number-of-unread-unticked ?s)
1234 (list ?i 'number-of-ticked-and-dormant ?d)
1236 (list ?G 'qualified-group ?s)
1237 (list ?D 'newsgroup-description ?s)
1238 (list ?o 'moderated ?c)
1239 (list ?O 'moderated-string ?s)
1240 (list ?p 'process-marked ?c)
1241 (list ?s 'news-server ?s)
1242 (list ?n 'news-method ?s)
1243 (list ?z 'news-method-string ?s)
1244 (list ?u 'user-defined ?s)))
1246 (defconst gnus-summary-line-format-alist
1247 (list (list ?N 'number ?d)
1248 (list ?S 'subject ?s)
1249 (list ?s 'subject-or-nil ?s)
1251 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1253 (list ?a '(or (car (funcall gnus-extract-address-components from))
1256 (list ?x (macroexpand '(header-xref header)) ?s)
1257 (list ?D (macroexpand '(header-date header)) ?s)
1258 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1259 (list ?M (macroexpand '(header-id header)) ?s)
1260 (list ?r (macroexpand '(header-references header)) ?s)
1261 (list ?c '(or (header-chars header) 0) ?d)
1263 (list ?I 'indentation ?s)
1264 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1265 (list ?R 'replied ?c)
1266 (list ?\[ 'opening-bracket ?c)
1267 (list ?\] 'closing-bracket ?c)
1268 (list ?\> '(make-string level ? ) ?s)
1269 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1271 (list ?z 'score-char ?c)
1272 (list ?U 'unread ?c)
1273 (list ?t '(gnus-summary-number-of-articles-in-thread
1274 (and (boundp 'thread) (car thread)))
1276 (list ?e '(gnus-summary-number-of-articles-in-thread
1277 (and (boundp 'thread) (car thread)) t)
1279 (list ?u 'user-defined ?s))
1280 "An alist of format specifications that can appear in summary lines,
1281 and what variables they correspond with, along with the type of the
1282 variable (string, integer, character, etc).")
1284 (defconst gnus-summary-dummy-line-format-alist
1285 (list (list ?S 'subject ?s)
1286 (list ?N 'number ?d)
1287 (list ?u 'user-defined ?s)))
1289 (defconst gnus-summary-mode-line-format-alist
1290 (list (list ?G 'group-name ?s)
1291 (list ?g '(gnus-short-group-name group-name) ?s)
1292 (list ?A 'article-number ?d)
1293 (list ?Z 'unread-and-unselected ?s)
1294 (list ?V 'gnus-version ?s)
1295 (list ?U 'unread ?d)
1296 (list ?S 'subject ?s)
1297 (list ?e 'unselected ?d)
1298 (list ?u 'user-defined ?s)
1299 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1301 (defconst gnus-group-mode-line-format-alist
1302 (list (list ?S 'news-server ?s)
1303 (list ?M 'news-method ?s)
1304 (list ?u 'user-defined ?s)))
1306 (defvar gnus-have-read-active-file nil)
1308 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1309 "The mail address of the Gnus maintainers.")
1311 (defconst gnus-version "(ding) Gnus v0.99.6"
1312 "Version number for this version of Gnus.")
1314 (defvar gnus-info-nodes
1315 '((gnus-group-mode "(gnus)The Group Buffer")
1316 (gnus-summary-mode "(gnus)The Summary Buffer")
1317 (gnus-article-mode "(gnus)The Article Buffer"))
1318 "Assoc list of major modes and related Info nodes.")
1320 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1321 "The location of the (ding) Gnus documentation group.")
1323 (defvar gnus-group-buffer "*Group*")
1324 (defvar gnus-summary-buffer "*Summary*")
1325 (defvar gnus-article-buffer "*Article*")
1326 (defvar gnus-server-buffer "*Server*")
1328 (defvar gnus-work-buffer " *gnus work*")
1330 (defvar gnus-buffer-list nil
1331 "Gnus buffers that should be killed on exit.")
1333 (defvar gnus-server-alist nil
1334 "List of available servers.")
1336 (defvar gnus-variable-list
1337 '(gnus-newsrc-options gnus-newsrc-options-n
1338 gnus-newsrc-last-checked-date
1339 gnus-newsrc-alist gnus-server-alist
1340 gnus-killed-list gnus-zombie-list)
1341 "Gnus variables saved in the quick startup file.")
1343 (defvar gnus-overload-functions
1344 '((news-inews gnus-inews-news "rnewspost"))
1345 "Functions overloaded by gnus.
1346 It is a list of `(original overload &optional file)'.")
1348 (defvar gnus-newsrc-options nil
1349 "Options line in the .newsrc file.")
1351 (defvar gnus-newsrc-options-n nil
1352 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1354 (defvar gnus-newsrc-last-checked-date nil
1355 "Date Gnus last asked server for new newsgroups.")
1357 (defvar gnus-newsrc-alist nil
1358 "Assoc list of read articles.
1359 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1361 (defvar gnus-newsrc-hashtb nil
1362 "Hashtable of gnus-newsrc-alist.")
1364 (defvar gnus-killed-list nil
1365 "List of killed newsgroups.")
1367 (defvar gnus-killed-hashtb nil
1368 "Hash table equivalent of gnus-killed-list.")
1370 (defvar gnus-zombie-list nil
1371 "List of almost dead newsgroups.")
1373 (defvar gnus-description-hashtb nil
1374 "Descriptions of newsgroups.")
1376 (defvar gnus-list-of-killed-groups nil
1377 "List of newsgroups that have recently been killed by the user.")
1379 (defvar gnus-active-hashtb nil
1380 "Hashtable of active articles.")
1382 (defvar gnus-moderated-list nil
1383 "List of moderated newsgroups.")
1385 (defvar gnus-group-marked nil)
1387 (defvar gnus-current-startup-file nil
1388 "Startup file for the current host.")
1390 (defvar gnus-last-search-regexp nil
1391 "Default regexp for article search command.")
1393 (defvar gnus-last-shell-command nil
1394 "Default shell command on article.")
1396 (defvar gnus-current-select-method nil
1397 "The current method for selecting a newsgroup.")
1399 (defvar gnus-have-all-newsgroups nil)
1401 (defvar gnus-article-internal-prepare-hook nil)
1403 (defvar gnus-newsgroup-name nil)
1404 (defvar gnus-newsgroup-begin nil)
1405 (defvar gnus-newsgroup-end nil)
1406 (defvar gnus-newsgroup-last-rmail nil)
1407 (defvar gnus-newsgroup-last-mail nil)
1408 (defvar gnus-newsgroup-last-folder nil)
1409 (defvar gnus-newsgroup-last-file nil)
1410 (defvar gnus-newsgroup-auto-expire nil)
1411 (defvar gnus-newsgroup-active nil)
1413 (defvar gnus-newsgroup-unreads nil
1414 "List of unread articles in the current newsgroup.")
1416 (defvar gnus-newsgroup-unselected nil
1417 "List of unselected unread articles in the current newsgroup.")
1419 (defvar gnus-newsgroup-reads nil
1420 "Alist of read articles and article marks in the current newsgroup.")
1422 (defvar gnus-newsgroup-marked nil
1423 "List of ticked articles in the current newsgroup (a subset of unread art).")
1425 (defvar gnus-newsgroup-killed nil
1426 "List of ranges of articles that have been through the scoring process.")
1428 (defvar gnus-newsgroup-kill-headers nil)
1430 (defvar gnus-newsgroup-replied nil
1431 "List of articles that have been replied to in the current newsgroup.")
1433 (defvar gnus-newsgroup-expirable nil
1434 "List of articles in the current newsgroup that can be expired.")
1436 (defvar gnus-newsgroup-processable nil
1437 "List of articles in the current newsgroup that can be processed.")
1439 (defvar gnus-newsgroup-bookmarks nil
1440 "List of articles in the current newsgroup that have bookmarks.")
1442 (defvar gnus-newsgroup-dormant nil
1443 "List of dormant articles in the current newsgroup.")
1445 (defvar gnus-newsgroup-scored nil
1446 "List of scored articles in the current newsgroup.")
1448 (defvar gnus-newsgroup-headers nil
1449 "List of article headers in the current newsgroup.")
1450 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1452 (defvar gnus-newsgroup-ancient nil
1453 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1455 (defvar gnus-current-article nil)
1456 (defvar gnus-article-current nil)
1457 (defvar gnus-current-headers nil)
1458 (defvar gnus-have-all-headers nil)
1459 (defvar gnus-last-article nil)
1460 (defvar gnus-newsgroup-history nil)
1461 (defvar gnus-current-kill-article nil)
1463 ;; Save window configuration.
1464 (defvar gnus-prev-winconf nil)
1467 (defvar gnus-summary-line-format-spec nil)
1468 (defvar gnus-summary-dummy-line-format-spec nil)
1469 (defvar gnus-group-line-format-spec nil)
1470 (defvar gnus-summary-mode-line-format-spec nil)
1471 (defvar gnus-article-mode-line-format-spec nil)
1472 (defvar gnus-group-mode-line-format-spec nil)
1473 (defvar gnus-summary-mark-positions nil)
1474 (defvar gnus-group-mark-positions nil)
1476 (defvar gnus-summary-expunge-below nil)
1477 (defvar gnus-reffed-article-number nil)
1479 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1480 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1482 (defvar gnus-cache-removeable-articles nil)
1484 (defconst gnus-summary-local-variables
1485 '(gnus-newsgroup-name
1486 gnus-newsgroup-begin gnus-newsgroup-end
1487 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1488 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1489 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1490 gnus-newsgroup-unselected gnus-newsgroup-marked
1491 gnus-newsgroup-reads
1492 gnus-newsgroup-replied gnus-newsgroup-expirable
1493 gnus-newsgroup-processable gnus-newsgroup-killed
1494 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1495 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1496 gnus-current-article gnus-current-headers gnus-have-all-headers
1497 gnus-last-article gnus-article-internal-prepare-hook
1498 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1499 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1500 gnus-newsgroup-threads gnus-newsgroup-async
1501 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1502 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1503 gnus-newsgroup-history gnus-newsgroup-ancient
1504 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1505 gnus-cache-removeable-articles)
1506 "Variables that are buffer-local to the summary buffers.")
1508 (defconst gnus-bug-message
1509 "Sending a bug report to the Gnus Towers.
1510 ========================================
1512 The buffer below is a mail buffer. When you press `C-c C-c', it will
1513 be sent to the Gnus Bug Exterminators.
1515 At the bottom of the buffer you'll see lots of variable settings.
1516 Please do not delete those. They will tell the Bug People what your
1517 environment is, so that it will be easier to locate the bugs.
1519 If you have found a bug that makes Emacs go \"beep\", set
1520 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1521 and include the backtrace in your bug report.
1523 Please describe the bug in annoying, painstaking detail.
1525 Thank you for your help in stamping out bugs.
1528 ;;; End of variables.
1530 ;; Define some autoload functions Gnus might use.
1534 (autoload 'metamail-buffer "metamail")
1535 (autoload 'Info-goto-node "info")
1536 (autoload 'hexl-hex-string-to-integer "hexl")
1538 (autoload 'pp-to-string "pp")
1539 (autoload 'pp-eval-expression "pp")
1540 (autoload 'mail-extract-address-components "mail-extr")
1542 (autoload 'nnmail-split-fancy "nnmail")
1543 (autoload 'nnvirtual-catchup-group "nnvirtual")
1546 (autoload 'timezone-make-date-arpa-standard "timezone")
1547 (autoload 'timezone-fix-time "timezone")
1548 (autoload 'timezone-make-sortable-date "timezone")
1549 (autoload 'timezone-make-time-string "timezone")
1552 (autoload 'mail-position-on-field "sendmail")
1553 (autoload 'mail-setup "sendmail")
1554 (autoload 'rmail-output "rmailout")
1555 (autoload 'news-mail-other-window "rnewspost")
1556 (autoload 'news-reply-yank-original "rnewspost")
1557 (autoload 'news-caesar-buffer-body "rnewspost")
1558 (autoload 'rmail-insert-rmail-file-header "rmail")
1559 (autoload 'rmail-count-new-messages "rmail")
1560 (autoload 'rmail-show-message "rmail")
1563 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1564 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1565 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1566 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1567 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1568 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1569 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1572 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1573 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1574 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1575 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1576 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1577 (autoload 'gnus-Folder-save-name "gnus-mh")
1578 (autoload 'gnus-folder-save-name "gnus-mh")
1581 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1582 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1583 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1584 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1585 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1586 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1587 (autoload 'gnus-summary-highlight-line "gnus-vis")
1588 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1591 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1592 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1593 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1594 (autoload 'gnus-article-hide "gnus-vis" nil t)
1595 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1596 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1597 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1598 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1599 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1600 (autoload 'gnus-article-add-button "gnus-vis")
1603 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1604 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1605 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1608 (autoload 'gnus-kill "gnus-kill")
1609 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1610 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1611 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1612 (autoload 'gnus-execute "gnus-kill")
1613 (autoload 'gnus-expunge "gnus-kill")
1616 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1617 (autoload 'gnus-cache-save-buffers "gnus-cache")
1618 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1619 (autoload 'gnus-cache-request-article "gnus-cache")
1620 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1621 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1622 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1623 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1626 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1627 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1628 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1629 (autoload 'gnus-score-save "gnus-score")
1630 (autoload 'gnus-score-headers "gnus-score")
1631 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1632 (autoload 'gnus-score-adaptive "gnus-score")
1633 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1634 (autoload 'gnus-score-find-trace "gnus-score")
1637 (autoload 'gnus-score-customize "gnus-edit" nil t)
1640 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1641 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1642 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1643 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1644 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1645 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1646 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1647 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1648 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1649 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1650 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1651 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1652 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1653 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1654 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1655 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1656 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1657 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1658 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1659 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1660 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1661 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1664 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1665 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1666 (autoload 'gnus-group-mail "gnus-msg" nil t)
1667 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1668 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1669 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1670 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1671 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1672 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1673 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1674 (autoload 'gnus-post-news "gnus-msg" nil t)
1675 (autoload 'gnus-inews-news "gnus-msg" nil t)
1676 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1677 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1678 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1679 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1680 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1681 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1682 (autoload 'gnus-mail-yank-original "gnus-msg")
1683 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1684 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1685 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1686 (autoload 'gnus-article-mail-with-original "gnus-msg")
1687 (autoload 'gnus-article-mail "gnus-msg")
1688 (autoload 'gnus-bug "gnus-msg" nil t)
1691 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1692 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1693 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1694 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1695 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1696 (autoload 'gnus-yank-article "gnus-vm" nil t)
1702 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1703 ;; If you want the cursor to go somewhere else, set these two
1704 ;; functions in some startup hook to whatever you want.
1705 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1706 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1708 ;;; Various macros and substs.
1710 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1711 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1712 (` (let ((GnusStartBufferWindow (selected-window)))
1715 (pop-to-buffer (, buffer))
1717 (select-window GnusStartBufferWindow)))))
1719 (defmacro gnus-gethash (string hashtable)
1720 "Get hash value of STRING in HASHTABLE."
1721 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1722 ;;(` (abbrev-expansion (, string) (, hashtable)))
1723 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1725 (defmacro gnus-sethash (string value hashtable)
1726 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1727 ;; We cannot use define-abbrev since it only accepts string as value.
1728 ;; (set (intern string hashtable) value))
1729 (` (set (intern (, string) (, hashtable)) (, value))))
1731 (defsubst gnus-buffer-substring (beg end)
1732 (buffer-substring (match-beginning beg) (match-end end)))
1734 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1735 ;; function `substring' might cut on a middle of multi-octet
1737 (defun gnus-truncate-string (str width)
1738 (substring str 0 width))
1740 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1741 ;; to limit the length of a string. This function is necessary since
1742 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1743 (defsubst gnus-limit-string (str width)
1744 (if (> (length str) width)
1745 (substring str 0 width)
1748 (defsubst gnus-simplify-subject-re (subject)
1749 "Remove \"Re:\" from subject lines."
1750 (let ((case-fold-search t))
1751 (if (string-match "^re: *" subject)
1752 (substring subject (match-end 0))
1755 (defsubst gnus-goto-char (point)
1756 (and point (goto-char point)))
1758 (defmacro gnus-buffer-exists-p (buffer)
1760 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1763 (defmacro gnus-kill-buffer (buffer)
1764 (` (if (gnus-buffer-exists-p (, buffer))
1765 (kill-buffer (, buffer)))))
1767 (defsubst gnus-point-at-bol ()
1768 "Return point at the beginning of line."
1775 (defsubst gnus-point-at-eol ()
1776 "Return point at the beginning of line."
1783 ;; Delete the current line (and the next N lines.);
1784 (defmacro gnus-delete-line (&optional n)
1785 (` (delete-region (progn (beginning-of-line) (point))
1786 (progn (forward-line (, (or n 1))) (point)))))
1788 ;;; Load the compatability functions.
1794 ;;; Gnus Utility Functions
1797 (defun gnus-extract-address-components (from)
1799 ;; First find the address - the thing with the @ in it. This may
1800 ;; not be accurate in mail addresses, but does the trick most of
1801 ;; the time in news messages.
1802 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1803 (setq address (substring from (match-beginning 0) (match-end 0))))
1804 ;; Then we check whether the "name <address>" format is used.
1806 (string-match (concat "<" (regexp-quote address) ">") from)
1807 (and (setq name (substring from 0 (1- (match-beginning 0))))
1808 ;; Strip any quotes from the name.
1809 (string-match "\".*\"" name)
1810 (setq name (substring name 1 (1- (match-end 0))))))
1811 ;; If not, then "address (name)" is used.
1813 (and (string-match "(.+)" from)
1814 (setq name (substring from (1+ (match-beginning 0))
1815 (1- (match-end 0)))))
1816 (and (string-match "()" from)
1817 (setq name address))
1818 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1819 ;; XOVER might not support folded From headers.
1820 (and (string-match "(.*" from)
1821 (setq name (substring from (1+ (match-beginning 0))
1823 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1824 (list (or name from) (or address from))))
1826 (defun gnus-fetch-field (field)
1827 "Return the value of the header FIELD of current article."
1830 (let ((case-fold-search t))
1831 (gnus-narrow-to-headers)
1832 (mail-fetch-field field)))))
1834 (defun gnus-goto-colon ()
1836 (search-forward ":" (gnus-point-at-eol) t))
1838 (defun gnus-narrow-to-headers ()
1842 (goto-char (point-min))
1843 (if (search-forward "\n\n" nil t)
1847 (defvar gnus-old-specs nil)
1849 (defun gnus-update-format-specifications ()
1850 (gnus-make-thread-indent-array)
1852 (let ((formats '(summary summary-dummy group
1853 summary-mode group-mode article-mode))
1854 old-format new-format)
1856 (setq new-format (symbol-value
1857 (intern (format "gnus-%s-line-format" (car formats)))))
1858 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1859 (equal old-format new-format))
1860 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1864 (intern (format "gnus-%s-line-format-alist"
1865 (if (eq (car formats) 'article-mode)
1866 'summary-mode (car formats))))))))
1867 (setq gnus-old-specs (cons (cons (car formats) new-format)
1868 (delq (car formats) gnus-old-specs)))
1869 (setq formats (cdr formats))))
1871 (gnus-update-summary-mark-positions)
1873 (if (and (string-match "%D" gnus-group-line-format)
1874 (not gnus-description-hashtb)
1875 gnus-read-active-file)
1876 (gnus-read-all-descriptions-files)))
1878 (defun gnus-update-summary-mark-positions ()
1880 (let ((gnus-replied-mark 129)
1881 (gnus-score-below-mark 130)
1882 (gnus-score-over-mark 130)
1885 (gnus-set-work-buffer)
1886 (gnus-summary-insert-line
1887 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1888 (goto-char (point-min))
1889 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1891 (goto-char (point-min))
1892 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1893 (- (point) 2))) pos))
1894 (goto-char (point-min))
1895 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1896 (- (point) 2))) pos))
1897 (setq gnus-summary-mark-positions pos))))
1899 (defun gnus-update-group-mark-positions ()
1901 (let ((gnus-process-mark 128)
1902 (gnus-group-marked '("dummy.group")))
1903 (gnus-set-work-buffer)
1904 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1905 (goto-char (point-min))
1906 (setq gnus-group-mark-positions
1907 (list (cons 'process (and (search-forward "\200" nil t)
1908 (- (point) 2))))))))
1910 (defun gnus-mouse-face-function (form)
1911 (` (let ((string (, form)))
1912 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1915 (defun gnus-max-width-function (el max-width)
1916 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1917 (` (let* ((val (eval (, el)))
1918 (valstr (if (numberp val)
1919 (int-to-string val) val)))
1920 (if (> (length valstr) (, max-width))
1921 (substring valstr 0 (, max-width))
1924 (defun gnus-parse-format (format spec-alist)
1925 ;; This function parses the FORMAT string with the help of the
1926 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1927 ;; string. If the FORMAT string contains the specifiers %( and %)
1928 ;; the text between them will have the mouse-face text property.
1929 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1930 (if (and gnus-visual gnus-mouse-face)
1931 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1932 (button (substring format (match-beginning 2) (match-end 2)))
1933 (post (substring format (match-beginning 3) (match-end 3))))
1935 (gnus-parse-simple-format pre spec-alist)
1936 (gnus-mouse-face-function
1937 (gnus-parse-simple-format button spec-alist))
1938 (gnus-parse-simple-format post spec-alist)))
1939 (gnus-parse-simple-format
1940 (concat (substring format (match-beginning 1) (match-end 1))
1941 (substring format (match-beginning 2) (match-end 2))
1942 (substring format (match-beginning 3) (match-end 3)))
1944 (gnus-parse-simple-format format spec-alist)))
1946 (defun gnus-parse-simple-format (format spec-alist)
1947 ;; This function parses the FORMAT string with the help of the
1948 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1949 ;; string. The list will consist of the symbol `format', a format
1950 ;; specification string, and a list of forms depending on the
1953 spec flist fstring newspec elem beg)
1955 (gnus-set-work-buffer)
1957 (goto-char (point-min))
1958 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1959 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1961 ;; First check if there are any specs that look anything like
1962 ;; "%12,12A", ie. with a "max width specification". These have
1963 ;; to be treated specially.
1964 (if (setq beg (match-beginning 1))
1967 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1969 (setq beg (match-beginning 2)))
1970 ;; Find the specification from `spec-alist'.
1971 (if (not (setq elem (cdr (assq spec spec-alist))))
1972 (setq elem '("*" ?s)))
1973 ;; Treat user defined format specifiers specially
1974 (and (eq (car elem) 'user-defined)
1977 (list (intern (concat "gnus-user-format-function-"
1983 (delete-region (match-beginning 3) (match-end 3)))
1984 (if (not (zerop max-width))
1985 (let ((el (car elem)))
1986 (cond ((= (car (cdr elem)) ?c)
1987 (setq el (list 'char-to-string el)))
1988 ((= (car (cdr elem)) ?d)
1989 (numberp el) (setq el (list 'int-to-string el))))
1990 (setq flist (cons (gnus-max-width-function el max-width)
1993 (setq flist (cons (car elem) flist))
1994 (setq newspec (car (cdr elem))))
1995 ;; Remove the old specification (and possibly a ",12" string).
1996 (delete-region beg (match-end 2))
1997 ;; Insert the new specification.
2000 (setq fstring (buffer-substring 1 (point-max))))
2001 (cons 'format (cons fstring (nreverse flist)))))
2003 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2004 (defun gnus-read-init-file ()
2006 (or (and (file-exists-p gnus-init-file)
2007 ;; Don't try to load a directory.
2008 (not (file-directory-p gnus-init-file)))
2009 (file-exists-p (concat gnus-init-file ".el"))
2010 (file-exists-p (concat gnus-init-file ".elc")))
2011 (load gnus-init-file nil t)))
2013 (defun gnus-set-work-buffer ()
2014 (if (get-buffer gnus-work-buffer)
2016 (set-buffer gnus-work-buffer)
2018 (set-buffer (get-buffer-create gnus-work-buffer))
2019 (kill-all-local-variables)
2020 (buffer-disable-undo (current-buffer))
2021 (gnus-add-current-to-buffer-list)))
2023 ;; Article file names when saving.
2025 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2026 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2027 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2028 Otherwise, it is like ~/News/news/group/num."
2031 (concat (if (gnus-use-long-file-name 'not-save)
2032 (gnus-capitalize-newsgroup newsgroup)
2033 (gnus-newsgroup-directory-form newsgroup))
2034 "/" (int-to-string (header-number headers)))
2035 (or gnus-article-save-directory "~/News"))))
2037 (string-equal (file-name-directory default)
2038 (file-name-directory last-file))
2039 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2041 (or last-file default))))
2043 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2044 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2045 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2046 Otherwise, it is like ~/News/news/group/num."
2049 (concat (if (gnus-use-long-file-name 'not-save)
2051 (gnus-newsgroup-directory-form newsgroup))
2052 "/" (int-to-string (header-number headers)))
2053 (or gnus-article-save-directory "~/News"))))
2055 (string-equal (file-name-directory default)
2056 (file-name-directory last-file))
2057 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2059 (or last-file default))))
2061 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2062 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2063 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2064 Otherwise, it is like ~/News/news/group/news."
2067 (if (gnus-use-long-file-name 'not-save)
2068 (gnus-capitalize-newsgroup newsgroup)
2069 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2070 (or gnus-article-save-directory "~/News"))))
2072 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2073 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2074 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
2075 Otherwise, it is like ~/News/news/group/news."
2078 (if (gnus-use-long-file-name 'not-save)
2080 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2081 (or gnus-article-save-directory "~/News"))))
2083 ;; For subscribing new newsgroup
2085 (defun gnus-subscribe-hierarchical-interactive (groups)
2086 (let ((groups (sort groups 'string<))
2087 prefixes prefix start ans group starts)
2089 (setq prefixes (list "^"))
2090 (while (and groups prefixes)
2091 (while (not (string-match (car prefixes) (car groups)))
2092 (setq prefixes (cdr prefixes)))
2093 (setq prefix (car prefixes))
2094 (setq start (1- (length prefix)))
2095 (if (and (string-match "[^\\.]\\." (car groups) start)
2098 (concat "^" (substring (car groups) 0 (match-end 0))))
2099 (string-match prefix (car (cdr groups))))
2101 (setq prefixes (cons prefix prefixes))
2102 (message "Descend hierarchy %s? ([y]nsq): "
2103 (substring prefix 1 (1- (length prefix))))
2104 (setq ans (read-char))
2107 (string-match prefix
2108 (setq group (car groups))))
2109 (setq gnus-killed-list
2110 (cons group gnus-killed-list))
2111 (gnus-sethash group group gnus-killed-hashtb)
2112 (setq groups (cdr groups)))
2113 (setq starts (cdr starts)))
2116 (string-match prefix
2117 (setq group (car groups))))
2118 (gnus-sethash group group gnus-killed-hashtb)
2119 (gnus-subscribe-alphabetically (car groups))
2120 (setq groups (cdr groups)))
2121 (setq starts (cdr starts)))
2124 (setq group (car groups))
2125 (setq gnus-killed-list (cons group gnus-killed-list))
2126 (gnus-sethash group group gnus-killed-hashtb)
2127 (setq groups (cdr groups))))
2129 (message "Subscribe %s? ([n]yq)" (car groups))
2130 (setq ans (read-char))
2131 (setq group (car groups))
2133 (gnus-subscribe-alphabetically (car groups))
2134 (gnus-sethash group group gnus-killed-hashtb))
2137 (setq group (car groups))
2138 (setq gnus-killed-list (cons group gnus-killed-list))
2139 (gnus-sethash group group gnus-killed-hashtb)
2140 (setq groups (cdr groups))))
2142 (setq gnus-killed-list (cons group gnus-killed-list))
2143 (gnus-sethash group group gnus-killed-hashtb)))
2144 (setq groups (cdr groups)))))))
2146 (defun gnus-subscribe-randomly (newsgroup)
2147 "Subscribe new NEWSGROUP by making it the first newsgroup."
2148 (gnus-subscribe-newsgroup newsgroup))
2150 (defun gnus-subscribe-alphabetically (newgroup)
2151 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2152 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2153 (let ((groups (cdr gnus-newsrc-alist))
2155 (while (and (not before) groups)
2156 (if (string< newgroup (car (car groups)))
2157 (setq before (car (car groups)))
2158 (setq groups (cdr groups))))
2159 (gnus-subscribe-newsgroup newgroup before)))
2161 (defun gnus-subscribe-hierarchically (newgroup)
2162 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2163 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2165 (set-buffer (find-file-noselect gnus-current-startup-file))
2166 (let ((groupkey newgroup)
2168 (while (and (not before) groupkey)
2169 (goto-char (point-min))
2171 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2172 (while (and (re-search-forward groupkey-re nil t)
2174 (setq before (buffer-substring
2175 (match-beginning 1) (match-end 1)))
2176 (string< before newgroup)))))
2177 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2179 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2180 (substring groupkey (match-beginning 1) (match-end 1)))))
2181 (gnus-subscribe-newsgroup newgroup before))))
2183 (defun gnus-subscribe-interactively (newsgroup)
2184 "Subscribe new NEWSGROUP interactively.
2185 It is inserted in hierarchical newsgroup order if subscribed. If not,
2187 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2188 (gnus-subscribe-hierarchically newsgroup)
2189 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2191 (defun gnus-subscribe-zombies (newsgroup)
2192 "Make new NEWSGROUP a zombie group."
2193 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2195 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2196 "Subscribe new NEWSGROUP.
2197 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2198 the first newsgroup."
2199 ;; We subscribe the group by changing its level to `subscribed'.
2200 (gnus-group-change-level
2201 newsgroup gnus-level-default-subscribed
2202 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2203 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2207 (defun gnus-newsgroup-directory-form (newsgroup)
2208 "Make hierarchical directory name from NEWSGROUP name."
2209 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2210 (len (length newsgroup))
2212 ;; If this is a foreign group, we don't want to translate the
2214 (if (setq idx (string-match ":" newsgroup))
2215 (aset newsgroup idx ?/)
2217 ;; Replace all occurrences of `.' with `/'.
2219 (if (= (aref newsgroup idx) ?.)
2220 (aset newsgroup idx ?/))
2221 (setq idx (1+ idx)))
2224 (defun gnus-make-directory (dir)
2225 "Make DIRECTORY recursively."
2226 (let* ((dir (expand-file-name dir default-directory))
2228 (if (string-match "/$" dir)
2229 (setq dir (substring dir 0 (match-beginning 0))))
2230 (while (not (file-exists-p dir))
2231 (setq dirs (cons dir dirs))
2232 (string-match "/[^/]+$" dir)
2233 (setq dir (substring dir 0 (match-beginning 0))))
2235 (make-directory (car dirs))
2236 (setq dirs (cdr dirs)))))
2238 (defun gnus-capitalize-newsgroup (newsgroup)
2239 "Capitalize NEWSGROUP name."
2240 (and (not (zerop (length newsgroup)))
2241 (concat (char-to-string (upcase (aref newsgroup 0)))
2242 (substring newsgroup 1))))
2246 (defun gnus-simplify-subject (subject &optional re-only)
2247 "Remove `Re:' and words in parentheses.
2248 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2249 (let ((case-fold-search t)) ;Ignore case.
2250 ;; Remove `Re:' and `Re^N:'.
2251 (if (string-match "^re:[ \t]*" subject)
2252 (setq subject (substring subject (match-end 0))))
2253 ;; Remove words in parentheses from end.
2255 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2256 (setq subject (substring subject 0 (match-beginning 0)))))
2257 ;; Return subject string.
2260 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2262 (defun gnus-simplify-subject-fuzzy (subject)
2263 (let ((case-fold-search t))
2265 (gnus-set-work-buffer)
2267 (inline (gnus-simplify-buffer-fuzzy))
2270 (defun gnus-simplify-buffer-fuzzy ()
2271 (goto-char (point-min))
2272 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2273 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2275 (replace-match "" t t))
2276 (goto-char (point-min))
2277 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2278 (replace-match "" t t))
2279 (goto-char (point-min))
2280 (while (re-search-forward "[ \t]+" nil t)
2281 (replace-match " " t t))
2282 (goto-char (point-min))
2283 (while (re-search-forward "[ \t]+$" nil t)
2284 (replace-match "" t t))
2285 (goto-char (point-min))
2286 (while (re-search-forward "^[ \t]+" nil t)
2287 (replace-match "" t t))
2288 (if gnus-simplify-subject-fuzzy-regexp
2289 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2290 (replace-match "" t t))))
2292 ;; Add the current buffer to the list of buffers to be killed on exit.
2293 (defun gnus-add-current-to-buffer-list ()
2294 (or (memq (current-buffer) gnus-buffer-list)
2295 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2297 (defun gnus-string> (s1 s2)
2298 (not (or (string< s1 s2)
2301 ;; Functions accessing headers.
2302 ;; Functions are more convenient than macros in some cases.
2304 (defun gnus-header-number (header)
2305 (header-number header))
2307 (defun gnus-header-subject (header)
2308 (header-subject header))
2310 (defun gnus-header-from (header)
2311 (header-from header))
2313 (defun gnus-header-xref (header)
2314 (header-xref header))
2316 (defun gnus-header-lines (header)
2317 (header-lines header))
2319 (defun gnus-header-date (header)
2320 (header-date header))
2322 (defun gnus-header-id (header)
2325 (defun gnus-header-references (header)
2326 (header-references header))
2328 ;;; General various misc type functions.
2330 (defun gnus-clear-system ()
2331 "Clear all variables and buffers."
2332 ;; Clear Gnus variables.
2333 (let ((variables gnus-variable-list))
2335 (set (car variables) nil)
2336 (setq variables (cdr variables))))
2337 ;; Clear other internal variables.
2338 (setq gnus-list-of-killed-groups nil
2339 gnus-have-read-active-file nil
2340 gnus-newsrc-alist nil
2341 gnus-newsrc-hashtb nil
2342 gnus-killed-list nil
2343 gnus-zombie-list nil
2344 gnus-killed-hashtb nil
2345 gnus-active-hashtb nil
2346 gnus-moderated-list nil
2347 gnus-description-hashtb nil
2348 gnus-newsgroup-headers nil
2349 gnus-newsgroup-headers-hashtb-by-number nil
2350 gnus-newsgroup-name nil
2351 gnus-server-alist nil
2352 gnus-current-select-method nil)
2353 ;; Reset any score variables.
2354 (and (boundp 'gnus-score-cache)
2355 (set 'gnus-score-cache nil))
2356 (and (boundp 'gnus-internal-global-score-files)
2357 (set 'gnus-internal-global-score-files nil))
2358 ;; Kill the startup file.
2359 (and gnus-current-startup-file
2360 (get-file-buffer gnus-current-startup-file)
2361 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2362 ;; Save any cache buffers.
2363 (and gnus-use-cache (gnus-cache-save-buffers))
2364 ;; Clear the dribble buffer.
2365 (gnus-dribble-clear)
2366 ;; Kill global KILL file buffer.
2367 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2368 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2369 (gnus-kill-buffer nntp-server-buffer)
2370 ;; Kill Gnus buffers.
2371 (while gnus-buffer-list
2372 (gnus-kill-buffer (car gnus-buffer-list))
2373 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2375 (defun gnus-windows-old-to-new (setting)
2376 (if (symbolp setting)
2378 (cond ((eq setting 'SelectArticle)
2380 ((eq setting 'SelectSubject)
2382 ((eq setting 'SelectNewsgroup)
2385 (if (or (listp setting)
2386 (not (and gnus-window-configuration
2387 (memq setting '(group summary article)))))
2389 (let* ((setting (if (eq setting 'group)
2390 (if (assq 'newsgroup gnus-window-configuration)
2392 'newsgroups) setting))
2393 (elem (car (cdr (assq setting gnus-window-configuration))))
2394 (total (apply '+ elem))
2395 (types '(group summary article))
2396 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2401 (or (zerop (nth i elem))
2403 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2404 (setq out (cons (if (eq pbuf (nth i types))
2405 (vector (nth i types) perc 'point)
2406 (vector (nth i types) perc))
2409 (list (nreverse out)))))
2411 (defun gnus-add-configuration (conf)
2412 (setq gnus-buffer-configuration
2413 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2414 gnus-buffer-configuration))))
2416 (defun gnus-configure-windows (setting &optional force)
2417 (setq setting (gnus-windows-old-to-new setting))
2418 (let ((r (if (symbolp setting)
2419 (cdr (assq setting gnus-buffer-configuration))
2421 (in-buf (current-buffer))
2422 rule val w height hor ohor heights sub jump-buffer
2423 rel total to-buf all-visible)
2424 (or r (error "No such setting: %s" setting))
2426 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2427 ;; All the windows mentioned are already visibe, so we just
2428 ;; put point in the assigned buffer, and do not touch the
2430 (select-window (get-buffer-window all-visible))
2432 ;; Either remove all windows or just remove all Gnus windows.
2433 (if gnus-use-full-window
2434 (delete-other-windows)
2435 (gnus-remove-some-windows)
2436 (switch-to-buffer nntp-server-buffer))
2442 ;; We have to do the (possible) horizontal splitting before the
2444 (if (and (listp (car hor))
2445 (eq (car (car hor)) 'horizontal))
2449 (if (integerp (nth 1 (car hor)))
2451 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2453 (setq hor (cdr hor))))
2455 ;; Go through the rules and eval the elements that are to be
2458 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2460 ;; Expand short buffer name.
2461 (setq w (aref val 0))
2462 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2464 (setq val (apply 'vector (mapcar 'identity val)))
2466 (setq ohor (cons val ohor))))
2467 (setq hor (cdr hor)))
2468 (setq rule (cons (nreverse ohor) rule))
2470 (setq rule (nreverse rule))
2472 ;; We tally the window sizes.
2473 (setq total (window-height))
2475 (setq hor (car rule))
2476 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2477 (setq hor (cdr hor)))
2480 (setq rel (aref (car hor) 1)
2482 (cond ((and (floatp rel) (= 1.0 rel))
2487 (max (floor (* total rel)) 4)))
2489 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2491 (setq heights (nreverse heights)
2494 ;; We then go through these heighs and create windows for them.
2496 (setq height (car heights)
2497 heights (cdr heights))
2499 (setq height (- total sub)))
2501 (split-window nil height))
2502 (setq to-buf (aref (car hor) 0))
2507 (symbol-value (aref (car hor) 0)))
2509 (aref (car hor) 0))))
2510 (and (> (length (car hor)) 2)
2511 (eq (aref (car hor) 2) 'point)
2512 (setq jump-buffer (current-buffer)))
2514 (setq hor (cdr hor)))
2516 (setq rule (cdr rule)))
2518 ;; Finally, we pop to the buffer that's supposed to have point.
2519 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2521 (select-window (get-buffer-window jump-buffer))
2522 (set-buffer jump-buffer))))
2524 (defun gnus-all-windows-visible-p (rule)
2525 (let (invisible hor jump-buffer val buffer)
2526 ;; Go through the rules and eval the elements that are to be
2528 (while (and rule (not invisible))
2529 (setq hor (car rule)
2531 (while (and hor (not invisible))
2532 (if (setq val (if (vectorp (car hor))
2534 (if (not (eq (car (car hor)) 'horizontal))
2537 ;; Expand short buffer name.
2538 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2540 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2542 (and (> (length val) 2) (eq 'point (aref val 2))
2543 (setq jump-buffer buffer))
2544 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2545 (setq hor (cdr hor))))
2546 (and (not invisible) jump-buffer)))
2549 (defun gnus-remove-some-windows ()
2550 (let ((buffers gnus-window-to-buffer)
2554 ;; Remove windows on all known Gnus buffers.
2556 (setq buf (cdr (car buffers)))
2558 (setq buf (and (boundp buf) (symbol-value buf))))
2560 (get-buffer-window buf)
2565 (switch-to-buffer nntp-server-buffer)
2567 (delete-window (get-buffer-window buf)))))
2568 (setq buffers (cdr buffers)))
2569 ;; Remove windows on *all* summary buffers.
2573 (let ((buf (window-buffer win)))
2574 (if (string-match "^\\*Summary" (buffer-name buf))
2578 (switch-to-buffer nntp-server-buffer)
2580 (setq wins (cons win wins)))))))
2582 (delete-window (car wins))
2583 (setq wins (cdr wins)))))))
2586 (defun gnus-version ()
2587 "Version numbers of this version of Gnus."
2589 (let ((methods gnus-valid-select-methods)
2592 ;; Go through all the legal select methods and add their version
2593 ;; numbers to the total version string. Only the backends that are
2594 ;; currently in use will have their message numbers taken into
2597 (setq meth (intern (concat (car (car methods)) "-version")))
2599 (stringp (symbol-value meth))
2600 (setq mess (concat mess "; " (symbol-value meth))))
2601 (setq methods (cdr methods)))
2602 (gnus-message 2 mess)))
2604 (defun gnus-info-find-node ()
2605 "Find Info documentation of Gnus."
2607 ;; Enlarge info window if needed.
2608 (let ((mode major-mode))
2609 (gnus-configure-windows 'info)
2610 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2612 (defun gnus-overload-functions (&optional overloads)
2613 "Overload functions specified by optional argument OVERLOADS.
2614 If nothing is specified, use the variable gnus-overload-functions."
2616 (overloads (or overloads gnus-overload-functions)))
2618 (setq defs (car overloads))
2619 (setq overloads (cdr overloads))
2620 ;; Load file before overloading function if necessary. Make
2621 ;; sure we cannot use `require' always.
2622 (and (not (fboundp (car defs)))
2623 (car (cdr (cdr defs)))
2624 (load (car (cdr (cdr defs))) nil 'nomessage))
2625 (fset (car defs) (car (cdr defs))))))
2627 (defun gnus-replace-chars-in-string (string from to)
2628 "Replace characters in STRING from FROM to TO."
2629 (let ((string (substring string 0)) ;Copy string.
2630 (len (length string))
2632 ;; Replace all occurrences of FROM with TO.
2634 (if (= (aref string idx) from)
2635 (aset string idx to))
2636 (setq idx (1+ idx)))
2639 (defun gnus-days-between (date1 date2)
2640 ;; Return the number of days between date1 and date2.
2641 (- (gnus-day-number date1) (gnus-day-number date2)))
2643 (defun gnus-day-number (date)
2644 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2645 (timezone-parse-date date))))
2646 (timezone-absolute-from-gregorian
2647 (nth 1 dat) (nth 2 dat) (car dat))))
2649 ;; Returns a floating point number that says how many seconds have
2650 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2651 (defun gnus-seconds-since-epoch (date)
2652 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2653 (timezone-parse-date date)))
2654 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2655 (timezone-parse-time
2656 (aref (timezone-parse-date date) 3))))
2657 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2658 (timezone-parse-date "Jan 1 12:00:00 1970")))
2659 (tday (- (timezone-absolute-from-gregorian
2660 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2661 (timezone-absolute-from-gregorian
2662 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2664 (* (nth 1 ttime) 60)
2665 (* 1.0 (nth 0 ttime) 60 60)
2666 (* 1.0 tday 60 60 24))))
2668 (defun gnus-file-newer-than (file date)
2669 (let ((fdate (nth 5 (file-attributes file))))
2670 (or (> (car fdate) (car date))
2671 (and (= (car fdate) (car date))
2672 (> (nth 1 fdate) (nth 1 date))))))
2674 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2676 (defun gnus-y-or-n-p (prompt)
2681 (defun gnus-yes-or-no-p (prompt)
2683 (yes-or-no-p prompt)
2686 ;; Check whether to use long file names.
2687 (defun gnus-use-long-file-name (symbol)
2688 ;; The variable has to be set...
2689 (and gnus-use-long-file-name
2690 ;; If it isn't a list, then we return t.
2691 (or (not (listp gnus-use-long-file-name))
2692 ;; If it is a list, and the list contains `symbol', we
2694 (not (memq symbol gnus-use-long-file-name)))))
2696 ;; I suspect there's a better way, but I haven't taken the time to do
2697 ;; it yet. -erik selberg@cs.washington.edu
2698 (defun gnus-dd-mmm (messy-date)
2699 "Return a string like DD-MMM from a big messy string"
2700 (let ((datevec (timezone-parse-date messy-date)))
2702 (or (aref datevec 2) "??")
2705 (nth (1- (string-to-number (aref datevec 1)))
2706 timezone-months-assoc))
2709 ;; Make a hash table (default and minimum size is 255).
2710 ;; Optional argument HASHSIZE specifies the table size.
2711 (defun gnus-make-hashtable (&optional hashsize)
2712 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2714 ;; Make a number that is suitable for hashing; bigger than MIN and one
2716 (defun gnus-create-hash-size (min)
2722 ;; Show message if message has a lower level than `gnus-verbose'.
2723 ;; Guide-line for numbers:
2724 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2725 ;; for things that take a long time, 7 - not very important messages
2726 ;; on stuff, 9 - messages inside loops.
2727 (defun gnus-message (level &rest args)
2728 (if (<= level gnus-verbose)
2729 (apply 'message args)
2730 ;; We have to do this format thingie here even if the result isn't
2731 ;; shown - the return value has to be the same as the return value
2733 (apply 'format args)))
2735 ;; Generate a unique new group name.
2736 (defun gnus-generate-new-group-name (leaf)
2739 (while (gnus-gethash name gnus-newsrc-hashtb)
2740 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2743 (defun gnus-find-file-noselect (file &optional force)
2744 "Does vaguely the same as find-file-noselect. No hooks are run."
2746 (if (setq buf (get-file-buffer file))
2748 (setq buf (create-file-buffer file))
2755 (and (file-readable-p file)
2756 (insert-file-contents file))
2757 (set-visited-file-name file)
2758 (set-buffer-modified-p nil)
2759 (current-buffer)))))
2761 ;;; List and range functions
2763 (defun gnus-last-element (list)
2764 "Return last element of LIST."
2766 (setq list (cdr list)))
2769 (defun gnus-copy-sequence (list)
2770 "Do a complete, total copy of a list."
2771 (if (and (consp list) (not (consp (cdr list))))
2772 (cons (car list) (cdr list))
2773 (mapcar (lambda (elem) (if (consp elem)
2774 (if (consp (cdr elem))
2775 (gnus-copy-sequence elem)
2776 (cons (car elem) (cdr elem)))
2780 (defun gnus-set-difference (list1 list2)
2781 "Return a list of elements of LIST1 that do not appear in LIST2."
2782 (let ((list1 (copy-sequence list1)))
2784 (setq list1 (delq (car list2) list1))
2785 (setq list2 (cdr list2)))
2788 (defun gnus-sorted-complement (list1 list2)
2789 "Return a list of elements of LIST1 that do not appear in LIST2.
2790 Both lists have to be sorted over <."
2792 (if (or (null list1) (null list2))
2794 (while (and list1 list2)
2795 (cond ((= (car list1) (car list2))
2796 (setq list1 (cdr list1)
2798 ((< (car list1) (car list2))
2799 (setq out (cons (car list1) out))
2800 (setq list1 (cdr list1)))
2802 (setq out (cons (car list2) out))
2803 (setq list2 (cdr list2)))))
2804 (nconc (nreverse out) (or list1 list2)))))
2806 (defun gnus-intersection (list1 list2)
2809 (if (memq (car list2) list1)
2810 (setq result (cons (car list2) result)))
2811 (setq list2 (cdr list2)))
2814 (defun gnus-sorted-intersection (list1 list2)
2815 ;; LIST1 and LIST2 have to be sorted over <.
2817 (while (and list1 list2)
2818 (cond ((= (car list1) (car list2))
2819 (setq out (cons (car list1) out)
2822 ((< (car list1) (car list2))
2823 (setq list1 (cdr list1)))
2825 (setq list2 (cdr list2)))))
2828 (defun gnus-set-sorted-intersection (list1 list2)
2829 ;; LIST1 and LIST2 have to be sorted over <.
2830 ;; This function modifies LIST1.
2831 (let* ((top (cons nil list1))
2833 (while (and list1 list2)
2834 (cond ((= (car list1) (car list2))
2838 ((< (car list1) (car list2))
2839 (setcdr prev (cdr list1))
2840 (setq list1 (cdr list1)))
2842 (setq list2 (cdr list2)))))
2846 (defun gnus-compress-sequence (numbers &optional always-list)
2847 "Convert list of numbers to a list of ranges or a single range.
2848 If ALWAYS-LIST is non-nil, this function will always release a list of
2850 (let* ((first (car numbers))
2851 (last (car numbers))
2855 (if (not (listp (cdr numbers)))
2858 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2859 ((= (1+ last) (car numbers)) ;Still in sequence
2860 (setq last (car numbers)))
2861 (t ;End of one sequence
2863 (cons (if (= first last) first
2864 (cons first last)) result))
2865 (setq first (car numbers))
2866 (setq last (car numbers))))
2867 (setq numbers (cdr numbers)))
2868 (if (and (not always-list) (null result))
2869 (if (= first last) (list first) (cons first last))
2870 (nreverse (cons (if (= first last) first (cons first last))
2873 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2874 (defun gnus-uncompress-range (ranges)
2875 "Expand a list of ranges into a list of numbers.
2876 RANGES is either a single range on the form `(num . num)' or a list of
2878 (let (first last result)
2882 ((not (listp (cdr ranges)))
2883 (setq first (car ranges))
2884 (setq last (cdr ranges))
2885 (while (<= first last)
2886 (setq result (cons first result))
2887 (setq first (1+ first)))
2891 (if (atom (car ranges))
2892 (if (numberp (car ranges))
2893 (setq result (cons (car ranges) result)))
2894 (setq first (car (car ranges)))
2895 (setq last (cdr (car ranges)))
2896 (while (<= first last)
2897 (setq result (cons first result))
2898 (setq first (1+ first))))
2899 (setq ranges (cdr ranges)))
2900 (nreverse result)))))
2902 (defun gnus-add-to-range (ranges list)
2903 "Return a list of ranges that has all articles from both RANGES and LIST.
2904 Note: LIST has to be sorted over `<'."
2906 (gnus-compress-sequence list t)
2907 (setq list (copy-sequence list))
2908 (or (listp (cdr ranges))
2909 (setq ranges (list ranges)))
2911 ilist lowest highest temp)
2912 (while (and ranges list)
2914 (setq lowest (or (and (atom (car ranges)) (car ranges))
2915 (car (car ranges))))
2916 (while (and list (cdr list) (< (car (cdr list)) lowest))
2917 (setq list (cdr list)))
2918 (if (< (car ilist) lowest)
2921 (setq list (cdr list))
2923 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2924 (setq highest (or (and (atom (car ranges)) (car ranges))
2925 (cdr (car ranges))))
2926 (while (and list (<= (car list) highest))
2927 (setq list (cdr list)))
2928 (setq ranges (cdr ranges)))
2930 (setq out (nconc (gnus-compress-sequence list t) out)))
2931 (setq out (sort out (lambda (r1 r2)
2932 (< (or (and (atom r1) r1) (car r1))
2933 (or (and (atom r2) r2) (car r2))))))
2936 (if (atom (car ranges))
2938 (if (atom (car (cdr ranges)))
2939 (if (= (1+ (car ranges)) (car (cdr ranges)))
2941 (setcar ranges (cons (car ranges)
2942 (car (cdr ranges))))
2943 (setcdr ranges (cdr (cdr ranges)))))
2944 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2946 (setcar (car (cdr ranges)) (car ranges))
2947 (setcar ranges (car (cdr ranges)))
2948 (setcdr ranges (cdr (cdr ranges)))))))
2950 (if (atom (car (cdr ranges)))
2951 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2953 (setcdr (car ranges) (car (cdr ranges)))
2954 (setcdr ranges (cdr (cdr ranges)))))
2955 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2957 (setcdr (car ranges) (cdr (car (cdr ranges))))
2958 (setcdr ranges (cdr (cdr ranges))))))))
2959 (setq ranges (cdr ranges)))
2962 (defun gnus-remove-from-range (ranges list)
2963 "Return a list of ranges that has all articles from LIST removed from RANGES.
2964 Note: LIST has to be sorted over `<'."
2965 ;; !!! This function shouldn't look like this, but I've got a headache.
2966 (gnus-compress-sequence
2967 (gnus-sorted-complement
2968 (gnus-uncompress-range ranges) list)))
2970 (defun gnus-member-of-range (number ranges)
2971 (if (not (listp (cdr ranges)))
2972 (and (>= number (car ranges))
2973 (<= number (cdr ranges)))
2976 (if (numberp (car ranges))
2977 (>= number (car ranges))
2978 (>= number (car (car ranges))))
2980 (if (if (numberp (car ranges))
2981 (= number (car ranges))
2982 (and (>= number (car (car ranges)))
2983 (<= number (cdr (car ranges)))))
2984 (setq not-stop nil))
2985 (setq ranges (cdr ranges)))
2993 (defvar gnus-group-mode-map nil)
2994 (defvar gnus-group-group-map nil)
2995 (defvar gnus-group-mark-map nil)
2996 (defvar gnus-group-list-map nil)
2997 (defvar gnus-group-sub-map nil)
2998 (put 'gnus-group-mode 'mode-class 'special)
3000 (if gnus-group-mode-map
3002 (setq gnus-group-mode-map (make-keymap))
3003 (suppress-keymap gnus-group-mode-map)
3004 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3005 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3006 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3007 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3008 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3009 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3010 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3011 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3012 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3013 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
3014 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
3015 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3016 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3017 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3018 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3019 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3020 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3021 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3022 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3023 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3024 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3025 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3026 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3027 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3028 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3029 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3030 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3031 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3032 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3033 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3034 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3035 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3036 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3037 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3038 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3039 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3040 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3041 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3042 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3043 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3044 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3045 (define-key gnus-group-mode-map "V" 'gnus-version)
3046 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3047 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3048 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3049 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3050 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3051 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3052 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3053 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3054 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3055 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3056 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3057 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3058 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3059 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3060 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3062 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3063 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3064 (define-prefix-command 'gnus-group-mark-map)
3065 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3066 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3067 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3068 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3070 (define-prefix-command 'gnus-group-group-map)
3071 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3072 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3073 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3074 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3075 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3076 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3077 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3078 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3079 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3080 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3081 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3082 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3083 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3084 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3085 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3086 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3087 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3088 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3090 (define-prefix-command 'gnus-group-list-map)
3091 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3092 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3093 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3094 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3095 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3096 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3097 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3098 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3099 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3101 (define-prefix-command 'gnus-group-sub-map)
3102 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3103 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3104 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3105 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3106 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3107 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3108 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3109 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3111 (defun gnus-group-mode ()
3112 "Major mode for reading news.
3114 All normal editing commands are switched off.
3115 \\<gnus-group-mode-map>
3116 The group buffer lists (some of) the groups available. For instance,
3117 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3118 lists all zombie groups.
3120 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3121 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3123 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3125 The following commands are available:
3127 \\{gnus-group-mode-map}"
3129 (if gnus-visual (gnus-group-make-menu-bar))
3130 (kill-all-local-variables)
3131 (setq mode-line-modified "-- ")
3132 (make-local-variable 'mode-line-format)
3133 (setq mode-line-format (copy-sequence mode-line-format))
3134 (and (equal (nth 3 mode-line-format) " ")
3135 (setcar (nthcdr 3 mode-line-format) ""))
3136 (setq major-mode 'gnus-group-mode)
3137 (setq mode-name "Group")
3138 (gnus-group-set-mode-line)
3139 (setq mode-line-process nil)
3140 (use-local-map gnus-group-mode-map)
3141 (buffer-disable-undo (current-buffer))
3142 (setq truncate-lines t)
3143 (setq buffer-read-only t)
3144 (run-hooks 'gnus-group-mode-hook))
3146 (defun gnus-mouse-pick-group (e)
3149 (gnus-group-read-group nil))
3152 (defun gnus-no-server (&optional arg)
3154 If ARG is a positive number, Gnus will use that as the
3155 startup level. If ARG is nil, Gnus will be started at level 2.
3156 If ARG is non-nil and not a positive number, Gnus will
3157 prompt the user for the name of an NNTP server to use.
3158 As opposed to `gnus', this command will not connect to the local server."
3160 (setq gnus-group-use-permanent-levels t)
3161 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3163 (defalias '\(ding\) 'gnus)
3166 (defun gnus (&optional arg dont-connect)
3168 If ARG is non-nil and a positive number, Gnus will use that as the
3169 startup level. If ARG is non-nil and not a positive number, Gnus will
3170 prompt the user for the name of an NNTP server to use."
3172 (if (get-buffer gnus-group-buffer)
3174 (switch-to-buffer gnus-group-buffer)
3175 (gnus-group-get-new-news))
3177 (nnheader-init-server-buffer)
3178 (gnus-read-init-file)
3180 (let ((level (and arg (numberp arg) (> arg 0) arg))
3184 (gnus-group-setup-buffer)
3187 (gnus-start-news-server (and arg (not level))))))
3188 (if (and (not dont-connect)
3191 (run-hooks 'gnus-startup-hook)
3192 ;; NNTP server is successfully open.
3194 ;; Find the current startup file name.
3195 (setq gnus-current-startup-file
3196 (gnus-make-newsrc-file gnus-startup-file))
3198 ;; Read the dribble file.
3199 (and gnus-use-dribble-file (gnus-dribble-read-file))
3201 (gnus-update-format-specifications)
3202 (gnus-summary-make-display-table)
3203 (let ((buffer-read-only nil))
3205 (if (not gnus-inhibit-startup-message)
3207 (gnus-group-startup-message)
3209 (gnus-setup-news nil level)
3210 (gnus-group-list-groups level)
3211 (gnus-configure-windows 'group))))))
3213 (defun gnus-unload ()
3214 "Unload all Gnus features."
3216 (let ((history load-history)
3219 (and (string-match "^gnus" (car (car history)))
3220 (setq feature (cdr (assq 'provide (car history))))
3221 (unload-feature feature 'force))
3222 (setq history (cdr history)))))
3224 (defun gnus-group-startup-message (&optional x y)
3225 "Insert startup message in current buffer."
3226 ;; Insert the message.
3242 ;; And then hack it.
3243 ;; 18 is the longest line.
3244 (indent-rigidly (point-min) (point-max)
3245 (/ (max (- (window-width) (or x 28)) 0) 2))
3246 (goto-char (point-min))
3247 ;; +4 is fuzzy factor.
3248 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3251 (goto-char (point-min))
3252 (search-forward "Praxis")
3253 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3254 (goto-char (point-min)))
3256 (defun gnus-group-setup-buffer ()
3257 (or (get-buffer gnus-group-buffer)
3259 (switch-to-buffer gnus-group-buffer)
3260 (gnus-add-current-to-buffer-list)
3262 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3264 (defun gnus-group-list-groups (level &optional unread)
3265 "List newsgroups with level LEVEL or lower that have unread articles.
3266 Default is all subscribed groups.
3267 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3268 (interactive (list (and current-prefix-arg
3269 (prefix-numeric-value current-prefix-arg))))
3270 (if gnus-group-use-permanent-levels
3272 (setq gnus-group-default-list-level
3273 (or level gnus-group-default-list-level))
3274 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3275 (setq level (or level gnus-group-default-list-level
3276 gnus-level-subscribed)))
3277 (gnus-group-setup-buffer) ;May call from out of group buffer
3278 (let ((case-fold-search nil)
3279 (group (gnus-group-group-name)))
3280 (funcall gnus-group-prepare-function level unread nil)
3281 (if (zerop (buffer-size))
3282 (gnus-message 5 gnus-no-groups-message)
3283 (goto-char (point-min))
3285 ;; Go to the first group with unread articles.
3286 (gnus-group-search-forward nil nil nil t)
3287 ;; Find the right group to put point on. If the current group
3288 ;; has disapeared in the new listing, try to find the next
3289 ;; one. If no next one can be found, just leave point at the
3290 ;; first newsgroup in the buffer.
3291 (if (not (gnus-goto-char
3292 (text-property-any (point-min) (point-max)
3293 'gnus-group (intern group))))
3294 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3296 (not (gnus-goto-char
3298 (point-min) (point-max) 'gnus-group
3299 (intern (car (car newsrc)))))))
3300 (setq newsrc (cdr newsrc)))
3301 (or newsrc (progn (goto-char (point-max))
3302 (forward-line -1))))))
3303 ;; Adjust cursor point.
3304 (gnus-group-position-cursor))))
3306 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3307 "List all newsgroups with unread articles of level LEVEL or lower.
3308 If ALL is non-nil, list groups that have no unread articles.
3309 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3310 If REGEXP, only list groups matching REGEXP."
3311 (set-buffer gnus-group-buffer)
3312 (let ((buffer-read-only nil)
3313 (newsrc (cdr gnus-newsrc-alist))
3314 (lowest (or lowest 1))
3315 info clevel unread group)
3317 (if (< lowest gnus-level-zombie)
3318 ;; List living groups.
3320 (setq info (car newsrc)
3323 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3324 (and unread ; This group might be bogus
3326 (string-match regexp group))
3327 (<= (setq clevel (car (cdr info))) level)
3329 (or all ; We list all groups?
3330 (eq unread t) ; We list unactivated groups
3331 (> unread 0) ; We list groups with unread articles
3332 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3333 (gnus-group-insert-group-line
3334 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3336 ;; List dead groups.
3337 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3338 (gnus-group-prepare-flat-list-dead
3339 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3340 gnus-level-zombie ?Z
3342 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3343 (gnus-group-prepare-flat-list-dead
3344 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3345 gnus-level-killed ?K regexp))
3347 (gnus-group-set-mode-line)
3348 (setq gnus-have-all-newsgroups all)
3349 (run-hooks 'gnus-group-prepare-hook)))
3351 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3352 ;; List zombies and killed lists somehwat faster, which was
3353 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3354 ;; this by ignoring the group format specification altogether.
3357 (setq group (car groups)
3358 groups (cdr groups))
3359 (if (or (not regexp)
3360 (string-match regexp group))
3363 (insert (format " %c *: %s\n" mark group))
3364 (add-text-properties
3366 (list 'gnus-group (intern group)
3368 'gnus-level level)))))))
3370 (defun gnus-group-real-name (group)
3371 "Find the real name of a foreign newsgroup."
3372 (if (string-match ":[^:]+$" group)
3373 (substring group (1+ (match-beginning 0)))
3376 (defun gnus-group-prefixed-name (group method)
3377 "Return the whole name from GROUP and METHOD."
3378 (and (stringp method) (setq method (gnus-server-to-method method)))
3379 (concat (format "%s" (car method))
3381 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3382 (not (string= (nth 1 method) "")))
3383 (concat "+" (nth 1 method)))
3386 (defun gnus-group-real-prefix (group)
3387 "Return the prefix of the current group name."
3388 (if (string-match "^[^:]+:" group)
3389 (substring group 0 (match-end 0))
3392 (defun gnus-group-method-name (group)
3393 "Return the method used for selecting GROUP."
3394 (let ((prefix (gnus-group-real-prefix group)))
3395 (if (equal prefix "")
3397 (if (string-match "^[^\\+]+\\+" prefix)
3398 (list (intern (substring prefix 0 (1- (match-end 0))))
3399 (substring prefix (match-end 0) (1- (length prefix))))
3400 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3402 (defun gnus-group-foreign-p (group)
3403 "Return nil if GROUP is native, non-nil if it is foreign."
3404 (string-match ":" group))
3406 (defun gnus-group-set-info (info &optional method-only-group part)
3407 (let* ((entry (gnus-gethash
3408 (or method-only-group (car info)) gnus-newsrc-hashtb))
3410 (info (if method-only-group (nth 2 entry) info)))
3411 (if (not method-only-group)
3414 (error "Trying to change non-existent group %s" method-only-group))
3415 ;; We have recevied parts of the actual group info - either the
3416 ;; select method or the group parameters. We first check
3417 ;; whether we have to extend the info, and if so, do that.
3418 (let ((len (length info))
3419 (total (if (eq part 'method) 5 6)))
3421 (setcdr (nthcdr (1- len) info)
3422 (make-list (- total len) nil)))
3423 ;; Then we enter the new info.
3424 (setcar (nthcdr (1- total) info) part-info)))
3425 ;; We uncompress some lists of marked articles.
3427 (if (not (setq marked (nth 3 info)))
3430 (or (eq 'score (car (car marked)))
3431 (eq 'bookmark (car (car marked)))
3432 (eq 'killed (car (car marked)))
3433 (setcdr (car marked)
3434 (gnus-uncompress-range (cdr (car marked)))))
3435 (setq marked (cdr marked)))))
3438 ;; This is a new group, so we just create it.
3440 (set-buffer gnus-group-buffer)
3442 ;; It's a foreign group...
3443 (gnus-group-make-group
3444 (gnus-group-real-name (car info))
3445 (prin1-to-string (car (nth 4 info)))
3446 (nth 1 (nth 4 info)))
3447 ;; It's a native group.
3448 (gnus-group-make-group
3450 (prin1-to-string (car gnus-select-method))
3451 (nth 1 gnus-select-method)))
3452 (gnus-message 6 "Note: New group created")
3454 (gnus-gethash (gnus-group-prefixed-name
3455 (gnus-group-real-name (car info))
3456 (or (nth 4 info) gnus-select-method))
3457 gnus-newsrc-hashtb))))
3458 ;; Whether it was a new group or not, we now have the entry, so we
3459 ;; can do the update.
3462 (setcar (nthcdr 2 entry) info)
3463 (if (and (not (eq (car entry) t))
3464 (gnus-gethash (car info) gnus-active-hashtb))
3465 (let ((marked (nth 3 info)))
3467 (max 0 (- (length (gnus-list-of-unread-articles
3469 (length (cdr (assq 'tick marked)))
3470 (length (cdr (assq 'dormant marked)))))))))
3471 (error "No such group: %s" (car info)))))
3473 (defun gnus-group-set-method-info (group select-method)
3474 (gnus-group-set-info select-method group 'method))
3476 (defun gnus-group-set-params-info (group params)
3477 (gnus-group-set-info params group 'params))
3479 (defun gnus-group-update-group-line ()
3480 "This function updates the current line in the newsgroup buffer and
3481 moves the point to the colon."
3482 (let* ((buffer-read-only nil)
3483 (group (gnus-group-group-name))
3484 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3487 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3490 (delete-region (point) (progn (forward-line 1) (point)))
3491 (gnus-group-insert-group-line-info group)
3493 (gnus-group-position-cursor)))
3495 (defun gnus-group-insert-group-line-info (group)
3496 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3500 (setq info (nth 2 entry))
3501 (gnus-group-insert-group-line
3502 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3503 (setq active (gnus-gethash group gnus-active-hashtb))
3504 (gnus-group-insert-group-line
3506 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3507 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3509 (defun gnus-group-insert-group-line (gformat group level marked number method)
3510 (let* ((gformat (or gformat gnus-group-line-format-spec))
3511 (active (gnus-gethash group gnus-active-hashtb))
3512 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3513 (number-of-dormant (length (cdr (assq 'dormant marked))))
3514 (number-of-ticked (length (cdr (assq 'tick marked))))
3515 (number-of-ticked-and-dormant
3516 (+ number-of-ticked number-of-dormant))
3517 (number-of-unread-unticked
3518 (if (numberp number) (int-to-string (max 0 number))
3521 (if (numberp number)
3522 (max 0 (- number-total number))
3524 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3525 ((<= level gnus-level-unsubscribed) ?U)
3526 ((= level gnus-level-zombie) ?Z)
3528 (qualified-group (gnus-group-real-name group))
3529 (newsgroup-description
3530 (if gnus-description-hashtb
3531 (or (gnus-gethash group gnus-description-hashtb) "")
3533 (moderated (if (member group gnus-moderated-list) ?m ? ))
3534 (moderated-string (if (eq moderated ?m) "(m)" ""))
3535 (method (gnus-server-get-method group method))
3536 (news-server (or (car (cdr method)) ""))
3537 (news-method (or (car method) ""))
3539 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3543 (> number-of-ticked 0))
3545 (number (if (eq number t) "*" (+ number number-of-dormant
3547 (process-marked (if (member qualified-group gnus-group-marked)
3548 gnus-process-mark ? ))
3549 (buffer-read-only nil)
3550 header ; passed as parameter to user-funcs.
3555 (insert (eval gformat))
3557 (add-text-properties
3558 b (1+ b) (list 'gnus-group (intern group)
3559 'gnus-unread (if (numberp number)
3560 (string-to-int number-of-unread-unticked)
3563 'gnus-level level))))
3565 (defun gnus-group-update-group (group &optional visible-only)
3566 "Update newsgroup info of GROUP.
3567 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3569 (set-buffer gnus-group-buffer)
3570 (let ((buffer-read-only nil)
3572 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3575 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3577 ;; Buffer may be narrowed.
3580 ;; Search a line to modify. If the buffer is large, the search
3581 ;; takes long time. In most cases, current point is on the line
3582 ;; we are looking for. So, first of all, check current line.
3585 (eq (get-text-property (point) 'gnus-group)
3590 (point-min) (point-max) 'gnus-group (intern group)))))
3591 ;; GROUP is listed in current buffer. So, delete old line.
3595 (delete-region (point) (progn (forward-line 1) (point))))
3596 ;; No such line in the buffer, find out where it's supposed to
3597 ;; go, and insert it there (or at the end of the buffer).
3598 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3601 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3607 (point-min) (point-max)
3608 'gnus-group (intern (car (car entry)))))))
3609 (setq entry (cdr entry)))
3610 (or entry (goto-char (point-max)))))))
3611 (if (or visible (not visible-only))
3612 (gnus-group-insert-group-line-info group))
3613 (gnus-group-set-mode-line))))
3615 (defun gnus-group-set-mode-line ()
3616 (if (memq 'group gnus-updated-mode-lines)
3617 (let* ((gformat (or gnus-group-mode-line-format-spec
3618 (setq gnus-group-mode-line-format-spec
3620 gnus-group-mode-line-format
3621 gnus-group-mode-line-format-alist))))
3622 (news-server (car (cdr gnus-select-method)))
3623 (news-method (car gnus-select-method))
3625 (mode-string (eval gformat)))
3626 (setq mode-string (eval gformat))
3627 (if (> (length mode-string) max-len)
3628 (setq mode-string (substring mode-string 0 (- max-len 4))))
3629 (setq mode-line-buffer-identification mode-string)
3630 (set-buffer-modified-p t))))
3632 (defun gnus-group-group-name ()
3633 "Get the name of the newsgroup on the current line."
3634 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3635 (and group (symbol-name group))))
3637 (defun gnus-group-group-level ()
3638 "Get the level of the newsgroup on the current line."
3639 (get-text-property (gnus-point-at-bol) 'gnus-level))
3641 (defun gnus-group-group-unread ()
3642 "Get the number of unread articles of the newsgroup on the current line."
3643 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3645 (defun gnus-group-search-forward (&optional backward all level first-too)
3646 "Find the next newsgroup with unread articles.
3647 If BACKWARD is non-nil, find the previous newsgroup instead.
3648 If ALL is non-nil, just find any newsgroup.
3649 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3651 If FIRST-TOO, the current line is also eligible as a target."
3652 (let ((way (if backward -1 1))
3653 (low gnus-level-killed)
3656 (if (and backward (progn (beginning-of-line)) (bobp))
3658 (or first-too (forward-line way))
3666 (get-text-property (point) 'gnus-unread)))
3667 (or (eq unread t) (and unread (> unread 0))))
3668 (setq lev (get-text-property (point)
3670 (<= lev gnus-level-subscribed)))
3672 (and (setq lev (get-text-property (point)
3681 (zerop (forward-line way)))))
3683 (progn (gnus-group-position-cursor) t)
3684 (goto-char (or pos beg))
3687 ;;; Gnus group mode commands
3691 (defun gnus-group-mark-group (n &optional unmark no-advance)
3692 "Mark the current group."
3694 (let ((buffer-read-only nil)
3698 (setq group (gnus-group-group-name))
3702 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3707 (setq gnus-group-marked (delete group gnus-group-marked)))
3709 (setq gnus-group-marked
3710 (cons group (delete group gnus-group-marked))))
3712 (or no-advance (zerop (gnus-group-next-group 1))))
3714 (gnus-summary-position-cursor)
3717 (defun gnus-group-unmark-group (n)
3718 "Remove the mark from the current group."
3720 (gnus-group-mark-group n 'unmark))
3722 (defun gnus-group-mark-region (unmark beg end)
3723 "Mark all groups between point and mark.
3724 If UNMARK, remove the mark instead."
3725 (interactive "P\nr")
3726 (let ((num (count-lines beg end)))
3729 (- num (gnus-group-mark-group num unmark)))))
3731 (defun gnus-group-remove-mark (group)
3732 (and (gnus-group-goto-group group)
3734 (gnus-group-mark-group 1 'unmark t))))
3736 ;; Return a list of groups to work on. Take into consideration N (the
3737 ;; prefix) and the list of marked groups.
3738 (defun gnus-group-process-prefix (n)
3740 (setq n (prefix-numeric-value n))
3741 ;; There is a prefix, so we return a list of the N next
3743 (let ((way (if (< n 0) -1 1))
3748 (setq group (gnus-group-group-name)))
3749 (setq groups (cons group groups))
3751 (forward-line way)))
3754 ;; No prefix, but a list of marked articles.
3755 (reverse gnus-group-marked))
3757 ;; Neither marked articles or a prefix, so we return the
3759 (let ((group (gnus-group-group-name)))
3760 (and group (list group))))))
3762 ;; Selecting groups.
3764 (defun gnus-group-read-group (&optional all no-article group)
3765 "Read news in this newsgroup.
3766 If the prefix argument ALL is non-nil, already read articles become
3767 readable. If the optional argument NO-ARTICLE is non-nil, no article
3768 will be auto-selected upon group entry."
3770 (let ((group (or group (gnus-group-group-name)))
3771 number active marked entry)
3772 (or group (error "No group on current line"))
3774 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3775 ;; This group might be a dead group. In that case we have to get
3776 ;; the number of unread articles from `gnus-active-hashtb'.
3778 (setq number (car entry))
3779 (if (setq active (gnus-gethash group gnus-active-hashtb))
3780 (setq number (- (1+ (cdr active)) (car active)))))
3781 (gnus-summary-read-group
3782 group (or all (and (numberp number)
3783 (zerop (+ number (length (cdr (assq 'tick marked)))
3784 (length (cdr (assq 'dormant marked)))))))
3787 (defun gnus-group-select-group (&optional all)
3788 "Select this newsgroup.
3789 No article is selected automatically.
3790 If argument ALL is non-nil, already read articles become readable."
3792 (gnus-group-read-group all t))
3794 ;; Enter a group that is not in the group buffer. Non-nil is returned
3795 ;; if selection was successful.
3796 (defun gnus-group-read-ephemeral-group
3797 (group method &optional activate quit-config)
3798 (let ((group (if (gnus-group-foreign-p group) group
3799 (gnus-group-prefixed-name group method))))
3802 (list t nil (list group gnus-level-default-subscribed nil nil
3806 (if quit-config quit-config
3807 (cons (current-buffer) 'summary)))))))
3809 (set-buffer gnus-group-buffer)
3810 (or (gnus-server-opened method)
3811 (gnus-open-server method)
3812 (error "Unable to contact server: %s" (gnus-status-message method)))
3813 (if activate (or (gnus-request-group group)
3814 (error "Couldn't request group")))
3816 (gnus-group-read-group t t group)
3819 (not (equal major-mode 'gnus-group-mode))))
3821 (defun gnus-group-jump-to-group (group)
3822 "Jump to newsgroup GROUP."
3824 (list (completing-read
3825 "Group: " gnus-active-hashtb nil
3826 (memq gnus-select-method gnus-have-read-active-file))))
3828 (if (equal group "")
3829 (error "Empty group name"))
3831 (let ((b (text-property-any
3832 (point-min) (point-max) 'gnus-group (intern group))))
3834 ;; Either go to the line in the group buffer...
3836 ;; ... or insert the line.
3838 (gnus-gethash group gnus-active-hashtb)
3839 (gnus-activate-newsgroup group)
3840 (error "%s error: %s" group (gnus-status-message group)))
3842 (gnus-group-update-group group)
3843 (goto-char (text-property-any
3844 (point-min) (point-max) 'gnus-group (intern group)))))
3845 ;; Adjust cursor point.
3846 (gnus-group-position-cursor))
3848 (defun gnus-group-goto-group (group)
3849 "Goto to newsgroup GROUP."
3850 (let ((b (text-property-any (point-min) (point-max)
3851 'gnus-group (intern group))))
3852 (and b (goto-char b))))
3854 (defun gnus-group-next-group (n)
3855 "Go to next N'th newsgroup.
3856 If N is negative, search backward instead.
3857 Returns the difference between N and the number of skips actually
3860 (gnus-group-next-unread-group n t))
3862 (defun gnus-group-next-unread-group (n &optional all level)
3863 "Go to next N'th unread newsgroup.
3864 If N is negative, search backward instead.
3865 If ALL is non-nil, choose any newsgroup, unread or not.
3866 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3867 such group can be found, the next group with a level higher than
3869 Returns the difference between N and the number of skips actually
3872 (let ((backward (< n 0))
3875 (gnus-group-search-forward
3876 backward (or (not gnus-group-goto-unread) all) level))
3878 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3879 (if level " on this level or higher" "")))
3882 (defun gnus-group-prev-group (n)
3883 "Go to previous N'th newsgroup.
3884 Returns the difference between N and the number of skips actually
3887 (gnus-group-next-unread-group (- n) t))
3889 (defun gnus-group-prev-unread-group (n)
3890 "Go to previous N'th unread newsgroup.
3891 Returns the difference between N and the number of skips actually
3894 (gnus-group-next-unread-group (- n)))
3896 (defun gnus-group-next-unread-group-same-level (n)
3897 "Go to next N'th unread newsgroup on the same level.
3898 If N is negative, search backward instead.
3899 Returns the difference between N and the number of skips actually
3902 (gnus-group-next-unread-group n t (gnus-group-group-level))
3903 (gnus-group-position-cursor))
3905 (defun gnus-group-prev-unread-group-same-level (n)
3906 "Go to next N'th unread newsgroup on the same level.
3907 Returns the difference between N and the number of skips actually
3910 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3911 (gnus-group-position-cursor))
3913 (defun gnus-group-best-unread-group (&optional exclude-group)
3914 "Go to the group with the highest level.
3915 If EXCLUDE-GROUP, do not go to that group."
3917 (goto-char (point-min))
3920 (while (setq unread (get-text-property (point) 'gnus-unread))
3921 (if (and (numberp unread) (> unread 0))
3923 (if (and (< (get-text-property (point) 'gnus-level) best)
3924 (or (not exclude-group)
3925 (not (equal exclude-group (gnus-group-group-name)))))
3927 (setq best (get-text-property (point) 'gnus-level))
3928 (setq best-point (point))))))
3930 (if best-point (goto-char best-point))
3931 (gnus-summary-position-cursor)
3932 (and best-point (gnus-group-group-name))))
3934 (defun gnus-group-first-unread-group ()
3935 "Go to the first group with unread articles."
3937 (goto-char (point-min))
3938 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3939 (gnus-group-next-unread-group 1))
3940 (gnus-group-position-cursor))
3942 (defun gnus-group-enter-server-mode ()
3943 "Jump to the server buffer."
3945 (gnus-server-setup-buffer)
3946 (gnus-configure-windows 'server)
3947 (gnus-server-prepare))
3949 (defun gnus-group-make-group (name method &optional address)
3950 "Add a new newsgroup.
3951 The user will be prompted for a NAME, for a select METHOD, and an
3955 (read-string "Group name: ")
3958 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3960 (if (assoc method gnus-valid-select-methods)
3962 (if (memq 'prompt-address
3963 (assoc method gnus-valid-select-methods))
3964 (read-string "Address: ")
3966 (list method nil)))))
3968 (let* ((meth (if address (list (intern method) address) method))
3969 (nname (gnus-group-prefixed-name name meth))
3971 (and (gnus-gethash nname gnus-newsrc-hashtb)
3972 (error "Group %s already exists" nname))
3973 (gnus-group-change-level
3974 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3975 gnus-level-default-subscribed gnus-level-killed
3976 (and (gnus-group-group-name)
3977 (gnus-gethash (gnus-group-group-name)
3978 gnus-newsrc-hashtb))
3980 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
3982 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3983 (gnus-group-insert-group-line-info nname)
3985 (if (assoc method gnus-valid-select-methods)
3986 (require (intern method)))
3987 (and (gnus-check-backend-function 'request-create-group nname)
3988 (gnus-request-create-group nname))))
3990 (defun gnus-group-edit-group (group &optional part)
3991 "Edit the group on the current line."
3992 (interactive (list (gnus-group-group-name)))
3993 (let ((done-func '(lambda ()
3994 "Exit editing mode and update the information."
3996 (gnus-group-edit-group-done 'part 'group)))
3997 (part (or part 'info))
3998 (winconf (current-window-configuration))
4000 (or group (error "No group on current line"))
4001 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4002 (error "Killed group; can't be edited"))
4003 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4004 (gnus-configure-windows 'edit-group)
4005 (gnus-add-current-to-buffer-list)
4007 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4008 (use-local-map (copy-keymap emacs-lisp-mode-map))
4009 (local-set-key "\C-c\C-c" done-func)
4010 (make-local-variable 'gnus-prev-winconf)
4011 (setq gnus-prev-winconf winconf)
4012 ;; We modify the func to let it know what part it is editing.
4013 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4014 (setcar (cdr (cdr (nth 4 done-func))) group)
4019 ";; Type `C-c C-c' after editing the select method.\n\n")
4021 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4023 ";; Type `C-c C-c' after editing the group info.\n\n")))
4024 (let ((cinfo (gnus-copy-sequence info))
4026 (if (not (setq marked (nth 3 cinfo)))
4029 (or (eq 'score (car (car marked)))
4030 (eq 'bookmark (car (car marked)))
4031 (eq 'killed (car (car marked)))
4032 (not (numberp (car (cdr (car marked)))))
4033 (setcdr (car marked)
4034 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4035 (setq marked (cdr marked))))
4038 (cond ((eq part 'method)
4039 (or (nth 4 info) "native"))
4046 (defun gnus-group-edit-group-method (group)
4047 "Edit the select method of GROUP."
4048 (interactive (list (gnus-group-group-name)))
4049 (gnus-group-edit-group group 'method))
4051 (defun gnus-group-edit-group-parameters (group)
4052 "Edit the group parameters of GROUP."
4053 (interactive (list (gnus-group-group-name)))
4054 (gnus-group-edit-group group 'params))
4056 (defun gnus-group-edit-group-done (part group)
4057 "Get info from buffer, update variables and jump to the group buffer."
4058 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4059 (goto-char (point-min))
4060 (let ((form (read (current-buffer)))
4061 (winconf gnus-prev-winconf))
4063 (gnus-group-set-info form)
4064 (gnus-group-set-info form group part))
4065 (kill-buffer (current-buffer))
4066 (and winconf (set-window-configuration winconf))
4067 (set-buffer gnus-group-buffer)
4068 (gnus-group-update-group (gnus-group-group-name))
4069 (gnus-group-position-cursor)))
4071 (defun gnus-group-make-help-group ()
4072 "Create the (ding) Gnus documentation group."
4074 (let ((path load-path)
4076 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4077 "gnus-help" '(nndoc "gnus-help")))
4079 (error "Documentation group already exists"))
4081 (not (file-exists-p (concat (file-name-as-directory (car path))
4083 (setq path (cdr path)))
4084 (or path (error "Couldn't find doc group"))
4085 (gnus-group-make-group
4086 (gnus-group-real-name name)
4088 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4089 (list 'nndoc-article-type 'mbox))))
4090 (gnus-group-position-cursor))
4092 (defun gnus-group-make-doc-group (file type)
4093 "Create a group that uses a single file as the source."
4095 (list (read-file-name "File name: ")
4099 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4100 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4101 ((= char ?b) 'babyl)
4102 ((= char ?d) 'digest)
4103 (t (setq err (format "%c unknown. " char))
4106 (let* ((file (expand-file-name file))
4107 (name (gnus-generate-new-group-name
4108 (gnus-group-prefixed-name
4109 (file-name-nondirectory file) '(nndoc "")))))
4110 (gnus-group-make-group
4111 (gnus-group-real-name name)
4113 (list 'nndoc-address file)
4114 (list 'nndoc-article-type type)))))
4116 (defun gnus-group-make-archive-group ()
4117 "Create the (ding) Gnus archive group."
4119 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
4121 (error "Archive group already exists"))
4122 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
4123 (gnus-group-position-cursor))
4125 (defun gnus-group-make-directory-group (dir)
4126 "Create an nndir group.
4127 The user will be prompted for a directory. The contents of this
4128 directory will be used as a newsgroup. The directory should contain
4129 mail messages or news articles in files that have numeric names."
4131 (list (read-file-name "Create group from directory: ")))
4132 (or (file-exists-p dir) (error "No such directory"))
4133 (or (file-directory-p dir) (error "Not a directory"))
4134 (gnus-group-make-group dir "nndir" dir)
4135 (gnus-group-position-cursor))
4137 (defun gnus-group-make-kiboze-group (group address scores)
4138 "Create an nnkiboze group.
4139 The user will be prompted for a name, a regexp to match groups, and
4140 score file entries for articles to include in the group."
4143 (read-string "nnkiboze group name: ")
4144 (read-string "Source groups (regexp): ")
4145 (let ((headers (mapcar (lambda (group) (list group))
4146 '("subject" "from" "number" "date" "message-id"
4147 "references" "chars" "lines" "xref")))
4148 scores header regexp regexps)
4149 (while (not (equal "" (setq header (completing-read
4150 "Match on header: " headers nil t))))
4152 (while (not (equal "" (setq regexp (read-string
4153 (format "Match on %s (string): "
4155 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4156 (setq scores (cons (cons header regexps) scores)))
4158 (gnus-group-make-group group "nnkiboze" address)
4160 (gnus-set-work-buffer)
4161 (let (emacs-lisp-mode-hook)
4162 (pp scores (current-buffer)))
4163 (write-region (point-min) (point-max)
4164 (concat (or gnus-kill-files-directory "~/News")
4165 "nnkiboze:" group "." gnus-score-file-suffix)))
4166 (gnus-group-position-cursor))
4168 (defun gnus-group-add-to-virtual (n vgroup)
4169 "Add the current group to a virtual group."
4171 (list current-prefix-arg
4172 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4174 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4175 (error "%s is not an nnvirtual group" vgroup))
4176 (let* ((groups (gnus-group-process-prefix n))
4177 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4178 (setcar (cdr method)
4180 (nth 1 method) "\\|"
4183 (gnus-group-remove-mark s)
4184 (concat "\\(^" (regexp-quote s) "$\\)"))
4186 (gnus-group-position-cursor))
4188 (defun gnus-group-make-empty-virtual (group)
4189 "Create a new, fresh, empty virtual group."
4190 (interactive "sCreate new, empty virtual group: ")
4191 (let* ((method (list 'nnvirtual "^$"))
4192 (pgroup (gnus-group-prefixed-name group method)))
4193 ;; Check whether it exists already.
4194 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4195 (error "Group %s already exists." pgroup))
4196 ;; Subscribe the new group after the group on the current line.
4197 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4198 (gnus-group-update-group pgroup)
4200 (gnus-group-position-cursor)))
4202 (defun gnus-group-enter-directory (dir)
4203 "Enter an ephemeral nneething group."
4204 (interactive "DDirectory to read: ")
4205 (let* ((method (list 'nneething dir))
4206 (leaf (gnus-group-prefixed-name
4207 (file-name-nondirectory (directory-file-name dir))
4209 (name (gnus-generate-new-group-name leaf)))
4210 (let ((nneething-read-only t))
4211 (or (gnus-group-read-ephemeral-group
4213 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4215 (error "Couldn't enter %s" dir)))))
4217 ;; Group sorting commands
4218 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4220 (defun gnus-group-sort-groups ()
4221 "Sort the group buffer using `gnus-group-sort-function'."
4223 (setq gnus-newsrc-alist
4224 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4225 (gnus-make-hashtable-from-newsrc-alist)
4226 (gnus-group-list-groups (if gnus-have-all-newsgroups gnus-level-unsubscribed)
4227 gnus-have-all-newsgroups))
4229 (defun gnus-group-sort-by-alphabet (info1 info2)
4230 (string< (car info1) (car info2)))
4232 (defun gnus-group-sort-by-unread (info1 info2)
4233 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4234 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4235 (< (or (and (numberp n1) n1) 0)
4236 (or (and (numberp n2) n2) 0))))
4238 (defun gnus-group-sort-by-level (info1 info2)
4239 (< (nth 1 info1) (nth 1 info2)))
4241 ;; Group catching up.
4243 (defun gnus-group-catchup-current (&optional n all)
4244 "Mark all articles not marked as unread in current newsgroup as read.
4245 If prefix argument N is numeric, the ARG next newsgroups will be
4246 caught up. If ALL is non-nil, marked articles will also be marked as
4247 read. Cross references (Xref: header) of articles are ignored.
4248 The difference between N and actual number of newsgroups that were
4249 caught up is returned."
4251 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4255 "Do you really want to mark all articles as read? "
4256 "Mark all unread articles as read? "))))
4258 (let ((groups (gnus-group-process-prefix n))
4261 ;; Virtual groups have to be given special treatment.
4262 (let ((method (gnus-find-method-for-group (car groups))))
4263 (if (eq 'nnvirtual (car method))
4264 (nnvirtual-catchup-group
4265 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4266 (gnus-group-remove-mark (car groups))
4268 (gnus-group-goto-group (car groups))
4269 (gnus-group-catchup (car groups) all))
4270 (gnus-group-update-group-line)
4271 (setq ret (1+ ret)))
4272 (setq groups (cdr groups)))
4273 (gnus-group-next-unread-group 1)
4276 (defun gnus-group-catchup-current-all (&optional n)
4277 "Mark all articles in current newsgroup as read.
4278 Cross references (Xref: header) of articles are ignored."
4280 (gnus-group-catchup-current n 'all))
4282 (defun gnus-group-catchup (group &optional all)
4283 "Mark all articles in GROUP as read.
4284 If ALL is non-nil, all articles are marked as read.
4285 The return value is the number of articles that were marked as read,
4286 or nil if no action could be taken."
4287 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4289 (marked (nth 3 (nth 2 entry))))
4290 (if (not (numberp (car entry)))
4291 (gnus-message 1 "Can't catch up; non-active group")
4292 ;; Do the updating only if the newsgroup isn't killed.
4295 (gnus-update-read-articles
4296 group (and (not all) (append (cdr (assq 'tick marked))
4297 (cdr (assq 'dormant marked))))
4298 nil (and (not all) (cdr (assq 'tick marked))))
4300 (setcar (nthcdr 3 (nth 2 entry))
4301 (delq (assq 'dormant marked)
4302 (nth 3 (nth 2 entry)))))))
4305 (defun gnus-group-expire-articles (&optional n)
4306 "Expire all expirable articles in the current newsgroup."
4308 (let ((groups (gnus-group-process-prefix n))
4310 (or groups (error "No groups to expire"))
4312 (setq group (car groups)
4313 groups (cdr groups))
4314 (gnus-group-remove-mark group)
4315 (if (not (gnus-check-backend-function 'request-expire-articles group))
4317 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4318 (expirable (if (memq 'total-expire (nth 5 info))
4319 (cons nil (gnus-list-of-read-articles group))
4320 (assq 'expire (nth 3 info)))))
4323 (gnus-request-expire-articles
4324 (cdr expirable) group))))))))
4326 (defun gnus-group-expire-all-groups ()
4327 "Expire all expirable articles in all newsgroups."
4330 (gnus-message 5 "Expiring...")
4331 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4332 (cdr gnus-newsrc-alist))))
4333 (gnus-group-expire-articles nil)))
4334 (gnus-group-position-cursor)
4335 (gnus-message 5 "Expiring...done"))
4337 (defun gnus-group-set-current-level (n level)
4338 "Set the level of the next N groups to LEVEL."
4339 (interactive "P\nnLevel: ")
4340 (or (and (>= level 1) (<= level gnus-level-killed))
4341 (error "Illegal level: %d" level))
4342 (let ((groups (gnus-group-process-prefix n))
4345 (setq group (car groups)
4346 groups (cdr groups))
4347 (gnus-group-remove-mark group)
4348 (gnus-message 6 "Changed level of %s from %d to %d"
4349 group (gnus-group-group-level) level)
4350 (gnus-group-change-level group level
4351 (gnus-group-group-level))
4352 (gnus-group-update-group-line)))
4353 (gnus-group-position-cursor))
4355 (defun gnus-group-unsubscribe-current-group (&optional n)
4356 "Toggle subscription of the current group.
4357 If given numerical prefix, toggle the N next groups."
4359 (let ((groups (gnus-group-process-prefix n))
4362 (setq group (car groups)
4363 groups (cdr groups))
4364 (gnus-group-remove-mark group)
4365 (gnus-group-unsubscribe-group
4366 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4367 gnus-level-default-unsubscribed
4368 gnus-level-default-subscribed))
4369 (gnus-group-update-group-line))
4370 (gnus-group-next-group 1)))
4372 (defun gnus-group-unsubscribe-group (group &optional level)
4373 "Toggle subscribe from/to unsubscribe GROUP.
4374 New newsgroup is added to .newsrc automatically."
4376 (list (completing-read
4377 "Group: " gnus-active-hashtb nil
4378 (memq gnus-select-method gnus-have-read-active-file))))
4379 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4381 ;; Toggle subscription flag.
4382 (gnus-group-change-level
4383 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4384 gnus-level-subscribed)
4385 (1+ gnus-level-subscribed)
4386 gnus-level-default-subscribed)))
4387 (gnus-group-update-group group))
4388 ((and (stringp group)
4389 (or (not gnus-have-read-active-file)
4390 (gnus-gethash group gnus-active-hashtb)))
4391 ;; Add new newsgroup.
4392 (gnus-group-change-level
4394 (if level level gnus-level-default-subscribed)
4395 (or (and (member group gnus-zombie-list)
4398 (and (gnus-group-group-name)
4399 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4400 (gnus-group-update-group group))
4401 (t (error "No such newsgroup: %s" group)))
4402 (gnus-group-position-cursor)))
4404 (defun gnus-group-transpose-groups (n)
4405 "Move the current newsgroup up N places.
4406 If given a negative prefix, move down instead. The difference between
4407 N and the number of steps taken is returned."
4409 (or (gnus-group-group-name)
4410 (error "No group on current line"))
4411 (gnus-group-kill-group 1)
4413 (forward-line (- n))
4414 (gnus-group-yank-group)
4415 (gnus-group-position-cursor)))
4417 (defun gnus-group-kill-all-zombies ()
4418 "Kill all zombie newsgroups."
4420 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4421 (setq gnus-zombie-list nil)
4422 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4423 (goto-char (point-min))
4424 (gnus-group-position-cursor))
4426 (defun gnus-group-kill-region (begin end)
4427 "Kill newsgroups in current region (excluding current point).
4428 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4443 (beginning-of-line) ;Important when LINES < 1
4444 (gnus-group-kill-group lines)))
4446 (defun gnus-group-kill-group (&optional n)
4447 "The the next N groups.
4448 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4449 However, only groups that were alive can be yanked; already killed
4450 groups or zombie groups can't be yanked.
4451 The return value is the name of the (last) group that was killed."
4453 (let ((buffer-read-only nil)
4454 (groups (gnus-group-process-prefix n))
4457 (setq group (car groups)
4458 groups (cdr groups))
4459 (gnus-group-remove-mark group)
4460 (setq level (gnus-group-group-level))
4462 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4463 (setq gnus-list-of-killed-groups
4464 (cons (cons (car entry) (nth 2 entry))
4465 gnus-list-of-killed-groups)))
4466 (gnus-group-change-level
4467 (if entry entry group) gnus-level-killed (if entry nil level)))
4468 (gnus-group-position-cursor)
4471 (defun gnus-group-yank-group (&optional arg)
4472 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4473 inserting it before the current newsgroup. The numeric ARG specifies
4474 how many newsgroups are to be yanked. The name of the (last)
4475 newsgroup yanked is returned."
4477 (if (not arg) (setq arg 1))
4478 (let (info group prev)
4479 (while (>= (setq arg (1- arg)) 0)
4480 (if (not (setq info (car gnus-list-of-killed-groups)))
4481 (error "No more newsgroups to yank"))
4482 (setq group (nth 2 info))
4483 ;; Find which newsgroup to insert this one before - search
4484 ;; backward until something suitable is found. If there are no
4485 ;; other newsgroups in this buffer, just make this newsgroup the
4487 (setq prev (gnus-group-group-name))
4488 (gnus-group-change-level
4489 info (nth 2 info) gnus-level-killed
4490 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4492 (gnus-group-insert-group-line-info (nth 1 info))
4493 (setq gnus-list-of-killed-groups
4494 (cdr gnus-list-of-killed-groups)))
4496 (gnus-group-position-cursor)
4499 (defun gnus-group-list-all-groups (&optional arg)
4500 "List all newsgroups with level ARG or lower.
4501 Default is gnus-level-unsubscribed, which lists all subscribed and most
4502 unsubscribed groups."
4504 (setq arg (or arg gnus-level-unsubscribed))
4505 (gnus-group-list-groups arg t))
4507 (defun gnus-group-list-killed ()
4508 "List all killed newsgroups in the group buffer."
4510 (if (not gnus-killed-list)
4511 (gnus-message 6 "No killed groups")
4512 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4513 (goto-char (point-min)))
4514 (gnus-group-position-cursor))
4516 (defun gnus-group-list-zombies ()
4517 "List all zombie newsgroups in the group buffer."
4519 (if (not gnus-zombie-list)
4520 (gnus-message 6 "No zombie groups")
4521 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4522 (goto-char (point-min)))
4523 (gnus-group-position-cursor))
4525 (defun gnus-group-get-new-news (&optional arg)
4526 "Get newly arrived articles.
4527 If ARG is non-nil, it should be a number between one and nine to
4528 specify which levels you are interested in re-scanning."
4530 (run-hooks 'gnus-get-new-news-hook)
4531 (if gnus-group-use-permanent-levels
4533 (setq gnus-group-default-list-level
4534 (or arg gnus-group-default-list-level
4535 gnus-level-subscribed))))
4536 (if (and gnus-read-active-file (not arg))
4538 (gnus-read-active-file)
4539 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4540 (let ((gnus-read-active-file (not arg))
4541 (gnus-have-read-active-file
4542 (and (not arg) gnus-have-read-active-file)))
4543 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4544 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels arg)
4545 gnus-group-default-list-level
4546 gnus-level-subscribed)
4547 gnus-have-all-newsgroups))
4549 (defun gnus-group-get-new-news-this-group (&optional n)
4550 "Check for newly arrived news in the current group (and the N-1 next groups).
4551 The difference between N and the number of newsgroup checked is returned.
4552 If N is negative, this group and the N-1 previous groups will be checked."
4554 (let* ((groups (gnus-group-process-prefix n))
4555 (ret (if (numberp n) (- n (length groups)) 0))
4558 (setq group (car groups)
4559 groups (cdr groups))
4560 (gnus-group-remove-mark group)
4561 (or (gnus-get-new-news-in-group group)
4564 (message "%s error: %s" group (gnus-status-message group))
4566 ;; !!! I don't know why the buffer scrolls forward when updating
4567 ;; the first line in the group buffer, but it does. So we set the
4568 ;; window start forcibly.
4569 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4570 (gnus-group-next-unread-group 1 t)
4571 (gnus-summary-position-cursor)
4574 (defun gnus-get-new-news-in-group (group)
4576 (gnus-activate-newsgroup group)
4578 (gnus-get-unread-articles-in-group
4579 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4580 (gnus-gethash group gnus-active-hashtb))
4581 (gnus-group-update-group-line)
4584 (defun gnus-group-fetch-faq (group)
4585 "Fetch the FAQ for the current group."
4586 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4587 (or group (error "No group name given"))
4588 (let ((file (concat gnus-group-faq-directory group)))
4589 (if (not (file-exists-p file))
4590 (error "No such file: %s" file)
4593 (defun gnus-group-describe-group (force &optional group)
4594 "Display a description of the current newsgroup."
4595 (interactive (list current-prefix-arg (gnus-group-group-name)))
4596 (and force (setq gnus-description-hashtb nil))
4597 (let ((method (gnus-find-method-for-group group))
4599 (or group (error "No group name given"))
4600 (and (or (and gnus-description-hashtb
4601 ;; We check whether this group's method has been
4602 ;; queried for a description file.
4604 (gnus-group-prefixed-name "" method)
4605 gnus-description-hashtb))
4606 (setq desc (gnus-group-get-description group))
4607 (gnus-read-descriptions-file method))
4609 (or desc (gnus-gethash group gnus-description-hashtb)
4610 "No description available")))))
4612 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4613 (defun gnus-group-describe-all-groups (&optional force)
4614 "Pop up a buffer with descriptions of all newsgroups."
4616 (and force (setq gnus-description-hashtb nil))
4617 (if (not (or gnus-description-hashtb
4618 (gnus-read-all-descriptions-files)))
4619 (error "Couldn't request descriptions file"))
4620 (let ((buffer-read-only nil)
4626 (insert (format " *: %-20s %s\n" (symbol-name group)
4627 (symbol-value group)))
4628 (add-text-properties
4629 b (1+ b) (list 'gnus-group group
4630 'gnus-unread t 'gnus-marked nil
4631 'gnus-level (1+ gnus-level-subscribed))))
4632 gnus-description-hashtb)
4633 (goto-char (point-min))
4634 (gnus-group-position-cursor)))
4636 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4637 (defun gnus-group-apropos (regexp &optional search-description)
4638 "List all newsgroups that have names that match a regexp."
4639 (interactive "sGnus apropos (regexp): ")
4641 (obuf (current-buffer))
4643 ;; Go through all newsgroups that are known to Gnus.
4646 (and (symbol-name group)
4647 (string-match regexp (symbol-name group))
4648 (setq groups (cons (symbol-name group) groups))))
4650 ;; Go through all descriptions that are known to Gnus.
4651 (if search-description
4654 (and (string-match regexp (symbol-value group))
4655 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4656 (setq groups (cons (symbol-name group) groups))))
4657 gnus-description-hashtb))
4659 (gnus-message 3 "No groups matched \"%s\"." regexp)
4660 ;; Print out all the groups.
4662 (pop-to-buffer "*Gnus Help*")
4663 (buffer-disable-undo (current-buffer))
4665 (setq groups (sort groups 'string<))
4667 ;; Groups may be entered twice into the list of groups.
4668 (if (not (string= (car groups) prev))
4670 (insert (setq prev (car groups)) "\n")
4671 (if (and gnus-description-hashtb
4672 (setq des (gnus-gethash (car groups)
4673 gnus-description-hashtb)))
4674 (insert " " des "\n"))))
4675 (setq groups (cdr groups)))
4676 (goto-char (point-min))))
4677 (pop-to-buffer obuf)))
4679 (defun gnus-group-description-apropos (regexp)
4680 "List all newsgroups that have names or descriptions that match a regexp."
4681 (interactive "sGnus description apropos (regexp): ")
4682 (if (not (or gnus-description-hashtb
4683 (gnus-read-all-descriptions-files)))
4684 (error "Couldn't request descriptions file"))
4685 (gnus-group-apropos regexp t))
4687 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4688 (defun gnus-group-list-matching (level regexp &optional all lowest)
4689 "List all groups with unread articles that match REGEXP.
4690 If the prefix LEVEL is non-nil, it should be a number that says which
4691 level to cut off listing groups.
4692 If ALL, also list groups with no unread articles.
4693 If LOWEST, don't list groups with level lower than LOWEST."
4694 (interactive "P\nsList newsgroups matching: ")
4695 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4696 all (or lowest 1) regexp)
4697 (goto-char (point-min))
4698 (gnus-group-position-cursor))
4700 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4701 "List all groups that match REGEXP.
4702 If the prefix LEVEL is non-nil, it should be a number that says which
4703 level to cut off listing groups.
4704 If LOWEST, don't list groups with level lower than LOWEST."
4705 (interactive "P\nsList newsgroups matching: ")
4706 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4708 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4709 (defun gnus-group-save-newsrc ()
4710 "Save the Gnus startup files."
4712 (gnus-save-newsrc-file))
4714 (defun gnus-group-restart (&optional arg)
4715 "Force Gnus to read the .newsrc file."
4717 (gnus-save-newsrc-file)
4718 (gnus-setup-news 'force)
4719 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4721 (defun gnus-group-read-init-file ()
4722 "Read the Gnus elisp init file."
4724 (gnus-read-init-file))
4726 (defun gnus-group-check-bogus-groups (&optional silent)
4727 "Check bogus newsgroups.
4728 If given a prefix, don't ask for confirmation before removing a bogus
4731 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4732 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4734 (defun gnus-group-edit-global-kill (&optional article group)
4735 "Edit the global kill file.
4736 If GROUP, edit that local kill file instead."
4738 (setq gnus-current-kill-article article)
4739 (gnus-kill-file-edit-file group)
4741 (substitute-command-keys
4742 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4744 (defun gnus-group-edit-local-kill (article group)
4745 "Edit a local kill file."
4746 (interactive (list nil (gnus-group-group-name)))
4747 (gnus-group-edit-global-kill article group))
4749 (defun gnus-group-force-update ()
4750 "Update `.newsrc' file."
4752 (gnus-save-newsrc-file))
4754 (defun gnus-group-suspend ()
4755 "Suspend the current Gnus session.
4756 In fact, cleanup buffers except for group mode buffer.
4757 The hook gnus-suspend-gnus-hook is called before actually suspending."
4759 (run-hooks 'gnus-suspend-gnus-hook)
4760 ;; Kill Gnus buffers except for group mode buffer.
4761 (let ((group-buf (get-buffer gnus-group-buffer)))
4762 ;; Do this on a separate list in case the user does a ^G before we finish
4763 (let ((gnus-buffer-list
4764 (delq group-buf (delq gnus-dribble-buffer
4765 (append gnus-buffer-list nil)))))
4766 (while gnus-buffer-list
4767 (gnus-kill-buffer (car gnus-buffer-list))
4768 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4771 (setq gnus-buffer-list (list group-buf))
4772 (bury-buffer group-buf)
4773 (delete-windows-on group-buf t)))))
4775 (defun gnus-group-clear-dribble ()
4776 "Clear all information from the dribble buffer."
4778 (gnus-dribble-clear))
4780 (defun gnus-group-exit ()
4781 "Quit reading news after updating .newsrc.eld and .newsrc.
4782 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4784 (if (or noninteractive ;For gnus-batch-kill
4785 (zerop (buffer-size)) ;No news is good news.
4786 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4787 (not gnus-interactive-exit) ;Without confirmation
4789 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4791 (run-hooks 'gnus-exit-gnus-hook)
4792 ;; Offer to save data from non-quitted summary buffers.
4793 (gnus-offer-save-summaries)
4794 ;; Save the newsrc file(s).
4795 (gnus-save-newsrc-file)
4797 (gnus-close-backends)
4798 ;; Reset everything.
4799 (gnus-clear-system))))
4801 (defun gnus-close-backends ()
4802 ;; Send a close request to all backends that support such a request.
4803 (let ((methods gnus-valid-select-methods)
4806 (if (fboundp (setq func (intern (concat (car (car methods))
4807 "-request-close"))))
4809 (setq methods (cdr methods)))))
4811 (defun gnus-group-quit ()
4812 "Quit reading news without updating .newsrc.eld or .newsrc.
4813 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4815 (if (or noninteractive ;For gnus-batch-kill
4816 (zerop (buffer-size))
4817 (not (gnus-server-opened gnus-select-method))
4819 (not gnus-current-startup-file)
4821 (format "Quit reading news without saving %s? "
4822 (file-name-nondirectory gnus-current-startup-file))))
4824 (run-hooks 'gnus-exit-gnus-hook)
4825 (if gnus-use-full-window
4826 (delete-other-windows)
4827 (gnus-remove-some-windows))
4829 (gnus-close-backends)
4830 (gnus-clear-system))))
4832 (defun gnus-offer-save-summaries ()
4833 (let ((buffers (buffer-list)))
4837 ;; We look for buffers with "Summary" in the name.
4838 (string-match "Summary" (or (buffer-name (car buffers)) ""))
4840 (set-buffer (car buffers))
4841 ;; We check that this is, indeed, a summary buffer.
4842 (eq major-mode 'gnus-summary-mode))
4843 ;; We ask the user whether she wants to save the info.
4845 (format "Update summary buffer %s? " (buffer-name)))
4846 ;; We do it by simply exiting.
4847 (gnus-summary-exit))
4848 (setq buffers (cdr buffers))))))
4850 (defun gnus-group-describe-briefly ()
4851 "Give a one line description of the group mode commands."
4853 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
4855 (defun gnus-group-browse-foreign-server (method)
4856 "Browse a foreign news server.
4857 If called interactively, this function will ask for a select method
4858 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4859 If not, METHOD should be a list where the first element is the method
4860 and the second element is the address."
4862 (list (let ((how (completing-read
4864 (append gnus-valid-select-methods gnus-server-alist)
4866 ;; We either got a backend name or a virtual server name.
4867 ;; If the first, we also need an address.
4868 (if (assoc how gnus-valid-select-methods)
4870 ;; Suggested by mapjph@bath.ac.uk.
4873 (mapcar (lambda (server) (list server))
4874 gnus-secondary-servers)))
4875 ;; We got a server name, so we find the method.
4876 (gnus-server-to-method how)))))
4877 (gnus-browse-foreign-server method))
4881 ;;; Browse Server Mode
4884 (defvar gnus-browse-mode-hook nil)
4885 (defvar gnus-browse-mode-map nil)
4886 (put 'gnus-browse-mode 'mode-class 'special)
4888 (if gnus-browse-mode-map
4890 (setq gnus-browse-mode-map (make-keymap))
4891 (suppress-keymap gnus-browse-mode-map)
4892 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4893 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
4894 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4895 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4896 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4897 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4898 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4899 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4900 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4901 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
4902 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4903 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4904 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4905 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4906 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4907 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4908 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4909 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4912 (defvar gnus-browse-current-method nil)
4913 (defvar gnus-browse-return-buffer nil)
4915 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4917 (defun gnus-browse-foreign-server (method &optional return-buffer)
4918 (setq gnus-browse-current-method method)
4919 (setq gnus-browse-return-buffer return-buffer)
4920 (let ((gnus-select-method method)
4922 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4923 (or (gnus-server-opened method)
4924 (gnus-open-server method)
4925 (error "Unable to contact server: %s" (gnus-status-message method)))
4926 (or (gnus-request-list method)
4927 (error "Couldn't request list: %s" (gnus-status-message method)))
4928 (get-buffer-create gnus-browse-buffer)
4929 (gnus-add-current-to-buffer-list)
4930 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4931 (gnus-configure-windows 'browse)
4932 (buffer-disable-undo (current-buffer))
4933 (let ((buffer-read-only nil))
4936 (setq mode-line-buffer-identification
4938 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4940 (set-buffer nntp-server-buffer)
4941 (let ((cur (current-buffer)))
4942 (goto-char (point-min))
4943 (or (string= gnus-ignored-newsgroups "")
4944 (delete-matching-lines gnus-ignored-newsgroups))
4945 (while (re-search-forward
4946 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4947 (goto-char (match-end 1))
4948 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4950 (max 0 (- (1+ (read cur)) (read cur))))
4952 (setq groups (sort groups
4954 (string< (car l1) (car l2)))))
4955 (let ((buffer-read-only nil))
4957 (setq group (car groups))
4959 (format "K%7d: %s\n" (cdr group) (car group)))
4960 (setq groups (cdr groups))))
4961 (switch-to-buffer (current-buffer))
4962 (goto-char (point-min))
4963 (gnus-group-position-cursor)))
4965 (defun gnus-browse-mode ()
4966 "Major mode for browsing a foreign server.
4968 All normal editing commands are switched off.
4970 \\<gnus-browse-mode-map>
4971 The only things you can do in this buffer is
4973 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
4974 The group will be inserted into the group buffer upon exit from this
4977 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
4979 3) `\\[gnus-browse-exit]' to return to the group buffer."
4981 (kill-all-local-variables)
4982 (if gnus-visual (gnus-browse-make-menu-bar))
4983 (setq mode-line-modified "-- ")
4984 (make-local-variable 'mode-line-format)
4985 (setq mode-line-format (copy-sequence mode-line-format))
4986 (and (equal (nth 3 mode-line-format) " ")
4987 (setcar (nthcdr 3 mode-line-format) ""))
4988 (setq major-mode 'gnus-browse-mode)
4989 (setq mode-name "Browse Server")
4990 (setq mode-line-process nil)
4991 (use-local-map gnus-browse-mode-map)
4992 (buffer-disable-undo (current-buffer))
4993 (setq truncate-lines t)
4994 (setq buffer-read-only t)
4995 (run-hooks 'gnus-browse-mode-hook))
4997 (defun gnus-browse-read-group (&optional no-article)
4998 "Enter the group at the current line."
5000 (let ((group (gnus-browse-group-name)))
5001 (or (gnus-group-read-ephemeral-group
5002 group gnus-browse-current-method nil
5003 (cons (current-buffer) 'browse))
5004 (error "Couldn't enter %s" group))))
5006 (defun gnus-browse-select-group ()
5007 "Select the current group."
5009 (gnus-browse-read-group 'no))
5011 (defun gnus-browse-next-group (n)
5012 "Go to the next group."
5016 (gnus-group-position-cursor)))
5018 (defun gnus-browse-prev-group (n)
5019 "Go to the next group."
5021 (gnus-browse-next-group (- n)))
5023 (defun gnus-browse-unsubscribe-current-group (arg)
5024 "(Un)subscribe to the next ARG groups."
5027 (error "No group at current line."))
5028 (let ((ward (if (< arg 0) -1 1))
5030 (while (and (> arg 0)
5032 (gnus-browse-unsubscribe-group)
5033 (zerop (gnus-browse-next-group ward)))
5034 (setq arg (1- arg)))
5035 (gnus-group-position-cursor)
5036 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5039 (defun gnus-browse-group-name ()
5042 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5044 (gnus-group-prefixed-name
5045 (buffer-substring (match-beginning 1) (match-end 1))
5046 gnus-browse-current-method))))
5048 (defun gnus-browse-unsubscribe-group ()
5050 (buffer-read-only nil)
5054 (if (= (following-char) ?K) (setq sub t))
5055 (setq group (gnus-browse-group-name))
5060 (gnus-group-change-level
5061 (list t group gnus-level-default-subscribed
5062 nil nil gnus-browse-current-method)
5063 gnus-level-default-subscribed gnus-level-killed
5064 (and (car (nth 1 gnus-newsrc-alist))
5065 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5066 gnus-newsrc-hashtb))
5069 (gnus-group-change-level
5070 group gnus-level-killed gnus-level-default-subscribed)
5074 (defun gnus-browse-exit ()
5075 "Quit browsing and return to the group buffer."
5077 (if (eq major-mode 'gnus-browse-mode)
5078 (kill-buffer (current-buffer)))
5079 (if gnus-browse-return-buffer
5080 (gnus-configure-windows 'server 'force)
5081 (gnus-configure-windows 'group 'force)
5082 (gnus-group-list-groups nil)))
5084 (defun gnus-browse-describe-briefly ()
5085 "Give a one line description of the group mode commands."
5088 (substitute-command-keys "\\<gnus-browse-mode-map>\\[gnus-group-next-group]:Forward \\[gnus-group-prev-group]:Backward \\[gnus-browse-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-browse-describe-briefly]:This help")))
5092 ;;; Gnus summary mode
5095 (defvar gnus-summary-mode-map nil)
5096 (defvar gnus-summary-mark-map nil)
5097 (defvar gnus-summary-mscore-map nil)
5098 (defvar gnus-summary-article-map nil)
5099 (defvar gnus-summary-thread-map nil)
5100 (defvar gnus-summary-goto-map nil)
5101 (defvar gnus-summary-exit-map nil)
5102 (defvar gnus-summary-various-map nil)
5103 (defvar gnus-summary-interest-map nil)
5104 (defvar gnus-summary-sort-map nil)
5105 (defvar gnus-summary-backend-map nil)
5106 (defvar gnus-summary-save-map nil)
5107 (defvar gnus-summary-wash-map nil)
5108 (defvar gnus-summary-help-map nil)
5110 (put 'gnus-summary-mode 'mode-class 'special)
5112 (if gnus-summary-mode-map
5114 (setq gnus-summary-mode-map (make-keymap))
5115 (suppress-keymap gnus-summary-mode-map)
5117 ;; Non-orthogonal keys
5119 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5120 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5121 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5122 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5123 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5124 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5125 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5126 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5127 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5128 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5129 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5130 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5131 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5132 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5133 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5134 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5135 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5136 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5137 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5138 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5139 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5140 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5141 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5142 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5143 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5144 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5145 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5146 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5147 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5148 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5149 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5150 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5151 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5152 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5153 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5154 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5155 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5156 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5157 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5158 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5159 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5160 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5161 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5162 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5163 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5164 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5165 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5166 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5167 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5168 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5169 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5170 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5171 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5172 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5173 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5174 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5175 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5176 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5177 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5178 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5179 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5180 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5181 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5182 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5183 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5184 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5185 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5186 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5187 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5188 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5189 (define-key gnus-summary-mode-map "V" 'gnus-version)
5190 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5191 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5192 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5193 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5194 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5195 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5196 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5197 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5198 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5199 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5200 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5201 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5202 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5203 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5204 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5205 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5206 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5207 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5210 ;; Sort of orthogonal keymap
5211 (define-prefix-command 'gnus-summary-mark-map)
5212 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5213 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5214 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5215 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5216 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5217 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5218 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5219 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5220 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5221 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5222 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5223 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5224 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5225 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5226 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5227 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5228 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5229 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5230 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5231 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5232 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5233 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5234 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5235 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5237 (define-prefix-command 'gnus-summary-mscore-map)
5238 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
5239 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5240 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5241 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5242 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5244 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
5246 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5248 (define-prefix-command 'gnus-summary-goto-map)
5249 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5250 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5251 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5252 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5253 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5254 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5255 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5256 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5257 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5258 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5259 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5260 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5261 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5262 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5265 (define-prefix-command 'gnus-summary-thread-map)
5266 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5267 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5268 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5269 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5270 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5271 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5272 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5273 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5274 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5275 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5276 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5277 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5278 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5279 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5282 (define-prefix-command 'gnus-summary-exit-map)
5283 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5284 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5285 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5286 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5287 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5288 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5289 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5290 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5291 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5292 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5293 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5296 (define-prefix-command 'gnus-summary-article-map)
5297 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5298 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5299 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5300 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5301 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5302 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5303 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5304 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5305 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5306 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5307 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5308 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5309 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5310 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5314 (define-prefix-command 'gnus-summary-wash-map)
5315 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5316 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
5317 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
5318 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
5319 (define-key gnus-summary-wash-map "\C-c" 'gnus-article-hide-citation-maybe)
5320 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5321 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5322 (define-key gnus-summary-wash-map "M" 'gnus-article-remove-cr)
5323 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5324 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5325 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
5326 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
5327 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
5329 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5330 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5331 (define-key gnus-summary-wash-map "G" 'gnus-summary-toggle-header)
5332 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5334 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
5335 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
5336 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
5337 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
5338 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
5339 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5342 (define-prefix-command 'gnus-summary-help-map)
5343 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5344 (define-key gnus-summary-help-map "v" 'gnus-version)
5345 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5346 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5347 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5348 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5351 (define-prefix-command 'gnus-summary-backend-map)
5352 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5353 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5354 (define-key gnus-summary-backend-map "\M-\C-e"
5355 'gnus-summary-expire-articles-now)
5356 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5357 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5358 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5359 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5360 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5361 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5362 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5365 (define-prefix-command 'gnus-summary-save-map)
5366 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5367 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5368 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5369 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5370 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5371 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5372 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5373 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5374 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5376 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5378 (define-prefix-command 'gnus-summary-various-map)
5379 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
5380 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5381 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5382 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5383 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5384 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5385 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5386 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5387 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5388 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5389 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5391 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
5393 ; (define-prefix-command 'gnus-summary-sort-map)
5394 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5395 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5396 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5397 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5398 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5399 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5401 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5402 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5408 (defun gnus-summary-mode (&optional group)
5409 "Major mode for reading articles.
5411 All normal editing commands are switched off.
5412 \\<gnus-summary-mode-map>
5413 Each line in this buffer represents one article. To read an
5414 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5415 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5418 You can also post articles and send mail from this buffer. To
5419 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5420 of an article, type `\\[gnus-summary-reply]'.
5422 There are approx. one gazillion commands you can execute in this
5423 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5425 The following commands are available:
5427 \\{gnus-summary-mode-map}"
5429 (if gnus-visual (gnus-summary-make-menu-bar))
5430 (kill-all-local-variables)
5431 (let ((locals gnus-summary-local-variables))
5433 (if (consp (car locals))
5435 (make-local-variable (car (car locals)))
5436 (set (car (car locals)) (eval (cdr (car locals)))))
5437 (make-local-variable (car locals))
5438 (set (car locals) nil))
5439 (setq locals (cdr locals))))
5440 (gnus-make-thread-indent-array)
5441 (setq mode-line-modified "-- ")
5442 (make-local-variable 'mode-line-format)
5443 (setq mode-line-format (copy-sequence mode-line-format))
5444 (and (equal (nth 3 mode-line-format) " ")
5445 (setcar (nthcdr 3 mode-line-format) ""))
5446 (setq major-mode 'gnus-summary-mode)
5447 (setq mode-name "Summary")
5448 (make-local-variable 'minor-mode-alist)
5449 (use-local-map gnus-summary-mode-map)
5450 (buffer-disable-undo (current-buffer))
5451 (setq buffer-read-only t) ;Disable modification
5452 (setq truncate-lines t)
5453 (setq selective-display t)
5454 (setq selective-display-ellipses t) ;Display `...'
5455 (setq buffer-display-table gnus-summary-display-table)
5456 (setq gnus-newsgroup-name group)
5457 (run-hooks 'gnus-summary-mode-hook))
5459 (defun gnus-summary-make-display-table ()
5460 ;; Change the display table. Odd characters have a tendency to mess
5461 ;; up nicely formatted displays - we make all possible glyphs
5462 ;; display only a single character.
5464 ;; We start from the standard display table, if any.
5465 (setq gnus-summary-display-table
5466 (or (copy-sequence standard-display-table)
5467 (make-display-table)))
5468 ;; Nix out all the control chars...
5470 (while (>= (setq i (1- i)) 0)
5471 (aset gnus-summary-display-table i [??])))
5472 ;; ... but not newline and cr, of course. (cr is necessary for the
5473 ;; selective display).
5474 (aset gnus-summary-display-table ?\n nil)
5475 (aset gnus-summary-display-table ?\r nil)
5476 ;; We nix out any glyphs over 126 that are not set already.
5478 (while (>= (setq i (1- i)) 127)
5479 ;; Only modify if the entry is nil.
5480 (or (aref gnus-summary-display-table i)
5481 (aset gnus-summary-display-table i [??])))))
5483 (defun gnus-summary-clear-local-variables ()
5484 (let ((locals gnus-summary-local-variables))
5486 (if (consp (car locals))
5487 (and (vectorp (car (car locals)))
5488 (set (car (car locals)) nil))
5489 (and (vectorp (car locals))
5490 (set (car locals) nil)))
5491 (setq locals (cdr locals)))))
5493 ;; Some summary mode macros.
5495 ;; Return a header specified by a NUMBER.
5496 (defun gnus-get-header-by-number (number)
5498 (set-buffer gnus-summary-buffer)
5499 (or gnus-newsgroup-headers-hashtb-by-number
5500 (gnus-make-headers-hashtable-by-number))
5501 (gnus-gethash (int-to-string number)
5502 gnus-newsgroup-headers-hashtb-by-number)))
5504 ;; Fast version of the function above.
5505 (defmacro gnus-get-header-by-num (number)
5506 (` (gnus-gethash (int-to-string (, number))
5507 gnus-newsgroup-headers-hashtb-by-number)))
5509 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5510 "Search for article forward.
5511 If UNREAD is non-nil, only unread articles are selected.
5512 If SUBJECT is non-nil, the article which has the same subject will be
5514 If BACKWARD is non-nil, the search will be performed backwards instead."
5515 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5517 (defmacro gnus-summary-search-backward (&optional unread subject)
5518 "Search for article backward.
5519 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5520 If 2nd optional argument SUBJECT is non-nil, the article which has
5521 the same subject will be searched for."
5522 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5524 (defmacro gnus-summary-article-number (&optional number-or-nil)
5525 "The article number of the article on the current line.
5526 If there isn's an article number here, then we return the current
5529 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5530 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5531 gnus-current-article)))
5533 (defmacro gnus-summary-thread-level ()
5534 "The thread level of the article on the current line."
5535 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5538 (defmacro gnus-summary-article-mark ()
5539 "The mark on the current line."
5540 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5542 (defun gnus-summary-subject-string ()
5543 "Return current subject string or nil if nothing."
5544 (let ((article (gnus-summary-article-number))
5547 (setq header (gnus-get-header-by-num article))
5549 (header-subject header))))
5551 ;; Various summary mode internalish functions.
5553 (defun gnus-mouse-pick-article (e)
5556 (gnus-summary-next-page nil t))
5558 (defun gnus-summary-setup-buffer (group)
5559 "Initialize summary buffer."
5560 (let ((buffer (concat "*Summary " group "*")))
5561 (if (get-buffer buffer)
5564 (not gnus-newsgroup-begin))
5565 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5566 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5567 (gnus-add-current-to-buffer-list)
5568 (gnus-summary-mode group)
5569 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5570 (setq gnus-newsgroup-name group)
5573 (defun gnus-set-global-variables ()
5574 ;; Set the global equivalents of the summary buffer-local variables
5575 ;; to the latest values they had. These reflect the summary buffer
5576 ;; that was in action when the last article was fetched.
5577 (if (eq major-mode 'gnus-summary-mode)
5579 (setq gnus-summary-buffer (current-buffer))
5580 (let ((name gnus-newsgroup-name)
5581 (marked gnus-newsgroup-marked)
5582 (unread gnus-newsgroup-unreads)
5583 (headers gnus-current-headers)
5584 (score-file gnus-current-score-file))
5586 (set-buffer gnus-group-buffer)
5587 (setq gnus-newsgroup-name name)
5588 (setq gnus-newsgroup-marked marked)
5589 (setq gnus-newsgroup-unreads unread)
5590 (setq gnus-current-headers headers)
5591 (setq gnus-current-score-file score-file))))))
5593 (defun gnus-summary-insert-dummy-line (sformat subject number)
5595 (setq sformat gnus-summary-dummy-line-format-spec))
5599 (insert (eval sformat))
5600 (add-text-properties
5602 (list 'gnus-number number
5603 'gnus-mark gnus-dummy-mark
5606 (defvar gnus-thread-indent-array nil)
5607 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5608 (defun gnus-make-thread-indent-array ()
5610 (if (and gnus-thread-indent-array
5611 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5613 (setq gnus-thread-indent-array (make-vector 201 "")
5614 gnus-thread-indent-array-level gnus-thread-indent-level)
5616 (aset gnus-thread-indent-array n
5617 (make-string (* n gnus-thread-indent-level) ? ))
5620 (defun gnus-summary-insert-line
5621 (sformat header level current unread replied expirable subject-or-nil
5622 &optional dummy score)
5623 (or sformat (setq sformat gnus-summary-line-format-spec))
5624 (let* ((indentation (aref gnus-thread-indent-array level))
5625 (lines (header-lines header))
5626 (score (or score gnus-summary-default-score 0))
5628 (if (or (null gnus-summary-default-score)
5629 (<= (abs (- score gnus-summary-default-score))
5630 gnus-summary-zcore-fuzz)) ?
5631 (if (< score gnus-summary-default-score)
5632 gnus-score-below-mark gnus-score-over-mark)))
5633 (replied (if replied gnus-replied-mark ? ))
5634 (from (header-from header))
5636 ((string-match "(.+)" from)
5637 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5638 ((string-match "<[^>]+> *$" from)
5639 (let ((beg (match-beginning 0)))
5640 (or (and (string-match "^\"[^\"]*\"" from)
5641 (substring from (1+ (match-beginning 0))
5642 (1- (match-end 0))))
5643 (substring from 0 beg))))
5645 (subject (header-subject header))
5646 (number (header-number header))
5647 (opening-bracket (if dummy ?\< ?\[))
5648 (closing-bracket (if dummy ?\> ?\]))
5649 (buffer-read-only nil)
5650 (b (progn (beginning-of-line) (point))))
5651 (or (numberp lines) (setq lines 0))
5652 (insert (eval sformat))
5653 (add-text-properties
5654 b (1+ b) (list 'gnus-number number
5655 'gnus-mark (or unread gnus-unread-mark)
5656 'gnus-level level))))
5658 (defun gnus-summary-update-line (&optional dont-update)
5659 ;; Update summary line after change.
5660 (or (not gnus-summary-default-score)
5661 gnus-summary-inhibit-highlight
5662 (let ((gnus-summary-inhibit-highlight t)
5663 (article (gnus-summary-article-number)))
5666 (if (and gnus-summary-mark-below
5667 (< (gnus-summary-article-score)
5668 gnus-summary-mark-below))
5669 (and (not (memq article gnus-newsgroup-marked))
5670 (not (memq article gnus-newsgroup-dormant))
5671 (memq article gnus-newsgroup-unreads)
5672 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5673 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5674 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5676 (run-hooks 'gnus-summary-update-hook))))))
5678 (defun gnus-summary-update-lines (&optional beg end)
5679 ;; Mark article as read (or not) by taking into account scores.
5680 (let ((beg (or beg (point-min)))
5681 (end (or end (point-max))))
5682 (if (or (not gnus-summary-default-score)
5683 gnus-summary-inhibit-highlight)
5685 (let ((gnus-summary-inhibit-highlight t)
5688 (set-buffer gnus-summary-buffer)
5691 (while (and (not (eobp)) (< (point) end))
5692 (if (and gnus-summary-mark-below
5694 (setq article (get-text-property
5695 (point) 'gnus-number))
5696 gnus-newsgroup-scored))
5697 gnus-summary-default-score 0)
5698 gnus-summary-mark-below))
5699 ;; We want to possibly mark it as read...
5700 (and (not (memq article gnus-newsgroup-marked))
5701 (not (memq article gnus-newsgroup-dormant))
5702 (memq article gnus-newsgroup-unreads)
5703 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5704 ;; We want to possibly mark it as unread.
5705 (and (eq (get-text-property (point) 'gnus-mark)
5706 gnus-low-score-mark)
5707 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5708 ;; Do the visual highlights at the same time.
5709 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5710 (forward-line 1)))))))
5712 (defvar gnus-tmp-gathered nil)
5714 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5715 ;; Sum up all elements (and sub-elements) in a list.
5717 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5718 (if (and (consp thread) (cdr thread))
5723 (if (memq (header-number (car arg)) gnus-tmp-gathered)
5725 (gnus-summary-number-of-articles-in-thread arg))))
5729 (if (> number 1) gnus-not-empty-thread-mark
5730 gnus-empty-thread-mark)
5733 (defun gnus-summary-read-group
5734 (group &optional show-all no-article kill-buffer)
5735 "Start reading news in newsgroup GROUP.
5736 If SHOW-ALL is non-nil, already read articles are also listed.
5737 If NO-ARTICLE is non-nil, no article is selected initially."
5738 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5739 (let* ((new-group (gnus-summary-setup-buffer group))
5740 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5742 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5745 (gnus-set-global-variables)
5746 (gnus-kill-buffer kill-buffer)
5747 (gnus-configure-windows 'summary)
5748 (gnus-set-mode-line 'summary)
5749 (gnus-summary-position-cursor)
5753 (and (eq major-mode 'gnus-summary-mode)
5754 (not (equal (current-buffer) kill-buffer))
5756 (kill-buffer (current-buffer))
5757 (if (not quit-config)
5759 (set-buffer gnus-group-buffer)
5760 (gnus-group-jump-to-group group)
5761 (gnus-group-next-unread-group 1))
5762 (if (not (buffer-name (car quit-config)))
5763 (gnus-configure-windows 'group 'force)
5764 (set-buffer (car quit-config))
5765 (and (eq major-mode 'gnus-summary-mode)
5766 (gnus-set-global-variables))
5767 (gnus-configure-windows (cdr quit-config))))))
5768 (message "Can't select group")
5770 ((eq did-select 'quit)
5771 (and (eq major-mode 'gnus-summary-mode)
5772 (not (equal (current-buffer) kill-buffer))
5773 (kill-buffer (current-buffer)))
5774 (gnus-kill-buffer kill-buffer)
5775 (if (not quit-config)
5777 (set-buffer gnus-group-buffer)
5778 (gnus-group-jump-to-group group)
5779 (gnus-group-next-unread-group 1)
5780 (gnus-configure-windows 'group 'force))
5781 (if (not (buffer-name (car quit-config)))
5782 (gnus-configure-windows 'group 'force)
5783 (set-buffer (car quit-config))
5784 (and (eq major-mode 'gnus-summary-mode)
5785 (gnus-set-global-variables))
5786 (gnus-configure-windows (cdr quit-config))))
5789 (gnus-set-global-variables)
5790 ;; Save the active value in effect when the group was entered.
5791 (setq gnus-newsgroup-active
5793 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5794 ;; You can change the subjects in this hook.
5795 (run-hooks 'gnus-select-group-hook)
5796 ;; Do score processing.
5797 (and gnus-use-scoring (gnus-possibly-score-headers))
5798 (gnus-update-format-specifications)
5799 ;; Generate the summary buffer.
5800 (gnus-summary-prepare)
5801 (if (zerop (buffer-size))
5802 (cond (gnus-newsgroup-dormant
5803 (gnus-summary-show-all-dormant))
5804 ((and gnus-newsgroup-scored show-all)
5805 (gnus-summary-show-all-expunged))))
5806 ;; Function `gnus-apply-kill-file' must be called in this hook.
5807 (run-hooks 'gnus-apply-kill-hook)
5808 (if (zerop (buffer-size))
5810 ;; This newsgroup is empty.
5811 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5812 (gnus-message 6 "No unread news")
5813 (gnus-kill-buffer kill-buffer)
5817 ;; (let ((gnus-summary-buffer kill-buffer))
5818 ;; (gnus-configure-windows 'group))))
5819 ;; Hide conversation thread subtrees. We cannot do this in
5820 ;; gnus-summary-prepare-hook since kill processing may not
5821 ;; work with hidden articles.
5822 (and gnus-show-threads
5823 gnus-thread-hide-subtree
5824 (gnus-summary-hide-all-threads))
5825 ;; Show first unread article if requested.
5826 (goto-char (point-min))
5827 (if (and (not no-article)
5828 gnus-auto-select-first
5829 (gnus-summary-first-unread-article))
5831 (gnus-configure-windows 'summary))
5832 (gnus-set-mode-line 'summary)
5833 (gnus-summary-position-cursor)
5834 ;; If in async mode, we send some info to the backend.
5835 (and gnus-newsgroup-async
5836 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5837 (gnus-request-asynchronous
5839 (if (and gnus-asynchronous-article-function
5840 (fboundp gnus-asynchronous-article-function))
5841 (funcall gnus-asynchronous-article-function
5842 gnus-newsgroup-threads)
5843 gnus-newsgroup-threads)))
5844 (gnus-kill-buffer kill-buffer)
5845 (if (not (get-buffer-window gnus-group-buffer))
5847 ;; gotta use windows, because recenter does wierd stuff if
5848 ;; the current buffer ain't the displayed window.
5849 (let ((owin (selected-window)))
5850 (select-window (get-buffer-window gnus-group-buffer))
5851 (and (gnus-group-goto-group group)
5853 (select-window owin))))
5856 (defun gnus-summary-prepare ()
5857 ;; Generate the summary buffer.
5858 (let ((buffer-read-only nil))
5860 (gnus-message 5 "Threading...")
5861 (gnus-summary-prepare-threads
5862 (if gnus-show-threads
5863 (gnus-gather-threads
5865 (if (and gnus-summary-expunge-below
5866 (not gnus-fetch-old-headers))
5867 (gnus-make-threads-and-expunge)
5868 (gnus-make-threads))))
5869 gnus-newsgroup-headers)
5871 (gnus-message 5 "Threading...done")
5872 (gnus-summary-update-lines)
5873 ;; Remove the final newline.
5874 ;;(goto-char (point-max))
5876 ;; Call hooks for modifying summary buffer.
5877 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5878 (goto-char (point-min))
5879 (run-hooks 'gnus-summary-prepare-hook)))
5881 (defun gnus-gather-threads (threads)
5882 "Gather threads that have lost their roots."
5883 (if (not gnus-summary-make-false-root)
5885 (let ((hashtb (gnus-make-hashtable 1023))
5888 subject hthread whole-subject)
5891 (setq subject (header-subject (car (car threads)))))
5892 (if gnus-summary-gather-subject-limit
5893 (or (and (numberp gnus-summary-gather-subject-limit)
5894 (> (length subject) gnus-summary-gather-subject-limit)
5896 (substring subject 0
5897 gnus-summary-gather-subject-limit)))
5898 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5899 (setq subject (gnus-simplify-subject-fuzzy subject))))
5900 (setq subject (gnus-simplify-subject-re subject)))
5902 (gnus-gethash subject hashtb))
5904 (or (stringp (car (car hthread)))
5905 (setcar hthread (list whole-subject (car hthread))))
5906 (setcdr (car hthread) (nconc (cdr (car hthread))
5907 (list (car threads))))
5908 (setcdr prev (cdr threads))
5909 (setq threads prev))
5910 (gnus-sethash subject threads hashtb))
5912 (setq threads (cdr threads)))
5915 (defun gnus-make-threads ()
5916 ;; This function takes the dependencies already made by
5917 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5918 ;; through the dependecies in the hash table and finds all the
5919 ;; roots. Roots do not refer back to any valid articles.
5920 (let (roots new-roots)
5921 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5922 (gnus-build-old-threads))
5925 (if (not (car (symbol-value refs)))
5926 (setq roots (append (cdr (symbol-value refs)) roots))
5927 ;; Ok, these refer back to valid articles, but if
5928 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5929 ;; the root has the same subject as its children. The children
5930 ;; that do not are made into roots and removed from the list
5932 (or gnus-thread-ignore-subject
5933 (let* ((prev (symbol-value refs))
5934 (subject (gnus-simplify-subject-re
5935 (header-subject (car prev))))
5936 (headers (cdr prev)))
5938 (if (not (string= subject
5939 (gnus-simplify-subject-re
5940 (header-subject (car headers)))))
5942 (setq new-roots (cons (car headers) new-roots))
5943 (setcdr prev (cdr headers)))
5944 (setq prev headers))
5945 (setq headers (cdr headers)))))))
5946 gnus-newsgroup-dependencies)
5948 ;; We enter the new roots into the dependencies structure to
5949 ;; ensure that any possible later thread-regeneration will be
5951 (let ((r new-roots))
5953 (gnus-sethash (concat (header-id (car r)) ".boo")
5954 (list nil (car r)) gnus-newsgroup-dependencies)
5957 (setq roots (nconc new-roots roots))
5959 (mapcar 'gnus-trim-thread
5961 (mapcar 'gnus-cut-thread
5962 (mapcar 'gnus-make-sub-thread roots))))))
5964 (defun gnus-make-threads-and-expunge ()
5965 ;; This function takes the dependencies already made by
5966 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5967 ;; through the dependecies in the hash table and finds all the
5968 ;; roots. Roots do not refer back to any valid articles.
5969 (let ((default (or gnus-summary-default-score 0))
5970 (below gnus-summary-expunge-below)
5971 roots article new-roots)
5972 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5973 (gnus-build-old-threads))
5976 (if (not (car (symbol-value refs)))
5977 ;; These articles do not refer back to any other articles -
5979 (let ((headers (cdr (symbol-value refs))))
5980 ;; We weed out the low-scored articles.
5982 (if (not (< (or (cdr (assq (header-number (car headers))
5983 gnus-newsgroup-scored)) default)
5986 (setq roots (cons (car headers) roots))
5987 ;; It is below, so we mark it as read.
5988 (setq gnus-newsgroup-unreads
5989 (delq (header-number (car headers))
5990 gnus-newsgroup-unreads))
5991 (setq gnus-newsgroup-reads
5992 (cons (cons (header-number (car headers))
5993 gnus-low-score-mark)
5994 gnus-newsgroup-reads)))
5995 (setq headers (cdr headers))))
5996 ;; Ok, these refer back to valid articles, but if
5997 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5998 ;; the root has the same subject as its children. The children
5999 ;; that do not are made into roots and removed from the list
6001 (or gnus-thread-ignore-subject
6002 (let* ((prev (symbol-value refs))
6003 (subject (gnus-simplify-subject-re
6004 (header-subject (car prev))))
6005 (headers (cdr prev)))
6007 (if (not (string= subject
6008 (gnus-simplify-subject-re
6009 (header-subject (car headers)))))
6011 (if (not (< (or (cdr (assq (header-number (car headers))
6012 gnus-newsgroup-scored))
6014 (setq new-roots (cons (car headers) new-roots))
6015 (setq gnus-newsgroup-unreads
6016 (delq (header-number (car headers))
6017 gnus-newsgroup-unreads))
6018 (setq gnus-newsgroup-reads
6019 (cons (cons (header-number (car headers))
6020 gnus-low-score-mark)
6021 gnus-newsgroup-reads)))
6022 (setcdr prev (cdr headers)))
6023 (setq prev headers))
6024 (setq headers (cdr headers)))))
6025 ;; If this article is expunged, some of the children might be
6027 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
6028 gnus-newsgroup-scored)) default)
6030 (let* ((prev (symbol-value refs))
6031 (headers (cdr prev)))
6033 (setq article (header-number (car headers)))
6034 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6036 (progn (setq new-roots (cons (car headers) new-roots))
6037 (setq prev headers))
6038 (setq gnus-newsgroup-unreads
6039 (delq article gnus-newsgroup-unreads))
6040 (setq gnus-newsgroup-reads
6041 (cons (cons article gnus-low-score-mark)
6042 gnus-newsgroup-reads))
6043 (setcdr prev (cdr headers)))
6044 (setq headers (cdr headers))))
6045 ;; It was not expunged, but we look at expunged children.
6046 (let* ((prev (symbol-value refs))
6047 (headers (cdr prev))
6050 (setq article (header-number (car headers)))
6051 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6054 (setq gnus-newsgroup-unreads
6055 (delq article gnus-newsgroup-unreads))
6056 (setq gnus-newsgroup-reads
6057 (cons (cons article gnus-low-score-mark)
6058 gnus-newsgroup-reads))
6059 (setcdr prev (cdr headers)))
6060 (setq headers (cdr headers)))))))
6061 gnus-newsgroup-dependencies)
6063 ;; We enter the new roots into the dependencies structure to
6064 ;; ensure that any possible later thread-regeneration will be
6066 (let ((r new-roots))
6068 (gnus-sethash (concat (header-id (car r)) ".boo")
6069 (list nil (car r)) gnus-newsgroup-dependencies)
6072 (setq roots (nconc new-roots roots))
6074 (mapcar 'gnus-trim-thread
6076 (mapcar 'gnus-cut-thread
6077 (mapcar 'gnus-make-sub-thread roots))))))
6079 (defun gnus-cut-thread (thread)
6080 ;; Remove leaf dormant or ancient articles from THREAD.
6081 (let ((head (car thread))
6082 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6083 (if (and (null tail)
6084 (let ((number (header-number head)))
6085 (or (memq number gnus-newsgroup-ancient)
6086 (memq number gnus-newsgroup-dormant)
6087 (and gnus-summary-expunge-below
6088 (eq gnus-fetch-old-headers 'some)
6089 (< (or (cdr (assq number gnus-newsgroup-scored))
6090 gnus-summary-default-score 0)
6091 gnus-summary-expunge-below)
6093 (setq gnus-newsgroup-unreads
6094 (delq number gnus-newsgroup-unreads))
6095 (setq gnus-newsgroup-reads
6096 (cons (cons number gnus-low-score-mark)
6097 gnus-newsgroup-reads))
6100 (list (cons head tail)))))
6102 (defun gnus-trim-thread (thread)
6103 ;; Remove root ancient articles with only one child from THREAD.
6104 (if (and (eq gnus-fetch-old-headers 'some)
6105 (memq (header-number (car thread)) gnus-newsgroup-ancient)
6106 (= (length thread) 2))
6107 (gnus-trim-thread (nth 1 thread))
6110 (defun gnus-make-sub-thread (root)
6111 ;; This function makes a sub-tree for a node in the tree.
6112 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
6113 gnus-newsgroup-dependencies)))))
6114 (cons root (mapcar 'gnus-make-sub-thread children))))
6116 (defun gnus-build-old-threads ()
6117 ;; Look at all the articles that refer back to old articles, and
6118 ;; fetch the headers for the articles that aren't there. This will
6119 ;; build complete threads - if the roots haven't been expired by the
6124 (if (not (car (symbol-value refs)))
6126 (setq heads (cdr (symbol-value refs)))
6128 (if (not (memq (header-number (car heads))
6129 gnus-newsgroup-dormant))
6131 (setq id (symbol-name refs))
6132 (while (and (setq id (gnus-build-get-header id))
6133 (not (car (gnus-gethash
6134 id gnus-newsgroup-dependencies)))))
6136 (setq heads (cdr heads)))))))
6137 gnus-newsgroup-dependencies)))
6139 (defun gnus-build-get-header (id)
6140 ;; Look through the buffer of NOV lines and find the header to
6141 ;; ID. Enter this line into the dependencies hash table, and return
6142 ;; the id of the parent article (if any).
6143 (let ((deps gnus-newsgroup-dependencies)
6147 (set-buffer nntp-server-buffer)
6148 (goto-char (point-min))
6149 (while (and (not found) (search-forward id nil t))
6151 (setq found (looking-at
6152 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6153 (regexp-quote id))))
6154 (or found (beginning-of-line 2)))
6159 (setq header (gnus-nov-parse-line
6160 (read (current-buffer)) deps))
6161 (setq ref (header-references header))
6162 (string-match "\\(<[^>]+>\\) *$" ref)
6163 (substring ref (match-beginning 1) (match-end 1))))))
6165 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6166 gnus-newsgroup-ancient (cons (header-number header)
6167 gnus-newsgroup-ancient))))))
6169 ;; Re-build the thread containing ID.
6170 (defun gnus-rebuild-thread (id)
6171 (let ((dep gnus-newsgroup-dependencies)
6172 (buffer-read-only nil)
6173 parent headers refs thread art)
6174 (while (and id (setq headers
6175 (car (setq art (gnus-gethash (downcase id) dep)))))
6177 (setq id (and (setq refs (header-references headers))
6178 (string-match "\\(<[^>]+>\\) *$" refs)
6179 (substring refs (match-beginning 1) (match-end 1)))))
6180 (setq thread (gnus-make-sub-thread (car parent)))
6181 (gnus-rebuild-remove-articles thread)
6182 (let ((beg (point)))
6183 (gnus-summary-prepare-threads (list thread))
6184 (gnus-summary-update-lines beg (point)))))
6186 ;; Delete all lines in the summary buffer that correspond to articles
6188 (defun gnus-rebuild-remove-articles (thread)
6189 (and (gnus-summary-goto-subject (header-number (car thread)))
6191 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6193 (defun gnus-sort-threads (threads)
6194 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6195 (let ((fun gnus-thread-sort-functions))
6197 (setq threads (sort threads (car fun))
6201 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6202 (defmacro gnus-thread-header (thread)
6203 ;; Return header of first article in THREAD.
6204 ;; Note that THREAD must never, evr be anything else than a variable -
6205 ;; using some other form will lead to serious barfage.
6206 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6207 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6208 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6211 (defun gnus-thread-sort-by-number (h1 h2)
6212 "Sort threads by root article number."
6213 (< (header-number (gnus-thread-header h1))
6214 (header-number (gnus-thread-header h2))))
6216 (defun gnus-thread-sort-by-author (h1 h2)
6217 "Sort threads by root author."
6219 (let ((extract (funcall
6220 gnus-extract-address-components
6221 (header-from (gnus-thread-header h1)))))
6222 (or (car extract) (cdr extract)))
6223 (let ((extract (funcall
6224 gnus-extract-address-components
6225 (header-from (gnus-thread-header h2)))))
6226 (or (car extract) (cdr extract)))))
6228 (defun gnus-thread-sort-by-subject (h1 h2)
6229 "Sort threads by root subject."
6231 (downcase (gnus-simplify-subject
6232 (header-subject (gnus-thread-header h1))))
6233 (downcase (gnus-simplify-subject
6234 (header-subject (gnus-thread-header h2))))))
6236 (defun gnus-thread-sort-by-date (h1 h2)
6237 "Sort threads by root article date."
6239 (gnus-sortable-date (header-date (gnus-thread-header h1)))
6240 (gnus-sortable-date (header-date (gnus-thread-header h2)))))
6242 (defun gnus-thread-sort-by-score (h1 h2)
6243 "Sort threads by root article score.
6244 Unscored articles will be counted as having a score of zero."
6245 (> (or (cdr (assq (header-number (gnus-thread-header h1))
6246 gnus-newsgroup-scored))
6247 gnus-summary-default-score 0)
6248 (or (cdr (assq (header-number (gnus-thread-header h2))
6249 gnus-newsgroup-scored))
6250 gnus-summary-default-score 0)))
6252 (defun gnus-thread-sort-by-total-score (h1 h2)
6253 "Sort threads by the sum of all scores in the thread.
6254 Unscored articles will be counted as having a score of zero."
6255 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6257 (defun gnus-thread-total-score (thread)
6258 ;; This function find the total score of THREAD.
6260 (if (stringp (car thread))
6261 (apply gnus-thread-score-function 0
6262 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6263 (gnus-thread-total-score-1 thread))
6264 (gnus-thread-total-score-1 (list thread))))
6266 (defun gnus-thread-total-score-1 (root)
6267 ;; This function find the total score of the thread below ROOT.
6268 (setq root (car root))
6269 (apply gnus-thread-score-function
6270 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
6271 gnus-summary-default-score 0)
6272 (mapcar 'gnus-thread-total-score
6273 (cdr (gnus-gethash (downcase (header-id root))
6274 gnus-newsgroup-dependencies)))))
6276 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6277 (defvar gnus-tmp-prev-subject "")
6279 (defun gnus-summary-prepare-threads (threads &optional cull)
6280 "Prepare summary buffer from THREADS and indentation LEVEL.
6281 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6282 or a straight list of headers."
6284 thread header number subject stack state gnus-tmp-gathered)
6285 (if (vectorp (car threads))
6286 ;; If this is a straight (sic) list of headers, then a
6287 ;; threaded summary display isn't required, so we just create
6288 ;; an unthreaded one.
6289 (gnus-summary-prepare-unthreaded threads cull)
6291 ;; Do the threaded display.
6293 (while (or threads stack)
6296 ;; If there are some threads, we do them before the
6297 ;; threads on the stack.
6298 (setq thread threads
6299 header (car (car thread)))
6300 ;; There were no current threads, so we pop something off
6302 (setq state (car stack)
6306 header (car (car thread))))
6308 (if (stringp header)
6310 ;; The header is a dummy root.
6312 ((eq gnus-summary-make-false-root 'adopt)
6313 ;; We let the first article adopt the rest.
6314 (let ((th (car (cdr (car thread)))))
6317 (setcdr th (cdr (cdr (car thread))))
6318 (setq gnus-tmp-gathered
6320 (lambda (h) (header-number (car h)))
6321 (cdr (cdr (car thread))))
6323 (setcdr (cdr (car thread)) nil))
6325 ((eq gnus-summary-make-false-root 'empty)
6326 ;; We print adopted articles with empty subject fields.
6327 (setq gnus-tmp-gathered
6329 (lambda (h) (header-number (car h)))
6330 (cdr (cdr (car thread))))
6333 ((eq gnus-summary-make-false-root 'dummy)
6334 ;; We output a dummy root.
6335 (gnus-summary-insert-dummy-line
6336 nil header (header-number (car (car (cdr (car thread)))))))
6338 ;; We do not make a root for the gathered
6339 ;; sub-threads at all.
6342 (setq number (header-number header)
6343 subject (header-subject header))
6345 ;; Do the async thing.
6346 (and gnus-newsgroup-async
6347 (setq gnus-newsgroup-threads
6348 (cons (cons number (header-lines header))
6349 gnus-newsgroup-threads)))
6351 ;; We may have to root out some bad articles...
6354 (cond ((and (memq (setq number (header-number header))
6355 gnus-newsgroup-dormant)
6358 ((and gnus-summary-expunge-below
6359 (< (or (cdr (assq number gnus-newsgroup-scored))
6360 gnus-summary-default-score 0)
6361 gnus-summary-expunge-below))
6363 (setq gnus-newsgroup-unreads
6364 (delq number gnus-newsgroup-unreads))
6365 (setq gnus-newsgroup-reads
6366 (cons (cons number gnus-low-score-mark)
6367 gnus-newsgroup-reads)))))
6373 (gnus-summary-insert-line
6374 nil header level nil
6376 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6377 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6378 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6379 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6380 (t (or (cdr (assq number gnus-newsgroup-reads))
6381 gnus-ancient-mark)))
6382 (memq number gnus-newsgroup-replied)
6383 (memq number gnus-newsgroup-expirable)
6384 (if (and (eq gnus-summary-make-false-root 'empty)
6385 (memq number gnus-tmp-gathered))
6386 gnus-summary-same-subject
6387 (if (or (zerop level)
6388 (and gnus-thread-ignore-subject
6390 (gnus-simplify-subject-re
6391 gnus-tmp-prev-subject)
6392 (gnus-simplify-subject-re
6395 gnus-summary-same-subject))
6396 (and (eq gnus-summary-make-false-root 'adopt)
6397 (memq number gnus-tmp-gathered))
6398 (cdr (assq number gnus-newsgroup-scored)))
6400 (setq gnus-tmp-prev-subject subject)))))
6403 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6404 (setq level (1+ level))
6405 (setq threads (cdr (car thread)))))))
6408 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6409 (let (header number)
6411 ;; Do the async thing, if that is required.
6412 (if gnus-newsgroup-async
6413 (setq gnus-newsgroup-threads
6414 (mapcar (lambda (h) (cons (header-number h) (header-lines h)))
6418 (setq header (car headers)
6419 headers (cdr headers)
6420 number (header-number header))
6422 ;; We may have to root out some bad articles...
6425 (memq (setq number (header-number header))
6426 gnus-newsgroup-dormant)))
6427 ((and cull gnus-summary-expunge-below
6428 (< (or (cdr (assq number gnus-newsgroup-scored))
6429 gnus-summary-default-score 0)
6430 gnus-summary-expunge-below))
6431 (setq gnus-newsgroup-unreads
6432 (delq number gnus-newsgroup-unreads))
6433 (setq gnus-newsgroup-reads
6434 (cons (cons number gnus-low-score-mark)
6435 gnus-newsgroup-reads)))
6437 (gnus-summary-insert-line
6439 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6440 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6441 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6442 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6443 (t (or (cdr (assq number gnus-newsgroup-reads))
6444 gnus-ancient-mark)))
6445 (memq number gnus-newsgroup-replied)
6446 (memq number gnus-newsgroup-expirable)
6447 (header-subject header) nil
6448 (cdr (assq number gnus-newsgroup-scored))))))))
6450 (defun gnus-select-newsgroup (group &optional read-all)
6451 "Select newsgroup GROUP.
6452 If READ-ALL is non-nil, all articles in the group are selected."
6453 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6454 (info (nth 2 entry))
6456 (gnus-check-news-server
6457 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6459 (or (gnus-server-opened gnus-current-select-method)
6460 (gnus-open-server gnus-current-select-method)
6461 (error "Couldn't open server"))
6463 (or (and (eq (car entry) t)
6464 (gnus-activate-newsgroup (car info)))
6465 (gnus-request-group group t)
6467 (kill-buffer (current-buffer))
6468 (error "Couldn't request group %s: %s"
6469 group (gnus-status-message group))))
6471 (setq gnus-newsgroup-name group)
6472 (setq gnus-newsgroup-unselected nil)
6473 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6475 (and gnus-asynchronous
6476 (gnus-check-backend-function
6477 'request-asynchronous gnus-newsgroup-name)
6478 (setq gnus-newsgroup-async
6479 (gnus-request-asynchronous gnus-newsgroup-name)))
6481 (setq articles (gnus-articles-to-read group read-all))
6485 (gnus-message 3 "Couldn't select newsgroup")
6487 ((eq articles 0) nil)
6489 ;; Init the dependencies hash table.
6490 (setq gnus-newsgroup-dependencies
6491 (gnus-make-hashtable (length articles)))
6492 ;; Retrieve the headers and read them in.
6493 (gnus-message 5 "Fetching headers...")
6494 (setq gnus-newsgroup-headers
6495 (if (eq 'nov (setq gnus-headers-retrieved-by
6496 ;; This is a naughty hack. To get the
6497 ;; retrieval of old headers to work, we
6498 ;; set `nntp-nov-gap' to nil (locally),
6499 ;; and then just retrieve the headers.
6501 (if gnus-fetch-old-headers
6503 (gnus-retrieve-headers
6504 (if (not (eq 1 (car articles)))
6507 gnus-newsgroup-name))
6508 (gnus-retrieve-headers
6509 articles gnus-newsgroup-name))))
6511 (gnus-get-newsgroup-headers-xover articles))
6512 ;; If we were to fetch old headers, but the backend didn't
6513 ;; support XOVER, then it is possible we fetched one article
6514 ;; that we shouldn't have. If that's the case, we remove it.
6515 (if (not gnus-fetch-old-headers)
6518 (set-buffer nntp-server-buffer)
6519 (goto-char (point-min))
6521 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6522 (delete-region ; So we delete this head.
6524 (search-forward "\n.\n" nil t)))))
6525 (gnus-get-newsgroup-headers)))
6526 (gnus-message 5 "Fetching headers...done")
6527 ;; Remove canceled articles from the list of unread articles.
6528 (setq gnus-newsgroup-unreads
6529 (gnus-set-sorted-intersection
6530 gnus-newsgroup-unreads
6531 (mapcar (lambda (headers) (header-number headers))
6532 gnus-newsgroup-headers)))
6533 ;; Adjust and set lists of article marks.
6536 (gnus-adjust-marked-articles info)
6537 (setq gnus-newsgroup-marked
6539 (cdr (assq 'tick (setq marked (nth 3 info))))))
6540 (setq gnus-newsgroup-replied
6541 (copy-sequence (cdr (assq 'reply marked))))
6542 (setq gnus-newsgroup-expirable
6543 (copy-sequence (cdr (assq 'expire marked))))
6544 (setq gnus-newsgroup-killed
6545 (copy-sequence (cdr (assq 'killed marked))))
6546 (setq gnus-newsgroup-bookmarks
6547 (copy-sequence (cdr (assq 'bookmark marked))))
6548 (setq gnus-newsgroup-dormant
6549 (copy-sequence (cdr (assq 'dormant marked))))
6550 (setq gnus-newsgroup-scored
6551 (copy-sequence (cdr (assq 'score marked))))
6552 (setq gnus-newsgroup-processable nil)))
6553 ;; Create the header hashtb.
6554 (or gnus-newsgroup-headers-hashtb-by-number
6555 (gnus-make-headers-hashtable-by-number))
6556 ;; Check whether auto-expire is to be done in this group.
6557 (setq gnus-newsgroup-auto-expire
6558 (or (and (stringp gnus-auto-expirable-newsgroups)
6559 (string-match gnus-auto-expirable-newsgroups group))
6560 (memq 'auto-expire (nth 5 info))))
6561 ;; First and last article in this newsgroup.
6562 (and gnus-newsgroup-headers
6563 (setq gnus-newsgroup-begin
6564 (header-number (car gnus-newsgroup-headers)))
6565 (setq gnus-newsgroup-end
6566 (header-number (gnus-last-element gnus-newsgroup-headers))))
6567 (setq gnus-reffed-article-number -1)
6568 ;; GROUP is successfully selected.
6569 (or gnus-newsgroup-headers t)))))
6571 (defun gnus-articles-to-read (group read-all)
6572 ;; Find out what articles the user wants to read.
6574 ;; Select all articles if `read-all' is non-nil, or if all the
6575 ;; unread articles are dormant articles.
6576 (if (or (and read-all (not (numberp read-all)))
6577 (= (length gnus-newsgroup-unreads)
6578 (length gnus-newsgroup-dormant)))
6579 (gnus-uncompress-range
6580 (gnus-gethash group gnus-active-hashtb))
6581 gnus-newsgroup-unreads))
6582 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6583 (scored (length scored-list))
6584 (number (length articles))
6585 (marked (+ (length gnus-newsgroup-marked)
6586 (length gnus-newsgroup-dormant)))
6593 (cond ((and (or (<= scored marked)
6595 (numberp gnus-large-newsgroup)
6596 (> number gnus-large-newsgroup))
6600 "How many articles from %s (default %d): "
6601 gnus-newsgroup-name number))))
6602 (if (string-match "^[ \t]*$" input)
6604 ((and (> scored marked) (< scored number))
6608 "%s %s (%d scored, %d total): "
6609 "How many articles from"
6610 group scored number))))
6611 (if (string-match "^[ \t]*$" input)
6615 (setq select (if (stringp select) (string-to-number select) select))
6616 (if (or (null select) (zerop select))
6618 (if (and (not (zerop scored)) (<= (abs select) scored))
6620 (setq articles (sort scored-list '<))
6621 (setq number (length articles)))
6622 (setq articles (copy-sequence articles)))
6624 (if (< (abs select) number)
6626 ;; Select the N oldest articles.
6627 (setcdr (nthcdr (1- (abs select)) articles) nil)
6628 ;; Select the N most recent articles.
6629 (setq articles (nthcdr (- number select) articles))))
6630 (setq gnus-newsgroup-unselected
6631 (gnus-sorted-intersection
6632 gnus-newsgroup-unreads
6633 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6636 (defun gnus-killed-articles (killed articles)
6639 (if (inline (gnus-member-of-range (car articles) killed))
6640 (setq out (cons (car articles) out)))
6641 (setq articles (cdr articles)))
6644 (defun gnus-adjust-marked-articles (info &optional active)
6645 "Remove all marked articles that are no longer legal."
6646 (let ((marked-lists (nth 3 info))
6647 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6649 ;; There are many types of marked articles.
6651 (setq m (cdr (setq prev (car marked-lists))))
6652 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6653 ;; Make sure that all ticked articles are a subset of the
6654 ;; unread/unselected articles.
6656 (if (or (memq (car m) gnus-newsgroup-unreads)
6657 (memq (car m) gnus-newsgroup-unselected))
6659 (setcdr prev (cdr m)))
6661 ((eq 'score (car prev))
6662 ;; Scored articles should be a subset of
6663 ;; unread/unselected articles.
6665 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6666 (memq (car (car m)) gnus-newsgroup-unreads))
6668 (setcdr prev (cdr m)))
6670 ((eq 'bookmark (car prev))
6671 ;; Bookmarks should be a subset of active articles.
6673 (if (< (car (car m)) (car active))
6674 (setcdr prev (cdr m))
6677 ((eq 'killed (car prev))
6678 ;; Articles that have been through the kill process are
6679 ;; to be a subset of active articles.
6680 (while (and m (< (or (and (numberp (car m)) (car m))
6683 (setcdr prev (cdr m))
6685 (if (and m (< (or (and (numberp (car m)) (car m))
6688 (setcar (if (numberp (car m)) m (car m)) (car active))))
6689 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6690 ;; The replied and expirable articles have to be articles
6693 (if (< (car m) (car active))
6694 (setcdr prev (cdr m))
6697 (setq marked-lists (cdr marked-lists)))
6698 ;; Remove all lists that are empty.
6699 (setq marked-lists (nth 3 info))
6702 (while (= 1 (length (car marked-lists)))
6703 (setq marked-lists (cdr marked-lists)))
6704 (setq m (cdr (setq prev marked-lists)))
6706 (if (= 1 (length (car m)))
6707 (setcdr prev (cdr m))
6710 (setcar (nthcdr 3 info) marked-lists)))
6711 ;; Finally, if there are no marked lists at all left, and if there
6712 ;; are no elements after the lists in the info list, we just chop
6713 ;; the info list off before the marked lists.
6714 (and (null marked-lists)
6715 (not (nthcdr 4 info))
6716 (setcdr (nthcdr 2 info) nil)))
6719 (defun gnus-set-marked-articles
6720 (info ticked replied expirable killed dormant bookmark score)
6721 "Enter the various lists of marked articles into the newsgroup info list."
6723 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6724 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6725 (and expirable (setq newmarked (cons (cons 'expire expirable)
6727 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6728 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6729 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6731 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6734 (setcar (nthcdr 3 info) newmarked)
6735 (and (not newmarked)
6736 (not (nthcdr 4 info))
6737 (setcdr (nthcdr 2 info) nil)))
6739 (setcdr (nthcdr 2 info) (list newmarked))))))
6741 (defun gnus-add-marked-articles (group type articles &optional info force)
6742 ;; Add ARTICLES of TYPE to the info of GROUP.
6743 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6744 ;; add, but replace marked articles of TYPE with ARTICLES.
6745 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6748 (and (not (setq marked (nthcdr 3 info)))
6749 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6750 (and (not (setq m (assq type (car marked))))
6751 (setcar marked (cons (cons type articles) (car marked))))
6754 (nconc m articles)))))
6756 (defun gnus-set-mode-line (where)
6757 "This function sets the mode line of the article or summary buffers.
6758 If WHERE is `summary', the summary mode line format will be used."
6759 (if (memq where gnus-updated-mode-lines)
6762 (set-buffer gnus-summary-buffer)
6763 (let* ((mformat (if (eq where 'article)
6764 gnus-article-mode-line-format-spec
6765 gnus-summary-mode-line-format-spec))
6766 (group-name gnus-newsgroup-name)
6767 (article-number (or gnus-current-article 0))
6768 (unread (- (length gnus-newsgroup-unreads)
6769 (length gnus-newsgroup-dormant)))
6770 (unread-and-unticked
6771 (- unread (length gnus-newsgroup-marked)))
6772 (unselected (length gnus-newsgroup-unselected))
6773 (unread-and-unselected
6774 (cond ((and (zerop unread-and-unticked)
6775 (zerop unselected)) "")
6777 (format "{%d more}" unread-and-unticked))
6778 (t (format "{%d(+%d) more}"
6779 unread-and-unticked unselected))))
6781 (if gnus-current-headers
6782 (header-subject gnus-current-headers) ""))
6783 (max-len (and gnus-mode-non-string-length
6784 (- (frame-width) gnus-mode-non-string-length)))
6785 header) ;; passed as argument to any user-format-funcs
6786 (setq mode-string (eval mformat))
6787 (or (numberp max-len)
6788 (setq max-len (length mode-string)))
6789 (if (< max-len 4) (setq max-len 4))
6790 (if (> (length mode-string) max-len)
6791 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6792 ;; function `substring' might cut on a middle
6793 ;; of multi-octet character.
6795 (concat (gnus-truncate-string mode-string (- max-len 3))
6797 (setq mode-string (format (format "%%-%ds" max-len)
6799 (setq mode-line-buffer-identification mode-string)
6800 (set-buffer-modified-p t))))
6802 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6803 "Go through the HEADERS list and add all Xrefs to a hash table.
6804 The resulting hash table is returned, or nil if no Xrefs were found."
6805 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6807 (gnus-group-foreign-p from-newsgroup)
6809 (assoc (symbol-name (car from-method))
6810 gnus-valid-select-methods))))
6811 (gnus-group-real-prefix from-newsgroup)))
6812 (xref-hashtb (make-vector 63 0))
6813 start group entry number xrefs header)
6815 (setq header (car headers))
6816 (if (and (setq xrefs (header-xref header))
6817 (not (memq (header-number header) unreads)))
6820 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6821 (setq start (match-end 0))
6822 (setq group (concat prefix (substring xrefs (match-beginning 1)
6825 (string-to-int (substring xrefs (match-beginning 2)
6827 (if (setq entry (gnus-gethash group xref-hashtb))
6828 (setcdr entry (cons number (cdr entry)))
6829 (gnus-sethash group (cons number nil) xref-hashtb)))))
6830 (setq headers (cdr headers)))
6831 (if start xref-hashtb nil)))
6833 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6834 "Look through all the headers and mark the Xrefs as read."
6835 (let ((virtual (memq 'virtual
6836 (assoc (symbol-name (car (gnus-find-method-for-group
6838 gnus-valid-select-methods)))
6839 name entry info xref-hashtb idlist method
6842 (set-buffer gnus-group-buffer)
6843 (if (setq xref-hashtb
6844 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6847 (if (string= from-newsgroup (setq name (symbol-name group)))
6849 (setq idlist (symbol-value group))
6850 ;; Dead groups are not updated.
6852 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6854 (if (stringp (setq nth4 (nth 4 info)))
6855 (setq nth4 (gnus-server-to-method nth4))))
6856 ;; Only do the xrefs if the group has the same
6857 ;; select method as the group we have just read.
6858 (or (gnus-methods-equal-p
6859 nth4 (gnus-find-method-for-group from-newsgroup))
6862 (setq method (gnus-find-method-for-group
6864 (and (equal (car nth4) (car method))
6865 (equal (nth 1 nth4) (nth 1 method))))
6866 gnus-use-cross-reference
6867 (or (not (eq gnus-use-cross-reference t))
6869 ;; Only do cross-references on subscribed
6870 ;; groups, if that is what is wanted.
6871 (<= (nth 1 info) gnus-level-subscribed)))
6872 (gnus-group-make-articles-read name idlist expirable))))
6875 (defun gnus-group-make-articles-read (group articles expirable)
6877 (entry (gnus-gethash group gnus-newsrc-hashtb))
6878 (info (nth 2 entry))
6879 (active (gnus-gethash group gnus-active-hashtb))
6880 exps expirable range)
6881 ;; First peel off all illegal article numbers.
6883 (let ((ids articles)
6884 (ticked (cdr (assq 'tick (nth 3 info))))
6885 (dormant (cdr (assq 'dormant (nth 3 info))))
6890 (if (or (> id (cdr active))
6894 (setq articles (delq id articles)))
6895 (and (memq id expirable)
6896 (setq exps (cons id exps)))
6897 (setq ids (cdr ids)))))
6898 ;; Update expirable articles.
6899 (gnus-add-marked-articles nil 'expirable exps info)
6903 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6904 (setcar (nthcdr 2 info)
6908 (setq articles (sort articles '<)))))
6909 ;; Then we have to re-compute how many unread
6910 ;; articles there are in this group.
6915 (setq num (- (1+ (cdr active)) (car active))))
6916 ((not (listp (cdr range)))
6917 (setq num (- (cdr active) (- (1+ (cdr range))
6921 (if (numberp (car range))
6923 (setq num (+ num (- (1+ (cdr (car range)))
6924 (car (car range))))))
6925 (setq range (cdr range)))
6926 (setq num (- (cdr active) num))))
6927 ;; Update the number of unread articles.
6931 (length (cdr (assq 'tick (nth 3 info))))
6933 (cdr (assq 'dormant (nth 3 info)))))))
6934 ;; Update the group buffer.
6935 (gnus-group-update-group group t)))))
6937 (defun gnus-methods-equal-p (m1 m2)
6938 (let ((m1 (or m1 gnus-select-method))
6939 (m2 (or m2 gnus-select-method)))
6941 (and (eq (car m1) (car m2))
6942 (or (not (memq 'address (assoc (symbol-name (car m1))
6943 gnus-valid-select-methods)))
6944 (equal (nth 1 m1) (nth 1 m2)))))))
6946 (defsubst gnus-header-value ()
6947 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6949 (defvar gnus-newsgroup-none-id 0)
6951 (defun gnus-get-newsgroup-headers ()
6952 (setq gnus-article-internal-prepare-hook nil)
6953 (let ((cur nntp-server-buffer)
6954 (dependencies gnus-newsgroup-dependencies)
6955 headers id dep end ref)
6957 (set-buffer nntp-server-buffer)
6958 (goto-char (point-min))
6959 ;; Search to the beginning of the next header. Error messages
6960 ;; do not begin with 2 or 3.
6961 (while (re-search-forward "^[23][0-9]+ " nil t)
6962 (let ((header (make-vector 9 nil))
6963 (case-fold-search t)
6968 (header-set-number header (read cur))
6969 ;; This implementation of this function, with nine
6970 ;; search-forwards instead of the one re-search-forward and
6971 ;; a case (which basically was the old function) is actually
6972 ;; about twice as fast, even though it looks messier. You
6973 ;; can't have everything, I guess. Speed and elegance
6974 ;; doesn't always come hand in hand.
6976 (narrow-to-region (point) (or (save-excursion
6977 (search-forward "\n.\n" nil t))
6979 (if (search-forward "\nfrom: " nil t)
6980 (header-set-from header (gnus-header-value))
6981 (header-set-from header "(nobody)"))
6983 (if (search-forward "\nsubject: " nil t)
6984 (header-set-subject header (gnus-header-value))
6985 (header-set-subject header "(none)"))
6987 (and (search-forward "\nxref: " nil t)
6988 (header-set-xref header (gnus-header-value)))
6990 (or (numberp (and (search-forward "\nlines: " nil t)
6991 (header-set-lines header (read cur))))
6992 (header-set-lines header 0))
6994 (and (search-forward "\ndate: " nil t)
6995 (header-set-date header (gnus-header-value)))
6997 (if (search-forward "\nmessage-id: " nil t)
6998 (header-set-id header (setq id (gnus-header-value)))
6999 ;; If there was no message-id, we just fake one to make
7000 ;; subsequent routines simpler.
7003 (setq id (concat "none+"
7005 (setq gnus-newsgroup-none-id
7006 (1+ gnus-newsgroup-none-id)))))))
7008 (if (search-forward "\nreferences: " nil t)
7010 (header-set-references header (gnus-header-value))
7011 (setq end (match-end 0))
7018 (search-backward ">" end t)
7021 (search-backward "<" end t)
7023 ;; Get the references from the in-reply-to header if there
7024 ;; ware no references and the in-reply-to header looks
7026 (if (and (search-forward "\nin-reply-to: " nil t)
7027 (setq in-reply-to (gnus-header-value))
7028 (string-match "<[^>]+>" in-reply-to))
7030 (header-set-references
7032 (setq ref (substring in-reply-to (match-beginning 0)
7034 (setq ref (downcase ref)))
7036 ;; We do some threading while we read the headers. The
7037 ;; message-id and the last reference are both entered into
7038 ;; the same hash table. Some tippy-toeing around has to be
7039 ;; done in case an article has arrived before the article
7040 ;; which it refers to.
7041 (if (boundp (setq dep (intern (downcase id) dependencies)))
7042 (if (car (symbol-value dep))
7043 ;; An article with this Message-ID has already
7044 ;; been seen, so we ignore this one, except we add
7045 ;; any additional Xrefs (in case the two articles
7046 ;; came from different servers.
7049 (car (symbol-value dep))
7050 (concat (or (header-xref (car (symbol-value dep))) "")
7051 (or (header-xref header) "")))
7053 (setcar (symbol-value dep) header))
7054 (set dep (list header)))
7057 (if (boundp (setq dep (intern ref dependencies)))
7058 (setcdr (symbol-value dep)
7059 (cons header (cdr (symbol-value dep))))
7060 (set dep (list nil header)))
7061 (setq headers (cons header headers))))
7062 (goto-char (point-max))))))
7063 (nreverse headers)))
7065 ;; The following macros and functions were written by Felix Lee
7066 ;; <flee@cse.psu.edu>.
7068 (defmacro gnus-nov-read-integer ()
7070 (if (= (following-char) ?\t)
7072 (let ((num (condition-case nil (read buffer) (error nil))))
7073 (if (numberp num) num 0)))
7074 (or (eobp) (forward-char 1))))
7076 (defmacro gnus-nov-skip-field ()
7077 '(search-forward "\t" eol 'move))
7079 (defmacro gnus-nov-field ()
7080 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7082 ;; Goes through the xover lines and returns a list of vectors
7083 (defun gnus-get-newsgroup-headers-xover (sequence)
7084 "Parse the news overview data in the server buffer, and return a
7085 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7086 ;; Get the Xref when the users reads the articles since most/some
7087 ;; NNTP servers do not include Xrefs when using XOVER.
7088 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7089 (let ((cur nntp-server-buffer)
7090 (dependencies gnus-newsgroup-dependencies)
7091 number headers header)
7093 (set-buffer nntp-server-buffer)
7094 (goto-char (point-min))
7095 (while (and sequence (not (eobp)))
7096 (setq number (read cur))
7097 (while (and sequence (< (car sequence) number))
7098 (setq sequence (cdr sequence)))
7100 (eq number (car sequence))
7102 (setq sequence (cdr sequence))
7104 (inline (gnus-nov-parse-line number dependencies)))
7105 (setq headers (cons header headers)))))
7107 (setq headers (nreverse headers)))
7110 ;; This function has to be called with point after the article number
7111 ;; on the beginning of the line.
7112 (defun gnus-nov-parse-line (number dependencies)
7114 (eol (gnus-point-at-eol))
7115 (buffer (current-buffer))
7118 ;; overview: [num subject from date id refs chars lines misc]
7119 (narrow-to-region (point) eol)
7126 (gnus-nov-field) ; subject
7127 (gnus-nov-field) ; from
7128 (gnus-nov-field) ; date
7129 (setq id (or (gnus-nov-field)
7132 (setq none (1+ none)))))) ; id
7135 (let ((beg (point)))
7136 (search-forward "\t" eol)
7137 (if (search-backward ">" beg t)
7143 (search-backward "<" beg t)
7146 (gnus-nov-field)) ; refs
7147 (gnus-nov-read-integer) ; chars
7148 (gnus-nov-read-integer) ; lines
7149 (if (= (following-char) ?\n)
7151 (gnus-nov-field)) ; misc
7155 (message "Strange nov line.")
7161 ;; We build the thread tree.
7163 (if (boundp (setq dep (intern (downcase id) dependencies)))
7164 (if (car (symbol-value dep))
7165 ;; An article with this Message-ID has already been seen,
7166 ;; so we ignore this one, except we add any additional
7167 ;; Xrefs (in case the two articles came from different
7171 (car (symbol-value dep))
7172 (concat (or (header-xref (car (symbol-value dep))) "")
7173 (or (header-xref header) "")))
7175 (setcar (symbol-value dep) header))
7176 (set dep (list header))))
7179 (if (boundp (setq dep (intern (or ref "none")
7181 (setcdr (symbol-value dep)
7182 (cons header (cdr (symbol-value dep))))
7183 (set dep (list nil header)))))
7186 (defun gnus-article-get-xrefs ()
7187 "Fill in the Xref value in `gnus-current-headers', if necessary.
7188 This is meant to be called in `gnus-article-internal-prepare-hook'."
7189 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7190 gnus-current-headers)))
7191 (or (not gnus-use-cross-reference)
7193 (and (header-xref headers)
7194 (not (string= (header-xref headers) "")))
7195 (let ((case-fold-search t)
7198 (gnus-narrow-to-headers)
7199 (goto-char (point-min))
7200 (if (or (and (eq (downcase (following-char)) ?x)
7201 (looking-at "Xref:"))
7202 (search-forward "\nXref:" nil t))
7204 (goto-char (1+ (match-end 0)))
7205 (setq xref (buffer-substring (point)
7206 (progn (end-of-line) (point))))
7207 (header-set-xref headers xref))))))))
7209 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7210 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7212 (defun gnus-make-headers-hashtable-by-number ()
7213 "Make hashtable for the variable gnus-newsgroup-headers by number."
7215 (set-buffer gnus-summary-buffer)
7216 (let ((headers gnus-newsgroup-headers)
7218 (setq gnus-newsgroup-headers-hashtb-by-number
7219 (gnus-make-hashtable (length headers)))
7221 (setq header (car headers))
7222 (gnus-sethash (int-to-string (header-number header))
7223 header gnus-newsgroup-headers-hashtb-by-number)
7224 (setq headers (cdr headers))))))
7226 (defun gnus-more-header-backward ()
7227 "Find new header backward."
7228 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7229 (artnum gnus-newsgroup-begin)
7231 (while (and (not header)
7233 (setq artnum (1- artnum))
7234 (setq header (gnus-read-header artnum)))
7237 (defun gnus-more-header-forward (&optional backward)
7238 "Find new header forward.
7239 If BACKWARD, find new header backward instead."
7241 (gnus-more-header-backward)
7242 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7243 (artnum gnus-newsgroup-end)
7245 (while (and (not header)
7247 (setq artnum (1+ artnum))
7248 (setq header (gnus-read-header artnum)))
7251 (defun gnus-extend-newsgroup (header &optional backward)
7252 "Extend newsgroup selection with HEADER.
7253 Optional argument BACKWARD means extend toward backward."
7255 (let ((artnum (header-number header)))
7256 (setq gnus-newsgroup-headers
7258 (cons header gnus-newsgroup-headers)
7259 (nconc gnus-newsgroup-headers (list header))))
7260 (setq gnus-newsgroup-unselected
7261 (delq artnum gnus-newsgroup-unselected))
7262 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7263 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7265 (defun gnus-summary-work-articles (n)
7266 "Return a list of articles to be worked upon. The prefix argument,
7267 the list of process marked articles, and the current article will be
7268 taken into consideration."
7270 (if (and n (numberp n))
7271 (let ((backward (< n 0))
7275 (setq articles (cons (gnus-summary-article-number)
7277 (gnus-summary-search-forward nil nil backward))
7279 (sort articles (function <)))
7280 (or (reverse gnus-newsgroup-processable)
7281 (list (gnus-summary-article-number))))))
7283 (defun gnus-summary-search-group (&optional backward use-level)
7284 "Search for next unread newsgroup.
7285 If optional argument BACKWARD is non-nil, search backward instead."
7287 (set-buffer gnus-group-buffer)
7288 (if (gnus-group-search-forward
7289 backward nil (if use-level (gnus-group-group-level) nil))
7290 (gnus-group-group-name))))
7292 (defun gnus-summary-best-group (&optional exclude-group)
7293 "Find the name of the best unread group.
7294 If EXCLUDE-GROUP, do not go to this group."
7296 (set-buffer gnus-group-buffer)
7298 (gnus-group-best-unread-group exclude-group))))
7300 (defun gnus-subject-equal (s1 s2)
7302 ((null gnus-summary-gather-subject-limit)
7303 (equal (gnus-simplify-subject-re s1)
7304 (gnus-simplify-subject-re s2)))
7305 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7306 (equal (gnus-simplify-subject-fuzzy s1)
7307 (gnus-simplify-subject-fuzzy s2)))
7308 ((numberp gnus-summary-gather-subject-limit)
7309 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7310 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7314 (defun gnus-summary-search-subject (&optional backward unread subject)
7315 "Search for article forward.
7316 If BACKWARD is non-nil, search backward.
7317 If UNREAD is non-nil, only unread articles are selected.
7318 If SUBJECT is non-nil, the article which has the same subject will be
7320 (let ((func (if backward 'previous-single-property-change
7321 'next-single-property-change))
7326 (and gnus-summary-check-current unread
7327 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7331 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7334 (setq pos (funcall func (point) 'gnus-number))
7335 (goto-char (if backward (1- pos) pos))
7339 (eq (get-text-property (point) 'gnus-mark)
7342 (and (setq psubject (inline (gnus-summary-subject-string)))
7343 (inline (gnus-subject-equal subject psubject)))))))
7344 (if backward (if (bobp) nil (forward-char -1) t)
7345 (if (eobp) nil (forward-char 1) t)))))
7347 (progn (goto-char beg) nil)
7349 (get-text-property (point) 'gnus-number)
7350 (gnus-summary-position-cursor)))))
7352 (defun gnus-summary-pseudo-article ()
7353 "The thread level of the article on the current line."
7354 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7356 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7357 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7358 (defun gnus-summary-article-score ()
7359 "Return current article score."
7360 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7361 gnus-summary-default-score 0))
7363 (defun gnus-summary-recenter ()
7364 "Center point in the summary window.
7365 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7366 displayed, no centering will be performed."
7367 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7368 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7369 (let* ((top (cond ((< (window-height) 4) 0)
7370 ((< (window-height) 7) 1)
7372 (height (1- (window-height)))
7373 (bottom (save-excursion (goto-char (point-max))
7374 (forward-line (- height))
7376 (window (get-buffer-window (current-buffer))))
7378 ;; The user has to want it,
7379 gnus-auto-center-summary
7380 ;; the article buffer must be displayed,
7381 (get-buffer-window gnus-article-buffer)
7382 ;; Set the window start to either `bottom', which is the biggest
7383 ;; possible valid number, or the second line from the top,
7384 ;; whichever is the least.
7386 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7388 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7389 (defun gnus-short-group-name (group &optional levels)
7390 "Collapse GROUP name LEVELS."
7391 (let* ((name "") (foreign "") (depth -1) (skip 1)
7394 (while (string-match "\\." group skip)
7395 (setq skip (match-end 0)
7398 (if (string-match ":" group)
7399 (setq foreign (substring group 0 (match-end 0))
7400 group (substring group (match-end 0))))
7402 (if (and (string-match "\\." group) (> levels 0))
7403 (setq name (concat name (substring group 0 1))
7404 group (substring group (match-end 0))
7406 name (concat name "."))
7407 (setq name (concat foreign name group)
7411 (defun gnus-summary-jump-to-group (newsgroup)
7412 "Move point to NEWSGROUP in group mode buffer."
7413 ;; Keep update point of group mode buffer if visible.
7414 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7415 (save-window-excursion
7416 ;; Take care of tree window mode.
7417 (if (get-buffer-window gnus-group-buffer)
7418 (pop-to-buffer gnus-group-buffer))
7419 (gnus-group-jump-to-group newsgroup))
7421 ;; Take care of tree window mode.
7422 (if (get-buffer-window gnus-group-buffer)
7423 (pop-to-buffer gnus-group-buffer)
7424 (set-buffer gnus-group-buffer))
7425 (gnus-group-jump-to-group newsgroup))))
7427 ;; This function returns a list of article numbers based on the
7428 ;; difference between the ranges of read articles in this group and
7429 ;; the range of active articles.
7430 (defun gnus-list-of-unread-articles (group)
7431 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7432 (active (gnus-gethash group gnus-active-hashtb))
7435 ;; If none are read, then all are unread.
7437 (setq first (car active))
7438 ;; If the range of read articles is a single range, then the
7439 ;; first unread article is the article after the last read
7440 ;; article. Sounds logical, doesn't it?
7441 (if (not (listp (cdr read)))
7442 (setq first (1+ (cdr read)))
7443 ;; `read' is a list of ranges.
7444 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7445 (car (car read)))) 1)
7449 (while (< first nlast)
7450 (setq unread (cons first unread))
7451 (setq first (1+ first))))
7452 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7453 (setq nlast (if (atom (car (cdr read)))
7455 (car (car (cdr read)))))
7456 (setq read (cdr read)))))
7457 ;; And add the last unread articles.
7458 (while (<= first last)
7459 (setq unread (cons first unread))
7460 (setq first (1+ first)))
7461 ;; Return the list of unread articles.
7464 (defun gnus-list-of-read-articles (group)
7465 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7466 (active (gnus-gethash group gnus-active-hashtb)))
7468 (gnus-sorted-complement
7469 (gnus-uncompress-range active)
7470 (gnus-list-of-unread-articles group)))))
7472 ;; Various summary commands
7474 (defun gnus-summary-universal-argument ()
7475 "Perform any operation on all articles marked with the process mark."
7477 (gnus-set-global-variables)
7478 (let ((articles (reverse gnus-newsgroup-processable))
7480 (or articles (error "No articles marked"))
7481 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7482 (error "Undefined key"))
7484 (gnus-summary-goto-subject (car articles))
7485 (command-execute func)
7486 (gnus-summary-remove-process-mark (car articles))
7487 (setq articles (cdr articles)))))
7489 (defun gnus-summary-toggle-truncation (&optional arg)
7490 "Toggle truncation of summary lines.
7491 With arg, turn line truncation on iff arg is positive."
7493 (setq truncate-lines
7494 (if (null arg) (not truncate-lines)
7495 (> (prefix-numeric-value arg) 0)))
7498 (defun gnus-summary-reselect-current-group (&optional all)
7499 "Once exit and then reselect the current newsgroup.
7500 The prefix argument ALL means to select all articles."
7502 (gnus-set-global-variables)
7503 (let ((current-subject (gnus-summary-article-number))
7504 (group gnus-newsgroup-name))
7505 (setq gnus-newsgroup-begin nil)
7506 (gnus-summary-exit t)
7507 ;; We have to adjust the point of group mode buffer because the
7508 ;; current point was moved to the next unread newsgroup by
7510 (gnus-summary-jump-to-group group)
7511 (gnus-group-read-group all t)
7512 (gnus-summary-goto-subject current-subject)))
7514 (defun gnus-summary-rescan-group (&optional all)
7515 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7517 (gnus-set-global-variables)
7518 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7519 (let ((group gnus-newsgroup-name))
7521 (gnus-summary-jump-to-group group)
7523 (set-buffer gnus-group-buffer)
7524 (gnus-group-get-new-news-this-group 1))
7525 (gnus-summary-jump-to-group group)
7526 (gnus-group-read-group all)))
7528 (defun gnus-summary-update-info ()
7529 (let* ((group gnus-newsgroup-name))
7530 (if gnus-newsgroup-kill-headers
7531 (setq gnus-newsgroup-killed
7532 (gnus-compress-sequence
7534 (gnus-set-sorted-intersection
7535 (gnus-uncompress-range gnus-newsgroup-killed)
7536 (setq gnus-newsgroup-unselected
7537 (sort gnus-newsgroup-unselected '<)))
7538 (setq gnus-newsgroup-unreads
7539 (sort gnus-newsgroup-unreads '<))) t)))
7540 (or (listp (cdr gnus-newsgroup-killed))
7541 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7542 (let ((headers gnus-newsgroup-headers))
7543 (gnus-close-group group)
7544 (run-hooks 'gnus-exit-group-hook)
7545 (gnus-update-read-articles
7546 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7547 gnus-newsgroup-marked
7548 t gnus-newsgroup-replied gnus-newsgroup-expirable
7549 gnus-newsgroup-killed gnus-newsgroup-dormant
7550 gnus-newsgroup-bookmarks
7551 (and gnus-save-score gnus-newsgroup-scored))
7552 (and gnus-use-cross-reference
7553 (gnus-mark-xrefs-as-read
7554 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7555 ;; Do adaptive scoring, and possibly save score files.
7556 (and gnus-newsgroup-adaptive
7557 (gnus-score-adaptive))
7558 (and gnus-use-scoring
7559 (fboundp 'gnus-score-save)
7560 (funcall 'gnus-score-save))
7561 ;; Do not switch windows but change the buffer to work.
7562 (set-buffer gnus-group-buffer)
7563 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7564 (gnus-group-update-group group)))))
7566 (defun gnus-summary-exit (&optional temporary)
7567 "Exit reading current newsgroup, and then return to group selection mode.
7568 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7570 (gnus-set-global-variables)
7571 (gnus-kill-save-kill-buffer)
7572 (let* ((group gnus-newsgroup-name)
7573 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7574 gnus-newsgroup-name))))
7576 (buf (current-buffer)))
7577 (run-hooks 'gnus-summary-prepare-exit-hook)
7578 (gnus-summary-update-info) ; Make all changes in this group permanent.
7580 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7581 ;; Make sure where I was, and go to next newsgroup.
7582 (set-buffer gnus-group-buffer)
7585 (gnus-group-jump-to-group group)
7586 (gnus-group-next-unread-group 1)))
7589 ;; We set all buffer-local variables to nil. It is unclear why
7590 ;; this is needed, but if we don't, buffer-local variables are
7591 ;; not garbage-collected, it seems. This would the lead to en
7592 ;; ever-growing Emacs.
7594 (gnus-summary-clear-local-variables)
7595 ;; We clear the global counterparts of the buffer-local
7596 ;; variables as well, just to be on the safe side.
7597 (gnus-configure-windows 'group 'force)
7598 (gnus-summary-clear-local-variables)
7599 ;; Return to group mode buffer.
7600 (if (eq mode 'gnus-summary-mode)
7601 (gnus-kill-buffer buf))
7602 (if (get-buffer gnus-article-buffer)
7603 (bury-buffer gnus-article-buffer))
7604 (setq gnus-current-select-method gnus-select-method)
7605 (pop-to-buffer gnus-group-buffer)
7606 (if (not quit-config)
7608 (gnus-group-jump-to-group group)
7609 (gnus-group-next-unread-group 1))
7610 (if (not (buffer-name (car quit-config)))
7611 (gnus-configure-windows 'group 'force)
7612 (set-buffer (car quit-config))
7613 (and (eq major-mode 'gnus-summary-mode)
7614 (gnus-set-global-variables))
7615 (gnus-configure-windows (cdr quit-config))))
7616 (run-hooks 'gnus-summary-exit-hook))))
7618 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7619 (defun gnus-summary-exit-no-update (&optional no-questions)
7620 "Quit reading current newsgroup without updating read article info."
7622 (gnus-set-global-variables)
7623 (let* ((group gnus-newsgroup-name)
7624 (quit-config (nth 1 (assoc 'quit-config
7625 (gnus-find-method-for-group group)))))
7626 (if (or no-questions
7628 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7630 (gnus-close-group group)
7631 (gnus-summary-clear-local-variables)
7632 (set-buffer gnus-group-buffer)
7633 (gnus-summary-clear-local-variables)
7634 ;; Return to group selection mode.
7635 (gnus-configure-windows 'group 'force)
7636 (if (get-buffer gnus-summary-buffer)
7637 (kill-buffer gnus-summary-buffer))
7638 (if (get-buffer gnus-article-buffer)
7639 (bury-buffer gnus-article-buffer))
7640 (if (equal (gnus-group-group-name) group)
7641 (gnus-group-next-unread-group 1))
7644 (if (not (buffer-name (car quit-config)))
7645 (gnus-configure-windows 'group 'force)
7646 (set-buffer (car quit-config))
7647 (and (eq major-mode 'gnus-summary-mode)
7648 (gnus-set-global-variables))
7649 (gnus-configure-windows (cdr quit-config)))))))))
7651 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7652 (defun gnus-summary-fetch-faq (group)
7653 "Fetch the FAQ for the current group."
7654 (interactive (list gnus-newsgroup-name))
7655 (let ((gnus-faq-buffer
7656 (find-file (concat gnus-group-faq-directory
7657 (gnus-group-real-name group)))))
7658 (and gnus-faq-buffer (gnus-configure-windows 'summary-faq))))
7660 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7661 (defun gnus-summary-describe-group (&optional force)
7662 "Describe the current newsgroup."
7664 (gnus-group-describe-group force gnus-newsgroup-name))
7666 (defun gnus-summary-describe-briefly ()
7667 "Describe summary mode commands briefly."
7670 (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")))
7672 ;; Walking around group mode buffer from summary mode.
7674 (defun gnus-summary-next-group (&optional no-article target-group backward)
7675 "Exit current newsgroup and then select next unread newsgroup.
7676 If prefix argument NO-ARTICLE is non-nil, no article is selected
7677 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7678 previous group instead."
7680 (gnus-set-global-variables)
7681 (let ((current-group gnus-newsgroup-name)
7682 (current-buffer (current-buffer))
7684 ;; First we semi-exit this group to update Xrefs and all variables.
7685 ;; We can't do a real exit, because the window conf must remain
7686 ;; the same in case the user is prompted for info, and we don't
7687 ;; want the window conf to change before that...
7688 (gnus-summary-exit t)
7689 (while (not entered)
7690 ;; Then we find what group we are supposed to enter.
7691 (set-buffer gnus-group-buffer)
7692 (gnus-group-jump-to-group current-group)
7695 (if (eq gnus-keep-same-level 'best)
7696 (gnus-summary-best-group gnus-newsgroup-name)
7697 (gnus-summary-search-group backward gnus-keep-same-level))))
7698 (if (not target-group)
7699 ;; There are no further groups, so we return to the group
7702 (gnus-message 5 "Returning to the group buffer")
7704 (set-buffer current-buffer)
7705 (gnus-summary-exit))
7706 ;; We try to enter the target group.
7707 (gnus-group-jump-to-group target-group)
7708 (let ((unreads (gnus-group-group-unread)))
7709 (if (and (or (eq t unreads)
7710 (and unreads (not (zerop unreads))))
7711 (gnus-summary-read-group
7712 target-group nil no-article current-buffer))
7714 (setq current-group target-group
7715 target-group nil)))))))
7717 (defun gnus-summary-next-group-old (&optional no-article group backward)
7718 "Exit current newsgroup and then select next unread newsgroup.
7719 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7720 If BACKWARD, go to previous group instead."
7722 (gnus-set-global-variables)
7723 (let ((ingroup gnus-newsgroup-name)
7724 (sumbuf (current-buffer))
7726 (set-buffer gnus-group-buffer)
7728 (or (and (numberp (setq num (car (gnus-gethash
7729 group gnus-newsrc-hashtb))))
7733 (gnus-group-jump-to-group group)
7735 (gnus-group-jump-to-group ingroup))
7736 (gnus-summary-search-group backward)
7737 (let ((group (or group (gnus-summary-search-group backward))))
7739 (gnus-summary-exit t) ;Update all information.
7741 (gnus-summary-exit-no-update t)
7742 (gnus-group-jump-to-group ingroup)
7743 (setq group (gnus-summary-search-group backward))
7744 (gnus-message 5 "Selecting %s..." group)
7745 (set-buffer gnus-group-buffer)
7746 ;; We are now in group mode buffer.
7747 ;; Make sure group mode buffer point is on GROUP.
7748 (gnus-group-jump-to-group group)
7749 (if (not (eq gnus-auto-select-next 'quietly))
7751 (gnus-summary-read-group group nil no-article sumbuf)
7752 (and (string= gnus-newsgroup-name ingroup)
7753 (bufferp sumbuf) (buffer-name sumbuf)
7755 (set-buffer (setq gnus-summary-buffer sumbuf))
7756 (gnus-summary-exit-no-update t))))
7757 (let ((prevgroup group))
7758 (gnus-group-jump-to-group ingroup)
7759 (setq group (gnus-summary-search-group backward))
7760 (gnus-summary-read-group group nil no-article sumbuf)
7761 (while (and (string= gnus-newsgroup-name ingroup)
7763 (buffer-name sumbuf)
7764 (not (string= prevgroup (gnus-group-group-name))))
7765 (set-buffer gnus-group-buffer)
7766 (gnus-summary-read-group
7767 (setq prevgroup (gnus-group-group-name))
7768 nil no-article sumbuf))
7769 (and (string= prevgroup (gnus-group-group-name))
7770 ;; We have reached the final group in the group
7773 (if (buffer-name sumbuf)
7776 (gnus-summary-exit)))))))))))
7778 (defun gnus-summary-prev-group (&optional no-article)
7779 "Exit current newsgroup and then select previous unread newsgroup.
7780 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7782 (gnus-summary-next-group no-article nil t))
7784 ;; Walking around summary lines.
7786 (defun gnus-summary-first-subject (&optional unread)
7787 "Go to the first unread subject.
7788 If UNREAD is non-nil, go to the first unread article.
7789 Returns nil if there are no unread articles."
7793 (goto-char (point-min)))
7796 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7799 ;; There are no unread articles.
7800 (gnus-message 3 "No more unread articles")
7802 (gnus-summary-position-cursor)))
7804 (defun gnus-summary-next-subject (n &optional unread dont-display)
7805 "Go to next N'th summary line.
7806 If N is negative, go to the previous N'th subject line.
7807 If UNREAD is non-nil, only unread articles are selected.
7808 The difference between N and the actual number of steps taken is
7811 (let ((backward (< n 0))
7814 (gnus-summary-search-forward unread nil backward))
7816 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7817 (if unread " unread" "")))
7820 (gnus-summary-recenter)
7821 (gnus-summary-position-cursor)))
7824 (defun gnus-summary-next-unread-subject (n)
7825 "Go to next N'th unread summary line."
7827 (gnus-summary-next-subject n t))
7829 (defun gnus-summary-prev-subject (n &optional unread)
7830 "Go to previous N'th summary line.
7831 If optional argument UNREAD is non-nil, only unread article is selected."
7833 (gnus-summary-next-subject (- n) unread))
7835 (defun gnus-summary-prev-unread-subject (n)
7836 "Go to previous N'th unread summary line."
7838 (gnus-summary-next-subject (- n) t))
7840 (defun gnus-summary-goto-subject (article)
7841 "Go the subject line of ARTICLE."
7845 (completing-read "Article number: "
7849 (int-to-string (header-number headers))))
7850 gnus-newsgroup-headers)
7851 nil 'require-match))))
7852 (or article (error "No article number"))
7854 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
7855 'gnus-number article)))
7857 (gnus-summary-show-thread)
7858 ;; Skip dummy articles.
7859 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7866 (gnus-summary-position-cursor)))))
7868 ;; Walking around summary lines with displaying articles.
7870 (defun gnus-summary-expand-window (&optional arg)
7871 "Make the summary buffer take up the entire Emacs frame.
7872 Given a prefix, will force an `article' buffer configuration."
7874 (gnus-set-global-variables)
7876 (gnus-configure-windows 'article 'force)
7877 (gnus-configure-windows 'summary 'force)))
7879 (defun gnus-summary-display-article (article &optional all-header)
7880 "Display ARTICLE in article buffer."
7881 (gnus-set-global-variables)
7885 (gnus-article-prepare article all-header)
7886 (gnus-summary-show-thread)
7887 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7890 (gnus-summary-position-cursor)))
7891 (run-hooks 'gnus-select-article-hook)
7892 (gnus-summary-recenter)
7893 (gnus-summary-goto-subject article)
7894 ;; Successfully display article.
7895 (gnus-summary-update-line)
7896 (gnus-article-set-window-start
7897 (cdr (assq article gnus-newsgroup-bookmarks)))
7900 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7901 "Select the current article.
7902 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7903 non-nil, the article will be re-fetched even if it already present in
7904 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7906 (and (not pseudo) (gnus-summary-pseudo-article)
7907 (error "This is a pseudo-article."))
7908 (let ((article (or article (gnus-summary-article-number)))
7909 (all-headers (not (not all-headers))) ;Must be T or NIL.
7913 (set-buffer gnus-summary-buffer)
7914 (if (or (null gnus-current-article)
7915 (null gnus-article-current)
7916 (null (get-buffer gnus-article-buffer))
7917 (not (eq article (cdr gnus-article-current)))
7918 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7920 ;; The requested article is different from the current article.
7922 (gnus-summary-display-article article all-headers)
7924 (if (or all-headers gnus-show-all-headers)
7925 (gnus-article-show-all-headers))
7928 (gnus-article-set-window-start
7929 (cdr (assq article gnus-newsgroup-bookmarks)))))))
7931 (defun gnus-summary-set-current-mark (&optional current-mark)
7932 "Obsolete function."
7935 (defun gnus-summary-next-article (&optional unread subject backward)
7936 "Select the next article.
7937 If UNREAD, only unread articles are selected.
7938 If SUBJECT, only articles with SUBJECT are selected.
7939 If BACKWARD, the previous article is selected instead of the next."
7941 (gnus-set-global-variables)
7944 ;; Is there such an article?
7945 ((or (gnus-summary-display-article
7946 (gnus-summary-search-forward unread subject backward))
7947 (eq (gnus-summary-article-mark) gnus-canceled-mark))
7948 (gnus-summary-position-cursor))
7949 ;; If not, we try the first unread, if that is wanted.
7951 gnus-auto-select-same
7952 (gnus-summary-first-unread-article))
7953 (gnus-message 6 "Wrapped"))
7954 ;; Try to get next/previous article not displayed in this group.
7955 ((and gnus-auto-extend-newsgroup
7956 (not unread) (not subject)
7957 (setq header (gnus-more-header-forward backward)))
7958 (gnus-extend-newsgroup header backward)
7959 (let ((buffer-read-only nil))
7960 (goto-char (if backward (point-min) (point-max)))
7961 (gnus-summary-prepare-threads (list header)))
7962 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7963 gnus-newsgroup-end)))
7964 ;; Go to next/previous group.
7966 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7967 (gnus-summary-jump-to-group gnus-newsgroup-name))
7968 (let ((cmd (aref (this-command-keys) 0))
7970 (if (eq gnus-keep-same-level 'best)
7971 (gnus-summary-best-group gnus-newsgroup-name)
7972 (gnus-summary-search-group backward gnus-keep-same-level))))
7973 ;; For some reason, the group window gets selected. We change
7975 (select-window (get-buffer-window (current-buffer)))
7976 ;; Keep just the event type of CMD.
7977 (and (listp cmd) (setq cmd (car cmd)))
7978 ;; Select next unread newsgroup automagically.
7980 ((not gnus-auto-select-next)
7981 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7982 ((eq gnus-auto-select-next 'quietly)
7984 (if (assoc 'quit-config (gnus-find-method-for-group
7985 gnus-newsgroup-name))
7987 (gnus-message 7 "No more%s articles (%s)..."
7988 (if unread " unread" "")
7989 (if group (concat "selecting " group)
7991 (gnus-summary-next-group nil group backward)))
7993 (let ((keystrokes '(?\C-n ?\C-p))
7995 (while (or (null key) (memq key keystrokes))
7997 7 "No more%s articles%s" (if unread " unread" "")
7998 (if (and group (not (assoc 'quit-config
7999 (gnus-find-method-for-group
8000 gnus-newsgroup-name))))
8001 (format " (Type %s for %s [%s])"
8002 (single-key-description cmd) group
8003 (car (gnus-gethash group gnus-newsrc-hashtb)))
8004 (format " (Type %s to exit %s)"
8005 (single-key-description cmd)
8006 gnus-newsgroup-name)))
8007 ;; Confirm auto selection.
8008 (let* ((event (read-event)))
8009 (setq key (if (listp event) (car event) event))
8010 (if (memq key keystrokes)
8011 (let ((obuf (current-buffer)))
8012 (switch-to-buffer gnus-group-buffer)
8014 (gnus-group-jump-to-group group))
8016 (execute-kbd-macro (char-to-string key))
8018 (setq group (gnus-group-group-name))
8019 (switch-to-buffer obuf)))))
8021 (if (or (not group) (assoc 'quit-config
8022 (gnus-find-method-for-group
8023 gnus-newsgroup-name)))
8025 (gnus-summary-next-group nil group backward))
8026 (setq unread-command-events (list key)))))))))))
8028 (defun gnus-summary-next-unread-article ()
8029 "Select unread article after current one."
8031 (gnus-summary-next-article t (and gnus-auto-select-same
8032 (gnus-summary-subject-string))))
8034 (defun gnus-summary-prev-article (&optional unread subject)
8035 "Select the article after the current one.
8036 If UNREAD is non-nil, only unread articles are selected."
8038 (gnus-summary-next-article unread subject t))
8040 (defun gnus-summary-prev-unread-article ()
8041 "Select unred article before current one."
8043 (gnus-summary-prev-article t (and gnus-auto-select-same
8044 (gnus-summary-subject-string))))
8046 (defun gnus-summary-next-page (&optional lines circular)
8047 "Show next page of selected article.
8048 If end of article, select next article.
8049 Argument LINES specifies lines to be scrolled up.
8050 If CIRCULAR is non-nil, go to the start of the article instead of
8051 instead of selecting the next article when reaching the end of the
8054 (setq gnus-summary-buffer (current-buffer))
8055 (gnus-set-global-variables)
8056 (let ((article (gnus-summary-article-number))
8058 (gnus-configure-windows 'article)
8059 (if (or (null gnus-current-article)
8060 (null gnus-article-current)
8061 (/= article (cdr gnus-article-current))
8062 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8063 ;; Selected subject is different from current article's.
8064 (gnus-summary-display-article article)
8065 (gnus-eval-in-buffer-window
8067 (setq endp (gnus-article-next-page lines)))
8070 (gnus-summary-beginning-of-article))
8072 (gnus-message 3 "End of message"))
8074 (gnus-summary-next-unread-article)))))
8075 (gnus-summary-recenter)
8076 (gnus-summary-position-cursor)))
8078 (defun gnus-summary-prev-page (&optional lines)
8079 "Show previous page of selected article.
8080 Argument LINES specifies lines to be scrolled down."
8082 (gnus-set-global-variables)
8083 (let ((article (gnus-summary-article-number)))
8084 (gnus-configure-windows 'article)
8085 (if (or (null gnus-current-article)
8086 (null gnus-article-current)
8087 (/= article (cdr gnus-article-current))
8088 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8089 ;; Selected subject is different from current article's.
8090 (gnus-summary-display-article article)
8091 (gnus-summary-recenter)
8092 (gnus-eval-in-buffer-window gnus-article-buffer
8093 (gnus-article-prev-page lines))))
8094 (gnus-summary-position-cursor))
8096 (defun gnus-summary-scroll-up (lines)
8097 "Scroll up (or down) one line current article.
8098 Argument LINES specifies lines to be scrolled up (or down if negative)."
8100 (gnus-set-global-variables)
8101 (gnus-configure-windows 'article)
8102 (or (gnus-summary-select-article nil nil 'pseudo)
8103 (gnus-eval-in-buffer-window
8106 (if (gnus-article-next-page lines)
8107 (gnus-message 3 "End of message")))
8109 (gnus-article-prev-page (- lines))))))
8110 (gnus-summary-recenter)
8111 (gnus-summary-position-cursor))
8113 (defun gnus-summary-next-same-subject ()
8114 "Select next article which has the same subject as current one."
8116 (gnus-set-global-variables)
8117 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8119 (defun gnus-summary-prev-same-subject ()
8120 "Select previous article which has the same subject as current one."
8122 (gnus-set-global-variables)
8123 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8125 (defun gnus-summary-next-unread-same-subject ()
8126 "Select next unread article which has the same subject as current one."
8128 (gnus-set-global-variables)
8129 (gnus-summary-next-article t (gnus-summary-subject-string)))
8131 (defun gnus-summary-prev-unread-same-subject ()
8132 "Select previous unread article which has the same subject as current one."
8134 (gnus-set-global-variables)
8135 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8137 (defun gnus-summary-first-unread-article ()
8138 "Select the first unread article.
8139 Return nil if there are no unread articles."
8141 (gnus-set-global-variables)
8143 (if (gnus-summary-first-subject t)
8144 (gnus-summary-display-article (gnus-summary-article-number)))
8145 (gnus-summary-position-cursor)))
8147 (defun gnus-summary-best-unread-article ()
8148 "Select the unread article with the highest score."
8150 (gnus-set-global-variables)
8151 (let ((scored gnus-newsgroup-scored)
8155 (or (> best (cdr (car scored)))
8156 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
8157 (not (memq art gnus-newsgroup-marked))
8158 (not (memq art gnus-newsgroup-dormant))
8159 (if (= best (cdr (car scored)))
8160 (setq article (min art article))
8162 (setq best (cdr (car scored))))))
8163 (setq scored (cdr scored)))
8165 ((or (not article) (null gnus-newsgroup-unreads))
8166 ;; We didn't find any scored articles, so we just jump to the
8168 (gnus-summary-first-unread-article))
8169 ((> best gnus-summary-default-score)
8170 ;; We found one, and it's bigger than the default score, so we
8172 (gnus-summary-goto-article article))
8174 ;; We found an article, but it has a score lower than the
8175 ;; defaults, so we try to find an article with the default
8177 (goto-char (point-min))
8178 (while (and (or (not (= (gnus-summary-article-mark) gnus-unread-mark))
8179 (not (eq (cdr (memq (gnus-summary-article-number)
8180 gnus-newsgroup-scored))
8181 gnus-summary-default-score)))
8182 (zerop (forward-line 1))
8184 ;; We jump to the article we have finally found.
8185 (gnus-summary-goto-article (gnus-summary-article-number))))
8186 (gnus-summary-position-cursor)))
8188 (defun gnus-summary-goto-article (article &optional all-headers)
8189 "Fetch ARTICLE and display it if it exists.
8190 If ALL-HEADERS is non-nil, no header lines are hidden."
8196 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
8197 gnus-newsgroup-headers)
8198 nil 'require-match))))
8200 (and (gnus-summary-goto-subject article)
8201 (gnus-summary-display-article article all-headers))
8202 (gnus-summary-position-cursor)))
8204 (defun gnus-summary-goto-last-article ()
8205 "Go to the previously read article."
8208 (and gnus-last-article
8209 (gnus-summary-goto-article gnus-last-article))
8210 (gnus-summary-position-cursor)))
8212 (defun gnus-summary-pop-article (number)
8213 "Pop one article off the history and go to the previous.
8214 NUMBER articles will be popped off."
8217 (setq gnus-newsgroup-history
8218 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8220 (gnus-summary-goto-article (car to))
8221 (error "Article history empty")))
8222 (gnus-summary-position-cursor))
8224 ;; Summary article oriented commands
8226 (defun gnus-summary-refer-parent-article (n)
8227 "Refer parent article N times.
8228 The difference between N and the number of articles fetched is returned."
8230 (gnus-set-global-variables)
8234 (let ((ref (header-references (gnus-get-header-by-num
8235 (gnus-summary-article-number)))))
8236 (if (and ref (not (equal ref ""))
8237 (string-match "<[^<>]*>[ \t]*$" ref))
8238 (gnus-summary-refer-article
8239 (substring ref (match-beginning 0) (match-end 0)))
8240 (gnus-message 1 "No references in article %d"
8241 (gnus-summary-article-number))
8244 (gnus-summary-position-cursor)
8247 (defun gnus-summary-refer-article (message-id)
8248 "Refer article specified by MESSAGE-ID.
8249 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8250 (interactive "sMessage-ID: ")
8251 (if (or (not (stringp message-id))
8252 (zerop (length message-id)))
8254 ;; Construct the correct Message-ID if necessary.
8255 ;; Suggested by tale@pawl.rpi.edu.
8256 (or (string-match "^<" message-id)
8257 (setq message-id (concat "<" message-id)))
8258 (or (string-match ">$" message-id)
8259 (setq message-id (concat message-id ">")))
8260 (let ((header (car (gnus-gethash (downcase message-id)
8261 gnus-newsgroup-dependencies))))
8263 (or (gnus-summary-goto-article (header-number header))
8264 ;; The header has been read, but the article had been
8265 ;; expunged, so we insert it again.
8267 (gnus-summary-insert-line
8268 nil header 0 nil gnus-read-mark nil nil
8269 (header-subject header))
8271 (header-number header)))
8272 (let ((gnus-override-method gnus-refer-article-method)
8273 (gnus-ancient-mark gnus-read-mark)
8274 (tmp-point (window-start
8275 (get-buffer-window gnus-article-buffer)))
8277 (and gnus-refer-article-method
8278 (or (gnus-server-opened gnus-refer-article-method)
8279 (gnus-open-server gnus-refer-article-method)))
8280 ;; Save the old article buffer.
8282 (set-buffer gnus-article-buffer)
8283 (gnus-kill-buffer " *temp Article*")
8284 (setq tmp-buf (rename-buffer " *temp Article*")))
8286 (if (gnus-article-prepare
8287 message-id nil (gnus-read-header message-id))
8289 (setq number (header-number gnus-current-headers))
8290 (gnus-rebuild-thread message-id)
8291 (gnus-summary-goto-subject number)
8292 (gnus-summary-recenter)
8293 (gnus-article-set-window-start
8294 (cdr (assq number gnus-newsgroup-bookmarks)))
8296 ;; We restore the old article buffer.
8298 (kill-buffer gnus-article-buffer)
8299 (set-buffer tmp-buf)
8300 (rename-buffer gnus-article-buffer)
8301 (let ((buffer-read-only nil))
8303 (set-window-start (get-buffer-window (current-buffer))
8304 tmp-point)))))))))))
8306 (defun gnus-summary-enter-digest-group ()
8307 "Enter a digest group based on the current article."
8309 (gnus-set-global-variables)
8310 (gnus-summary-select-article)
8311 ;; We do not want a narrowed article.
8312 (gnus-summary-stop-page-breaking)
8313 (let ((name (format "%s-%d"
8314 (gnus-group-prefixed-name
8315 gnus-newsgroup-name (list 'nndoc ""))
8316 gnus-current-article))
8317 (ogroup gnus-newsgroup-name)
8318 (buf (current-buffer)))
8319 (if (gnus-group-read-ephemeral-group
8320 name (list 'nndoc name
8321 (list 'nndoc-address (get-buffer gnus-article-buffer))
8322 '(nndoc-article-type digest))
8324 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8325 (list (list (cons 'to-group ogroup))))
8326 (switch-to-buffer buf)
8327 (gnus-set-global-variables)
8328 (gnus-configure-windows 'summary)
8329 (gnus-message 3 "Article not a digest?"))))
8331 (defun gnus-summary-isearch-article ()
8332 "Do incremental search forward on current article."
8334 (gnus-set-global-variables)
8335 (gnus-summary-select-article)
8336 (gnus-eval-in-buffer-window
8337 gnus-article-buffer (isearch-forward)))
8339 (defun gnus-summary-search-article-forward (regexp &optional backward)
8340 "Search for an article containing REGEXP forward.
8341 If BACKWARD, search backward instead."
8344 (format "Search article %s (regexp%s): "
8345 (if current-prefix-arg "backward" "forward")
8346 (if gnus-last-search-regexp
8347 (concat ", default " gnus-last-search-regexp)
8349 current-prefix-arg))
8350 (gnus-set-global-variables)
8351 (if (string-equal regexp "")
8352 (setq regexp (or gnus-last-search-regexp ""))
8353 (setq gnus-last-search-regexp regexp))
8354 (if (gnus-summary-search-article regexp backward)
8355 (gnus-article-set-window-start
8356 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8357 (error "Search failed: \"%s\"" regexp)))
8359 (defun gnus-summary-search-article-backward (regexp)
8360 "Search for an article containing REGEXP backward."
8363 (format "Search article backward (regexp%s): "
8364 (if gnus-last-search-regexp
8365 (concat ", default " gnus-last-search-regexp)
8367 (gnus-summary-search-article-forward regexp 'backward))
8369 (defun gnus-summary-search-article (regexp &optional backward)
8370 "Search for an article containing REGEXP.
8371 Optional argument BACKWARD means do search for backward.
8372 gnus-select-article-hook is not called during the search."
8373 (let ((gnus-select-article-hook nil) ;Disable hook.
8374 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8377 (function re-search-backward) (function re-search-forward)))
8380 ;; Hidden thread subtrees must be searched for ,too.
8381 (gnus-summary-show-all-threads)
8382 (if (eobp) (forward-line -1))
8383 ;; First of all, search current article.
8384 ;; We don't want to read article again from NNTP server nor reset
8386 (gnus-summary-select-article)
8387 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8388 (setq last gnus-current-article)
8389 (gnus-eval-in-buffer-window gnus-article-buffer
8392 ;; Begin search from current point.
8393 (setq found (funcall re-search regexp nil t))))
8394 ;; Then search next articles.
8395 (while (and (not found)
8396 (gnus-summary-display-article
8397 (gnus-summary-search-subject backward nil nil)))
8398 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8399 (gnus-eval-in-buffer-window gnus-article-buffer
8402 (goto-char (if backward (point-max) (point-min)))
8403 (setq found (funcall re-search regexp nil t)))))
8405 ;; Adjust article pointer.
8406 (or (eq last gnus-current-article)
8407 (setq gnus-last-article last))
8408 ;; Return T if found such article.
8411 (defun gnus-summary-execute-command (header regexp command &optional backward)
8412 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8413 If HEADER is an empty string (or nil), the match is done on the entire
8414 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8416 (list (let ((completion-ignore-case t))
8419 (mapcar (lambda (string) (list string))
8420 '("Number" "Subject" "From" "Lines" "Date"
8421 "Message-ID" "Xref" "References"))
8422 nil 'require-match))
8423 (read-string "Regexp: ")
8424 (read-key-sequence "Command: ")
8425 current-prefix-arg))
8426 (gnus-set-global-variables)
8427 ;; Hidden thread subtrees must be searched as well.
8428 (gnus-summary-show-all-threads)
8429 ;; We don't want to change current point nor window configuration.
8431 (save-window-excursion
8432 (gnus-message 6 "Executing %s..." (key-description command))
8433 ;; We'd like to execute COMMAND interactively so as to give arguments.
8434 (gnus-execute header regexp
8436 (call-interactively '(, (key-binding command)))))
8438 (gnus-message 6 "Executing %s...done" (key-description command)))))
8440 (defun gnus-summary-beginning-of-article ()
8441 "Scroll the article back to the beginning."
8443 (gnus-set-global-variables)
8444 (gnus-summary-select-article)
8445 (gnus-configure-windows 'article)
8446 (gnus-eval-in-buffer-window
8449 (goto-char (point-min))
8450 (and gnus-break-pages (gnus-narrow-to-page))))
8452 (defun gnus-summary-end-of-article ()
8453 "Scroll to the end of the article."
8455 (gnus-set-global-variables)
8456 (gnus-summary-select-article)
8457 (gnus-configure-windows 'article)
8458 (gnus-eval-in-buffer-window
8461 (goto-char (point-max))
8462 (and gnus-break-pages (gnus-narrow-to-page))))
8464 (defun gnus-summary-show-article (&optional no-refetch)
8465 "Force re-fetching of the current article.
8466 If the prefix argument NO-REFETCH is non-nil, no actual refetch will
8467 be performed. The current article will simply be redisplayed."
8469 (gnus-set-global-variables)
8470 (if (not no-refetch)
8471 (gnus-summary-select-article gnus-have-all-headers t)
8472 (or gnus-current-article
8473 (error "There is no current article"))
8474 (gnus-summary-goto-subject gnus-current-article)
8475 (gnus-configure-windows 'article)
8476 (gnus-summary-position-cursor)))
8478 (defun gnus-summary-verbose-headers (&optional arg)
8479 "Toggle permanent full header display.
8480 If ARG is a positive number, turn header display on.
8481 If ARG is a negative number, turn header display off."
8483 (gnus-set-global-variables)
8484 (gnus-summary-toggle-header arg)
8485 (setq gnus-show-all-headers
8486 (cond ((or (not (numberp arg))
8488 (not gnus-show-all-headers))
8492 (defun gnus-summary-toggle-header (&optional arg)
8493 "Show the headers if they are hidden, or hide them if they are shown.
8494 If ARG is a positive number, show the entire header.
8495 If ARG is a negative number, hide the unwanted header lines."
8497 (gnus-set-global-variables)
8499 (set-buffer gnus-article-buffer)
8500 (let ((buffer-read-only nil))
8502 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8503 gnus-hidden-properties)
8504 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8505 (if (text-property-any (point-min) (point-max) 'invisible t)
8506 (remove-text-properties
8507 (point-min) (point-max) gnus-hidden-properties)
8508 ;; We hide the headers. This song and dance act below is
8509 ;; done because `gnus-have-all-headers' is buffer-local to
8510 ;; the summary buffer, and we only want to temporarily
8511 ;; change it in that buffer. Ugh.
8512 (let ((have gnus-have-all-headers))
8514 (set-buffer gnus-summary-buffer)
8515 (setq gnus-have-all-headers nil)
8517 (set-buffer gnus-article-buffer)
8518 (run-hooks 'gnus-article-display-hook))
8519 (setq gnus-have-all-headers have)))))
8520 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8522 (defun gnus-summary-show-all-headers ()
8523 "Make all header lines visible."
8525 (gnus-set-global-variables)
8526 (gnus-article-show-all-headers))
8528 (defun gnus-summary-toggle-mime (&optional arg)
8529 "Toggle MIME processing.
8530 If ARG is a positive number, turn MIME processing on."
8532 (gnus-set-global-variables)
8533 (setq gnus-show-mime
8534 (if (null arg) (not gnus-show-mime)
8535 (> (prefix-numeric-value arg) 0)))
8536 (gnus-summary-select-article t 'force))
8538 (defun gnus-summary-caesar-message (&optional arg)
8539 "Caesar rotate the current article by 13.
8540 The numerical prefix specifies how manu places to rotate each letter
8543 (gnus-set-global-variables)
8544 (gnus-summary-select-article)
8545 (let ((mail-header-separator ""))
8546 (gnus-eval-in-buffer-window
8550 (let ((last (point)))
8551 (news-caesar-buffer-body arg)
8555 (defun gnus-summary-stop-page-breaking ()
8556 "Stop page breaking in the current article."
8558 (gnus-set-global-variables)
8559 (gnus-summary-select-article)
8560 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8562 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8564 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8565 "Move the current article to a different newsgroup.
8566 If N is a positive number, move the N next articles.
8567 If N is a negative number, move the N previous articles.
8568 If N is nil and any articles have been marked with the process mark,
8569 move those articles instead.
8570 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8571 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8572 re-spool using this method.
8573 For this function to work, both the current newsgroup and the
8574 newsgroup that you want to move to have to support the `request-move'
8575 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8577 (gnus-set-global-variables)
8578 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8579 (error "The current newsgroup does not support article moving"))
8580 (let ((articles (gnus-summary-work-articles n))
8581 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8582 art-group to-method sel-met)
8583 (if (and (not to-newsgroup) (not select-method))
8586 (format "Where do you want to move %s? %s"
8587 (if (> (length articles) 1)
8588 (format "these %d articles" (length articles))
8590 (if gnus-current-move-group
8591 (format "(%s default) " gnus-current-move-group)
8593 gnus-active-hashtb nil nil prefix)))
8596 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8597 (setq to-newsgroup (or gnus-current-move-group "")))
8598 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8599 (gnus-activate-newsgroup to-newsgroup)
8600 (error "No such group: %s" to-newsgroup))
8601 (setq gnus-current-move-group to-newsgroup)))
8602 (setq to-method (if select-method (list select-method "")
8603 (gnus-find-method-for-group to-newsgroup)))
8604 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8605 (error "%s does not support article copying" (car to-method)))
8606 (or (gnus-server-opened to-method)
8607 (gnus-open-server to-method)
8608 (error "Can't open server %s" (car to-method)))
8609 (gnus-message 6 "Moving to %s: %s..."
8610 (or select-method to-newsgroup) articles)
8613 (gnus-request-move-article
8614 (car articles) ; Article to move
8615 gnus-newsgroup-name ; From newsgrouo
8616 (nth 1 (gnus-find-method-for-group
8617 gnus-newsgroup-name)) ; Server
8618 (list 'gnus-request-accept-article
8620 (list 'quote select-method)
8622 (not (cdr articles))) ; Accept form
8623 (not (cdr articles)))) ; Only save nov last time
8624 (let* ((buffer-read-only nil)
8627 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8629 (gnus-group-prefixed-name
8631 (if select-method (list select-method "")
8632 (gnus-find-method-for-group to-newsgroup)))
8633 gnus-newsrc-hashtb)))
8634 (info (nth 2 entry))
8635 (article (car articles)))
8636 (gnus-summary-goto-subject article)
8638 (delete-region (point)
8639 (progn (forward-line 1) (point)))
8640 (if (not (memq article gnus-newsgroup-unreads))
8641 (setcar (cdr (cdr info))
8642 (gnus-add-to-range (nth 2 info)
8643 (list (cdr art-group)))))
8644 ;; Copy any marks over to the new group.
8645 (let ((marks '((tick . gnus-newsgroup-marked)
8646 (dormant . gnus-newsgroup-dormant)
8647 (expire . gnus-newsgroup-expirable)
8648 (bookmark . gnus-newsgroup-bookmarks)
8649 ; (score . gnus-newsgroup-scored)
8650 (reply . gnus-newsgroup-replied)))
8651 (to-article (cdr art-group)))
8653 (if (memq article (symbol-value (cdr (car marks))))
8654 (gnus-add-marked-articles
8655 (car info) (car (car marks)) (list to-article) info))
8656 (setq marks (cdr marks))))
8657 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8658 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8659 (setq gnus-newsgroup-dormant
8660 (delq article gnus-newsgroup-dormant))
8661 (setq gnus-newsgroup-reads
8662 (cons (cons article gnus-canceled-mark)
8663 gnus-newsgroup-reads)))
8664 (gnus-message 1 "Couldn't move article %s" (car articles)))
8665 (gnus-summary-remove-process-mark (car articles))
8666 (setq articles (cdr articles)))))
8668 (defun gnus-summary-respool-article (&optional n respool-method)
8669 "Respool the current article.
8670 The article will be squeezed through the mail spooling process again,
8671 which means that it will be put in some mail newsgroup or other
8672 depending on `nnmail-split-methods'.
8673 If N is a positive number, respool the N next articles.
8674 If N is a negative number, respool the N previous articles.
8675 If N is nil and any articles have been marked with the process mark,
8676 respool those articles instead.
8678 Respooling can be done both from mail groups and \"real\" newsgroups.
8679 In the former case, the articles in question will be moved from the
8680 current group into whatever groups they are destined to. In the
8681 latter case, they will be copied into the relevant groups."
8683 (gnus-set-global-variables)
8684 (let ((respool-methods (gnus-methods-using 'respool))
8686 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8688 (setq respool-method
8690 "What method do you want to use when respooling? "
8691 respool-methods nil t methname)))
8692 (or (string= respool-method "")
8693 (if (assoc (symbol-name
8694 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8696 (gnus-summary-move-article n nil (intern respool-method))
8697 (gnus-summary-copy-article n nil (intern respool-method))))))
8699 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8700 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8701 "Move the current article to a different newsgroup.
8702 If N is a positive number, move the N next articles.
8703 If N is a negative number, move the N previous articles.
8704 If N is nil and any articles have been marked with the process mark,
8705 move those articles instead.
8706 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8707 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8708 re-spool using this method.
8709 For this function to work, the newsgroup that you want to move to have
8710 to support the `request-move' and `request-accept'
8711 functions. (Ie. mail newsgroups at present.)"
8713 (gnus-set-global-variables)
8714 (let ((articles (gnus-summary-work-articles n))
8715 (copy-buf (get-buffer-create "*copy work*"))
8716 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8717 art-group to-method)
8718 (buffer-disable-undo copy-buf)
8719 (if (and (not to-newsgroup) (not select-method))
8722 (format "Where do you want to copy %s? %s"
8723 (if (> (length articles) 1)
8724 (format "these %d articles" (length articles))
8726 (if gnus-current-move-group
8727 (format "(%s default) " gnus-current-move-group)
8729 gnus-active-hashtb nil nil prefix)))
8732 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8733 (setq to-newsgroup (or gnus-current-move-group "")))
8734 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8735 (gnus-activate-newsgroup to-newsgroup)
8736 (error "No such group: %s" to-newsgroup))
8737 (setq gnus-current-move-group to-newsgroup)))
8738 (setq to-method (if select-method (list select-method "")
8739 (gnus-find-method-for-group to-newsgroup)))
8740 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8741 (error "%s does not support article copying" (car to-method)))
8742 (or (gnus-server-opened to-method)
8743 (gnus-open-server to-method)
8744 (error "Can't open server %s" (car to-method)))
8746 (gnus-message 6 "Copying to %s: %s..."
8747 (or select-method to-newsgroup) articles)
8750 (set-buffer copy-buf)
8751 (gnus-request-article-this-buffer
8752 (car articles) gnus-newsgroup-name)
8753 (gnus-request-accept-article
8754 (if select-method (quote select-method) to-newsgroup)
8755 (not (cdr articles)))))
8758 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8760 (gnus-group-prefixed-name
8762 (if select-method (list select-method "")
8763 (gnus-find-method-for-group to-newsgroup)))
8764 gnus-newsrc-hashtb)))
8765 (info (nth 2 entry))
8766 (article (car articles)))
8767 (if (not (memq article gnus-newsgroup-unreads))
8768 (setcar (cdr (cdr info))
8769 (gnus-add-to-range (nth 2 info)
8770 (list (cdr art-group)))))
8771 ;; Copy any marks over to the new group.
8772 (let ((marks '((tick . gnus-newsgroup-marked)
8773 (dormant . gnus-newsgroup-dormant)
8774 (expire . gnus-newsgroup-expirable)
8775 (bookmark . gnus-newsgroup-bookmarks)
8776 ; (score . gnus-newsgroup-scored)
8777 (reply . gnus-newsgroup-replied)))
8778 (to-article (cdr art-group)))
8780 (if (memq article (symbol-value (cdr (car marks))))
8781 (gnus-add-marked-articles
8782 (car info) (car (car marks)) (list to-article) info))
8783 (setq marks (cdr marks)))))
8784 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8785 (gnus-summary-remove-process-mark (car articles))
8786 (setq articles (cdr articles)))
8787 (kill-buffer copy-buf)))
8789 (defun gnus-summary-import-article (file)
8790 "Import a random file into a mail newsgroup."
8791 (interactive "fImport file: ")
8792 (let ((group gnus-newsgroup-name)
8794 (or (gnus-check-backend-function 'request-accept-article group)
8795 (error "%s does not support article importing" group))
8796 (or (file-readable-p file)
8797 (not (file-regular-p file))
8798 (error "Can't read %s" file))
8800 (set-buffer (get-buffer-create " *import file*"))
8801 (buffer-disable-undo (current-buffer))
8803 (insert-file-contents file)
8804 (goto-char (point-min))
8805 (if (nnheader-article-p)
8807 (setq atts (file-attributes file))
8808 (insert "From: " (read-string "From: ") "\n"
8809 "Subject: " (read-string "Subject: ") "\n"
8810 "Date: " (current-time-string (nth 5 atts)) "\n"
8811 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8812 (gnus-request-accept-article group t)
8813 (kill-buffer (current-buffer)))))
8815 (defun gnus-summary-expire-articles ()
8816 "Expire all articles that are marked as expirable in the current group."
8818 (if (not (gnus-check-backend-function
8819 'request-expire-articles gnus-newsgroup-name))
8821 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
8822 gnus-newsrc-hashtb)))
8823 (total (memq 'total-expire (nth 5 info)))
8824 (expirable (if total
8825 (gnus-list-of-read-articles gnus-newsgroup-name)
8826 (setq gnus-newsgroup-expirable
8827 (sort gnus-newsgroup-expirable '<))))
8831 (gnus-message 6 "Expiring articles...")
8832 ;; The list of articles that weren't expired is returned.
8833 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
8834 (or total (setq gnus-newsgroup-expirable es))
8835 ;; We go through the old list of expirable, and mark all
8836 ;; really expired articles as non-existant.
8837 (or (eq es expirable) ; If nothing was expired, we don't mark.
8838 (let ((gnus-use-cache nil))
8840 (or (memq (car expirable) es)
8841 (gnus-summary-mark-article
8842 (car expirable) gnus-canceled-mark))
8843 (setq expirable (cdr expirable)))))
8844 (gnus-message 6 "Expiring articles...done")))))
8846 (defun gnus-summary-expire-articles-now ()
8847 "Expunge all expirable articles in the current group.
8848 This means that *all* articles that are marked as expirable will be
8849 deleted forever, right now."
8851 (or gnus-expert-user
8853 "Are you really, really, really sure you want to expunge? ")
8855 (let ((nnmail-expiry-wait -1)
8856 (nnmail-expiry-wait-function nil))
8857 (gnus-summary-expire-articles)))
8859 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8860 (defun gnus-summary-delete-article (&optional n)
8861 "Delete the N next (mail) articles.
8862 This command actually deletes articles. This is not a marking
8863 command. The article will disappear forever from you life, never to
8865 If N is negative, delete backwards.
8866 If N is nil and articles have been marked with the process mark,
8867 delete these instead."
8869 (or (gnus-check-backend-function 'request-expire-articles
8870 gnus-newsgroup-name)
8871 (error "The current newsgroup does not support article deletion."))
8872 ;; Compute the list of articles to delete.
8873 (let ((articles (gnus-summary-work-articles n))
8875 (if (and gnus-novice-user
8877 (format "Do you really want to delete %s forever? "
8878 (if (> (length articles) 1) "these articles"
8881 ;; Delete the articles.
8882 (setq not-deleted (gnus-request-expire-articles
8883 articles gnus-newsgroup-name 'force))
8885 (gnus-summary-remove-process-mark (car articles))
8886 ;; The backend might not have been able to delete the article
8888 (or (memq (car articles) not-deleted)
8889 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8890 (setq articles (cdr articles))))
8891 (gnus-summary-position-cursor)
8894 (defun gnus-summary-edit-article ()
8895 "Enter into a buffer and edit the current article.
8896 This will have permanent effect only in mail groups."
8898 (or (gnus-check-backend-function
8899 'request-replace-article gnus-newsgroup-name)
8900 (error "The current newsgroup does not support article editing."))
8901 (gnus-summary-select-article t)
8902 (gnus-configure-windows 'article)
8903 (select-window (get-buffer-window gnus-article-buffer))
8904 (gnus-message 6 "C-c C-c to end edits")
8905 (setq buffer-read-only nil)
8907 (use-local-map (copy-keymap (current-local-map)))
8908 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8909 (buffer-enable-undo)
8911 (goto-char (point-min))
8912 (search-forward "\n\n" nil t))
8914 (defun gnus-summary-edit-article-done ()
8915 "Make edits to the current article permanent."
8917 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
8920 (if (not (gnus-request-replace-article
8921 (cdr gnus-article-current) (car gnus-article-current)
8923 (error "Couldn't replace article.")
8925 (use-local-map gnus-article-mode-map)
8926 (setq buffer-read-only t)
8927 (buffer-disable-undo (current-buffer))
8928 (gnus-configure-windows 'summary))))
8930 (defun gnus-summary-fancy-query ()
8931 "Query where the fancy respool algorithm would put this article."
8933 (gnus-summary-select-article)
8935 (set-buffer gnus-article-buffer)
8937 (goto-char (point-min))
8938 (search-forward "\n\n")
8939 (narrow-to-region (point-min) (point))
8940 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8942 ;; Summary score commands.
8944 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8946 (defun gnus-summary-raise-score (n)
8947 "Raise the score of the current article by N."
8949 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8951 (defun gnus-summary-set-score (n)
8952 "Set the score of the current article to N."
8954 ;; Skip dummy header line.
8956 (gnus-summary-show-thread)
8957 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8959 (let ((buffer-read-only nil))
8961 (gnus-summary-update-mark
8962 (if (= n (or gnus-summary-default-score 0)) ?
8963 (if (< n (or gnus-summary-default-score 0))
8964 gnus-score-below-mark gnus-score-over-mark)) 'score))
8965 (let* ((article (gnus-summary-article-number))
8966 (score (assq article gnus-newsgroup-scored)))
8967 (if score (setcdr score n)
8968 (setq gnus-newsgroup-scored
8969 (cons (cons article n) gnus-newsgroup-scored))))
8970 (gnus-summary-update-line)))
8972 (defun gnus-summary-current-score ()
8973 "Return the score of the current article."
8975 (message "%s" (gnus-summary-article-score)))
8977 ;; Summary marking commands.
8979 (defun gnus-summary-raise-same-subject-and-select (score)
8980 "Raise articles which has the same subject with SCORE and select the next."
8982 (let ((subject (gnus-summary-subject-string)))
8983 (gnus-summary-raise-score score)
8984 (while (gnus-summary-search-subject nil nil subject)
8985 (gnus-summary-raise-score score))
8986 (gnus-summary-next-article t)))
8988 (defun gnus-summary-raise-same-subject (score)
8989 "Raise articles which has the same subject with SCORE."
8991 (let ((subject (gnus-summary-subject-string)))
8992 (gnus-summary-raise-score score)
8993 (while (gnus-summary-search-subject nil nil subject)
8994 (gnus-summary-raise-score score))
8995 (gnus-summary-next-subject 1 t)))
8997 (defun gnus-score-default (level)
8998 (if level (prefix-numeric-value level)
8999 gnus-score-interactive-default-score))
9001 (defun gnus-summary-raise-thread (&optional score)
9002 "Raise the score of the articles in the current thread with SCORE."
9004 (setq score (1- (gnus-score-default score)))
9007 (let ((level (gnus-summary-thread-level)))
9008 (gnus-summary-raise-score score)
9009 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9010 (> (gnus-summary-thread-level) level))
9011 (gnus-summary-raise-score score))
9013 (let ((gnus-summary-check-current t))
9014 (or (zerop (gnus-summary-next-subject 1 t))
9016 (gnus-summary-recenter)
9017 (gnus-summary-position-cursor)
9018 (gnus-set-mode-line 'summary))
9020 (defun gnus-summary-lower-same-subject-and-select (score)
9021 "Raise articles which has the same subject with SCORE and select the next."
9023 (gnus-summary-raise-same-subject-and-select (- score)))
9025 (defun gnus-summary-lower-same-subject (score)
9026 "Raise articles which has the same subject with SCORE."
9028 (gnus-summary-raise-same-subject (- score)))
9030 (defun gnus-summary-lower-thread (&optional score)
9031 "Lower score of articles in the current thread with SCORE."
9033 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9035 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9036 "Mark articles which has the same subject as read, and then select the next.
9037 If UNMARK is positive, remove any kind of mark.
9038 If UNMARK is negative, tick articles."
9041 (setq unmark (prefix-numeric-value unmark)))
9043 (gnus-summary-mark-same-subject
9044 (gnus-summary-subject-string) unmark)))
9045 ;; Select next unread article. If auto-select-same mode, should
9046 ;; select the first unread article.
9047 (gnus-summary-next-article t (and gnus-auto-select-same
9048 (gnus-summary-subject-string)))
9049 (gnus-message 7 "%d articles are marked as %s"
9050 count (if unmark "unread" "read"))))
9052 (defun gnus-summary-kill-same-subject (&optional unmark)
9053 "Mark articles which has the same subject as read.
9054 If UNMARK is positive, remove any kind of mark.
9055 If UNMARK is negative, tick articles."
9058 (setq unmark (prefix-numeric-value unmark)))
9060 (gnus-summary-mark-same-subject
9061 (gnus-summary-subject-string) unmark)))
9062 ;; If marked as read, go to next unread subject.
9064 ;; Go to next unread subject.
9065 (gnus-summary-next-subject 1 t))
9066 (gnus-message 7 "%d articles are marked as %s"
9067 count (if unmark "unread" "read"))))
9069 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9070 "Mark articles with same SUBJECT as read, and return marked number.
9071 If optional argument UNMARK is positive, remove any kinds of marks.
9072 If optional argument UNMARK is negative, mark articles as unread instead."
9076 ((null unmark) ; Mark as read.
9079 (gnus-summary-mark-article-as-read gnus-killed-mark)
9080 (gnus-summary-show-thread) t)
9081 (gnus-summary-search-forward nil subject))
9082 (setq count (1+ count))))
9083 ((> unmark 0) ; Tick.
9086 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9087 (gnus-summary-show-thread) t)
9088 (gnus-summary-search-forward nil subject))
9089 (setq count (1+ count))))
9090 (t ; Mark as unread.
9093 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9094 (gnus-summary-show-thread) t)
9095 (gnus-summary-search-forward nil subject))
9096 (setq count (1+ count)))))
9097 ;; Return the number of marked articles.
9100 (defun gnus-summary-mark-as-processable (n &optional unmark)
9101 "Set the process mark on the next N articles.
9102 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9103 the process mark instead. The difference between N and the actual
9104 number of articles marked is returned."
9106 (let ((backward (< n 0))
9111 (gnus-summary-remove-process-mark (gnus-summary-article-number))
9112 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9113 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9115 (if (/= 0 n) (gnus-message 7 "No more articles"))
9116 (gnus-summary-recenter)
9117 (gnus-summary-position-cursor)
9120 (defun gnus-summary-unmark-as-processable (n)
9121 "Remove the process mark from the next N articles.
9122 If N is negative, mark backward instead. The difference between N and
9123 the actual number of articles marked is returned."
9125 (gnus-summary-mark-as-processable n t))
9127 (defun gnus-summary-unmark-all-processable ()
9128 "Remove the process mark from all articles."
9131 (while gnus-newsgroup-processable
9132 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9133 (gnus-summary-position-cursor))
9135 (defun gnus-summary-mark-as-expirable (n)
9136 "Mark N articles forward as expirable.
9137 If N is negative, mark backward instead. The difference between N and
9138 the actual number of articles marked is returned."
9140 (gnus-summary-mark-forward n gnus-expirable-mark))
9142 (defun gnus-summary-mark-article-as-replied (article)
9143 "Mark ARTICLE replied and update the summary line."
9144 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9145 (let ((buffer-read-only nil))
9146 (if (gnus-summary-goto-subject article)
9148 (gnus-summary-update-mark gnus-replied-mark 'replied)
9151 (defun gnus-summary-set-bookmark (article)
9152 "Set a bookmark in current article."
9153 (interactive (list (gnus-summary-article-number)))
9154 (if (or (not (get-buffer gnus-article-buffer))
9155 (not gnus-current-article)
9156 (not gnus-article-current)
9157 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9158 (error "No current article selected"))
9159 ;; Remove old bookmark, if one exists.
9160 (let ((old (assq article gnus-newsgroup-bookmarks)))
9161 (if old (setq gnus-newsgroup-bookmarks
9162 (delq old gnus-newsgroup-bookmarks))))
9163 ;; Set the new bookmark, which is on the form
9164 ;; (article-number . line-number-in-body).
9165 (setq gnus-newsgroup-bookmarks
9169 (set-buffer gnus-article-buffer)
9173 (goto-char (point-min))
9174 (search-forward "\n\n" nil t)
9177 gnus-newsgroup-bookmarks))
9178 (gnus-message 6 "A bookmark has been added to the current article."))
9180 (defun gnus-summary-remove-bookmark (article)
9181 "Remove the bookmark from the current article."
9182 (interactive (list (gnus-summary-article-number)))
9183 ;; Remove old bookmark, if one exists.
9184 (let ((old (assq article gnus-newsgroup-bookmarks)))
9187 (setq gnus-newsgroup-bookmarks
9188 (delq old gnus-newsgroup-bookmarks))
9189 (gnus-message 6 "Removed bookmark."))
9190 (gnus-message 6 "No bookmark in current article."))))
9192 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9193 (defun gnus-summary-mark-as-dormant (n)
9194 "Mark N articles forward as dormant.
9195 If N is negative, mark backward instead. The difference between N and
9196 the actual number of articles marked is returned."
9198 (gnus-summary-mark-forward n gnus-dormant-mark))
9200 (defun gnus-summary-set-process-mark (article)
9201 "Set the process mark on ARTICLE and update the summary line."
9202 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9203 (let ((buffer-read-only nil))
9204 (if (gnus-summary-goto-subject article)
9206 (gnus-summary-show-thread)
9207 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9209 (gnus-summary-update-mark gnus-process-mark 'replied)
9212 (defun gnus-summary-remove-process-mark (article)
9213 "Remove the process mark from ARTICLE and update the summary line."
9214 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9215 (let ((buffer-read-only nil))
9216 (if (gnus-summary-goto-subject article)
9218 (gnus-summary-show-thread)
9219 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9221 (gnus-summary-update-mark ? 'replied)
9222 (if (memq article gnus-newsgroup-replied)
9223 (gnus-summary-update-mark gnus-replied-mark 'replied))
9226 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9227 "Mark N articles as read forwards.
9228 If N is negative, mark backwards instead.
9229 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9231 The difference between N and the actual number of articles marked is
9234 (gnus-set-global-variables)
9235 (let ((backward (< n 0))
9236 (gnus-summary-goto-unread
9237 (and gnus-summary-goto-unread
9238 (not (memq mark (list gnus-unread-mark
9239 gnus-ticked-mark gnus-dormant-mark)))))
9241 (mark (or mark gnus-del-mark)))
9243 (gnus-summary-mark-article nil mark no-expire)
9244 (zerop (gnus-summary-next-subject
9245 (if backward -1 1) gnus-summary-goto-unread t)))
9247 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9248 (gnus-summary-recenter)
9249 (gnus-summary-position-cursor)
9250 (gnus-set-mode-line 'summary)
9253 (defun gnus-summary-mark-article-as-read (mark)
9254 "Mark the current article quickly as read with MARK."
9255 (let ((article (gnus-summary-article-number)))
9256 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9257 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9258 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9259 (setq gnus-newsgroup-reads
9260 (cons (cons article mark) gnus-newsgroup-reads))
9261 ;; Possibly remove from cache, if that is used.
9262 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9263 (and gnus-newsgroup-auto-expire
9264 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9265 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9266 (= mark gnus-read-mark))
9268 (setq mark gnus-expirable-mark)
9269 (setq gnus-newsgroup-expirable
9270 (cons article gnus-newsgroup-expirable))))
9271 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9274 (gnus-summary-update-mark mark 'unread)
9277 (defun gnus-summary-mark-article-as-unread (mark)
9278 "Mark the current article quickly as unread with MARK."
9279 (let ((article (gnus-summary-article-number)))
9280 (or (memq article gnus-newsgroup-unreads)
9281 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9282 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9283 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9284 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9285 (setq gnus-newsgroup-reads
9286 (delq (assq article gnus-newsgroup-reads)
9287 gnus-newsgroup-reads))
9288 (if (= mark gnus-ticked-mark)
9289 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9290 (if (= mark gnus-dormant-mark)
9291 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9293 ;; See whether the article is to be put in the cache.
9295 (vectorp (gnus-get-header-by-num article))
9297 (gnus-cache-possibly-enter-article
9298 gnus-newsgroup-name article
9299 (gnus-get-header-by-num article)
9300 (= mark gnus-ticked-mark)
9301 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9303 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9306 (gnus-summary-update-mark mark 'unread)
9309 (defun gnus-summary-mark-article (&optional article mark no-expire)
9310 "Mark ARTICLE with MARK. MARK can be any character.
9311 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9312 (dormant) and `?E' (expirable).
9313 If MARK is nil, then the default character `?D' is used.
9314 If ARTICLE is nil, then the article on the current line will be
9317 (setq mark (aref mark 0)))
9318 ;; If no mark is given, then we check auto-expiring.
9319 (and (not no-expire)
9320 gnus-newsgroup-auto-expire
9323 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9324 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9325 (= mark gnus-read-mark))))
9326 (setq mark gnus-expirable-mark))
9327 (let* ((mark (or mark gnus-del-mark))
9328 (article (or article (gnus-summary-article-number))))
9329 (or article (error "No article on current line"))
9330 (if (or (= mark gnus-unread-mark)
9331 (= mark gnus-ticked-mark)
9332 (= mark gnus-dormant-mark))
9333 (gnus-mark-article-as-unread article mark)
9334 (gnus-mark-article-as-read article mark))
9336 ;; See whether the article is to be put in the cache.
9338 (not (= mark gnus-canceled-mark))
9339 (vectorp (gnus-get-header-by-num article))
9341 (gnus-cache-possibly-enter-article
9342 gnus-newsgroup-name article
9343 (gnus-get-header-by-num article)
9344 (= mark gnus-ticked-mark)
9345 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9347 (if (gnus-summary-goto-subject article)
9348 (let ((buffer-read-only nil))
9349 (gnus-summary-show-thread)
9350 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9353 (gnus-summary-update-mark mark 'unread)
9356 (defun gnus-summary-update-mark (mark type)
9358 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9359 (buffer-read-only nil)
9363 (forward-char forward)
9364 (setq plist (text-properties-at (point)))
9367 (and plist (add-text-properties (1- (point)) (point) plist))
9368 (and (eq type 'unread)
9369 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9370 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9372 (defun gnus-mark-article-as-read (article &optional mark)
9373 "Enter ARTICLE in the pertinent lists and remove it from others."
9374 ;; Make the article expirable.
9375 (let ((mark (or mark gnus-del-mark)))
9376 (if (= mark gnus-expirable-mark)
9377 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9378 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9379 ;; Remove from unread and marked lists.
9380 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9381 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9382 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9383 (setq gnus-newsgroup-reads
9384 (cons (cons article mark) gnus-newsgroup-reads))
9385 ;; Possibly remove from cache, if that is used.
9386 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9388 (defun gnus-mark-article-as-unread (article &optional mark)
9389 "Enter ARTICLE in the pertinent lists and remove it from others."
9390 (let ((mark (or mark gnus-ticked-mark)))
9391 ;; Add to unread list.
9392 (or (memq article gnus-newsgroup-unreads)
9393 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9394 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9395 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9396 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9397 (setq gnus-newsgroup-reads
9398 (delq (assq article gnus-newsgroup-reads)
9399 gnus-newsgroup-reads))
9400 (if (= mark gnus-ticked-mark)
9401 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9402 (if (= mark gnus-dormant-mark)
9403 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9405 (defalias 'gnus-summary-mark-as-unread-forward
9406 'gnus-summary-tick-article-forward)
9407 (make-obsolete 'gnus-summary-mark-as-unread-forward
9408 'gnus-summary-tick-article-forward)
9409 (defun gnus-summary-tick-article-forward (n)
9410 "Tick N articles forwards.
9411 If N is negative, tick backwards instead.
9412 The difference between N and the number of articles ticked is returned."
9414 (gnus-summary-mark-forward n gnus-ticked-mark))
9416 (defalias 'gnus-summary-mark-as-unread-backward
9417 'gnus-summary-tick-article-backward)
9418 (make-obsolete 'gnus-summary-mark-as-unread-backward
9419 'gnus-summary-tick-article-backward)
9420 (defun gnus-summary-tick-article-backward (n)
9421 "Tick N articles backwards.
9422 The difference between N and the number of articles ticked is returned."
9424 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9426 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9427 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9428 (defun gnus-summary-tick-article (&optional article clear-mark)
9429 "Mark current article as unread.
9430 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9431 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9432 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9435 (defun gnus-summary-mark-as-read-forward (n)
9436 "Mark N articles as read forwards.
9437 If N is negative, mark backwards instead.
9438 The difference between N and the actual number of articles marked is
9441 (gnus-summary-mark-forward n gnus-del-mark t))
9443 (defun gnus-summary-mark-as-read-backward (n)
9444 "Mark the N articles as read backwards.
9445 The difference between N and the actual number of articles marked is
9448 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9450 (defun gnus-summary-mark-as-read (&optional article mark)
9451 "Mark current article as read.
9452 ARTICLE specifies the article to be marked as read.
9453 MARK specifies a string to be inserted at the beginning of the line."
9454 (gnus-summary-mark-article article mark))
9456 (defun gnus-summary-clear-mark-forward (n)
9457 "Clear marks from N articles forward.
9458 If N is negative, clear backward instead.
9459 The difference between N and the number of marks cleared is returned."
9461 (gnus-summary-mark-forward n gnus-unread-mark))
9463 (defun gnus-summary-clear-mark-backward (n)
9464 "Clear marks from N articles backward.
9465 The difference between N and the number of marks cleared is returned."
9467 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9469 (defun gnus-summary-mark-unread-as-read ()
9470 "Intended to be used by `gnus-summary-mark-article-hook'."
9471 (and (memq gnus-current-article gnus-newsgroup-unreads)
9472 (or (memq gnus-current-article gnus-newsgroup-marked)
9473 (memq gnus-current-article gnus-newsgroup-dormant)
9474 (memq gnus-current-article gnus-newsgroup-expirable)
9475 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9477 (defun gnus-summary-mark-region-as-read (point mark all)
9478 "Mark all unread articles between point and mark as read.
9479 If given a prefix, mark all articles between point and mark as read,
9480 even ticked and dormant ones."
9481 (interactive "r\nP")
9491 (not (memq (gnus-summary-article-number)
9492 gnus-newsgroup-marked))
9493 (not (memq (gnus-summary-article-number)
9494 gnus-newsgroup-dormant))))
9495 (gnus-summary-mark-article
9496 (gnus-summary-article-number) gnus-del-mark))
9498 (zerop (forward-line 1))))))
9500 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9501 (defalias 'gnus-summary-delete-marked-as-read
9502 'gnus-summary-remove-lines-marked-as-read)
9503 (make-obsolete 'gnus-summary-delete-marked-as-read
9504 'gnus-summary-remove-lines-marked-as-read)
9505 (defun gnus-summary-remove-lines-marked-as-read ()
9506 "Remove lines that are marked as read."
9508 (gnus-summary-remove-lines-marked-with
9510 (lambda (char) (char-to-string (symbol-value char)))
9511 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9512 gnus-killed-mark gnus-kill-file-mark
9513 gnus-low-score-mark gnus-expirable-mark
9517 (defalias 'gnus-summary-delete-marked-with
9518 'gnus-summary-remove-lines-marked-with)
9519 (make-obsolete 'gnus-summary-delete-marked-with
9520 'gnus-summary-remove-lines-marked-with)
9521 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9522 (defun gnus-summary-remove-lines-marked-with (marks)
9523 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9524 (interactive "sMarks: ")
9525 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9526 (gnus-set-global-variables)
9527 (let ((buffer-read-only nil)
9528 (marks (concat "^[" marks "]")))
9529 (goto-char (point-min))
9530 (if gnus-newsgroup-adaptive
9531 (gnus-score-remove-lines-adaptive marks)
9532 (while (re-search-forward marks nil t)
9533 (gnus-delete-line)))
9534 ;; If we use dummy roots, we have to do an additional sweep over
9536 (if (not (eq gnus-summary-make-false-root 'dummy))
9538 (goto-char (point-min))
9539 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9540 (while (re-search-forward marks nil t)
9541 (if (gnus-subject-equal
9542 (gnus-summary-subject-string)
9545 (gnus-summary-subject-string)))
9548 (gnus-delete-line)))))
9549 (or (zerop (buffer-size))
9551 (gnus-summary-prev-subject 1)
9552 (gnus-summary-position-cursor))))
9554 (defun gnus-summary-expunge-below (&optional score)
9555 "Remove articles with score less than SCORE."
9557 (gnus-set-global-variables)
9558 (setq score (if score
9559 (prefix-numeric-value score)
9560 (or gnus-summary-default-score 0)))
9562 (set-buffer gnus-summary-buffer)
9563 (goto-char (point-min))
9564 (let ((buffer-read-only nil)
9567 (if (< (gnus-summary-article-score) score)
9571 (delete-region beg (point)))
9574 (or (zerop (buffer-size))
9576 (gnus-summary-prev-subject 1)
9577 (gnus-summary-position-cursor))))))
9579 (defun gnus-summary-mark-below (score mark)
9580 "Mark articles with score less than SCORE with MARK."
9581 (interactive "P\ncMark: ")
9582 (gnus-set-global-variables)
9583 (setq score (if score
9584 (prefix-numeric-value score)
9585 (or gnus-summary-default-score 0)))
9587 (set-buffer gnus-summary-buffer)
9588 (goto-char (point-min))
9590 (and (< (gnus-summary-article-score) score)
9591 (gnus-summary-mark-article nil mark))
9594 (defun gnus-summary-kill-below (&optional score)
9595 "Mark articles with score below SCORE as read."
9597 (gnus-set-global-variables)
9598 (gnus-summary-mark-below score gnus-killed-mark))
9600 (defun gnus-summary-clear-above (&optional score)
9601 "Clear all marks from articles with score above SCORE."
9603 (gnus-set-global-variables)
9604 (gnus-summary-mark-above score gnus-unread-mark))
9606 (defun gnus-summary-tick-above (&optional score)
9607 "Tick all articles with score above SCORE."
9609 (gnus-set-global-variables)
9610 (gnus-summary-mark-above score gnus-ticked-mark))
9612 (defun gnus-summary-mark-above (score mark)
9613 "Mark articles with score over SCORE with MARK."
9614 (interactive "P\ncMark: ")
9615 (gnus-set-global-variables)
9616 (setq score (if score
9617 (prefix-numeric-value score)
9618 (or gnus-summary-default-score 0)))
9620 (set-buffer gnus-summary-buffer)
9621 (goto-char (point-min))
9623 (if (> (gnus-summary-article-score) score)
9625 (gnus-summary-mark-article nil mark)
9627 (forward-line 1)))))
9629 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9630 (defun gnus-summary-show-all-expunged ()
9631 "Display all the hidden articles that were expunged for low scores."
9633 (gnus-set-global-variables)
9634 (let ((buffer-read-only nil))
9635 (let ((scored gnus-newsgroup-scored)
9638 (or (gnus-summary-goto-subject (car (car scored)))
9639 (and (setq h (gnus-get-header-by-num (car (car scored))))
9640 (< (cdr (car scored)) gnus-summary-expunge-below)
9641 (setq headers (cons h headers))))
9642 (setq scored (cdr scored)))
9643 (or headers (error "No expunged articles hidden."))
9644 (goto-char (point-min))
9646 (gnus-summary-update-lines
9649 (gnus-summary-prepare-unthreaded (nreverse headers))
9651 (goto-char (point-min))
9652 (gnus-summary-position-cursor)))
9654 (defun gnus-summary-show-all-dormant ()
9655 "Display all the hidden articles that are marked as dormant."
9657 (gnus-set-global-variables)
9658 (let ((buffer-read-only nil))
9659 (let ((dormant gnus-newsgroup-dormant)
9662 (or (gnus-summary-goto-subject (car dormant))
9663 (and (setq h (gnus-get-header-by-num (car dormant)))
9664 (setq headers (cons h headers))))
9665 (setq dormant (cdr dormant)))
9666 (or headers (error "No dormant articles hidden."))
9667 (goto-char (point-min))
9669 (gnus-summary-update-lines
9672 (gnus-summary-prepare-unthreaded (nreverse headers))
9674 (goto-char (point-min))
9675 (gnus-summary-position-cursor)))
9677 (defun gnus-summary-hide-all-dormant ()
9678 "Hide all dormant articles."
9680 (gnus-set-global-variables)
9681 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9682 (gnus-summary-position-cursor))
9684 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9685 "Mark all articles not marked as unread in this newsgroup as read.
9686 If prefix argument ALL is non-nil, all articles are marked as read.
9687 If QUIETLY is non-nil, no questions will be asked.
9688 If TO-HERE is non-nil, it should be a point in the buffer. All
9689 articles before this point will be marked as read.
9690 The number of articles marked as read is returned."
9692 (gnus-set-global-variables)
9695 (not gnus-interactive-catchup) ;Without confirmation?
9699 "Mark absolutely all articles as read? "
9700 "Mark all unread articles as read? ")))
9702 (not gnus-newsgroup-adaptive)
9703 (not gnus-newsgroup-auto-expire))
9705 (and all (setq gnus-newsgroup-marked nil
9706 gnus-newsgroup-dormant nil))
9707 (setq gnus-newsgroup-unreads
9708 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9709 ;; We actually mark all articles as canceled, which we
9710 ;; have to do when using auto-expiry or adaptive scoring.
9711 (let ((unreads (length gnus-newsgroup-unreads)))
9712 (gnus-summary-show-all-threads)
9713 (if (gnus-summary-first-subject (not all))
9715 (if to-here (< (point) to-here) t)
9716 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9717 (gnus-summary-search-subject nil (not all)))))
9718 (- unreads (length gnus-newsgroup-unreads))
9720 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9721 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9722 (if (and (not to-here) (eq 'nnvirtual (car method)))
9723 (nnvirtual-catchup-group
9724 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9725 (gnus-summary-position-cursor)))
9727 (defun gnus-summary-catchup-to-here (&optional all)
9728 "Mark all unticked articles before the current one as read.
9729 If ALL is non-nil, also mark ticked and dormant articles as read."
9731 (gnus-set-global-variables)
9733 (and (zerop (forward-line -1))
9736 (gnus-summary-catchup all t (point))
9737 (gnus-set-mode-line 'summary))))
9738 (gnus-summary-position-cursor))
9740 (defun gnus-summary-catchup-all (&optional quietly)
9741 "Mark all articles in this newsgroup as read."
9743 (gnus-set-global-variables)
9744 (gnus-summary-catchup t quietly))
9746 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9747 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9748 If prefix argument ALL is non-nil, all articles are marked as read."
9750 (gnus-set-global-variables)
9751 (gnus-summary-catchup all quietly nil 'fast)
9752 ;; Select next newsgroup or exit.
9753 (if (eq gnus-auto-select-next 'quietly)
9754 (gnus-summary-next-group nil)
9755 (gnus-summary-exit)))
9757 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9758 "Mark all articles in this newsgroup as read, and then exit."
9760 (gnus-set-global-variables)
9761 (gnus-summary-catchup-and-exit t quietly))
9763 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9764 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9765 "Mark all articles in this group as read and select the next group.
9766 If given a prefix, mark all articles, unread as well as ticked, as
9769 (gnus-set-global-variables)
9770 (gnus-summary-catchup all)
9771 (gnus-summary-next-group))
9773 ;; Thread-based commands.
9775 (defun gnus-summary-toggle-threads (&optional arg)
9776 "Toggle showing conversation threads.
9777 If ARG is positive number, turn showing conversation threads on."
9779 (gnus-set-global-variables)
9780 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9781 (setq gnus-show-threads
9782 (if (null arg) (not gnus-show-threads)
9783 (> (prefix-numeric-value arg) 0)))
9784 (gnus-summary-prepare)
9785 (gnus-summary-goto-subject current)
9786 (gnus-summary-position-cursor)))
9788 (defun gnus-summary-show-all-threads ()
9791 (gnus-set-global-variables)
9793 (let ((buffer-read-only nil))
9794 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9795 (gnus-summary-position-cursor))
9797 (defun gnus-summary-show-thread ()
9798 "Show thread subtrees.
9799 Returns nil if no thread was there to be shown."
9801 (gnus-set-global-variables)
9802 (let ((buffer-read-only nil)
9804 ;; first goto end then to beg, to have point at beg after let
9805 (end (progn (end-of-line) (point)))
9806 (beg (progn (beginning-of-line) (point))))
9808 ;; Any hidden lines here?
9809 (search-forward "\r" end t)
9810 (subst-char-in-region beg end ?\^M ?\n t)
9812 (gnus-summary-position-cursor))))
9814 (defun gnus-summary-hide-all-threads ()
9815 "Hide all thread subtrees."
9817 (gnus-set-global-variables)
9819 (goto-char (point-min))
9820 (gnus-summary-hide-thread)
9821 (while (and (not (eobp)) (zerop (forward-line 1)))
9822 (gnus-summary-hide-thread)))
9823 (gnus-summary-position-cursor))
9825 (defun gnus-summary-hide-thread ()
9826 "Hide thread subtrees.
9827 Returns nil if no threads were there to be hidden."
9829 (gnus-set-global-variables)
9830 (let ((buffer-read-only nil)
9832 (level (gnus-summary-thread-level))
9834 ;; Go forward until either the buffer ends or the subthread
9838 (while (and (zerop (forward-line 1))
9839 (> (gnus-summary-thread-level) level))
9844 (search-backward "\n" start t))
9845 (subst-char-in-region start end ?\n ?\^M t)
9846 (forward-line -1)))))
9848 (defun gnus-summary-go-to-next-thread (&optional previous)
9849 "Go to the same level (or less) next thread.
9850 If PREVIOUS is non-nil, go to previous thread instead.
9851 Return the article number moved to, or nil if moving was impossible."
9852 (let ((level (gnus-summary-thread-level))
9853 (article (gnus-summary-article-number)))
9855 (while (and (zerop (forward-line -1))
9856 (> (gnus-summary-thread-level) level)))
9857 (while (and (save-excursion
9860 (zerop (forward-line 1))
9861 (> (gnus-summary-thread-level) level))))
9862 (gnus-summary-recenter)
9863 (gnus-summary-position-cursor)
9864 (let ((oart (gnus-summary-article-number)))
9865 (and (/= oart article) oart))))
9867 (defun gnus-summary-next-thread (n)
9868 "Go to the same level next N'th thread.
9869 If N is negative, search backward instead.
9870 Returns the difference between N and the number of skips actually
9873 (gnus-set-global-variables)
9874 (let ((backward (< n 0))
9877 (gnus-summary-go-to-next-thread backward))
9879 (gnus-summary-position-cursor)
9880 (if (/= 0 n) (gnus-message 7 "No more threads"))
9883 (defun gnus-summary-prev-thread (n)
9884 "Go to the same level previous N'th thread.
9885 Returns the difference between N and the number of skips actually
9888 (gnus-set-global-variables)
9889 (gnus-summary-next-thread (- n)))
9891 (defun gnus-summary-go-down-thread (&optional same)
9892 "Go down one level in the current thread.
9893 If SAME is non-nil, also move to articles of the same level."
9894 (let ((level (gnus-summary-thread-level))
9896 (if (and (zerop (forward-line 1))
9897 (> (gnus-summary-thread-level) level))
9902 (defun gnus-summary-go-up-thread ()
9903 "Go up one level in the current thread."
9904 (let ((level (gnus-summary-thread-level))
9906 (while (and (zerop (forward-line -1))
9907 (>= (gnus-summary-thread-level) level)))
9908 (if (>= (gnus-summary-thread-level) level)
9914 (defun gnus-summary-down-thread (n)
9915 "Go down thread N steps.
9916 If N is negative, go up instead.
9917 Returns the difference between N and how many steps down that were
9920 (gnus-set-global-variables)
9924 (if up (gnus-summary-go-up-thread)
9925 (gnus-summary-go-down-thread)))
9927 (gnus-summary-position-cursor)
9928 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9931 (defun gnus-summary-up-thread (n)
9932 "Go up thread N steps.
9933 If N is negative, go up instead.
9934 Returns the difference between N and how many steps down that were
9937 (gnus-set-global-variables)
9938 (gnus-summary-down-thread (- n)))
9940 (defun gnus-summary-kill-thread (&optional unmark)
9941 "Mark articles under current thread as read.
9942 If the prefix argument is positive, remove any kinds of marks.
9943 If the prefix argument is negative, tick articles instead."
9945 (gnus-set-global-variables)
9947 (setq unmark (prefix-numeric-value unmark)))
9949 (level (gnus-summary-thread-level)))
9952 ;; Mark the article...
9953 (cond ((null unmark) (gnus-summary-mark-article-as-read
9955 ((> unmark 0) (gnus-summary-mark-article-as-unread
9957 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9958 ;; ...and go forward until either the buffer ends or the subtree
9960 (if (not (and (zerop (forward-line 1))
9961 (> (gnus-summary-thread-level) level)))
9962 (setq killing nil))))
9963 ;; Hide killed subtrees.
9965 gnus-thread-hide-killed
9966 (gnus-summary-hide-thread))
9967 ;; If marked as read, go to next unread subject.
9969 ;; Go to next unread subject.
9970 (gnus-summary-next-subject 1 t)))
9971 (gnus-set-mode-line 'summary))
9973 ;; Summary sorting commands
9975 (defun gnus-summary-sort-by-number (&optional reverse)
9976 "Sort summary buffer by article number.
9977 Argument REVERSE means reverse order."
9979 (gnus-set-global-variables)
9981 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
9982 ;; a function, so we wrap it.
9983 (cons (lambda () (gnus-summary-article-number))
9984 'gnus-thread-sort-by-number) reverse))
9986 (defun gnus-summary-sort-by-author (&optional reverse)
9987 "Sort summary buffer by author name alphabetically.
9988 If case-fold-search is non-nil, case of letters is ignored.
9989 Argument REVERSE means reverse order."
9991 (gnus-set-global-variables)
9995 (let ((extract (funcall
9996 gnus-extract-address-components
9997 (header-from (gnus-get-header-by-num
9998 (gnus-summary-article-number))))))
9999 (or (car extract) (cdr extract))))
10000 'gnus-thread-sort-by-author)
10003 (defun gnus-summary-sort-by-subject (&optional reverse)
10004 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10005 If case-fold-search is non-nil, case of letters is ignored.
10006 Argument REVERSE means reverse order."
10008 (gnus-set-global-variables)
10012 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
10013 'gnus-thread-sort-by-subject)
10016 (defun gnus-summary-sort-by-date (&optional reverse)
10017 "Sort summary buffer by date.
10018 Argument REVERSE means reverse order."
10020 (gnus-set-global-variables)
10024 (gnus-sortable-date
10026 (gnus-get-header-by-num (gnus-summary-article-number)))))
10027 'gnus-thread-sort-by-date)
10030 (defun gnus-summary-sort-by-score (&optional reverse)
10031 "Sort summary buffer by score.
10032 Argument REVERSE means reverse order."
10034 (gnus-set-global-variables)
10036 (cons (lambda () (gnus-summary-article-score))
10037 'gnus-thread-sort-by-score)
10040 (defvar gnus-summary-already-sorted nil)
10041 (defun gnus-summary-sort (predicate reverse)
10042 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10043 (if gnus-summary-already-sorted
10045 (let (buffer-read-only)
10046 (if (not gnus-show-threads)
10047 ;; We do untreaded sorting...
10049 (goto-char (point-min))
10050 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10051 ;; ... or we do threaded sorting.
10052 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10053 (gnus-summary-prepare-hook nil)
10054 (gnus-summary-already-sorted nil))
10055 ;; We do that by simply regenerating the threads.
10056 (gnus-summary-prepare)
10057 (and gnus-show-threads
10058 gnus-thread-hide-subtree
10059 (gnus-summary-hide-all-threads))
10060 ;; If in async mode, we send some info to the backend.
10061 (and gnus-newsgroup-async
10062 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10063 (gnus-request-asynchronous
10064 gnus-newsgroup-name
10065 (if (and gnus-asynchronous-article-function
10066 (fboundp gnus-asynchronous-article-function))
10067 (funcall gnus-asynchronous-article-function
10068 gnus-newsgroup-threads)))))))))
10071 (defun gnus-sortable-date (date)
10072 "Make sortable string by string-lessp from DATE.
10073 Timezone package is used."
10074 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10075 (year (aref date 0))
10076 (month (aref date 1))
10077 (day (aref date 2)))
10078 (timezone-make-sortable-date
10080 (timezone-make-time-string
10081 (aref date 3) (aref date 4) (aref date 5)))))
10084 ;; Summary saving commands.
10086 (defun gnus-summary-save-article (&optional n)
10087 "Save the current article using the default saver function.
10088 If N is a positive number, save the N next articles.
10089 If N is a negative number, save the N previous articles.
10090 If N is nil and any articles have been marked with the process mark,
10091 save those articles instead.
10092 The variable `gnus-default-article-saver' specifies the saver function."
10094 (gnus-set-global-variables)
10095 (let ((articles (gnus-summary-work-articles n)))
10097 (let ((header (gnus-get-header-by-num (car articles))))
10098 (if (vectorp header)
10100 (save-window-excursion
10101 (gnus-summary-select-article t nil nil (car articles)))
10102 (or gnus-save-all-headers
10103 (gnus-article-hide-headers t))
10104 ;; Remove any X-Gnus lines.
10107 (set-buffer gnus-article-buffer)
10108 (let ((buffer-read-only nil))
10109 (goto-char (point-min))
10110 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10112 (while (re-search-forward "^X-Gnus" nil t)
10113 (beginning-of-line)
10114 (delete-region (point)
10115 (progn (forward-line 1) (point))))
10117 (save-window-excursion
10118 (if gnus-default-article-saver
10119 (funcall gnus-default-article-saver)
10120 (error "No default saver is defined."))))
10121 (if (assq 'name header)
10122 (gnus-copy-file (cdr (assq 'name header)))
10123 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10124 (gnus-summary-remove-process-mark (car articles))
10125 (setq articles (cdr articles)))
10126 (gnus-summary-position-cursor)
10129 (defun gnus-summary-pipe-output (&optional arg)
10130 "Pipe the current article to a subprocess.
10131 If N is a positive number, pipe the N next articles.
10132 If N is a negative number, pipe the N previous articles.
10133 If N is nil and any articles have been marked with the process mark,
10134 pipe those articles instead."
10136 (gnus-set-global-variables)
10137 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10138 (gnus-summary-save-article arg)))
10140 (defun gnus-summary-save-article-mail (&optional arg)
10141 "Append the current article to an mail file.
10142 If N is a positive number, save the N next articles.
10143 If N is a negative number, save the N previous articles.
10144 If N is nil and any articles have been marked with the process mark,
10145 save those articles instead."
10147 (gnus-set-global-variables)
10148 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10149 (gnus-summary-save-article arg)))
10151 (defun gnus-summary-save-article-rmail (&optional arg)
10152 "Append the current article to an rmail file.
10153 If N is a positive number, save the N next articles.
10154 If N is a negative number, save the N previous articles.
10155 If N is nil and any articles have been marked with the process mark,
10156 save those articles instead."
10158 (gnus-set-global-variables)
10159 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10160 (gnus-summary-save-article arg)))
10162 (defun gnus-summary-save-article-file (&optional arg)
10163 "Append the current article to a file.
10164 If N is a positive number, save the N next articles.
10165 If N is a negative number, save the N previous articles.
10166 If N is nil and any articles have been marked with the process mark,
10167 save those articles instead."
10169 (gnus-set-global-variables)
10170 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10171 (gnus-summary-save-article arg)))
10173 (defun gnus-read-save-file-name (prompt default-name)
10174 (let ((methods gnus-split-methods)
10176 (if (not gnus-split-methods)
10179 (set-buffer gnus-article-buffer)
10180 (gnus-narrow-to-headers)
10182 (goto-char (point-min))
10183 (and (condition-case ()
10184 (re-search-forward (car (car methods)) nil t)
10186 (setq split-name (cons (nth 1 (car methods)) split-name)))
10187 (setq methods (cdr methods)))
10189 (cond ((null split-name)
10191 (concat prompt " (default "
10192 (file-name-nondirectory default-name) ") ")
10193 (file-name-directory default-name)
10195 ((= 1 (length split-name))
10197 (concat prompt " (default " (car split-name) ") ")
10198 gnus-article-save-directory
10199 (concat gnus-article-save-directory (car split-name))))
10201 (setq split-name (mapcar (lambda (el) (list el))
10202 (nreverse split-name)))
10203 (let ((result (completing-read
10204 (concat prompt " ")
10205 split-name nil nil)))
10206 (concat gnus-article-save-directory
10207 (if (string= result "")
10208 (car (car split-name))
10211 (defun gnus-summary-save-in-rmail (&optional filename)
10212 "Append this article to Rmail file.
10213 Optional argument FILENAME specifies file name.
10214 Directory to save to is default to `gnus-article-save-directory' which
10215 is initialized from the SAVEDIR environment variable."
10217 (gnus-set-global-variables)
10218 (let ((default-name
10219 (funcall gnus-rmail-save-name gnus-newsgroup-name
10220 gnus-current-headers gnus-newsgroup-last-rmail)))
10222 (setq filename (gnus-read-save-file-name
10223 "Save in rmail file:" default-name)))
10224 (gnus-make-directory (file-name-directory filename))
10225 (gnus-eval-in-buffer-window
10226 gnus-article-buffer
10230 (gnus-output-to-rmail filename))))
10231 ;; Remember the directory name to save articles
10232 (setq gnus-newsgroup-last-rmail filename)))
10234 (defun gnus-summary-save-in-mail (&optional filename)
10235 "Append this article to Unix mail file.
10236 Optional argument FILENAME specifies file name.
10237 Directory to save to is default to `gnus-article-save-directory' which
10238 is initialized from the SAVEDIR environment variable."
10240 (gnus-set-global-variables)
10241 (let ((default-name
10242 (funcall gnus-mail-save-name gnus-newsgroup-name
10243 gnus-current-headers gnus-newsgroup-last-mail)))
10245 (setq filename (gnus-read-save-file-name
10246 "Save in Unix mail file:" default-name)))
10248 (expand-file-name filename
10250 (file-name-directory default-name))))
10251 (gnus-make-directory (file-name-directory filename))
10252 (gnus-eval-in-buffer-window
10253 gnus-article-buffer
10257 (if (and (file-readable-p filename) (rmail-file-p filename))
10258 (gnus-output-to-rmail filename)
10259 (rmail-output filename 1 t t)))))
10260 ;; Remember the directory name to save articles.
10261 (setq gnus-newsgroup-last-mail filename)))
10263 (defun gnus-summary-save-in-file (&optional filename)
10264 "Append this article to file.
10265 Optional argument FILENAME specifies file name.
10266 Directory to save to is default to `gnus-article-save-directory' which
10267 is initialized from the SAVEDIR environment variable."
10269 (gnus-set-global-variables)
10270 (let ((default-name
10271 (funcall gnus-file-save-name gnus-newsgroup-name
10272 gnus-current-headers gnus-newsgroup-last-file)))
10274 (setq filename (gnus-read-save-file-name
10275 "Save in file:" default-name)))
10276 (gnus-make-directory (file-name-directory filename))
10277 (gnus-eval-in-buffer-window
10278 gnus-article-buffer
10282 (gnus-output-to-file filename))))
10283 ;; Remember the directory name to save articles.
10284 (setq gnus-newsgroup-last-file filename)))
10286 (defun gnus-summary-save-in-pipe (&optional command)
10287 "Pipe this article to subprocess."
10289 (gnus-set-global-variables)
10290 (let ((command (read-string "Shell command on article: "
10291 gnus-last-shell-command)))
10292 (if (string-equal command "")
10293 (setq command gnus-last-shell-command))
10294 (gnus-eval-in-buffer-window
10295 gnus-article-buffer
10298 (shell-command-on-region (point-min) (point-max) command nil)))
10299 (setq gnus-last-shell-command command)))
10301 ;; Summary extract commands
10303 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10304 (let ((buffer-read-only nil)
10305 (article (gnus-summary-article-number))
10307 (or (gnus-summary-goto-subject article)
10308 (error (format "No such article: %d" article)))
10309 (or gnus-newsgroup-headers-hashtb-by-number
10310 (gnus-make-headers-hashtable-by-number))
10311 (gnus-summary-position-cursor)
10312 ;; If all commands are to be bunched up on one line, we collect
10314 (if gnus-view-pseudos-separately
10316 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10319 (setq action (cdr (assq 'action (car ps))))
10320 (setq files (list (cdr (assq 'name (car ps)))))
10321 (while (and ps (cdr ps)
10322 (string= (or action "1")
10323 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10324 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10325 (setcdr ps (cdr (cdr ps))))
10328 (if (not (string-match "%s" action))
10329 (setq files (cons " " files)))
10330 (setq files (cons " " files))
10331 (and (assq 'execute (car ps))
10332 (setcdr (assq 'execute (car ps))
10333 (funcall (if (string-match "%s" action)
10336 (mapconcat (lambda (f) f) files " ")))))
10337 (setq ps (cdr ps)))))
10338 (if (and gnus-view-pseudos (not not-view))
10340 (and (assq 'execute (car pslist))
10341 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10342 (eq gnus-view-pseudos 'not-confirm)))
10343 (setq pslist (cdr pslist)))
10346 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10347 (gnus-summary-article-number)))
10350 (insert " " (file-name-nondirectory
10351 (cdr (assq 'name (car pslist))))
10352 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10353 (add-text-properties
10354 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10355 'gnus-mark gnus-unread-mark
10357 'gnus-pseudo (car pslist)))
10359 (gnus-sethash (int-to-string gnus-reffed-article-number)
10360 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10361 (setq gnus-newsgroup-unreads
10362 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10363 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10364 (setq pslist (cdr pslist)))))))
10366 (defun gnus-pseudos< (p1 p2)
10367 (let ((c1 (cdr (assq 'action p1)))
10368 (c2 (cdr (assq 'action p2))))
10369 (and c1 c2 (string< c1 c2))))
10371 (defun gnus-request-pseudo-article (props)
10372 (cond ((assq 'execute props)
10373 (gnus-execute-command (cdr (assq 'execute props)))))
10374 (let ((gnus-current-article (gnus-summary-article-number)))
10375 (run-hooks 'gnus-mark-article-hook)))
10377 (defun gnus-execute-command (command &optional automatic)
10379 (gnus-article-setup-buffer)
10380 (set-buffer gnus-article-buffer)
10381 (let ((command (if automatic command (read-string "Command: " command)))
10382 (buffer-read-only nil))
10384 (insert "$ " command "\n\n")
10385 (if gnus-view-pseudo-asynchronously
10386 (start-process "gnus-execute" nil "sh" "-c" command)
10387 (call-process "sh" nil t nil "-c" command)))))
10389 (defun gnus-copy-file (file &optional to)
10392 (list (read-file-name "Copy file: " default-directory)
10393 (read-file-name "Copy file to: " default-directory)))
10394 (gnus-set-global-variables)
10395 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10396 (and (file-directory-p to)
10397 (setq to (concat (file-name-as-directory to)
10398 (file-name-nondirectory file))))
10399 (copy-file file to))
10401 ;; Summary kill commands.
10403 (defun gnus-summary-edit-global-kill (article)
10404 "Edit the \"global\" kill file."
10405 (interactive (list (gnus-summary-article-number)))
10406 (gnus-set-global-variables)
10407 (gnus-group-edit-global-kill article))
10409 (defun gnus-summary-edit-local-kill ()
10410 "Edit a local kill file applied to the current newsgroup."
10412 (gnus-set-global-variables)
10413 (setq gnus-current-headers
10415 (int-to-string (gnus-summary-article-number))
10416 gnus-newsgroup-headers-hashtb-by-number))
10417 (gnus-set-global-variables)
10418 (gnus-group-edit-local-kill
10419 (gnus-summary-article-number) gnus-newsgroup-name))
10423 ;;; Gnus article mode
10426 (put 'gnus-article-mode 'mode-class 'special)
10428 (if gnus-article-mode-map
10430 (setq gnus-article-mode-map (make-keymap))
10431 (suppress-keymap gnus-article-mode-map)
10432 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10433 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10434 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10435 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10436 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10437 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10438 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10439 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10440 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10441 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10442 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10443 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10445 ;; Duplicate almost all summary keystrokes in the article mode map.
10448 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10449 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10450 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10451 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10452 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10453 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10454 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10455 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10456 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10457 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10458 "\C-c\C-v\C-v" "\C-d" "v"
10459 ;; "Mt" "M!" "Md" "Mr"
10460 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10461 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10462 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10463 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10464 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10465 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10466 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10467 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10468 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10469 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10470 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10473 (define-key gnus-article-mode-map (car commands)
10474 'gnus-article-summary-command)
10475 (setq commands (cdr commands))))
10477 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10478 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10479 "=" "n" "^" "\M-^")))
10481 (define-key gnus-article-mode-map (car commands)
10482 'gnus-article-summary-command-nosave)
10483 (setq commands (cdr commands)))))
10486 (defun gnus-article-mode ()
10487 "Major mode for displaying an article.
10489 All normal editing commands are switched off.
10491 The following commands are available:
10493 \\<gnus-article-mode-map>
10494 \\[gnus-article-next-page]\t Scroll the article one page forwards
10495 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10496 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10497 \\[gnus-article-show-summary]\t Display the summary buffer
10498 \\[gnus-article-mail]\t Send a reply to the address near point
10499 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10500 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10501 \\[gnus-info-find-node]\t Go to the Gnus info node"
10503 (if gnus-visual (gnus-article-make-menu-bar))
10504 (kill-all-local-variables)
10505 (setq mode-line-modified "-- ")
10506 (make-local-variable 'mode-line-format)
10507 (setq mode-line-format (copy-sequence mode-line-format))
10508 (and (equal (nth 3 mode-line-format) " ")
10509 (setcar (nthcdr 3 mode-line-format) ""))
10510 (setq mode-name "Article")
10511 (setq major-mode 'gnus-article-mode)
10512 (make-local-variable 'minor-mode-alist)
10513 (or (assq 'gnus-show-mime minor-mode-alist)
10514 (setq minor-mode-alist
10515 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10516 (use-local-map gnus-article-mode-map)
10517 (make-local-variable 'page-delimiter)
10518 (setq page-delimiter gnus-page-delimiter)
10519 (buffer-disable-undo (current-buffer))
10520 (setq buffer-read-only t) ;Disable modification
10521 (run-hooks 'gnus-article-mode-hook))
10523 (defun gnus-article-setup-buffer ()
10524 "Initialize article mode buffer."
10525 (if (get-buffer gnus-article-buffer)
10527 (set-buffer gnus-article-buffer)
10528 (buffer-disable-undo (current-buffer))
10529 (setq buffer-read-only t)
10530 (gnus-add-current-to-buffer-list)
10531 (or (eq major-mode 'gnus-article-mode)
10532 (gnus-article-mode)))
10534 (set-buffer (get-buffer-create gnus-article-buffer))
10535 (gnus-add-current-to-buffer-list)
10536 (gnus-article-mode))))
10538 ;; Set article window start at LINE, where LINE is the number of lines
10539 ;; from the head of the article.
10540 (defun gnus-article-set-window-start (&optional line)
10542 (get-buffer-window gnus-article-buffer)
10544 (set-buffer gnus-article-buffer)
10545 (goto-char (point-min))
10548 (gnus-message 6 "Moved to bookmark")
10549 (search-forward "\n\n" nil t)
10550 (forward-line line)
10553 (defun gnus-request-article-this-buffer (article group)
10554 "Get an article and insert it into this buffer."
10555 (setq group (or group gnus-newsgroup-name))
10557 ;; Open server if it has closed.
10558 (gnus-check-news-server (gnus-find-method-for-group group))
10560 ;; Using `gnus-request-article' directly will insert the article into
10561 ;; `nntp-server-buffer' - so we'll save some time by not having to
10562 ;; copy it from the server buffer into the article buffer.
10564 ;; We only request an article by message-id when we do not have the
10565 ;; headers for it, so we'll have to get those.
10566 (and (stringp article)
10567 (let ((gnus-override-method gnus-refer-article-method))
10568 (gnus-read-header article)))
10570 ;; If the article number is negative, that means that this article
10571 ;; doesn't belong in this newsgroup (possibly), so we find its
10572 ;; message-id and request it by id instead of number.
10573 (if (not (numberp article))
10576 (set-buffer gnus-summary-buffer)
10577 (let ((header (gnus-get-header-by-num article)))
10579 (if (vectorp header)
10580 ;; It's a real article.
10581 (setq article (header-id header))
10582 ;; It is an extracted pseudo-article.
10583 (setq article 'pseudo)
10584 (gnus-request-pseudo-article header)))
10586 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10587 (if (not (eq (car method) 'nneething))
10589 (let ((dir (concat (file-name-as-directory (nth 1 method))
10590 (header-subject header))))
10591 (if (file-directory-p dir)
10593 (setq article 'nneething)
10594 (gnus-group-enter-directory dir)))))))))
10596 ;; Check the cache.
10597 (if (and gnus-use-cache
10599 (gnus-cache-request-article article group))
10601 ;; Get the article and into the article buffer.
10602 (if (or (stringp article) (numberp article))
10605 (let ((gnus-override-method
10606 (and (stringp article) gnus-refer-article-method)))
10607 (and (gnus-request-article article group (current-buffer))
10611 (defun gnus-read-header (id)
10612 "Read the headers of article ID and enter them into the Gnus system."
10613 (or gnus-newsgroup-headers-hashtb-by-number
10614 (gnus-make-headers-hashtable-by-number))
10616 (if (not (setq header
10617 (car (if (let ((gnus-nov-is-evil t))
10618 (gnus-retrieve-headers
10619 (list id) gnus-newsgroup-name))
10620 (gnus-get-newsgroup-headers)))))
10623 (header-set-number header gnus-reffed-article-number))
10624 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10625 (gnus-sethash (int-to-string (header-number header)) header
10626 gnus-newsgroup-headers-hashtb-by-number)
10628 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10629 (setq gnus-current-headers header)
10632 (defun gnus-article-prepare (article &optional all-headers header)
10633 "Prepare ARTICLE in article mode buffer.
10634 ARTICLE should either be an article number or a Message-ID.
10635 If ARTICLE is an id, HEADER should be the article headers.
10636 If ALL-HEADERS is non-nil, no headers are hidden."
10638 ;; Make sure we start in a summary buffer.
10639 (or (eq major-mode 'gnus-summary-mode)
10640 (set-buffer gnus-summary-buffer))
10641 (setq gnus-summary-buffer (current-buffer))
10642 ;; Make sure the connection to the server is alive.
10643 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10645 (gnus-check-news-server
10646 (gnus-find-method-for-group gnus-newsgroup-name))
10647 (gnus-request-group gnus-newsgroup-name t)))
10648 (or gnus-newsgroup-headers-hashtb-by-number
10649 (gnus-make-headers-hashtable-by-number))
10650 (let* ((article (if header (header-number header) article))
10651 (summary-buffer (current-buffer))
10652 (internal-hook gnus-article-internal-prepare-hook)
10653 (group gnus-newsgroup-name)
10656 (gnus-article-setup-buffer)
10657 (set-buffer gnus-article-buffer)
10658 (if (not (setq result (let ((buffer-read-only nil))
10659 (gnus-request-article-this-buffer
10661 ;; There is no such article.
10663 (if (not (numberp article))
10665 (setq gnus-article-current
10666 (cons gnus-newsgroup-name article))
10667 (set-buffer gnus-summary-buffer)
10668 (setq gnus-current-article article)
10669 (gnus-summary-mark-article article gnus-canceled-mark))
10670 (gnus-message 1 "No such article (may be canceled)")
10673 (if (or (eq result 'pseudo) (eq result 'nneething))
10676 (set-buffer summary-buffer)
10677 (setq gnus-last-article gnus-current-article
10678 gnus-newsgroup-history (cons gnus-current-article
10679 gnus-newsgroup-history)
10680 gnus-current-article 0
10681 gnus-current-headers nil
10682 gnus-article-current nil)
10683 (if (eq result 'nneething)
10684 (gnus-configure-windows 'summary)
10685 (gnus-configure-windows 'article))
10686 (gnus-set-global-variables))
10687 (gnus-set-mode-line 'article))
10688 ;; The result from the `request' was an actual article -
10689 ;; or at least some text that is now displayed in the
10691 (if (and (numberp article)
10692 (not (eq article gnus-current-article)))
10693 ;; Seems like a new article has been selected.
10694 ;; `gnus-current-article' must be an article number.
10696 (set-buffer summary-buffer)
10697 (setq gnus-last-article gnus-current-article
10698 gnus-newsgroup-history (cons gnus-current-article
10699 gnus-newsgroup-history)
10700 gnus-current-article article
10701 gnus-current-headers
10702 (gnus-get-header-by-num gnus-current-article)
10703 gnus-article-current
10704 (cons gnus-newsgroup-name gnus-current-article))
10705 (gnus-summary-show-thread)
10706 (run-hooks 'gnus-mark-article-hook)
10707 (gnus-set-mode-line 'summary)
10709 (run-hooks 'gnus-visual-mark-article-hook))
10710 ;; Set the global newsgroup variables here.
10711 ;; Suggested by Jim Sisolak
10712 ;; <sisolak@trans4.neep.wisc.edu>.
10713 (gnus-set-global-variables)
10714 (setq gnus-have-all-headers
10715 (or all-headers gnus-show-all-headers))
10716 (and gnus-use-cache
10717 (vectorp (gnus-get-header-by-number article))
10718 (gnus-cache-possibly-enter-article
10720 (gnus-get-header-by-number article)
10721 (memq article gnus-newsgroup-marked)
10722 (memq article gnus-newsgroup-dormant)
10723 (memq article gnus-newsgroup-unreads)))))
10724 ;; Hooks for getting information from the article.
10725 ;; This hook must be called before being narrowed.
10726 (let (buffer-read-only)
10727 (run-hooks 'internal-hook)
10728 (run-hooks 'gnus-article-prepare-hook)
10729 ;; Decode MIME message.
10730 (if (and gnus-show-mime
10731 (or (not gnus-strict-mime)
10732 (gnus-fetch-field "Mime-Version")))
10733 (funcall gnus-show-mime-method))
10734 ;; Perform the article display hooks.
10735 (run-hooks 'gnus-article-display-hook))
10737 (goto-char (point-min))
10738 (and gnus-break-pages (gnus-narrow-to-page))
10739 (gnus-set-mode-line 'article)
10740 (gnus-configure-windows 'article)
10741 (goto-char (point-min))
10744 (defun gnus-article-show-all-headers ()
10745 "Show all article headers in article mode buffer."
10747 (gnus-article-setup-buffer)
10748 (set-buffer gnus-article-buffer)
10749 (let ((buffer-read-only nil))
10750 (remove-text-properties (point-min) (point-max)
10751 gnus-hidden-properties))))
10753 (defun gnus-article-hide-headers-if-wanted ()
10754 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10755 Provided for backwards compatability."
10756 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10757 (gnus-article-hide-headers)))
10759 (defun gnus-article-hide-headers (&optional delete)
10760 "Hide unwanted headers and possibly sort them as well."
10763 (set-buffer gnus-article-buffer)
10765 (let ((sorted gnus-sorted-header-list)
10766 (buffer-read-only nil)
10767 want-list beg want-l)
10768 ;; First we narrow to just the headers.
10770 (goto-char (point-min))
10771 ;; Hide any "From " lines at the beginning of (mail) articles.
10772 (while (looking-at "From ")
10775 (add-text-properties (point-min) (point) gnus-hidden-properties))
10776 ;; Then treat the rest of the header lines.
10779 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10780 ;; Then we use the two regular expressions
10781 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10782 ;; select which header lines is to remain visible in the
10784 (goto-char (point-min))
10785 (while (re-search-forward "^[^ \t]*:" nil t)
10786 (beginning-of-line)
10787 ;; We add the headers we want to keep to a list and delete
10788 ;; them from the buffer.
10789 (if (or (and (stringp gnus-visible-headers)
10790 (looking-at gnus-visible-headers))
10791 (and (not (stringp gnus-visible-headers))
10792 (stringp gnus-ignored-headers)
10793 (not (looking-at gnus-ignored-headers))))
10797 ;; Be sure to get multi-line headers...
10798 (re-search-forward "^[^ \t]*:" nil t)
10799 (beginning-of-line)
10801 (cons (buffer-substring beg (point)) want-list))
10802 (delete-region beg (point))
10805 ;; Next we perform the sorting by looking at
10806 ;; `gnus-sorted-header-list'.
10807 (goto-char (point-min))
10808 (while (and sorted want-list)
10809 (setq want-l want-list)
10811 (not (string-match (car sorted) (car want-l))))
10812 (setq want-l (cdr want-l)))
10815 (insert (car want-l))
10816 (setq want-list (delq (car want-l) want-list))))
10817 (setq sorted (cdr sorted)))
10818 ;; Any headers that were not matched by the sorted list we
10819 ;; just tack on the end of the visible header list.
10821 (insert (car want-list))
10822 (setq want-list (cdr want-list)))
10823 ;; And finally we make the unwanted headers invisible.
10825 (delete-region (point) (point-max))
10826 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10827 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10829 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10830 (defun gnus-article-treat-overstrike ()
10831 "Translate overstrikes into bold text."
10834 (set-buffer gnus-article-buffer)
10835 (let ((buffer-read-only nil))
10836 (while (search-forward "\b" nil t)
10837 (let ((next (following-char))
10838 (previous (char-after (- (point) 2))))
10839 (cond ((eq next previous)
10840 (delete-region (- (point) 2) (point))
10841 (put-text-property (point) (1+ (point))
10844 (delete-region (1- (point)) (1+ (point)))
10845 (put-text-property (1- (point)) (point)
10848 (delete-region (- (point) 2) (point))
10849 (put-text-property (point) (1+ (point))
10850 'face 'underline))))))))
10852 (defun gnus-article-word-wrap ()
10853 "Format too long lines."
10856 (set-buffer gnus-article-buffer)
10857 (let ((buffer-read-only nil))
10858 (goto-char (point-min))
10859 (search-forward "\n\n" nil t)
10861 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
10862 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
10863 (adaptive-fill-mode t))
10864 (while (not (eobp))
10865 (and (>= (current-column) (min fill-column (window-width)))
10866 (/= (preceding-char) ?:)
10867 (fill-paragraph nil))
10868 (end-of-line 2))))))
10870 (defun gnus-article-remove-cr ()
10871 "Remove carriage returns from an article."
10874 (set-buffer gnus-article-buffer)
10875 (let ((buffer-read-only nil))
10876 (goto-char (point-min))
10877 (while (search-forward "\r" nil t)
10878 (replace-match "" t t)))))
10880 (defun gnus-article-display-x-face (&optional force)
10881 "Look for an X-Face header and display it if present."
10882 (interactive (list 'force))
10884 (set-buffer gnus-article-buffer)
10885 (let ((inhibit-point-motion-hooks t)
10886 (case-fold-search nil))
10888 (goto-char (point-min))
10889 (search-forward "\n\n")
10890 (narrow-to-region (point-min) (point))
10891 (goto-char (point-min))
10892 (if (or (not gnus-article-x-face-command)
10894 (or (not gnus-article-x-face-too-ugly)
10895 (string-match gnus-article-x-face-too-ugly
10896 (mail-fetch-field "from"))))
10898 (goto-char (point-min))
10899 (not (re-search-forward "^X-Face: " nil t))))
10901 (let ((beg (point))
10902 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
10903 (if (symbolp gnus-article-x-face-command)
10904 (and (or (fboundp gnus-article-x-face-command)
10905 (error "%s is not a function"
10906 gnus-article-x-face-command))
10907 (funcall gnus-article-x-face-command beg end))
10908 (call-process-region beg end "sh" nil 0 nil
10909 "-c" gnus-article-x-face-command))))))))
10911 (defun gnus-article-de-quoted-unreadable (&optional force)
10912 "Do a naïve translation of a quoted-printable-encoded article.
10913 This is in no way, shape or form meant as a replacement for real MIME
10914 processing, but is simply a stop-gap measure until MIME support is
10916 If FORCE, decode the article whether it is marked as quoted-printable
10918 (interactive (list 'force))
10920 (set-buffer gnus-article-buffer)
10921 (let ((case-fold-search t)
10922 (buffer-read-only nil)
10923 (type (gnus-fetch-field "content-transfer-encoding")))
10924 (if (or force (and type (string-match "quoted-printable" type)))
10926 (goto-char (point-min))
10927 (search-forward "\n\n" nil 'move)
10928 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
10930 (defun gnus-mime-decode-quoted-printable (from to)
10931 ;; Decode quoted-printable from region between FROM and TO.
10934 (while (search-forward "=" to t)
10935 (cond ((eq (following-char) ?\n)
10938 ((looking-at "[0-9A-F][0-9A-F]")
10940 (insert (hexl-hex-string-to-integer
10941 (buffer-substring (point) (+ 2 (point)))))
10945 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
10947 (defvar gnus-article-time-units
10948 (list (cons 'year (* 365.25 24 60 60))
10949 (cons 'week (* 7 24 60 60))
10950 (cons 'day (* 24 60 60))
10951 (cons 'hour (* 60 60))
10955 (defun gnus-article-date-ut (&optional type)
10956 "Convert DATE date to universal time in the current article.
10957 If TYPE is `local', convert to local time; if it is `lapsed', output
10958 how much time has lapsed since DATE."
10959 (interactive (list 'ut))
10960 (let ((date (header-date (or gnus-current-headers
10961 (gnus-get-header-by-number
10962 (gnus-summary-article-number))"")))
10963 (date-regexp "^Date: \\|^X-Sent: "))
10968 (set-buffer gnus-article-buffer)
10969 (let ((buffer-read-only nil))
10970 (goto-char (point-min))
10971 (if (and (re-search-forward date-regexp nil t)
10973 (beginning-of-line)
10974 (looking-at date-regexp)))
10975 (delete-region (gnus-point-at-bol)
10976 (progn (end-of-line) (1+ (point))))
10977 (goto-char (point-min))
10978 (goto-char (- (search-forward "\n\n") 2)))
10982 (concat "Date: " (condition-case ()
10983 (timezone-make-date-arpa-standard date)
10989 (timezone-make-date-arpa-standard date nil "UT")
10993 ;; If the date is seriously mangled, the timezone
10994 ;; functions are liable to bug out, so we condition-case
10995 ;; the entire thing.
10996 (let* ((real-sec (condition-case ()
10997 (- (gnus-seconds-since-epoch
10998 (timezone-make-date-arpa-standard
10999 (current-time-string)
11000 (current-time-zone) "UT"))
11001 (gnus-seconds-since-epoch
11002 (timezone-make-date-arpa-standard
11005 (sec (abs real-sec))
11013 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11015 (setq sec (- sec (* num (cdr unit))))
11017 (concat (if prev ", " "") (int-to-string
11019 " " (symbol-name (car unit))
11020 (if (> num 1) "s" ""))
11022 gnus-article-time-units "")
11025 " in the future\n")))))
11027 (error "Unknown conversion type: %s" type)))))))))
11029 (defun gnus-article-date-local ()
11030 "Convert the current article date to the local timezone."
11032 (gnus-article-date-ut 'local))
11034 (defun gnus-article-date-lapsed ()
11035 "Convert the current article date to time lapsed since it was sent."
11037 (gnus-article-date-ut 'lapsed))
11039 (defun gnus-article-maybe-highlight ()
11040 (if gnus-visual (gnus-article-highlight)))
11044 (defun gnus-output-to-rmail (file-name)
11045 "Append the current article to an Rmail file named FILE-NAME."
11047 ;; Most of these codes are borrowed from rmailout.el.
11048 (setq file-name (expand-file-name file-name))
11049 (setq rmail-default-rmail-file file-name)
11050 (let ((artbuf (current-buffer))
11051 (tmpbuf (get-buffer-create " *Gnus-output*")))
11053 (or (get-file-buffer file-name)
11054 (file-exists-p file-name)
11055 (if (gnus-yes-or-no-p
11056 (concat "\"" file-name "\" does not exist, create it? "))
11057 (let ((file-buffer (create-file-buffer file-name)))
11059 (set-buffer file-buffer)
11060 (rmail-insert-rmail-file-header)
11061 (let ((require-final-newline nil))
11062 (write-region (point-min) (point-max) file-name t 1)))
11063 (kill-buffer file-buffer))
11064 (error "Output file does not exist")))
11065 (set-buffer tmpbuf)
11066 (buffer-disable-undo (current-buffer))
11068 (insert-buffer-substring artbuf)
11069 (gnus-convert-article-to-rmail)
11070 ;; Decide whether to append to a file or to an Emacs buffer.
11071 (let ((outbuf (get-file-buffer file-name)))
11073 (append-to-file (point-min) (point-max) file-name)
11074 ;; File has been visited, in buffer OUTBUF.
11075 (set-buffer outbuf)
11076 (let ((buffer-read-only nil)
11077 (msg (and (boundp 'rmail-current-message)
11078 (symbol-value 'rmail-current-message))))
11079 ;; If MSG is non-nil, buffer is in RMAIL mode.
11082 (narrow-to-region (point-max) (point-max))))
11083 (insert-buffer-substring tmpbuf)
11086 (goto-char (point-min))
11088 (search-backward "\^_")
11089 (narrow-to-region (point) (point-max))
11090 (goto-char (1+ (point-min)))
11091 (rmail-count-new-messages t)
11092 (rmail-show-message msg)))))))
11093 (kill-buffer tmpbuf)))
11095 (defun gnus-output-to-file (file-name)
11096 "Append the current article to a file named FILE-NAME."
11097 (setq file-name (expand-file-name file-name))
11098 (let ((artbuf (current-buffer))
11099 (tmpbuf (get-buffer-create " *Gnus-output*")))
11101 (set-buffer tmpbuf)
11102 (buffer-disable-undo (current-buffer))
11104 (insert-buffer-substring artbuf)
11105 ;; Append newline at end of the buffer as separator, and then
11106 ;; save it to file.
11107 (goto-char (point-max))
11109 (append-to-file (point-min) (point-max) file-name))
11110 (kill-buffer tmpbuf)))
11112 (defun gnus-convert-article-to-rmail ()
11113 "Convert article in current buffer to Rmail message format."
11114 (let ((buffer-read-only nil))
11115 ;; Convert article directly into Babyl format.
11116 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11117 (goto-char (point-min))
11118 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11119 (while (search-forward "\n\^_" nil t) ;single char
11120 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11121 (goto-char (point-max))
11124 (defun gnus-narrow-to-page (&optional arg)
11125 "Make text outside current page invisible except for page delimiter.
11126 A numeric arg specifies to move forward or backward by that many pages,
11127 thus showing a page other than the one point was originally in."
11129 (setq arg (if arg (prefix-numeric-value arg) 0))
11131 (forward-page -1) ;Beginning of current page.
11136 (forward-page (1- arg))))
11137 ;; Find the end of the page.
11139 ;; If we stopped due to end of buffer, stay there.
11140 ;; If we stopped after a page delimiter, put end of restriction
11141 ;; at the beginning of that line.
11142 ;; These are commented out.
11143 ;; (if (save-excursion (beginning-of-line)
11144 ;; (looking-at page-delimiter))
11145 ;; (beginning-of-line))
11146 (narrow-to-region (point)
11148 ;; Find the top of the page.
11150 ;; If we found beginning of buffer, stay there.
11151 ;; If extra text follows page delimiter on same line,
11153 ;; Otherwise, show text starting with following line.
11154 (if (and (eolp) (not (bobp)))
11158 (defun gnus-gmt-to-local ()
11159 "Rewrite Date header described in GMT to local in current buffer.
11160 Intended to be used with gnus-article-prepare-hook."
11164 (goto-char (point-min))
11165 (narrow-to-region (point-min)
11166 (progn (search-forward "\n\n" nil 'move) (point)))
11167 (goto-char (point-min))
11168 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11169 (let ((buffer-read-only nil)
11170 (date (buffer-substring-no-properties
11171 (match-beginning 1) (match-end 1))))
11172 (delete-region (match-beginning 1) (match-end 1))
11174 (timezone-make-date-arpa-standard
11175 date nil (current-time-zone))))))))
11178 ;; Article mode commands
11180 (defun gnus-article-next-page (&optional lines)
11181 "Show next page of current article.
11182 If end of article, return non-nil. Otherwise return nil.
11183 Argument LINES specifies lines to be scrolled up."
11185 (move-to-window-line -1)
11186 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11187 (if (save-excursion
11189 (and (pos-visible-in-window-p) ;Not continuation line.
11191 ;; Nothing in this page.
11192 (if (or (not gnus-break-pages)
11195 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11197 (gnus-narrow-to-page 1) ;Go to next page.
11199 ;; More in this page.
11203 ;; Long lines may cause an end-of-buffer error.
11204 (goto-char (point-max))))
11207 (defun gnus-article-prev-page (&optional lines)
11208 "Show previous page of current article.
11209 Argument LINES specifies lines to be scrolled down."
11211 (move-to-window-line 0)
11212 (if (and gnus-break-pages
11214 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11216 (gnus-narrow-to-page -1) ;Go to previous page.
11217 (goto-char (point-max))
11219 (scroll-down lines)))
11221 (defun gnus-article-refer-article ()
11222 "Read article specified by message-id around point."
11224 (search-forward ">" nil t) ;Move point to end of "<....>".
11225 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11227 (buffer-substring (match-beginning 1) (match-end 1))))
11228 (set-buffer gnus-summary-buffer)
11229 (gnus-summary-refer-article message-id))
11230 (error "No references around point")))
11232 (defun gnus-article-show-summary ()
11233 "Reconfigure windows to show summary buffer."
11235 (gnus-configure-windows 'article)
11236 (gnus-summary-goto-subject gnus-current-article))
11238 (defun gnus-article-describe-briefly ()
11239 "Describe article mode commands briefly."
11242 (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")))
11244 (defun gnus-article-summary-command ()
11245 "Execute the last keystroke in the summary buffer."
11247 (let ((obuf (current-buffer))
11248 (owin (current-window-configuration))
11250 (switch-to-buffer gnus-summary-buffer 'norecord)
11251 (setq func (lookup-key (current-local-map) (this-command-keys)))
11252 (call-interactively func)
11254 (set-window-configuration owin)
11255 (set-window-start (get-buffer-window (current-buffer)) (point))))
11257 (defun gnus-article-summary-command-nosave ()
11258 "Execute the last keystroke in the summary buffer."
11261 (pop-to-buffer gnus-summary-buffer 'norecord)
11262 (setq func (lookup-key (current-local-map) (this-command-keys)))
11263 (call-interactively func)))
11266 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11269 (defalias 'gnus-batch-kill 'gnus-batch-score)
11271 (defun gnus-batch-score ()
11272 "Run batched scoring.
11273 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11274 Newsgroups is a list of strings in Bnews format. If you want to score
11275 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11276 score the alt hierarchy, you'd say \"!alt.all\"."
11279 (gnus-newsrc-parse-options
11280 (apply (function concat)
11281 (mapcar (lambda (g) (concat g " "))
11282 command-line-args-left))))
11283 (gnus-expert-user t)
11284 (nnmail-spool-file nil)
11285 (gnus-use-dribble-file nil)
11286 (yes (car yes-and-no))
11287 (no (cdr yes-and-no))
11289 ;; Disable verbose message.
11290 gnus-novice-user gnus-large-newsgroup)
11291 ;; Eat all arguments.
11292 (setq command-line-args-left nil)
11295 ;; Apply kills to specified newsgroups in command line arguments.
11296 (setq newsrc (cdr gnus-newsrc-alist))
11298 (setq group (car (car newsrc)))
11299 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11300 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11302 (or (eq (car entry) t)
11303 (not (zerop (car entry)))))
11304 (if yes (string-match yes group) t)
11305 (or (null no) (not (string-match no group))))
11307 (gnus-summary-read-group group nil t)
11308 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11309 (gnus-summary-exit))))
11310 (setq newsrc (cdr newsrc)))
11312 (switch-to-buffer gnus-group-buffer)
11313 (gnus-group-save-newsrc)))
11315 (defun gnus-apply-kill-file ()
11316 "Apply a kill file to the current newsgroup.
11317 Returns the number of articles marked as read."
11318 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11319 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11320 (gnus-apply-kill-file-internal)
11323 (defun gnus-kill-save-kill-buffer ()
11325 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11326 (if (get-file-buffer file)
11328 (set-buffer (get-file-buffer file))
11329 (and (buffer-modified-p) (save-buffer))
11330 (kill-buffer (current-buffer)))))))
11332 (defvar gnus-kill-file-name "KILL"
11333 "Suffix of the kill files.")
11335 (defun gnus-newsgroup-kill-file (newsgroup)
11336 "Return the name of a kill file name for NEWSGROUP.
11337 If NEWSGROUP is nil, return the global kill file name instead."
11338 (cond ((or (null newsgroup)
11339 (string-equal newsgroup ""))
11340 ;; The global KILL file is placed at top of the directory.
11341 (expand-file-name gnus-kill-file-name
11342 (or gnus-kill-files-directory "~/News")))
11343 ((gnus-use-long-file-name 'not-kill)
11344 ;; Append ".KILL" to newsgroup name.
11345 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
11346 (or gnus-kill-files-directory "~/News")))
11348 ;; Place "KILL" under the hierarchical directory.
11349 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11350 "/" gnus-kill-file-name)
11351 (or gnus-kill-files-directory "~/News")))))
11358 (defvar gnus-dribble-ignore nil)
11359 (defvar gnus-dribble-eval-file nil)
11361 (defun gnus-dribble-file-name ()
11362 (concat gnus-current-startup-file "-dribble"))
11364 (defun gnus-dribble-enter (string)
11365 (if (and (not gnus-dribble-ignore)
11366 gnus-dribble-buffer
11367 (buffer-name gnus-dribble-buffer))
11368 (let ((obuf (current-buffer)))
11369 (set-buffer gnus-dribble-buffer)
11370 (insert string "\n")
11371 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11372 (set-buffer obuf))))
11374 (defun gnus-dribble-read-file ()
11375 (let ((dribble-file (gnus-dribble-file-name)))
11377 (set-buffer (setq gnus-dribble-buffer
11379 (file-name-nondirectory dribble-file))))
11380 (gnus-add-current-to-buffer-list)
11382 (set-visited-file-name dribble-file)
11383 (buffer-disable-undo (current-buffer))
11384 (bury-buffer (current-buffer))
11385 (set-buffer-modified-p nil)
11386 (let ((auto (make-auto-save-file-name))
11387 (gnus-dribble-ignore t))
11388 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11390 (if (file-newer-than-file-p auto dribble-file)
11391 (setq dribble-file auto))
11392 (insert-file-contents dribble-file)
11393 (if (not (zerop (buffer-size)))
11394 (set-buffer-modified-p t))
11396 "Auto-save file exists. Do you want to read it? ")
11397 (setq gnus-dribble-eval-file t))))))))
11399 (defun gnus-dribble-eval-file ()
11400 (if (not gnus-dribble-eval-file)
11402 (setq gnus-dribble-eval-file nil)
11404 (let ((gnus-dribble-ignore t))
11405 (set-buffer gnus-dribble-buffer)
11406 (eval-buffer (current-buffer))))))
11408 (defun gnus-dribble-delete-file ()
11409 (if (file-exists-p (gnus-dribble-file-name))
11410 (delete-file (gnus-dribble-file-name)))
11411 (if gnus-dribble-buffer
11413 (set-buffer gnus-dribble-buffer)
11414 (let ((auto (make-auto-save-file-name)))
11415 (if (file-exists-p auto)
11416 (delete-file auto))
11418 (set-buffer-modified-p nil)))))
11420 (defun gnus-dribble-save ()
11421 (if (and gnus-dribble-buffer
11422 (buffer-name gnus-dribble-buffer))
11424 (set-buffer gnus-dribble-buffer)
11427 (defun gnus-dribble-clear ()
11429 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11431 (set-buffer gnus-dribble-buffer)
11433 (set-buffer-modified-p nil)
11434 (setq buffer-saved-size (buffer-size))))))
11437 ;;; Server Communication
11440 ;; All the Gnus backends have the same interface, and should return
11441 ;; data in a similar format. Below is an overview of what functions
11442 ;; these packages must supply and what results they should return.
11446 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11449 ;; Functions for the imaginary backend `choke':
11451 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11452 ;; Should return all headers for all ARTICLES, or return NOV lines for
11455 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11456 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11457 ;; must be returned.
11459 ;; `choke-close-group GROUP &optional SERVER'
11460 ;; Close group. Most backends won't have to do anything with this
11461 ;; call, but it is an opportunity to clean up, if that is needed. It
11462 ;; is called when Gnus exits a group.
11464 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11465 ;; Return ARTICLE, which is either an article number or
11466 ;; message-id. Note that not all backends can return articles based on
11469 ;; `choke-request-list SERVER'
11470 ;; Return a list of all newsgroups on SERVER.
11472 ;; `choke-request-list-newsgroups SERVER'
11473 ;; Return a list of descriptions of all newsgroups on SERVER.
11475 ;; `choke-request-newgroups DATE &optional SERVER'
11476 ;; Return a list of all groups that have arrived after DATE on
11477 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11478 ;; always check whether the groups are old or not. Backends that do
11479 ;; not store date information may just return the entire list of
11480 ;; groups, although this might not be a good idea in general.
11482 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11483 ;; Should return a buffer that is suitable for "posting". nnspool and
11484 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11485 ;; buffer. This function should fill out the appropriate headers.
11487 ;; `choke-request-post &optional SERVER'
11488 ;; Function that will be called from a buffer to be posted.
11490 ;; `choke-open-server SERVER &optional ARGUMENT'
11491 ;; Open a connection to SERVER.
11493 ;; `choke-close-server &optional SERVER'
11494 ;; Close the connection to SERVER.
11496 ;; `choke-server-opened &optional SERVER'
11497 ;; Whether the conenction to SERVER is opened or not.
11499 ;; `choke-server-status &optional SERVER'
11500 ;; Should return a status string (not in the nntp buffer, but as the
11501 ;; result of the function).
11503 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11504 ;; Optional function for retrieving active file info on all groups in
11505 ;; GROUPS. Two return formats are supported: The normal active file
11506 ;; format, and a list of GROUP lines. This function should return (as
11507 ;; a function value) either `active' or `group', depending on what
11508 ;; format it returns.
11510 ;; The following functions are optional and apply only to backends
11511 ;; that are able to control the contents of their groups totally
11512 ;; (ie. mail backends.) Backends that aren't able to do that
11513 ;; shouldn't define these functions at all. Gnus will check for their
11514 ;; presence before attempting to call them.
11516 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11517 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11518 ;; backends will not be able to expire articles. Should return a list
11519 ;; of all articles that were not expired.
11521 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11522 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11523 ;; Removes any information it has added to the article (extra headers,
11524 ;; whatever - make it as clean as possible), and then passes the
11525 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11526 ;; function described below. If the ACCEPT-FORM returns a non-nil
11527 ;; value, the article should then be deleted. If LAST is nil, that
11528 ;; means that there will be further calls to this function. This might
11529 ;; be taken as an advice not to save buffers/internal variables just
11530 ;; yet, but wait until the last call to speed things up.
11532 ;; `choke-request-accept-article GROUP &optional LAST'
11533 ;; The contents of the current buffer will be put into GROUP. There
11534 ;; should, of course, be an article in the current buffer. This
11535 ;; function is normally only called by the function described above,
11536 ;; and LAST works the same way as in that function.
11538 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11539 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11540 ;; This provides an easy interface for allowing editing of
11541 ;; articles. Note that even headers may be edited, so the backend has
11542 ;; to update any tables (nov buffers, etc) that it maintains after
11543 ;; replacing the article.
11545 ;; `choke-request-create-group GROUP &optional SERVER'
11546 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11547 ;; might be a group that already exists, but hasn't been registered
11550 ;; All these functions must return nil if they couldn't service the
11551 ;; request. If the optional arguments are not supplied, some "current"
11552 ;; or "default" values should be used. In short, one should emulate an
11553 ;; NNTP server, in a way.
11555 ;; If you want to write a new backend, you just have to supply the
11556 ;; functions listed above. In addition, you must enter the new backend
11557 ;; into the list of valid select methods:
11558 ;; (setq gnus-valid-select-methods
11559 ;; (cons '("choke" mail) gnus-valid-select-methods))
11560 ;; The first element in this list is the name of the backend. Other
11561 ;; elemnets may be `mail' (for mail groups), `post' (for news
11562 ;; groups), `none' (neither), `respool' (for groups that can control
11563 ;; their contents).
11565 (defun gnus-start-news-server (&optional confirm)
11566 "Open a method for getting news.
11567 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11569 (if gnus-current-select-method
11570 ;; Stream is already opened.
11572 ;; Open NNTP server.
11573 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11576 ;; Read server name with completion.
11577 (setq gnus-nntp-server
11578 (completing-read "NNTP server: "
11579 (mapcar (lambda (server) (list server))
11580 (cons (list gnus-nntp-server)
11581 gnus-secondary-servers))
11582 nil nil gnus-nntp-server))))
11584 (if (and gnus-nntp-server
11585 (stringp gnus-nntp-server)
11586 (not (string= gnus-nntp-server "")))
11587 (setq gnus-select-method
11588 (cond ((or (string= gnus-nntp-server "")
11589 (string= gnus-nntp-server "::"))
11590 (list 'nnspool (system-name)))
11591 ((string-match "^:" gnus-nntp-server)
11592 (list 'nnmh gnus-nntp-server
11593 (list 'nnmh-directory
11594 (file-name-as-directory
11596 (concat "~/" (substring
11597 gnus-nntp-server 1)))))
11598 (list 'nnmh-get-new-mail nil)))
11600 (list 'nntp gnus-nntp-server)))))
11602 (setq how (car gnus-select-method))
11603 (cond ((eq how 'nnspool)
11605 (gnus-message 5 "Looking up local news spool..."))
11608 (gnus-message 5 "Looking up mh spool..."))
11611 (setq gnus-current-select-method gnus-select-method)
11612 (run-hooks 'gnus-open-server-hook)
11614 ;; gnus-open-server-hook might have opened it
11615 (gnus-server-opened gnus-select-method)
11616 (gnus-open-server gnus-select-method)
11619 "%s server on %s can't be opened. Continue? "
11620 (car gnus-select-method) (nth 1 gnus-select-method)))
11622 (gnus-message 1 "Couldn't open server on %s"
11623 (nth 1 gnus-select-method))
11627 (defun gnus-check-news-server (&optional method)
11628 "If the news server is down, start it up again."
11629 (let ((method (if method method gnus-select-method)))
11630 (and (stringp method)
11631 (setq method (gnus-server-to-method method)))
11632 (if (gnus-server-opened method)
11633 ;; Stream is already opened.
11636 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11637 (run-hooks 'gnus-open-server-hook)
11638 (or (gnus-server-opened method)
11639 (gnus-open-server method))
11642 (defun gnus-nntp-message (&optional message)
11643 "Check the status of the NNTP server.
11644 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11645 is returned insted of the status string."
11646 (let ((status (gnus-status-message (gnus-find-method-for-group
11647 gnus-newsgroup-name)))
11648 (message (or message "")))
11649 (if (and (stringp status) (> (length status) 0))
11652 (defun gnus-get-function (method function)
11653 (and (stringp method)
11654 (setq method (gnus-server-to-method method)))
11655 (let ((func (intern (format "%s-%s" (car method) function))))
11656 (if (not (fboundp func))
11658 (require (car method))
11659 (if (not (fboundp func))
11660 (error "No such function: %s" func))))
11663 ;;; Interface functions to the backends.
11665 (defun gnus-open-server (method)
11666 (funcall (gnus-get-function method 'open-server)
11667 (nth 1 method) (nthcdr 2 method)))
11669 (defun gnus-close-server (method)
11670 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11672 (defun gnus-request-list (method)
11673 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11675 (defun gnus-request-list-newsgroups (method)
11676 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11678 (defun gnus-request-newgroups (date method)
11679 (funcall (gnus-get-function method 'request-newgroups)
11680 date (nth 1 method)))
11682 (defun gnus-server-opened (method)
11683 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11685 (defun gnus-status-message (method)
11686 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11688 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11690 (defun gnus-request-group (group &optional dont-check)
11691 (let ((method (gnus-find-method-for-group group)))
11692 ; (and t (message "%s GROUP %s" (car method) group))
11693 (funcall (gnus-get-function method 'request-group)
11694 (gnus-group-real-name group) (nth 1 method) dont-check)))
11696 (defun gnus-request-asynchronous (group &optional articles)
11697 (let ((method (gnus-find-method-for-group group)))
11698 (funcall (gnus-get-function method 'request-asynchronous)
11699 (gnus-group-real-name group) (nth 1 method) articles)))
11701 (defun gnus-list-active-group (group)
11702 (let ((method (gnus-find-method-for-group group))
11703 (func 'list-active-group))
11704 (and (gnus-check-backend-function func group)
11705 (funcall (gnus-get-function method func)
11706 (gnus-group-real-name group) (nth 1 method)))))
11708 (defun gnus-request-group-description (group)
11709 (let ((method (gnus-find-method-for-group group))
11710 (func 'request-group-description))
11711 (and (gnus-check-backend-function func group)
11712 (funcall (gnus-get-function method func)
11713 (gnus-group-real-name group) (nth 1 method)))))
11715 (defun gnus-close-group (group)
11716 (let ((method (gnus-find-method-for-group group)))
11717 (funcall (gnus-get-function method 'close-group)
11718 (gnus-group-real-name group) (nth 1 method))))
11720 (defun gnus-retrieve-headers (articles group)
11721 (let ((method (gnus-find-method-for-group group)))
11722 (if (and gnus-use-cache (numberp (car articles)))
11723 (gnus-cache-retrieve-headers articles group)
11724 (funcall (gnus-get-function method 'retrieve-headers)
11725 articles (gnus-group-real-name group) (nth 1 method)))))
11727 (defun gnus-retrieve-groups (groups method)
11728 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11730 (defun gnus-request-article (article group &optional buffer)
11731 (let ((method (gnus-find-method-for-group group)))
11732 (funcall (gnus-get-function method 'request-article)
11733 article (gnus-group-real-name group) (nth 1 method) buffer)))
11735 (defun gnus-request-head (article group)
11736 (let ((method (gnus-find-method-for-group group)))
11737 (funcall (gnus-get-function method 'request-head)
11738 article (gnus-group-real-name group) (nth 1 method))))
11740 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11741 (defun gnus-request-post-buffer (post group subject header artbuf
11742 info follow-to respect-poster)
11743 (let* ((info (or info (and group (nth 2 (gnus-gethash
11744 group gnus-newsrc-hashtb)))))
11746 (if (and gnus-post-method
11747 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11749 (format "%s" (car (gnus-find-method-for-group
11750 gnus-newsgroup-name)))
11751 gnus-valid-select-methods)))
11753 (gnus-find-method-for-group gnus-newsgroup-name))))
11754 (or (gnus-server-opened method)
11755 (gnus-open-server method)
11756 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11757 (let ((mail-self-blind nil)
11758 (mail-archive-file-name nil))
11759 (funcall (gnus-get-function method 'request-post-buffer)
11760 post group subject header artbuf info follow-to
11763 (defun gnus-request-post (method &optional force)
11764 (and (stringp method)
11765 (setq method (gnus-server-to-method method)))
11766 (and (not force) gnus-post-method
11767 (memq 'post (assoc (format "%s" (car method))
11768 gnus-valid-select-methods))
11769 (setq method gnus-post-method))
11770 (funcall (gnus-get-function method 'request-post)
11773 (defun gnus-request-expire-articles (articles group &optional force)
11774 (let ((method (gnus-find-method-for-group group)))
11775 (funcall (gnus-get-function method 'request-expire-articles)
11776 articles (gnus-group-real-name group) (nth 1 method)
11779 (defun gnus-request-move-article
11780 (article group server accept-function &optional last)
11781 (let ((method (gnus-find-method-for-group group)))
11782 (funcall (gnus-get-function method 'request-move-article)
11783 article (gnus-group-real-name group)
11784 (nth 1 method) accept-function last)))
11786 (defun gnus-request-accept-article (group &optional last)
11787 (let ((func (if (symbolp group) group
11788 (car (gnus-find-method-for-group group)))))
11789 (funcall (intern (format "%s-request-accept-article" func))
11790 (if (stringp group) (gnus-group-real-name group) group)
11793 (defun gnus-request-replace-article (article group buffer)
11794 (let ((func (car (gnus-find-method-for-group group))))
11795 (funcall (intern (format "%s-request-replace-article" func))
11796 article (gnus-group-real-name group) buffer)))
11798 (defun gnus-request-create-group (group)
11799 (let ((method (gnus-find-method-for-group group)))
11800 (funcall (gnus-get-function method 'request-create-group)
11801 (gnus-group-real-name group) (nth 1 method))))
11803 (defun gnus-member-of-valid (symbol group)
11804 (memq symbol (assoc
11805 (format "%s" (car (gnus-find-method-for-group group)))
11806 gnus-valid-select-methods)))
11808 (defsubst gnus-secondary-method-p (method)
11809 (member method gnus-secondary-select-methods))
11811 (defun gnus-find-method-for-group (group &optional info)
11812 (or gnus-override-method
11814 gnus-select-method)
11815 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11818 (not (setq method (nth 4 info))))
11819 (setq method gnus-select-method)
11821 (cond ((stringp method)
11822 (gnus-server-to-method method))
11823 ((stringp (car method))
11824 (gnus-server-extend-method group method))
11827 (gnus-server-add-address method))))
11829 (defun gnus-check-backend-function (func group)
11830 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11832 (fboundp (intern (format "%s-%s" method func)))))
11834 (defun gnus-methods-using (method)
11835 (let ((valids gnus-valid-select-methods)
11838 (if (memq method (car valids))
11839 (setq outs (cons (car valids) outs)))
11840 (setq valids (cdr valids)))
11844 ;;; Active & Newsrc File Handling
11847 ;; Newsrc related functions.
11848 ;; Gnus internal format of gnus-newsrc-alist:
11849 ;; (("alt.general" 3 (1 . 1))
11850 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11851 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11852 ;; The first item is the group name; the second is the subscription
11853 ;; level; the third is either a range of a list of ranges of read
11854 ;; articles, the optional fourth element is a list of marked articles,
11855 ;; the optional fifth element is the select method.
11857 ;; Gnus internal format of gnus-newsrc-hashtb:
11858 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11859 ;; This is the entry for "alt.misc". The first element is the number
11860 ;; of unread articles in "alt.misc". The cdr of this entry is the
11861 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11862 ;; trivial to remove or add new elements into gnus-newsrc-alist
11863 ;; without scanning the entire list. So, to get the actual information
11864 ;; of "alt.misc", you'd say something like
11865 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11867 ;; Gnus internal format of gnus-active-hashtb:
11871 ;; The only element in each entry in this hash table is a range of
11872 ;; (possibly) available articles. (Articles in this range may have
11873 ;; been expired or canceled.)
11875 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11876 ;; ("alt.misc" "alt.test" "alt.general" ...)
11878 (defun gnus-setup-news (&optional rawfile level)
11879 "Setup news information.
11880 If RAWFILE is non-nil, the .newsrc file will also be read.
11881 If LEVEL is non-nil, the news will be set up at level LEVEL."
11882 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
11883 ;; Clear some variables to re-initialize news information.
11884 (if init (setq gnus-newsrc-alist nil
11885 gnus-active-hashtb nil))
11887 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11888 (if init (gnus-read-newsrc-file rawfile))
11890 ;; Read the active file and create `gnus-active-hashtb'.
11891 ;; If `gnus-read-active-file' is nil, then we just create an empty
11892 ;; hash table. The partial filling out of the hash table will be
11893 ;; done in `gnus-get-unread-articles'.
11894 (if (and gnus-read-active-file
11896 (gnus-read-active-file)
11897 (setq gnus-active-hashtb (make-vector 4095 0)))
11899 ;; Possibly eval the dribble file.
11900 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
11902 ;; Find the number of unread articles in each non-dead group.
11903 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
11904 ;; Find new newsgroups and treat them.
11905 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
11906 (gnus-server-opened gnus-select-method))
11907 (gnus-find-new-newsgroups))
11908 (if (and init gnus-check-bogus-newsgroups
11909 gnus-read-active-file (not level)
11910 (gnus-server-opened gnus-select-method))
11911 (gnus-check-bogus-newsgroups))))
11913 (defun gnus-find-new-newsgroups ()
11914 "Search for new newsgroups and add them.
11915 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11916 The `-n' option line from .newsrc is respected."
11918 (or (gnus-check-first-time-used)
11919 (if (or (consp gnus-check-new-newsgroups)
11920 (eq gnus-check-new-newsgroups 'ask-server))
11921 (gnus-ask-server-for-new-groups)
11923 group new-newsgroups)
11924 (gnus-message 5 "Checking for new newsgroups...")
11925 (or gnus-have-read-active-file (gnus-read-active-file))
11926 (setq gnus-newsrc-last-checked-date (current-time-string))
11927 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11928 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11929 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11932 (if (or (null (setq group (symbol-name sym)))
11933 (gnus-gethash group gnus-killed-hashtb)
11934 (gnus-gethash group gnus-newsrc-hashtb))
11936 (let ((do-sub (gnus-matches-options-n group)))
11937 (cond ((eq do-sub 'subscribe)
11938 (setq groups (1+ groups))
11939 (gnus-sethash group group gnus-killed-hashtb)
11941 gnus-subscribe-options-newsgroup-method group))
11942 ((eq do-sub 'ignore)
11945 (setq groups (1+ groups))
11946 (gnus-sethash group group gnus-killed-hashtb)
11947 (if gnus-subscribe-hierarchical-interactive
11948 (setq new-newsgroups (cons group new-newsgroups))
11949 (funcall gnus-subscribe-newsgroup-method group)))))))
11950 gnus-active-hashtb)
11952 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11953 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11955 (gnus-message 6 "%d new newsgroup%s arrived."
11956 groups (if (> groups 1) "s have" " has"))
11957 (gnus-message 6 "No new newsgroups."))))))
11959 (defun gnus-matches-options-n (group)
11960 ;; Returns `subscribe' if the group is to be uncoditionally
11961 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
11962 ;; no match for the group.
11964 ;; First we check the two user variables.
11966 ((and gnus-options-subscribe
11967 (string-match gnus-options-subscribe group))
11969 ((and gnus-options-not-subscribe
11970 (string-match gnus-options-not-subscribe group))
11972 ;; Then we go through the list that was retrieved from the .newsrc
11973 ;; file. This list has elements on the form
11974 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11975 ;; is in the reverse order of the options line) is returned.
11977 (let ((regs gnus-newsrc-options-n))
11979 (not (string-match (car (car regs)) group)))
11980 (setq regs (cdr regs)))
11981 (and regs (cdr (car regs)))))))
11983 (defun gnus-ask-server-for-new-groups ()
11984 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11985 (methods (cons gnus-select-method
11987 (and (consp gnus-check-new-newsgroups)
11988 gnus-check-new-newsgroups)
11989 gnus-secondary-select-methods)))
11991 (new-date (current-time-string))
11992 hashtb group new-newsgroups got-new)
11993 ;; Go thorugh both primary and secondary select methods and
11994 ;; request new newsgroups.
11996 (and (or (gnus-server-opened (car methods))
11997 (gnus-open-server (car methods)))
11998 (gnus-request-newgroups date (car methods))
12001 (set-buffer nntp-server-buffer)
12002 (or hashtb (setq hashtb (gnus-make-hashtable
12003 (count-lines (point-min) (point-max)))))
12004 ;; Enter all the new groups in a hashtable.
12005 (gnus-active-to-gnus-format (car methods) hashtb 'ignore)))
12006 (setq methods (cdr methods)))
12007 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12008 ;; Now all new groups from all select methods are in `hashtb'.
12010 (lambda (group-sym)
12011 (setq group (symbol-name group-sym))
12012 (if (or (gnus-gethash group gnus-newsrc-hashtb)
12013 (member group gnus-zombie-list)
12014 (member group gnus-killed-list))
12015 ;; The group is already known.
12017 (and (symbol-value group-sym)
12018 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12019 (let ((do-sub (gnus-matches-options-n group)))
12020 (cond ((eq do-sub 'subscribe)
12021 (setq groups (1+ groups))
12022 (gnus-sethash group group gnus-killed-hashtb)
12024 gnus-subscribe-options-newsgroup-method group))
12025 ((eq do-sub 'ignore)
12028 (setq groups (1+ groups))
12029 (gnus-sethash group group gnus-killed-hashtb)
12030 (if gnus-subscribe-hierarchical-interactive
12031 (setq new-newsgroups (cons group new-newsgroups))
12032 (funcall gnus-subscribe-newsgroup-method group)))))))
12035 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12036 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12038 (gnus-message 6 "%d new newsgroup%s arrived."
12039 groups (if (> groups 1) "s have" " has")))
12042 (defun gnus-check-first-time-used ()
12043 (if (or (> (length gnus-newsrc-alist) 1)
12044 (file-exists-p gnus-startup-file)
12045 (file-exists-p (concat gnus-startup-file ".el"))
12046 (file-exists-p (concat gnus-startup-file ".eld")))
12048 (gnus-message 6 "First time user; subscribing you to default groups")
12049 (or gnus-have-read-active-file (gnus-read-active-file))
12050 (setq gnus-newsrc-last-checked-date (current-time-string))
12051 (let ((groups gnus-default-subscribed-newsgroups)
12055 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12058 (if (null (setq group (symbol-name sym)))
12060 (let ((do-sub (gnus-matches-options-n group)))
12062 ((eq do-sub 'subscribe)
12063 (gnus-sethash group group gnus-killed-hashtb)
12064 (funcall gnus-subscribe-options-newsgroup-method group))
12065 ((eq do-sub 'ignore)
12068 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12069 gnus-active-hashtb)
12071 (if (gnus-gethash (car groups) gnus-active-hashtb)
12072 (gnus-group-change-level
12073 (car groups) gnus-level-default-subscribed gnus-level-killed))
12074 (setq groups (cdr groups)))
12075 (gnus-group-make-help-group)
12076 (and gnus-novice-user
12077 (gnus-message 7 "`A k' to list killed groups"))))))
12079 (defun gnus-subscribe-group (group previous &optional method)
12080 (gnus-group-change-level
12082 (list t group gnus-level-default-subscribed nil nil method)
12084 gnus-level-default-subscribed gnus-level-killed previous t))
12086 ;; `gnus-group-change-level' is the fundamental function for changing
12087 ;; subscription levels of newsgroups. This might mean just changing
12088 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12089 ;; again, which subscribes/unsubscribes a group, which is equally
12090 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12091 ;; from 8-9 to 1-7 means that you remove the group from the list of
12092 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12093 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12094 ;; which is trivial.
12095 ;; ENTRY can either be a string (newsgroup name) or a list (if
12096 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12097 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12099 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12100 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12102 (defun gnus-group-change-level (entry level &optional oldlevel
12103 previous fromkilled)
12104 (let (group info active num)
12105 ;; Glean what info we can from the arguments
12107 (if fromkilled (setq group (nth 1 entry))
12108 (setq group (car (nth 2 entry))))
12109 (setq group entry))
12110 (if (and (stringp entry)
12112 (< oldlevel gnus-level-zombie))
12113 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12114 (if (and (not oldlevel)
12116 (setq oldlevel (car (cdr (nth 2 entry)))))
12117 (if (stringp previous)
12118 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12120 (if (and (>= oldlevel gnus-level-zombie)
12121 (gnus-gethash group gnus-newsrc-hashtb))
12122 ;; We are trying to subscribe a group that is already
12126 (gnus-dribble-enter
12127 (format "(gnus-group-change-level %S %S %S %S %S)"
12128 group level oldlevel (car (nth 2 previous)) fromkilled))
12130 ;; Then we remove the newgroup from any old structures, if needed.
12131 ;; If the group was killed, we remove it from the killed or zombie
12132 ;; list. If not, and it is in fact going to be killed, we remove
12133 ;; it from the newsrc hash table and assoc.
12134 (cond ((>= oldlevel gnus-level-zombie)
12135 (if (= oldlevel gnus-level-zombie)
12136 (setq gnus-zombie-list (delete group gnus-zombie-list))
12137 (setq gnus-killed-list (delete group gnus-killed-list))))
12139 (if (and (>= level gnus-level-zombie)
12142 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12144 (setcdr (gnus-gethash (car (nth 3 entry))
12145 gnus-newsrc-hashtb)
12147 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12149 ;; Finally we enter (if needed) the list where it is supposed to
12150 ;; go, and change the subscription level. If it is to be killed,
12151 ;; we enter it into the killed or zombie list.
12152 (cond ((>= level gnus-level-zombie)
12153 ;; Remove from the hash table.
12154 (gnus-sethash group nil gnus-newsrc-hashtb)
12155 (or (gnus-group-foreign-p group)
12156 ;; We do not enter foreign groups into the list of dead
12158 (if (= level gnus-level-zombie)
12159 (setq gnus-zombie-list (cons group gnus-zombie-list))
12160 (setq gnus-killed-list (cons group gnus-killed-list)))))
12162 ;; If the list is to be entered into the newsrc assoc, and
12163 ;; it was killed, we have to create an entry in the newsrc
12164 ;; hashtb format and fix the pointers in the newsrc assoc.
12165 (if (>= oldlevel gnus-level-zombie)
12169 (setq info (cdr entry))
12170 (setq num (car entry)))
12171 (setq active (gnus-gethash group gnus-active-hashtb))
12172 (setq num (if active (- (1+ (cdr active)) (car active)) t))
12173 ;; Check whether the group is foreign. If so, the
12174 ;; foreign select method has to be entered into the
12176 (let ((method (gnus-group-method-name group)))
12177 (if (eq method gnus-select-method)
12178 (setq info (list group level nil))
12179 (setq info (list group level nil nil method)))))
12182 (let ((p gnus-newsrc-alist))
12183 (while (cdr (cdr p))
12186 (setq entry (cons info (cdr (cdr previous))))
12189 (setcdr (cdr previous) entry)
12190 (gnus-sethash group (cons num (cdr previous))
12191 gnus-newsrc-hashtb))
12192 (setcdr previous entry)
12193 (gnus-sethash group (cons num previous)
12194 gnus-newsrc-hashtb))
12196 (setcdr (gnus-gethash (car (car (cdr entry)))
12197 gnus-newsrc-hashtb)
12199 ;; It was alive, and it is going to stay alive, so we
12200 ;; just change the level and don't change any pointers or
12201 ;; hash table entries.
12202 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12204 (defun gnus-kill-newsgroup (newsgroup)
12205 "Obsolete function. Kills a newsgroup."
12206 (gnus-group-change-level
12207 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12209 (defun gnus-check-bogus-newsgroups (&optional confirm)
12210 "Remove bogus newsgroups.
12211 If CONFIRM is non-nil, the user has to confirm the deletion of every
12213 (let ((newsrc (cdr gnus-newsrc-alist))
12215 (gnus-message 5 "Checking bogus newsgroups...")
12216 (or gnus-have-read-active-file (gnus-read-active-file))
12217 ;; Find all bogus newsgroup that are subscribed.
12219 (setq group (car (car newsrc)))
12220 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12221 (nth 4 (car newsrc)) ; Foreign
12223 (not (gnus-y-or-n-p
12224 (format "Remove bogus newsgroup: %s " group)))))
12227 ;; Found a bogus newsgroup.
12228 (setq bogus (cons group bogus)))
12229 (setq newsrc (cdr newsrc)))
12230 ;; Remove all bogus subscribed groups by first killing them, and
12231 ;; then removing them from the list of killed groups.
12233 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12235 (gnus-group-change-level entry gnus-level-killed)
12236 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12237 (setq bogus (cdr bogus)))
12238 ;; Then we remove all bogus groups from the list of killed and
12239 ;; zombie groups. They are are removed without confirmation.
12240 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12243 (setq killed (symbol-value (car dead-lists)))
12245 (setq group (car killed))
12246 (or (gnus-gethash group gnus-active-hashtb)
12247 ;; The group is bogus.
12248 (set (car dead-lists)
12249 (delete group (symbol-value (car dead-lists)))))
12250 (setq killed (cdr killed)))
12251 (setq dead-lists (cdr dead-lists))))
12252 (gnus-message 5 "Checking bogus newsgroups...done")))
12254 (defun gnus-check-duplicate-killed-groups ()
12255 "Remove duplicates from the list of killed groups."
12257 (let ((killed gnus-killed-list))
12259 (gnus-message 9 "%d" (length killed))
12260 (setcdr killed (delete (car killed) (cdr killed)))
12261 (setq killed (cdr killed)))))
12263 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12264 ;; and compute how many unread articles there are in each group.
12265 (defun gnus-get-unread-articles (&optional level)
12266 (let* ((newsrc (cdr gnus-newsrc-alist))
12267 (level (or level (1+ gnus-level-subscribed)))
12270 (cond ((and gnus-activate-foreign-newsgroups
12271 (not (numberp gnus-activate-foreign-newsgroups)))
12272 (1+ gnus-level-subscribed))
12273 ((numberp gnus-activate-foreign-newsgroups)
12274 gnus-activate-foreign-newsgroups)
12277 info group active virtuals method)
12278 (gnus-message 5 "Checking new news...")
12281 (setq info (car newsrc)
12283 active (gnus-gethash group gnus-active-hashtb))
12285 ;; Check newsgroups. If the user doesn't want to check them, or
12286 ;; they can't be checked (for instance, if the news server can't
12287 ;; be reached) we just set the number of unread articles in this
12288 ;; newsgroup to t. This means that Gnus thinks that there are
12289 ;; unread articles, but it has no idea how many.
12290 (if (and (setq method (nth 4 info))
12291 (not (gnus-server-equal gnus-select-method
12292 (gnus-server-get-method nil method)))
12293 (not (gnus-secondary-method-p method)))
12294 ;; These groups are foreign. Check the level.
12295 (if (<= (nth 1 info) foreign-level)
12296 (if (eq (car (if (stringp method)
12297 (gnus-server-to-method method)
12298 (nth 4 info))) 'nnvirtual)
12299 ;; We have to activate the virtual groups after all
12300 ;; the others, so we just pop them on a list for
12302 (setq virtuals (cons info virtuals))
12303 (and (setq active (gnus-activate-newsgroup (car info)))
12304 ;; Close the groups as we look at them!
12305 (gnus-close-group group))))
12307 ;; These groups are native or secondary.
12308 (if (and (not gnus-read-active-file)
12309 (<= (nth 1 info) level))
12310 (setq active (gnus-activate-newsgroup (car info)))))
12313 (gnus-get-unread-articles-in-group info active)
12314 ;; The group couldn't be reached, so we nix out the number of
12315 ;; unread articles and stuff.
12316 (gnus-sethash group nil gnus-active-hashtb)
12317 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12319 (setq newsrc (cdr newsrc)))
12321 ;; Activate the virtual groups. This has to be done after all the
12323 ;; !!! If one virtual group contains another virtual group, even
12324 ;; doing it this way might cause problems.
12326 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
12327 (gnus-get-unread-articles-in-group (car virtuals) active))
12328 (setq virtuals (cdr virtuals)))
12330 (gnus-message 5 "Checking new news...done")))
12332 ;; Create a hash table out of the newsrc alist. The `car's of the
12333 ;; alist elements are used as keys.
12334 (defun gnus-make-hashtable-from-newsrc-alist ()
12335 (let ((alist gnus-newsrc-alist)
12336 (ohashtb gnus-newsrc-hashtb)
12338 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12340 (setq prev (setq gnus-newsrc-alist
12341 (if (equal (car (car gnus-newsrc-alist))
12344 (cons (list "dummy.group" 0 nil) alist)))))
12346 (gnus-sethash (car (car alist))
12347 (cons (and ohashtb (car (gnus-gethash
12348 (car (car alist)) ohashtb)))
12349 prev) gnus-newsrc-hashtb)
12351 alist (cdr alist)))))
12353 (defun gnus-make-hashtable-from-killed ()
12354 "Create a hash table from the killed and zombie lists."
12355 (let ((lists '(gnus-killed-list gnus-zombie-list))
12357 (setq gnus-killed-hashtb
12358 (gnus-make-hashtable
12359 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12361 (setq list (symbol-value (car lists)))
12362 (setq lists (cdr lists))
12364 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12365 (setq list (cdr list))))))
12367 (defun gnus-get-unread-articles-in-group (info active)
12368 (let* ((range (nth 2 info))
12370 (marked (nth 3 info)))
12371 ;; If a cache is present, we may have to alter the active info.
12372 (and gnus-use-cache
12373 (gnus-cache-possibly-alter-active (car info) active))
12374 ;; Modify the list of read articles according to what articles
12375 ;; are available; then tally the unread articles and add the
12376 ;; number to the group hash table entry.
12378 ((zerop (cdr active))
12381 (setq num (- (1+ (cdr active)) (car active))))
12382 ((not (listp (cdr range)))
12383 ;; Fix a single (num . num) range according to the
12384 ;; active hash table.
12385 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12386 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12387 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12388 ;; Compute number of unread articles.
12389 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12391 ;; The read list is a list of ranges. Fix them according to
12392 ;; the active hash table.
12393 ;; First peel off any elements that are below the lower
12395 (while (and (cdr range)
12397 (or (and (atom (car (cdr range))) (car (cdr range)))
12398 (car (car (cdr range))))))
12399 (if (numberp (car range))
12402 (or (and (numberp (car (cdr range)))
12404 (cdr (car (cdr range))))))
12405 (setcdr (car range)
12406 (or (and (numberp (nth 1 range)) (nth 1 range))
12407 (cdr (car (cdr range))))))
12408 (setcdr range (cdr (cdr range))))
12409 ;; Adjust the first element to be the same as the lower limit.
12410 (if (and (not (atom (car range)))
12411 (< (cdr (car range)) (car active)))
12412 (setcdr (car range) (1- (car active))))
12413 ;; Then we want to peel off any elements that are higher
12414 ;; than the upper active limit.
12415 (let ((srange range))
12416 ;; Go past all legal elements.
12417 (while (and (cdr srange)
12418 (<= (or (and (atom (car (cdr srange)))
12419 (car (cdr srange)))
12420 (car (car (cdr srange)))) (cdr active)))
12421 (setq srange (cdr srange)))
12423 ;; Nuke all remaining illegal elements.
12424 (setcdr srange nil))
12426 ;; Adjust the final element.
12427 (if (and (not (atom (car srange)))
12428 (> (cdr (car srange)) (cdr active)))
12429 (setcdr (car srange) (cdr active))))
12430 ;; Compute the number of unread articles.
12432 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12433 (cdr (car range))))
12434 (or (and (atom (car range)) (car range))
12435 (car (car range))))))
12436 (setq range (cdr range)))
12437 (setq num (max 0 (- (cdr active) num)))))
12440 (and (assq 'tick marked)
12441 (inline (gnus-remove-illegal-marked-articles
12442 (assq 'tick marked) (nth 2 info))))
12443 (and (assq 'dormant marked)
12444 (inline (gnus-remove-illegal-marked-articles
12445 (assq 'dormant marked) (nth 2 info))))
12447 (gnus-gethash (car info) gnus-newsrc-hashtb)
12448 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12449 (length (cdr (assq 'dormant marked)))))))))
12452 (defun gnus-remove-illegal-marked-articles (marked ranges)
12453 (let ((m (cdr marked)))
12454 ;; Make sure that all ticked articles are a subset of the unread
12457 (if (gnus-member-of-range (car m) ranges)
12458 (setcdr marked (cdr m))
12460 (setq m (cdr m)))))
12462 (defun gnus-activate-newsgroup (group)
12463 (let ((method (gnus-find-method-for-group group))
12465 (and (or (gnus-server-opened method) (gnus-open-server method))
12466 (gnus-request-group group)
12468 (set-buffer nntp-server-buffer)
12469 (goto-char (point-min))
12470 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12472 (goto-char (match-beginning 1))
12474 group (setq active (cons (read (current-buffer))
12475 (read (current-buffer))))
12476 gnus-active-hashtb))
12479 (defun gnus-update-read-articles
12480 (group unread unselected ticked &optional domarks replied expirable killed
12481 dormant bookmark score)
12482 "Update the list of read and ticked articles in GROUP using the
12483 UNREAD and TICKED lists.
12484 Note: UNSELECTED has to be sorted over `<'.
12485 Returns whether the updating was successful."
12486 (let* ((active (or gnus-newsgroup-active
12487 (gnus-gethash group gnus-active-hashtb)))
12488 (entry (gnus-gethash group gnus-newsrc-hashtb))
12489 (info (nth 2 entry))
12490 (marked (nth 3 info))
12492 (unread (sort (copy-sequence unread) (function <)))
12494 (if (or (not info) (not active))
12495 ;; There is no info on this group if it was, in fact,
12496 ;; killed. Gnus stores no information on killed groups, so
12497 ;; there's nothing to be done.
12498 ;; One could store the information somewhere temporarily,
12499 ;; perhaps... Hmmm...
12501 ;; Remove any negative articles numbers.
12502 (while (and unread (< (car unread) 0))
12503 (setq unread (cdr unread)))
12504 ;; Remove any expired article numbers
12505 (while (and unread (< (car unread) (car active)))
12506 (setq unread (cdr unread)))
12507 (while (and ticked (< (car ticked) (car active)))
12508 (setq ticked (cdr ticked)))
12509 (while (and dormant (< (car dormant) (car active)))
12510 (setq dormant (cdr dormant)))
12511 (setq unread (sort (append unselected unread) '<))
12512 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12513 (setcar entry (max 0 (- (length unread) (length ticked)
12514 (length dormant))))
12515 ;; Compute the ranges of read articles by looking at the list of
12516 ;; unread articles.
12518 (if (/= (car unread) prev)
12519 (setq read (cons (if (= prev (1- (car unread))) prev
12520 (cons prev (1- (car unread)))) read)))
12521 (setq prev (1+ (car unread)))
12522 (setq unread (cdr unread)))
12523 (if (<= prev (cdr active))
12524 (setq read (cons (cons prev (cdr active)) read)))
12525 ;; Enter this list into the group info.
12526 (setcar (cdr (cdr info))
12527 (if (> (length read) 1) (nreverse read) read))
12528 ;; Enter the list of ticked articles.
12529 (gnus-set-marked-articles
12531 (if domarks replied (cdr (assq 'reply marked)))
12532 (if domarks expirable (cdr (assq 'expire marked)))
12533 (if domarks killed (cdr (assq 'killed marked)))
12534 (if domarks dormant (cdr (assq 'dormant marked)))
12535 (if domarks bookmark (cdr (assq 'bookmark marked)))
12536 (if domarks score (cdr (assq 'score marked))))
12539 (defun gnus-make-articles-unread (group articles)
12540 "Mark ARTICLES in GROUP as unread."
12541 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12542 (gnus-gethash (gnus-group-real-name group)
12543 gnus-newsrc-hashtb))))
12544 (ranges (nth 2 info))
12547 (and (gnus-member-of-range (car articles) ranges)
12548 (setq news (cons (car articles) news)))
12549 (setq articles (cdr articles)))
12552 (setcar (nthcdr 2 info)
12553 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12554 (gnus-group-update-group group t))))
12556 ;; Get the active file(s) from the backend(s).
12557 (defun gnus-read-active-file ()
12558 (gnus-group-set-mode-line)
12559 (let ((methods (if (or (gnus-server-opened gnus-select-method)
12560 (gnus-open-server gnus-select-method))
12561 ;; The native server is available.
12562 (cons gnus-select-method gnus-secondary-select-methods)
12563 ;; The native server is down, so we just do the
12565 gnus-secondary-select-methods))
12567 (setq gnus-have-read-active-file nil)
12569 (set-buffer nntp-server-buffer)
12571 (let* ((where (nth 1 (car methods)))
12572 (mesg (format "Reading active file%s via %s..."
12573 (if (and where (not (zerop (length where))))
12574 (concat " from " where) "")
12575 (car (car methods)))))
12576 (gnus-message 5 mesg)
12577 (gnus-check-news-server (car methods))
12579 ((and (eq gnus-read-active-file 'some)
12580 (gnus-check-backend-function
12581 'retrieve-groups (car (car methods))))
12582 (let ((newsrc (cdr gnus-newsrc-alist))
12585 (and (gnus-server-equal
12586 (gnus-find-method-for-group
12587 (car (car newsrc)) (car newsrc))
12588 (gnus-server-get-method nil (car methods)))
12589 (setq groups (cons (car (car newsrc)) groups)))
12590 (setq newsrc (cdr newsrc)))
12591 (setq list-type (gnus-retrieve-groups groups (car methods)))
12592 (cond ((not list-type)
12594 1 "Cannot read partial active file from %s server."
12595 (car (car methods)))
12598 ((eq list-type 'active)
12599 (gnus-active-to-gnus-format (car methods)))
12601 (gnus-groups-to-gnus-format (car methods))))))
12603 (if (not (gnus-request-list (car methods)))
12605 (gnus-message 1 "Cannot read active file from %s server."
12606 (car (car methods)))
12608 (gnus-active-to-gnus-format (car methods))
12609 ;; We mark this active file as read.
12610 (setq gnus-have-read-active-file
12611 (cons (car methods) gnus-have-read-active-file))
12612 (gnus-message 5 "%sdone" mesg)))))
12613 (setq methods (cdr methods))))))
12615 ;; Read an active file and place the results in `gnus-active-hashtb'.
12616 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12617 (let ((cur (current-buffer))
12619 (if (and gnus-active-hashtb
12620 (not (equal method gnus-select-method)))
12622 (setq gnus-active-hashtb
12623 (if (equal method gnus-select-method)
12624 (gnus-make-hashtable
12625 (count-lines (point-min) (point-max)))
12626 (gnus-make-hashtable 4096))))))
12627 (flag-hashtb (gnus-make-hashtable 60)))
12628 ;; Delete unnecessary lines.
12629 (goto-char (point-min))
12630 (while (search-forward "\nto." nil t)
12631 (delete-region (1+ (match-beginning 0))
12632 (progn (forward-line 1) (point))))
12633 (or (string= gnus-ignored-newsgroups "")
12635 (goto-char (point-min))
12636 (delete-matching-lines gnus-ignored-newsgroups)))
12637 ;; If these are groups from a foreign select method, we insert the
12638 ;; group prefix in front of the group names.
12639 (and method (not (eq method gnus-select-method))
12640 (let ((prefix (gnus-group-prefixed-name "" method)))
12641 (goto-char (point-min))
12642 (while (and (not (eobp))
12643 (progn (insert prefix)
12644 (zerop (forward-line 1)))))))
12645 (goto-char (point-min))
12646 ;; Store active file in hashtable.
12647 (goto-char (point-min))
12648 (if (string-match "%[oO]" gnus-group-line-format)
12649 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12650 ;; If we want information on moderated groups, we use this
12652 (let* ((mod-hashtb (make-vector 7 0))
12653 (m (intern "m" mod-hashtb))
12655 (while (not (eobp))
12656 (condition-case nil
12658 (narrow-to-region (point) (gnus-point-at-eol))
12659 (setq group (let ((obarray hashtb)) (read cur)))
12660 (if (and (numberp (setq max (read cur)))
12661 (numberp (setq min (read cur)))
12663 (skip-chars-forward " \t")
12665 (or (= (following-char) ?=)
12666 (= (following-char) ?x)
12667 (= (following-char) ?j)))))
12668 (set group (cons min max))
12670 ;; Enter moderated groups into a list.
12671 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12672 (setq gnus-moderated-list
12673 (cons (symbol-name group) gnus-moderated-list))))
12677 ;; And if we do not care about moderation, we use this loop,
12678 ;; which is faster.
12679 (let (group max min)
12680 (while (not (eobp))
12683 (narrow-to-region (point) (gnus-point-at-eol))
12684 ;; group gets set to a symbol interned in the hash table
12685 ;; (what a hack!!) - jwz
12686 (setq group (let ((obarray hashtb)) (read cur)))
12687 (if (and (numberp (setq max (read cur)))
12688 (numberp (setq min (read cur)))
12690 (skip-chars-forward " \t")
12692 (or (= (following-char) ?=)
12693 (= (following-char) ?x)
12694 (= (following-char) ?j)))))
12695 (set group (cons min max))
12702 (gnus-message 3 "Warning - illegal active: %s"
12704 (gnus-point-at-bol) (gnus-point-at-eol)))
12707 (forward-line 1))))))
12709 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12710 ;; Parse a "groups" active file.
12711 (let ((cur (current-buffer))
12715 (setq gnus-active-hashtb
12716 (gnus-make-hashtable
12717 (count-lines (point-min) (point-max)))))))
12718 (prefix (and method (not (eq method gnus-select-method))
12719 (gnus-group-prefixed-name "" method))))
12721 (goto-char (point-min))
12723 ;; We split this into to separate loops, one with the prefix
12724 ;; and one without to speed the reading up somewhat.
12726 (let (min max opoint)
12727 (while (not (eobp))
12728 (read cur) (read cur)
12729 (setq min (read cur)
12732 (skip-chars-forward " \t")
12735 (set (let ((obarray hashtb)) (read cur))
12739 (while (not (eobp))
12740 (if (= (following-char) ?2)
12742 (read cur) (read cur)
12743 (setq min (read cur)
12745 (set (let ((obarray hashtb)) (read cur))
12747 (forward-line 1))))
12749 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
12751 (defun gnus-read-newsrc-file (&optional force)
12752 "Read startup file.
12753 If FORCE is non-nil, the .newsrc file is read."
12754 ;; Reset variables that might be defined in the .newsrc.eld file.
12755 (let ((variables gnus-variable-list))
12757 (set (car variables) nil)
12758 (setq variables (cdr variables))))
12759 (let* ((newsrc-file gnus-current-startup-file)
12760 (quick-file (concat newsrc-file ".el")))
12762 ;; We always load the .newsrc.eld file. If always contains
12763 ;; much information that can not be gotten from the .newsrc
12764 ;; file (ticked articles, killed groups, foreign methods, etc.)
12765 (gnus-read-newsrc-el-file quick-file)
12768 (and (file-newer-than-file-p newsrc-file quick-file)
12769 (file-newer-than-file-p newsrc-file
12770 (concat quick-file "d")))
12771 (not gnus-newsrc-alist))
12772 ;; We read the .newsrc file. Note that if there if a
12773 ;; .newsrc.eld file exists, it has already been read, and
12774 ;; the `gnus-newsrc-hashtb' has been created. While reading
12775 ;; the .newsrc file, Gnus will only use the information it
12776 ;; can find there for changing the data already read -
12777 ;; ie. reading the .newsrc file will not trash the data
12778 ;; already read (except for read articles).
12780 (gnus-message 5 "Reading %s..." newsrc-file)
12781 (set-buffer (find-file-noselect newsrc-file))
12782 (buffer-disable-undo (current-buffer))
12783 (gnus-newsrc-to-gnus-format)
12784 (kill-buffer (current-buffer))
12785 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12787 (defun gnus-read-newsrc-el-file (file)
12788 (let ((ding-file (concat file "d")))
12789 ;; We always, always read the .eld file.
12790 (gnus-message 5 "Reading %s..." ding-file)
12791 (let (gnus-newsrc-assoc)
12792 (condition-case nil
12793 (load ding-file t t t)
12795 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12796 (let ((inhibit-quit t))
12797 (gnus-uncompress-newsrc-alist))
12798 (gnus-make-hashtable-from-newsrc-alist)
12799 (if (not (file-newer-than-file-p file ding-file))
12801 ;; Old format quick file
12802 (gnus-message 5 "Reading %s..." file)
12803 ;; The .el file is newer than the .eld file, so we read that one
12805 (gnus-read-old-newsrc-el-file file))))
12807 ;; Parse the old-style quick startup file
12808 (defun gnus-read-old-newsrc-el-file (file)
12809 (let (newsrc killed marked group m)
12811 (let ((gnus-killed-assoc nil)
12812 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12814 (condition-case nil
12817 (setq newsrc gnus-newsrc-assoc
12818 killed gnus-killed-assoc
12819 marked gnus-marked-assoc)))
12820 (setq gnus-newsrc-alist nil)
12822 (setq group (car newsrc))
12823 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12826 (setcar (nthcdr 2 info) (cdr (cdr group)))
12828 (if (nth 1 group) gnus-level-default-subscribed
12829 gnus-level-default-unsubscribed))
12830 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
12831 (setq gnus-newsrc-alist
12835 (if (nth 1 group) gnus-level-default-subscribed
12836 gnus-level-default-unsubscribed)
12837 (cdr (cdr group))))
12838 gnus-newsrc-alist)))
12839 (if (setq m (assoc (car group) marked))
12840 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12841 (setq newsrc (cdr newsrc)))
12842 (setq newsrc killed)
12844 (setcar newsrc (car (car newsrc)))
12845 (setq newsrc (cdr newsrc)))
12846 (setq gnus-killed-list killed))
12847 ;; The .el file version of this variable does not begin with
12848 ;; "options", while the .eld version does, so we just add it if it
12851 gnus-newsrc-options
12853 (and (not (string-match "^ *options" gnus-newsrc-options))
12854 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
12855 (and (not (string-match "\n$" gnus-newsrc-options))
12856 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))))
12857 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
12858 (gnus-make-hashtable-from-newsrc-alist)))
12860 (defun gnus-make-newsrc-file (file)
12861 "Make server dependent file name by catenating FILE and server host name."
12862 (let* ((file (expand-file-name file nil))
12863 (real-file (concat file "-" (nth 1 gnus-select-method))))
12864 (if (or (file-exists-p real-file)
12865 (file-exists-p (concat real-file ".el"))
12866 (file-exists-p (concat real-file ".eld")))
12869 (defun gnus-uncompress-newsrc-alist ()
12870 ;; Uncompress all lists of marked articles in the newsrc assoc.
12871 (let ((newsrc gnus-newsrc-alist)
12874 (if (not (setq marked (nth 3 (car newsrc))))
12877 (or (eq 'score (car (car marked)))
12878 (eq 'bookmark (car (car marked)))
12879 (eq 'killed (car (car marked)))
12880 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12881 (setq marked (cdr marked))))
12882 (setq newsrc (cdr newsrc)))))
12884 (defun gnus-compress-newsrc-alist ()
12885 ;; Compress all lists of marked articles in the newsrc assoc.
12886 (let ((newsrc gnus-newsrc-alist)
12889 (if (not (setq marked (nth 3 (car newsrc))))
12892 (or (eq 'score (car (car marked)))
12893 (eq 'bookmark (car (car marked)))
12894 (eq 'killed (car (car marked)))
12895 (setcdr (car marked)
12897 (gnus-compress-sequence
12898 (sort (cdr (car marked)) '<) t)
12899 (error (cdr (car marked))))))
12900 (setq marked (cdr marked))))
12901 (setq newsrc (cdr newsrc)))))
12903 (defun gnus-newsrc-to-gnus-format ()
12904 (setq gnus-newsrc-options "")
12905 (setq gnus-newsrc-options-n nil)
12907 (or gnus-active-hashtb
12908 (setq gnus-active-hashtb (make-vector 4095 0)))
12909 (let ((buf (current-buffer))
12910 (already-read (> (length gnus-newsrc-alist) 1))
12911 group subscribed options-symbol newsrc Options-symbol
12913 (goto-char (point-min))
12914 ;; We intern the symbol `options' in the active hashtb so that we
12915 ;; can `eq' against it later.
12916 (setq options-symbol (intern "options" gnus-active-hashtb))
12917 (setq Options-symbol (intern "Options" gnus-active-hashtb))
12919 (while (not (eobp))
12920 ;; We first read the first word on the line by narrowing and
12921 ;; then reading into `gnus-active-hashtb'. Most groups will
12922 ;; already exist in that hashtb, so this will save some string
12926 (progn (skip-chars-forward "^ \t!:\n") (point)))
12927 (goto-char (point-min))
12929 (and (/= (point-min) (point-max))
12930 (let ((obarray gnus-active-hashtb)) (read buf))))
12932 ;; Now, the symbol we have read is either `options' or a group
12933 ;; name. If it is an options line, we just add it to a string.
12935 ((or (eq symbol options-symbol)
12936 (eq symbol Options-symbol))
12937 (setq gnus-newsrc-options
12938 ;; This concatting is quite inefficient, but since our
12939 ;; thorough studies show that approx 99.37% of all
12940 ;; .newsrc files only contain a single options line, we
12941 ;; don't give a damn, frankly, my dear.
12942 (concat gnus-newsrc-options
12944 (gnus-point-at-bol)
12945 ;; Options may continue on the next line.
12946 (or (and (re-search-forward "^[^ \t]" nil 'move)
12947 (progn (beginning-of-line) (point)))
12950 ;; It was a group name.
12951 (setq subscribed (= (following-char) ?:)
12952 group (symbol-name symbol)
12955 ;; If the line ends here, this is clearly a buggy line, so
12956 ;; we put point a the beginning of line and let the cond
12957 ;; below do the error handling.
12958 (beginning-of-line)
12959 ;; We skip to the beginning of the ranges.
12960 (skip-chars-forward "!: \t"))
12961 ;; We are now at the beginning of the list of read articles.
12962 ;; We read them range by range.
12965 ((looking-at "[0-9]+")
12966 ;; We narrow and read a number instead of buffer-substring/
12967 ;; string-to-int because it's faster. narrow/widen is
12968 ;; faster than save-restriction/narrow, and save-restriction
12969 ;; produces a garbage object.
12971 (narrow-to-region (match-beginning 0) (match-end 0))
12974 ;; If the next character is a dash, then this is a range.
12975 (if (= (following-char) ?-)
12977 ;; We read the upper bound of the range.
12979 (if (not (looking-at "[0-9]+"))
12980 ;; This is a buggy line, by we pretend that
12981 ;; it's kinda OK. Perhaps the user should be
12983 (setq reads (cons num1 reads))
12987 (narrow-to-region (match-beginning 0)
12992 ;; It was just a simple number, so we add it to the
12994 (setq reads (cons num1 reads)))
12995 ;; If the next char in ?\n, then we have reached the end
12996 ;; of the line and return nil.
12997 (/= (following-char) ?\n))
12998 ((= (following-char) ?\n)
12999 ;; End of line, so we end.
13002 ;; Not numbers and not eol, so this might be a buggy
13004 (or (eobp) ; If it was eob instead of ?\n, we allow it.
13006 ;; The line was buggy.
13008 (gnus-message 3 "Mangled line: %s"
13009 (buffer-substring (gnus-point-at-bol)
13010 (gnus-point-at-eol)))
13014 ;; Skip past ", ". Spaces are illegal in these ranges, but
13015 ;; we allow them, because it's a common mistake to put a
13016 ;; space after the comma.
13017 (skip-chars-forward ", "))
13019 ;; We have already read .newsrc.eld, so we gently update the
13020 ;; data in the hash table with the information we have just
13024 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13027 ;; There is an entry for this file in the alist.
13029 (setcar (nthcdr 2 info) (nreverse reads))
13030 ;; We update the level very gently. In fact, we
13031 ;; only change it if there's been a status change
13032 ;; from subscribed to unsubscribed, or vice versa.
13033 (setq level (nth 1 info))
13034 (cond ((and (<= level gnus-level-subscribed)
13036 (setq level (if reads
13037 gnus-level-default-unsubscribed
13038 (1+ gnus-level-default-unsubscribed))))
13039 ((and (> level gnus-level-subscribed) subscribed)
13040 (setq level gnus-level-default-subscribed)))
13041 (setcar (cdr info) level))
13042 ;; This is a new group.
13043 (setq info (list group
13045 gnus-level-default-subscribed
13047 (1+ gnus-level-subscribed)
13048 gnus-level-default-unsubscribed))
13049 (nreverse reads))))
13050 (setq newsrc (cons info newsrc))))))
13053 (setq newsrc (nreverse newsrc))
13055 (if (not already-read)
13057 ;; We now have two newsrc lists - `newsrc', which is what we
13058 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13059 ;; what we've read from .newsrc.eld. We have to merge these
13060 ;; lists. We do this by "attaching" any (foreign) groups in the
13061 ;; gnus-newsrc-alist to the (native) group that precedes them.
13062 (let ((rc (cdr gnus-newsrc-alist))
13063 (prev gnus-newsrc-alist)
13066 (or (null (nth 4 (car rc))) ; It's a native group.
13067 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13068 (if (setq entry (assoc (car (car prev)) newsrc))
13069 (setcdr (setq mentry (memq entry newsrc))
13070 (cons (car rc) (cdr mentry)))
13071 (setq newsrc (cons (car rc) newsrc))))
13075 (setq gnus-newsrc-alist newsrc)
13076 ;; We make the newsrc hashtb.
13077 (gnus-make-hashtable-from-newsrc-alist)
13079 ;; Finally, if we read some options lines, we parse them.
13080 (or (string= gnus-newsrc-options "")
13081 (gnus-newsrc-parse-options gnus-newsrc-options))))
13083 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13084 ;; The return value will be a list on the form
13085 ;; ((regexp1 . ignore)
13086 ;; (regexp2 . subscribe)...)
13087 ;; When handling new newsgroups, groups that match a `ignore' regexp
13088 ;; will be ignored, and groups that match a `subscribe' regexp will be
13089 ;; subscribed. A line like
13090 ;; options -n !all rec.all
13091 ;; will lead to a list that looks like
13092 ;; (("^rec\\..+" . subscribe)
13093 ;; ("^.+" . ignore))
13094 ;; So all "rec.*" groups will be subscribed, while all the other
13095 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13096 ;; different from "options -n rec.all !all".
13097 (defun gnus-newsrc-parse-options (options)
13100 (gnus-set-work-buffer)
13101 (insert (regexp-quote options))
13102 ;; First we treat all continuation lines.
13103 (goto-char (point-min))
13104 (while (re-search-forward "\n[ \t]+" nil t)
13105 (replace-match " " t t))
13106 ;; Then we transform all "all"s into ".+"s.
13107 (goto-char (point-min))
13108 (while (re-search-forward "\\ball\\b" nil t)
13109 (replace-match ".+" t t))
13110 (goto-char (point-min))
13111 ;; We remove all other options than the "-n" ones.
13112 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13113 (replace-match " ")
13115 (goto-char (point-min))
13117 ;; We are only interested in "options -n" lines - we
13118 ;; ignore the other option lines.
13119 (while (re-search-forward "[ \t]-n" nil t)
13121 (or (save-excursion
13122 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13124 (gnus-point-at-eol)))
13125 ;; Search for all "words"...
13126 (while (re-search-forward "[^ \t,\n]+" eol t)
13127 (if (= (char-after (match-beginning 0)) ?!)
13128 ;; If the word begins with a bang (!), this is a "not"
13129 ;; spec. We put this spec (minus the bang) and the
13130 ;; symbol `ignore' into the list.
13131 (setq out (cons (cons (concat
13132 "^" (buffer-substring
13133 (1+ (match-beginning 0))
13136 ;; There was no bang, so this is a "yes" spec.
13137 (setq out (cons (cons (concat
13138 "^" (buffer-substring (match-beginning 0)
13140 'subscribe) out)))))
13142 (setq gnus-newsrc-options-n out))))
13145 (defun gnus-save-newsrc-file ()
13146 "Save .newsrc file."
13147 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13148 ;; from the variable gnus-newsrc-alist.
13149 (and (or gnus-newsrc-alist gnus-killed-list)
13150 gnus-current-startup-file
13152 (run-hooks 'gnus-save-newsrc-hook)
13154 (if (and gnus-use-dribble-file
13155 (or (not gnus-dribble-buffer)
13156 (not (buffer-name gnus-dribble-buffer))
13157 (zerop (save-excursion
13158 (set-buffer gnus-dribble-buffer)
13160 (gnus-message 4 "(No changes need to be saved)")
13161 (if gnus-save-newsrc-file
13163 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13164 ;; Make backup file of master newsrc.
13165 (gnus-gnus-to-newsrc-format)
13166 (gnus-message 5 "Saving %s...done"
13167 gnus-current-startup-file)))
13168 ;; Quickly loadable .newsrc.
13169 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13170 (set-visited-file-name (concat gnus-current-startup-file ".eld"))
13171 (gnus-add-current-to-buffer-list)
13172 (buffer-disable-undo (current-buffer))
13174 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13175 (gnus-gnus-to-quick-newsrc-format)
13177 (kill-buffer (current-buffer))
13178 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13179 (gnus-dribble-delete-file))))))
13181 (defun gnus-gnus-to-quick-newsrc-format ()
13182 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13183 (insert ";; (ding) Gnus startup file.\n")
13184 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13185 (insert ";; to read .newsrc.\n")
13186 (let ((variables gnus-variable-list)
13188 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13190 ;; insert lisp expressions.
13191 (gnus-compress-newsrc-alist)
13193 (setq variable (car variables))
13194 (and (boundp variable)
13195 (symbol-value variable)
13196 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13197 (insert "(setq " (symbol-name variable) " '"
13198 (prin1-to-string (symbol-value variable))
13200 (setq variables (cdr variables)))
13201 (gnus-uncompress-newsrc-alist)))
13204 (defun gnus-gnus-to-newsrc-format ()
13205 ;; Generate and save the .newsrc file.
13206 (let ((newsrc (cdr gnus-newsrc-alist))
13209 (set-buffer (create-file-buffer gnus-current-startup-file))
13210 (set-visited-file-name gnus-current-startup-file)
13211 (buffer-disable-undo (current-buffer))
13214 (if gnus-newsrc-options (insert gnus-newsrc-options))
13215 ;; Write subscribed and unsubscribed.
13217 (setq info (car newsrc))
13218 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13220 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13222 (if (setq ranges (nth 2 info))
13225 (if (not (listp (cdr ranges)))
13226 (if (= (car ranges) (cdr ranges))
13227 (insert (int-to-string (car ranges)))
13228 (insert (int-to-string (car ranges)) "-"
13229 (int-to-string (cdr ranges))))
13231 (setq range (car ranges)
13232 ranges (cdr ranges))
13233 (if (or (atom range) (= (car range) (cdr range)))
13234 (insert (int-to-string
13235 (or (and (atom range) range)
13237 (insert (int-to-string (car range)) "-"
13238 (int-to-string (cdr range))))
13239 (if ranges (insert ","))))))
13241 (setq newsrc (cdr newsrc)))
13243 (kill-buffer (current-buffer)))))
13245 (defun gnus-read-all-descriptions-files ()
13246 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13248 (gnus-read-descriptions-file (car methods))
13249 (setq methods (cdr methods)))
13252 (defun gnus-read-descriptions-file (&optional method)
13253 (let ((method (or method gnus-select-method)))
13254 ;; We create the hashtable whether we manage to read the desc file
13255 ;; to avoid trying to re-read after a failed read.
13256 (or gnus-description-hashtb
13257 (setq gnus-description-hashtb
13258 (gnus-make-hashtable (length gnus-active-hashtb))))
13259 ;; Mark this method's desc file as read.
13260 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13261 gnus-description-hashtb)
13263 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13265 ((not (or (gnus-server-opened method)
13266 (gnus-open-server method)))
13267 (gnus-message 1 "Couldn't open server")
13269 ((not (gnus-request-list-newsgroups method))
13270 (gnus-message 1 "Couldn't read newsgroups descriptions")
13276 (set-buffer nntp-server-buffer)
13277 (goto-char (point-min))
13278 (if (or (search-forward "\n.\n" nil t)
13279 (goto-char (point-max)))
13281 (beginning-of-line)
13282 (narrow-to-region (point-min) (point))))
13283 (goto-char (point-min))
13284 (while (not (eobp))
13285 ;; If we get an error, we set group to 0, which is not a
13289 (let ((obarray gnus-description-hashtb))
13290 ;; Group is set to a symbol interned in this
13292 (read nntp-server-buffer))
13294 (skip-chars-forward " \t")
13295 ;; ... which leads to this line being effectively ignored.
13296 (and (symbolp group)
13297 (set group (buffer-substring
13298 (point) (progn (end-of-line) (point)))))
13299 (forward-line 1))))
13300 (gnus-message 5 "Reading descriptions file...done")
13303 (defun gnus-group-get-description (group)
13304 ;; Get the description of a group by sending XGTITLE to the server.
13305 (and (gnus-request-group-description group)
13307 (set-buffer nntp-server-buffer)
13308 (goto-char (point-min))
13309 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13310 (buffer-substring (match-beginning 1) (match-end 1))))))
13316 (defvar gnus-server-mode-hook nil
13317 "Hook run in `gnus-server-mode' buffers.")
13319 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13320 "Format of server lines.
13321 It works along the same lines as a normal formatting string,
13322 with some simple extensions.")
13324 (defvar gnus-server-mode-line-format "(ding) List of servers"
13325 "The format specification for the server mode line.")
13327 (defconst gnus-server-line-format-alist
13328 (list (list ?h 'how ?s)
13330 (list ?w 'where ?s)
13333 (defconst gnus-server-mode-line-format-alist
13334 (list (list ?S 'news-server ?s)
13335 (list ?M 'news-method ?s)
13336 (list ?u 'user-defined ?s)))
13338 (defvar gnus-server-line-format-spec nil)
13339 (defvar gnus-server-mode-line-format-spec nil)
13340 (defvar gnus-server-killed-servers nil)
13342 (defvar gnus-server-mode-map nil)
13343 (put 'gnus-server-mode 'mode-class 'special)
13345 (if gnus-server-mode-map
13347 (setq gnus-server-mode-map (make-sparse-keymap))
13348 (suppress-keymap gnus-server-mode-map)
13349 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13350 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13351 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13352 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13353 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13354 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13355 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13356 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13357 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13358 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13360 (defun gnus-server-mode ()
13361 "Major mode for listing and editing servers.
13363 All normal editing commands are switched off.
13364 \\<gnus-server-mode-map>
13366 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13368 The following commands are available:
13370 \\{gnus-server-mode-map}"
13372 (if gnus-visual (gnus-server-make-menu-bar))
13373 (kill-all-local-variables)
13374 (setq mode-line-modified "-- ")
13375 (make-local-variable 'mode-line-format)
13376 (setq mode-line-format (copy-sequence mode-line-format))
13377 (and (equal (nth 3 mode-line-format) " ")
13378 (setcar (nthcdr 3 mode-line-format) ""))
13379 (setq major-mode 'gnus-server-mode)
13380 (setq mode-name "Server")
13381 ; (gnus-group-set-mode-line)
13382 (setq mode-line-process nil)
13383 (use-local-map gnus-server-mode-map)
13384 (buffer-disable-undo (current-buffer))
13385 (setq truncate-lines t)
13386 (setq buffer-read-only t)
13387 (run-hooks 'gnus-server-mode-hook))
13389 (defun gnus-server-insert-server-line (sformat name method)
13390 (let* ((sformat (or sformat gnus-server-line-format-spec))
13392 (where (nth 1 method))
13394 (beginning-of-line)
13396 ;; Insert the text.
13397 (insert (eval sformat))
13398 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13400 (defun gnus-server-setup-buffer ()
13401 (if (get-buffer gnus-server-buffer)
13404 (set-buffer (get-buffer-create gnus-server-buffer))
13406 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13408 (defun gnus-server-prepare ()
13409 (setq gnus-server-mode-line-format-spec
13410 (gnus-parse-format gnus-server-mode-line-format
13411 gnus-server-mode-line-format-alist))
13412 (setq gnus-server-line-format-spec
13413 (gnus-parse-format gnus-server-line-format
13414 gnus-server-line-format-alist))
13415 (let ((alist gnus-server-alist)
13416 (buffer-read-only nil))
13419 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13420 (setq alist (cdr alist))))
13421 (goto-char (point-min))
13422 (gnus-server-position-cursor))
13424 (defun gnus-server-server-name ()
13425 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13426 (and server (symbol-name server))))
13428 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13430 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13432 (defun gnus-server-update-server (server)
13434 (set-buffer gnus-server-buffer)
13435 (let ((buffer-read-only nil)
13436 (info (cdr (assoc server gnus-server-alist))))
13437 (gnus-dribble-enter
13438 (concat "(gnus-server-set-info \"" server "\" '"
13439 (prin1-to-string info) ")"))
13440 ;; Buffer may be narrowed.
13443 (if (gnus-server-goto-server server)
13444 (delete-region (progn (beginning-of-line) (point))
13445 (progn (forward-line 1) (point))))
13446 (let ((entry (assoc server gnus-server-alist)))
13447 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13448 (gnus-server-position-cursor))))))
13450 (defun gnus-server-set-info (server info)
13451 ;; Enter a select method into the virtual server alist.
13452 (gnus-dribble-enter
13453 (concat "(gnus-server-set-info \"" server "\" '"
13454 (prin1-to-string info) ")"))
13455 (let* ((server (nth 1 info))
13456 (entry (assoc server gnus-server-alist)))
13457 (if entry (setcdr entry info)
13458 (setq gnus-server-alist
13459 (nconc gnus-server-alist (list (cons server info)))))))
13461 (defun gnus-server-to-method (server)
13462 ;; Map virtual server names to select methods.
13463 (or (and (equal server "native") gnus-select-method)
13464 (cdr (assoc server gnus-server-alist))))
13466 (defun gnus-server-extend-method (group method)
13467 ;; This function "extends" a virtual server. If the server is
13468 ;; "hello", and the select method is ("hello" (my-var "something"))
13469 ;; in the group "alt.alt", this will result in a new virtual server
13470 ;; called "helly+alt.alt".
13472 (gnus-copy-sequence
13473 (if (equal (car method) "native") gnus-select-method
13474 (cdr (assoc (car method) gnus-server-alist))))))
13475 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13476 (nconc entry (cdr method))))
13478 (defun gnus-server-get-method (group method)
13479 ;; Input either a server name, and extended server name, or a
13480 ;; select method, and return a select method.
13481 (cond ((stringp method)
13482 (gnus-server-to-method method))
13483 ((stringp (car method))
13484 (gnus-server-extend-method group method))
13486 (gnus-server-add-address method))))
13488 (defun gnus-server-add-address (method)
13489 (let ((method-name (symbol-name (car method))))
13490 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13491 (not (assq (intern (concat method-name "-address")) method)))
13492 (append method (list (list (intern (concat method-name "-address"))
13496 (defun gnus-server-equal (s1 s2)
13498 (and (= (length s1) (length s2))
13500 (while (and s1 (member (car s1) s2))
13501 (setq s1 (cdr s1)))
13504 ;;; Interactive server functions.
13506 (defun gnus-server-kill-server (server)
13507 "Kill the server on the current line."
13508 (interactive (list (gnus-server-server-name)))
13509 (or (gnus-server-goto-server server)
13510 (if server (error "No such server: %s" server)
13511 (error "No server on the current line")))
13512 (let ((buffer-read-only nil))
13513 (delete-region (progn (beginning-of-line) (point))
13514 (progn (forward-line 1) (point))))
13515 (setq gnus-server-killed-servers
13516 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13517 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13518 gnus-server-alist))
13519 (gnus-server-position-cursor))
13521 (defun gnus-server-yank-server ()
13522 "Yank the previously killed server."
13524 (or gnus-server-killed-servers
13525 (error "No killed servers to be yanked"))
13526 (let ((alist gnus-server-alist)
13527 (server (gnus-server-server-name))
13528 (killed (car gnus-server-killed-servers)))
13530 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13531 (if (string= server (car (car gnus-server-alist)))
13532 (setq gnus-server-alist (cons killed gnus-server-alist))
13533 (while (and (cdr alist)
13534 (not (string= server (car (car (cdr alist))))))
13535 (setq alist (cdr alist)))
13536 (setcdr alist (cons killed (cdr alist)))))
13537 (gnus-server-update-server (car killed))
13538 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13539 (gnus-server-position-cursor)))
13541 (defun gnus-server-exit ()
13542 "Return to the group buffer."
13544 (kill-buffer (current-buffer))
13545 (switch-to-buffer gnus-group-buffer))
13547 (defun gnus-server-list-servers ()
13548 "List all available servers."
13550 (let ((cur (gnus-server-server-name)))
13551 (gnus-server-prepare)
13552 (if cur (gnus-server-goto-server cur)
13553 (goto-char (point-max))
13555 (gnus-server-position-cursor)))
13557 (defun gnus-server-copy-server (from to)
13560 (or (gnus-server-server-name)
13561 (error "No server on the current line"))
13562 (read-string "Copy to: ")))
13563 (or from (error "No server on current line"))
13564 (or (and to (not (string= to ""))) (error "No name to copy to"))
13565 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13566 (or (assoc from gnus-server-alist)
13567 (error "%s: no such server" from))
13568 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13569 (setcar to-entry to)
13570 (setcar (nthcdr 2 to-entry) to)
13571 (setq gnus-server-killed-servers
13572 (cons to-entry gnus-server-killed-servers))
13573 (gnus-server-yank-server)))
13575 (defun gnus-server-add-server (how where)
13577 (list (intern (completing-read "Server method: "
13578 gnus-valid-select-methods nil t))
13579 (read-string "Server name: ")))
13580 (setq gnus-server-killed-servers
13581 (cons (list where how where) gnus-server-killed-servers))
13582 (gnus-server-yank-server))
13584 (defun gnus-server-goto-server (server)
13585 "Jump to a server line."
13587 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13588 (let ((to (text-property-any (point-min) (point-max)
13589 'gnus-server (intern server))))
13593 (gnus-server-position-cursor)))))
13595 (defun gnus-server-edit-server (server)
13596 "Edit the server on the current line."
13597 (interactive (list (gnus-server-server-name)))
13599 (error "No server on current line"))
13600 (let ((winconf (current-window-configuration)))
13601 (get-buffer-create gnus-server-edit-buffer)
13602 (gnus-configure-windows 'edit-server)
13603 (gnus-add-current-to-buffer-list)
13605 (make-local-variable 'gnus-prev-winconf)
13606 (setq gnus-prev-winconf winconf)
13607 (use-local-map (copy-keymap (current-local-map)))
13608 (let ((done-func '(lambda ()
13609 "Exit editing mode and update the information."
13611 (gnus-server-edit-server-done 'group))))
13612 (setcar (cdr (nth 4 done-func)) server)
13613 (local-set-key "\C-c\C-c" done-func))
13615 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13616 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13618 (defun gnus-server-edit-server-done (server)
13620 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13621 (goto-char (point-min))
13622 (let ((form (read (current-buffer)))
13623 (winconf gnus-prev-winconf))
13624 (gnus-server-set-info server form)
13625 (kill-buffer (current-buffer))
13626 (and winconf (set-window-configuration winconf))
13627 (set-buffer gnus-server-buffer)
13628 (gnus-server-update-server (gnus-server-server-name))
13629 (gnus-server-position-cursor)))
13631 (defun gnus-server-read-server (server)
13633 (interactive (list (gnus-server-server-name)))
13634 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13636 (defun gnus-mouse-pick-server (e)
13638 (mouse-set-point e)
13639 (gnus-server-read-server (gnus-server-server-name)))
13642 ;;; entry points into gnus-score.el
13645 ;;; Finding score files.
13647 (defvar gnus-global-score-files nil
13648 "*List of global score files and directories.
13649 Set this variable if you want to use people's score files. One entry
13650 for each score file or each score file directory. Gnus will decide
13651 by itself what score files are applicable to which group.
13653 Say you want to use the single score file
13654 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13655 score files in the \"/ftp.some-where:/pub/score\" directory.
13657 (setq gnus-global-score-files
13658 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13659 \"/ftp.some-where:/pub/score\"))")
13661 (defun gnus-score-score-files (group)
13662 "Return a list of all possible score files."
13663 ;; Search and set any global score files.
13664 (and gnus-global-score-files
13665 (or gnus-internal-global-score-files
13666 (gnus-score-search-global-directories gnus-global-score-files)))
13667 ;; Fix the kill-file dir variable.
13668 (setq gnus-kill-files-directory
13669 (file-name-as-directory
13670 (or gnus-kill-files-directory "~/News/")))
13671 ;; If we can't read it, there are no score files.
13672 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13673 (setq gnus-score-file-list nil)
13674 (if (gnus-use-long-file-name 'not-score)
13675 ;; We want long file names.
13676 (if (or (not gnus-score-file-list)
13677 (not (car gnus-score-file-list))
13678 (gnus-file-newer-than gnus-kill-files-directory
13679 (car gnus-score-file-list)))
13680 (setq gnus-score-file-list
13681 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13684 gnus-kill-files-directory t
13685 (gnus-score-file-regexp))))))
13686 ;; We do not use long file names, so we have to do some
13687 ;; directory traversing.
13688 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13689 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13692 (setq dir (expand-file-name
13693 (concat gnus-kill-files-directory
13694 (gnus-replace-chars-in-string group ?. ?/))))
13695 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13696 (setq suffix (car suffixes)
13697 suffixes (cdr suffixes))
13698 (if (file-exists-p (concat dir "/" suffix))
13699 (setq files (cons (concat dir "/" suffix) files)))
13700 (while (>= (1+ (length dir)) mdir)
13701 (and (file-exists-p (concat dir "/all/" suffix))
13702 (setq files (cons (concat dir "/all/" suffix) files)))
13703 (string-match "/[^/]*$" dir)
13704 (setq dir (substring dir 0 (match-beginning 0)))))
13705 (setq gnus-score-file-list
13706 (cons nil (nreverse files)))))
13707 (cdr gnus-score-file-list)))
13709 (defun gnus-score-file-regexp ()
13710 (concat "\\(" gnus-score-file-suffix
13711 "\\|" gnus-adaptive-file-suffix "\\)$"))
13713 (defun gnus-score-find-bnews (group)
13714 "Return a list of score files for GROUP.
13715 The score files are those files in the ~/News directory which matches
13716 GROUP using BNews sys file syntax."
13717 (let* ((sfiles (append (gnus-score-score-files group)
13718 gnus-internal-global-score-files))
13719 (kill-dir (file-name-as-directory
13720 (expand-file-name gnus-kill-files-directory)))
13721 (klen (length kill-dir))
13722 ofiles not-match regexp)
13724 (set-buffer (get-buffer-create "*gnus score files*"))
13725 (buffer-disable-undo (current-buffer))
13726 ;; Go through all score file names and create regexp with them
13730 (insert (car sfiles))
13731 (goto-char (point-min))
13732 ;; First remove the suffix itself.
13733 (re-search-forward (concat "." (gnus-score-file-regexp)))
13734 (replace-match "" t t)
13735 (goto-char (point-min))
13736 (if (looking-at (regexp-quote kill-dir))
13737 ;; If the file name was just "SCORE", `klen' is one character
13739 (delete-char (min (1- (point-max)) klen))
13740 (goto-char (point-max))
13741 (search-backward "/")
13742 (delete-region (1+ (point)) (point-min)))
13743 ;; If short file names were used, we have to translate slashes.
13744 (goto-char (point-min))
13745 (while (re-search-forward "[/:]" nil t)
13746 (replace-match "." t t))
13747 ;; Translate "all" to ".*".
13748 (while (search-forward "all" nil t)
13749 (replace-match ".*" t t))
13750 (goto-char (point-min))
13751 ;; Deal with "not."s.
13752 (if (looking-at "not.")
13755 (setq regexp (buffer-substring 5 (point-max))))
13756 (setq regexp (buffer-substring 1 (point-max)))
13757 (setq not-match nil))
13758 ;; Finally - if this resulting regexp matches the group name,
13759 ;; we add this score file to the list of score files
13760 ;; applicable to this group.
13761 (if (or (and not-match
13762 (not (string-match regexp group)))
13763 (and (not not-match)
13764 (string-match regexp group)))
13765 (setq ofiles (cons (car sfiles) ofiles)))
13766 (setq sfiles (cdr sfiles)))
13767 (kill-buffer (current-buffer))
13768 ;; Slight kludge here - the last score file returned should be
13769 ;; the local score file, whether it exists or not. This is so
13770 ;; that any score commands the user enters will go to the right
13771 ;; file, and not end up in some global score file.
13774 (if (gnus-use-long-file-name 'not-score)
13775 (concat gnus-kill-files-directory group "."
13776 gnus-score-file-suffix)
13777 (concat gnus-kill-files-directory
13778 (gnus-replace-chars-in-string group ?. ?/)
13779 "/" gnus-score-file-suffix)))))
13780 (and (member localscore ofiles)
13781 (delete localscore ofiles))
13782 (setq ofiles (cons localscore ofiles)))
13783 (nreverse ofiles))))
13785 (defun gnus-score-find-single (group)
13786 "Return list containing the score file for GROUP."
13787 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13788 (gnus-score-file-name group)))
13790 (defun gnus-score-find-hierarchical (group)
13791 "Return list of score files for GROUP.
13792 This includes the score file for the group and all its parents."
13793 (let ((all (copy-sequence '(nil)))
13795 (while (string-match "\\." group (1+ start))
13796 (setq start (match-beginning 0))
13797 (setq all (cons (substring group 0 start) all)))
13798 (setq all (cons group all))
13800 (mapcar (lambda (newsgroup)
13801 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
13802 (setq all (nreverse all)))
13803 (mapcar 'gnus-score-file-name all))))
13805 (defvar gnus-score-file-alist-cache nil)
13807 (defun gnus-score-find-alist (group)
13808 "Return list of score files for GROUP.
13809 The list is determined from the variable gnus-score-file-alist."
13810 (let ((alist gnus-score-file-multiple-match-alist)
13812 ;; if this group has been seen before, return the cached entry
13813 (if (setq score-files (assoc group gnus-score-file-alist-cache))
13814 (cdr score-files) ; ensures caching of groups with no matches
13815 ;; handle the multiple match alist
13817 (and (string-match (car (car alist)) group)
13819 (nconc score-files (copy-sequence (cdr (car alist))))))
13820 (setq alist (cdr alist)))
13821 (setq alist gnus-score-file-single-match-alist)
13822 ;; handle the single match alist
13824 (and (string-match (car (car alist)) group)
13825 ;; progn used just in case ("regexp") has no files
13826 ;; and score-files is still nil. -sj
13827 ;; this can be construed as a "stop searching here" feature :>
13828 ;; and used to simplify regexps in the single-alist
13831 (nconc score-files (copy-sequence (cdr (car alist)))))
13833 (setq alist (cdr alist)))
13834 ;; cache the score files
13835 (setq gnus-score-file-alist-cache
13836 (cons (cons group score-files) gnus-score-file-alist-cache))
13840 (defun gnus-possibly-score-headers (&optional trace)
13841 (let ((func gnus-score-find-score-files-function)
13843 (and func (not (listp func))
13844 (setq func (list func)))
13845 ;; Go through all the functions for finding score files (or actual
13846 ;; scores) and add them to a list.
13847 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
13849 (and (symbolp (car func))
13850 (fboundp (car func))
13852 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
13853 (setq func (cdr func)))
13854 (if score-files (gnus-score-headers score-files trace))))
13856 (defun gnus-score-file-name (newsgroup &optional suffix)
13857 "Return the name of a score file for NEWSGROUP."
13858 (let ((suffix (or suffix gnus-score-file-suffix)))
13859 (cond ((or (null newsgroup)
13860 (string-equal newsgroup ""))
13861 ;; The global score file is placed at top of the directory.
13863 suffix (or gnus-kill-files-directory "~/News")))
13864 ((gnus-use-long-file-name 'not-score)
13865 ;; Append ".SCORE" to newsgroup name.
13866 (expand-file-name (concat newsgroup "." suffix)
13867 (or gnus-kill-files-directory "~/News")))
13869 ;; Place "SCORE" under the hierarchical directory.
13870 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13872 (or gnus-kill-files-directory "~/News"))))))
13874 (defun gnus-score-search-global-directories (files)
13875 "Scan all global score directories for score files."
13876 ;; Set the variable `gnus-internal-global-score-files' to all
13877 ;; available global score files.
13878 (interactive (list gnus-global-score-files))
13881 (if (string-match "/$" (car files))
13882 (setq out (nconc (directory-files
13884 (concat (gnus-score-file-regexp) "$"))))
13885 (setq out (cons (car files) out)))
13886 (setq files (cdr files)))
13887 (setq gnus-internal-global-score-files out)))
13889 ;; Allow redefinition of Gnus functions.
13891 (gnus-ems-redefine)
13895 ;;; gnus.el ends here