1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although (ding) Gnus looks suspiciously like GNUS, it isn't quite
27 ;; the same beast. Most internal structures have been changed. If you
28 ;; have written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
40 ;; Site dependent variables. These variables should be defined in
43 (defvar gnus-default-nntp-server nil
44 "Specify a default NNTP server.
45 This variable should be defined in paths.el, and should never be set
47 If you want to change servers, you should use `gnus-select-method'.
48 See the documentation to that variable.")
50 (defconst gnus-backup-default-subscribed-newsgroups
51 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
52 "Default default new newsgroups the first time Gnus is run.
53 Should be set in paths.el, and shouldn't be touched by the user.")
55 (defvar gnus-local-domain nil
56 "Local domain name without a host name.
57 The DOMAINNAME environment variable is used instead if it is defined.
58 If the `system-name' function returns the full Internet name, there is
59 no need to set this variable.")
61 (defvar gnus-local-organization nil
62 "String with a description of what organization (if any) the user belongs to.
63 The ORGANIZATION environment variable is used instead if it is defined.
64 If this variable contains a function, this function will be called
65 with the current newsgroup name as the argument. The function should
68 In any case, if the string (either in the variable, in the environment
69 variable, or returned by the function) is a file name, the contents of
70 this file will be used as the organization.")
72 (defvar gnus-use-generic-from nil
73 "If nil, the full host name will be the system name prepended to the domain name.
74 If this is a string, the full host name will be this string.
75 If this is non-nil, non-string, the domain name will be used as the
78 (defvar gnus-use-generic-path nil
79 "If nil, use the NNTP server name in the Path header.
80 If stringp, use this; if non-nil, use no host name (user name only).")
83 ;; Customization variables
85 (defvar gnus-select-method
86 (list 'nntp (or (getenv "NNTPSERVER")
87 (if (and gnus-default-nntp-server
88 (not (string= gnus-default-nntp-server "")))
89 gnus-default-nntp-server)
91 "*Default method for selecting a newsgroup.
92 This variable should be a list, where the first element is how the
93 news is to be fetched, the second is the address.
95 For instance, if you want to get your news via NNTP from
96 \"flab.flab.edu\", you could say:
98 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
100 If you want to use your local spool, say:
102 (setq gnus-select-method (list 'nnspool (system-name)))
104 If you use this variable, you must set `gnus-nntp-server' to nil.
106 There is a lot more to know about select methods and virtual servers -
107 see the manual for details.")
109 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
110 (defvar gnus-post-method nil
111 "*Preferred method for posting USENET news.
112 If this variable is nil, Gnus will use the current method to decide
113 which method to use when posting. If it is non-nil, it will override
114 the current method. This method will not be used in mail groups and
115 the like, only in \"real\" newsgroups.
117 The value must be a valid method as discussed in the documentation of
118 `gnus-select-method'.")
120 (defvar gnus-refer-article-method nil
121 "*Preferred method for fetching an article by Message-ID.
122 If you are reading news from the local spool (with nnspool), fetching
123 articles by Message-ID is painfully slow. By setting this method to an
124 nntp method, you might get acceptable results.
126 The value of this variable must be a valid select method as discussed
127 in the documentation of `gnus-select-method'")
129 (defvar gnus-secondary-select-methods nil
130 "*A list of secondary methods that will be used for reading news.
131 This is a list where each element is a complete select method (see
132 `gnus-select-method').
134 If, for instance, you want to read your mail with the nnml backend,
135 you could set this variable:
137 (setq gnus-secondary-select-methods '((nnml \"\"))")
139 (defvar gnus-secondary-servers nil
140 "*List of NNTP servers that the user can choose between interactively.
141 To make Gnus query you for a server, you have to give `gnus' a
142 non-numeric prefix - `C-u M-x gnus', in short.")
144 (defvar gnus-nntp-server nil
145 "*The name of the host running the NNTP server.
146 This variable is semi-obsolete. Use the `gnus-select-method'
149 (defvar gnus-nntp-service "nntp"
150 "*NNTP service name (\"nntp\" or 119).
151 This is an obsolete variable, which is scarcely used. If you use an
152 nntp server for your newsgroup and want to change the port number
153 used to 899, you would say something along these lines:
155 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
157 (defvar gnus-startup-file "~/.newsrc"
158 "*Your `.newsrc' file.
159 `.newsrc-SERVER' will be used instead if that exists.")
161 (defvar gnus-init-file "~/.gnus"
162 "*Your Gnus elisp startup file.
163 If a file with the .el or .elc suffixes exist, it will be read
166 (defvar gnus-group-faq-directory
167 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
168 "*Directory where the group FAQs are stored.
169 This will most commonly be on a remote machine, and the file will be
170 fetched by ange-ftp.")
172 (defvar gnus-group-archive-directory
173 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
174 "*The address of the (ding) archives.")
176 (defvar gnus-default-subscribed-newsgroups nil
177 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
178 It should be a list of strings.
179 If it is `t', Gnus will not do anything special the first time it is
180 started; it'll just use the normal newsgroups subscription methods.")
182 (defvar gnus-use-cross-reference t
183 "*Non-nil means that cross referenced articles will be marked as read.
184 If nil, ignore cross references. If t, mark articles as read in
185 subscribed newsgroups. If neither t nor nil, mark as read in all
188 (defvar gnus-use-dribble-file t
189 "*Non-nil means that Gnus will use a dribble file to store user updates.
190 If Emacs should crash without saving the .newsrc files, complete
191 information can be restored from the dribble file.")
193 (defvar gnus-asynchronous nil
194 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
196 (defvar gnus-asynchronous-article-function nil
197 "*Function for picking articles to pre-fetch, possibly.")
199 (defvar gnus-score-file-single-match-alist nil
200 "*Alist mapping regexps to lists of score files.
201 Each element of this alist should be of the form
202 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
204 If the name of a group is matched by REGEXP, the corresponding scorefiles
205 will be used for that group.
206 The first match found is used, subsequent matching entries are ignored (to
207 use multiple matches, see gnus-score-file-multiple-match-alist).
209 These score files are loaded in addition to any files returned by
210 gnus-score-find-score-files-function (which see).")
212 (defvar gnus-score-file-multiple-match-alist nil
213 "*Alist mapping regexps to lists of score files.
214 Each element of this alist should be of the form
215 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
217 If the name of a group is matched by REGEXP, the corresponding scorefiles
218 will be used for that group.
219 If multiple REGEXPs match a group, the score files corresponding to each
220 match will be used (for only one match to be used, see
221 gnus-score-file-single-match-alist).
223 These score files are loaded in addition to any files returned by
224 gnus-score-find-score-files-function (which see).")
227 (defvar gnus-score-file-suffix "SCORE"
228 "*Suffix of the score files.")
230 (defvar gnus-adaptive-file-suffix "ADAPT"
231 "*Suffix of the adaptive score files.")
233 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
234 "*Function used to find SCORE files.
235 The function will be called with the group name as the argument, and
236 should return a list of score files to apply to that group. The score
237 files do not actually have to exist.
239 Predefined values are:
241 gnus-score-find-single: Only apply the group's own SCORE file.
242 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
243 gnus-score-find-bnews: Apply SCORE files whose names matches.
245 See the documentation to these functions for more information.
247 This variable can also be a list of functions to be called. Each
248 function should either return a list of score files, or a list of
251 (defvar gnus-score-interactive-default-score 1000
252 "*Scoring commands will raise/lower the score with this number as the default.")
254 (defvar gnus-large-newsgroup 200
255 "*The number of articles which indicates a large newsgroup.
256 If the number of articles in a newsgroup is greater than this value,
257 confirmation is required for selecting the newsgroup.")
259 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
260 (defvar gnus-no-groups-message "No news is horrible news"
261 "*Message displayed by Gnus when no groups are available.")
263 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
264 "*Non-nil means that the default name of a file to save articles in is the group name.
265 If it's nil, the directory form of the group name is used instead.
267 If this variable is a list, and the list contains the element
268 `not-score', long file names will not be used for score files; if it
269 contains the element `not-save', long file names will not be used for
270 saving; and if it contains the element `not-kill', long file names
271 will not be used for kill files.")
273 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
274 "*Name of the directory articles will be saved in (default \"~/News\").
275 Initialized from the SAVEDIR environment variable.")
277 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
278 "*Name of the directory where kill files will be stored (default \"~/News\").
279 Initialized from the SAVEDIR environment variable.")
281 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
282 "*A function to save articles in your favorite format.
283 The function must be interactively callable (in other words, it must
284 be an Emacs command).
286 Gnus provides the following functions:
288 * gnus-summary-save-in-rmail (Rmail format)
289 * gnus-summary-save-in-mail (Unix mail format)
290 * gnus-summary-save-in-folder (MH folder)
291 * gnus-summary-save-in-file (article format).
292 * gnus-summary-save-in-vm (use VM's folder format).")
294 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
295 "*A function generating a file name to save articles in Rmail format.
296 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
298 (defvar gnus-mail-save-name (function gnus-plain-save-name)
299 "*A function generating a file name to save articles in Unix mail format.
300 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
302 (defvar gnus-folder-save-name (function gnus-folder-save-name)
303 "*A function generating a file name to save articles in MH folder.
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
306 (defvar gnus-file-save-name (function gnus-numeric-save-name)
307 "*A function generating a file name to save articles in article format.
308 The function is called with NEWSGROUP, HEADERS, and optional
311 (defvar gnus-split-methods nil
312 "*Variable used to suggest where articles are to be saved.
313 The syntax of this variable is the same as `nnmail-split-methods'.
315 For instance, if you would like to save articles related to Gnus in
316 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
317 you could set this variable to something like:
319 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
320 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
322 (defvar gnus-save-score nil
323 "*If non-nil, save group scoring info.")
325 (defvar gnus-use-adaptive-scoring nil
326 "*If non-nil, use some adaptive scoring scheme.")
328 (defvar gnus-use-cache nil
329 "*If non-nil, Gnus will cache (some) articles locally.")
331 (defvar gnus-use-scoring t
332 "*If non-nil, enable scoring.")
334 (defvar gnus-fetch-old-headers nil
335 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
336 If an unread article in the group refers to an older, already read (or
337 just marked as read) article, the old article will not normally be
338 displayed in the Summary buffer. If this variable is non-nil, Gnus
339 will attempt to grab the headers to the old articles, and thereby
340 build complete threads. If it has the value `some', only enough
341 headers to connect otherwise loose threads will be displayed.
343 The server has to support XOVER for any of this to work.")
345 (defvar gnus-visual t
346 "*If non-nil, will do various highlighting.
347 If nil, no mouse highlights (or any other highlights) will be
348 performed. This might speed up Gnus some when generating large group
349 and summary buffers.")
351 (defvar gnus-novice-user t
352 "*Non-nil means that you are a usenet novice.
353 If non-nil, verbose messages may be displayed and confirmations may be
356 (defvar gnus-expert-user nil
357 "*Non-nil means that you will never be asked for confirmation about anything.
358 And that means *anything*.")
360 (defvar gnus-verbose 7
361 "*Integer that says how verbose Gnus should be.
362 The higher the number, the more messages Gnus will flash to say what
363 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
364 display most important messages; and at ten, Gnus will keep on
365 jabbering all the time.")
367 (defvar gnus-keep-same-level nil
368 "*Non-nil means that the next newsgroup after the current will be on the same level.
369 When you type, for instance, `n' after reading the last article in the
370 current newsgroup, you will go to the next newsgroup. If this variable
371 is nil, the next newsgroup will be the next from the group
373 If this variable is non-nil, Gnus will either put you in the
374 next newsgroup with the same level, or, if no such newsgroup is
375 available, the next newsgroup with the lowest possible level higher
376 than the current level.
377 If this variable is `best', Gnus will make the next newsgroup the one
378 with the best level.")
380 (defvar gnus-summary-make-false-root 'adopt
381 "*nil means that Gnus won't gather loose threads.
382 If the root of a thread has expired or been read in a previous
383 session, the information necessary to build a complete thread has been
384 lost. Instead of having many small sub-threads from this original thread
385 scattered all over the summary buffer, Gnus can gather them.
387 If non-nil, Gnus will try to gather all loose sub-threads from an
388 original thread into one large thread.
390 If this variable is non-nil, it should be one of `none', `adopt',
393 If this variable is `none', Gnus will not make a false root, but just
394 present the sub-threads after another.
395 If this variable is `dummy', Gnus will create a dummy root that will
396 have all the sub-threads as children.
397 If this variable is `adopt', Gnus will make one of the \"children\"
398 the parent and mark all the step-children as such.
399 If this variable is `empty', the \"children\" are printed with empty
400 subject fields. (Or rather, they will be printed with a string
401 given by the `gnus-summary-same-subject' variable.)")
403 (defvar gnus-summary-gather-subject-limit nil
404 "*Maximum length of subject comparisons when gathering loose threads.
405 Use nil to compare full subjects. Setting this variable to a low
406 number will help gather threads that have been corrupted by
407 newsreaders chopping off subject lines, but it might also mean that
408 unrelated articles that have subject that happen to begin with the
409 same few characters will be incorrectly gathered.
411 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
412 comparing subjects.")
414 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
415 (defvar gnus-summary-same-subject ""
416 "*String indicating that the current article has the same subject as the previous.
417 This variable will only be used if the value of
418 `gnus-summary-make-false-root' is `empty'.")
420 (defvar gnus-summary-goto-unread nil
421 "*If non-nil, marking commands will go to the next unread article.")
423 (defvar gnus-group-goto-unread t
424 "*If non-nil, movement commands will go to the next unread and subscribed group.")
426 (defvar gnus-check-new-newsgroups t
427 "*Non-nil means that Gnus will add new newsgroups at startup.
428 If this variable is `ask-server', Gnus will ask the server for new
429 groups since the last time it checked. This means that the killed list
430 is no longer necessary, so you could set `gnus-save-killed-list' to
433 A variant is to have this variable be a list of select methods. Gnus
434 will then use the `ask-server' method on all these select methods to
435 query for new groups from all those servers.
438 (setq gnus-check-new-newsgroups
439 '((nntp \"some.server\") (nntp \"other.server\")))
441 If this variable is nil, then you have to tell Gnus explicitly to
442 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
444 (defvar gnus-check-bogus-newsgroups nil
445 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
446 If this variable is nil, then you have to tell Gnus explicitly to
447 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
449 (defvar gnus-read-active-file t
450 "*Non-nil means that Gnus will read the entire active file at startup.
451 If this variable is nil, Gnus will only know about the groups in your
454 If this variable is `some', Gnus will try to only read the relevant
455 parts of the active file from the server. Not all servers support
456 this, and it might be quite slow with other servers, but this should
457 generally be faster than both the t and nil value.
459 If you set this variable to nil or `some', you probably still want to
460 be told about new newsgroups that arrive. To do that, set
461 `gnus-check-new-newsgroups' to `ask-server'. This may not work
462 properly with all servers.")
464 (defvar gnus-level-subscribed 5
465 "*Groups with levels less than or equal to this variable are subscribed.")
467 (defvar gnus-level-unsubscribed 7
468 "*Groups with levels less than or equal to this variable are unsubscribed.
469 Groups with levels less than `gnus-level-subscribed', which should be
470 less than this variable, are subscribed.")
472 (defvar gnus-level-zombie 8
473 "*Groups with this level are zombie groups.")
475 (defvar gnus-level-killed 9
476 "*Groups with this level are killed.")
478 (defvar gnus-level-default-subscribed 3
479 "*New subscribed groups will be subscribed at this level.")
481 (defvar gnus-level-default-unsubscribed 6
482 "*New unsubscribed groups will be unsubscribed at this level.")
484 (defvar gnus-activate-foreign-newsgroups nil
485 "*If nil, Gnus will not check foreign newsgroups at startup.
486 If it is non-nil, it should be a number between one and nine. Foreign
487 newsgroups that have a level lower or equal to this number will be
488 activated on startup. For instance, if you want to active all
489 subscribed newsgroups, but not the rest, you'd set this variable to
490 `gnus-level-subscribed'.
492 If you subscribe to lots of newsgroups from different servers, startup
493 might take a while. By setting this variable to nil, you'll save time,
494 but you won't be told how many unread articles there are in the
497 (defvar gnus-save-newsrc-file t
498 "*Non-nil means that Gnus will save the `.newsrc' file.
499 Gnus always saves its own startup file, which is called
500 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
501 be readily understood by other newsreaders. If you don't plan on
502 using other newsreaders, set this variable to nil to save some time on
505 (defvar gnus-save-killed-list t
506 "*If non-nil, save the list of killed groups to the startup file.
507 This will save both time (when starting and quitting) and space (both
508 memory and disk), but it will also mean that Gnus has no record of
509 which groups are new and which are old, so the automatic new
510 newsgroups subscription methods become meaningless. You should always
511 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
514 (defvar gnus-interactive-catchup t
515 "*If non-nil, require your confirmation when catching up a group.")
517 (defvar gnus-interactive-post t
518 "*If non-nil, group name will be asked for when posting.")
520 (defvar gnus-interactive-exit t
521 "*If non-nil, require your confirmation when exiting Gnus.")
523 (defvar gnus-kill-killed nil
524 "*If non-nil, Gnus will apply kill files to already killed articles.
525 If it is nil, Gnus will never apply kill files to articles that have
526 already been through the scoring process, which might very well save lots
529 (defvar gnus-extract-address-components 'gnus-extract-address-components
530 "*Function for extracting address components from a From header.
531 Two pre-defined function exist: `gnus-extract-address-components',
532 which is the default, quite fast, and too simplistic solution, and
533 `mail-extract-address-components', which works much better, but is
536 (defvar gnus-summary-default-score 0
537 "*Default article score level.
538 If this variable is nil, scoring will be disabled.")
540 (defvar gnus-summary-zcore-fuzz 0
541 "*Fuzziness factor for the zcore in the summary buffer.
542 Articles with scores closer than this to `gnus-summary-default-score'
543 will not be marked.")
545 (defvar gnus-simplify-subject-fuzzy-regexp nil
546 "*Regular expression that will be removed from subject strings if
547 fuzzy subject simplification is selected.")
549 (defvar gnus-group-default-list-level gnus-level-subscribed
550 "*Default listing level.
551 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
553 (defvar gnus-group-use-permanent-levels nil
554 "*If non-nil, once you set a level, Gnus will use this level.")
556 (defvar gnus-show-mime nil
557 "*If non-nil, do mime processing of articles.
558 The articles will simply be fed to the function given by
559 `gnus-show-mime-method'.")
561 (defvar gnus-strict-mime t
562 "*If nil, decode MIME header even if there is not Mime-Version field.")
564 (defvar gnus-show-mime-method (function metamail-buffer)
565 "*Function to process a MIME message.
566 The function is called from the article buffer.")
568 (defvar gnus-show-threads t
569 "*If non-nil, display threads in summary mode.")
571 (defvar gnus-thread-hide-subtree nil
572 "*If non-nil, hide all threads initially.
573 If threads are hidden, you have to run the command
574 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
575 to expose hidden threads.")
577 (defvar gnus-thread-hide-killed t
578 "*If non-nil, hide killed threads automatically.")
580 (defvar gnus-thread-ignore-subject nil
581 "*If non-nil, ignore subjects and do all threading based on the Reference header.
582 If nil, which is the default, articles that have different subjects
583 from their parents will start separate threads.")
585 (defvar gnus-thread-indent-level 4
586 "*Number that says how much each sub-thread should be indented.")
588 (defvar gnus-ignored-newsgroups ""
589 "*A regexp to match uninteresting newsgroups in the active file.
590 Any lines in the active file matching this regular expression are
591 removed from the newsgroup list before anything else is done to it,
592 thus making them effectively non-existent.")
594 (defvar gnus-ignored-headers
595 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
596 "*All headers that match this regexp will be hidden.
597 Also see `gnus-visible-headers'.")
599 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
600 "*All headers that do not match this regexp will be hidden.
601 Also see `gnus-ignored-headers'.")
603 (defvar gnus-sorted-header-list
604 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
605 "^Cc:" "^Date:" "^Organization:")
606 "*This variable is a list of regular expressions.
607 If it is non-nil, headers that match the regular expressions will
608 be placed first in the article buffer in the sequence specified by
611 (defvar gnus-show-all-headers nil
612 "*If non-nil, don't hide any headers.")
614 (defvar gnus-save-all-headers t
615 "*If non-nil, don't remove any headers before saving.")
617 (defvar gnus-inhibit-startup-message nil
618 "*If non-nil, the startup message will not be displayed.")
620 (defvar gnus-signature-separator "^-- *$"
621 "Regexp matching signature separator.")
623 (defvar gnus-auto-extend-newsgroup t
624 "*If non-nil, extend newsgroup forward and backward when requested.")
626 (defvar gnus-auto-select-first t
627 "*If non-nil, select the first unread article when entering a group.
628 If you want to prevent automatic selection of the first unread article
629 in some newsgroups, set the variable to nil in
630 `gnus-select-group-hook'.")
632 (defvar gnus-auto-select-next t
633 "*If non-nil, offer to go to the next group from the end of the previous.
634 If the value is t and the next newsgroup is empty, Gnus will exit
635 summary mode and go back to group mode. If the value is neither nil
636 nor t, Gnus will select the following unread newsgroup. In
637 particular, if the value is the symbol `quietly', the next unread
638 newsgroup will be selected without any confirmations.")
640 (defvar gnus-auto-select-same nil
641 "*If non-nil, select the next article with the same subject.")
643 (defvar gnus-summary-check-current nil
644 "*If non-nil, consider the current article when moving.
645 The \"unread\" movement commands will stay on the same line if the
646 current article is unread.")
648 (defvar gnus-auto-center-summary t
649 "*If non-nil, always center the current summary buffer.")
651 (defvar gnus-break-pages t
652 "*If non-nil, do page breaking on articles.
653 The page delimiter is specified by the `gnus-page-delimiter'
656 (defvar gnus-page-delimiter "^\^L"
657 "*Regexp describing what to use as article page delimiters.
658 The default value is \"^\^L\", which is a form linefeed at the
659 beginning of a line.")
661 (defvar gnus-use-full-window t
662 "*If non-nil, use the entire Emacs screen.")
664 (defvar gnus-window-configuration nil
665 "Obsolete variable. See `gnus-buffer-configuration'.")
667 (defvar gnus-buffer-configuration
668 '((group ([group 1.0 point]
669 (if gnus-carpal [group-carpal 4])))
670 (summary ([summary 1.0 point]
671 (if gnus-carpal [summary-carpal 4])))
672 (article ([summary 0.25 point]
673 (if gnus-carpal [summary-carpal 4])
675 (server ([server 1.0 point]
676 (if gnus-carpal [server-carpal 2])))
677 (browse ([browse 1.0 point]
678 (if gnus-carpal [browse-carpal 2])))
679 (group-mail ([mail 1.0 point]))
680 (summary-mail ([mail 1.0 point]))
681 (summary-reply ([article 0.5]
683 (info ([nil 1.0 point]))
684 (summary-faq ([summary 0.25]
686 (edit-group ([group 0.5]
687 [edit-group 1.0 point]))
688 (edit-server ([server 0.5]
689 [edit-server 1.0 point]))
690 (edit-score ([summary 0.25]
691 [edit-score 1.0 point]))
692 (post ([post 1.0 point]))
693 (reply ([article 0.5]
695 (mail-forward ([mail 1.0 point]))
696 (post-forward ([post 1.0 point]))
697 (reply-yank ([mail 1.0 point]))
698 (followup ([article 0.5]
700 (followup-yank ([post 1.0 point])))
701 "Window configuration for all possible Gnus buffers.
702 This variable is a list of lists. Each of these lists has a NAME and
703 a RULE. The NAMEs are commonsense names like `group', which names a
704 rule used when displaying the group buffer; `summary', which names a
705 rule for what happens when you enter a group and do not display an
706 article buffer; and so on. See the value of this variable for a
707 complete list of NAMEs.
709 Each RULE is a list of vectors. The first element in this vector is
710 the name of the buffer to be displayed; the second element is the
711 percentage of the screen this buffer is to occupy (a number in the
712 0.0-0.99 range); the optional third element is `point', which should
713 be present to denote which buffer point is to go to after making this
714 buffer configuration.")
716 (defvar gnus-window-to-buffer
717 '((group . gnus-group-buffer)
718 (summary . gnus-summary-buffer)
719 (article . gnus-article-buffer)
720 (server . gnus-server-buffer)
721 (browse . "*Gnus Browse Server*")
722 (edit-group . gnus-group-edit-buffer)
723 (edit-server . gnus-server-edit-buffer)
724 (group-carpal . gnus-carpal-group-buffer)
725 (summary-carpal . gnus-carpal-summary-buffer)
726 (server-carpal . gnus-carpal-server-buffer)
727 (browse-carpal . gnus-carpal-browse-buffer)
728 (edit-score . gnus-score-edit-buffer)
729 (mail . gnus-mail-buffer)
730 (post . gnus-post-news-buffer)
731 (faq . gnus-faq-buffer))
732 "Mapping from short symbols to buffer names or buffer variables.")
734 (defvar gnus-carpal nil
735 "*If non-nil, display clickable icons.")
737 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
738 "*Function called with a group name when new group is detected.
739 A few pre-made functions are supplied: `gnus-subscribe-randomly'
740 inserts new groups at the beginning of the list of groups;
741 `gnus-subscribe-alphabetically' inserts new groups in strict
742 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
743 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
746 ;; Suggested by a bug report by Hallvard B Furuseth.
747 ;; <h.b.furuseth@usit.uio.no>.
748 (defvar gnus-subscribe-options-newsgroup-method
749 (function gnus-subscribe-alphabetically)
750 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
751 If, for instance, you want to subscribe to all newsgroups in the
752 \"no\" and \"alt\" hierarchies, you'd put the following in your
755 options -n no.all alt.all
757 Gnus will the subscribe all new newsgroups in these hierarchies with
758 the subscription method in this variable.")
760 (defvar gnus-subscribe-hierarchical-interactive nil
761 "*If non-nil, Gnus will offer to subscribe hierarchically.
762 When a new hierarchy appears, Gnus will ask the user:
764 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
766 If the user pressed `d', Gnus will descend the hierarchy, `y' will
767 subscribe to all newsgroups in the hierarchy and `s' will skip this
768 hierarchy in its entirety.")
770 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
771 "*Function used for sorting the group buffer.
772 This function will be called with group info entries as the arguments
773 for the groups to be sorted. Pre-made functions include
774 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
775 `gnus-sort-by-level'")
777 ;; Mark variables suggested by Thomas Michanek
778 ;; <Thomas.Michanek@telelogic.se>.
779 (defvar gnus-unread-mark ?
780 "*Mark used for unread articles.")
781 (defvar gnus-ticked-mark ?!
782 "*Mark used for ticked articles.")
783 (defvar gnus-dormant-mark ??
784 "*Mark used for dormant articles.")
785 (defvar gnus-del-mark ?D
786 "*Mark used for del'd articles.")
787 (defvar gnus-read-mark ?d
788 "*Mark used for read articles.")
789 (defvar gnus-expirable-mark ?E
790 "*Mark used for expirable articles.")
791 (defvar gnus-killed-mark ?K
792 "*Mark used for killed articles.")
793 (defvar gnus-kill-file-mark ?X
794 "*Mark used for articles killed by kill files.")
795 (defvar gnus-low-score-mark ?Y
796 "*Mark used for articles with a low score.")
797 (defvar gnus-catchup-mark ?C
798 "*Mark used for articles that are caught up.")
799 (defvar gnus-replied-mark ?R
800 "*Mark used for articles that have been replied to.")
801 (defvar gnus-process-mark ?#
803 (defvar gnus-ancient-mark ?A
804 "*Mark used for ancient articles.")
805 (defvar gnus-canceled-mark ?G
806 "*Mark used for canceled articles.")
807 (defvar gnus-score-over-mark ?+
808 "*Score mark used for articles with high scores.")
809 (defvar gnus-score-below-mark ?-
810 "*Score mark used for articles with low scores.")
811 (defvar gnus-empty-thread-mark ?
812 "*There is no thread under the article.")
813 (defvar gnus-not-empty-thread-mark ?=
814 "*There is a thread under the article.")
815 (defvar gnus-dummy-mark ?Z
816 "*This is a dummy article.")
818 (defvar gnus-view-pseudo-asynchronously nil
819 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
821 (defvar gnus-view-pseudos nil
822 "*If `automatic', pseudo-articles will be viewed automatically.
823 If `not-confirm', pseudos will be viewed automatically, and the user
824 will not be asked to confirm the command.")
826 (defvar gnus-view-pseudos-separately t
827 "*If non-nil, one pseudo-article will be created for each file to be viewed.
828 If nil, all files that use the same viewing command will be given as a
829 list of parameters to that command.")
831 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
832 "*Format of group lines.
833 It works along the same lines as a normal formatting string,
834 with some simple extensions.
836 %M Only marked articles (character, \"*\" or \" \")
837 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
838 %L Level of subscribedness (integer)
839 %N Number of unread articles (integer)
840 %I Number of dormant articles (integer)
841 %i Number of ticked and dormant (integer)
842 %T Number of ticked articles (integer)
843 %R Number of read articles (integer)
844 %t Total number of articles (integer)
845 %y Number of unread, unticked articles (integer)
846 %G Group name (string)
847 %g Qualified group name (string)
848 %D Group description (string)
849 %s Select method (string)
850 %o Moderated group (char, \"m\")
851 %p Process mark (char)
852 %O Moderated group (string, \"(m)\" or \"\")
853 %n Select from where (string)
854 %z A string that look like `<%s:%n>' if a foreign select method is used
855 %u User defined specifier. The next character in the format string should
856 be a letter. Gnus will call the function gnus-user-format-function-X,
857 where X is the letter following %u. The function will be passed the
858 current header as argument. The function should return a string, which
859 will be inserted into the buffer just like information from any other
862 Text between %( and %) will be highlighted with `gnus-mouse-face' when
863 the mouse point move inside the area. There can only be one such area.
865 Note that this format specification is not always respected. For
866 reasons of efficiency, when listing killed groups, this specification
867 is ignored altogether. If the spec is changed considerably, your
868 output may end up looking strange when listing both alive and killed
871 If you use %o or %O, reading the active file will be slower and quite
872 a bit of extra memory will be used. %D will also worsen performance.
873 Also note that if you change the format specification to include any
874 of these specs, you must probably re-start Gnus to see them go into
877 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
878 "*The format specification of the lines in the summary buffer.
880 It works along the same lines as a normal formatting string,
881 with some simple extensions.
883 %N Article number, left padded with spaces (string)
885 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
886 %n Name of the poster (string)
887 %A Address of the poster (string)
888 %F Contents of the From: header (string)
889 %x Contents of the Xref: header (string)
890 %D Date of the article (string)
891 %d Date of the article (string) in DD-MMM format
892 %M Message-id of the article (string)
893 %r References of the article (string)
894 %c Number of characters in the article (integer)
895 %L Number of lines in the article (integer)
896 %I Indentation based on thread level (a string of spaces)
897 %T A string with two possible values: 80 spaces if the article
898 is on thread level two or larger and 0 spaces on level one
899 %R \"R\" if this article has been replied to, \" \" otherwise (character)
900 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
901 %[ Opening bracket (character, \"[\" or \"<\")
902 %] Closing bracket (character, \"]\" or \">\")
903 %> Spaces of length thread-level (string)
904 %< Spaces of length (- 20 thread-level) (string)
905 %i Article score (number)
906 %z Article zcore (character)
907 %t Number of articles under the current thread (number).
908 %e Whether the thread is empty or not (character).
909 %u User defined specifier. The next character in the format string should
910 be a letter. Gnus will call the function gnus-user-format-function-X,
911 where X is the letter following %u. The function will be passed the
912 current header as argument. The function should return a string, which
913 will be inserted into the summary just like information from any other
916 Text between %( and %) will be highlighted with `gnus-mouse-face'
917 when the mouse point is placed inside the area. There can only be one
920 The %U (status), %R (replied) and %z (zcore) specs have to be handled
921 with care. For reasons of efficiency, Gnus will compute what column
922 these characters will end up in, and \"hard-code\" that. This means that
923 it is illegal to have these specs after a variable-length spec. Well,
924 you might not be arrested, but your summary buffer will look strange,
927 The smart choice is to have these specs as for to the left as
930 This restriction may disappear in later versions of Gnus.")
932 (defvar gnus-summary-dummy-line-format "* : : %S\n"
933 "*The format specification for the dummy roots in the summary buffer.
934 It works along the same lines as a normal formatting string,
935 with some simple extensions.
939 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
940 "*The format specification for the summary mode line.")
942 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
943 "*The format specification for the article mode line.")
945 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
946 "*The format specification for the group mode line.")
948 (defvar gnus-valid-select-methods
949 '(("nntp" post address prompt-address)
951 ("nnvirtual" none virtual prompt-address)
952 ("nnmbox" mail respool)
953 ("nnml" mail respool)
954 ("nnmh" mail respool)
955 ("nndir" none prompt-address address)
956 ("nneething" none prompt-address)
958 ("nndoc" none prompt-address)
959 ("nnbabyl" mail respool)
960 ("nnkiboze" post virtual)
962 ("nnfolder" mail respool))
963 "An alist of valid select methods.
964 The first element of each list lists should be a string with the name
965 of the select method. The other elements may be be the category of
966 this method (ie. `post', `mail', `none' or whatever) or other
967 properties that this method has (like being respoolable).
968 If you implement a new select method, all you should have to change is
969 this variable. I think.")
971 (defvar gnus-updated-mode-lines '(group article summary)
972 "*List of buffers that should update their mode lines.
973 The list may contain the symbols `group', `article' and `summary'. If
974 the corresponding symbol is present, Gnus will keep that mode line
975 updated with information that may be pertinent.
976 If this variable is nil, screen refresh may be quicker.")
978 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
979 (defvar gnus-mode-non-string-length 21
980 "*Max length of mode-line non-string contents.
981 If this is nil, Gnus will take space as is needed, leaving the rest
982 of the modeline intact.")
984 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
985 (defvar gnus-display-type
987 (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
988 (cond (display-resource (intern (downcase display-resource)))
989 ((x-display-color-p) 'color)
990 ((x-display-grayscale-p) 'grayscale)
993 "A symbol indicating the display Emacs is running under.
994 The symbol should be one of `color', `grayscale' or `mono'. If Emacs
995 guesses this display attribute wrongly, either set this variable in
996 your `~/.emacs' or set the resource `Emacs.displayType' in your
997 `~/.Xdefaults'. See also `gnus-background-mode'.")
999 (defvar gnus-background-mode
1001 (let ((bg-resource (x-get-resource ".backgroundMode"
1003 (params (frame-parameters)))
1004 (cond (bg-resource (intern (downcase bg-resource)))
1005 ((< (apply '+ (x-color-values
1006 (cdr (assq 'background-color params))))
1007 (/ (apply '+ (x-color-values "white")) 3))
1011 "A symbol indicating the Emacs background brightness.
1012 The symbol should be one of `light' or `dark'.
1013 If Emacs guesses this frame attribute wrongly, either set this variable in
1014 your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
1016 See also `gnus-display-type'.")
1018 (defvar gnus-mouse-face 'highlight
1019 "*Face used for mouse highlighting in Gnus.
1020 No mouse highlights will be done if `gnus-visual' is nil.")
1022 (defvar gnus-summary-mark-below nil
1023 "*Mark all articles with a score below this variable as read.
1024 This variable is local to each summary buffer and usually set by the
1027 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1028 "*List of functions used for sorting threads in the summary buffer.
1029 By default, threads are sorted by article number.
1031 Each function takes two threads and return non-nil if the first thread
1032 should be sorted before the other. If you use more than one function,
1033 the primary sort function should be the last.
1035 Ready-mady functions include `gnus-thread-sort-by-number',
1036 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1037 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1038 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1040 (defvar gnus-thread-score-function '+
1041 "*Function used for calculating the total score of a thread.
1043 The function is called with the scores of the article and each
1044 subthread and should then return the score of the thread.
1046 Some functions you can use are `+', `max', or `min'.")
1048 (defvar gnus-options-subscribe nil
1049 "*All new groups matching this regexp will be subscribed unconditionally.
1050 Note that this variable deals only with new newsgroups. This variable
1051 does not affect old newsgroups.")
1053 (defvar gnus-options-not-subscribe nil
1054 "*All new groups matching this regexp will be ignored.
1055 Note that this variable deals only with new newsgroups. This variable
1056 does not affect old (already subscribed) newsgroups.")
1058 (defvar gnus-auto-expirable-newsgroups nil
1059 "*Groups in which to automatically mark read articles as expirable.
1060 If non-nil, this should be a regexp that should match all groups in
1061 which to perform auto-expiry. This only makes sense for mail groups.")
1063 (defvar gnus-hidden-properties '(invisible t intangible t)
1064 "Property list to use for hiding text.")
1068 (defvar gnus-group-mode-hook nil
1069 "*A hook for Gnus group mode.")
1071 (defvar gnus-summary-mode-hook nil
1072 "*A hook for Gnus summary mode.
1073 This hook is run before any variables are set in the summary buffer.")
1075 (defvar gnus-article-mode-hook nil
1076 "*A hook for Gnus article mode.")
1078 (defun gnus-summary-exit-hook nil
1079 "*A hook called on exit from the summary buffer.
1080 It calls `gnus-summary-expire-articles' by default.")
1081 (add-hook 'gnus-summary-exit-hook 'gnus-summary-expire-articles)
1083 (defvar gnus-open-server-hook nil
1084 "*A hook called just before opening connection to the news server.")
1086 (defvar gnus-startup-hook nil
1087 "*A hook called at startup.
1088 This hook is called after Gnus is connected to the NNTP server.")
1090 (defvar gnus-get-new-news-hook nil
1091 "*A hook run just before Gnus checks for new news.")
1093 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1094 "*A function that is called to generate the group buffer.
1095 The function is called with three arguments: The first is a number;
1096 all group with a level less or equal to that number should be listed,
1097 if the second is non-nil, empty groups should also be displayed. If
1098 the third is non-nil, it is a number. No groups with a level lower
1099 than this number should be displayed.
1101 The only current function implemented is `gnus-group-prepare-flat'.")
1103 (defvar gnus-group-prepare-hook nil
1104 "*A hook called after the group buffer has been generated.
1105 If you want to modify the group buffer, you can use this hook.")
1107 (defvar gnus-summary-prepare-hook nil
1108 "*A hook called after the summary buffer has been generated.
1109 If you want to modify the summary buffer, you can use this hook.")
1111 (defvar gnus-article-prepare-hook nil
1112 "*A hook called after an article has been prepared in the article buffer.
1113 If you want to run a special decoding program like nkf, use this hook.")
1115 (defvar gnus-article-display-hook nil
1116 "*A hook called after the article is displayed in the article buffer.
1117 The hook is designed to change the contents of the article
1118 buffer. Typical functions that this hook may contain are
1119 `gnus-article-hide-headers' (hide selected headers),
1120 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1121 `gnus-article-hide-signature' (hide signature) and
1122 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1123 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1124 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1126 (defvar gnus-article-x-face-command
1127 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1128 "String or function to be executed to display an X-Face header.
1129 If it is a string, the command will be executed in a sub-shell
1130 asynchronously. The compressed face will be piped to this command.")
1132 (defvar gnus-article-x-face-too-ugly nil
1133 "Regexp matching posters whose face shouldn't be shown automatically.")
1135 (defvar gnus-select-group-hook nil
1136 "*A hook called when a newsgroup is selected.
1138 If you'd like to simplify subjects like the
1139 `gnus-summary-next-same-subject' command does, you can use the
1142 (setq gnus-select-group-hook
1145 (mapcar (lambda (header)
1148 (gnus-simplify-subject
1149 (header-subject header) 're-only)))
1150 gnus-newsgroup-headers))))")
1152 (defvar gnus-select-article-hook
1153 '(gnus-summary-show-thread)
1154 "*A hook called when an article is selected.
1155 The default hook shows conversation thread subtrees of the selected
1156 article automatically using `gnus-summary-show-thread'.")
1158 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1159 "*A hook called to apply kill files to a group.
1160 This hook is intended to apply a kill file to the selected newsgroup.
1161 The function `gnus-apply-kill-file' is called by default.
1163 Since a general kill file is too heavy to use only for a few
1164 newsgroups, I recommend you to use a lighter hook function. For
1165 example, if you'd like to apply a kill file to articles which contains
1166 a string `rmgroup' in subject in newsgroup `control', you can use the
1169 \(setq gnus-apply-kill-hook
1172 (cond ((string-match \"control\" gnus-newsgroup-name)
1173 (gnus-kill \"Subject\" \"rmgroup\")
1174 (gnus-expunge \"X\"))))))")
1176 (defvar gnus-visual-mark-article-hook
1177 (list 'gnus-highlight-selected-summary)
1178 "*Hook run after selecting an article in the summary buffer.
1179 It is meant to be used for highlighting the article in some way. It
1180 is not run if `gnus-visual' is nil.")
1182 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1183 "*A hook called after preparing body, but before preparing header headers.
1184 The default hook (`gnus-inews-insert-signature') inserts a signature
1185 file specified by the variable `gnus-signature-file'.")
1187 (defvar gnus-exit-group-hook nil
1188 "*A hook called when exiting (not quitting) summary mode.")
1190 (defvar gnus-suspend-gnus-hook nil
1191 "*A hook called when suspending (not exiting) Gnus.")
1193 (defvar gnus-exit-gnus-hook nil
1194 "*A hook called when exiting Gnus.")
1196 (defvar gnus-save-newsrc-hook nil
1197 "*A hook called when saving the newsrc file.")
1199 (defvar gnus-summary-update-hook
1200 (list 'gnus-summary-highlight-line)
1201 "*A hook called when a summary line is changed.
1202 The hook will not be called if `gnus-visual' is nil.
1204 The default function `gnus-summary-highlight-line' will
1205 highlight the line according to the `gnus-summary-highlight'
1208 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1209 "*A hook called when an article is selected for the first time.
1210 The hook is intended to mark an article as read (or unread)
1211 automatically when it is selected.")
1213 ;; Remove any hilit infestation.
1214 (add-hook 'gnus-startup-hook
1216 (remove-hook 'gnus-summary-prepare-hook
1217 'hilit-rehighlight-buffer-quietly)
1218 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1219 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1220 (remove-hook 'gnus-article-prepare-hook
1221 'hilit-rehighlight-buffer-quietly)))
1225 ;; Internal variables
1227 ;; Avoid highlighting in kill files.
1228 (defvar gnus-summary-inhibit-highlight nil)
1229 (defvar gnus-newsgroup-selected-overlay nil)
1231 (defvar gnus-article-mode-map nil)
1232 (defvar caesar-translate-table nil)
1233 (defvar gnus-dribble-buffer nil)
1234 (defvar gnus-headers-retrieved-by nil)
1235 (defvar gnus-article-reply nil)
1236 (defvar gnus-override-method nil)
1237 (defvar gnus-article-check-size nil)
1239 (defvar gnus-current-score-file nil)
1240 (defvar gnus-internal-global-score-files nil)
1241 (defvar gnus-score-file-list nil)
1244 (defvar gnus-current-move-group nil)
1246 (defvar gnus-newsgroup-dependencies nil)
1247 (defvar gnus-newsgroup-threads nil)
1248 (defvar gnus-newsgroup-async nil)
1249 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1251 (defvar gnus-newsgroup-adaptive nil)
1253 (defvar gnus-summary-display-table nil)
1255 (defconst gnus-group-line-format-alist
1256 (list (list ?M 'marked ?c)
1257 (list ?S 'subscribed ?c)
1259 (list ?N 'number ?s)
1260 (list ?I 'number-of-dormant ?d)
1261 (list ?T 'number-of-ticked ?d)
1262 (list ?R 'number-of-read ?s)
1263 (list ?t 'number-total ?d)
1264 (list ?y 'number-of-unread-unticked ?s)
1265 (list ?i 'number-of-ticked-and-dormant ?d)
1267 (list ?G 'qualified-group ?s)
1268 (list ?D 'newsgroup-description ?s)
1269 (list ?o 'moderated ?c)
1270 (list ?O 'moderated-string ?s)
1271 (list ?p 'process-marked ?c)
1272 (list ?s 'news-server ?s)
1273 (list ?n 'news-method ?s)
1274 (list ?z 'news-method-string ?s)
1275 (list ?u 'user-defined ?s)))
1277 (defconst gnus-summary-line-format-alist
1278 (list (list ?N 'number ?d)
1279 (list ?S 'subject ?s)
1280 (list ?s 'subject-or-nil ?s)
1282 (list ?A 'address ?s)
1284 (list ?x (macroexpand '(header-xref header)) ?s)
1285 (list ?D (macroexpand '(header-date header)) ?s)
1286 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1287 (list ?M (macroexpand '(header-id header)) ?s)
1288 (list ?r (macroexpand '(header-references header)) ?s)
1289 (list ?c '(or (header-chars header) 0) ?d)
1291 (list ?I 'indentation ?s)
1292 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1293 (list ?R 'replied ?c)
1294 (list ?\[ 'opening-bracket ?c)
1295 (list ?\] 'closing-bracket ?c)
1296 (list ?\> '(make-string level ? ) ?s)
1297 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1299 (list ?z 'score-char ?c)
1300 (list ?U 'unread ?c)
1301 (list ?t '(gnus-summary-number-of-articles-in-thread
1302 (or (prog1 gnus-tmp-adopt-thread
1303 (setq gnus-tmp-adopt-thread nil))
1304 (if (boundp 'thread) (symbol-value 'thread)
1307 (list ?e '(gnus-summary-number-of-articles-in-thread
1308 (or gnus-tmp-adopt-thread
1309 (if (boundp 'thread) (symbol-value 'thread)
1312 (list ?u 'user-defined ?s))
1313 "An alist of format specifications that can appear in summary lines,
1314 and what variables they correspond with, along with the type of the
1315 variable (string, integer, character, etc).")
1317 (defconst gnus-summary-dummy-line-format-alist
1318 (list (list ?S 'subject ?s)
1319 (list ?N 'number ?d)
1320 (list ?u 'user-defined ?s)))
1322 (defconst gnus-summary-mode-line-format-alist
1323 (list (list ?G 'group-name ?s)
1324 (list ?g '(gnus-short-group-name group-name) ?s)
1325 (list ?A 'article-number ?d)
1326 (list ?Z 'unread-and-unselected ?s)
1327 (list ?V 'gnus-version ?s)
1328 (list ?U 'unread ?d)
1329 (list ?S 'subject ?s)
1330 (list ?e 'unselected ?d)
1331 (list ?u 'user-defined ?s)
1332 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1334 (defconst gnus-group-mode-line-format-alist
1335 (list (list ?S 'news-server ?s)
1336 (list ?M 'news-method ?s)
1337 (list ?u 'user-defined ?s)))
1339 (defvar gnus-have-read-active-file nil)
1341 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1342 "The mail address of the Gnus maintainers.")
1344 (defconst gnus-version "(ding) Gnus v0.93"
1345 "Version number for this version of Gnus.")
1347 (defvar gnus-info-nodes
1348 '((gnus-group-mode "(gnus)The Group Buffer")
1349 (gnus-summary-mode "(gnus)The Summary Buffer")
1350 (gnus-article-mode "(gnus)The Article Buffer"))
1351 "Assoc list of major modes and related Info nodes.")
1353 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1354 "The location of the (ding) Gnus documentation group.")
1356 (defvar gnus-group-buffer "*Group*")
1357 (defvar gnus-summary-buffer "*Summary*")
1358 (defvar gnus-article-buffer "*Article*")
1359 (defvar gnus-server-buffer "*Server*")
1361 (defvar gnus-work-buffer " *gnus work*")
1363 (defvar gnus-buffer-list nil
1364 "Gnus buffers that should be killed on exit.")
1366 (defvar gnus-server-alist nil
1367 "List of available servers.")
1369 (defvar gnus-variable-list
1370 '(gnus-newsrc-options gnus-newsrc-options-n
1371 gnus-newsrc-last-checked-date
1372 gnus-newsrc-alist gnus-server-alist
1373 gnus-killed-list gnus-zombie-list)
1374 "Gnus variables saved in the quick startup file.")
1376 (defvar gnus-overload-functions
1377 '((news-inews gnus-inews-news "rnewspost")
1378 (caesar-region gnus-caesar-region "rnews"))
1379 "Functions overloaded by gnus.
1380 It is a list of `(original overload &optional file)'.")
1382 (defvar gnus-newsrc-options nil
1383 "Options line in the .newsrc file.")
1385 (defvar gnus-newsrc-options-n nil
1386 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1388 (defvar gnus-newsrc-last-checked-date nil
1389 "Date Gnus last asked server for new newsgroups.")
1391 (defvar gnus-newsrc-alist nil
1392 "Assoc list of read articles.
1393 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1395 (defvar gnus-newsrc-hashtb nil
1396 "Hashtable of gnus-newsrc-alist.")
1398 (defvar gnus-killed-list nil
1399 "List of killed newsgroups.")
1401 (defvar gnus-killed-hashtb nil
1402 "Hash table equivalent of gnus-killed-list.")
1404 (defvar gnus-zombie-list nil
1405 "List of almost dead newsgroups.")
1407 (defvar gnus-description-hashtb nil
1408 "Descriptions of newsgroups.")
1410 (defvar gnus-list-of-killed-groups nil
1411 "List of newsgroups that have recently been killed by the user.")
1413 (defvar gnus-active-hashtb nil
1414 "Hashtable of active articles.")
1416 (defvar gnus-moderated-list nil
1417 "List of moderated newsgroups.")
1419 (defvar gnus-group-marked nil)
1421 (defvar gnus-current-startup-file nil
1422 "Startup file for the current host.")
1424 (defvar gnus-last-search-regexp nil
1425 "Default regexp for article search command.")
1427 (defvar gnus-last-shell-command nil
1428 "Default shell command on article.")
1430 (defvar gnus-current-select-method nil
1431 "The current method for selecting a newsgroup.")
1433 (defvar gnus-have-all-newsgroups nil)
1435 (defvar gnus-article-internal-prepare-hook nil)
1437 (defvar gnus-newsgroup-name nil)
1438 (defvar gnus-newsgroup-begin nil)
1439 (defvar gnus-newsgroup-end nil)
1440 (defvar gnus-newsgroup-last-rmail nil)
1441 (defvar gnus-newsgroup-last-mail nil)
1442 (defvar gnus-newsgroup-last-folder nil)
1443 (defvar gnus-newsgroup-last-file nil)
1444 (defvar gnus-newsgroup-auto-expire nil)
1445 (defvar gnus-newsgroup-active nil)
1447 (defvar gnus-newsgroup-unreads nil
1448 "List of unread articles in the current newsgroup.")
1450 (defvar gnus-newsgroup-unselected nil
1451 "List of unselected unread articles in the current newsgroup.")
1453 (defvar gnus-newsgroup-marked nil
1454 "List of ticked articles in the current newsgroup (a subset of unread art).")
1456 (defvar gnus-newsgroup-killed nil
1457 "List of ranges of articles that have been through the scoring process.")
1459 (defvar gnus-newsgroup-kill-headers nil)
1461 (defvar gnus-newsgroup-replied nil
1462 "List of articles that have been replied to in the current newsgroup.")
1464 (defvar gnus-newsgroup-expirable nil
1465 "List of articles in the current newsgroup that can be expired.")
1467 (defvar gnus-newsgroup-processable nil
1468 "List of articles in the current newsgroup that can be processed.")
1470 (defvar gnus-newsgroup-bookmarks nil
1471 "List of articles in the current newsgroup that have bookmarks.")
1473 (defvar gnus-newsgroup-dormant nil
1474 "List of dormant articles in the current newsgroup.")
1476 (defvar gnus-newsgroup-scored nil
1477 "List of scored articles in the current newsgroup.")
1479 (defvar gnus-newsgroup-headers nil
1480 "List of article headers in the current newsgroup.")
1481 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1483 (defvar gnus-newsgroup-ancient nil
1484 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1486 (defvar gnus-current-article nil)
1487 (defvar gnus-article-current nil)
1488 (defvar gnus-current-headers nil)
1489 (defvar gnus-have-all-headers nil)
1490 (defvar gnus-last-article nil)
1491 (defvar gnus-newsgroup-history nil)
1492 (defvar gnus-current-kill-article nil)
1494 ;; Save window configuration.
1495 (defvar gnus-prev-winconf nil)
1498 (defvar gnus-summary-line-format-spec nil)
1499 (defvar gnus-summary-dummy-line-format-spec nil)
1500 (defvar gnus-group-line-format-spec nil)
1501 (defvar gnus-summary-mode-line-format-spec nil)
1502 (defvar gnus-article-mode-line-format-spec nil)
1503 (defvar gnus-group-mode-line-format-spec nil)
1504 (defvar gnus-summary-mark-positions nil)
1506 (defvar gnus-summary-expunge-below nil)
1507 (defvar gnus-reffed-article-number nil)
1509 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1510 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1512 (defconst gnus-summary-local-variables
1513 '(gnus-newsgroup-name
1514 gnus-newsgroup-begin gnus-newsgroup-end
1515 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1516 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1517 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1518 gnus-newsgroup-unselected gnus-newsgroup-marked
1519 gnus-newsgroup-replied gnus-newsgroup-expirable
1520 gnus-newsgroup-processable gnus-newsgroup-killed
1521 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1522 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1523 gnus-current-article gnus-current-headers gnus-have-all-headers
1524 gnus-last-article gnus-article-internal-prepare-hook
1525 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1526 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1527 gnus-newsgroup-threads gnus-newsgroup-async
1528 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1529 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1530 gnus-newsgroup-history gnus-newsgroup-ancient
1531 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring))
1532 "Variables that are buffer-local to the summary buffers.")
1534 (defconst gnus-bug-message
1535 "Sending a bug report to the Gnus Towers.
1536 ========================================
1538 The buffer below is a mail buffer. When you press `C-c C-c', it will
1539 be sent to the Gnus Bug Exterminators.
1541 At the bottom of the buffer you'll see lots of variable settings.
1542 Please do not delete those. They will tell the Bug People what your
1543 environment is, so that it will be easier to locate the bugs.
1545 If you have found a bug that makes Emacs go \"beep\", set
1546 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1547 and include the backtrace in your bug report.
1549 Please describe the bug in annoying, painstaking detail.
1551 Thank you for your help in stamping out bugs.
1554 ;;; End of variables.
1556 ;; Define some autoload functions Gnus might use.
1560 (autoload 'metamail-buffer "metamail")
1561 (autoload 'Info-goto-node "info")
1562 (autoload 'hexl-hex-string-to-integer "hexl")
1564 (autoload 'pp-to-string "pp")
1565 (autoload 'pp-eval-expression "pp")
1566 (autoload 'mail-extract-address-components "mail-extr")
1568 (autoload 'nnmail-split-fancy "nnmail")
1569 (autoload 'nnvirtual-catchup-group "nnvirtual")
1572 (autoload 'timezone-make-date-arpa-standard "timezone")
1573 (autoload 'timezone-fix-time "timezone")
1574 (autoload 'timezone-make-sortable-date "timezone")
1575 (autoload 'timezone-make-time-string "timezone")
1578 (autoload 'mail-position-on-field "sendmail")
1579 (autoload 'mail-setup "sendmail")
1580 (autoload 'rmail-output "rmailout")
1581 (autoload 'news-mail-other-window "rnewspost")
1582 (autoload 'news-reply-yank-original "rnewspost")
1583 (autoload 'news-caesar-buffer-body "rnewspost")
1584 (autoload 'rmail-insert-rmail-file-header "rmail")
1585 (autoload 'rmail-count-new-messages "rmail")
1586 (autoload 'rmail-show-message "rmail")
1589 (autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1590 (autoload 'gnus-brew-soup "gnus-soup" nil t)
1591 (autoload 'gnus-soup-add-article "gnus-soup" nil t)
1592 (autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1593 (autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1594 (autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1595 (autoload 'nnsoup-pack-replies "nnsoup" nil t)
1598 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1599 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1600 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1601 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1602 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1603 (autoload 'gnus-Folder-save-name "gnus-mh")
1604 (autoload 'gnus-folder-save-name "gnus-mh")
1607 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1608 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1609 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1610 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1611 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1612 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1613 (autoload 'gnus-summary-highlight-line "gnus-vis")
1614 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1617 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1618 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1619 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1620 (autoload 'gnus-article-hide "gnus-vis" nil t)
1621 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1622 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1623 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1624 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1625 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1626 (autoload 'gnus-article-add-button "gnus-vis")
1629 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1630 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1631 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1634 (autoload 'gnus-kill "gnus-kill")
1635 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1636 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1637 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1638 (autoload 'gnus-execute "gnus-kill")
1639 (autoload 'gnus-expunge "gnus-kill")
1642 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1643 (autoload 'gnus-cache-save-buffers "gnus-cache")
1644 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1645 (autoload 'gnus-cache-request-article "gnus-cache")
1646 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1647 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1648 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1649 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1652 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1653 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1654 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1655 (autoload 'gnus-score-save "gnus-score")
1656 (autoload 'gnus-score-headers "gnus-score")
1657 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1658 (autoload 'gnus-score-adaptive "gnus-score")
1659 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1660 (autoload 'gnus-score-find-trace "gnus-score")
1663 (autoload 'gnus-score-customize "gnus-edit" nil t)
1666 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1667 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1668 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1669 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1670 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1671 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1672 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1673 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1674 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1675 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1676 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1677 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1678 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1679 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1680 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1681 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1682 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1683 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1684 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1685 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1686 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1687 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1690 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1691 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1692 (autoload 'gnus-group-mail "gnus-msg" nil t)
1693 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1694 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1695 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1696 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1697 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1698 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1699 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1700 (autoload 'gnus-post-news "gnus-msg" nil t)
1701 (autoload 'gnus-inews-news "gnus-msg" nil t)
1702 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1703 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1704 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1705 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1706 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1707 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1708 (autoload 'gnus-mail-yank-original "gnus-msg")
1709 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1710 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1711 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1712 (autoload 'gnus-article-mail-with-original "gnus-msg")
1713 (autoload 'gnus-article-mail "gnus-msg")
1714 (autoload 'gnus-bug "gnus-msg" nil t)
1717 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1718 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1719 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1720 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1721 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1722 (autoload 'gnus-yank-article "gnus-vm" nil t)
1728 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1729 ;; If you want the cursor to go somewhere else, set these two
1730 ;; functions in some startup hook to whatever you want.
1731 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1732 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1734 ;;; Various macros and substs.
1736 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1737 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1738 (` (let ((GnusStartBufferWindow (selected-window)))
1741 (pop-to-buffer (, buffer))
1743 (select-window GnusStartBufferWindow)))))
1745 (defmacro gnus-gethash (string hashtable)
1746 "Get hash value of STRING in HASHTABLE."
1747 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1748 ;;(` (abbrev-expansion (, string) (, hashtable)))
1749 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1751 (defmacro gnus-sethash (string value hashtable)
1752 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1753 ;; We cannot use define-abbrev since it only accepts string as value.
1754 ;; (set (intern string hashtable) value))
1755 (` (set (intern (, string) (, hashtable)) (, value))))
1757 (defsubst gnus-buffer-substring (beg end)
1758 (buffer-substring (match-beginning beg) (match-end end)))
1760 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1761 ;; function `substring' might cut on a middle of multi-octet
1764 (defun gnus-truncate-string (str width)
1765 (substring str 0 width))
1767 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1768 ;; to limit the length of a string. This function is necessary since
1769 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1770 (defsubst gnus-limit-string (str width)
1771 (if (> (length str) width)
1772 (substring str 0 width)
1775 (defsubst gnus-simplify-subject-re (subject)
1776 "Remove \"Re:\" from subject lines."
1777 (let ((case-fold-search t))
1778 (if (string-match "^re: *" subject)
1779 (substring subject (match-end 0))
1782 (defsubst gnus-goto-char (point)
1783 (and point (goto-char point)))
1785 (defmacro gnus-buffer-exists-p (buffer)
1787 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1790 (defmacro gnus-kill-buffer (buffer)
1791 (` (if (gnus-buffer-exists-p (, buffer))
1792 (kill-buffer (, buffer)))))
1794 (defsubst gnus-point-at-bol ()
1795 "Return point at the beginning of line."
1802 (defsubst gnus-point-at-eol ()
1803 "Return point at the beginning of line."
1810 ;; Delete the current line (and the next N lines.);
1811 (defmacro gnus-delete-line (&optional n)
1812 (` (delete-region (progn (beginning-of-line) (point))
1813 (progn (forward-line (, (or n 1))) (point)))))
1815 ;;; Load the compatability functions.
1821 ;;; Gnus Utility Functions
1824 (defun gnus-extract-address-components (from)
1826 ;; First find the address - the thing with the @ in it. This may
1827 ;; not be accurate in mail addresses, but does the trick most of
1828 ;; the time in news messages.
1829 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1830 (setq address (substring from (match-beginning 0) (match-end 0))))
1831 ;; Then we check whether the "name <address>" format is used.
1833 (string-match (concat "<" (regexp-quote address) ">") from)
1834 (and (setq name (substring from 0 (1- (match-beginning 0))))
1835 ;; Strip any quotes from the name.
1836 (string-match "\".*\"" name)
1837 (setq name (substring name 1 (1- (match-end 0))))))
1838 ;; If not, then "address (name)" is used.
1840 (and (string-match "(.+)" from)
1841 (setq name (substring from (1+ (match-beginning 0))
1842 (1- (match-end 0)))))
1843 (and (string-match "()" from)
1844 (setq name address))
1845 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1846 ;; XOVER might not support folded From headers.
1847 (and (string-match "(.*" from)
1848 (setq name (substring from (1+ (match-beginning 0))
1850 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1851 (list (or name from) (or address from))))
1853 (defun gnus-fetch-field (field)
1854 "Return the value of the header FIELD of current article."
1857 (let ((case-fold-search t))
1858 (gnus-narrow-to-headers)
1859 (mail-fetch-field field)))))
1861 (defun gnus-goto-colon ()
1863 (search-forward ":" (gnus-point-at-eol) t))
1865 (defun gnus-narrow-to-headers ()
1869 (goto-char (point-min))
1870 (if (search-forward "\n\n" nil t)
1874 (defun gnus-update-format-specifications ()
1875 (gnus-make-thread-indent-array)
1876 (setq gnus-summary-line-format-spec
1878 gnus-summary-line-format gnus-summary-line-format-alist))
1879 (gnus-update-summary-mark-positions)
1880 (setq gnus-summary-dummy-line-format-spec
1881 (gnus-parse-format gnus-summary-dummy-line-format
1882 gnus-summary-dummy-line-format-alist))
1883 (setq gnus-group-line-format-spec
1885 gnus-group-line-format
1886 gnus-group-line-format-alist))
1887 (if (and (string-match "%D" gnus-group-line-format)
1888 (not gnus-description-hashtb)
1889 gnus-read-active-file)
1890 (gnus-read-all-descriptions-files))
1891 (setq gnus-summary-mode-line-format-spec
1892 (gnus-parse-format gnus-summary-mode-line-format
1893 gnus-summary-mode-line-format-alist))
1894 (setq gnus-article-mode-line-format-spec
1895 (gnus-parse-format gnus-article-mode-line-format
1896 gnus-summary-mode-line-format-alist))
1897 (setq gnus-group-mode-line-format-spec
1898 (gnus-parse-format gnus-group-mode-line-format
1899 gnus-group-mode-line-format-alist)))
1901 (defun gnus-update-summary-mark-positions ()
1903 (let ((gnus-replied-mark 129)
1904 (gnus-score-below-mark 130)
1905 (gnus-score-over-mark 130)
1908 (gnus-set-work-buffer)
1909 (gnus-summary-insert-line
1910 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1911 (goto-char (point-min))
1912 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1914 (goto-char (point-min))
1915 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1916 (- (point) 2))) pos))
1917 (goto-char (point-min))
1918 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1919 (- (point) 2))) pos))
1920 (setq gnus-summary-mark-positions pos))))
1922 (defun gnus-format-max-width (form length)
1923 (let* ((val (eval form))
1924 (valstr (if (numberp val) (int-to-string val) val)))
1925 (gnus-limit-string valstr length)))
1927 (defun gnus-set-mouse-face (string)
1928 ;; Set mouse face property on STRING.
1929 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1932 (defun gnus-parse-format (format spec-alist)
1933 ;; This function parses the FORMAT string with the help of the
1934 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1935 ;; string. If the FORMAT string contains the specifiers %( and %)
1936 ;; the text between them will have the mouse-face text property.
1937 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1938 (if (and gnus-visual gnus-mouse-face)
1939 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1940 (button (substring format (match-beginning 2) (match-end 2)))
1941 (post (substring format (match-beginning 3) (match-end 3))))
1943 (gnus-parse-simple-format pre spec-alist)
1944 (list 'gnus-set-mouse-face
1945 (gnus-parse-simple-format button spec-alist))
1946 (gnus-parse-simple-format post spec-alist)))
1947 (gnus-parse-simple-format
1948 (concat (substring format (match-beginning 1) (match-end 1))
1949 (substring format (match-beginning 2) (match-end 2))
1950 (substring format (match-beginning 3) (match-end 3)))
1952 (gnus-parse-simple-format format spec-alist)))
1954 (defun gnus-parse-simple-format (format spec-alist)
1955 ;; This function parses the FORMAT string with the help of the
1956 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1957 ;; string. The list will consist of the symbol `format', a format
1958 ;; specification string, and a list of forms depending on the
1961 spec flist fstring newspec elem beg)
1963 (gnus-set-work-buffer)
1965 (goto-char (point-min))
1966 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1967 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1969 ;; First check if there are any specs that look anything like
1970 ;; "%12,12A", ie. with a "max width specification". These have
1971 ;; to be treated specially.
1972 (if (setq beg (match-beginning 1))
1975 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1977 (setq beg (match-beginning 2)))
1978 ;; Find the specification from `spec-alist'.
1979 (if (not (setq elem (cdr (assq spec spec-alist))))
1980 (setq elem '("*" ?s)))
1981 ;; Treat user defined format specifiers specially
1982 (and (eq (car elem) 'user-defined)
1985 (list (intern (concat "gnus-user-format-function-"
1991 (delete-region (match-beginning 3) (match-end 3)))
1992 (if (not (zerop max-width))
1993 (let ((el (car elem)))
1994 (cond ((= (car (cdr elem)) ?c)
1995 (setq el (list 'char-to-string el)))
1996 ((= (car (cdr elem)) ?d)
1997 (numberp el) (setq el (list 'int-to-string el))))
1998 (setq flist (cons (list 'gnus-format-max-width el max-width)
2001 (setq flist (cons (car elem) flist))
2002 (setq newspec (car (cdr elem))))
2003 ;; Remove the old specification (and possibly a ",12" string).
2004 (delete-region beg (match-end 2))
2005 ;; Insert the new specification.
2008 (setq fstring (buffer-substring 1 (point-max))))
2009 (cons 'format (cons fstring (nreverse flist)))))
2011 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2012 (defun gnus-read-init-file ()
2014 (or (and (file-exists-p gnus-init-file)
2015 ;; Don't try to load a directory.
2016 (not (file-directory-p gnus-init-file)))
2017 (file-exists-p (concat gnus-init-file ".el"))
2018 (file-exists-p (concat gnus-init-file ".elc")))
2019 (load gnus-init-file nil t)))
2021 (defun gnus-set-work-buffer ()
2022 (if (get-buffer gnus-work-buffer)
2024 (set-buffer gnus-work-buffer)
2026 (set-buffer (get-buffer-create gnus-work-buffer))
2027 (kill-all-local-variables)
2028 (buffer-disable-undo (current-buffer))
2029 (gnus-add-current-to-buffer-list)))
2031 ;; Article file names when saving.
2033 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2034 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2035 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2036 Otherwise, it is like ~/News/news/group/num."
2039 (concat (if (gnus-use-long-file-name 'not-save)
2040 (gnus-capitalize-newsgroup newsgroup)
2041 (gnus-newsgroup-directory-form newsgroup))
2042 "/" (int-to-string (header-number headers)))
2043 (or gnus-article-save-directory "~/News"))))
2045 (string-equal (file-name-directory default)
2046 (file-name-directory last-file))
2047 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2049 (or last-file default))))
2051 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2052 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2053 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2054 Otherwise, it is like ~/News/news/group/num."
2057 (concat (if (gnus-use-long-file-name 'not-save)
2059 (gnus-newsgroup-directory-form newsgroup))
2060 "/" (int-to-string (header-number headers)))
2061 (or gnus-article-save-directory "~/News"))))
2063 (string-equal (file-name-directory default)
2064 (file-name-directory last-file))
2065 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2067 (or last-file default))))
2069 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2070 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2071 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2072 Otherwise, it is like ~/News/news/group/news."
2075 (if (gnus-use-long-file-name 'not-save)
2076 (gnus-capitalize-newsgroup newsgroup)
2077 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2078 (or gnus-article-save-directory "~/News"))))
2080 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2081 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2082 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
2083 Otherwise, it is like ~/News/news/group/news."
2086 (if (gnus-use-long-file-name 'not-save)
2088 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2089 (or gnus-article-save-directory "~/News"))))
2091 ;; For subscribing new newsgroup
2093 (defun gnus-subscribe-hierarchical-interactive (groups)
2094 (let ((groups (sort groups 'string<))
2095 prefixes prefix start ans group starts)
2097 (setq prefixes (list "^"))
2098 (while (and groups prefixes)
2099 (while (not (string-match (car prefixes) (car groups)))
2100 (setq prefixes (cdr prefixes)))
2101 (setq prefix (car prefixes))
2102 (setq start (1- (length prefix)))
2103 (if (and (string-match "[^\\.]\\." (car groups) start)
2106 (concat "^" (substring (car groups) 0 (match-end 0))))
2107 (string-match prefix (car (cdr groups))))
2109 (setq prefixes (cons prefix prefixes))
2110 (message "Descend hierarchy %s? ([y]nsq): "
2111 (substring prefix 1 (1- (length prefix))))
2112 (setq ans (read-char))
2115 (string-match prefix
2116 (setq group (car groups))))
2117 (setq gnus-killed-list
2118 (cons group gnus-killed-list))
2119 (gnus-sethash group group gnus-killed-hashtb)
2120 (setq groups (cdr groups)))
2121 (setq starts (cdr starts)))
2124 (string-match prefix
2125 (setq group (car groups))))
2126 (gnus-sethash group group gnus-killed-hashtb)
2127 (gnus-subscribe-alphabetically (car groups))
2128 (setq groups (cdr groups)))
2129 (setq starts (cdr starts)))
2132 (setq group (car groups))
2133 (setq gnus-killed-list (cons group gnus-killed-list))
2134 (gnus-sethash group group gnus-killed-hashtb)
2135 (setq groups (cdr groups))))
2137 (message "Subscribe %s? ([n]yq)" (car groups))
2138 (setq ans (read-char))
2139 (setq group (car groups))
2141 (gnus-subscribe-alphabetically (car groups))
2142 (gnus-sethash group group gnus-killed-hashtb))
2145 (setq group (car groups))
2146 (setq gnus-killed-list (cons group gnus-killed-list))
2147 (gnus-sethash group group gnus-killed-hashtb)
2148 (setq groups (cdr groups))))
2150 (setq gnus-killed-list (cons group gnus-killed-list))
2151 (gnus-sethash group group gnus-killed-hashtb)))
2152 (setq groups (cdr groups)))))))
2154 (defun gnus-subscribe-randomly (newsgroup)
2155 "Subscribe new NEWSGROUP by making it the first newsgroup."
2156 (gnus-subscribe-newsgroup newsgroup))
2158 (defun gnus-subscribe-alphabetically (newgroup)
2159 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2160 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2161 (let ((groups (cdr gnus-newsrc-alist))
2163 (while (and (not before) groups)
2164 (if (string< newgroup (car (car groups)))
2165 (setq before (car (car groups)))
2166 (setq groups (cdr groups))))
2167 (gnus-subscribe-newsgroup newgroup before)))
2169 (defun gnus-subscribe-hierarchically (newgroup)
2170 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2171 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2173 (set-buffer (find-file-noselect gnus-current-startup-file))
2174 (let ((groupkey newgroup)
2176 (while (and (not before) groupkey)
2177 (goto-char (point-min))
2179 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2180 (while (and (re-search-forward groupkey-re nil t)
2182 (setq before (buffer-substring
2183 (match-beginning 1) (match-end 1)))
2184 (string< before newgroup)))))
2185 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2187 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2188 (substring groupkey (match-beginning 1) (match-end 1)))))
2189 (gnus-subscribe-newsgroup newgroup before))))
2191 (defun gnus-subscribe-interactively (newsgroup)
2192 "Subscribe new NEWSGROUP interactively.
2193 It is inserted in hierarchical newsgroup order if subscribed. If not,
2195 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2196 (gnus-subscribe-hierarchically newsgroup)
2197 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2199 (defun gnus-subscribe-zombies (newsgroup)
2200 "Make new NEWSGROUP a zombie group."
2201 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2203 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2204 "Subscribe new NEWSGROUP.
2205 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2206 the first newsgroup."
2207 ;; We subscribe the group by changing its level to `subscribed'.
2208 (gnus-group-change-level
2209 newsgroup gnus-level-default-subscribed
2210 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2211 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2215 (defun gnus-newsgroup-directory-form (newsgroup)
2216 "Make hierarchical directory name from NEWSGROUP name."
2217 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2218 (len (length newsgroup))
2220 ;; If this is a foreign group, we don't want to translate the
2222 (if (setq idx (string-match ":" newsgroup))
2223 (aset newsgroup idx ?/)
2225 ;; Replace all occurrences of `.' with `/'.
2227 (if (= (aref newsgroup idx) ?.)
2228 (aset newsgroup idx ?/))
2229 (setq idx (1+ idx)))
2232 (defun gnus-make-directory (dir)
2233 "Make DIRECTORY recursively."
2234 (let* ((dir (expand-file-name dir default-directory))
2236 (if (string-match "/$" dir)
2237 (setq dir (substring dir 0 (match-beginning 0))))
2238 (while (not (file-exists-p dir))
2239 (setq dirs (cons dir dirs))
2240 (string-match "/[^/]+$" dir)
2241 (setq dir (substring dir 0 (match-beginning 0))))
2243 (make-directory (car dirs))
2244 (setq dirs (cdr dirs)))))
2246 (defun gnus-capitalize-newsgroup (newsgroup)
2247 "Capitalize NEWSGROUP name."
2248 (and (not (zerop (length newsgroup)))
2249 (concat (char-to-string (upcase (aref newsgroup 0)))
2250 (substring newsgroup 1))))
2254 (defun gnus-simplify-subject (subject &optional re-only)
2255 "Remove `Re:' and words in parentheses.
2256 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2257 (let ((case-fold-search t)) ;Ignore case.
2258 ;; Remove `Re:' and `Re^N:'.
2259 (if (string-match "^re:[ \t]*" subject)
2260 (setq subject (substring subject (match-end 0))))
2261 ;; Remove words in parentheses from end.
2263 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2264 (setq subject (substring subject 0 (match-beginning 0)))))
2265 ;; Return subject string.
2268 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2270 (defun gnus-simplify-subject-fuzzy (subject)
2271 (let ((case-fold-search t))
2273 (gnus-set-work-buffer)
2275 (inline (gnus-simplify-buffer-fuzzy))
2278 (defun gnus-simplify-buffer-fuzzy ()
2279 (goto-char (point-min))
2280 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2281 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2283 (replace-match "" t t))
2284 (goto-char (point-min))
2285 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2286 (replace-match "" t t))
2287 (goto-char (point-min))
2288 (while (re-search-forward "[ \t]+" nil t)
2289 (replace-match " " t t))
2290 (goto-char (point-min))
2291 (while (re-search-forward "[ \t]+$" nil t)
2292 (replace-match "" t t))
2293 (goto-char (point-min))
2294 (while (re-search-forward "^[ \t]+" nil t)
2295 (replace-match "" t t))
2296 (if gnus-simplify-subject-fuzzy-regexp
2297 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2298 (replace-match "" t t)))
2301 ;; Add the current buffer to the list of buffers to be killed on exit.
2302 (defun gnus-add-current-to-buffer-list ()
2303 (or (memq (current-buffer) gnus-buffer-list)
2304 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2306 (defun gnus-string> (s1 s2)
2307 (not (or (string< s1 s2)
2310 ;; Functions accessing headers.
2311 ;; Functions are more convenient than macros in some cases.
2313 (defun gnus-header-number (header)
2314 (header-number header))
2316 (defun gnus-header-subject (header)
2317 (header-subject header))
2319 (defun gnus-header-from (header)
2320 (header-from header))
2322 (defun gnus-header-xref (header)
2323 (header-xref header))
2325 (defun gnus-header-lines (header)
2326 (header-lines header))
2328 (defun gnus-header-date (header)
2329 (header-date header))
2331 (defun gnus-header-id (header)
2334 (defun gnus-header-references (header)
2335 (header-references header))
2337 ;;; General various misc type functions.
2339 (defun gnus-clear-system ()
2340 "Clear all variables and buffers."
2341 ;; Clear Gnus variables.
2342 (let ((variables gnus-variable-list))
2344 (set (car variables) nil)
2345 (setq variables (cdr variables))))
2346 ;; Clear other internal variables.
2347 (setq gnus-list-of-killed-groups nil
2348 gnus-have-read-active-file nil
2349 gnus-newsrc-alist nil
2350 gnus-newsrc-hashtb nil
2351 gnus-killed-list nil
2352 gnus-zombie-list nil
2353 gnus-killed-hashtb nil
2354 gnus-active-hashtb nil
2355 gnus-moderated-list nil
2356 gnus-description-hashtb nil
2357 gnus-newsgroup-headers nil
2358 gnus-newsgroup-headers-hashtb-by-number nil
2359 gnus-newsgroup-name nil
2360 gnus-server-alist nil
2361 gnus-current-select-method nil)
2362 ;; Reset any score variables.
2363 (and (boundp 'gnus-score-cache)
2364 (set 'gnus-score-cache nil))
2365 (and (boundp 'gnus-internal-global-score-files)
2366 (set 'gnus-internal-global-score-files nil))
2367 ;; Kill the startup file.
2368 (and gnus-current-startup-file
2369 (get-file-buffer gnus-current-startup-file)
2370 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2371 ;; Save any cache buffers.
2372 (and gnus-use-cache (gnus-cache-save-buffers))
2373 ;; Clear the dribble buffer.
2374 (gnus-dribble-clear)
2375 ;; Kill global KILL file buffer.
2376 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2377 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2378 (gnus-kill-buffer nntp-server-buffer)
2379 ;; Kill Gnus buffers.
2380 (while gnus-buffer-list
2381 (gnus-kill-buffer (car gnus-buffer-list))
2382 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2384 (defun gnus-windows-old-to-new (setting)
2385 (if (symbolp setting)
2387 (cond ((eq setting 'SelectArticle)
2389 ((eq setting 'SelectSubject)
2391 ((eq setting 'SelectNewsgroup)
2394 (if (or (listp setting)
2395 (not (and gnus-window-configuration
2396 (memq setting '(group summary article)))))
2398 (let* ((setting (if (eq setting 'group)
2399 (if (assq 'newsgroup gnus-window-configuration)
2401 'newsgroups) setting))
2402 (elem (car (cdr (assq setting gnus-window-configuration))))
2403 (total (apply '+ elem))
2404 (types '(group summary article))
2405 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2410 (or (zerop (nth i elem))
2412 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2413 (setq out (cons (if (eq pbuf (nth i types))
2414 (vector (nth i types) perc 'point)
2415 (vector (nth i types) perc))
2418 (list (nreverse out)))))
2420 (defun gnus-add-configuration (conf)
2421 (setq gnus-buffer-configuration
2422 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2423 gnus-buffer-configuration))))
2425 (defun gnus-configure-windows (setting)
2426 (setq setting (gnus-windows-old-to-new setting))
2427 (let ((r (if (symbolp setting)
2428 (cdr (assq setting gnus-buffer-configuration))
2430 (in-buf (current-buffer))
2431 rule val w height hor ohor heights sub jump-buffer
2433 (or r (error "No such setting: %s" setting))
2435 ;; Either remove all windows or just remove all Gnus windows.
2436 (if gnus-use-full-window
2437 (delete-other-windows)
2438 (gnus-remove-some-windows)
2439 (switch-to-buffer nntp-server-buffer))
2445 ;; We have to do the (possible) horizontal splitting before the
2447 (if (and (listp (car hor))
2448 (eq (car (car hor)) 'horizontal))
2452 (if (integerp (nth 1 (car hor)))
2454 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2456 (setq hor (cdr hor))))
2458 ;; Go through the rules and eval the elements that are to be
2461 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2463 ;; Expand short buffer name.
2464 (setq w (aref val 0))
2465 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2467 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2469 (setq ohor (cons val ohor))))
2470 (setq hor (cdr hor)))
2471 (setq rule (cons (nreverse ohor) rule))
2473 (setq rule (nreverse rule))
2475 ;; We tally the window sizes.
2476 (setq total (window-height))
2478 (setq hor (car rule))
2479 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2480 (setq hor (cdr hor)))
2483 (setq rel (aref (car hor) 1)
2485 (cond ((and (floatp rel) (= 1.0 rel))
2490 (max (floor (* total rel)) 4)))
2492 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2494 (setq heights (nreverse heights)
2497 ;; We then go through these heighs and create windows for them.
2499 (setq height (car heights)
2500 heights (cdr heights))
2502 (setq height (- total sub)))
2504 (split-window nil height))
2505 (setq to-buf (aref (car hor) 0))
2510 (symbol-value (aref (car hor) 0)))
2512 (aref (car hor) 0))))
2513 (and (> (length (car hor)) 2)
2514 (eq (aref (car hor) 2) 'point)
2515 (setq jump-buffer (current-buffer)))
2517 (setq hor (cdr hor)))
2519 (setq rule (cdr rule)))
2521 ;; Finally, we pop to the buffer that's supposed to have point.
2522 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2524 (select-window (get-buffer-window jump-buffer))
2525 (set-buffer jump-buffer)))
2527 (defun gnus-remove-some-windows ()
2528 (let ((buffers gnus-window-to-buffer)
2532 ;; Remove windows on all known Gnus buffers.
2534 (setq buf (cdr (car buffers)))
2536 (setq buf (and (boundp buf) (symbol-value buf))))
2538 (get-buffer-window buf)
2543 (switch-to-buffer nntp-server-buffer)
2545 (delete-window (get-buffer-window buf)))))
2546 (setq buffers (cdr buffers)))
2547 ;; Remove windows on *all* summary buffers.
2548 (let ((buffers (buffer-list)))
2550 (if (and (string-match
2551 "^\\*Summary" (or (buffer-name (car buffers)) ""))
2552 (get-buffer-window (car buffers)))
2553 (delete-window (get-buffer-window (car buffers))))
2554 (setq buffers (cdr buffers)))))))
2556 (defun gnus-version ()
2557 "Version numbers of this version of Gnus."
2559 (let ((methods gnus-valid-select-methods)
2562 ;; Go through all the legal select methods and add their version
2563 ;; numbers to the total version string. Only the backends that are
2564 ;; currently in use will have their message numbers taken into
2567 (setq meth (intern (concat (car (car methods)) "-version")))
2569 (stringp (symbol-value meth))
2570 (setq mess (concat mess "; " (symbol-value meth))))
2571 (setq methods (cdr methods)))
2572 (gnus-message 2 mess)))
2574 (defun gnus-info-find-node ()
2575 "Find Info documentation of Gnus."
2577 ;; Enlarge info window if needed.
2578 (let ((mode major-mode))
2579 (gnus-configure-windows 'info)
2580 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2582 (defun gnus-overload-functions (&optional overloads)
2583 "Overload functions specified by optional argument OVERLOADS.
2584 If nothing is specified, use the variable gnus-overload-functions."
2586 (overloads (or overloads gnus-overload-functions)))
2588 (setq defs (car overloads))
2589 (setq overloads (cdr overloads))
2590 ;; Load file before overloading function if necessary. Make
2591 ;; sure we cannot use `require' always.
2592 (and (not (fboundp (car defs)))
2593 (car (cdr (cdr defs)))
2594 (load (car (cdr (cdr defs))) nil 'nomessage))
2595 (fset (car defs) (car (cdr defs))))))
2597 (defun gnus-replace-chars-in-string (string from to)
2598 "Replace characters in STRING from FROM to TO."
2599 (let ((string (substring string 0)) ;Copy string.
2600 (len (length string))
2602 ;; Replace all occurrences of FROM with TO.
2604 (if (= (aref string idx) from)
2605 (aset string idx to))
2606 (setq idx (1+ idx)))
2609 (defun gnus-days-between (date1 date2)
2610 ;; Return the number of days between date1 and date2.
2611 (- (gnus-day-number date1) (gnus-day-number date2)))
2613 (defun gnus-day-number (date)
2614 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2615 (timezone-parse-date date))))
2616 (timezone-absolute-from-gregorian
2617 (nth 1 dat) (nth 2 dat) (car dat))))
2619 ;; Returns a floating point number that says how many seconds have
2620 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2621 (defun gnus-seconds-since-epoch (date)
2622 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2623 (timezone-parse-date date)))
2624 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2625 (timezone-parse-time
2626 (aref (timezone-parse-date date) 3))))
2627 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2628 (timezone-parse-date "Jan 1 12:00:00 1970")))
2629 (tday (- (timezone-absolute-from-gregorian
2630 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2631 (timezone-absolute-from-gregorian
2632 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2634 (* (nth 1 ttime) 60)
2635 (* 1.0 (nth 0 ttime) 60 60)
2636 (* 1.0 tday 60 60 24))))
2638 (defun gnus-file-newer-than (file date)
2639 (let ((fdate (nth 5 (file-attributes file))))
2640 (or (> (car fdate) (car date))
2641 (and (= (car fdate) (car date))
2642 (> (nth 1 fdate) (nth 1 date))))))
2644 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2646 (defun gnus-y-or-n-p (prompt)
2651 (defun gnus-yes-or-no-p (prompt)
2653 (yes-or-no-p prompt)
2656 ;; Check whether to use long file names.
2657 (defun gnus-use-long-file-name (symbol)
2658 ;; The variable has to be set...
2659 (and gnus-use-long-file-name
2660 ;; If it isn't a list, then we return t.
2661 (or (not (listp gnus-use-long-file-name))
2662 ;; If it is a list, and the list contains `symbol', we
2664 (not (memq symbol gnus-use-long-file-name)))))
2666 ;; I suspect there's a better way, but I haven't taken the time to do
2667 ;; it yet. -erik selberg@cs.washington.edu
2668 (defun gnus-dd-mmm (messy-date)
2669 "Return a string like DD-MMM from a big messy string"
2670 (let ((datevec (timezone-parse-date messy-date)))
2672 (or (aref datevec 2) "??")
2675 (nth (1- (string-to-number (aref datevec 1)))
2676 timezone-months-assoc))
2679 ;; Make a hash table (default and minimum size is 255).
2680 ;; Optional argument HASHSIZE specifies the table size.
2681 (defun gnus-make-hashtable (&optional hashsize)
2682 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2684 ;; Make a number that is suitable for hashing; bigger than MIN and one
2686 (defun gnus-create-hash-size (min)
2692 ;; Show message if message has a lower level than `gnus-verbose'.
2693 ;; Guide-line for numbers:
2694 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2695 ;; for things that take a long time, 7 - not very important messages
2696 ;; on stuff, 9 - messages inside loops.
2697 (defun gnus-message (level &rest args)
2698 (if (<= level gnus-verbose)
2699 (apply 'message args)
2700 ;; We have to do this format thingie here even if the result isn't
2701 ;; shown - the return value has to be the same as the return value
2703 (apply 'format args)))
2705 ;; Generate a unique new group name.
2706 (defun gnus-generate-new-group-name (leaf)
2709 (while (gnus-gethash name gnus-newsrc-hashtb)
2710 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2713 (defun gnus-find-file-noselect (file &optional force)
2714 "Does vaguely the same as find-file-noselect. No hooks are run."
2716 (if (setq buf (get-file-buffer file))
2718 (setq buf (create-file-buffer file))
2725 (and (file-readable-p file)
2726 (insert-file-contents file))
2727 (set-visited-file-name file)
2728 (set-buffer-modified-p nil)
2729 (current-buffer)))))
2731 ;;; List and range functions
2733 (defun gnus-last-element (list)
2734 "Return last element of LIST."
2736 (setq list (cdr list)))
2739 (defun gnus-copy-sequence (list)
2740 "Do a complete, total copy of a list."
2741 (if (and (consp list) (not (consp (cdr list))))
2742 (cons (car list) (cdr list))
2743 (mapcar (lambda (elem) (if (consp elem)
2744 (if (consp (cdr elem))
2745 (gnus-copy-sequence elem)
2746 (cons (car elem) (cdr elem)))
2750 (defun gnus-set-difference (list1 list2)
2751 "Return a list of elements of LIST1 that do not appear in LIST2."
2752 (let ((list1 (copy-sequence list1)))
2754 (setq list1 (delq (car list2) list1))
2755 (setq list2 (cdr list2)))
2758 (defun gnus-sorted-complement (list1 list2)
2759 "Return a list of elements of LIST1 that do not appear in LIST2.
2760 Both lists have to be sorted over <."
2762 (if (or (null list1) (null list2))
2764 (while (and list1 list2)
2765 (cond ((= (car list1) (car list2))
2766 (setq list1 (cdr list1)
2768 ((< (car list1) (car list2))
2769 (setq out (cons (car list1) out))
2770 (setq list1 (cdr list1)))
2772 (setq out (cons (car list2) out))
2773 (setq list2 (cdr list2)))))
2774 (nconc (nreverse out) (or list1 list2)))))
2776 (defun gnus-intersection (list1 list2)
2779 (if (memq (car list2) list1)
2780 (setq result (cons (car list2) result)))
2781 (setq list2 (cdr list2)))
2784 (defun gnus-sorted-intersection (list1 list2)
2785 ;; LIST1 and LIST2 have to be sorted over <.
2787 (while (and list1 list2)
2788 (cond ((= (car list1) (car list2))
2789 (setq out (cons (car list1) out)
2792 ((< (car list1) (car list2))
2793 (setq list1 (cdr list1)))
2795 (setq list2 (cdr list2)))))
2798 (defun gnus-set-sorted-intersection (list1 list2)
2799 ;; LIST1 and LIST2 have to be sorted over <.
2800 ;; This function modifies LIST1.
2801 (let* ((top (cons nil list1))
2803 (while (and list1 list2)
2804 (cond ((= (car list1) (car list2))
2808 ((< (car list1) (car list2))
2809 (setcdr prev (cdr list1))
2810 (setq list1 (cdr list1)))
2812 (setq list2 (cdr list2)))))
2816 (defun gnus-compress-sequence (numbers &optional always-list)
2817 "Convert list of numbers to a list of ranges or a single range.
2818 If ALWAYS-LIST is non-nil, this function will always release a list of
2820 (let* ((first (car numbers))
2821 (last (car numbers))
2825 (if (not (listp (cdr numbers)))
2828 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2829 ((= (1+ last) (car numbers)) ;Still in sequence
2830 (setq last (car numbers)))
2831 (t ;End of one sequence
2833 (cons (if (= first last) first
2834 (cons first last)) result))
2835 (setq first (car numbers))
2836 (setq last (car numbers))))
2837 (setq numbers (cdr numbers)))
2838 (if (and (not always-list) (null result))
2839 (if (= first last) (list first) (cons first last))
2840 (nreverse (cons (if (= first last) first (cons first last))
2843 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2844 (defun gnus-uncompress-range (ranges)
2845 "Expand a list of ranges into a list of numbers.
2846 RANGES is either a single range on the form `(num . num)' or a list of
2848 (let (first last result)
2852 ((not (listp (cdr ranges)))
2853 (setq first (car ranges))
2854 (setq last (cdr ranges))
2855 (while (<= first last)
2856 (setq result (cons first result))
2857 (setq first (1+ first)))
2861 (if (atom (car ranges))
2862 (if (numberp (car ranges))
2863 (setq result (cons (car ranges) result)))
2864 (setq first (car (car ranges)))
2865 (setq last (cdr (car ranges)))
2866 (while (<= first last)
2867 (setq result (cons first result))
2868 (setq first (1+ first))))
2869 (setq ranges (cdr ranges)))
2870 (nreverse result)))))
2872 (defun gnus-add-to-range (ranges list)
2873 "Return a list of ranges that has all articles from both RANGES and LIST.
2874 Note: LIST has to be sorted over `<'."
2876 (gnus-compress-sequence list t)
2877 (setq list (copy-sequence list))
2878 (or (listp (cdr ranges))
2879 (setq ranges (list ranges)))
2881 ilist lowest highest temp)
2882 (while (and ranges list)
2884 (setq lowest (or (and (atom (car ranges)) (car ranges))
2885 (car (car ranges))))
2886 (while (and list (cdr list) (< (car (cdr list)) lowest))
2887 (setq list (cdr list)))
2888 (if (< (car ilist) lowest)
2891 (setq list (cdr list))
2893 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2894 (setq highest (or (and (atom (car ranges)) (car ranges))
2895 (cdr (car ranges))))
2896 (while (and list (<= (car list) highest))
2897 (setq list (cdr list)))
2898 (setq ranges (cdr ranges)))
2900 (setq out (nconc (gnus-compress-sequence list t) out)))
2901 (setq out (sort out (lambda (r1 r2)
2902 (< (or (and (atom r1) r1) (car r1))
2903 (or (and (atom r2) r2) (car r2))))))
2906 (if (atom (car ranges))
2908 (if (atom (car (cdr ranges)))
2909 (if (= (1+ (car ranges)) (car (cdr ranges)))
2911 (setcar ranges (cons (car ranges)
2912 (car (cdr ranges))))
2913 (setcdr ranges (cdr (cdr ranges)))))
2914 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2916 (setcar (car (cdr ranges)) (car ranges))
2917 (setcar ranges (car (cdr ranges)))
2918 (setcdr ranges (cdr (cdr ranges)))))))
2920 (if (atom (car (cdr ranges)))
2921 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2923 (setcdr (car ranges) (car (cdr ranges)))
2924 (setcdr ranges (cdr (cdr ranges)))))
2925 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2927 (setcdr (car ranges) (cdr (car (cdr ranges))))
2928 (setcdr ranges (cdr (cdr ranges))))))))
2929 (setq ranges (cdr ranges)))
2932 (defun gnus-remove-from-range (ranges list)
2933 "Return a list of ranges that has all articles from LIST removed from RANGES.
2934 Note: LIST has to be sorted over `<'."
2935 ;; !!! This function shouldn't look like this, but I've got a headache.
2936 (gnus-compress-sequence
2937 (gnus-sorted-complement
2938 (gnus-uncompress-range ranges) list)))
2940 (defun gnus-member-of-range (number ranges)
2941 (if (not (listp (cdr ranges)))
2942 (and (>= number (car ranges))
2943 (<= number (cdr ranges)))
2946 (if (numberp (car ranges))
2947 (>= number (car ranges))
2948 (>= number (car (car ranges))))
2950 (if (if (numberp (car ranges))
2951 (= number (car ranges))
2952 (and (>= number (car (car ranges)))
2953 (<= number (cdr (car ranges)))))
2954 (setq not-stop nil))
2955 (setq ranges (cdr ranges)))
2963 (defvar gnus-group-mode-map nil)
2964 (defvar gnus-group-group-map nil)
2965 (defvar gnus-group-mark-map nil)
2966 (defvar gnus-group-list-map nil)
2967 (defvar gnus-group-sub-map nil)
2968 (put 'gnus-group-mode 'mode-class 'special)
2970 (if gnus-group-mode-map
2972 (setq gnus-group-mode-map (make-keymap))
2973 (suppress-keymap gnus-group-mode-map)
2974 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2975 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2976 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2977 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2978 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2979 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2980 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2981 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2982 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2983 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2984 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2985 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2986 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2987 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2988 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2989 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2990 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2991 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2992 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2993 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2994 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2995 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2996 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2997 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2998 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2999 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3000 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3001 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3002 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3003 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3004 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3005 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3006 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3007 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3008 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3009 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3010 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3011 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3012 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3013 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3014 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3015 (define-key gnus-group-mode-map "V" 'gnus-version)
3016 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3017 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3018 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3019 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3020 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3021 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3022 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3023 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3024 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3025 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3026 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3027 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3028 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3029 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3030 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3032 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3033 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3034 (define-prefix-command 'gnus-group-mark-map)
3035 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3036 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3037 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3038 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3040 (define-prefix-command 'gnus-group-group-map)
3041 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3042 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3043 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3044 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3045 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3046 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3047 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3048 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3049 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3050 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3051 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3052 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3053 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3054 (define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3055 (define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3056 (define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3057 (define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3058 (define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3060 (define-prefix-command 'gnus-group-list-map)
3061 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3062 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3063 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3064 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3065 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3066 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3067 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3068 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3069 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3071 (define-prefix-command 'gnus-group-sub-map)
3072 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3073 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3074 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3075 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3076 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3077 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3078 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3079 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3081 (defun gnus-group-mode ()
3082 "Major mode for reading news.
3084 All normal editing commands are switched off.
3085 \\<gnus-group-mode-map>
3086 The group buffer lists (some of) the groups available. For instance,
3087 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3088 lists all zombie groups.
3090 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3091 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3093 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3095 The following commands are available:
3097 \\{gnus-group-mode-map}"
3099 (if gnus-visual (gnus-group-make-menu-bar))
3100 (kill-all-local-variables)
3101 (setq mode-line-modified "-- ")
3102 (make-local-variable 'mode-line-format)
3103 (setq mode-line-format (copy-sequence mode-line-format))
3104 (and (equal (nth 3 mode-line-format) " ")
3105 (setcar (nthcdr 3 mode-line-format) ""))
3106 (setq major-mode 'gnus-group-mode)
3107 (setq mode-name "Group")
3108 (gnus-group-set-mode-line)
3109 (setq mode-line-process nil)
3110 (use-local-map gnus-group-mode-map)
3111 (buffer-disable-undo (current-buffer))
3112 (setq truncate-lines t)
3113 (setq buffer-read-only t)
3114 (run-hooks 'gnus-group-mode-hook))
3116 (defun gnus-mouse-pick-group (e)
3119 (gnus-group-read-group nil))
3122 (defun gnus-no-server (&optional arg)
3124 If ARG is a positive number, Gnus will use that as the
3125 startup level. If ARG is nil, Gnus will be started at level 2.
3126 If ARG is non-nil and not a positive number, Gnus will
3127 prompt the user for the name of an NNTP server to use.
3128 As opposed to `gnus', this command will not connect to the local server."
3130 (setq gnus-group-use-permanent-levels t)
3131 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3133 (defalias '\(ding\) 'gnus)
3136 (defun gnus (&optional arg dont-connect)
3138 If ARG is non-nil and a positive number, Gnus will use that as the
3139 startup level. If ARG is non-nil and not a positive number, Gnus will
3140 prompt the user for the name of an NNTP server to use."
3142 (if (get-buffer gnus-group-buffer)
3144 (switch-to-buffer gnus-group-buffer)
3145 (gnus-group-get-new-news))
3147 (nnheader-init-server-buffer)
3148 (gnus-read-init-file)
3149 (let ((level (and arg (numberp arg) (> arg 0) arg))
3153 (gnus-group-setup-buffer)
3156 (gnus-start-news-server (and arg (not level))))))
3157 (if (and (not dont-connect)
3160 (run-hooks 'gnus-startup-hook)
3161 ;; NNTP server is successfully open.
3162 (gnus-update-format-specifications)
3163 (gnus-summary-make-display-table)
3164 (let ((buffer-read-only nil))
3166 (if (not gnus-inhibit-startup-message)
3168 (gnus-group-startup-message)
3170 (gnus-setup-news nil level)
3171 (and gnus-use-dribble-file (gnus-dribble-open))
3172 (gnus-group-list-groups level)
3173 (gnus-configure-windows 'group))))))
3175 (defun gnus-group-startup-message (&optional x y)
3176 "Insert startup message in current buffer."
3177 ;; Insert the message.
3193 ;; And then hack it.
3194 ;; 18 is the longest line.
3195 (indent-rigidly (point-min) (point-max)
3196 (/ (max (- (window-width) (or x 28)) 0) 2))
3197 (goto-char (point-min))
3198 ;; +4 is fuzzy factor.
3199 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3202 (goto-char (point-min))
3203 (search-forward "Praxis")
3204 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3205 (goto-char (point-min)))
3207 (defun gnus-group-setup-buffer ()
3208 (or (get-buffer gnus-group-buffer)
3210 (switch-to-buffer gnus-group-buffer)
3211 (gnus-add-current-to-buffer-list)
3213 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3215 (defun gnus-group-list-groups (level &optional unread)
3216 "List newsgroups with level LEVEL or lower that have unread articles.
3217 Default is all subscribed groups.
3218 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3219 (interactive (list (and current-prefix-arg
3220 (prefix-numeric-value current-prefix-arg))))
3221 (if gnus-group-use-permanent-levels
3223 (setq gnus-group-default-list-level
3224 (or level gnus-group-default-list-level))
3225 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3226 (setq level (or level gnus-group-default-list-level
3227 gnus-level-subscribed)))
3228 (gnus-group-setup-buffer) ;May call from out of group buffer
3229 (let ((case-fold-search nil)
3230 (group (gnus-group-group-name)))
3231 (funcall gnus-group-prepare-function level unread nil)
3232 (if (zerop (buffer-size))
3233 (gnus-message 5 gnus-no-groups-message)
3234 (goto-char (point-min))
3236 ;; Go to the first group with unread articles.
3237 (gnus-group-search-forward nil nil nil t)
3238 ;; Find the right group to put point on. If the current group
3239 ;; has disapeared in the new listing, try to find the next
3240 ;; one. If no next one can be found, just leave point at the
3241 ;; first newsgroup in the buffer.
3242 (if (not (gnus-goto-char
3243 (text-property-any (point-min) (point-max)
3244 'gnus-group (intern group))))
3245 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3247 (not (gnus-goto-char
3249 (point-min) (point-max) 'gnus-group
3250 (intern (car (car newsrc)))))))
3251 (setq newsrc (cdr newsrc)))
3252 (or newsrc (progn (goto-char (point-max))
3253 (forward-line -1))))))
3254 ;; Adjust cursor point.
3255 (gnus-group-position-cursor))))
3257 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3258 "List all newsgroups with unread articles of level LEVEL or lower.
3259 If ALL is non-nil, list groups that have no unread articles.
3260 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3261 If REGEXP, only list groups matching REGEXP."
3262 (set-buffer gnus-group-buffer)
3263 (let ((buffer-read-only nil)
3264 (newsrc (cdr gnus-newsrc-alist))
3265 (lowest (or lowest 1))
3266 info clevel unread group)
3268 (if (< lowest gnus-level-zombie)
3269 ;; List living groups.
3271 (setq info (car newsrc)
3274 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3275 (and unread ; This group might be bogus
3277 (string-match regexp group))
3278 (<= (setq clevel (car (cdr info))) level)
3280 (or all ; We list all groups?
3281 (eq unread t) ; We list unactivated groups
3282 (> unread 0) ; We list groups with unread articles
3283 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3284 (gnus-group-insert-group-line
3285 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3287 ;; List dead groups.
3288 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3289 (gnus-group-prepare-flat-list-dead
3290 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3291 gnus-level-zombie ?Z
3293 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3294 (gnus-group-prepare-flat-list-dead
3295 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3296 gnus-level-killed ?K regexp))
3298 (gnus-group-set-mode-line)
3299 (setq gnus-have-all-newsgroups all)
3300 (run-hooks 'gnus-group-prepare-hook)))
3302 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3303 ;; List zombies and killed lists somehwat faster, which was
3304 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3305 ;; this by ignoring the group format specification altogether.
3308 (setq group (car groups)
3309 groups (cdr groups))
3310 (if (or (not regexp)
3311 (string-match regexp group))
3314 (insert (format " %c *: %s\n" mark group))
3315 (add-text-properties
3317 (list 'gnus-group (intern group)
3319 'gnus-level level)))))))
3321 (defun gnus-group-real-name (group)
3322 "Find the real name of a foreign newsgroup."
3323 (if (string-match ":[^:]+$" group)
3324 (substring group (1+ (match-beginning 0)))
3327 (defun gnus-group-prefixed-name (group method)
3328 "Return the whole name from GROUP and METHOD."
3329 (and (stringp method) (setq method (gnus-server-to-method method)))
3330 (concat (format "%s" (car method))
3332 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3333 (not (string= (nth 1 method) "")))
3334 (concat "+" (nth 1 method)))
3337 (defun gnus-group-real-prefix (group)
3338 "Return the prefix of the current group name."
3339 (if (string-match "^[^:]+:" group)
3340 (substring group 0 (match-end 0))
3343 (defun gnus-group-method-name (group)
3344 "Return the method used for selecting GROUP."
3345 (let ((prefix (gnus-group-real-prefix group)))
3346 (if (equal prefix "")
3348 (if (string-match "^[^\\+]+\\+" prefix)
3349 (list (intern (substring prefix 0 (1- (match-end 0))))
3350 (substring prefix (match-end 0) (1- (length prefix))))
3351 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3353 (defun gnus-group-foreign-p (group)
3354 "Return nil if GROUP is native, non-nil if it is foreign."
3355 (string-match ":" group))
3357 (defun gnus-group-set-info (info &optional method-only-group part)
3358 (let* ((entry (gnus-gethash
3359 (or method-only-group (car info)) gnus-newsrc-hashtb))
3361 (info (if method-only-group (nth 2 entry) info)))
3362 (if (not method-only-group)
3365 (error "Trying to change non-existent group %s" method-only-group))
3366 ;; We have recevied parts of the actual group info - either the
3367 ;; select method or the group parameters. We first check
3368 ;; whether we have to extend the info, and if so, do that.
3369 (let ((len (length info))
3370 (total (if (eq part 'method) 5 6)))
3372 (setcdr (nthcdr (1- len) info)
3373 (make-list (- total len) nil)))
3374 ;; Then we enter the new info.
3375 (setcar (nthcdr (1- total) info) part-info)))
3376 ;; We uncompress some lists of marked articles.
3378 (if (not (setq marked (nth 3 info)))
3381 (or (eq 'score (car (car marked)))
3382 (eq 'bookmark (car (car marked)))
3383 (eq 'killed (car (car marked)))
3384 (setcdr (car marked)
3385 (gnus-uncompress-range (cdr (car marked)))))
3386 (setq marked (cdr marked)))))
3389 ;; This is a new group, so we just create it.
3391 (set-buffer gnus-group-buffer)
3393 ;; It's a foreign group...
3394 (gnus-group-make-group
3395 (gnus-group-real-name (car info))
3396 (prin1-to-string (car (nth 4 info)))
3397 (nth 1 (nth 4 info)))
3398 ;; It's a native group.
3399 (gnus-group-make-group
3401 (prin1-to-string (car gnus-select-method))
3402 (nth 1 gnus-select-method)))
3403 (gnus-message 6 "Note: New group created")
3405 (gnus-gethash (gnus-group-prefixed-name
3406 (gnus-group-real-name (car info))
3407 (or (nth 4 info) gnus-select-method))
3408 gnus-newsrc-hashtb))))
3409 ;; Whether it was a new group or not, we now have the entry, so we
3410 ;; can do the update.
3413 (setcar (nthcdr 2 entry) info)
3414 (if (and (not (eq (car entry) t))
3415 (gnus-gethash (car info) gnus-active-hashtb))
3416 (let ((marked (nth 3 info)))
3418 (max 0 (- (length (gnus-list-of-unread-articles
3420 (length (cdr (assq 'tick marked)))
3421 (length (cdr (assq 'dormant marked)))))))))
3422 (error "No such group: %s" (car info)))))
3424 (defun gnus-group-set-method-info (group select-method)
3425 (gnus-group-set-info select-method group 'method))
3427 (defun gnus-group-set-params-info (group params)
3428 (gnus-group-set-info params group 'params))
3430 (defun gnus-group-update-group-line ()
3431 "This function updates the current line in the newsgroup buffer and
3432 moves the point to the colon."
3433 (let* ((buffer-read-only nil)
3434 (group (gnus-group-group-name))
3435 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3438 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3441 (delete-region (point) (progn (forward-line 1) (point)))
3442 (gnus-group-insert-group-line-info group)
3444 (gnus-group-position-cursor)))
3446 (defun gnus-group-insert-group-line-info (group)
3447 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3451 (setq info (nth 2 entry))
3452 (gnus-group-insert-group-line
3453 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3454 (setq active (gnus-gethash group gnus-active-hashtb))
3455 (gnus-group-insert-group-line
3457 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3458 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3460 (defun gnus-group-insert-group-line (gformat group level marked number method)
3461 (let* ((gformat (or gformat gnus-group-line-format-spec))
3462 (active (gnus-gethash group gnus-active-hashtb))
3463 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3464 (number-of-dormant (length (cdr (assq 'dormant marked))))
3465 (number-of-ticked (length (cdr (assq 'tick marked))))
3466 (number-of-ticked-and-dormant
3467 (+ number-of-ticked number-of-dormant))
3468 (number-of-unread-unticked
3469 (if (numberp number) (int-to-string (max 0 number))
3472 (if (numberp number)
3473 (max 0 (- number-total number))
3475 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3476 ((<= level gnus-level-unsubscribed) ?U)
3477 ((= level gnus-level-zombie) ?Z)
3479 (qualified-group (gnus-group-real-name group))
3480 (newsgroup-description
3481 (if gnus-description-hashtb
3482 (or (gnus-gethash group gnus-description-hashtb) "")
3484 (moderated (if (member group gnus-moderated-list) ?m ? ))
3485 (moderated-string (if (eq moderated ?m) "(m)" ""))
3486 (method (gnus-server-get-method group method))
3487 (news-server (or (car (cdr method)) ""))
3488 (news-method (or (car method) ""))
3490 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3494 (> number-of-ticked 0))
3496 (number (if (eq number t) "*" (+ number number-of-dormant
3498 (process-marked (if (member qualified-group gnus-group-marked)
3499 gnus-process-mark ? ))
3500 (buffer-read-only nil)
3505 (insert (eval gformat))
3507 (add-text-properties
3508 b (1+ b) (list 'gnus-group (intern group)
3509 'gnus-unread (if (numberp number)
3510 (string-to-int number-of-unread-unticked)
3513 'gnus-level level))))
3515 (defun gnus-group-update-group (group &optional visible-only)
3516 "Update newsgroup info of GROUP.
3517 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3519 (set-buffer gnus-group-buffer)
3520 (let ((buffer-read-only nil)
3522 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3525 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3527 ;; Buffer may be narrowed.
3530 ;; Search a line to modify. If the buffer is large, the search
3531 ;; takes long time. In most cases, current point is on the line
3532 ;; we are looking for. So, first of all, check current line.
3535 (eq (get-text-property (point) 'gnus-group)
3540 (point-min) (point-max) 'gnus-group (intern group)))))
3541 ;; GROUP is listed in current buffer. So, delete old line.
3545 (delete-region (point) (progn (forward-line 1) (point))))
3546 ;; No such line in the buffer, find out where it's supposed to
3547 ;; go, and insert it there (or at the end of the buffer).
3548 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3551 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3557 (point-min) (point-max)
3558 'gnus-group (intern (car (car entry)))))))
3559 (setq entry (cdr entry)))
3560 (or entry (goto-char (point-max)))))))
3561 (if (or visible (not visible-only))
3562 (gnus-group-insert-group-line-info group))
3563 (gnus-group-set-mode-line))))
3565 (defun gnus-group-set-mode-line ()
3566 (if (memq 'group gnus-updated-mode-lines)
3567 (let* ((gformat (or gnus-group-mode-line-format-spec
3568 (setq gnus-group-mode-line-format-spec
3570 gnus-group-mode-line-format
3571 gnus-group-mode-line-format-alist))))
3572 (news-server (car (cdr gnus-select-method)))
3573 (news-method (car gnus-select-method))
3575 (mode-string (eval gformat)))
3576 (setq mode-string (eval gformat))
3577 (if (> (length mode-string) max-len)
3578 (setq mode-string (substring mode-string 0 (- max-len 4))))
3579 (setq mode-line-buffer-identification mode-string)
3580 (set-buffer-modified-p t))))
3582 (defun gnus-group-group-name ()
3583 "Get the name of the newsgroup on the current line."
3584 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3585 (and group (symbol-name group))))
3587 (defun gnus-group-group-level ()
3588 "Get the level of the newsgroup on the current line."
3589 (get-text-property (gnus-point-at-bol) 'gnus-level))
3591 (defun gnus-group-group-unread ()
3592 "Get the number of unread articles of the newsgroup on the current line."
3593 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3595 (defun gnus-group-search-forward (&optional backward all level first-too)
3596 "Find the next newsgroup with unread articles.
3597 If BACKWARD is non-nil, find the previous newsgroup instead.
3598 If ALL is non-nil, just find any newsgroup.
3599 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3601 If FIRST-TOO, the current line is also eligible as a target."
3602 (let ((way (if backward -1 1))
3606 (if (and backward (progn (beginning-of-line)) (bobp))
3608 (or first-too (forward-line way))
3616 (get-text-property (point) 'gnus-unread)))
3617 (or (eq unread t) (and unread (> unread 0))))
3618 (let ((lev (get-text-property
3619 (point) 'gnus-level)))
3620 (and lev (<= (get-text-property
3621 (point) 'gnus-level)
3622 gnus-level-subscribed)))))
3624 (let ((lev (get-text-property (point) 'gnus-level)))
3625 (if (and lev (<= lev level))
3630 (setq pos (point))))
3632 (zerop (forward-line way)))))
3634 (progn (gnus-group-position-cursor) t)
3635 (if pos (goto-char pos) (goto-char beg))
3638 ;;; Gnus group mode commands
3642 (defun gnus-group-mark-group (n &optional unmark no-advance)
3643 "Mark the current group."
3645 (let ((buffer-read-only nil)
3649 (setq group (gnus-group-group-name))
3657 (setq gnus-group-marked (delete group gnus-group-marked)))
3659 (setq gnus-group-marked
3660 (cons group (delete group gnus-group-marked))))
3662 (or no-advance (zerop (gnus-group-next-group 1))))
3664 (gnus-summary-position-cursor)
3667 (defun gnus-group-unmark-group (n)
3668 "Remove the mark from the current group."
3670 (gnus-group-mark-group n 'unmark))
3672 (defun gnus-group-mark-region (unmark beg end)
3673 "Mark all groups between point and mark.
3674 If UNMARK, remove the mark instead."
3675 (interactive "P\nr")
3676 (let ((num (count-lines beg end)))
3679 (- num (gnus-group-mark-group num unmark)))))
3681 (defun gnus-group-remove-mark (group)
3682 (and (gnus-group-goto-group group)
3684 (gnus-group-mark-group 1 'unmark t))))
3686 ;; Return a list of groups to work on. Take into consideration N (the
3687 ;; prefix) and the list of marked groups.
3688 (defun gnus-group-process-prefix (n)
3690 (setq n (prefix-numeric-value n))
3691 ;; There is a prefix, so we return a list of the N next
3693 (let ((way (if (< n 0) -1 1))
3698 (setq group (gnus-group-group-name)))
3699 (setq groups (cons group groups))
3701 (forward-line way)))
3704 ;; No prefix, but a list of marked articles.
3705 (reverse gnus-group-marked))
3707 ;; Neither marked articles or a prefix, so we return the
3709 (let ((group (gnus-group-group-name)))
3710 (and group (list group))))))
3712 ;; Selecting groups.
3714 (defun gnus-group-read-group (all &optional no-article group)
3715 "Read news in this newsgroup.
3716 If argument ALL is non-nil, already read articles become readable.
3717 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3719 (let ((group (or group (gnus-group-group-name)))
3720 number active marked entry)
3721 (or group (error "No group on current line"))
3723 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3724 ;; This group might be a dead group. In that case we have to get
3725 ;; the number of unread articles from `gnus-active-hashtb'.
3727 (setq number (car entry))
3728 (if (setq active (gnus-gethash group gnus-active-hashtb))
3729 (setq number (- (1+ (cdr active)) (car active)))))
3730 (gnus-summary-read-group
3731 group (or all (and (numberp number)
3732 (zerop (+ number (length (cdr (assq 'tick marked)))
3733 (length (cdr (assq 'dormant marked)))))))
3736 (defun gnus-group-select-group (all)
3737 "Select this newsgroup.
3738 No article is selected automatically.
3739 If argument ALL is non-nil, already read articles become readable."
3741 (gnus-group-read-group all t))
3743 ;; Enter a group that is not in the group buffer. Non-nil is returned
3744 ;; if selection was successful.
3745 (defun gnus-group-read-ephemeral-group
3746 (group method &optional activate quit-config)
3747 (let ((group (if (gnus-group-foreign-p group) group
3748 (gnus-group-prefixed-name group method))))
3751 (list t nil (list group gnus-level-default-subscribed nil nil
3755 (if quit-config quit-config
3756 (cons (current-buffer) 'summary)))))))
3758 (set-buffer gnus-group-buffer)
3759 (or (gnus-server-opened method)
3760 (gnus-open-server method)
3761 (error "Unable to contact server: %s" (gnus-status-message method)))
3762 (if activate (gnus-request-group group))
3764 (gnus-group-read-group t t group)
3767 (not (equal major-mode 'gnus-group-mode))))
3769 (defun gnus-group-jump-to-group (group)
3770 "Jump to newsgroup GROUP."
3772 (list (completing-read
3773 "Group: " gnus-active-hashtb nil (not (not gnus-read-active-file)))))
3775 (if (equal group "")
3776 (error "Empty group name"))
3778 (let ((b (text-property-any
3779 (point-min) (point-max) 'gnus-group (intern group))))
3781 ;; Either go to the line in the group buffer...
3783 ;; ... or insert the line.
3785 (gnus-gethash group gnus-active-hashtb)
3786 (gnus-activate-newsgroup group)
3787 (error "%s error: %s" group (gnus-status-message group)))
3789 (gnus-group-update-group group)
3790 (goto-char (text-property-any
3791 (point-min) (point-max) 'gnus-group (intern group)))))
3792 ;; Adjust cursor point.
3793 (gnus-group-position-cursor))
3795 (defun gnus-group-goto-group (group)
3796 "Goto to newsgroup GROUP."
3797 (let ((b (text-property-any (point-min) (point-max)
3798 'gnus-group (intern group))))
3799 (and b (goto-char b))))
3801 (defun gnus-group-next-group (n)
3802 "Go to next N'th newsgroup.
3803 If N is negative, search backward instead.
3804 Returns the difference between N and the number of skips actually
3807 (gnus-group-next-unread-group n t))
3809 (defun gnus-group-next-unread-group (n &optional all level)
3810 "Go to next N'th unread newsgroup.
3811 If N is negative, search backward instead.
3812 If ALL is non-nil, choose any newsgroup, unread or not.
3813 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3814 such group can be found, the next group with a level higher than
3816 Returns the difference between N and the number of skips actually
3819 (let ((backward (< n 0))
3822 (gnus-group-search-forward
3823 backward (or (not gnus-group-goto-unread) all) level))
3825 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3826 (if level " on this level or higher" "")))
3829 (defun gnus-group-prev-group (n)
3830 "Go to previous N'th newsgroup.
3831 Returns the difference between N and the number of skips actually
3834 (gnus-group-next-unread-group (- n) t))
3836 (defun gnus-group-prev-unread-group (n)
3837 "Go to previous N'th unread newsgroup.
3838 Returns the difference between N and the number of skips actually
3841 (gnus-group-next-unread-group (- n)))
3843 (defun gnus-group-next-unread-group-same-level (n)
3844 "Go to next N'th unread newsgroup on the same level.
3845 If N is negative, search backward instead.
3846 Returns the difference between N and the number of skips actually
3849 (gnus-group-next-unread-group n t (gnus-group-group-level))
3850 (gnus-group-position-cursor))
3852 (defun gnus-group-prev-unread-group-same-level (n)
3853 "Go to next N'th unread newsgroup on the same level.
3854 Returns the difference between N and the number of skips actually
3857 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3858 (gnus-group-position-cursor))
3860 (defun gnus-group-best-unread-group (&optional exclude-group)
3861 "Go to the group with the highest level.
3862 If EXCLUDE-GROUP, do not go to that group."
3864 (goto-char (point-min))
3867 (while (setq unread (get-text-property (point) 'gnus-unread))
3868 (if (and (numberp unread) (> unread 0))
3870 (if (and (< (get-text-property (point) 'gnus-level) best)
3871 (or (not exclude-group)
3872 (not (equal exclude-group (gnus-group-group-name)))))
3874 (setq best (get-text-property (point) 'gnus-level))
3875 (setq best-point (point))))))
3877 (if best-point (goto-char best-point))
3878 (gnus-summary-position-cursor)
3879 (and best-point (gnus-group-group-name))))
3881 (defun gnus-group-first-unread-group ()
3882 "Go to the first group with unread articles."
3884 (goto-char (point-min))
3885 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3886 (gnus-group-next-unread-group 1))
3887 (gnus-group-position-cursor))
3889 (defun gnus-group-enter-server-mode ()
3890 "Jump to the server buffer."
3892 (gnus-server-setup-buffer)
3893 (gnus-configure-windows 'server)
3894 (gnus-server-prepare))
3896 (defun gnus-group-make-group (name method &optional address)
3897 "Add a new newsgroup.
3898 The user will be prompted for a NAME, for a select METHOD, and an
3902 (read-string "Group name: ")
3905 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3907 (if (assoc method gnus-valid-select-methods)
3909 (if (memq 'prompt-address
3910 (assoc method gnus-valid-select-methods))
3911 (read-string "Address: ")
3913 (list method nil)))))
3915 (let* ((meth (if address (list (intern method) address) method))
3916 (nname (gnus-group-prefixed-name name meth))
3918 (and (gnus-gethash nname gnus-newsrc-hashtb)
3919 (error "Group %s already exists" nname))
3920 (gnus-group-change-level
3921 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3922 gnus-level-default-subscribed gnus-level-killed
3923 (and (gnus-group-group-name)
3924 (gnus-gethash (gnus-group-group-name)
3925 gnus-newsrc-hashtb))
3927 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
3929 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3930 (gnus-group-insert-group-line-info nname)
3932 (require (intern method))
3933 (and (gnus-check-backend-function 'request-create-group nname)
3934 (gnus-request-create-group nname))))
3936 (defun gnus-group-edit-group (group &optional part)
3937 "Edit the group on the current line."
3938 (interactive (list (gnus-group-group-name)))
3939 (let ((done-func '(lambda ()
3940 "Exit editing mode and update the information."
3942 (gnus-group-edit-group-done 'part 'group)))
3943 (part (or part 'info))
3944 (winconf (current-window-configuration))
3946 (or group (error "No group on current line"))
3947 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3948 (error "Killed group; can't be edited"))
3949 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3950 (gnus-configure-windows 'edit-group)
3951 (gnus-add-current-to-buffer-list)
3953 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3954 (use-local-map (copy-keymap emacs-lisp-mode-map))
3955 (local-set-key "\C-c\C-c" done-func)
3956 (make-local-variable 'gnus-prev-winconf)
3957 (setq gnus-prev-winconf winconf)
3958 ;; We modify the func to let it know what part it is editing.
3959 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3960 (setcar (cdr (cdr (nth 4 done-func))) group)
3965 ";; Type `C-c C-c' after editing the select method.\n\n")
3967 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3969 ";; Type `C-c C-c' after editing the group info.\n\n")))
3970 (let ((cinfo (gnus-copy-sequence info))
3972 (if (not (setq marked (nth 3 cinfo)))
3975 (or (eq 'score (car (car marked)))
3976 (eq 'bookmark (car (car marked)))
3977 (eq 'killed (car (car marked)))
3978 (not (numberp (car (cdr (car marked)))))
3979 (setcdr (car marked)
3980 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3981 (setq marked (cdr marked))))
3984 (cond ((eq part 'method)
3985 (or (nth 4 info) "native"))
3992 (defun gnus-group-edit-group-method (group)
3993 "Edit the select method of GROUP."
3994 (interactive (list (gnus-group-group-name)))
3995 (gnus-group-edit-group group 'method))
3997 (defun gnus-group-edit-group-parameters (group)
3998 "Edit the group parameters of GROUP."
3999 (interactive (list (gnus-group-group-name)))
4000 (gnus-group-edit-group group 'params))
4002 (defun gnus-group-edit-group-done (part group)
4003 "Get info from buffer, update variables and jump to the group buffer."
4004 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4005 (goto-char (point-min))
4006 (let ((form (read (current-buffer)))
4007 (winconf gnus-prev-winconf))
4009 (gnus-group-set-info form)
4010 (gnus-group-set-info form group part))
4011 (kill-buffer (current-buffer))
4012 (and winconf (set-window-configuration winconf))
4013 (set-buffer gnus-group-buffer)
4014 (gnus-group-update-group (gnus-group-group-name))
4015 (gnus-group-position-cursor)))
4017 (defun gnus-group-make-help-group ()
4018 "Create the (ding) Gnus documentation group."
4020 (let ((path load-path)
4022 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4023 "gnus-help" '(nndoc "gnus-help")))
4025 (error "Documentation group already exists"))
4027 (not (file-exists-p (concat (file-name-as-directory (car path))
4029 (setq path (cdr path)))
4030 (or path (error "Couldn't find doc group"))
4031 (gnus-group-make-group
4032 (gnus-group-real-name name)
4034 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4035 (list 'nndoc-article-type 'mbox))))
4036 (gnus-group-position-cursor))
4038 (defun gnus-group-make-doc-group (file type)
4039 "Create a group that uses a single file as the source."
4041 (list (read-file-name "File name: ")
4045 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4046 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4047 ((= char ?b) 'babyl)
4048 ((= char ?d) 'digest)
4049 (t (setq err "%c unknown. " char)
4052 (let* ((file (expand-file-name file))
4053 (name (gnus-generate-new-group-name
4054 (gnus-group-prefixed-name
4055 (file-name-nondirectory file) '(nndoc "")))))
4056 (gnus-group-make-group
4057 (gnus-group-real-name name)
4059 (list 'nndoc-address file)
4060 (list 'nndoc-article-type type)))))
4062 (defun gnus-group-make-archive-group ()
4063 "Create the (ding) Gnus archive group."
4065 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
4067 (error "Archive group already exists"))
4068 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
4069 (gnus-group-position-cursor))
4071 (defun gnus-group-make-directory-group (dir)
4072 "Create an nndir group.
4073 The user will be prompted for a directory. The contents of this
4074 directory will be used as a newsgroup. The directory should contain
4075 mail messages or news articles in files that have numeric names."
4077 (list (read-file-name "Create group from directory: ")))
4078 (or (file-exists-p dir) (error "No such directory"))
4079 (or (file-directory-p dir) (error "Not a directory"))
4080 (gnus-group-make-group dir "nndir" dir)
4081 (gnus-group-position-cursor))
4083 (defun gnus-group-make-kiboze-group (group address scores)
4084 "Create an nnkiboze group.
4085 The user will be prompted for a name, a regexp to match groups, and
4086 score file entries for articles to include in the group."
4089 (read-string "nnkiboze group name: ")
4090 (read-string "Source groups (regexp): ")
4091 (let ((headers (mapcar (lambda (group) (list group))
4092 '("subject" "from" "number" "date" "message-id"
4093 "references" "chars" "lines" "xref")))
4094 scores header regexp regexps)
4095 (while (not (equal "" (setq header (completing-read
4096 "Match on header: " headers nil t))))
4098 (while (not (equal "" (setq regexp (read-string
4099 (format "Match on %s (string): "
4101 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4102 (setq scores (cons (cons header regexps) scores)))
4104 (gnus-group-make-group group "nnkiboze" address)
4106 (gnus-set-work-buffer)
4107 (let (emacs-lisp-mode-hook)
4108 (pp scores (current-buffer)))
4109 (write-region (point-min) (point-max)
4110 (concat (or gnus-kill-files-directory "~/News")
4111 "nnkiboze:" group "." gnus-score-file-suffix)))
4112 (gnus-group-position-cursor))
4114 (defun gnus-group-add-to-virtual (n vgroup)
4115 "Add the current group to a virtual group."
4117 (list current-prefix-arg
4118 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4120 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4121 (error "%s is not an nnvirtual group" vgroup))
4122 (let* ((groups (gnus-group-process-prefix n))
4123 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4124 (setcar (cdr method)
4126 (nth 1 method) "\\|"
4129 (gnus-group-remove-mark s)
4130 (concat "\\(^" (regexp-quote s) "$\\)"))
4132 (gnus-group-position-cursor))
4134 (defun gnus-group-make-empty-virtual (group)
4135 "Create a new, fresh, empty virtual group."
4136 (interactive "sCreate new, empty virtual group: ")
4137 (let* ((method (list 'nnvirtual "^$"))
4138 (pgroup (gnus-group-prefixed-name group method)))
4139 ;; Check whether it exists already.
4140 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4141 (error "Group %s already exists." pgroup))
4142 ;; Subscribe the new group after the group on the current line.
4143 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4144 (gnus-group-update-group pgroup)
4146 (gnus-group-position-cursor)))
4148 (defun gnus-group-enter-directory (dir)
4149 "Enter an ephemeral nneething group."
4150 (interactive "DDirectory to read: ")
4151 (let* ((method (list 'nneething dir))
4152 (leaf (gnus-group-prefixed-name
4153 (file-name-nondirectory (directory-file-name dir))
4155 (name (gnus-generate-new-group-name leaf)))
4156 (let ((nneething-read-only t))
4157 (or (gnus-group-read-ephemeral-group
4159 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4161 (error "Couldn't enter %s" dir)))))
4163 ;; Group sorting commands
4164 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4166 (defun gnus-group-sort-groups ()
4167 "Sort the group buffer using `gnus-group-sort-function'."
4169 (setq gnus-newsrc-alist
4170 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4171 (gnus-make-hashtable-from-newsrc-alist)
4172 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4174 (defun gnus-group-sort-by-alphabet (info1 info2)
4175 (string< (car info1) (car info2)))
4177 (defun gnus-group-sort-by-unread (info1 info2)
4178 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4179 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4180 (< (or (and (numberp n1) n1) 0)
4181 (or (and (numberp n2) n2) 0))))
4183 (defun gnus-group-sort-by-level (info1 info2)
4184 (< (nth 1 info1) (nth 1 info2)))
4186 ;; Group catching up.
4188 (defun gnus-group-catchup-current (n &optional all)
4189 "Mark all articles not marked as unread in current newsgroup as read.
4190 If prefix argument N is numeric, the ARG next newsgroups will be
4191 caught up. If ALL is non-nil, marked articles will also be marked as
4192 read. Cross references (Xref: header) of articles are ignored.
4193 The difference between N and actual number of newsgroups that were
4194 caught up is returned."
4196 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4200 "Do you really want to mark all articles as read? "
4201 "Mark all unread articles as read? "))))
4203 (let ((groups (gnus-group-process-prefix n))
4206 ;; Virtual groups have to be given special treatment.
4207 (let ((method (gnus-find-method-for-group (car groups))))
4208 (if (eq 'nnvirtual (car method))
4209 (nnvirtual-catchup-group
4210 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4211 (gnus-group-remove-mark (car groups))
4213 (gnus-group-goto-group (car groups))
4214 (gnus-group-catchup (car groups) all))
4215 (gnus-group-update-group-line)
4216 (setq ret (1+ ret)))
4217 (setq groups (cdr groups)))
4218 (gnus-group-next-unread-group 1)
4221 (defun gnus-group-catchup-current-all (n)
4222 "Mark all articles in current newsgroup as read.
4223 Cross references (Xref: header) of articles are ignored."
4225 (gnus-group-catchup-current n 'all))
4227 (defun gnus-group-catchup (group &optional all)
4228 "Mark all articles in GROUP as read.
4229 If ALL is non-nil, all articles are marked as read.
4230 The return value is the number of articles that were marked as read,
4231 or nil if no action could be taken."
4232 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4234 (marked (nth 3 (nth 2 entry))))
4235 (if (not (numberp (car entry)))
4236 (gnus-message 1 "Can't catch up; non-active group")
4237 ;; Do the updating only if the newsgroup isn't killed.
4240 (gnus-update-read-articles
4241 group (and (not all) (append (cdr (assq 'tick marked))
4242 (cdr (assq 'dormant marked))))
4243 nil (and (not all) (cdr (assq 'tick marked))))
4245 (setcar (nthcdr 3 (nth 2 entry))
4246 (delq (assq 'dormant marked)
4247 (nth 3 (nth 2 entry)))))))
4250 (defun gnus-group-expire-articles (n)
4251 "Expire all expirable articles in the current newsgroup."
4253 (let ((groups (gnus-group-process-prefix n))
4255 (or groups (error "No groups to expire"))
4257 (setq group (car groups)
4258 groups (cdr groups))
4259 (gnus-group-remove-mark group)
4260 (if (not (gnus-check-backend-function 'request-expire-articles group))
4262 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4263 (expirable (if (memq 'total-expire (nth 5 info))
4264 (cons nil (gnus-list-of-read-articles group))
4265 (assq 'expire (nth 3 info)))))
4268 (gnus-request-expire-articles
4269 (cdr expirable) group))))))))
4271 (defun gnus-group-expire-all-groups ()
4272 "Expire all expirable articles in all newsgroups."
4275 (gnus-message 5 "Expiring...")
4276 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4277 (cdr gnus-newsrc-alist))))
4278 (gnus-group-expire-articles nil)))
4279 (gnus-group-position-cursor)
4280 (gnus-message 5 "Expiring...done"))
4282 (defun gnus-group-set-current-level (n level)
4283 "Set the level of the next N groups to LEVEL."
4284 (interactive "P\nnLevel: ")
4285 (or (and (>= level 1) (<= level gnus-level-killed))
4286 (error "Illegal level: %d" level))
4287 (let ((groups (gnus-group-process-prefix n))
4290 (setq group (car groups)
4291 groups (cdr groups))
4292 (gnus-group-remove-mark group)
4293 (gnus-message 6 "Changed level of %s from %d to %d"
4294 group (gnus-group-group-level) level)
4295 (gnus-group-change-level group level
4296 (gnus-group-group-level))
4297 (gnus-group-update-group-line)))
4298 (gnus-group-position-cursor))
4300 (defun gnus-group-unsubscribe-current-group (n)
4301 "Toggle subscription of the current group.
4302 If given numerical prefix, toggle the N next groups."
4304 (let ((groups (gnus-group-process-prefix n))
4307 (setq group (car groups)
4308 groups (cdr groups))
4309 (gnus-group-remove-mark group)
4310 (gnus-group-unsubscribe-group
4311 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4312 gnus-level-default-unsubscribed
4313 gnus-level-default-subscribed))
4314 (gnus-group-update-group-line))
4315 (gnus-group-next-group 1)))
4317 (defun gnus-group-unsubscribe-group (group &optional level)
4318 "Toggle subscribe from/to unsubscribe GROUP.
4319 New newsgroup is added to .newsrc automatically."
4321 (list (completing-read "Group: " gnus-active-hashtb nil
4322 gnus-have-read-active-file)))
4323 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4325 ;; Toggle subscription flag.
4326 (gnus-group-change-level
4327 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4328 gnus-level-subscribed)
4329 (1+ gnus-level-subscribed)
4330 gnus-level-default-subscribed)))
4331 (gnus-group-update-group group))
4332 ((and (stringp group)
4333 (or (not gnus-have-read-active-file)
4334 (gnus-gethash group gnus-active-hashtb)))
4335 ;; Add new newsgroup.
4336 (gnus-group-change-level
4338 (if level level gnus-level-default-subscribed)
4339 (or (and (member group gnus-zombie-list)
4342 (and (gnus-group-group-name)
4343 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4344 (gnus-group-update-group group))
4345 (t (error "No such newsgroup: %s" group)))
4346 (gnus-group-position-cursor)))
4348 (defun gnus-group-transpose-groups (n)
4349 "Move the current newsgroup up N places.
4350 If given a negative prefix, move down instead. The difference between
4351 N and the number of steps taken is returned."
4353 (or (gnus-group-group-name)
4354 (error "No group on current line"))
4355 (gnus-group-kill-group 1)
4357 (forward-line (- n))
4358 (gnus-group-yank-group)
4359 (gnus-group-position-cursor)))
4361 (defun gnus-group-kill-all-zombies ()
4362 "Kill all zombie newsgroups."
4364 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4365 (setq gnus-zombie-list nil)
4366 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4367 (goto-char (point-min))
4368 (gnus-group-position-cursor))
4370 (defun gnus-group-kill-region (begin end)
4371 "Kill newsgroups in current region (excluding current point).
4372 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4387 (beginning-of-line) ;Important when LINES < 1
4388 (gnus-group-kill-group lines)))
4390 (defun gnus-group-kill-group (n)
4391 "The the next N groups.
4392 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4393 However, only groups that were alive can be yanked; already killed
4394 groups or zombie groups can't be yanked.
4395 The return value is the name of the (last) group that was killed."
4397 (let ((buffer-read-only nil)
4398 (groups (gnus-group-process-prefix n))
4401 (setq group (car groups)
4402 groups (cdr groups))
4403 (gnus-group-remove-mark group)
4404 (setq level (gnus-group-group-level))
4406 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4407 (setq gnus-list-of-killed-groups
4408 (cons (cons (car entry) (nth 2 entry))
4409 gnus-list-of-killed-groups)))
4410 (gnus-group-change-level
4411 (if entry entry group) gnus-level-killed (if entry nil level)))
4412 (gnus-group-position-cursor)
4415 (defun gnus-group-yank-group (&optional arg)
4416 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4417 inserting it before the current newsgroup. The numeric ARG specifies
4418 how many newsgroups are to be yanked. The name of the (last)
4419 newsgroup yanked is returned."
4421 (if (not arg) (setq arg 1))
4422 (let (info group prev)
4423 (while (>= (setq arg (1- arg)) 0)
4424 (if (not (setq info (car gnus-list-of-killed-groups)))
4425 (error "No more newsgroups to yank"))
4426 (setq group (nth 2 info))
4427 ;; Find which newsgroup to insert this one before - search
4428 ;; backward until something suitable is found. If there are no
4429 ;; other newsgroups in this buffer, just make this newsgroup the
4431 (setq prev (gnus-group-group-name))
4432 (gnus-group-change-level
4433 info (nth 2 info) gnus-level-killed
4434 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4436 (gnus-group-insert-group-line-info (nth 1 info))
4437 (setq gnus-list-of-killed-groups
4438 (cdr gnus-list-of-killed-groups)))
4440 (gnus-group-position-cursor)
4443 (defun gnus-group-list-all-groups (arg)
4444 "List all newsgroups with level ARG or lower.
4445 Default is gnus-level-unsubscribed, which lists all subscribed and most
4446 unsubscribed groups."
4448 (setq arg (or arg gnus-level-unsubscribed))
4449 (gnus-group-list-groups arg t))
4451 (defun gnus-group-list-killed ()
4452 "List all killed newsgroups in the group buffer."
4454 (if (not gnus-killed-list)
4455 (gnus-message 6 "No killed groups")
4456 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4457 (goto-char (point-min)))
4458 (gnus-group-position-cursor))
4460 (defun gnus-group-list-zombies ()
4461 "List all zombie newsgroups in the group buffer."
4463 (if (not gnus-zombie-list)
4464 (gnus-message 6 "No zombie groups")
4465 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4466 (goto-char (point-min)))
4467 (gnus-group-position-cursor))
4469 (defun gnus-group-get-new-news (&optional arg)
4470 "Get newly arrived articles.
4471 If ARG is non-nil, it should be a number between one and nine to
4472 specify which levels you are interested in re-scanning."
4474 (run-hooks 'gnus-get-new-news-hook)
4476 (if gnus-group-use-permanent-levels
4478 (setq gnus-group-default-list-level level)
4479 (setq level (or gnus-group-default-list-level
4480 gnus-level-subscribed))))
4481 (if (and gnus-read-active-file (not level))
4483 (gnus-read-active-file)
4484 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
4485 (let ((gnus-read-active-file nil)
4486 (gnus-have-read-active-file (not arg)))
4487 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))))
4488 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels level)
4489 gnus-group-default-list-level
4490 gnus-level-subscribed)
4491 gnus-have-all-newsgroups)))
4493 (defun gnus-group-get-new-news-this-group (n)
4494 "Check for newly arrived news in the current group (and the N-1 next groups).
4495 The difference between N and the number of newsgroup checked is returned.
4496 If N is negative, this group and the N-1 previous groups will be checked."
4498 (let* ((groups (gnus-group-process-prefix n))
4499 (ret (if (numberp n) (- n (length groups)) 0))
4502 (setq group (car groups)
4503 groups (cdr groups))
4504 (gnus-group-remove-mark group)
4505 (or (gnus-get-new-news-in-group group)
4508 (message "%s error: %s" group (gnus-status-message group))
4510 ;; !!! I don't know why the buffer scrolls forward when updating
4511 ;; the first line in the group buffer, but it does. So we set the
4512 ;; window start forcibly.
4513 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4514 (gnus-group-next-unread-group 1 t)
4515 (gnus-summary-position-cursor)
4518 (defun gnus-get-new-news-in-group (group)
4520 (gnus-activate-newsgroup group)
4522 (gnus-get-unread-articles-in-group
4523 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4524 (gnus-gethash group gnus-active-hashtb))
4525 (gnus-group-update-group-line)
4528 (defun gnus-group-fetch-faq (group)
4529 "Fetch the FAQ for the current group."
4530 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4531 (or group (error "No group name given"))
4532 (let ((file (concat gnus-group-faq-directory group)))
4533 (if (not (file-exists-p file))
4534 (error "No such file: %s" file)
4537 (defun gnus-group-describe-group (force &optional group)
4538 "Display a description of the current newsgroup."
4539 (interactive (list current-prefix-arg (gnus-group-group-name)))
4540 (and force (setq gnus-description-hashtb nil))
4541 (let ((method (gnus-find-method-for-group group))
4543 (or group (error "No group name given"))
4544 (and (or (and gnus-description-hashtb
4545 ;; We check whether this group's method has been
4546 ;; queried for a description file.
4548 (gnus-group-prefixed-name "" method)
4549 gnus-description-hashtb))
4550 (setq desc (gnus-group-get-description group))
4551 (gnus-read-descriptions-file method))
4553 (or desc (gnus-gethash group gnus-description-hashtb)
4554 "No description available")))))
4556 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4557 (defun gnus-group-describe-all-groups (force)
4558 "Pop up a buffer with descriptions of all newsgroups."
4560 (and force (setq gnus-description-hashtb nil))
4561 (if (not (or gnus-description-hashtb
4562 (gnus-read-all-descriptions-files)))
4563 (error "Couldn't request descriptions file"))
4564 (let ((buffer-read-only nil)
4570 (insert (format " *: %-20s %s\n" (symbol-name group)
4571 (symbol-value group)))
4572 (add-text-properties
4573 b (1+ b) (list 'gnus-group group
4574 'gnus-unread t 'gnus-marked nil
4575 'gnus-level (1+ gnus-level-subscribed))))
4576 gnus-description-hashtb)
4577 (goto-char (point-min))
4578 (gnus-group-position-cursor)))
4580 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4581 (defun gnus-group-apropos (regexp &optional search-description)
4582 "List all newsgroups that have names that match a regexp."
4583 (interactive "sGnus apropos (regexp): ")
4585 (obuf (current-buffer))
4587 ;; Go through all newsgroups that are known to Gnus.
4590 (and (string-match regexp (symbol-name group))
4591 (setq groups (cons (symbol-name group) groups))))
4593 ;; Go through all descriptions that are known to Gnus.
4594 (if search-description
4597 (and (string-match regexp (symbol-value group))
4598 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4599 (setq groups (cons (symbol-name group) groups))))
4600 gnus-description-hashtb))
4602 (gnus-message 3 "No groups matched \"%s\"." regexp)
4603 ;; Print out all the groups.
4605 (pop-to-buffer "*Gnus Help*")
4606 (buffer-disable-undo (current-buffer))
4608 (setq groups (sort groups 'string<))
4610 ;; Groups may be entered twice into the list of groups.
4611 (if (not (string= (car groups) prev))
4613 (insert (setq prev (car groups)) "\n")
4614 (if (and gnus-description-hashtb
4615 (setq des (gnus-gethash (car groups)
4616 gnus-description-hashtb)))
4617 (insert " " des "\n"))))
4618 (setq groups (cdr groups)))
4619 (goto-char (point-min))))
4620 (pop-to-buffer obuf)))
4622 (defun gnus-group-description-apropos (regexp)
4623 "List all newsgroups that have names or descriptions that match a regexp."
4624 (interactive "sGnus description apropos (regexp): ")
4625 (if (not (or gnus-description-hashtb
4626 (gnus-read-all-descriptions-files)))
4627 (error "Couldn't request descriptions file"))
4628 (gnus-group-apropos regexp t))
4630 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4631 (defun gnus-group-list-matching (level regexp &optional all lowest)
4632 "List all groups with unread articles that match REGEXP.
4633 If the prefix LEVEL is non-nil, it should be a number that says which
4634 level to cut off listing groups.
4635 If ALL, also list groups with no unread articles.
4636 If LOWEST, don't list groups with level lower than LOWEST."
4637 (interactive "P\nsList newsgroups matching: ")
4638 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4639 all (or lowest 1) regexp)
4640 (goto-char (point-min))
4641 (gnus-group-position-cursor))
4643 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4644 "List all groups that match REGEXP.
4645 If the prefix LEVEL is non-nil, it should be a number that says which
4646 level to cut off listing groups.
4647 If LOWEST, don't list groups with level lower than LOWEST."
4648 (interactive "P\nsList newsgroups matching: ")
4649 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4651 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4652 (defun gnus-group-save-newsrc ()
4653 "Save the Gnus startup files."
4655 (gnus-save-newsrc-file))
4657 (defun gnus-group-restart (&optional arg)
4658 "Force Gnus to read the .newsrc file."
4660 (gnus-save-newsrc-file)
4661 (gnus-setup-news 'force)
4662 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4664 (defun gnus-group-read-init-file ()
4665 "Read the Gnus elisp init file."
4667 (gnus-read-init-file))
4669 (defun gnus-group-check-bogus-groups (silent)
4670 "Check bogus newsgroups.
4671 If given a prefix, don't ask for confirmation before removing a bogus
4674 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4675 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4677 (defun gnus-group-edit-global-kill (article &optional group)
4678 "Edit the global kill file.
4679 If GROUP, edit that local kill file instead."
4681 (setq gnus-current-kill-article article)
4682 (gnus-kill-file-edit-file group)
4684 (substitute-command-keys
4685 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4687 (defun gnus-group-edit-local-kill (article group)
4688 "Edit a local kill file."
4689 (interactive (list nil (gnus-group-group-name)))
4690 (gnus-group-edit-global-kill article group))
4692 (defun gnus-group-force-update ()
4693 "Update `.newsrc' file."
4695 (gnus-save-newsrc-file))
4697 (defun gnus-group-suspend ()
4698 "Suspend the current Gnus session.
4699 In fact, cleanup buffers except for group mode buffer.
4700 The hook gnus-suspend-gnus-hook is called before actually suspending."
4702 (run-hooks 'gnus-suspend-gnus-hook)
4703 ;; Kill Gnus buffers except for group mode buffer.
4704 (let ((group-buf (get-buffer gnus-group-buffer)))
4705 ;; Do this on a separate list in case the user does a ^G before we finish
4706 (let ((gnus-buffer-list
4707 (delq group-buf (delq gnus-dribble-buffer
4708 (append gnus-buffer-list nil)))))
4709 (while gnus-buffer-list
4710 (gnus-kill-buffer (car gnus-buffer-list))
4711 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4714 (setq gnus-buffer-list (list group-buf))
4715 (bury-buffer group-buf)
4716 (delete-windows-on group-buf t)))))
4718 (defun gnus-group-clear-dribble ()
4719 "Clear all information from the dribble buffer."
4721 (gnus-dribble-clear))
4723 (defun gnus-group-exit ()
4724 "Quit reading news after updating .newsrc.eld and .newsrc.
4725 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4727 (if (or noninteractive ;For gnus-batch-kill
4728 (zerop (buffer-size)) ;No news is good news.
4729 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4730 (not gnus-interactive-exit) ;Without confirmation
4732 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4734 (if gnus-use-full-window
4735 (delete-other-windows)
4736 (gnus-remove-some-windows))
4737 (run-hooks 'gnus-exit-gnus-hook)
4738 (gnus-offer-save-summaries)
4739 (gnus-save-newsrc-file)
4740 (gnus-close-backends)
4741 (gnus-clear-system))))
4743 (defun gnus-close-backends ()
4744 ;; Send a close request to all backends that support such a request.
4745 (let ((methods gnus-valid-select-methods)
4748 (if (fboundp (setq func (intern (concat (car (car methods))
4749 "-request-close"))))
4751 (setq methods (cdr methods)))))
4753 (defun gnus-group-quit ()
4754 "Quit reading news without updating .newsrc.eld or .newsrc.
4755 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4757 (if (or noninteractive ;For gnus-batch-kill
4758 (zerop (buffer-size))
4759 (not (gnus-server-opened gnus-select-method))
4761 (not gnus-current-startup-file)
4763 (format "Quit reading news without saving %s? "
4764 (file-name-nondirectory gnus-current-startup-file))))
4766 (run-hooks 'gnus-exit-gnus-hook)
4767 (if gnus-use-full-window
4768 (delete-other-windows)
4769 (gnus-remove-some-windows))
4771 (gnus-close-backends)
4772 (gnus-clear-system))))
4774 (defun gnus-offer-save-summaries ()
4775 (let ((buffers (buffer-list)))
4779 ;; We look for buffers with "Summary" in the name.
4780 (string-match "Summary" (or (buffer-name (car buffers)) ""))
4782 (set-buffer (car buffers))
4783 ;; We check that this is, indeed, a summary buffer.
4784 (eq major-mode 'gnus-summary-mode))
4785 ;; We ask the user whether she wants to save the info.
4787 (format "Update summary buffer %s? " (buffer-name)))
4788 ;; We do it by simply exiting.
4789 (gnus-summary-exit))
4790 (setq buffers (cdr buffers))))))
4792 (defun gnus-group-describe-briefly ()
4793 "Give a one line description of the group mode commands."
4796 (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")))
4798 (defun gnus-group-browse-foreign-server (method)
4799 "Browse a foreign news server.
4800 If called interactively, this function will ask for a select method
4801 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4802 If not, METHOD should be a list where the first element is the method
4803 and the second element is the address."
4805 (list (let ((how (completing-read
4807 (append gnus-valid-select-methods gnus-server-alist)
4809 ;; We either got a backend name or a virtual server name.
4810 ;; If the first, we also need an address.
4811 (if (assoc how gnus-valid-select-methods)
4813 ;; Suggested by mapjph@bath.ac.uk.
4816 (mapcar (lambda (server) (list server))
4817 gnus-secondary-servers)))
4818 ;; We got a server name, so we find the method.
4819 (gnus-server-to-method how)))))
4820 (gnus-browse-foreign-server method))
4824 ;;; Browse Server Mode
4827 (defvar gnus-browse-mode-hook nil)
4828 (defvar gnus-browse-mode-map nil)
4829 (put 'gnus-browse-mode 'mode-class 'special)
4831 (if gnus-browse-mode-map
4833 (setq gnus-browse-mode-map (make-keymap))
4834 (suppress-keymap gnus-browse-mode-map)
4835 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4836 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
4837 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4838 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4839 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4840 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4841 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4842 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4843 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4844 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
4845 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4846 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4847 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4848 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4849 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4850 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4851 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4852 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4855 (defvar gnus-browse-current-method nil)
4856 (defvar gnus-browse-return-buffer nil)
4858 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4860 (defun gnus-browse-foreign-server (method &optional return-buffer)
4861 (setq gnus-browse-current-method method)
4862 (setq gnus-browse-return-buffer return-buffer)
4863 (let ((gnus-select-method method)
4865 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4866 (or (gnus-server-opened method)
4867 (gnus-open-server method)
4868 (error "Unable to contact server: %s" (gnus-status-message method)))
4869 (or (gnus-request-list method)
4870 (error "Couldn't request list: %s" (gnus-status-message method)))
4871 (get-buffer-create gnus-browse-buffer)
4872 (gnus-add-current-to-buffer-list)
4873 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4874 (gnus-configure-windows 'browse)
4875 (buffer-disable-undo (current-buffer))
4876 (let ((buffer-read-only nil))
4879 (setq mode-line-buffer-identification
4881 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4883 (set-buffer nntp-server-buffer)
4884 (let ((cur (current-buffer)))
4885 (goto-char (point-min))
4886 (or (string= gnus-ignored-newsgroups "")
4887 (delete-matching-lines gnus-ignored-newsgroups))
4888 (while (re-search-forward
4889 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4890 (goto-char (match-end 1))
4891 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4893 (max 0 (- (1+ (read cur)) (read cur))))
4895 (setq groups (sort groups
4897 (string< (car l1) (car l2)))))
4898 (let ((buffer-read-only nil))
4900 (setq group (car groups))
4902 (format "K%7d: %s\n" (cdr group) (car group)))
4903 (setq groups (cdr groups))))
4904 (switch-to-buffer (current-buffer))
4905 (goto-char (point-min))
4906 (gnus-group-position-cursor)))
4908 (defun gnus-browse-mode ()
4909 "Major mode for browsing a foreign server.
4911 All normal editing commands are switched off.
4913 \\<gnus-browse-mode-map>
4914 The only things you can do in this buffer is
4916 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
4917 The group will be inserted into the group buffer upon exit from this
4920 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
4922 3) `\\[gnus-browse-exit]' to return to the group buffer."
4924 (kill-all-local-variables)
4925 (if gnus-visual (gnus-browse-make-menu-bar))
4926 (setq mode-line-modified "-- ")
4927 (make-local-variable 'mode-line-format)
4928 (setq mode-line-format (copy-sequence mode-line-format))
4929 (and (equal (nth 3 mode-line-format) " ")
4930 (setcar (nthcdr 3 mode-line-format) ""))
4931 (setq major-mode 'gnus-browse-mode)
4932 (setq mode-name "Browse Server")
4933 (setq mode-line-process nil)
4934 (use-local-map gnus-browse-mode-map)
4935 (buffer-disable-undo (current-buffer))
4936 (setq truncate-lines t)
4937 (setq buffer-read-only t)
4938 (run-hooks 'gnus-browse-mode-hook))
4940 (defun gnus-browse-read-group (&optional no-article)
4941 "Enter the group at the current line."
4943 (let ((group (gnus-browse-group-name)))
4944 (or (gnus-group-read-ephemeral-group
4945 group gnus-browse-current-method nil
4946 (cons (current-buffer) 'browse))
4947 (error "Couldn't enter %s" group))))
4949 (defun gnus-browse-select-group ()
4950 "Select the current group."
4952 (gnus-browse-read-group 'no))
4954 (defun gnus-browse-next-group (n)
4955 "Go to the next group."
4959 (gnus-group-position-cursor)))
4961 (defun gnus-browse-prev-group (n)
4962 "Go to the next group."
4964 (gnus-browse-next-group (- n)))
4966 (defun gnus-browse-unsubscribe-current-group (arg)
4967 "(Un)subscribe to the next ARG groups."
4970 (error "No group at current line."))
4971 (let ((ward (if (< arg 0) -1 1))
4973 (while (and (> arg 0)
4975 (gnus-browse-unsubscribe-group)
4976 (zerop (gnus-browse-next-group ward)))
4977 (setq arg (1- arg)))
4978 (gnus-group-position-cursor)
4979 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
4982 (defun gnus-browse-group-name ()
4985 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
4987 (gnus-group-prefixed-name
4988 (buffer-substring (match-beginning 1) (match-end 1))
4989 gnus-browse-current-method))))
4991 (defun gnus-browse-unsubscribe-group ()
4993 (buffer-read-only nil)
4997 (if (= (following-char) ?K) (setq sub t))
4998 (setq group (gnus-browse-group-name))
5003 (gnus-group-change-level
5004 (list t group gnus-level-default-subscribed
5005 nil nil gnus-browse-current-method)
5006 gnus-level-default-subscribed gnus-level-killed
5007 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
5010 (gnus-group-change-level
5011 group gnus-level-killed gnus-level-default-subscribed)
5015 (defun gnus-browse-exit ()
5016 "Quit browsing and return to the group buffer."
5018 (if (eq major-mode 'gnus-browse-mode)
5019 (kill-buffer (current-buffer)))
5020 (if gnus-browse-return-buffer
5021 (gnus-configure-windows 'server)
5022 (gnus-configure-windows 'group)
5023 (gnus-group-list-groups nil)))
5025 (defun gnus-browse-describe-briefly ()
5026 "Give a one line description of the group mode commands."
5029 (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")))
5033 ;;; Gnus summary mode
5036 (defvar gnus-summary-mode-map nil)
5037 (defvar gnus-summary-mark-map nil)
5038 (defvar gnus-summary-mscore-map nil)
5039 (defvar gnus-summary-article-map nil)
5040 (defvar gnus-summary-thread-map nil)
5041 (defvar gnus-summary-goto-map nil)
5042 (defvar gnus-summary-exit-map nil)
5043 (defvar gnus-summary-various-map nil)
5044 (defvar gnus-summary-interest-map nil)
5045 (defvar gnus-summary-sort-map nil)
5046 (defvar gnus-summary-backend-map nil)
5047 (defvar gnus-summary-save-map nil)
5048 (defvar gnus-summary-wash-map nil)
5049 (defvar gnus-summary-help-map nil)
5051 (put 'gnus-summary-mode 'mode-class 'special)
5053 (if gnus-summary-mode-map
5055 (setq gnus-summary-mode-map (make-keymap))
5056 (suppress-keymap gnus-summary-mode-map)
5058 ;; Non-orthogonal keys
5060 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5061 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5062 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5063 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5064 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5065 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5066 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5067 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5068 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5069 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5070 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5071 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5072 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5073 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5074 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5075 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5076 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5077 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5078 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5079 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5080 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5081 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5082 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5083 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5084 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5085 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5086 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5087 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5088 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5089 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5090 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5091 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5092 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5093 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5094 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5095 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5096 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5097 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5098 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5099 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5100 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5101 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5102 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5103 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5104 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5105 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5106 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5107 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5108 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5109 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5110 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5111 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5112 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5113 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5114 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5115 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5116 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5117 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5118 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5119 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5120 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5121 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5122 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5123 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5124 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5125 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5126 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5127 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5128 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5129 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5130 (define-key gnus-summary-mode-map "V" 'gnus-version)
5131 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5132 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5133 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5134 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5135 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5136 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5137 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5138 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5139 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5140 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5141 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5142 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5143 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5144 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5145 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5146 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5147 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5148 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5151 ;; Sort of orthogonal keymap
5152 (define-prefix-command 'gnus-summary-mark-map)
5153 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5154 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5155 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5156 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5157 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5158 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5159 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5160 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5161 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5162 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5163 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5164 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5165 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5166 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5167 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5168 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5169 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5170 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5171 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5172 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5173 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5174 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5175 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5176 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5178 (define-prefix-command 'gnus-summary-mscore-map)
5179 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
5180 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5181 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5182 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5183 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5185 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
5187 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5189 (define-prefix-command 'gnus-summary-goto-map)
5190 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5191 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5192 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5193 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5194 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5195 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5196 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5197 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5198 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5199 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5200 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5201 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5202 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5203 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5206 (define-prefix-command 'gnus-summary-thread-map)
5207 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5208 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5209 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5210 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5211 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5212 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5213 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5214 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5215 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5216 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5217 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5218 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5219 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5220 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5223 (define-prefix-command 'gnus-summary-exit-map)
5224 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5225 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5226 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5227 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5228 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5229 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5230 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5231 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5232 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5233 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5234 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5237 (define-prefix-command 'gnus-summary-article-map)
5238 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5239 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5240 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5241 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5242 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5243 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5244 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5245 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5246 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5247 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5248 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5249 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5250 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
5251 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
5252 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5253 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
5254 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
5255 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5258 (define-prefix-command 'gnus-summary-wash-map)
5259 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5260 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
5261 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
5262 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
5263 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5264 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5265 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
5266 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5267 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5268 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
5269 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
5270 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
5272 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
5273 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
5274 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
5275 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
5276 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
5277 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5280 (define-prefix-command 'gnus-summary-help-map)
5281 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5282 (define-key gnus-summary-help-map "v" 'gnus-version)
5283 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5284 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5285 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5286 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5289 (define-prefix-command 'gnus-summary-backend-map)
5290 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5291 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5292 (define-key gnus-summary-backend-map "\M-\C-e"
5293 'gnus-summary-expire-articles-now)
5294 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5295 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5296 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5297 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5298 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5299 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5300 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5303 (define-prefix-command 'gnus-summary-save-map)
5304 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5305 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5306 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5307 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5308 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5309 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5310 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5311 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5312 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5314 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5316 (define-prefix-command 'gnus-summary-various-map)
5317 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
5318 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
5319 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5320 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5321 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5322 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5323 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5324 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5325 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
5326 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5327 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5329 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
5331 (define-prefix-command 'gnus-summary-sort-map)
5332 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5333 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5334 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5335 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5336 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5337 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5339 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5340 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5346 (defun gnus-summary-mode (&optional group)
5347 "Major mode for reading articles.
5349 All normal editing commands are switched off.
5350 \\<gnus-summary-mode-map>
5351 Each line in this buffer represents one article. To read an
5352 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5353 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5356 You can also post articles and send mail from this buffer. To
5357 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5358 of an article, type `\\[gnus-summary-reply]'.
5360 There are approx. one gazillion commands you can execute in this
5361 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5363 The following commands are available:
5365 \\{gnus-summary-mode-map}"
5367 (if gnus-visual (gnus-summary-make-menu-bar))
5368 (kill-all-local-variables)
5369 (let ((locals gnus-summary-local-variables))
5371 (if (consp (car locals))
5373 (make-local-variable (car (car locals)))
5374 (set (car (car locals)) (eval (cdr (car locals)))))
5375 (make-local-variable (car locals))
5376 (set (car locals) nil))
5377 (setq locals (cdr locals))))
5378 (gnus-make-thread-indent-array)
5379 (gnus-update-format-specifications)
5380 (setq mode-line-modified "-- ")
5381 (make-local-variable 'mode-line-format)
5382 (setq mode-line-format (copy-sequence mode-line-format))
5383 (and (equal (nth 3 mode-line-format) " ")
5384 (setcar (nthcdr 3 mode-line-format) ""))
5385 (setq major-mode 'gnus-summary-mode)
5386 (setq mode-name "Summary")
5387 (make-local-variable 'minor-mode-alist)
5388 (use-local-map gnus-summary-mode-map)
5389 (buffer-disable-undo (current-buffer))
5390 (setq buffer-read-only t) ;Disable modification
5391 (setq truncate-lines t)
5392 (setq selective-display t)
5393 (setq selective-display-ellipses t) ;Display `...'
5394 (setq buffer-display-table gnus-summary-display-table)
5395 (setq gnus-newsgroup-name group)
5396 (run-hooks 'gnus-summary-mode-hook))
5398 (defun gnus-summary-make-display-table ()
5399 ;; Change the display table. Odd characters have a tendency to mess
5400 ;; up nicely formatted displays - we make all possible glyphs
5401 ;; display only a single character.
5403 ;; We start from the standard display table, if any.
5404 (setq gnus-summary-display-table
5405 (or (copy-sequence standard-display-table)
5406 (make-display-table)))
5407 ;; Nix out all the control chars...
5409 (while (>= (setq i (1- i)) 0)
5410 (aset gnus-summary-display-table i [??])))
5411 ;; ... but not newline and cr, of course. (cr is necessary for the
5412 ;; selective display).
5413 (aset gnus-summary-display-table ?\n nil)
5414 (aset gnus-summary-display-table ?\r nil)
5415 ;; We nix out any glyphs over 126 that are not set already.
5417 (while (>= (setq i (1- i)) 127)
5418 ;; Only modify if the entry is nil.
5419 (or (aref gnus-summary-display-table i)
5420 (aset gnus-summary-display-table i [??])))))
5422 (defun gnus-summary-clear-local-variables ()
5423 (let ((locals gnus-summary-local-variables))
5425 (if (consp (car locals))
5426 (and (vectorp (car (car locals)))
5427 (set (car (car locals)) nil))
5428 (and (vectorp (car locals))
5429 (set (car locals) nil)))
5430 (setq locals (cdr locals)))))
5432 (defun gnus-mouse-pick-article (e)
5435 (gnus-summary-next-page nil t))
5437 (defun gnus-summary-setup-buffer (group)
5438 "Initialize summary buffer."
5439 (let ((buffer (concat "*Summary " group "*")))
5440 (if (get-buffer buffer)
5443 (not gnus-newsgroup-begin))
5444 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5445 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5446 (gnus-add-current-to-buffer-list)
5447 (gnus-summary-mode group)
5448 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5449 (setq gnus-newsgroup-name group)
5452 (defun gnus-set-global-variables ()
5453 ;; Set the global equivalents of the summary buffer-local variables
5454 ;; to the latest values they had. These reflect the summary buffer
5455 ;; that was in action when the last article was fetched.
5456 (if (eq major-mode 'gnus-summary-mode)
5458 (setq gnus-summary-buffer (current-buffer))
5459 (let ((name gnus-newsgroup-name)
5460 (marked gnus-newsgroup-marked)
5461 (unread gnus-newsgroup-unreads)
5462 (headers gnus-current-headers)
5463 (score-file gnus-current-score-file))
5465 (set-buffer gnus-group-buffer)
5466 (setq gnus-newsgroup-name name)
5467 (setq gnus-newsgroup-marked marked)
5468 (setq gnus-newsgroup-unreads unread)
5469 (setq gnus-current-headers headers)
5470 (setq gnus-current-score-file score-file))))))
5472 (defun gnus-summary-insert-dummy-line (sformat subject number)
5474 (setq sformat gnus-summary-dummy-line-format-spec))
5478 (insert (eval sformat))
5479 (add-text-properties
5481 (list 'gnus-number number
5482 'gnus-mark gnus-dummy-mark
5485 (defvar gnus-thread-indent-array nil)
5486 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5487 (defun gnus-make-thread-indent-array ()
5489 (if (and gnus-thread-indent-array
5490 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5492 (setq gnus-thread-indent-array (make-vector 201 "")
5493 gnus-thread-indent-array-level gnus-thread-indent-level)
5495 (aset gnus-thread-indent-array n
5496 (make-string (* n gnus-thread-indent-level) ? ))
5499 (defun gnus-summary-insert-line
5500 (sformat header level current unread replied expirable subject-or-nil
5501 &optional dummy score)
5502 (or sformat (setq sformat gnus-summary-line-format-spec))
5503 (let* ((indentation (aref gnus-thread-indent-array level))
5504 (lines (header-lines header))
5505 (score (or score gnus-summary-default-score 0))
5507 (if (or (null gnus-summary-default-score)
5508 (<= (abs (- score gnus-summary-default-score))
5509 gnus-summary-zcore-fuzz)) ?
5510 (if (< score gnus-summary-default-score)
5511 gnus-score-below-mark gnus-score-over-mark)))
5512 (replied (if replied gnus-replied-mark ? ))
5513 (from (header-from header))
5514 (name-address (funcall gnus-extract-address-components from))
5515 (address (car (cdr name-address)))
5516 (name (or (car name-address) (car (cdr name-address))))
5517 (subject (header-subject header))
5518 (number (header-number header))
5519 (opening-bracket (if dummy ?\< ?\[))
5520 (closing-bracket (if dummy ?\> ?\]))
5521 (buffer-read-only nil)
5522 (b (progn (beginning-of-line) (point))))
5523 (or (numberp lines) (setq lines 0))
5524 (insert (eval sformat))
5525 (add-text-properties
5526 b (1+ b) (list 'gnus-number number
5527 'gnus-mark (or unread gnus-unread-mark)
5528 'gnus-level level))))
5530 (defun gnus-summary-update-line (&optional dont-update)
5531 ;; Update summary line after change.
5532 (or (not gnus-summary-default-score)
5533 gnus-summary-inhibit-highlight
5534 (let ((gnus-summary-inhibit-highlight t)
5535 (article (gnus-summary-article-number)))
5538 (if (and gnus-summary-mark-below
5539 (< (gnus-summary-article-score)
5540 gnus-summary-mark-below))
5541 (and (not (memq article gnus-newsgroup-marked))
5542 (not (memq article gnus-newsgroup-dormant))
5543 (memq article gnus-newsgroup-unreads)
5544 (gnus-summary-mark-article nil gnus-low-score-mark))
5545 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5546 (gnus-summary-mark-article nil gnus-unread-mark))))
5548 (run-hooks 'gnus-summary-update-hook))))))
5550 (defun gnus-summary-update-lines (&optional beg end)
5551 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5552 (let ((beg (or beg (point-min)))
5553 (end (or end (point-max))))
5555 (set-buffer gnus-summary-buffer)
5557 (while (and (not (eobp)) (< (point) end))
5558 (gnus-summary-update-line)
5559 (forward-line 1)))))
5561 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5562 ;; Sum up all elements (and sub-elements) in a list.
5566 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5569 (if (> number 1) gnus-not-empty-thread-mark
5570 gnus-empty-thread-mark)
5573 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5574 "Start reading news in newsgroup GROUP.
5575 If SHOW-ALL is non-nil, already read articles are also listed.
5576 If NO-ARTICLE is non-nil, no article is selected initially."
5577 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5578 (let* ((new-group (gnus-summary-setup-buffer group))
5579 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5581 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5584 (gnus-set-global-variables)
5585 (gnus-kill-buffer kill-buffer)
5586 (gnus-configure-windows 'summary)
5587 (gnus-set-mode-line 'summary)
5588 (gnus-summary-position-cursor)
5592 (and (eq major-mode 'gnus-summary-mode)
5593 (not (equal (current-buffer) kill-buffer))
5595 (kill-buffer (current-buffer))
5596 (if (not quit-config)
5598 (set-buffer gnus-group-buffer)
5599 (gnus-group-jump-to-group group)
5600 (gnus-group-next-unread-group 1))
5601 (if (not (buffer-name (car quit-config)))
5602 (gnus-configure-windows 'group)
5603 (set-buffer (car quit-config))
5604 (and (eq major-mode 'gnus-summary-mode)
5605 (gnus-set-global-variables))
5606 (gnus-configure-windows (cdr quit-config))))))
5607 (message "Can't select group")
5609 ((eq did-select 'quit)
5610 (and (eq major-mode 'gnus-summary-mode)
5611 (not (equal (current-buffer) kill-buffer))
5612 (kill-buffer (current-buffer)))
5613 (gnus-kill-buffer kill-buffer)
5614 (if (not quit-config)
5616 (set-buffer gnus-group-buffer)
5617 (gnus-group-jump-to-group group)
5618 (gnus-group-next-unread-group 1))
5619 (if (not (buffer-name (car quit-config)))
5620 (gnus-configure-windows 'group)
5621 (set-buffer (car quit-config))
5622 (and (eq major-mode 'gnus-summary-mode)
5623 (gnus-set-global-variables))
5624 (gnus-configure-windows (cdr quit-config))))
5627 (gnus-set-global-variables)
5628 ;; Save the active value in effect when the group was entered.
5629 (setq gnus-newsgroup-active
5631 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5632 ;; You can change the subjects in this hook.
5633 (run-hooks 'gnus-select-group-hook)
5634 ;; Do score processing.
5635 (and gnus-use-scoring (gnus-possibly-score-headers))
5636 ;; Update the format specifiers.
5637 (gnus-update-format-specifications)
5638 ;; Generate the summary buffer.
5639 (gnus-summary-prepare)
5640 (if (zerop (buffer-size))
5641 (cond (gnus-newsgroup-dormant
5642 (gnus-summary-show-all-dormant))
5643 ((and gnus-newsgroup-scored show-all)
5644 (gnus-summary-show-all-expunged))))
5645 ;; Function `gnus-apply-kill-file' must be called in this hook.
5646 (run-hooks 'gnus-apply-kill-hook)
5647 (if (zerop (buffer-size))
5649 ;; This newsgroup is empty.
5650 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5651 (gnus-message 6 "No unread news")
5652 (gnus-kill-buffer kill-buffer)
5656 ;; (let ((gnus-summary-buffer kill-buffer))
5657 ;; (gnus-configure-windows 'group))))
5658 ;; Hide conversation thread subtrees. We cannot do this in
5659 ;; gnus-summary-prepare-hook since kill processing may not
5660 ;; work with hidden articles.
5661 (and gnus-show-threads
5662 gnus-thread-hide-subtree
5663 (gnus-summary-hide-all-threads))
5664 ;; Show first unread article if requested.
5665 (goto-char (point-min))
5666 (if (and (not no-article)
5667 gnus-auto-select-first
5668 (gnus-summary-first-unread-article))
5670 (gnus-configure-windows 'summary))
5671 (gnus-set-mode-line 'summary)
5672 (gnus-summary-position-cursor)
5673 ;; If in async mode, we send some info to the backend.
5674 (and gnus-newsgroup-async
5675 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5676 (gnus-request-asynchronous
5678 (if (and gnus-asynchronous-article-function
5679 (fboundp gnus-asynchronous-article-function))
5680 (funcall gnus-asynchronous-article-function
5681 gnus-newsgroup-threads)
5682 gnus-newsgroup-threads)))
5683 (gnus-kill-buffer kill-buffer)
5684 (if (not (get-buffer-window gnus-group-buffer))
5686 ;; gotta use windows, because recenter does wierd stuff if
5687 ;; the current buffer ain't the displayed window.
5688 (let ((owin (selected-window)))
5689 (select-window (get-buffer-window gnus-group-buffer))
5690 (and (gnus-group-goto-group group)
5692 (select-window owin))))
5695 (defun gnus-summary-prepare ()
5696 ;; Generate the summary buffer.
5697 (let ((buffer-read-only nil))
5699 (gnus-summary-prepare-threads
5700 (if gnus-show-threads
5701 (gnus-gather-threads
5703 (if (and gnus-summary-expunge-below
5704 (not gnus-fetch-old-headers))
5705 (gnus-make-threads-and-expunge)
5706 (gnus-make-threads))))
5707 gnus-newsgroup-headers)
5709 ;; Erase header retrieval message.
5710 (gnus-summary-update-lines)
5712 ;; Remove the final newline.
5713 ;;(goto-char (point-max))
5715 ;; Call hooks for modifying summary buffer.
5716 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5717 (goto-char (point-min))
5718 (run-hooks 'gnus-summary-prepare-hook)))
5720 (defun gnus-gather-threads (threads)
5721 "Gather threads that have lost their roots."
5722 (if (not gnus-summary-make-false-root)
5724 (let ((hashtb (gnus-make-hashtable 1023))
5727 subject hthread whole-subject)
5730 (setq subject (header-subject (car (car threads)))))
5731 (if gnus-summary-gather-subject-limit
5732 (or (and (numberp gnus-summary-gather-subject-limit)
5733 (> (length subject) gnus-summary-gather-subject-limit)
5735 (substring subject 0
5736 gnus-summary-gather-subject-limit)))
5737 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5738 (setq subject (gnus-simplify-subject-fuzzy subject))))
5739 (setq subject (gnus-simplify-subject-re subject)))
5741 (gnus-gethash subject hashtb))
5743 (or (stringp (car (car hthread)))
5744 (setcar hthread (list whole-subject (car hthread))))
5745 (setcdr (car hthread) (nconc (cdr (car hthread))
5746 (list (car threads))))
5747 (setcdr prev (cdr threads))
5748 (setq threads prev))
5749 (gnus-sethash subject threads hashtb))
5751 (setq threads (cdr threads)))
5754 (defun gnus-make-threads ()
5755 ;; This function takes the dependencies already made by
5756 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5757 ;; through the dependecies in the hash table and finds all the
5758 ;; roots. Roots do not refer back to any valid articles.
5760 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5761 (gnus-build-old-threads))
5764 (if (not (car (symbol-value refs)))
5765 (setq roots (append (cdr (symbol-value refs)) roots))
5766 ;; Ok, these refer back to valid articles, but if
5767 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5768 ;; the root has the same subject as its children. The children
5769 ;; that do not are made into roots and removed from the list
5771 (or gnus-thread-ignore-subject
5772 (let* ((prev (symbol-value refs))
5773 (subject (gnus-simplify-subject-re
5774 (header-subject (car prev))))
5775 (headers (cdr prev)))
5777 (if (not (string= subject
5778 (gnus-simplify-subject-re
5779 (header-subject (car headers)))))
5781 (setq roots (cons (car headers) roots))
5782 (setcdr prev (cdr headers)))
5783 (setq prev headers))
5784 (setq headers (cdr headers)))))))
5785 gnus-newsgroup-dependencies)
5787 (mapcar 'gnus-trim-thread
5789 (mapcar 'gnus-cut-thread
5790 (mapcar 'gnus-make-sub-thread roots))))))
5792 (defun gnus-make-threads-and-expunge ()
5793 ;; This function takes the dependencies already made by
5794 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5795 ;; through the dependecies in the hash table and finds all the
5796 ;; roots. Roots do not refer back to any valid articles.
5797 (let ((default (or gnus-summary-default-score 0))
5798 (below gnus-summary-expunge-below)
5800 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5801 (gnus-build-old-threads))
5804 (if (not (car (symbol-value refs)))
5805 ;; These articles do not refer back to any other articles -
5807 (let ((headers (cdr (symbol-value refs))))
5808 ;; We weed out the low-scored articles.
5810 (if (not (< (or (cdr (assq (header-number (car headers))
5811 gnus-newsgroup-scored)) default)
5814 (setq roots (cons (car headers) roots))
5815 ;; It is below, so we mark it as read.
5816 (setq gnus-newsgroup-unreads
5817 (delq (header-number (car headers))
5818 gnus-newsgroup-unreads)))
5819 (setq headers (cdr headers))))
5820 ;; Ok, these refer back to valid articles, but if
5821 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5822 ;; the root has the same subject as its children. The children
5823 ;; that do not are made into roots and removed from the list
5825 (or gnus-thread-ignore-subject
5826 (let* ((prev (symbol-value refs))
5827 (subject (gnus-simplify-subject-re
5828 (header-subject (car prev))))
5829 (headers (cdr prev)))
5831 (if (not (string= subject
5832 (gnus-simplify-subject-re
5833 (header-subject (car headers)))))
5835 (if (not (< (or (cdr (assq (header-number (car headers))
5836 gnus-newsgroup-scored))
5838 (setq roots (cons (car headers) roots))
5839 (setq gnus-newsgroup-unreads
5840 (delq (header-number (car headers))
5841 gnus-newsgroup-unreads)))
5842 (setcdr prev (cdr headers)))
5843 (setq prev headers))
5844 (setq headers (cdr headers)))))
5845 ;; If this article is expunged, some of the children might be
5847 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
5848 gnus-newsgroup-scored)) default)
5850 (let* ((prev (symbol-value refs))
5851 (headers (cdr prev)))
5853 (setq article (header-number (car headers)))
5854 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5856 (progn (setq roots (cons (car headers) roots))
5857 (setq prev headers))
5858 (setq gnus-newsgroup-unreads
5859 (delq article gnus-newsgroup-unreads))
5860 (setcdr prev (cdr headers)))
5861 (setq headers (cdr headers))))
5862 ;; It was not expunged, but we look at expunged children.
5863 (let* ((prev (symbol-value refs))
5864 (headers (cdr prev))
5867 (setq article (header-number (car headers)))
5868 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5871 (setq gnus-newsgroup-unreads
5872 (delq article gnus-newsgroup-unreads))
5873 (setcdr prev (cdr headers)))
5874 (setq headers (cdr headers)))))))
5875 gnus-newsgroup-dependencies)
5877 (mapcar 'gnus-trim-thread
5879 (mapcar 'gnus-cut-thread
5880 (mapcar 'gnus-make-sub-thread roots))))))
5882 (defun gnus-cut-thread (thread)
5883 ;; Remove leaf dormant or ancient articles from THREAD.
5884 (let ((head (car thread))
5885 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5886 (if (and (null tail)
5887 (let ((number (header-number head)))
5888 (or (memq number gnus-newsgroup-ancient)
5889 (memq number gnus-newsgroup-dormant)
5890 (and gnus-summary-expunge-below
5891 (eq gnus-fetch-old-headers 'some)
5892 (< (or (cdr (assq number gnus-newsgroup-scored))
5893 gnus-summary-default-score 0)
5894 gnus-summary-expunge-below)
5896 (setq gnus-newsgroup-unreads
5897 (delq number gnus-newsgroup-unreads))
5900 (list (cons head tail)))))
5902 (defun gnus-trim-thread (thread)
5903 ;; Remove root ancient articles with only one child from THREAD.
5904 (if (and (eq gnus-fetch-old-headers 'some)
5905 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5906 (= (length thread) 2))
5907 (gnus-trim-thread (nth 1 thread))
5910 (defun gnus-make-sub-thread (root)
5911 ;; This function makes a sub-tree for a node in the tree.
5912 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5913 gnus-newsgroup-dependencies)))))
5914 (cons root (mapcar 'gnus-make-sub-thread children))))
5916 (defun gnus-build-old-threads ()
5917 ;; Look at all the articles that refer back to old articles, and
5918 ;; fetch the headers for the articles that aren't there. This will
5919 ;; build complete threads - if the roots haven't been expired by the
5924 (if (not (car (symbol-value refs)))
5926 (setq heads (cdr (symbol-value refs)))
5928 (if (not (memq (header-number (car heads))
5929 gnus-newsgroup-dormant))
5931 (setq id (symbol-name refs))
5932 (while (and (setq id (gnus-build-get-header id))
5933 (not (car (gnus-gethash
5934 id gnus-newsgroup-dependencies)))))
5936 (setq heads (cdr heads)))))))
5937 gnus-newsgroup-dependencies)))
5939 (defun gnus-build-get-header (id)
5940 ;; Look through the buffer of NOV lines and find the header to
5941 ;; ID. Enter this line into the dependencies hash table, and return
5942 ;; the id of the parent article (if any).
5943 (let ((deps gnus-newsgroup-dependencies)
5947 (set-buffer nntp-server-buffer)
5948 (goto-char (point-min))
5949 (while (and (not found) (search-forward id nil t))
5951 (setq found (looking-at
5952 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5953 (regexp-quote id))))
5954 (or found (beginning-of-line 2)))
5959 (setq header (gnus-nov-parse-line
5960 (read (current-buffer)) deps))
5961 (setq ref (header-references header))
5962 (string-match "\\(<[^>]+>\\) *$" ref)
5963 (substring ref (match-beginning 1) (match-end 1))))))
5965 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5966 gnus-newsgroup-ancient (cons (header-number header)
5967 gnus-newsgroup-ancient))))))
5969 ;; Re-build the thread containing ID.
5970 (defun gnus-rebuild-thread (id)
5971 (let ((dep gnus-newsgroup-dependencies)
5972 (buffer-read-only nil)
5973 parent headers refs thread art)
5974 (while (and id (setq headers
5975 (car (setq art (gnus-gethash (downcase id) dep)))))
5977 (setq id (and (setq refs (header-references headers))
5978 (string-match "\\(<[^>]+>\\) *$" refs)
5979 (substring refs (match-beginning 1) (match-end 1)))))
5980 (setq thread (gnus-make-sub-thread (car parent)))
5981 (gnus-rebuild-remove-articles thread)
5982 (let ((beg (point)))
5983 (gnus-summary-prepare-threads (list thread) 0)
5984 (gnus-summary-update-lines beg (point)))))
5986 ;; Delete all lines in the summary buffer that correspond to articles
5988 (defun gnus-rebuild-remove-articles (thread)
5989 (and (gnus-summary-goto-subject (header-number (car thread)))
5991 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
5993 (defun gnus-sort-threads (threads)
5994 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5995 (let ((fun gnus-thread-sort-functions))
5997 (setq threads (sort threads (car fun))
6001 (defun gnus-thread-header (thread)
6002 ;; Return header of first article in THREAD.
6004 (if (stringp (car thread))
6005 (car (car (cdr thread)))
6009 (defun gnus-thread-sort-by-number (h1 h2)
6010 "Sort threads by root article number."
6011 (let ((h1 (gnus-thread-header h1))
6012 (h2 (gnus-thread-header h2)))
6013 (< (header-number h1) (header-number h2))))
6015 (defun gnus-thread-sort-by-author (h1 h2)
6016 "Sort threads by root author."
6017 (let ((h1 (gnus-thread-header h1))
6018 (h2 (gnus-thread-header h2)))
6020 (let ((extract (funcall
6021 gnus-extract-address-components (header-from h1))))
6022 (or (car extract) (cdr extract)))
6023 (let ((extract (funcall
6024 gnus-extract-address-components (header-from h2))))
6025 (or (car extract) (cdr extract))))))
6027 (defun gnus-thread-sort-by-subject (h1 h2)
6028 "Sort threads by root subject."
6029 (let ((h1 (gnus-thread-header h1))
6030 (h2 (gnus-thread-header h2)))
6032 (downcase (gnus-simplify-subject (header-subject h1)))
6033 (downcase (gnus-simplify-subject (header-subject h2))))))
6035 (defun gnus-thread-sort-by-date (h1 h2)
6036 "Sort threads by root article date."
6037 (let ((h1 (gnus-thread-header h1))
6038 (h2 (gnus-thread-header h2)))
6040 (gnus-sortable-date (header-date h1))
6041 (gnus-sortable-date (header-date h2)))))
6043 (defun gnus-thread-sort-by-score (h1 h2)
6044 "Sort threads by root article score.
6045 Unscored articles will be counted as having a score of zero."
6046 (let ((h1 (gnus-thread-header h1))
6047 (h2 (gnus-thread-header h2)))
6048 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
6049 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
6050 (> (or (cdr s1) gnus-summary-default-score 0)
6051 (or (cdr s2) gnus-summary-default-score 0)))))
6053 (defun gnus-thread-sort-by-total-score (h1 h2)
6054 "Sort threads by the sum of all scores in the thread.
6055 Unscored articles will be counted as having a score of zero."
6056 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6058 (defun gnus-thread-total-score (thread)
6059 ;; This function find the total score of THREAD.
6061 (if (stringp (car thread))
6062 (apply gnus-thread-score-function 0
6063 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6064 (gnus-thread-total-score-1 thread))
6065 (gnus-thread-total-score-1 (list thread))))
6067 (defun gnus-thread-total-score-1 (root)
6068 ;; This function find the total score of the thread below ROOT.
6069 (setq root (car root))
6070 (apply gnus-thread-score-function
6071 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
6072 gnus-summary-default-score 0)
6073 (mapcar 'gnus-thread-total-score
6074 (cdr (gnus-gethash (downcase (header-id root))
6075 gnus-newsgroup-dependencies)))))
6077 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6078 (defvar gnus-tmp-prev-subject "")
6079 (defvar gnus-tmp-adopt-thread nil)
6081 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
6082 (defun gnus-summary-prepare-threads
6083 (threads level &optional not-child no-subject cull)
6084 "Prepare summary buffer from THREADS and indentation LEVEL.
6085 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6086 or a straight list of headers."
6087 (let (thread header number subject clevel)
6089 (setq thread (car threads)
6090 threads (cdr threads))
6091 ;; If `thread' is a cons, hierarchical threads are used. If not,
6092 ;; `thread' is the header.
6094 (setq header (car thread))
6095 (setq header thread)
6097 (or (memq (setq number (header-number header))
6098 gnus-newsgroup-dormant)
6099 (and gnus-summary-expunge-below
6100 (< (or (cdr (assq number gnus-newsgroup-scored))
6101 gnus-summary-default-score 0)
6102 gnus-summary-expunge-below)))
6105 (setq gnus-newsgroup-unreads
6106 (delq number gnus-newsgroup-unreads)))))
6109 ;; The header is a dummy root.
6110 (cond ((eq gnus-summary-make-false-root 'adopt)
6111 ;; We let the first article adopt the rest.
6112 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
6113 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
6114 (setq thread (cdr (cdr thread)))
6116 (gnus-summary-prepare-threads (list (car thread)) 1 t)
6117 (setq thread (cdr thread))))
6118 ((eq gnus-summary-make-false-root 'dummy)
6119 ;; We output a dummy root.
6120 (gnus-summary-insert-dummy-line
6121 nil header (header-number (car (car (cdr thread)))))
6123 ((eq gnus-summary-make-false-root 'empty)
6124 ;; We print the articles with empty subject fields.
6125 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
6126 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
6127 (setq thread (cdr (cdr thread)))
6129 (gnus-summary-prepare-threads
6130 (list (car thread)) 0 nil
6131 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
6133 (gnus-simplify-subject-re
6134 (header-subject (car (car thread))))
6135 (gnus-simplify-subject-re header))))))
6136 (setq thread (cdr thread))))
6138 ;; We do not make a root for the gathered
6139 ;; sub-threads at all.
6141 ;; Print the sub-threads.
6142 (and (consp thread) (cdr thread)
6143 (gnus-summary-prepare-threads (cdr thread) clevel)))
6144 ;; The header is a real article.
6146 (setq number (header-number header)
6147 subject (header-subject header))
6148 (and gnus-newsgroup-async
6149 (setq gnus-newsgroup-threads
6150 (cons (cons (header-number header)
6151 (header-lines header)) gnus-newsgroup-threads)))
6152 (gnus-summary-insert-line
6153 nil header level nil
6154 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6155 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6156 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6157 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6158 (t gnus-ancient-mark))
6159 (memq number gnus-newsgroup-replied)
6160 (memq number gnus-newsgroup-expirable)
6162 gnus-summary-same-subject
6163 (if (or (zerop level)
6164 (and gnus-thread-ignore-subject
6166 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6167 (gnus-simplify-subject-re subject)))))
6169 gnus-summary-same-subject))
6171 (cdr (assq number gnus-newsgroup-scored)))
6172 (setq gnus-tmp-prev-subject subject)
6173 ;; Recursively print subthreads.
6174 (and (consp thread) (cdr thread)
6175 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
6177 (defun gnus-select-newsgroup (group &optional read-all)
6178 "Select newsgroup GROUP.
6179 If READ-ALL is non-nil, all articles in the group are selected."
6180 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6181 (info (nth 2 entry))
6183 (gnus-check-news-server
6184 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6186 (or (gnus-server-opened gnus-current-select-method)
6187 (gnus-open-server gnus-current-select-method)
6188 (error "Couldn't open server"))
6190 (or (and (eq (car entry) t)
6191 (gnus-activate-newsgroup (car info)))
6192 (gnus-request-group group t)
6194 (kill-buffer (current-buffer))
6195 (error "Couldn't request group %s: %s"
6196 group (gnus-status-message group))))
6198 (setq gnus-newsgroup-name group)
6199 (setq gnus-newsgroup-unselected nil)
6200 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6202 (and gnus-asynchronous
6203 (gnus-check-backend-function
6204 'request-asynchronous gnus-newsgroup-name)
6205 (setq gnus-newsgroup-async
6206 (gnus-request-asynchronous gnus-newsgroup-name)))
6208 (setq articles (gnus-articles-to-read group read-all))
6212 (gnus-message 3 "Couldn't select newsgroup")
6214 ((eq articles 0) nil)
6216 ;; Init the dependencies hash table.
6217 (setq gnus-newsgroup-dependencies
6218 (gnus-make-hashtable (length articles)))
6219 ;; Retrieve the headers and read them in.
6220 (setq gnus-newsgroup-headers
6221 (if (eq 'nov (setq gnus-headers-retrieved-by
6222 (gnus-retrieve-headers
6223 (if (and gnus-fetch-old-headers
6224 (not (eq 1 (car articles))))
6227 gnus-newsgroup-name)))
6229 (gnus-get-newsgroup-headers-xover articles))
6230 ;; If we were to fetch old headers, but the backend didn't
6231 ;; support XOVER, then it is possible we fetched one article
6232 ;; that we shouldn't have. If that's the case, we pop it off the
6234 (if (not gnus-fetch-old-headers)
6237 (set-buffer nntp-server-buffer)
6238 (goto-char (point-min))
6239 (and (looking-at "[0-9]+[ \t]+1[ \t]")
6242 (search-forward "\n.\n" nil t)))))
6243 (gnus-get-newsgroup-headers)))
6244 ;; Remove canceled articles from the list of unread articles.
6245 (setq gnus-newsgroup-unreads
6246 (gnus-set-sorted-intersection
6247 gnus-newsgroup-unreads
6248 (mapcar (lambda (headers) (header-number headers))
6249 gnus-newsgroup-headers)))
6250 ;; Adjust and set lists of article marks.
6253 (gnus-adjust-marked-articles info)
6254 (setq gnus-newsgroup-marked
6255 (cdr (assq 'tick (setq marked (nth 3 info)))))
6256 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
6257 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
6258 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
6259 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
6260 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
6261 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
6262 (setq gnus-newsgroup-processable nil)))
6263 ;; Check whether auto-expire is to be done in this group.
6264 (setq gnus-newsgroup-auto-expire
6265 (or (and (stringp gnus-auto-expirable-newsgroups)
6266 (string-match gnus-auto-expirable-newsgroups group))
6267 (memq 'auto-expire (nth 5 info))))
6268 ;; First and last article in this newsgroup.
6269 (and gnus-newsgroup-headers
6270 (setq gnus-newsgroup-begin
6271 (header-number (car gnus-newsgroup-headers)))
6272 (setq gnus-newsgroup-end
6273 (header-number (gnus-last-element gnus-newsgroup-headers))))
6274 (setq gnus-reffed-article-number -1)
6275 ;; GROUP is successfully selected.
6276 (or gnus-newsgroup-headers t)))))
6278 (defun gnus-articles-to-read (group read-all)
6279 ;; Find out what articles the user wants to read.
6281 ;; Select all articles if `read-all' is non-nil, or if all the
6282 ;; unread articles are dormant articles.
6283 (if (or (and read-all (not (numberp read-all)))
6284 (= (length gnus-newsgroup-unreads)
6285 (length gnus-newsgroup-dormant)))
6286 (gnus-uncompress-range
6287 (gnus-gethash group gnus-active-hashtb))
6288 gnus-newsgroup-unreads))
6289 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6290 (scored (length scored-list))
6291 (number (length articles))
6292 (marked (+ (length gnus-newsgroup-marked)
6293 (length gnus-newsgroup-dormant)))
6300 (cond ((and (or (<= scored marked)
6302 (numberp gnus-large-newsgroup)
6303 (> number gnus-large-newsgroup))
6307 "How many articles from %s (default %d): "
6308 gnus-newsgroup-name number))))
6309 (if (string-match "^[ \t]*$" input)
6311 ((and (> scored marked) (< scored number))
6315 "%s %s (%d scored, %d total): "
6316 "How many articles from"
6317 group scored number))))
6318 (if (string-match "^[ \t]*$" input)
6322 (setq select (if (stringp select) (string-to-number select) select))
6323 (if (or (null select) (zerop select))
6325 (if (and (not (zerop scored)) (<= (abs select) scored))
6327 (setq articles (sort scored-list '<))
6328 (setq number (length articles)))
6329 (setq articles (copy-sequence articles)))
6331 (if (< (abs select) number)
6333 ;; Select the N oldest articles.
6334 (setcdr (nthcdr (1- (abs select)) articles) nil)
6335 ;; Select the N most recent articles.
6336 (setq articles (nthcdr (- number select) articles))))
6337 (setq gnus-newsgroup-unselected
6338 (gnus-sorted-intersection
6339 gnus-newsgroup-unreads
6340 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6343 (defun gnus-killed-articles (killed articles)
6346 (if (inline (gnus-member-of-range (car articles) killed))
6347 (setq out (cons (car articles) out)))
6348 (setq articles (cdr articles)))
6351 (defun gnus-adjust-marked-articles (info &optional active)
6352 "Remove all marked articles that are no longer legal."
6353 (let ((marked-lists (nth 3 info))
6354 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6356 ;; There are many types of marked articles.
6358 (setq m (cdr (setq prev (car marked-lists))))
6359 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6360 ;; Make sure that all ticked articles are a subset of the
6361 ;; unread/unselected articles.
6363 (if (or (memq (car m) gnus-newsgroup-unreads)
6364 (memq (car m) gnus-newsgroup-unselected))
6366 (setcdr prev (cdr m)))
6368 ((eq 'score (car prev))
6369 ;; Scored articles should be a subset of
6370 ;; unread/unselected articles.
6372 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6373 (memq (car (car m)) gnus-newsgroup-unreads))
6375 (setcdr prev (cdr m)))
6377 ((eq 'bookmark (car prev))
6378 ;; Bookmarks should be a subset of active articles.
6380 (if (< (car (car m)) (car active))
6381 (setcdr prev (cdr m))
6384 ((eq 'killed (car prev))
6385 ;; Articles that have been through the kill process are
6386 ;; to be a subset of active articles.
6387 (while (and m (< (or (and (numberp (car m)) (car m))
6390 (setcdr prev (cdr m))
6392 (if (and m (< (or (and (numberp (car m)) (car m))
6395 (setcar (if (numberp (car m)) m (car m)) (car active))))
6396 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6397 ;; The replied and expirable articles have to be articles
6400 (if (< (car m) (car active))
6401 (setcdr prev (cdr m))
6404 (setq marked-lists (cdr marked-lists)))
6405 ;; Remove all lists that are empty.
6406 (setq marked-lists (nth 3 info))
6409 (while (= 1 (length (car marked-lists)))
6410 (setq marked-lists (cdr marked-lists)))
6411 (setq m (cdr (setq prev marked-lists)))
6413 (if (= 1 (length (car m)))
6414 (setcdr prev (cdr m))
6417 (setcar (nthcdr 3 info) marked-lists)))
6418 ;; Finally, if there are no marked lists at all left, and if there
6419 ;; are no elements after the lists in the info list, we just chop
6420 ;; the info list off before the marked lists.
6421 (and (null marked-lists)
6422 (not (nthcdr 4 info))
6423 (setcdr (nthcdr 2 info) nil)))
6426 (defun gnus-set-marked-articles
6427 (info ticked replied expirable killed dormant bookmark score)
6428 "Enter the various lists of marked articles into the newsgroup info list."
6430 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6431 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6432 (and expirable (setq newmarked (cons (cons 'expire expirable)
6434 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6435 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6436 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6438 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6441 (setcar (nthcdr 3 info) newmarked)
6442 (and (not newmarked)
6443 (not (nthcdr 4 info))
6444 (setcdr (nthcdr 2 info) nil)))
6446 (setcdr (nthcdr 2 info) (list newmarked))))))
6448 (defun gnus-add-marked-articles (group type articles &optional info force)
6449 ;; Add ARTICLES of TYPE to the info of GROUP.
6450 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6451 ;; add, but replace marked articles of TYPE with ARTICLES.
6452 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6455 (and (not (setq marked (nthcdr 3 info)))
6456 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6457 (and (not (setq m (assq type (car marked))))
6458 (setcar marked (cons (cons type articles) (car marked))))
6461 (nconc m articles)))))
6463 (defun gnus-set-mode-line (where)
6464 "This function sets the mode line of the article or summary buffers.
6465 If WHERE is `summary', the summary mode line format will be used."
6466 (if (memq where gnus-updated-mode-lines)
6469 (set-buffer gnus-summary-buffer)
6470 (let* ((mformat (if (eq where 'article)
6471 gnus-article-mode-line-format-spec
6472 gnus-summary-mode-line-format-spec))
6473 (group-name gnus-newsgroup-name)
6474 (article-number (or gnus-current-article 0))
6475 (unread (- (length gnus-newsgroup-unreads)
6476 (length gnus-newsgroup-dormant)))
6477 (unread-and-unticked
6478 (- unread (length gnus-newsgroup-marked)))
6479 (unselected (length gnus-newsgroup-unselected))
6480 (unread-and-unselected
6481 (cond ((and (zerop unread-and-unticked)
6482 (zerop unselected)) "")
6484 (format "{%d more}" unread-and-unticked))
6485 (t (format "{%d(+%d) more}"
6486 unread-and-unticked unselected))))
6488 (if gnus-current-headers
6489 (header-subject gnus-current-headers) ""))
6490 (max-len (and gnus-mode-non-string-length
6491 (- (frame-width) gnus-mode-non-string-length)))
6492 header) ;; passed as argument to any user-format-funcs
6493 (setq mode-string (eval mformat))
6494 (or (numberp max-len)
6495 (setq max-len (length mode-string)))
6496 (if (< max-len 4) (setq max-len 4))
6497 (if (> (length mode-string) max-len)
6498 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6499 ;; function `substring' might cut on a middle
6500 ;; of multi-octet character.
6502 (concat (gnus-truncate-string mode-string (- max-len 3))
6504 (setq mode-string (format (format "%%-%ds" max-len)
6506 (setq mode-line-buffer-identification mode-string)
6507 (set-buffer-modified-p t))))
6509 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6510 "Go through the HEADERS list and add all Xrefs to a hash table.
6511 The resulting hash table is returned, or nil if no Xrefs were found."
6512 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6514 (gnus-group-foreign-p from-newsgroup)
6516 (assoc (symbol-name (car from-method))
6517 gnus-valid-select-methods))))
6518 (gnus-group-real-prefix from-newsgroup)))
6519 (xref-hashtb (make-vector 63 0))
6520 start group entry number xrefs header)
6522 (setq header (car headers))
6523 (if (and (setq xrefs (header-xref header))
6524 (not (memq (header-number header) unreads)))
6527 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6528 (setq start (match-end 0))
6529 (setq group (concat prefix (substring xrefs (match-beginning 1)
6532 (string-to-int (substring xrefs (match-beginning 2)
6534 (if (setq entry (gnus-gethash group xref-hashtb))
6535 (setcdr entry (cons number (cdr entry)))
6536 (gnus-sethash group (cons number nil) xref-hashtb)))))
6537 (setq headers (cdr headers)))
6538 (if start xref-hashtb nil)))
6540 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6541 "Look through all the headers and mark the Xrefs as read."
6542 (let ((virtual (memq 'virtual
6543 (assoc (symbol-name (car (gnus-find-method-for-group
6545 gnus-valid-select-methods)))
6546 name entry info xref-hashtb idlist method
6549 (set-buffer gnus-group-buffer)
6550 (if (setq xref-hashtb
6551 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6554 (if (string= from-newsgroup (setq name (symbol-name group)))
6556 (setq idlist (symbol-value group))
6557 ;; Dead groups are not updated.
6559 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6561 (if (stringp (setq nth4 (nth 4 info)))
6562 (setq nth4 (gnus-server-to-method nth4))))
6563 ;; Only do the xrefs if the group has the same
6564 ;; select method as the group we have just read.
6565 (or (gnus-methods-equal-p
6566 nth4 (gnus-find-method-for-group from-newsgroup))
6569 (setq method (gnus-find-method-for-group
6571 (and (equal (car nth4) (car method))
6572 (equal (nth 1 nth4) (nth 1 method))))
6573 gnus-use-cross-reference
6574 (or (not (eq gnus-use-cross-reference t))
6576 ;; Only do cross-references on subscribed
6577 ;; groups, if that is what is wanted.
6578 (<= (nth 1 info) gnus-level-subscribed)))
6579 (gnus-group-make-articles-read name idlist expirable))))
6582 (defun gnus-group-make-articles-read (group articles expirable)
6584 (entry (gnus-gethash group gnus-newsrc-hashtb))
6585 (info (nth 2 entry))
6586 (active (gnus-gethash group gnus-active-hashtb))
6587 exps expirable range)
6588 ;; First peel off all illegal article numbers.
6590 (let ((ids articles)
6591 (ticked (cdr (assq 'tick (nth 3 info))))
6592 (dormant (cdr (assq 'dormant (nth 3 info))))
6597 (if (or (> id (cdr active))
6601 (setq articles (delq id articles)))
6602 (and (memq id expirable)
6603 (setq exps (cons id exps)))
6604 (setq ids (cdr ids)))))
6605 ;; Update expirable articles.
6606 (gnus-add-marked-articles nil 'expirable exps info)
6610 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6611 (setcar (nthcdr 2 info)
6615 (setq articles (sort articles '<)))))
6616 ;; Then we have to re-compute how many unread
6617 ;; articles there are in this group.
6622 (setq num (- (1+ (cdr active)) (car active))))
6623 ((not (listp (cdr range)))
6624 (setq num (- (cdr active) (- (1+ (cdr range))
6628 (if (numberp (car range))
6630 (setq num (+ num (- (1+ (cdr (car range)))
6631 (car (car range))))))
6632 (setq range (cdr range)))
6633 (setq num (- (cdr active) num))))
6634 ;; Update the number of unread articles.
6638 (length (cdr (assq 'tick (nth 3 info))))
6640 (cdr (assq 'dormant (nth 3 info)))))))
6641 ;; Update the group buffer.
6642 (gnus-group-update-group group t)))))
6644 (defun gnus-methods-equal-p (m1 m2)
6645 (let ((m1 (or m1 gnus-select-method))
6646 (m2 (or m2 gnus-select-method)))
6648 (and (eq (car m1) (car m2))
6649 (or (not (memq 'address (assoc (symbol-name (car m1))
6650 gnus-valid-select-methods)))
6651 (equal (nth 1 m1) (nth 1 m2)))))))
6653 (defsubst gnus-header-value ()
6654 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6656 (defvar gnus-newsgroup-none-id 0)
6658 (defun gnus-get-newsgroup-headers ()
6659 (setq gnus-article-internal-prepare-hook nil)
6660 (let ((cur nntp-server-buffer)
6661 (dependencies gnus-newsgroup-dependencies)
6662 headers id dep end ref)
6664 (set-buffer nntp-server-buffer)
6665 (goto-char (point-min))
6666 ;; Search to the beginning of the next header. Error messages
6667 ;; do not begin with 2 or 3.
6668 (while (re-search-forward "^[23][0-9]+ " nil t)
6669 (let ((header (make-vector 9 nil))
6670 (case-fold-search t)
6675 (header-set-number header (read cur))
6676 ;; This implementation of this function, with nine
6677 ;; search-forwards instead of the one re-search-forward and
6678 ;; a case (which basically was the old function) is actually
6679 ;; about twice as fast, even though it looks messier. You
6680 ;; can't have everything, I guess. Speed and elegance
6681 ;; doesn't always come hand in hand.
6683 (narrow-to-region (point) (or (save-excursion
6684 (search-forward "\n.\n" nil t))
6686 (if (search-forward "\nfrom: " nil t)
6687 (header-set-from header (gnus-header-value))
6688 (header-set-from header "(nobody)"))
6690 (if (search-forward "\nsubject: " nil t)
6691 (header-set-subject header (gnus-header-value))
6692 (header-set-subject header "(none)"))
6694 (and (search-forward "\nxref: " nil t)
6695 (header-set-xref header (gnus-header-value)))
6697 (or (numberp (and (search-forward "\nlines: " nil t)
6698 (header-set-lines header (read cur))))
6699 (header-set-lines header 0))
6701 (and (search-forward "\ndate: " nil t)
6702 (header-set-date header (gnus-header-value)))
6704 (if (search-forward "\nmessage-id: " nil t)
6705 (header-set-id header (setq id (gnus-header-value)))
6706 ;; If there was no message-id, we just fake one to make
6707 ;; subsequent routines simpler.
6710 (setq id (concat "none+"
6712 (setq gnus-newsgroup-none-id
6713 (1+ gnus-newsgroup-none-id)))))))
6715 (if (search-forward "\nreferences: " nil t)
6717 (header-set-references header (gnus-header-value))
6718 (setq end (match-end 0))
6725 (search-backward ">" end t)
6728 (search-backward "<" end t)
6730 ;; Get the references from the in-reply-to header if there
6731 ;; ware no references and the in-reply-to header looks
6733 (if (and (search-forward "\nin-reply-to: " nil t)
6734 (setq in-reply-to (gnus-header-value))
6735 (string-match "<[^>]+>" in-reply-to))
6737 (header-set-references
6739 (setq ref (substring in-reply-to (match-beginning 0)
6741 (setq ref (downcase ref)))
6743 ;; We do some threading while we read the headers. The
6744 ;; message-id and the last reference are both entered into
6745 ;; the same hash table. Some tippy-toeing around has to be
6746 ;; done in case an article has arrived before the article
6747 ;; which it refers to.
6748 (if (boundp (setq dep (intern (downcase id) dependencies)))
6749 (if (car (symbol-value dep))
6750 ;; An article with this Message-ID has already
6751 ;; been seen, so we ignore this one, except we add
6752 ;; any additional Xrefs (in case the two articles
6753 ;; came from different servers.
6756 (car (symbol-value dep))
6757 (concat (or (header-xref (car (symbol-value dep))) "")
6758 (or (header-xref header) "")))
6760 (setcar (symbol-value dep) header))
6761 (set dep (list header)))
6764 (if (boundp (setq dep (intern ref dependencies)))
6765 (setcdr (symbol-value dep)
6766 (cons header (cdr (symbol-value dep))))
6767 (set dep (list nil header)))
6768 (setq headers (cons header headers))))
6769 (goto-char (point-max))))))
6770 (nreverse headers)))
6772 ;; The following macros and functions were written by Felix Lee
6773 ;; <flee@cse.psu.edu>.
6775 (defmacro gnus-nov-read-integer ()
6777 (if (= (following-char) ?\t)
6779 (let ((num (condition-case nil (read buffer) (error nil))))
6780 (if (numberp num) num 0)))
6781 (or (eobp) (forward-char 1))))
6783 (defmacro gnus-nov-skip-field ()
6784 '(search-forward "\t" eol 'move))
6786 (defmacro gnus-nov-field ()
6787 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6789 ;; Goes through the xover lines and returns a list of vectors
6790 (defun gnus-get-newsgroup-headers-xover (sequence)
6791 "Parse the news overview data in the server buffer, and return a
6792 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6793 ;; Get the Xref when the users reads the articles since most/some
6794 ;; NNTP servers do not include Xrefs when using XOVER.
6795 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6796 (let ((cur nntp-server-buffer)
6797 (dependencies gnus-newsgroup-dependencies)
6798 number headers header)
6800 (set-buffer nntp-server-buffer)
6801 (goto-char (point-min))
6802 (while (and sequence (not (eobp)))
6803 (setq number (read cur))
6804 (while (and sequence (< (car sequence) number))
6805 (setq sequence (cdr sequence)))
6807 (eq number (car sequence))
6809 (setq sequence (cdr sequence))
6811 (inline (gnus-nov-parse-line number dependencies)))
6812 (setq headers (cons header headers)))))
6814 (setq headers (nreverse headers)))
6817 ;; This function has to be called with point after the article number
6818 ;; on the beginning of the line.
6819 (defun gnus-nov-parse-line (number dependencies)
6821 (eol (gnus-point-at-eol))
6822 (buffer (current-buffer))
6825 ;; overview: [num subject from date id refs chars lines misc]
6826 (narrow-to-region (point) eol)
6833 (gnus-nov-field) ; subject
6834 (gnus-nov-field) ; from
6835 (gnus-nov-field) ; date
6836 (setq id (or (gnus-nov-field)
6839 (setq none (1+ none)))))) ; id
6842 (let ((beg (point)))
6843 (search-forward "\t" eol)
6844 (if (search-backward ">" beg t)
6850 (search-backward "<" beg t)
6853 (gnus-nov-field)) ; refs
6854 (gnus-nov-read-integer) ; chars
6855 (gnus-nov-read-integer) ; lines
6856 (if (= (following-char) ?\n)
6858 (gnus-nov-field)) ; misc
6862 (message "Strange nov line.")
6868 ;; We build the thread tree.
6870 (if (boundp (setq dep (intern (downcase id) dependencies)))
6871 (if (car (symbol-value dep))
6872 ;; An article with this Message-ID has already been seen,
6873 ;; so we ignore this one, except we add any additional
6874 ;; Xrefs (in case the two articles came from different
6878 (car (symbol-value dep))
6879 (concat (or (header-xref (car (symbol-value dep))) "")
6880 (or (header-xref header) "")))
6882 (setcar (symbol-value dep) header))
6883 (set dep (list header))))
6886 (if (boundp (setq dep (intern (or ref "none")
6888 (setcdr (symbol-value dep)
6889 (cons header (cdr (symbol-value dep))))
6890 (set dep (list nil header)))))
6893 (defun gnus-article-get-xrefs ()
6894 "Fill in the Xref value in `gnus-current-headers', if necessary.
6895 This is meant to be called in `gnus-article-internal-prepare-hook'."
6896 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6897 gnus-current-headers)))
6898 (or (not gnus-use-cross-reference)
6900 (and (header-xref headers)
6901 (not (string= (header-xref headers) "")))
6902 (let ((case-fold-search t)
6905 (gnus-narrow-to-headers)
6906 (goto-char (point-min))
6907 (if (or (and (eq (downcase (following-char)) ?x)
6908 (looking-at "Xref:"))
6909 (search-forward "\nXref:" nil t))
6911 (goto-char (1+ (match-end 0)))
6912 (setq xref (buffer-substring (point)
6913 (progn (end-of-line) (point))))
6914 (header-set-xref headers xref))))))))
6916 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6917 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6919 ;; Return a header specified by a NUMBER.
6920 (defun gnus-get-header-by-number (number)
6922 (set-buffer gnus-summary-buffer)
6923 (or gnus-newsgroup-headers-hashtb-by-number
6924 (gnus-make-headers-hashtable-by-number))
6925 (gnus-gethash (int-to-string number)
6926 gnus-newsgroup-headers-hashtb-by-number)))
6928 (defun gnus-make-headers-hashtable-by-number ()
6929 "Make hashtable for the variable gnus-newsgroup-headers by number."
6931 (set-buffer gnus-summary-buffer)
6932 (let ((headers gnus-newsgroup-headers)
6934 (setq gnus-newsgroup-headers-hashtb-by-number
6935 (gnus-make-hashtable (length headers)))
6937 (setq header (car headers))
6938 (gnus-sethash (int-to-string (header-number header))
6939 header gnus-newsgroup-headers-hashtb-by-number)
6940 (setq headers (cdr headers))))))
6942 (defun gnus-more-header-backward ()
6943 "Find new header backward."
6944 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6945 (artnum gnus-newsgroup-begin)
6947 (while (and (not header)
6949 (setq artnum (1- artnum))
6950 (setq header (gnus-read-header artnum)))
6953 (defun gnus-more-header-forward (&optional backward)
6954 "Find new header forward.
6955 If BACKWARD, find new header backward instead."
6957 (gnus-more-header-backward)
6958 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6959 (artnum gnus-newsgroup-end)
6961 (while (and (not header)
6963 (setq artnum (1+ artnum))
6964 (setq header (gnus-read-header artnum)))
6967 (defun gnus-extend-newsgroup (header &optional backward)
6968 "Extend newsgroup selection with HEADER.
6969 Optional argument BACKWARD means extend toward backward."
6971 (let ((artnum (header-number header)))
6972 (setq gnus-newsgroup-headers
6974 (cons header gnus-newsgroup-headers)
6975 (nconc gnus-newsgroup-headers (list header))))
6976 (setq gnus-newsgroup-unselected
6977 (delq artnum gnus-newsgroup-unselected))
6978 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6979 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6981 (defun gnus-summary-work-articles (n)
6982 "Return a list of articles to be worked upon. The prefix argument,
6983 the list of process marked articles, and the current article will be
6984 taken into consideration."
6986 (if (and n (numberp n))
6987 (let ((backward (< n 0))
6991 (setq articles (cons (gnus-summary-article-number)
6993 (gnus-summary-search-forward nil nil backward))
6995 (sort articles (function <)))
6996 (or (reverse gnus-newsgroup-processable)
6997 (list (gnus-summary-article-number))))))
6999 (defun gnus-summary-search-group (&optional backward use-level)
7000 "Search for next unread newsgroup.
7001 If optional argument BACKWARD is non-nil, search backward instead."
7003 (set-buffer gnus-group-buffer)
7004 (if (gnus-group-search-forward
7005 backward nil (if use-level (gnus-group-group-level) nil))
7006 (gnus-group-group-name))))
7008 (defun gnus-summary-best-group (&optional exclude-group)
7009 "Find the name of the best unread group.
7010 If EXCLUDE-GROUP, do not go to this group."
7012 (set-buffer gnus-group-buffer)
7014 (gnus-group-best-unread-group exclude-group))))
7016 (defun gnus-summary-search-subject (&optional backward unread subject)
7017 "Search for article forward.
7018 If BACKWARD is non-nil, search backward.
7019 If UNREAD is non-nil, only unread articles are selected.
7020 If SUBJECT is non-nil, the article which has the same subject will be
7022 (let ((func (if backward 'previous-single-property-change
7023 'next-single-property-change))
7028 (and gnus-summary-check-current unread
7029 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7033 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7036 (setq pos (funcall func (point) 'gnus-number))
7037 (goto-char (if backward (1- pos) pos))
7041 (eq (get-text-property (point) 'gnus-mark)
7044 (and (setq psubject (gnus-summary-subject-string))
7045 (gnus-subject-equal subject psubject))))))
7046 (if backward (if (bobp) nil (forward-char -1) t)
7047 (if (eobp) nil (forward-char 1) t)))))
7049 (progn (goto-char beg) nil)
7051 (get-text-property (point) 'gnus-number)
7052 (gnus-summary-position-cursor)))))
7054 (defun gnus-subject-equal (s1 s2)
7056 ((null gnus-summary-gather-subject-limit)
7057 (equal (gnus-simplify-subject-re s1)
7058 (gnus-simplify-subject-re s2)))
7059 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7060 (equal (gnus-simplify-subject-fuzzy s1)
7061 (gnus-simplify-subject-fuzzy s2)))
7062 ((numberp gnus-summary-gather-subject-limit)
7063 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7064 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7068 (defun gnus-summary-search-forward (&optional unread subject backward)
7069 "Search for article forward.
7070 If UNREAD is non-nil, only unread articles are selected.
7071 If SUBJECT is non-nil, the article which has the same subject will be
7073 If BACKWARD is non-nil, the search will be performed backwards instead."
7074 (gnus-summary-search-subject backward unread subject))
7076 (defun gnus-summary-search-backward (&optional unread subject)
7077 "Search for article backward.
7078 If 1st optional argument UNREAD is non-nil, only unread article is selected.
7079 If 2nd optional argument SUBJECT is non-nil, the article which has
7080 the same subject will be searched for."
7081 (gnus-summary-search-forward unread subject t))
7083 (defun gnus-summary-article-number (&optional number-or-nil)
7084 "The article number of the article on the current line.
7085 If there isn's an article number here, then we return the current
7087 (let* ((number (get-text-property (gnus-point-at-bol) 'gnus-number)))
7088 (if number-or-nil number (or number gnus-current-article))))
7090 (defun gnus-summary-thread-level ()
7091 "The thread level of the article on the current line."
7092 (or (get-text-property (gnus-point-at-bol) 'gnus-level)
7095 (defun gnus-summary-pseudo-article ()
7096 "The thread level of the article on the current line."
7097 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7099 (defun gnus-summary-article-mark ()
7100 "The mark on the current line."
7101 (get-text-property (gnus-point-at-bol) 'gnus-mark))
7103 (defun gnus-summary-subject-string ()
7104 "Return current subject string or nil if nothing."
7105 (let ((article (gnus-summary-article-number))
7108 (setq header (gnus-get-header-by-number article))
7110 (header-subject header))))
7112 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7113 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7114 (defun gnus-summary-article-score ()
7115 "Return current article score."
7116 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7117 gnus-summary-default-score 0))
7119 (defun gnus-summary-recenter ()
7120 "Center point in the summary window.
7121 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7122 displayed, no centering will be performed."
7123 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7124 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7125 (let* ((top (cond ((< (window-height) 4) 0)
7126 ((< (window-height) 7) 1)
7128 (height (1- (window-height)))
7129 (bottom (save-excursion (goto-char (point-max))
7130 (forward-line (- height))
7132 (window (get-buffer-window (current-buffer))))
7134 ;; The user has to want it,
7135 gnus-auto-center-summary
7136 ;; the article buffer must be displayed,
7137 (get-buffer-window gnus-article-buffer)
7138 ;; Set the window start to either `bottom', which is the biggest
7139 ;; possible valid number, or the second line from the top,
7140 ;; whichever is the least.
7142 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7144 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7145 (defun gnus-short-group-name (group &optional levels)
7146 "Collapse GROUP name LEVELS."
7147 (let* ((name "") (foreign "") (depth -1) (skip 1)
7150 (while (string-match "\\." group skip)
7151 (setq skip (match-end 0)
7154 (if (string-match ":" group)
7155 (setq foreign (substring group 0 (match-end 0))
7156 group (substring group (match-end 0))))
7158 (if (and (string-match "\\." group) (> levels 0))
7159 (setq name (concat name (substring group 0 1))
7160 group (substring group (match-end 0))
7162 name (concat name "."))
7163 (setq name (concat foreign name group)
7167 (defun gnus-summary-jump-to-group (newsgroup)
7168 "Move point to NEWSGROUP in group mode buffer."
7169 ;; Keep update point of group mode buffer if visible.
7170 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7171 (save-window-excursion
7172 ;; Take care of tree window mode.
7173 (if (get-buffer-window gnus-group-buffer)
7174 (pop-to-buffer gnus-group-buffer))
7175 (gnus-group-jump-to-group newsgroup))
7177 ;; Take care of tree window mode.
7178 (if (get-buffer-window gnus-group-buffer)
7179 (pop-to-buffer gnus-group-buffer)
7180 (set-buffer gnus-group-buffer))
7181 (gnus-group-jump-to-group newsgroup))))
7183 ;; This function returns a list of article numbers based on the
7184 ;; difference between the ranges of read articles in this group and
7185 ;; the range of active articles.
7186 (defun gnus-list-of-unread-articles (group)
7187 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7188 (active (gnus-gethash group gnus-active-hashtb))
7191 ;; If none are read, then all are unread.
7193 (setq first (car active))
7194 ;; If the range of read articles is a single range, then the
7195 ;; first unread article is the article after the last read
7196 ;; article. Sounds logical, doesn't it?
7197 (if (not (listp (cdr read)))
7198 (setq first (1+ (cdr read)))
7199 ;; `read' is a list of ranges.
7200 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7201 (car (car read)))) 1)
7205 (while (< first nlast)
7206 (setq unread (cons first unread))
7207 (setq first (1+ first))))
7208 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7209 (setq nlast (if (atom (car (cdr read)))
7211 (car (car (cdr read)))))
7212 (setq read (cdr read)))))
7213 ;; And add the last unread articles.
7214 (while (<= first last)
7215 (setq unread (cons first unread))
7216 (setq first (1+ first)))
7217 ;; Return the list of unread articles.
7220 (defun gnus-list-of-read-articles (group)
7221 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7222 (active (gnus-gethash group gnus-active-hashtb)))
7224 (gnus-sorted-complement
7225 (gnus-uncompress-range active)
7226 (gnus-list-of-unread-articles group)))))
7228 ;; Various summary commands
7230 (defun gnus-summary-universal-argument ()
7231 "Perform any operation on all articles marked with the process mark."
7233 (gnus-set-global-variables)
7234 (let ((articles (reverse gnus-newsgroup-processable))
7236 (or articles (error "No articles marked"))
7237 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7238 (error "Undefined key"))
7240 (gnus-summary-goto-subject (car articles))
7241 (command-execute func)
7242 (gnus-summary-remove-process-mark (car articles))
7243 (setq articles (cdr articles)))))
7245 (defun gnus-summary-toggle-truncation (arg)
7246 "Toggle truncation of summary lines.
7247 With arg, turn line truncation on iff arg is positive."
7249 (setq truncate-lines
7250 (if (null arg) (not truncate-lines)
7251 (> (prefix-numeric-value arg) 0)))
7254 (defun gnus-summary-reselect-current-group (all)
7255 "Once exit and then reselect the current newsgroup.
7256 The prefix argument ALL means to select all articles."
7258 (gnus-set-global-variables)
7259 (let ((current-subject (gnus-summary-article-number))
7260 (group gnus-newsgroup-name))
7261 (setq gnus-newsgroup-begin nil)
7262 (gnus-summary-exit t)
7263 ;; We have to adjust the point of group mode buffer because the
7264 ;; current point was moved to the next unread newsgroup by
7266 (gnus-summary-jump-to-group group)
7267 (gnus-group-read-group all t)
7268 (gnus-summary-goto-subject current-subject)))
7270 (defun gnus-summary-rescan-group (all)
7271 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7273 (gnus-set-global-variables)
7274 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7275 (let ((group gnus-newsgroup-name))
7277 (gnus-summary-jump-to-group group)
7279 (set-buffer gnus-group-buffer)
7280 (gnus-group-get-new-news-this-group 1))
7281 (gnus-summary-jump-to-group group)
7282 (gnus-group-read-group all)))
7284 (defun gnus-summary-update-info ()
7285 (let* ((group gnus-newsgroup-name))
7286 (if gnus-newsgroup-kill-headers
7287 (setq gnus-newsgroup-killed
7288 (gnus-compress-sequence
7290 (gnus-set-sorted-intersection
7291 (gnus-uncompress-range gnus-newsgroup-killed)
7292 (setq gnus-newsgroup-unselected
7293 (sort gnus-newsgroup-unselected '<)))
7294 (setq gnus-newsgroup-unreads
7295 (sort gnus-newsgroup-unreads '<))) t)))
7296 (or (listp (cdr gnus-newsgroup-killed))
7297 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7298 (let ((headers gnus-newsgroup-headers))
7299 (gnus-close-group group)
7300 (run-hooks 'gnus-exit-group-hook)
7301 (gnus-update-read-articles
7302 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7303 gnus-newsgroup-marked
7304 t gnus-newsgroup-replied gnus-newsgroup-expirable
7305 gnus-newsgroup-killed gnus-newsgroup-dormant
7306 gnus-newsgroup-bookmarks
7307 (and gnus-save-score gnus-newsgroup-scored))
7308 (and gnus-use-cross-reference
7309 (gnus-mark-xrefs-as-read
7310 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7311 ;; Do adaptive scoring, and possibly save score files.
7312 (and gnus-newsgroup-adaptive
7313 (gnus-score-adaptive))
7314 (and gnus-use-scoring
7315 (fboundp 'gnus-score-save)
7316 (funcall 'gnus-score-save))
7317 ;; Do not switch windows but change the buffer to work.
7318 (set-buffer gnus-group-buffer)
7319 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7320 (gnus-group-update-group group)))))
7322 (defun gnus-summary-exit (&optional temporary)
7323 "Exit reading current newsgroup, and then return to group selection mode.
7324 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7326 (gnus-set-global-variables)
7327 (gnus-kill-save-kill-buffer)
7328 (let* ((group gnus-newsgroup-name)
7329 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7330 gnus-newsgroup-name))))
7332 (buf (current-buffer)))
7333 (gnus-summary-update-info) ; Make all changes in this group permanent.
7335 (run-hooks 'gnus-summary-exit-hook)
7336 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7337 ;; Make sure where I was, and go to next newsgroup.
7338 (set-buffer gnus-group-buffer)
7341 (gnus-group-jump-to-group group)
7342 (gnus-group-next-unread-group 1)))
7345 ;; We set all buffer-local variables to nil. It is unclear why
7346 ;; this is needed, but if we don't, buffer-local variables are
7347 ;; not garbage-collected, it seems. This would the lead to en
7348 ;; ever-growing Emacs.
7350 (gnus-summary-clear-local-variables)
7351 ;; We clear the global counterparts of the buffer-local
7352 ;; variables as well, just to be on the safe side.
7353 (gnus-configure-windows 'group)
7354 (gnus-summary-clear-local-variables)
7355 ;; Return to group mode buffer.
7356 (if (eq mode 'gnus-summary-mode)
7357 (gnus-kill-buffer buf))
7358 (if (get-buffer gnus-article-buffer)
7359 (bury-buffer gnus-article-buffer))
7360 (setq gnus-current-select-method gnus-select-method)
7361 (pop-to-buffer gnus-group-buffer)
7362 (if (not quit-config)
7364 (gnus-group-jump-to-group group)
7365 (gnus-group-next-unread-group 1))
7366 (if (not (buffer-name (car quit-config)))
7367 (gnus-configure-windows 'group)
7368 (set-buffer (car quit-config))
7369 (and (eq major-mode 'gnus-summary-mode)
7370 (gnus-set-global-variables))
7371 (gnus-configure-windows (cdr quit-config)))))))
7373 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7374 (defun gnus-summary-exit-no-update (&optional no-questions)
7375 "Quit reading current newsgroup without updating read article info."
7377 (gnus-set-global-variables)
7378 (let* ((group gnus-newsgroup-name)
7379 (quit-config (nth 1 (assoc 'quit-config
7380 (gnus-find-method-for-group group)))))
7381 (if (or no-questions
7383 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7385 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7386 (gnus-close-group group)
7387 (gnus-summary-clear-local-variables)
7388 (set-buffer gnus-group-buffer)
7389 (gnus-summary-clear-local-variables)
7390 ;; Return to group selection mode.
7391 (gnus-configure-windows 'group)
7392 (if (get-buffer gnus-summary-buffer)
7393 (kill-buffer gnus-summary-buffer))
7394 (if (get-buffer gnus-article-buffer)
7395 (bury-buffer gnus-article-buffer))
7396 (if (equal (gnus-group-group-name) group)
7397 (gnus-group-next-unread-group 1))
7400 (if (not (buffer-name (car quit-config)))
7401 (gnus-configure-windows 'group)
7402 (set-buffer (car quit-config))
7403 (and (eq major-mode 'gnus-summary-mode)
7404 (gnus-set-global-variables))
7405 (gnus-configure-windows (cdr quit-config)))))))))
7407 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7408 (defun gnus-summary-fetch-faq (group)
7409 "Fetch the FAQ for the current group."
7410 (interactive (list gnus-newsgroup-name))
7411 (let ((gnus-faq-buffer
7412 (find-file (concat gnus-group-faq-directory
7413 (gnus-group-real-name group)))))
7414 (and gnus-faq-buffer (gnus-configure-windows 'summary-faq))))
7416 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7417 (defun gnus-summary-describe-group (force)
7418 "Describe the current newsgroup."
7420 (gnus-group-describe-group force gnus-newsgroup-name))
7422 (defun gnus-summary-describe-briefly ()
7423 "Describe summary mode commands briefly."
7426 (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")))
7428 ;; Walking around group mode buffer from summary mode.
7430 (defun gnus-summary-next-group (&optional no-article target-group backward)
7431 "Exit current newsgroup and then select next unread newsgroup.
7432 If prefix argument NO-ARTICLE is non-nil, no article is selected
7433 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7434 previous group instead."
7436 (gnus-set-global-variables)
7437 (let ((current-group gnus-newsgroup-name)
7438 (current-buffer (current-buffer))
7440 ;; First we semi-exit this group to update Xrefs and all variables.
7441 ;; We can't do a real exit, because the window conf must remain
7442 ;; the same in case the user is prompted for info, and we don't
7443 ;; want the window conf to change before that...
7444 (gnus-summary-exit t)
7445 (while (not entered)
7446 ;; Then we find what group we are supposed to enter.
7447 (set-buffer gnus-group-buffer)
7448 (gnus-group-jump-to-group current-group)
7451 (if (eq gnus-keep-same-level 'best)
7452 (gnus-summary-best-group gnus-newsgroup-name)
7453 (gnus-summary-search-group backward gnus-keep-same-level))))
7454 (if (not target-group)
7455 ;; There are no further groups, so we return to the group
7458 (gnus-message 5 "Returning to the group buffer")
7460 (set-buffer current-buffer)
7461 (gnus-summary-exit))
7462 ;; We try to enter the target group.
7463 (gnus-group-jump-to-group target-group)
7464 (if (and (not (zerop (gnus-group-group-unread)))
7465 (gnus-summary-read-group
7466 target-group nil no-article current-buffer))
7468 (setq current-group target-group
7469 target-group nil))))))
7471 (defun gnus-summary-next-group-old (&optional no-article group backward)
7472 "Exit current newsgroup and then select next unread newsgroup.
7473 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7474 If BACKWARD, go to previous group instead."
7476 (gnus-set-global-variables)
7477 (let ((ingroup gnus-newsgroup-name)
7478 (sumbuf (current-buffer))
7480 (set-buffer gnus-group-buffer)
7482 (or (and (numberp (setq num (car (gnus-gethash
7483 group gnus-newsrc-hashtb))))
7487 (gnus-group-jump-to-group group)
7489 (gnus-group-jump-to-group ingroup))
7490 (gnus-summary-search-group backward)
7491 (let ((group (or group (gnus-summary-search-group backward))))
7493 (gnus-summary-exit t) ;Update all information.
7495 (gnus-summary-exit-no-update t)
7496 (gnus-group-jump-to-group ingroup)
7497 (setq group (gnus-summary-search-group backward))
7498 (gnus-message 5 "Selecting %s..." group)
7499 (set-buffer gnus-group-buffer)
7500 ;; We are now in group mode buffer.
7501 ;; Make sure group mode buffer point is on GROUP.
7502 (gnus-group-jump-to-group group)
7503 (if (not (eq gnus-auto-select-next 'quietly))
7505 (gnus-summary-read-group group nil no-article sumbuf)
7506 (and (string= gnus-newsgroup-name ingroup)
7507 (bufferp sumbuf) (buffer-name sumbuf)
7509 (set-buffer (setq gnus-summary-buffer sumbuf))
7510 (gnus-summary-exit-no-update t))))
7511 (let ((prevgroup group))
7512 (gnus-group-jump-to-group ingroup)
7513 (setq group (gnus-summary-search-group backward))
7514 (gnus-summary-read-group group nil no-article sumbuf)
7515 (while (and (string= gnus-newsgroup-name ingroup)
7517 (buffer-name sumbuf)
7518 (not (string= prevgroup (gnus-group-group-name))))
7519 (set-buffer gnus-group-buffer)
7520 (gnus-summary-read-group
7521 (setq prevgroup (gnus-group-group-name))
7522 nil no-article sumbuf))
7523 (and (string= prevgroup (gnus-group-group-name))
7524 ;; We have reached the final group in the group
7527 (if (buffer-name sumbuf)
7530 (gnus-summary-exit)))))))))))
7532 (defun gnus-summary-prev-group (no-article)
7533 "Exit current newsgroup and then select previous unread newsgroup.
7534 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7536 (gnus-summary-next-group no-article nil t))
7538 ;; Walking around summary lines.
7540 (defun gnus-summary-first-subject (unread)
7541 "Go to the first unread subject.
7542 If UNREAD is non-nil, go to the first unread article.
7543 Returns nil if there are no unread articles."
7547 (goto-char (point-min)))
7550 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7553 ;; There are no unread articles.
7554 (gnus-message 3 "No more unread articles")
7556 (gnus-summary-position-cursor)))
7558 (defun gnus-summary-next-subject (n &optional unread dont-display)
7559 "Go to next N'th summary line.
7560 If N is negative, go to the previous N'th subject line.
7561 If UNREAD is non-nil, only unread articles are selected.
7562 The difference between N and the actual number of steps taken is
7565 (let ((backward (< n 0))
7568 (gnus-summary-search-forward unread nil backward))
7570 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7571 (if unread " unread" "")))
7574 (gnus-summary-recenter)
7575 (gnus-summary-position-cursor)))
7578 (defun gnus-summary-next-unread-subject (n)
7579 "Go to next N'th unread summary line."
7581 (gnus-summary-next-subject n t))
7583 (defun gnus-summary-prev-subject (n &optional unread)
7584 "Go to previous N'th summary line.
7585 If optional argument UNREAD is non-nil, only unread article is selected."
7587 (gnus-summary-next-subject (- n) unread))
7589 (defun gnus-summary-prev-unread-subject (n)
7590 "Go to previous N'th unread summary line."
7592 (gnus-summary-next-subject (- n) t))
7594 (defun gnus-summary-goto-subject (article)
7595 "Go the subject line of ARTICLE."
7599 (completing-read "Article number: "
7603 (int-to-string (header-number headers))))
7604 gnus-newsgroup-headers)
7605 nil 'require-match))))
7606 (or article (error "No article number"))
7608 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
7609 'gnus-number article)))
7611 (gnus-summary-show-thread)
7612 ;; Skip dummy articles.
7613 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7620 (gnus-summary-position-cursor)))))
7622 ;; Walking around summary lines with displaying articles.
7624 (defun gnus-summary-expand-window ()
7625 "Make the summary buffer take up the entire Emacs frame."
7627 (gnus-set-global-variables)
7628 (gnus-configure-windows 'summary))
7630 (defun gnus-summary-display-article (article &optional all-header)
7631 "Display ARTICLE in article buffer."
7632 (gnus-set-global-variables)
7636 (gnus-article-prepare article all-header)
7637 (gnus-summary-show-thread)
7638 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7641 (gnus-summary-position-cursor)))
7642 (run-hooks 'gnus-select-article-hook)
7643 (gnus-summary-recenter)
7644 (gnus-summary-goto-subject article)
7645 ;; Successfully display article.
7646 (gnus-summary-update-line)
7647 (gnus-article-set-window-start
7648 (cdr (assq article gnus-newsgroup-bookmarks)))
7651 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7652 "Select the current article.
7653 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7654 non-nil, the article will be re-fetched even if it already present in
7655 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7657 (and (not pseudo) (gnus-summary-pseudo-article)
7658 (error "This is a pseudo-article."))
7659 (let ((article (or article (gnus-summary-article-number)))
7660 (all-headers (not (not all-headers))) ;Must be T or NIL.
7664 (set-buffer gnus-summary-buffer)
7665 (if (or (null gnus-current-article)
7666 (null gnus-article-current)
7667 (null (get-buffer gnus-article-buffer))
7668 (not (eq article (cdr gnus-article-current)))
7669 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7671 ;; The requested article is different from the current article.
7673 (gnus-summary-display-article article all-headers)
7675 (if all-headers (gnus-article-show-all-headers))
7678 (gnus-article-set-window-start
7679 (cdr (assq article gnus-newsgroup-bookmarks)))))))
7681 (defun gnus-summary-set-current-mark (&optional current-mark)
7682 "Obsolete function."
7685 (defun gnus-summary-next-article (unread &optional subject backward)
7686 "Select the next article.
7687 If UNREAD, only unread articles are selected.
7688 If SUBJECT, only articles with SUBJECT are selected.
7689 If BACKWARD, the previous article is selected instead of the next."
7691 (gnus-set-global-variables)
7694 ;; Is there such an article?
7695 ((gnus-summary-display-article
7696 (gnus-summary-search-forward unread subject backward))
7697 (gnus-summary-position-cursor))
7698 ;; If not, we try the first unread, if that is wanted.
7700 gnus-auto-select-same
7701 (gnus-summary-first-unread-article))
7702 (gnus-message 6 "Wrapped"))
7703 ;; Try to get next/previous article not displayed in this group.
7704 ((and gnus-auto-extend-newsgroup
7705 (not unread) (not subject)
7706 (setq header (gnus-more-header-forward backward)))
7707 (gnus-extend-newsgroup header backward)
7708 (let ((buffer-read-only nil))
7709 (goto-char (if backward (point-min) (point-max)))
7710 (gnus-summary-prepare-threads (list header) 0))
7711 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7712 gnus-newsgroup-end)))
7713 ;; Go to next/previous group.
7715 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7716 (gnus-summary-jump-to-group gnus-newsgroup-name))
7717 (let ((cmd (aref (this-command-keys) 0))
7719 (if (eq gnus-keep-same-level 'best)
7720 (gnus-summary-best-group gnus-newsgroup-name)
7721 (gnus-summary-search-group backward gnus-keep-same-level))))
7722 ;; For some reason, the group window gets selected. We change
7724 (select-window (get-buffer-window (current-buffer)))
7725 ;; Keep just the event type of CMD.
7726 (and (listp cmd) (setq cmd (car cmd)))
7727 ;; Select next unread newsgroup automagically.
7729 ((not gnus-auto-select-next)
7730 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7731 ((eq gnus-auto-select-next 'quietly)
7733 (if (assoc 'quit-config (gnus-find-method-for-group
7734 gnus-newsgroup-name))
7736 (gnus-message 7 "No more%s articles (%s)..."
7737 (if unread " unread" "")
7738 (if group (concat "selecting " group)
7740 (gnus-summary-next-group nil group backward)))
7742 (let ((keystrokes '(?\C-n ?\C-p))
7744 (while (or (null key) (memq key keystrokes))
7746 7 "No more%s articles%s" (if unread " unread" "")
7747 (if (and group (not (assoc 'quit-config
7748 (gnus-find-method-for-group
7749 gnus-newsgroup-name))))
7750 (format " (Type %s for %s [%s])"
7751 (single-key-description cmd) group
7752 (car (gnus-gethash group gnus-newsrc-hashtb)))
7753 (format " (Type %s to exit %s)"
7754 (single-key-description cmd)
7755 gnus-newsgroup-name)))
7756 ;; Confirm auto selection.
7757 (let* ((event (read-event)))
7758 (setq key (if (listp event) (car event) event))
7759 (if (memq key keystrokes)
7760 (let ((obuf (current-buffer)))
7761 (switch-to-buffer gnus-group-buffer)
7762 (gnus-group-jump-to-group group)
7763 (execute-kbd-macro (char-to-string key))
7764 (setq group (gnus-group-group-name))
7765 (switch-to-buffer obuf)))))
7767 (if (or (not group) (assoc 'quit-config
7768 (gnus-find-method-for-group
7769 gnus-newsgroup-name)))
7771 (gnus-summary-next-group nil group backward))
7772 (setq unread-command-events (list key)))))))))))
7774 (defun gnus-summary-next-unread-article ()
7775 "Select unread article after current one."
7777 (gnus-summary-next-article t (and gnus-auto-select-same
7778 (gnus-summary-subject-string))))
7780 (defun gnus-summary-prev-article (unread &optional subject)
7781 "Select the article after the current one.
7782 If UNREAD is non-nil, only unread articles are selected."
7784 (gnus-summary-next-article unread subject t))
7786 (defun gnus-summary-prev-unread-article ()
7787 "Select unred article before current one."
7789 (gnus-summary-prev-article t (and gnus-auto-select-same
7790 (gnus-summary-subject-string))))
7792 (defun gnus-summary-next-page (lines &optional circular)
7793 "Show next page of selected article.
7794 If end of article, select next article.
7795 Argument LINES specifies lines to be scrolled up.
7796 If CIRCULAR is non-nil, go to the start of the article instead of
7797 instead of selecting the next article when reaching the end of the
7800 (setq gnus-summary-buffer (current-buffer))
7801 (gnus-set-global-variables)
7802 (let ((article (gnus-summary-article-number))
7804 (gnus-configure-windows 'article)
7805 (if (or (null gnus-current-article)
7806 (null gnus-article-current)
7807 (/= article (cdr gnus-article-current))
7808 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7809 ;; Selected subject is different from current article's.
7810 (gnus-summary-display-article article)
7811 (gnus-eval-in-buffer-window
7813 (setq endp (gnus-article-next-page lines)))
7816 (gnus-summary-beginning-of-article))
7818 (gnus-message 3 "End of message"))
7820 (gnus-summary-next-unread-article)))))
7821 (gnus-summary-recenter)
7822 (gnus-summary-position-cursor)))
7824 (defun gnus-summary-prev-page (lines)
7825 "Show previous page of selected article.
7826 Argument LINES specifies lines to be scrolled down."
7828 (gnus-set-global-variables)
7829 (let ((article (gnus-summary-article-number)))
7830 (gnus-configure-windows 'article)
7831 (if (or (null gnus-current-article)
7832 (null gnus-article-current)
7833 (/= article (cdr gnus-article-current))
7834 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7835 ;; Selected subject is different from current article's.
7836 (gnus-summary-display-article article)
7837 (gnus-summary-recenter)
7838 (gnus-eval-in-buffer-window gnus-article-buffer
7839 (gnus-article-prev-page lines))))
7840 (gnus-summary-position-cursor))
7842 (defun gnus-summary-scroll-up (lines)
7843 "Scroll up (or down) one line current article.
7844 Argument LINES specifies lines to be scrolled up (or down if negative)."
7846 (gnus-set-global-variables)
7847 (gnus-configure-windows 'article)
7848 (or (gnus-summary-select-article nil nil 'pseudo)
7849 (gnus-eval-in-buffer-window
7852 (if (gnus-article-next-page lines)
7853 (gnus-message 3 "End of message")))
7855 (gnus-article-prev-page (- lines))))))
7856 (gnus-summary-recenter)
7857 (gnus-summary-position-cursor))
7859 (defun gnus-summary-next-same-subject ()
7860 "Select next article which has the same subject as current one."
7862 (gnus-set-global-variables)
7863 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7865 (defun gnus-summary-prev-same-subject ()
7866 "Select previous article which has the same subject as current one."
7868 (gnus-set-global-variables)
7869 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7871 (defun gnus-summary-next-unread-same-subject ()
7872 "Select next unread article which has the same subject as current one."
7874 (gnus-set-global-variables)
7875 (gnus-summary-next-article t (gnus-summary-subject-string)))
7877 (defun gnus-summary-prev-unread-same-subject ()
7878 "Select previous unread article which has the same subject as current one."
7880 (gnus-set-global-variables)
7881 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7883 (defun gnus-summary-first-unread-article ()
7884 "Select the first unread article.
7885 Return nil if there are no unread articles."
7887 (gnus-set-global-variables)
7889 (if (gnus-summary-first-subject t)
7890 (gnus-summary-display-article (gnus-summary-article-number)))
7891 (gnus-summary-position-cursor)))
7893 (defun gnus-summary-best-unread-article ()
7894 "Select the unread article with the highest score."
7896 (gnus-set-global-variables)
7897 (let ((scored gnus-newsgroup-scored)
7901 (or (> best (cdr (car scored)))
7902 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7903 (not (memq art gnus-newsgroup-marked))
7904 (not (memq art gnus-newsgroup-dormant))
7905 (if (= best (cdr (car scored)))
7906 (setq article (min art article))
7908 (setq best (cdr (car scored))))))
7909 (setq scored (cdr scored)))
7911 (gnus-summary-goto-article article)
7912 (gnus-summary-first-unread-article))
7913 (gnus-summary-position-cursor)))
7915 (defun gnus-summary-goto-article (article &optional all-headers)
7916 "Fetch ARTICLE and display it if it exists.
7917 If ALL-HEADERS is non-nil, no header lines are hidden."
7923 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7924 gnus-newsgroup-headers)
7925 nil 'require-match))))
7927 (and (gnus-summary-goto-subject article)
7928 (gnus-summary-display-article article all-headers))
7929 (gnus-summary-position-cursor)))
7931 (defun gnus-summary-goto-last-article ()
7932 "Go to the previously read article."
7935 (and gnus-last-article
7936 (gnus-summary-goto-article gnus-last-article))
7937 (gnus-summary-position-cursor)))
7939 (defun gnus-summary-pop-article (number)
7940 "Pop one article off the history and go to the previous.
7941 NUMBER articles will be popped off."
7944 (setq gnus-newsgroup-history
7945 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7947 (gnus-summary-goto-article (car to))
7948 (error "Article history empty")))
7949 (gnus-summary-position-cursor))
7951 ;; Summary article oriented commands
7953 (defun gnus-summary-refer-parent-article (n)
7954 "Refer parent article N times.
7955 The difference between N and the number of articles fetched is returned."
7957 (gnus-set-global-variables)
7961 (let ((ref (header-references (gnus-get-header-by-number
7962 (gnus-summary-article-number)))))
7963 (if (and ref (not (equal ref ""))
7964 (string-match "<[^<>]*>[ \t]*$" ref))
7965 (gnus-summary-refer-article
7966 (substring ref (match-beginning 0) (match-end 0)))
7967 (gnus-message 1 "No references in article %d"
7968 (gnus-summary-article-number))
7971 (gnus-summary-position-cursor)
7974 (defun gnus-summary-refer-article (message-id)
7975 "Refer article specified by MESSAGE-ID.
7976 NOTE: This command only works with newsgroups that use real or simulated NNTP."
7977 (interactive "sMessage-ID: ")
7978 (if (or (not (stringp message-id))
7979 (zerop (length message-id)))
7981 ;; Construct the correct Message-ID if necessary.
7982 ;; Suggested by tale@pawl.rpi.edu.
7983 (or (string-match "^<" message-id)
7984 (setq message-id (concat "<" message-id)))
7985 (or (string-match ">$" message-id)
7986 (setq message-id (concat message-id ">")))
7987 (let ((header (car (gnus-gethash (downcase message-id)
7988 gnus-newsgroup-dependencies))))
7990 (or (gnus-summary-goto-article (header-number header))
7991 ;; The header has been read, but the article had been
7992 ;; expunged, so we insert it again.
7994 (gnus-summary-insert-line
7995 nil header 0 nil gnus-read-mark nil nil
7996 (header-subject header))
7998 (header-number header)))
7999 (let ((gnus-override-method gnus-refer-article-method)
8000 (gnus-ancient-mark gnus-read-mark)
8001 (tmp-buf (get-buffer-create " *gnus refer"))
8002 (tmp-point (window-start
8003 (get-buffer-window gnus-article-buffer)))
8005 (and gnus-refer-article-method
8006 (or (gnus-server-opened gnus-refer-article-method)
8007 (gnus-open-server gnus-refer-article-method)))
8008 ;; Save the old article buffer.
8010 (set-buffer tmp-buf)
8011 (buffer-disable-undo (current-buffer))
8012 (insert-buffer-substring gnus-article-buffer))
8014 (if (gnus-article-prepare
8015 message-id nil (gnus-read-header message-id))
8017 (setq number (header-number gnus-current-headers))
8018 (gnus-rebuild-thread message-id)
8019 (gnus-summary-goto-subject number)
8020 (gnus-summary-recenter)
8021 (gnus-article-set-window-start
8022 (cdr (assq number gnus-newsgroup-bookmarks)))
8024 ;; We restore the old article buffer.
8026 (set-buffer gnus-article-buffer)
8027 (let ((buffer-read-only nil))
8028 (insert-buffer-substring tmp-buf)
8030 (set-window-start (get-buffer-window (current-buffer))
8033 (kill-buffer tmp-buf)))))))
8035 (defun gnus-summary-enter-digest-group ()
8036 "Enter a digest group based on the current article."
8038 (gnus-set-global-variables)
8039 (gnus-summary-select-article)
8040 ;; We do not want a narrowed article.
8041 (gnus-summary-stop-page-breaking)
8042 (let ((name (format "%s-%d"
8043 (gnus-group-prefixed-name
8044 gnus-newsgroup-name (list 'nndoc ""))
8045 gnus-current-article))
8046 (ogroup gnus-newsgroup-name)
8047 (buf (current-buffer)))
8048 (if (gnus-group-read-ephemeral-group
8049 name (list 'nndoc name
8050 (list 'nndoc-address (get-buffer gnus-article-buffer))
8051 '(nndoc-article-type digest))
8053 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8054 (list (list (cons 'to-group ogroup))))
8055 (switch-to-buffer buf)
8056 (gnus-set-global-variables)
8057 (gnus-configure-windows 'summary)
8058 (gnus-message 3 "Article not a digest?"))))
8060 (defun gnus-summary-isearch-article ()
8061 "Do incremental search forward on current article."
8063 (gnus-set-global-variables)
8064 (gnus-summary-select-article)
8065 (gnus-eval-in-buffer-window
8066 gnus-article-buffer (isearch-forward)))
8068 (defun gnus-summary-search-article-forward (regexp &optional backward)
8069 "Search for an article containing REGEXP forward.
8070 If BACKWARD, search backward instead."
8073 (format "Search article %s (regexp%s): "
8074 (if current-prefix-arg "backward" "forward")
8075 (if gnus-last-search-regexp
8076 (concat ", default " gnus-last-search-regexp)
8078 current-prefix-arg))
8079 (gnus-set-global-variables)
8080 (if (string-equal regexp "")
8081 (setq regexp (or gnus-last-search-regexp ""))
8082 (setq gnus-last-search-regexp regexp))
8083 (if (gnus-summary-search-article regexp backward)
8084 (gnus-article-set-window-start
8085 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8086 (error "Search failed: \"%s\"" regexp)))
8088 (defun gnus-summary-search-article-backward (regexp)
8089 "Search for an article containing REGEXP backward."
8092 (format "Search article backward (regexp%s): "
8093 (if gnus-last-search-regexp
8094 (concat ", default " gnus-last-search-regexp)
8096 (gnus-summary-search-article-forward regexp 'backward))
8098 (defun gnus-summary-search-article (regexp &optional backward)
8099 "Search for an article containing REGEXP.
8100 Optional argument BACKWARD means do search for backward.
8101 gnus-select-article-hook is not called during the search."
8102 (let ((gnus-select-article-hook nil) ;Disable hook.
8103 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8106 (function re-search-backward) (function re-search-forward)))
8109 ;; Hidden thread subtrees must be searched for ,too.
8110 (gnus-summary-show-all-threads)
8111 (if (eobp) (forward-line -1))
8112 ;; First of all, search current article.
8113 ;; We don't want to read article again from NNTP server nor reset
8115 (gnus-summary-select-article)
8116 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8117 (setq last gnus-current-article)
8118 (gnus-eval-in-buffer-window gnus-article-buffer
8121 ;; Begin search from current point.
8122 (setq found (funcall re-search regexp nil t))))
8123 ;; Then search next articles.
8124 (while (and (not found)
8125 (gnus-summary-display-article
8126 (gnus-summary-search-subject backward nil nil)))
8127 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8128 (gnus-eval-in-buffer-window gnus-article-buffer
8131 (goto-char (if backward (point-max) (point-min)))
8132 (setq found (funcall re-search regexp nil t)))))
8134 ;; Adjust article pointer.
8135 (or (eq last gnus-current-article)
8136 (setq gnus-last-article last))
8137 ;; Return T if found such article.
8140 (defun gnus-summary-execute-command (header regexp command &optional backward)
8141 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8142 If HEADER is an empty string (or nil), the match is done on the entire
8143 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8145 (list (let ((completion-ignore-case t))
8148 (mapcar (lambda (string) (list string))
8149 '("Number" "Subject" "From" "Lines" "Date"
8150 "Message-ID" "Xref" "References"))
8151 nil 'require-match))
8152 (read-string "Regexp: ")
8153 (read-key-sequence "Command: ")
8154 current-prefix-arg))
8155 (gnus-set-global-variables)
8156 ;; Hidden thread subtrees must be searched as well.
8157 (gnus-summary-show-all-threads)
8158 ;; We don't want to change current point nor window configuration.
8160 (save-window-excursion
8161 (gnus-message 6 "Executing %s..." (key-description command))
8162 ;; We'd like to execute COMMAND interactively so as to give arguments.
8163 (gnus-execute header regexp
8165 (call-interactively '(, (key-binding command)))))
8167 (gnus-message 6 "Executing %s...done" (key-description command)))))
8169 (defun gnus-summary-beginning-of-article ()
8170 "Scroll the article back to the beginning."
8172 (gnus-set-global-variables)
8173 (gnus-summary-select-article)
8174 (gnus-configure-windows 'article)
8175 (gnus-eval-in-buffer-window
8178 (goto-char (point-min))
8179 (and gnus-break-pages (gnus-narrow-to-page))))
8181 (defun gnus-summary-end-of-article ()
8182 "Scroll to the end of the article."
8184 (gnus-set-global-variables)
8185 (gnus-summary-select-article)
8186 (gnus-configure-windows 'article)
8187 (gnus-eval-in-buffer-window
8190 (goto-char (point-max))
8191 (and gnus-break-pages (gnus-narrow-to-page))))
8193 (defun gnus-summary-show-article (no-refetch)
8194 "Force re-fetching of the current article.
8195 If the prefix argument NO-REFETCH is non-nil, no actual refetch will
8196 be performed. The current article will simply be redisplayed."
8198 (gnus-set-global-variables)
8199 (if (not no-refetch)
8200 (gnus-summary-select-article gnus-have-all-headers t)
8201 (or gnus-current-article
8202 (error "There is no current article"))
8203 (gnus-summary-goto-subject gnus-current-article)
8204 (gnus-configure-windows 'article)
8205 (gnus-summary-position-cursor)))
8207 (defun gnus-summary-verbose-headers (arg)
8208 "Toggle permanent full header display.
8209 If ARG is a positive number, turn header display on.
8210 If ARG is a negative number, turn header display off."
8212 (gnus-set-global-variables)
8213 (gnus-summary-toggle-header arg)
8214 (setq gnus-have-all-headers
8215 (cond ((or (not (numberp arg))
8217 (not gnus-have-all-headers))
8221 (defun gnus-summary-toggle-header (arg)
8222 "Show the headers if they are hidden, or hide them if they are shown.
8223 If ARG is a positive number, show the entire header.
8224 If ARG is a negative number, hide the unwanted header lines."
8226 (gnus-set-global-variables)
8228 (set-buffer gnus-article-buffer)
8229 (let ((buffer-read-only nil))
8231 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8232 gnus-hidden-properties)
8233 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8234 (if (text-property-any (point-min) (point-max) 'invisible t)
8235 (remove-text-properties (point-min) (point-max)
8236 gnus-hidden-properties)
8237 (let ((gnus-have-all-headers nil))
8238 (run-hooks 'gnus-article-display-hook))))
8239 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8241 (defun gnus-summary-show-all-headers ()
8242 "Make all header lines visible."
8244 (gnus-set-global-variables)
8245 (gnus-article-show-all-headers))
8247 (defun gnus-summary-toggle-mime (arg)
8248 "Toggle MIME processing.
8249 If ARG is a positive number, turn MIME processing on."
8251 (gnus-set-global-variables)
8252 (setq gnus-show-mime
8253 (if (null arg) (not gnus-show-mime)
8254 (> (prefix-numeric-value arg) 0)))
8255 (gnus-summary-select-article t 'force))
8257 (defun gnus-summary-caesar-message (rotnum)
8258 "Caesar rotates all letters of current message by 13/47 places.
8259 With prefix arg, specifies the number of places to rotate each letter forward.
8260 Caesar rotates Japanese letters by 47 places in any case."
8262 (gnus-set-global-variables)
8263 (gnus-summary-select-article)
8264 (let ((mail-header-separator "")) ; !!! Is this necessary?
8265 (gnus-overload-functions)
8266 (gnus-eval-in-buffer-window
8270 ;; We don't want to jump to the beginning of the message.
8271 ;; `save-excursion' does not do its job.
8272 (move-to-window-line 0)
8273 (let ((last (point)))
8274 (news-caesar-buffer-body rotnum)
8278 (defun gnus-summary-stop-page-breaking ()
8279 "Stop page breaking in the current article."
8281 (gnus-set-global-variables)
8282 (gnus-summary-select-article)
8283 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8285 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8287 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
8288 "Move the current article to a different newsgroup.
8289 If N is a positive number, move the N next articles.
8290 If N is a negative number, move the N previous articles.
8291 If N is nil and any articles have been marked with the process mark,
8292 move those articles instead.
8293 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8294 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8295 re-spool using this method.
8296 For this function to work, both the current newsgroup and the
8297 newsgroup that you want to move to have to support the `request-move'
8298 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8300 (gnus-set-global-variables)
8301 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8302 (error "The current newsgroup does not support article moving"))
8303 (let ((articles (gnus-summary-work-articles n))
8304 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8305 art-group to-method)
8306 (if (and (not to-newsgroup) (not select-method))
8309 (format "Where do you want to move %s? %s"
8310 (if (> (length articles) 1)
8311 (format "these %d articles" (length articles))
8313 (if gnus-current-move-group
8314 (format "(%s default) " gnus-current-move-group)
8316 gnus-active-hashtb nil nil prefix)))
8319 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8320 (setq to-newsgroup (or gnus-current-move-group "")))
8321 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8322 (gnus-activate-newsgroup to-newsgroup)
8323 (error "No such group: %s" to-newsgroup))
8324 (setq gnus-current-move-group to-newsgroup)))
8325 (setq to-method (or select-method (gnus-find-method-for-group
8327 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8328 (error "%s does not support article copying" (car to-method)))
8329 (or (gnus-server-opened to-method)
8330 (gnus-open-server to-method)
8331 (error "Can't open server %s" (car to-method)))
8332 (gnus-message 6 "Moving to %s: %s..."
8333 (or select-method to-newsgroup) articles)
8336 (gnus-request-move-article
8337 (car articles) ; Article to move
8338 gnus-newsgroup-name ; From newsgrouo
8339 (nth 1 (gnus-find-method-for-group
8340 gnus-newsgroup-name)) ; Server
8341 (list 'gnus-request-accept-article
8343 (list 'quote select-method)
8345 (not (cdr articles))) ; Accept form
8346 (not (cdr articles)))) ; Only save nov last time
8347 (let* ((buffer-read-only nil)
8350 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8352 (gnus-group-prefixed-name
8354 (if select-method (list select-method "")
8355 (gnus-find-method-for-group to-newsgroup)))
8356 gnus-newsrc-hashtb)))
8357 (info (nth 2 entry))
8358 (article (car articles)))
8359 (gnus-summary-goto-subject article)
8361 (delete-region (point)
8362 (progn (forward-line 1) (point)))
8363 (if (not (memq article gnus-newsgroup-unreads))
8364 (setcar (cdr (cdr info))
8365 (gnus-add-to-range (nth 2 info)
8366 (list (cdr art-group)))))
8367 ;; Copy any marks over to the new group.
8368 (let ((marks '((tick . gnus-newsgroup-marked)
8369 (dormant . gnus-newsgroup-dormant)
8370 (expire . gnus-newsgroup-expirable)
8371 (bookmark . gnus-newsgroup-bookmarks)
8372 ; (score . gnus-newsgroup-scored)
8373 (reply . gnus-newsgroup-replied)))
8374 (to-article (cdr art-group)))
8376 (if (memq article (symbol-value (cdr (car marks))))
8377 (gnus-add-marked-articles
8378 (car info) (car (car marks)) (list to-article) info))
8379 (setq marks (cdr marks))))
8380 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8381 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8382 (setq gnus-newsgroup-dormant
8383 (delq article gnus-newsgroup-dormant)))
8384 (gnus-message 1 "Couldn't move article %s" (car articles)))
8385 (gnus-summary-remove-process-mark (car articles))
8386 (setq articles (cdr articles)))))
8388 (defun gnus-summary-respool-article (n &optional respool-method)
8389 "Respool the current article.
8390 The article will be squeezed through the mail spooling process again,
8391 which means that it will be put in some mail newsgroup or other
8392 depending on `nnmail-split-methods'.
8393 If N is a positive number, respool the N next articles.
8394 If N is a negative number, respool the N previous articles.
8395 If N is nil and any articles have been marked with the process mark,
8396 respool those articles instead.
8398 Respooling can be done both from mail groups and \"real\" newsgroups.
8399 In the former case, the articles in question will be moved from the
8400 current group into whatever groups they are destined to. In the
8401 latter case, they will be copied into the relevant groups."
8403 (gnus-set-global-variables)
8404 (let ((respool-methods (gnus-methods-using 'respool))
8406 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8408 (setq respool-method
8410 "What method do you want to use when respooling? "
8411 respool-methods nil t methname)))
8412 (or (string= respool-method "")
8413 (if (assoc (symbol-name
8414 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8416 (gnus-summary-move-article n nil (intern respool-method))
8417 (gnus-summary-copy-article n nil (intern respool-method))))))
8419 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8420 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
8421 "Move the current article to a different newsgroup.
8422 If N is a positive number, move the N next articles.
8423 If N is a negative number, move the N previous articles.
8424 If N is nil and any articles have been marked with the process mark,
8425 move those articles instead.
8426 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8427 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8428 re-spool using this method.
8429 For this function to work, the newsgroup that you want to move to have
8430 to support the `request-move' and `request-accept'
8431 functions. (Ie. mail newsgroups at present.)"
8433 (gnus-set-global-variables)
8434 (let ((articles (gnus-summary-work-articles n))
8435 (copy-buf (get-buffer-create "*copy work*"))
8436 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8437 art-group to-method)
8438 (buffer-disable-undo copy-buf)
8439 (if (and (not to-newsgroup) (not select-method))
8442 (format "Where do you want to copy %s? %s"
8443 (if (> (length articles) 1)
8444 (format "these %d articles" (length articles))
8446 (if gnus-current-move-group
8447 (format "(%s default) " gnus-current-move-group)
8449 gnus-active-hashtb nil nil prefix)))
8452 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8453 (setq to-newsgroup (or gnus-current-move-group "")))
8454 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8455 (gnus-activate-newsgroup to-newsgroup)
8456 (error "No such group: %s" to-newsgroup))
8457 (setq gnus-current-move-group to-newsgroup)))
8458 (setq to-method (or select-method (gnus-find-method-for-group
8460 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8461 (error "%s does not support article copying" (car to-method)))
8462 (or (gnus-server-opened to-method)
8463 (gnus-open-server to-method)
8464 (error "Can't open server %s" (car to-method)))
8465 (gnus-message 6 "Copying to %s: %s..."
8466 (or select-method to-newsgroup) articles)
8470 (set-buffer copy-buf)
8471 (gnus-request-article-this-buffer
8472 (car articles) gnus-newsgroup-name)
8473 (gnus-request-accept-article
8474 (if select-method (quote select-method) to-newsgroup)
8475 (not (cdr articles)))))
8478 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8480 (gnus-group-prefixed-name
8482 (if select-method (list select-method "")
8483 (gnus-find-method-for-group to-newsgroup)))
8484 gnus-newsrc-hashtb)))
8485 (info (nth 2 entry))
8486 (article (car articles)))
8487 (if (not (memq article gnus-newsgroup-unreads))
8488 (setcar (cdr (cdr info))
8489 (gnus-add-to-range (nth 2 info)
8490 (list (cdr art-group)))))
8491 ;; Copy any marks over to the new group.
8492 (let ((marks '((tick . gnus-newsgroup-marked)
8493 (dormant . gnus-newsgroup-dormant)
8494 (expire . gnus-newsgroup-expirable)
8495 (bookmark . gnus-newsgroup-bookmarks)
8496 ; (score . gnus-newsgroup-scored)
8497 (reply . gnus-newsgroup-replied)))
8498 (to-article (cdr art-group)))
8500 (if (memq article (symbol-value (cdr (car marks))))
8501 (gnus-add-marked-articles
8502 (car info) (car (car marks)) (list to-article) info))
8503 (setq marks (cdr marks)))))
8504 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8505 (gnus-summary-remove-process-mark (car articles))
8506 (setq articles (cdr articles)))
8507 (kill-buffer copy-buf)))
8509 (defun gnus-summary-import-article (file)
8510 "Import a random file into a mail newsgroup."
8511 (interactive "fImport file: ")
8512 (let ((group gnus-newsgroup-name)
8514 (or (gnus-check-backend-function 'request-accept-article group)
8515 (error "%s does not support article importing" group))
8516 (or (file-readable-p file)
8517 (not (file-regular-p file))
8518 (error "Can't read %s" file))
8520 (set-buffer (get-buffer-create " *import file*"))
8521 (buffer-disable-undo (current-buffer))
8523 (insert-file-contents file)
8524 (goto-char (point-min))
8525 (if (nnheader-article-p)
8527 (setq atts (file-attributes file))
8528 (insert "From: " (read-string "From: ") "\n"
8529 "Subject: " (read-string "Subject: ") "\n"
8530 "Date: " (current-time-string (nth 5 atts)) "\n"
8531 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8532 (gnus-request-accept-article group t)
8533 (kill-buffer (current-buffer)))))
8535 (defun gnus-summary-expire-articles ()
8536 "Expire all articles that are marked as expirable in the current group."
8538 (if (and gnus-newsgroup-expirable
8539 (gnus-check-backend-function
8540 'request-expire-articles gnus-newsgroup-name))
8541 (let ((expirable gnus-newsgroup-expirable))
8542 ;; The list of articles that weren't expired is returned.
8543 (setq gnus-newsgroup-expirable
8544 (gnus-request-expire-articles gnus-newsgroup-expirable
8545 gnus-newsgroup-name))
8546 ;; We go through the old list of expirable, and mark all
8547 ;; really expired articles as non-existent.
8549 (or (memq (car expirable) gnus-newsgroup-expirable)
8550 (gnus-summary-mark-as-read (car expirable) gnus-canceled-mark))
8551 (setq expirable (cdr expirable))))))
8553 (defun gnus-summary-expire-articles-now ()
8554 "Expunge all expirable articles in the current group.
8555 This means that *all* articles that are marked as expirable will be
8556 deleted forever, right now."
8558 (or gnus-expert-user
8560 "Are you really, really, really sure you want to expunge? ")
8562 (let ((nnmail-expiry-wait 0)
8563 (nnmail-expiry-wait-function nil))
8564 (gnus-summary-expire-articles)))
8566 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8567 (defun gnus-summary-delete-article (n)
8568 "Delete the N next (mail) articles.
8569 This command actually deletes articles. This is not a marking
8570 command. The article will disappear forever from you life, never to
8572 If N is negative, delete backwards.
8573 If N is nil and articles have been marked with the process mark,
8574 delete these instead."
8576 (or (gnus-check-backend-function 'request-expire-articles
8577 gnus-newsgroup-name)
8578 (error "The current newsgroup does not support article deletion."))
8579 ;; Compute the list of articles to delete.
8580 (let ((articles (gnus-summary-work-articles n))
8582 (if (and gnus-novice-user
8584 (format "Do you really want to delete %s forever? "
8585 (if (> (length articles) 1) "these articles"
8588 ;; Delete the articles.
8589 (setq not-deleted (gnus-request-expire-articles
8590 articles gnus-newsgroup-name 'force))
8592 (gnus-summary-remove-process-mark (car articles))
8593 ;; The backend might not have been able to delete the article
8595 (or (memq (car articles) not-deleted)
8596 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
8597 (setq articles (cdr articles))))
8598 (gnus-summary-position-cursor)
8601 (defun gnus-summary-edit-article ()
8602 "Enter into a buffer and edit the current article.
8603 This will have permanent effect only in mail groups."
8605 (or (gnus-check-backend-function
8606 'request-replace-article gnus-newsgroup-name)
8607 (error "The current newsgroup does not support article editing."))
8608 (gnus-summary-select-article t)
8609 (gnus-configure-windows 'article)
8610 (select-window (get-buffer-window gnus-article-buffer))
8611 (gnus-message 6 "C-c C-c to end edits")
8612 (setq buffer-read-only nil)
8614 (use-local-map (copy-keymap (current-local-map)))
8615 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8616 (buffer-enable-undo)
8617 (goto-char (point-min))
8618 (search-forward "\n\n" nil t))
8620 (defun gnus-summary-edit-article-done ()
8621 "Make edits to the current article permanent."
8623 (if (not (gnus-request-replace-article
8624 (cdr gnus-article-current) (car gnus-article-current)
8626 (error "Couldn't replace article.")
8628 (use-local-map gnus-article-mode-map)
8629 (setq buffer-read-only t)
8630 (buffer-disable-undo (current-buffer))
8631 (pop-to-buffer gnus-summary-buffer)))
8633 (defun gnus-summary-fancy-query ()
8634 "Query where the fancy respool algorithm would put this article."
8636 (gnus-summary-select-article)
8638 (set-buffer gnus-article-buffer)
8640 (goto-char (point-min))
8641 (search-forward "\n\n")
8642 (narrow-to-region (point-min) (point))
8643 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8645 ;; Summary score commands.
8647 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8649 (defun gnus-summary-raise-score (n)
8650 "Raise the score of the current article by N."
8652 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8654 (defun gnus-summary-lower-score (n)
8655 "Lower the score of the current article by N."
8657 (gnus-summary-raise-score (- n)))
8659 (defun gnus-summary-set-score (n)
8660 "Set the score of the current article to N."
8662 ;; Skip dummy header line.
8664 (gnus-summary-show-thread)
8665 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8667 (let ((buffer-read-only nil))
8669 (gnus-summary-update-mark
8670 (if (= n (or gnus-summary-default-score 0)) ?
8671 (if (< n (or gnus-summary-default-score 0))
8672 gnus-score-below-mark gnus-score-over-mark)) 'score))
8673 (let* ((article (gnus-summary-article-number))
8674 (score (assq article gnus-newsgroup-scored)))
8675 (if score (setcdr score n)
8676 (setq gnus-newsgroup-scored
8677 (cons (cons article n) gnus-newsgroup-scored))))
8678 (gnus-summary-update-line)))
8680 (defun gnus-summary-current-score ()
8681 "Return the score of the current article."
8683 (message "%s" (gnus-summary-article-score)))
8685 ;; Summary marking commands.
8687 (defun gnus-summary-raise-same-subject-and-select (score)
8688 "Raise articles which has the same subject with SCORE and select the next."
8690 (let ((subject (gnus-summary-subject-string)))
8691 (gnus-summary-raise-score score)
8692 (while (gnus-summary-search-subject nil nil subject)
8693 (gnus-summary-raise-score score))
8694 (gnus-summary-next-article t)))
8696 (defun gnus-summary-raise-same-subject (score)
8697 "Raise articles which has the same subject with SCORE."
8699 (let ((subject (gnus-summary-subject-string)))
8700 (gnus-summary-raise-score score)
8701 (while (gnus-summary-search-subject nil nil subject)
8702 (gnus-summary-raise-score score))
8703 (gnus-summary-next-subject 1 t)))
8705 (defun gnus-score-default (level)
8706 (if level (prefix-numeric-value level)
8707 gnus-score-interactive-default-score))
8709 (defun gnus-summary-raise-thread (score)
8710 "Raise the score of the articles in the current thread with SCORE."
8712 (setq score (1- (gnus-score-default score)))
8715 (let ((level (gnus-summary-thread-level)))
8716 (gnus-summary-raise-score score)
8717 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8718 (> (gnus-summary-thread-level) level))
8719 (gnus-summary-raise-score score))
8721 (let ((gnus-summary-check-current t))
8722 (or (zerop (gnus-summary-next-subject 1 t))
8724 (gnus-summary-recenter)
8725 (gnus-summary-position-cursor)
8726 (gnus-set-mode-line 'summary))
8728 (defun gnus-summary-lower-same-subject-and-select (score)
8729 "Raise articles which has the same subject with SCORE and select the next."
8731 (gnus-summary-raise-same-subject-and-select (- score)))
8733 (defun gnus-summary-lower-same-subject (score)
8734 "Raise articles which has the same subject with SCORE."
8736 (gnus-summary-raise-same-subject (- score)))
8738 (defun gnus-summary-lower-thread (score)
8739 "Lower score of articles in the current thread with SCORE."
8741 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8743 (defun gnus-summary-kill-same-subject-and-select (unmark)
8744 "Mark articles which has the same subject as read, and then select the next.
8745 If UNMARK is positive, remove any kind of mark.
8746 If UNMARK is negative, tick articles."
8749 (setq unmark (prefix-numeric-value unmark)))
8751 (gnus-summary-mark-same-subject
8752 (gnus-summary-subject-string) unmark)))
8753 ;; Select next unread article. If auto-select-same mode, should
8754 ;; select the first unread article.
8755 (gnus-summary-next-article t (and gnus-auto-select-same
8756 (gnus-summary-subject-string)))
8757 (gnus-message 7 "%d articles are marked as %s"
8758 count (if unmark "unread" "read"))))
8760 (defun gnus-summary-kill-same-subject (unmark)
8761 "Mark articles which has the same subject as read.
8762 If UNMARK is positive, remove any kind of mark.
8763 If UNMARK is negative, tick articles."
8766 (setq unmark (prefix-numeric-value unmark)))
8768 (gnus-summary-mark-same-subject
8769 (gnus-summary-subject-string) unmark)))
8770 ;; If marked as read, go to next unread subject.
8772 ;; Go to next unread subject.
8773 (gnus-summary-next-subject 1 t))
8774 (gnus-message 7 "%d articles are marked as %s"
8775 count (if unmark "unread" "read"))))
8777 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8778 "Mark articles with same SUBJECT as read, and return marked number.
8779 If optional argument UNMARK is positive, remove any kinds of marks.
8780 If optional argument UNMARK is negative, mark articles as unread instead."
8783 (cond ((null unmark)
8784 (gnus-summary-mark-as-read nil gnus-killed-mark))
8786 (gnus-summary-tick-article nil t))
8788 (gnus-summary-tick-article)))
8790 (gnus-summary-search-forward nil subject))
8791 (cond ((null unmark)
8792 (gnus-summary-mark-as-read nil gnus-killed-mark))
8794 (gnus-summary-tick-article nil t))
8796 (gnus-summary-tick-article)))
8797 (setq count (1+ count))))
8798 ;; Hide killed thread subtrees. Does not work properly always.
8799 ;;(and (null unmark)
8800 ;; gnus-thread-hide-killed
8801 ;; (gnus-summary-hide-thread))
8802 ;; Return number of articles marked as read.
8805 (defun gnus-summary-mark-as-processable (n &optional unmark)
8806 "Set the process mark on the next N articles.
8807 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8808 the process mark instead. The difference between N and the actual
8809 number of articles marked is returned."
8811 (let ((backward (< n 0))
8816 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8817 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8818 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8820 (if (/= 0 n) (gnus-message 7 "No more articles"))
8821 (gnus-summary-recenter)
8822 (gnus-summary-position-cursor)
8825 (defun gnus-summary-unmark-as-processable (n)
8826 "Remove the process mark from the next N articles.
8827 If N is negative, mark backward instead. The difference between N and
8828 the actual number of articles marked is returned."
8830 (gnus-summary-mark-as-processable n t))
8832 (defun gnus-summary-unmark-all-processable ()
8833 "Remove the process mark from all articles."
8836 (while gnus-newsgroup-processable
8837 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8838 (gnus-summary-position-cursor))
8840 (defun gnus-summary-mark-as-expirable (n)
8841 "Mark N articles forward as expirable.
8842 If N is negative, mark backward instead. The difference between N and
8843 the actual number of articles marked is returned."
8845 (gnus-summary-mark-forward n gnus-expirable-mark))
8847 (defun gnus-summary-mark-article-as-replied (article)
8848 "Mark ARTICLE replied and update the summary line."
8849 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8850 (let ((buffer-read-only nil))
8851 (if (gnus-summary-goto-subject article)
8853 (gnus-summary-update-mark gnus-replied-mark 'replied)
8856 (defun gnus-summary-set-bookmark (article)
8857 "Set a bookmark in current article."
8858 (interactive (list (gnus-summary-article-number)))
8859 (if (or (not (get-buffer gnus-article-buffer))
8860 (not gnus-current-article)
8861 (not gnus-article-current)
8862 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8863 (error "No current article selected"))
8864 ;; Remove old bookmark, if one exists.
8865 (let ((old (assq article gnus-newsgroup-bookmarks)))
8866 (if old (setq gnus-newsgroup-bookmarks
8867 (delq old gnus-newsgroup-bookmarks))))
8868 ;; Set the new bookmark, which is on the form
8869 ;; (article-number . line-number-in-body).
8870 (setq gnus-newsgroup-bookmarks
8874 (set-buffer gnus-article-buffer)
8878 (goto-char (point-min))
8879 (search-forward "\n\n" nil t)
8882 gnus-newsgroup-bookmarks))
8883 (gnus-message 6 "A bookmark has been added to the current article."))
8885 (defun gnus-summary-remove-bookmark (article)
8886 "Remove the bookmark from the current article."
8887 (interactive (list (gnus-summary-article-number)))
8888 ;; Remove old bookmark, if one exists.
8889 (let ((old (assq article gnus-newsgroup-bookmarks)))
8892 (setq gnus-newsgroup-bookmarks
8893 (delq old gnus-newsgroup-bookmarks))
8894 (gnus-message 6 "Removed bookmark."))
8895 (gnus-message 6 "No bookmark in current article."))))
8897 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8898 (defun gnus-summary-mark-as-dormant (n)
8899 "Mark N articles forward as dormant.
8900 If N is negative, mark backward instead. The difference between N and
8901 the actual number of articles marked is returned."
8903 (gnus-summary-mark-forward n gnus-dormant-mark))
8905 (defun gnus-summary-set-process-mark (article)
8906 "Set the process mark on ARTICLE and update the summary line."
8907 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8908 (let ((buffer-read-only nil))
8909 (if (gnus-summary-goto-subject article)
8911 (gnus-summary-show-thread)
8912 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8914 (gnus-summary-update-mark gnus-process-mark 'replied)
8917 (defun gnus-summary-remove-process-mark (article)
8918 "Remove the process mark from ARTICLE and update the summary line."
8919 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8920 (let ((buffer-read-only nil))
8921 (if (gnus-summary-goto-subject article)
8923 (gnus-summary-show-thread)
8924 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8926 (gnus-summary-update-mark ? 'replied)
8927 (if (memq article gnus-newsgroup-replied)
8928 (gnus-summary-update-mark gnus-replied-mark 'replied))
8931 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8932 "Mark N articles as read forwards.
8933 If N is negative, mark backwards instead.
8934 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8936 The difference between N and the actual number of articles marked is
8939 (gnus-set-global-variables)
8940 (let ((backward (< n 0))
8942 (mark (or mark gnus-del-mark)))
8944 (gnus-summary-mark-article nil mark no-expire)
8945 (zerop (gnus-summary-next-subject
8946 (if backward -1 1) gnus-summary-goto-unread t)))
8948 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8949 (gnus-summary-recenter)
8950 (gnus-summary-position-cursor)
8951 (gnus-set-mode-line 'summary)
8954 (defun gnus-summary-mark-article (&optional article mark no-expire)
8955 "Mark ARTICLE with MARK.
8956 MARK can be any character.
8957 Five MARK strings are reserved: ? (unread),
8958 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8959 If MARK is nil, then the default character ?D is used.
8960 If ARTICLE is nil, then the article on the current line will be
8962 ;; If no mark is given, then we check auto-expiring.
8963 (and (not no-expire)
8964 gnus-newsgroup-auto-expire
8967 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
8968 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
8969 (= mark gnus-read-mark))))
8970 (setq mark gnus-expirable-mark))
8971 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8972 (article (or article (gnus-summary-article-number))))
8973 (or article (error "No article on current line"))
8974 (if (or (= mark gnus-unread-mark)
8975 (= mark gnus-ticked-mark)
8976 (= mark gnus-dormant-mark))
8977 (gnus-mark-article-as-unread article mark)
8978 (gnus-mark-article-as-read article mark))
8980 ;; See whether the article is to be put in the cache.
8983 (gnus-cache-possibly-enter-article
8984 gnus-newsgroup-name article
8985 (gnus-get-header-by-number article)
8986 (= mark gnus-ticked-mark)
8987 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8989 (if (gnus-summary-goto-subject article)
8990 (let ((buffer-read-only nil))
8991 (gnus-summary-show-thread)
8992 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
8995 (gnus-summary-update-mark mark 'unread)
8998 (defun gnus-summary-update-mark (mark type)
9000 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9004 (forward-char forward)
9005 (setq plist (text-properties-at (point)))
9008 (and plist (add-text-properties (1- (point)) (point) plist))
9009 (and (eq type 'unread)
9010 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9011 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9013 (defun gnus-mark-article-as-read (article &optional mark)
9014 "Enter ARTICLE in the pertinent lists and remove it from others."
9015 ;; Make the article expirable.
9016 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
9017 (if (= mark gnus-expirable-mark)
9018 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9019 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9020 ;; Remove from unread and marked lists.
9021 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9022 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9023 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9024 ;; Possibly remove from cache, if that is used.
9025 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9027 (defun gnus-mark-article-as-unread (article &optional mark)
9028 "Enter ARTICLE in the pertinent lists and remove it from others."
9029 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
9030 ;; Add to unread list.
9031 (or (memq article gnus-newsgroup-unreads)
9032 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9033 ;; If CLEAR-MARK is non-nil, the article must be removed from mark
9034 ;; lists. Otherwise, it must be added to the list.
9035 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9036 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9037 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9038 (if (= mark gnus-ticked-mark)
9039 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9040 (if (= mark gnus-dormant-mark)
9041 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9043 (defalias 'gnus-summary-mark-as-unread-forward
9044 'gnus-summary-tick-article-forward)
9045 (make-obsolete 'gnus-summary-mark-as-unread-forward
9046 'gnus-summary-tick-article-forward)
9047 (defun gnus-summary-tick-article-forward (n)
9048 "Tick N articles forwards.
9049 If N is negative, tick backwards instead.
9050 The difference between N and the number of articles ticked is returned."
9052 (gnus-summary-mark-forward n gnus-ticked-mark))
9054 (defalias 'gnus-summary-mark-as-unread-backward
9055 'gnus-summary-tick-article-backward)
9056 (make-obsolete 'gnus-summary-mark-as-unread-backward
9057 'gnus-summary-tick-article-backward)
9058 (defun gnus-summary-tick-article-backward (n)
9059 "Tick N articles backwards.
9060 The difference between N and the number of articles ticked is returned."
9062 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9064 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9065 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9066 (defun gnus-summary-tick-article (&optional article clear-mark)
9067 "Mark current article as unread.
9068 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9069 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9070 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9073 (defun gnus-summary-mark-as-read-forward (n)
9074 "Mark N articles as read forwards.
9075 If N is negative, mark backwards instead.
9076 The difference between N and the actual number of articles marked is
9079 (gnus-summary-mark-forward n gnus-del-mark t))
9081 (defun gnus-summary-mark-as-read-backward (n)
9082 "Mark the N articles as read backwards.
9083 The difference between N and the actual number of articles marked is
9086 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9088 (defun gnus-summary-mark-as-read (&optional article mark)
9089 "Mark current article as read.
9090 ARTICLE specifies the article to be marked as read.
9091 MARK specifies a string to be inserted at the beginning of the line."
9092 (gnus-summary-mark-article article mark))
9094 (defun gnus-summary-clear-mark-forward (n)
9095 "Clear marks from N articles forward.
9096 If N is negative, clear backward instead.
9097 The difference between N and the number of marks cleared is returned."
9099 (gnus-summary-mark-forward n gnus-unread-mark))
9101 (defun gnus-summary-clear-mark-backward (n)
9102 "Clear marks from N articles backward.
9103 The difference between N and the number of marks cleared is returned."
9105 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9107 (defun gnus-summary-mark-unread-as-read ()
9108 "Intended to be used by `gnus-summary-mark-article-hook'."
9109 (or (memq gnus-current-article gnus-newsgroup-marked)
9110 (memq gnus-current-article gnus-newsgroup-dormant)
9111 (memq gnus-current-article gnus-newsgroup-expirable)
9112 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
9114 (defun gnus-summary-mark-region-as-read (point mark all)
9115 "Mark all unread articles between point and mark as read.
9116 If given a prefix, mark all articles between point and mark as read,
9117 even ticked and dormant ones."
9118 (interactive "r\nP")
9128 (not (memq (gnus-summary-article-number)
9129 gnus-newsgroup-marked))
9130 (not (memq (gnus-summary-article-number)
9131 gnus-newsgroup-dormant))))
9132 (gnus-summary-mark-article
9133 (gnus-summary-article-number) gnus-del-mark))
9135 (zerop (forward-line 1))))))
9137 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9138 (defalias 'gnus-summary-delete-marked-as-read
9139 'gnus-summary-remove-lines-marked-as-read)
9140 (make-obsolete 'gnus-summary-delete-marked-as-read
9141 'gnus-summary-remove-lines-marked-as-read)
9142 (defun gnus-summary-remove-lines-marked-as-read ()
9143 "Remove lines that are marked as read."
9145 (gnus-summary-remove-lines-marked-with
9147 (lambda (char) (char-to-string (symbol-value char)))
9148 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9149 gnus-killed-mark gnus-kill-file-mark
9150 gnus-low-score-mark gnus-expirable-mark
9154 (defalias 'gnus-summary-delete-marked-with
9155 'gnus-summary-remove-lines-marked-with)
9156 (make-obsolete 'gnus-summary-delete-marked-with
9157 'gnus-summary-remove-lines-marked-with)
9158 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9159 (defun gnus-summary-remove-lines-marked-with (marks)
9160 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9161 (interactive "sMarks: ")
9162 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9163 (gnus-set-global-variables)
9164 (let ((buffer-read-only nil)
9165 (marks (concat "^[" marks "]")))
9166 (goto-char (point-min))
9167 (if gnus-newsgroup-adaptive
9168 (gnus-score-remove-lines-adaptive marks)
9169 (while (re-search-forward marks nil t)
9170 (gnus-delete-line)))
9171 ;; If we use dummy roots, we have to do an additional sweep over
9173 (if (not (eq gnus-summary-make-false-root 'dummy))
9175 (goto-char (point-min))
9176 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9177 (while (re-search-forward marks nil t)
9178 (if (gnus-subject-equal
9179 (gnus-summary-subject-string)
9182 (gnus-summary-subject-string)))
9185 (gnus-delete-line)))))
9186 (or (zerop (buffer-size))
9188 (gnus-summary-prev-subject 1)
9189 (gnus-summary-position-cursor))))
9191 (defun gnus-summary-expunge-below (score)
9192 "Remove articles with score less than SCORE."
9194 (gnus-set-global-variables)
9195 (setq score (if score
9196 (prefix-numeric-value score)
9197 (or gnus-summary-default-score 0)))
9199 (set-buffer gnus-summary-buffer)
9200 (goto-char (point-min))
9201 (let ((buffer-read-only nil)
9204 (if (< (gnus-summary-article-score) score)
9208 (delete-region beg (point)))
9211 (or (zerop (buffer-size))
9213 (gnus-summary-prev-subject 1)
9214 (gnus-summary-position-cursor))))))
9216 (defun gnus-summary-mark-below (score mark)
9217 "Mark articles with score less than SCORE with MARK."
9218 (interactive "P\ncMark: ")
9219 (gnus-set-global-variables)
9220 (setq score (if score
9221 (prefix-numeric-value score)
9222 (or gnus-summary-default-score 0)))
9224 (set-buffer gnus-summary-buffer)
9225 (goto-char (point-min))
9227 (and (< (gnus-summary-article-score) score)
9228 (gnus-summary-mark-article nil mark))
9231 (defun gnus-summary-kill-below (score)
9232 "Mark articles with score below SCORE as read."
9234 (gnus-summary-mark-below score gnus-killed-mark))
9236 (defun gnus-summary-clear-above (score)
9237 "Clear all marks from articles with score above SCORE."
9239 (gnus-summary-mark-above score gnus-unread-mark))
9241 (defun gnus-summary-tick-above (score)
9242 "Tick all articles with score above SCORE."
9244 (gnus-summary-mark-above score gnus-ticked-mark))
9246 (defun gnus-summary-mark-above (score mark)
9247 "Mark articles with score over SCORE with MARK."
9248 (interactive "P\ncMark: ")
9249 (setq score (if score
9250 (prefix-numeric-value score)
9251 (or gnus-summary-default-score 0)))
9253 (set-buffer gnus-summary-buffer)
9254 (goto-char (point-min))
9256 (if (> (gnus-summary-article-score) score)
9258 (gnus-summary-mark-article nil mark)
9260 (forward-line 1)))))
9262 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9263 (defun gnus-summary-show-all-expunged ()
9264 "Display all the hidden articles that were expunged for low scores."
9266 (let ((buffer-read-only nil))
9267 (let ((scored gnus-newsgroup-scored)
9270 (or (gnus-summary-goto-subject (car (car scored)))
9271 (and (setq h (gnus-get-header-by-number (car (car scored))))
9272 (< (cdr (car scored)) gnus-summary-expunge-below)
9273 (setq headers (cons h headers))))
9274 (setq scored (cdr scored)))
9275 (or headers (error "No expunged articles hidden."))
9276 (goto-char (point-min))
9278 (gnus-summary-update-lines
9281 (gnus-summary-prepare-threads (nreverse headers) 0)
9283 (goto-char (point-min))
9284 (gnus-summary-position-cursor)))
9286 (defun gnus-summary-show-all-dormant ()
9287 "Display all the hidden articles that are marked as dormant."
9289 (let ((buffer-read-only nil))
9290 (let ((dormant gnus-newsgroup-dormant)
9293 (or (gnus-summary-goto-subject (car dormant))
9294 (and (setq h (gnus-get-header-by-number (car dormant)))
9295 (setq headers (cons h headers))))
9296 (setq dormant (cdr dormant)))
9297 (or headers (error "No dormant articles hidden."))
9298 (goto-char (point-min))
9300 (gnus-summary-update-lines
9303 (gnus-summary-prepare-threads (nreverse headers) 0)
9305 (goto-char (point-min))
9306 (gnus-summary-position-cursor)))
9308 (defun gnus-summary-hide-all-dormant ()
9309 "Hide all dormant articles."
9311 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9312 (gnus-summary-position-cursor))
9314 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
9315 "Mark all articles not marked as unread in this newsgroup as read.
9316 If prefix argument ALL is non-nil, all articles are marked as read.
9317 If QUIETLY is non-nil, no questions will be asked.
9318 If TO-HERE is non-nil, it should be a point in the buffer. All
9319 articles before this point will be marked as read.
9320 The number of articles marked as read is returned."
9324 (not gnus-interactive-catchup) ;Without confirmation?
9328 "Mark absolutely all articles as read? "
9329 "Mark all unread articles as read? ")))
9331 (not gnus-newsgroup-adaptive)
9332 (not gnus-newsgroup-auto-expire))
9334 (and all (setq gnus-newsgroup-marked nil
9335 gnus-newsgroup-dormant nil))
9336 (setq gnus-newsgroup-unreads
9337 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9338 ;; We actually mark all articles as canceled, which we
9339 ;; have to do when using auto-expiry or adaptive scoring.
9340 (let ((unreads (length gnus-newsgroup-unreads)))
9341 (if (gnus-summary-first-subject (not all))
9342 (while (and (if to-here (< (point) to-here) t)
9343 (gnus-summary-mark-as-read nil gnus-catchup-mark)
9344 (gnus-summary-search-subject nil (not all)))))
9345 (- unreads (length gnus-newsgroup-unreads))
9347 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9348 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9349 (if (and (not to-here) (eq 'nnvirtual (car method)))
9350 (nnvirtual-catchup-group
9351 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9352 (gnus-summary-position-cursor)))
9354 (defun gnus-summary-catchup-to-here (&optional all)
9355 "Mark all unticked articles before the current one as read.
9356 If ALL is non-nil, also mark ticked and dormant articles as read."
9360 (gnus-summary-catchup all t (point))
9361 (gnus-set-mode-line 'summary))
9362 (gnus-summary-position-cursor))
9364 (defun gnus-summary-catchup-all (&optional quietly)
9365 "Mark all articles in this newsgroup as read."
9367 (gnus-summary-catchup t quietly))
9369 (defun gnus-summary-catchup-and-exit (all &optional quietly)
9370 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9371 If prefix argument ALL is non-nil, all articles are marked as read."
9373 (gnus-summary-catchup all quietly nil 'fast)
9374 ;; Select next newsgroup or exit.
9375 (if (eq gnus-auto-select-next 'quietly)
9376 (gnus-summary-next-group nil)
9377 (gnus-summary-exit)))
9379 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9380 "Mark all articles in this newsgroup as read, and then exit."
9382 (gnus-summary-catchup-and-exit t quietly))
9384 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9385 (defun gnus-summary-catchup-and-goto-next-group (all)
9386 "Mark all articles in this group as read and select the next group.
9387 If given a prefix, mark all articles, unread as well as ticked, as
9390 (gnus-summary-catchup all)
9391 (gnus-summary-next-group))
9393 ;; Thread-based commands.
9395 (defun gnus-summary-toggle-threads (arg)
9396 "Toggle showing conversation threads.
9397 If ARG is positive number, turn showing conversation threads on."
9399 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9400 (setq gnus-show-threads
9401 (if (null arg) (not gnus-show-threads)
9402 (> (prefix-numeric-value arg) 0)))
9403 (gnus-summary-prepare)
9404 (gnus-summary-goto-subject current)
9405 (gnus-summary-position-cursor)))
9407 (defun gnus-summary-show-all-threads ()
9411 (let ((buffer-read-only nil))
9412 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9413 (gnus-summary-position-cursor))
9415 (defun gnus-summary-show-thread ()
9416 "Show thread subtrees.
9417 Returns nil if no thread was there to be shown."
9421 (let ((buffer-read-only nil)
9422 ;; first goto end then to beg, to have point at beg after let
9423 (end (progn (end-of-line) (point)))
9424 (beg (progn (beginning-of-line) (point))))
9426 ;; Any hidden lines here?
9427 (search-forward "\r" end t)
9428 (subst-char-in-region beg end ?\^M ?\n t))))
9429 (gnus-summary-position-cursor)))
9431 (defun gnus-summary-hide-all-threads ()
9432 "Hide all thread subtrees."
9435 (goto-char (point-min))
9436 (gnus-summary-hide-thread)
9437 (while (and (not (eobp)) (zerop (forward-line 1)))
9438 (gnus-summary-hide-thread)))
9439 (gnus-summary-position-cursor))
9441 (defun gnus-summary-hide-thread ()
9442 "Hide thread subtrees.
9443 Returns nil if no threads were there to be hidden."
9445 (let ((buffer-read-only nil)
9447 (level (gnus-summary-thread-level))
9449 ;; Go forward until either the buffer ends or the subthread
9453 (while (and (zerop (forward-line 1))
9454 (> (gnus-summary-thread-level) level))
9459 (search-backward "\n" start t))
9460 (subst-char-in-region start end ?\n ?\^M t)
9461 (forward-line -1)))))
9463 (defun gnus-summary-go-to-next-thread (&optional previous)
9464 "Go to the same level (or less) next thread.
9465 If PREVIOUS is non-nil, go to previous thread instead.
9466 Return the article number moved to, or nil if moving was impossible."
9467 (let ((level (gnus-summary-thread-level))
9468 (article (gnus-summary-article-number)))
9470 (while (and (zerop (forward-line -1))
9471 (> (gnus-summary-thread-level) level)))
9472 (while (and (save-excursion
9475 (zerop (forward-line 1))
9476 (> (gnus-summary-thread-level) level))))
9477 (gnus-summary-recenter)
9478 (gnus-summary-position-cursor)
9479 (let ((oart (gnus-summary-article-number)))
9480 (and (/= oart article) oart))))
9482 (defun gnus-summary-next-thread (n)
9483 "Go to the same level next N'th thread.
9484 If N is negative, search backward instead.
9485 Returns the difference between N and the number of skips actually
9488 (let ((backward (< n 0))
9491 (gnus-summary-go-to-next-thread backward))
9493 (gnus-summary-position-cursor)
9494 (if (/= 0 n) (gnus-message 7 "No more threads"))
9497 (defun gnus-summary-prev-thread (n)
9498 "Go to the same level previous N'th thread.
9499 Returns the difference between N and the number of skips actually
9502 (gnus-summary-next-thread (- n)))
9504 (defun gnus-summary-go-down-thread (&optional same)
9505 "Go down one level in the current thread.
9506 If SAME is non-nil, also move to articles of the same level."
9507 (let ((level (gnus-summary-thread-level))
9509 (if (and (zerop (forward-line 1))
9510 (> (gnus-summary-thread-level) level))
9515 (defun gnus-summary-go-up-thread ()
9516 "Go up one level in the current thread."
9517 (let ((level (gnus-summary-thread-level))
9519 (while (and (zerop (forward-line -1))
9520 (>= (gnus-summary-thread-level) level)))
9521 (if (>= (gnus-summary-thread-level) level)
9527 (defun gnus-summary-down-thread (n)
9528 "Go down thread N steps.
9529 If N is negative, go up instead.
9530 Returns the difference between N and how many steps down that were
9536 (if up (gnus-summary-go-up-thread)
9537 (gnus-summary-go-down-thread)))
9539 (gnus-summary-position-cursor)
9540 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9543 (defun gnus-summary-up-thread (n)
9544 "Go up thread N steps.
9545 If N is negative, go up instead.
9546 Returns the difference between N and how many steps down that were
9549 (gnus-summary-down-thread (- n)))
9551 (defun gnus-summary-kill-thread (unmark)
9552 "Mark articles under current thread as read.
9553 If the prefix argument is positive, remove any kinds of marks.
9554 If the prefix argument is negative, tick articles instead."
9557 (setq unmark (prefix-numeric-value unmark)))
9559 (level (gnus-summary-thread-level)))
9562 ;; Mark the article...
9563 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
9564 ((> unmark 0) (gnus-summary-tick-article nil t))
9565 (t (gnus-summary-tick-article)))
9566 ;; ...and go forward until either the buffer ends or the subtree
9568 (if (not (and (zerop (forward-line 1))
9569 (> (gnus-summary-thread-level) level)))
9570 (setq killing nil))))
9571 ;; Hide killed subtrees.
9573 gnus-thread-hide-killed
9574 (gnus-summary-hide-thread))
9575 ;; If marked as read, go to next unread subject.
9577 ;; Go to next unread subject.
9578 (gnus-summary-next-subject 1 t)))
9579 (gnus-set-mode-line 'summary))
9581 ;; Summary sorting commands
9583 (defun gnus-summary-sort-by-number (&optional reverse)
9584 "Sort summary buffer by article number.
9585 Argument REVERSE means reverse order."
9588 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9590 (defun gnus-summary-sort-by-author (&optional reverse)
9591 "Sort summary buffer by author name alphabetically.
9592 If case-fold-search is non-nil, case of letters is ignored.
9593 Argument REVERSE means reverse order."
9598 (let ((extract (funcall
9599 gnus-extract-address-components
9600 (header-from (gnus-get-header-by-number
9601 (gnus-summary-article-number))))))
9602 (or (car extract) (cdr extract))))
9603 'gnus-thread-sort-by-author)
9606 (defun gnus-summary-sort-by-subject (&optional reverse)
9607 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9608 If case-fold-search is non-nil, case of letters is ignored.
9609 Argument REVERSE means reverse order."
9614 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9615 'gnus-thread-sort-by-subject)
9618 (defun gnus-summary-sort-by-date (&optional reverse)
9619 "Sort summary buffer by date.
9620 Argument REVERSE means reverse order."
9627 (gnus-get-header-by-number (gnus-summary-article-number)))))
9628 'gnus-thread-sort-by-date)
9631 (defun gnus-summary-sort-by-score (&optional reverse)
9632 "Sort summary buffer by score.
9633 Argument REVERSE means reverse order."
9636 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9639 (defvar gnus-summary-already-sorted nil)
9640 (defun gnus-summary-sort (predicate reverse)
9641 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9642 (if gnus-summary-already-sorted
9644 (let (buffer-read-only)
9645 (if (not gnus-show-threads)
9647 (goto-char (point-min))
9648 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9649 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9650 (gnus-summary-prepare-hook nil)
9651 (gnus-summary-already-sorted nil))
9652 (gnus-summary-prepare)
9653 (and gnus-show-threads
9654 gnus-thread-hide-subtree
9655 (gnus-summary-hide-all-threads))
9656 ;; If in async mode, we send some info to the backend.
9657 (and gnus-newsgroup-async
9658 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
9659 (gnus-request-asynchronous
9661 (if (and gnus-asynchronous-article-function
9662 (fboundp gnus-asynchronous-article-function))
9663 (funcall gnus-asynchronous-article-function
9664 gnus-newsgroup-threads)))))))))
9667 (defun gnus-sortable-date (date)
9668 "Make sortable string by string-lessp from DATE.
9669 Timezone package is used."
9670 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9671 (year (aref date 0))
9672 (month (aref date 1))
9673 (day (aref date 2)))
9674 (timezone-make-sortable-date
9676 (timezone-make-time-string
9677 (aref date 3) (aref date 4) (aref date 5)))))
9680 ;; Summary saving commands.
9682 (defun gnus-summary-save-article (n)
9683 "Save the current article using the default saver function.
9684 If N is a positive number, save the N next articles.
9685 If N is a negative number, save the N previous articles.
9686 If N is nil and any articles have been marked with the process mark,
9687 save those articles instead.
9688 The variable `gnus-default-article-saver' specifies the saver function."
9690 (let ((articles (gnus-summary-work-articles n)))
9692 (let ((header (gnus-get-header-by-number (car articles))))
9693 (if (vectorp header)
9695 (gnus-summary-select-article t nil nil (car articles))
9696 (or gnus-save-all-headers
9697 (gnus-article-hide-headers t))
9698 ;; Remove any X-Gnus lines.
9701 (set-buffer gnus-article-buffer)
9702 (let ((buffer-read-only nil))
9703 (goto-char (point-min))
9704 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9706 (while (re-search-forward "^X-Gnus" nil t)
9708 (delete-region (point)
9709 (progn (forward-line 1) (point))))
9712 (if gnus-default-article-saver
9713 (funcall gnus-default-article-saver)
9714 (error "No default saver is defined."))))
9715 (if (assq 'name header)
9716 (gnus-copy-file (cdr (assq 'name header)))
9717 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9718 (gnus-summary-remove-process-mark (car articles))
9719 (setq articles (cdr articles)))
9720 (gnus-summary-position-cursor)
9723 (defun gnus-summary-pipe-output (arg)
9724 "Pipe the current article to a subprocess.
9725 If N is a positive number, pipe the N next articles.
9726 If N is a negative number, pipe the N previous articles.
9727 If N is nil and any articles have been marked with the process mark,
9728 pipe those articles instead."
9730 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9731 (gnus-summary-save-article arg)))
9733 (defun gnus-summary-save-article-mail (arg)
9734 "Append the current article to an mail file.
9735 If N is a positive number, save the N next articles.
9736 If N is a negative number, save the N previous articles.
9737 If N is nil and any articles have been marked with the process mark,
9738 save those articles instead."
9740 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9741 (gnus-summary-save-article arg)))
9743 (defun gnus-summary-save-article-rmail (arg)
9744 "Append the current article to an rmail file.
9745 If N is a positive number, save the N next articles.
9746 If N is a negative number, save the N previous articles.
9747 If N is nil and any articles have been marked with the process mark,
9748 save those articles instead."
9750 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9751 (gnus-summary-save-article arg)))
9753 (defun gnus-summary-save-article-file (arg)
9754 "Append the current article to a file.
9755 If N is a positive number, save the N next articles.
9756 If N is a negative number, save the N previous articles.
9757 If N is nil and any articles have been marked with the process mark,
9758 save those articles instead."
9760 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9761 (gnus-summary-save-article arg)))
9763 (defun gnus-read-save-file-name (prompt default-name)
9764 (let ((methods gnus-split-methods)
9766 (if (not gnus-split-methods)
9769 (set-buffer gnus-article-buffer)
9770 (gnus-narrow-to-headers)
9772 (goto-char (point-min))
9773 (and (condition-case ()
9774 (re-search-forward (car (car methods)) nil t)
9776 (setq split-name (cons (nth 1 (car methods)) split-name)))
9777 (setq methods (cdr methods)))
9779 (cond ((null split-name)
9781 (concat prompt " (default "
9782 (file-name-nondirectory default-name) ") ")
9783 (file-name-directory default-name)
9785 ((= 1 (length split-name))
9787 (concat prompt " (default " (car split-name) ") ")
9788 gnus-article-save-directory
9789 (concat gnus-article-save-directory (car split-name))))
9791 (setq split-name (mapcar (lambda (el) (list el))
9792 (nreverse split-name)))
9793 (let ((result (completing-read
9795 split-name nil nil)))
9796 (concat gnus-article-save-directory
9797 (if (string= result "")
9798 (car (car split-name))
9801 (defun gnus-summary-save-in-rmail (&optional filename)
9802 "Append this article to Rmail file.
9803 Optional argument FILENAME specifies file name.
9804 Directory to save to is default to `gnus-article-save-directory' which
9805 is initialized from the SAVEDIR environment variable."
9808 (funcall gnus-rmail-save-name gnus-newsgroup-name
9809 gnus-current-headers gnus-newsgroup-last-rmail)))
9811 (setq filename (gnus-read-save-file-name
9812 "Save in rmail file:" default-name)))
9813 (gnus-make-directory (file-name-directory filename))
9814 (gnus-eval-in-buffer-window
9819 (gnus-output-to-rmail filename))))
9820 ;; Remember the directory name to save articles.
9821 (setq gnus-newsgroup-last-rmail filename)))
9823 (defun gnus-summary-save-in-mail (&optional filename)
9824 "Append this article to Unix mail file.
9825 Optional argument FILENAME specifies file name.
9826 Directory to save to is default to `gnus-article-save-directory' which
9827 is initialized from the SAVEDIR environment variable."
9830 (funcall gnus-mail-save-name gnus-newsgroup-name
9831 gnus-current-headers gnus-newsgroup-last-mail)))
9833 (setq filename (gnus-read-save-file-name
9834 "Save in Unix mail file:" default-name)))
9836 (expand-file-name filename
9838 (file-name-directory default-name))))
9839 (gnus-make-directory (file-name-directory filename))
9840 (gnus-eval-in-buffer-window
9845 (if (and (file-readable-p filename) (rmail-file-p filename))
9846 (gnus-output-to-rmail filename)
9847 (rmail-output filename 1 t t)))))
9848 ;; Remember the directory name to save articles.
9849 (setq gnus-newsgroup-last-mail filename)))
9851 (defun gnus-summary-save-in-file (&optional filename)
9852 "Append this article to file.
9853 Optional argument FILENAME specifies file name.
9854 Directory to save to is default to `gnus-article-save-directory' which
9855 is initialized from the SAVEDIR environment variable."
9858 (funcall gnus-file-save-name gnus-newsgroup-name
9859 gnus-current-headers gnus-newsgroup-last-file)))
9861 (setq filename (gnus-read-save-file-name
9862 "Save in file:" default-name)))
9863 (gnus-make-directory (file-name-directory filename))
9864 (gnus-eval-in-buffer-window
9869 (gnus-output-to-file filename))))
9870 ;; Remember the directory name to save articles.
9871 (setq gnus-newsgroup-last-file filename)))
9873 (defun gnus-summary-save-in-pipe (&optional command)
9874 "Pipe this article to subprocess."
9876 (let ((command (read-string "Shell command on article: "
9877 gnus-last-shell-command)))
9878 (if (string-equal command "")
9879 (setq command gnus-last-shell-command))
9880 (gnus-eval-in-buffer-window
9884 (shell-command-on-region (point-min) (point-max) command nil)))
9885 (setq gnus-last-shell-command command)))
9887 ;; Summary extract commands
9889 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9890 (let ((buffer-read-only nil)
9891 (article (gnus-summary-article-number))
9893 (or (gnus-summary-goto-subject article)
9894 (error (format "No such article: %d" article)))
9895 (or gnus-newsgroup-headers-hashtb-by-number
9896 (gnus-make-headers-hashtable-by-number))
9897 (gnus-summary-position-cursor)
9898 ;; If all commands are to be bunched up on one line, we collect
9900 (if gnus-view-pseudos-separately
9902 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9905 (setq action (cdr (assq 'action (car ps))))
9906 (setq files (list (cdr (assq 'name (car ps)))))
9907 (while (and ps (cdr ps)
9908 (string= (or action "1")
9909 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9910 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9911 (setcdr ps (cdr (cdr ps))))
9914 (if (not (string-match "%s" action))
9915 (setq files (cons " " files)))
9916 (setq files (cons " " files))
9917 (and (assq 'execute (car ps))
9918 (setcdr (assq 'execute (car ps))
9919 (funcall (if (string-match "%s" action)
9922 (mapconcat (lambda (f) f) files " ")))))
9923 (setq ps (cdr ps)))))
9924 (if (and gnus-view-pseudos (not not-view))
9926 (and (assq 'execute (car pslist))
9927 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9928 (eq gnus-view-pseudos 'not-confirm)))
9929 (setq pslist (cdr pslist)))
9932 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9933 (gnus-summary-article-number)))
9936 (insert " " (file-name-nondirectory
9937 (cdr (assq 'name (car pslist))))
9938 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9939 (add-text-properties
9940 b (1+ b) (list 'gnus-number gnus-reffed-article-number
9941 'gnus-mark gnus-unread-mark
9943 'gnus-pseudo (car pslist)))
9945 (gnus-sethash (int-to-string gnus-reffed-article-number)
9946 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9947 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9948 (setq pslist (cdr pslist)))))))
9950 (defun gnus-pseudos< (p1 p2)
9951 (let ((c1 (cdr (assq 'action p1)))
9952 (c2 (cdr (assq 'action p2))))
9953 (and c1 c2 (string< c1 c2))))
9955 (defun gnus-request-pseudo-article (props)
9956 (cond ((assq 'execute props)
9957 (gnus-execute-command (cdr (assq 'execute props)))))
9958 (let ((gnus-current-article (gnus-summary-article-number)))
9959 (run-hooks 'gnus-mark-article-hook)))
9961 (defun gnus-execute-command (command &optional automatic)
9963 (gnus-article-setup-buffer)
9964 (set-buffer gnus-article-buffer)
9965 (let ((command (if automatic command (read-string "Command: " command)))
9966 (buffer-read-only nil))
9968 (insert "$ " command "\n\n")
9969 (if gnus-view-pseudo-asynchronously
9970 (start-process "gnus-execute" nil "sh" "-c" command)
9971 (call-process "sh" nil t nil "-c" command)))))
9973 (defun gnus-copy-file (file &optional to)
9976 (list (read-file-name "Copy file: " default-directory)
9977 (read-file-name "Copy file to: " default-directory)))
9978 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9979 (and (file-directory-p to)
9980 (setq to (concat (file-name-as-directory to)
9981 (file-name-nondirectory file))))
9982 (copy-file file to))
9984 ;; Summary kill commands.
9986 (defun gnus-summary-edit-global-kill (article)
9987 "Edit the \"global\" kill file."
9988 (interactive (list (gnus-summary-article-number)))
9989 (gnus-group-edit-global-kill article))
9991 (defun gnus-summary-edit-local-kill ()
9992 "Edit a local kill file applied to the current newsgroup."
9994 (setq gnus-current-headers
9996 (int-to-string (gnus-summary-article-number))
9997 gnus-newsgroup-headers-hashtb-by-number))
9998 (gnus-set-global-variables)
9999 (gnus-group-edit-local-kill
10000 (gnus-summary-article-number) gnus-newsgroup-name))
10004 ;;; Gnus article mode
10007 (put 'gnus-article-mode 'mode-class 'special)
10009 (if gnus-article-mode-map
10011 (setq gnus-article-mode-map (make-keymap))
10012 (suppress-keymap gnus-article-mode-map)
10013 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10014 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10015 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10016 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10017 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10018 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10019 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10020 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10021 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10022 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10023 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10024 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10026 ;; Duplicate almost all summary keystrokes in the article mode map.
10029 " " "\177" "\r" "n" "p" "N" "P" "\M-\C-n" "\M-\C-p"
10030 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j" "^" "\M-^"
10031 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10032 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10033 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10034 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10035 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10036 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10037 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10038 "\C-c\C-i" "x" "X" "s" "t" "g" "?" "l"
10039 "\C-c\C-v\C-v" "\C-d" "v"
10040 ;; "Mt" "M!" "Md" "Mr"
10041 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10042 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10043 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10044 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10045 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10046 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10047 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10048 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10049 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10050 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10051 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10054 (define-key gnus-article-mode-map (car commands)
10055 'gnus-article-summary-command)
10056 (setq commands (cdr commands))))
10058 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10059 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10062 (define-key gnus-article-mode-map (car commands)
10063 'gnus-article-summary-command-nosave)
10064 (setq commands (cdr commands)))))
10067 (defun gnus-article-mode ()
10068 "Major mode for displaying an article.
10070 All normal editing commands are switched off.
10072 The following commands are available:
10074 \\<gnus-article-mode-map>
10075 \\[gnus-article-next-page]\t Scroll the article one page forwards
10076 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10077 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10078 \\[gnus-article-show-summary]\t Display the summary buffer
10079 \\[gnus-article-mail]\t Send a reply to the address near point
10080 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10081 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10082 \\[gnus-info-find-node]\t Go to the Gnus info node"
10084 (if gnus-visual (gnus-article-make-menu-bar))
10085 (kill-all-local-variables)
10086 (setq mode-line-modified "-- ")
10087 (make-local-variable 'mode-line-format)
10088 (setq mode-line-format (copy-sequence mode-line-format))
10089 (and (equal (nth 3 mode-line-format) " ")
10090 (setcar (nthcdr 3 mode-line-format) ""))
10091 (setq mode-name "Article")
10092 (setq major-mode 'gnus-article-mode)
10093 (make-local-variable 'minor-mode-alist)
10094 (or (assq 'gnus-show-mime minor-mode-alist)
10095 (setq minor-mode-alist
10096 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10097 (use-local-map gnus-article-mode-map)
10098 (make-local-variable 'page-delimiter)
10099 (setq page-delimiter gnus-page-delimiter)
10100 (buffer-disable-undo (current-buffer))
10101 (setq buffer-read-only t) ;Disable modification
10102 (run-hooks 'gnus-article-mode-hook))
10104 (defun gnus-article-setup-buffer ()
10105 "Initialize article mode buffer."
10106 (if (get-buffer gnus-article-buffer)
10108 (set-buffer gnus-article-buffer)
10109 (buffer-disable-undo (current-buffer))
10110 (setq buffer-read-only t)
10111 (gnus-add-current-to-buffer-list)
10112 (or (eq major-mode 'gnus-article-mode)
10113 (gnus-article-mode)))
10115 (set-buffer (get-buffer-create gnus-article-buffer))
10116 (gnus-add-current-to-buffer-list)
10117 (gnus-article-mode))))
10119 ;; Set article window start at LINE, where LINE is the number of lines
10120 ;; from the head of the article.
10121 (defun gnus-article-set-window-start (&optional line)
10123 (get-buffer-window gnus-article-buffer)
10125 (set-buffer gnus-article-buffer)
10126 (goto-char (point-min))
10129 (gnus-message 6 "Moved to bookmark")
10130 (search-forward "\n\n" nil t)
10131 (forward-line line)
10134 (defun gnus-request-article-this-buffer (article group)
10135 "Get an article and insert it into this buffer."
10136 (setq group (or group gnus-newsgroup-name))
10138 ;; Open server if it has closed.
10139 (gnus-check-news-server (gnus-find-method-for-group group))
10141 ;; Using `gnus-request-article' directly will insert the article into
10142 ;; `nntp-server-buffer' - so we'll save some time by not having to
10143 ;; copy it from the server buffer into the article buffer.
10145 ;; We only request an article by message-id when we do not have the
10146 ;; headers for it, so we'll have to get those.
10147 (and (stringp article)
10148 (let ((gnus-override-method gnus-refer-article-method))
10149 (gnus-read-header article)))
10151 ;; If the article number is negative, that means that this article
10152 ;; doesn't belong in this newsgroup (possibly), so we find its
10153 ;; message-id and request it by id instead of number.
10154 (if (not (numberp article))
10157 (set-buffer gnus-summary-buffer)
10158 (let ((header (gnus-get-header-by-number article)))
10160 (if (vectorp header)
10161 ;; It's a real article.
10162 (setq article (header-id header))
10163 ;; It is an extracted pseudo-article.
10164 (setq article 'pseudo)
10165 (gnus-request-pseudo-article header)))
10167 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10168 (if (not (eq (car method) 'nneething))
10170 (let ((dir (concat (file-name-as-directory (nth 1 method))
10171 (header-subject header))))
10172 (if (file-directory-p dir)
10174 (setq article 'nneething)
10175 (gnus-group-enter-directory dir)))))))))
10177 ;; Check the cache.
10178 (if (and gnus-use-cache
10180 (gnus-cache-request-article article group))
10182 ;; Get the article and into the article buffer.
10183 (if (or (stringp article) (numberp article))
10186 (let ((gnus-override-method
10187 (and (stringp article) gnus-refer-article-method)))
10188 (and (gnus-request-article article group (current-buffer))
10192 (defun gnus-read-header (id)
10193 "Read the headers of article ID and enter them into the Gnus system."
10194 (or gnus-newsgroup-headers-hashtb-by-number
10195 (gnus-make-headers-hashtable-by-number))
10197 (if (not (setq header
10198 (car (if (let ((gnus-nov-is-evil t))
10199 (gnus-retrieve-headers
10200 (list id) gnus-newsgroup-name))
10201 (gnus-get-newsgroup-headers)))))
10204 (header-set-number header gnus-reffed-article-number))
10205 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10206 (gnus-sethash (int-to-string (header-number header)) header
10207 gnus-newsgroup-headers-hashtb-by-number)
10209 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10210 (setq gnus-current-headers header)
10213 (defun gnus-article-prepare (article &optional all-headers header)
10214 "Prepare ARTICLE in article mode buffer.
10215 ARTICLE should either be an article number or a Message-ID.
10216 If ARTICLE is an id, HEADER should be the article headers.
10217 If ALL-HEADERS is non-nil, no headers are hidden."
10219 ;; Make sure we start in a summary buffer.
10220 (or (eq major-mode 'gnus-summary-mode)
10221 (set-buffer gnus-summary-buffer))
10222 (setq gnus-summary-buffer (current-buffer))
10223 ;; Make sure the connection to the server is alive.
10224 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10226 (gnus-check-news-server
10227 (gnus-find-method-for-group gnus-newsgroup-name))
10228 (gnus-request-group gnus-newsgroup-name t)))
10229 (or gnus-newsgroup-headers-hashtb-by-number
10230 (gnus-make-headers-hashtable-by-number))
10231 (let* ((article (if header (header-number header) article))
10232 (summary-buffer (current-buffer))
10233 (internal-hook gnus-article-internal-prepare-hook)
10234 (group gnus-newsgroup-name)
10237 (gnus-article-setup-buffer)
10238 (set-buffer gnus-article-buffer)
10239 (if (not (setq result (let ((buffer-read-only nil))
10240 (gnus-request-article-this-buffer
10242 ;; There is no such article.
10244 (if (not (numberp article))
10246 (setq gnus-article-current
10247 (cons gnus-newsgroup-name article))
10248 (set-buffer gnus-summary-buffer)
10249 (setq gnus-current-article article)
10250 (gnus-summary-mark-as-read article gnus-canceled-mark))
10251 (gnus-message 1 "No such article (may be canceled)")
10254 (if (or (eq result 'pseudo) (eq result 'nneething))
10257 (set-buffer summary-buffer)
10258 (setq gnus-last-article gnus-current-article
10259 gnus-newsgroup-history (cons gnus-current-article
10260 gnus-newsgroup-history)
10261 gnus-current-article 0
10262 gnus-current-headers nil
10263 gnus-article-current nil)
10264 (if (eq result 'nneething)
10265 (gnus-configure-windows 'summary)
10266 (gnus-configure-windows 'article))
10267 (gnus-set-global-variables))
10268 (gnus-set-mode-line 'article))
10269 ;; The result from the `request' was an actual article -
10270 ;; or at least some text that is now displayed in the
10272 (if (and (numberp article)
10273 (not (eq article gnus-current-article)))
10274 ;; Seems like a new article has been selected.
10275 ;; `gnus-current-article' must be an article number.
10277 (set-buffer summary-buffer)
10278 (setq gnus-last-article gnus-current-article
10279 gnus-newsgroup-history (cons gnus-current-article
10280 gnus-newsgroup-history)
10281 gnus-current-article article
10282 gnus-current-headers
10283 (gnus-get-header-by-number gnus-current-article)
10284 gnus-article-current
10285 (cons gnus-newsgroup-name gnus-current-article))
10286 (gnus-summary-show-thread)
10287 (run-hooks 'gnus-mark-article-hook)
10288 (gnus-set-mode-line 'summary)
10290 (run-hooks 'gnus-visual-mark-article-hook))
10291 ;; Set the global newsgroup variables here.
10292 ;; Suggested by Jim Sisolak
10293 ;; <sisolak@trans4.neep.wisc.edu>.
10294 (gnus-set-global-variables)
10295 (and gnus-use-cache
10296 (gnus-cache-possibly-enter-article
10298 (gnus-get-header-by-number article)
10299 (memq article gnus-newsgroup-marked)
10300 (memq article gnus-newsgroup-dormant)
10301 (memq article gnus-newsgroup-unreads)))))
10302 ;; gnus-have-all-headers must be either T or NIL.
10303 (setq gnus-have-all-headers
10304 (not (not (or all-headers gnus-show-all-headers))))
10305 ;; Hooks for getting information from the article.
10306 ;; This hook must be called before being narrowed.
10307 (let (buffer-read-only)
10308 (run-hooks 'internal-hook)
10309 (run-hooks 'gnus-article-prepare-hook)
10310 ;; Decode MIME message.
10311 (if (and gnus-show-mime
10312 (or (not gnus-strict-mime)
10313 (gnus-fetch-field "Mime-Version")))
10314 (funcall gnus-show-mime-method))
10315 ;; Perform the article display hooks.
10316 (run-hooks 'gnus-article-display-hook))
10318 (goto-char (point-min))
10319 (and gnus-break-pages (gnus-narrow-to-page))
10320 (gnus-set-mode-line 'article)
10321 (gnus-configure-windows 'article)
10322 (goto-char (point-min))
10325 (defun gnus-article-show-all-headers ()
10326 "Show all article headers in article mode buffer."
10328 (gnus-article-setup-buffer)
10329 (set-buffer gnus-article-buffer)
10330 (let ((buffer-read-only nil))
10331 (remove-text-properties (point-min) (point-max)
10332 gnus-hidden-properties))))
10334 (defun gnus-article-hide-headers-if-wanted ()
10335 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10336 Provided for backwards compatability."
10337 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10338 (gnus-article-hide-headers)))
10340 (defun gnus-article-hide-headers (&optional delete)
10341 "Hide unwanted headers and possibly sort them as well."
10344 (set-buffer gnus-article-buffer)
10346 (let ((sorted gnus-sorted-header-list)
10347 (buffer-read-only nil)
10348 want-list beg want-l)
10349 ;; First we narrow to just the headers.
10351 (goto-char (point-min))
10352 ;; Hide any "From " lines at the beginning of (mail) articles.
10353 (while (looking-at "From ")
10356 (add-text-properties (point-min) (point) gnus-hidden-properties))
10357 ;; Then treat the rest of the header lines.
10360 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10361 ;; Then we use the two regular expressions
10362 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10363 ;; select which header lines is to remain visible in the
10365 (goto-char (point-min))
10366 (while (re-search-forward "^[^ \t]*:" nil t)
10367 (beginning-of-line)
10368 ;; We add the headers we want to keep to a list and delete
10369 ;; them from the buffer.
10370 (if (or (and (stringp gnus-visible-headers)
10371 (looking-at gnus-visible-headers))
10372 (and (not (stringp gnus-visible-headers))
10373 (stringp gnus-ignored-headers)
10374 (not (looking-at gnus-ignored-headers))))
10378 ;; Be sure to get multi-line headers...
10379 (re-search-forward "^[^ \t]*:" nil t)
10380 (beginning-of-line)
10382 (cons (buffer-substring beg (point)) want-list))
10383 (delete-region beg (point))
10386 ;; Next we perform the sorting by looking at
10387 ;; `gnus-sorted-header-list'.
10388 (goto-char (point-min))
10389 (while (and sorted want-list)
10390 (setq want-l want-list)
10392 (not (string-match (car sorted) (car want-l))))
10393 (setq want-l (cdr want-l)))
10396 (insert (car want-l))
10397 (setq want-list (delq (car want-l) want-list))))
10398 (setq sorted (cdr sorted)))
10399 ;; Any headers that were not matched by the sorted list we
10400 ;; just tack on the end of the visible header list.
10402 (insert (car want-list))
10403 (setq want-list (cdr want-list)))
10404 ;; And finally we make the unwanted headers invisible.
10406 (delete-region (point) (point-max))
10407 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10408 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10410 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10411 (defun gnus-article-treat-overstrike ()
10412 "Translate overstrikes into bold text."
10415 (set-buffer gnus-article-buffer)
10416 (let ((buffer-read-only nil))
10417 (while (search-forward "\b" nil t)
10418 (let ((next (following-char))
10419 (previous (char-after (- (point) 2))))
10420 (cond ((eq next previous)
10421 (delete-region (- (point) 2) (point))
10422 (put-text-property (point) (1+ (point))
10425 (delete-region (1- (point)) (1+ (point)))
10426 (put-text-property (1- (point)) (point)
10429 (delete-region (- (point) 2) (point))
10430 (put-text-property (point) (1+ (point))
10431 'face 'underline))))))))
10433 (defun gnus-article-word-wrap ()
10434 "Format too long lines."
10437 (set-buffer gnus-article-buffer)
10438 (let ((buffer-read-only nil))
10439 (goto-char (point-min))
10440 (search-forward "\n\n" nil t)
10442 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
10443 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
10444 (adaptive-fill-mode t))
10445 (while (not (eobp))
10446 (and (>= (current-column) (min fill-column (window-width)))
10447 (/= (preceding-char) ?:)
10448 (fill-paragraph nil))
10449 (end-of-line 2))))))
10451 (defun gnus-article-remove-cr ()
10452 "Remove carriage returns from an article."
10455 (set-buffer gnus-article-buffer)
10456 (let ((buffer-read-only nil))
10457 (goto-char (point-min))
10458 (while (search-forward "\r" nil t)
10459 (replace-match "" t t)))))
10461 (defun gnus-article-display-x-face (&optional force)
10462 "Look for an X-Face header and display it if present."
10463 (interactive (list 'force))
10465 (set-buffer gnus-article-buffer)
10466 (let ((inhibit-point-motion-hooks t)
10467 (case-fold-search nil))
10469 (goto-char (point-min))
10470 (search-forward "\n\n")
10471 (narrow-to-region (point-min) (point))
10472 (goto-char (point-min))
10473 (if (or (not gnus-article-x-face-command)
10475 (or (not gnus-article-x-face-too-ugly)
10476 (string-match gnus-article-x-face-too-ugly
10477 (mail-fetch-field "from"))))
10479 (goto-char (point-min))
10480 (not (re-search-forward "^X-Face: " nil t))))
10482 (let ((beg (point))
10483 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
10484 (if (symbolp gnus-article-x-face-command)
10485 (and (or (fboundp gnus-article-x-face-command)
10486 (error "%s is not a function"
10487 gnus-article-x-face-command))
10488 (funcall gnus-article-x-face-command beg end))
10489 (call-process-region beg end "sh" nil 0 nil
10490 "-c" gnus-article-x-face-command))))))))
10492 (defun gnus-article-de-quoted-unreadable (&optional force)
10493 "Do a naïve translation of a quoted-printable-encoded article.
10494 This is in no way, shape or form meant as a replacement for real MIME
10495 processing, but is simply a stop-gap measure until MIME support is
10497 If FORCE, decode the article whether it is marked as quoted-printable
10499 (interactive (list 'force))
10501 (set-buffer gnus-article-buffer)
10502 (let ((case-fold-search t)
10503 (buffer-read-only nil)
10504 (type (gnus-fetch-field "content-transfer-encoding")))
10505 (if (or force (and type (string-match "quoted-printable" type)))
10507 (goto-char (point-min))
10508 (search-forward "\n\n" nil 'move)
10509 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
10511 (defun gnus-mime-decode-quoted-printable (from to)
10512 ;; Decode quoted-printable from region between FROM and TO.
10515 (while (search-forward "=" to t)
10516 (cond ((eq (following-char) ?\n)
10519 ((looking-at "[0-9A-F][0-9A-F]")
10521 (insert (hexl-hex-string-to-integer
10522 (buffer-substring (point) (+ 2 (point)))))
10524 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
10526 (defvar gnus-article-time-units
10527 (list (cons 'year (* 365.25 24 60 60))
10528 (cons 'week (* 7 24 60 60))
10529 (cons 'day (* 24 60 60))
10530 (cons 'hour (* 60 60))
10534 (defun gnus-article-date-ut (&optional type)
10535 "Convert DATE date to universal time in the current article.
10536 If TYPE is `local', convert to local time; if it is `lapsed', output
10537 how much time has lapsed since DATE."
10538 (interactive (list 'ut))
10539 (let ((date (header-date (or gnus-current-headers
10540 (gnus-get-header-by-number
10541 (gnus-summary-article-number))"")))
10542 (date-regexp "^Date: \\|^X-Sent: "))
10547 (set-buffer gnus-article-buffer)
10548 (let ((buffer-read-only nil))
10549 (goto-char (point-min))
10550 (if (and (re-search-forward date-regexp nil t)
10552 (beginning-of-line)
10553 (looking-at date-regexp)))
10554 (delete-region (gnus-point-at-bol)
10555 (progn (end-of-line) (1+ (point))))
10556 (goto-char (point-min))
10557 (goto-char (- (search-forward "\n\n") 2)))
10561 (concat "Date: " (condition-case ()
10562 (timezone-make-date-arpa-standard date)
10568 (timezone-make-date-arpa-standard date nil "UT")
10572 ;; If the date is seriously mangled, the timezone
10573 ;; functions are liable to bug out, so we condition-case
10574 ;; the entire thing.
10575 (let* ((sec (condition-case ()
10576 (max (- (gnus-seconds-since-epoch
10577 (timezone-make-date-arpa-standard
10578 (current-time-string)
10579 (current-time-zone) "UT"))
10580 (gnus-seconds-since-epoch
10581 (timezone-make-date-arpa-standard
10590 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
10592 (setq sec (- sec (* num (cdr unit))))
10594 (concat (if prev ", " "") (int-to-string (floor num))
10595 " " (symbol-name (car unit))
10596 (if (> num 1) "s" ""))
10598 gnus-article-time-units "")
10601 (error "Unknown conversion type: %s" type)))))))))
10603 (defun gnus-article-date-local ()
10604 "Convert the current article date to the local timezone."
10606 (gnus-article-date-ut 'local))
10608 (defun gnus-article-date-lapsed ()
10609 "Convert the current article date to time lapsed since it was sent."
10611 (gnus-article-date-ut 'lapsed))
10613 (defun gnus-article-maybe-highlight ()
10614 (if gnus-visual (gnus-article-highlight)))
10618 (defun gnus-output-to-rmail (file-name)
10619 "Append the current article to an Rmail file named FILE-NAME."
10621 ;; Most of these codes are borrowed from rmailout.el.
10622 (setq file-name (expand-file-name file-name))
10623 (setq rmail-default-rmail-file file-name)
10624 (let ((artbuf (current-buffer))
10625 (tmpbuf (get-buffer-create " *Gnus-output*")))
10627 (or (get-file-buffer file-name)
10628 (file-exists-p file-name)
10629 (if (gnus-yes-or-no-p
10630 (concat "\"" file-name "\" does not exist, create it? "))
10631 (let ((file-buffer (create-file-buffer file-name)))
10633 (set-buffer file-buffer)
10634 (rmail-insert-rmail-file-header)
10635 (let ((require-final-newline nil))
10636 (write-region (point-min) (point-max) file-name t 1)))
10637 (kill-buffer file-buffer))
10638 (error "Output file does not exist")))
10639 (set-buffer tmpbuf)
10640 (buffer-disable-undo (current-buffer))
10642 (insert-buffer-substring artbuf)
10643 (gnus-convert-article-to-rmail)
10644 ;; Decide whether to append to a file or to an Emacs buffer.
10645 (let ((outbuf (get-file-buffer file-name)))
10647 (append-to-file (point-min) (point-max) file-name)
10648 ;; File has been visited, in buffer OUTBUF.
10649 (set-buffer outbuf)
10650 (let ((buffer-read-only nil)
10651 (msg (and (boundp 'rmail-current-message)
10652 (symbol-value 'rmail-current-message))))
10653 ;; If MSG is non-nil, buffer is in RMAIL mode.
10656 (narrow-to-region (point-max) (point-max))))
10657 (insert-buffer-substring tmpbuf)
10660 (goto-char (point-min))
10662 (search-backward "\^_")
10663 (narrow-to-region (point) (point-max))
10664 (goto-char (1+ (point-min)))
10665 (rmail-count-new-messages t)
10666 (rmail-show-message msg)))))))
10667 (kill-buffer tmpbuf)))
10669 (defun gnus-output-to-file (file-name)
10670 "Append the current article to a file named FILE-NAME."
10671 (setq file-name (expand-file-name file-name))
10672 (let ((artbuf (current-buffer))
10673 (tmpbuf (get-buffer-create " *Gnus-output*")))
10675 (set-buffer tmpbuf)
10676 (buffer-disable-undo (current-buffer))
10678 (insert-buffer-substring artbuf)
10679 ;; Append newline at end of the buffer as separator, and then
10680 ;; save it to file.
10681 (goto-char (point-max))
10683 (append-to-file (point-min) (point-max) file-name))
10684 (kill-buffer tmpbuf)))
10686 (defun gnus-convert-article-to-rmail ()
10687 "Convert article in current buffer to Rmail message format."
10688 (let ((buffer-read-only nil))
10689 ;; Convert article directly into Babyl format.
10690 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10691 (goto-char (point-min))
10692 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10693 (while (search-forward "\n\^_" nil t) ;single char
10694 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10695 (goto-char (point-max))
10698 (defun gnus-narrow-to-page (&optional arg)
10699 "Make text outside current page invisible except for page delimiter.
10700 A numeric arg specifies to move forward or backward by that many pages,
10701 thus showing a page other than the one point was originally in."
10703 (setq arg (if arg (prefix-numeric-value arg) 0))
10705 (forward-page -1) ;Beginning of current page.
10710 (forward-page (1- arg))))
10711 ;; Find the end of the page.
10713 ;; If we stopped due to end of buffer, stay there.
10714 ;; If we stopped after a page delimiter, put end of restriction
10715 ;; at the beginning of that line.
10716 ;; These are commented out.
10717 ;; (if (save-excursion (beginning-of-line)
10718 ;; (looking-at page-delimiter))
10719 ;; (beginning-of-line))
10720 (narrow-to-region (point)
10722 ;; Find the top of the page.
10724 ;; If we found beginning of buffer, stay there.
10725 ;; If extra text follows page delimiter on same line,
10727 ;; Otherwise, show text starting with following line.
10728 (if (and (eolp) (not (bobp)))
10732 (defun gnus-gmt-to-local ()
10733 "Rewrite Date header described in GMT to local in current buffer.
10734 Intended to be used with gnus-article-prepare-hook."
10738 (goto-char (point-min))
10739 (narrow-to-region (point-min)
10740 (progn (search-forward "\n\n" nil 'move) (point)))
10741 (goto-char (point-min))
10742 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10743 (let ((buffer-read-only nil)
10744 (date (buffer-substring-no-properties
10745 (match-beginning 1) (match-end 1))))
10746 (delete-region (match-beginning 1) (match-end 1))
10748 (timezone-make-date-arpa-standard
10749 date nil (current-time-zone))))))))
10752 ;; Article mode commands
10754 (defun gnus-article-next-page (lines)
10755 "Show next page of current article.
10756 If end of article, return non-nil. Otherwise return nil.
10757 Argument LINES specifies lines to be scrolled up."
10759 (move-to-window-line -1)
10760 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10761 (if (save-excursion
10763 (and (pos-visible-in-window-p) ;Not continuation line.
10765 ;; Nothing in this page.
10766 (if (or (not gnus-break-pages)
10769 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10771 (gnus-narrow-to-page 1) ;Go to next page.
10773 ;; More in this page.
10777 ;; Long lines may cause an end-of-buffer error.
10778 (goto-char (point-max))))
10781 (defun gnus-article-prev-page (lines)
10782 "Show previous page of current article.
10783 Argument LINES specifies lines to be scrolled down."
10785 (move-to-window-line 0)
10786 (if (and gnus-break-pages
10788 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10790 (gnus-narrow-to-page -1) ;Go to previous page.
10791 (goto-char (point-max))
10793 (scroll-down lines)))
10795 (defun gnus-article-refer-article ()
10796 "Read article specified by message-id around point."
10798 (search-forward ">" nil t) ;Move point to end of "<....>".
10799 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10801 (buffer-substring (match-beginning 1) (match-end 1))))
10802 (set-buffer gnus-summary-buffer)
10803 (gnus-summary-refer-article message-id))
10804 (error "No references around point")))
10806 (defun gnus-article-show-summary ()
10807 "Reconfigure windows to show summary buffer."
10809 (gnus-configure-windows 'article)
10810 (gnus-summary-goto-subject gnus-current-article))
10812 (defun gnus-article-describe-briefly ()
10813 "Describe article mode commands briefly."
10816 (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")))
10818 (defun gnus-article-summary-command ()
10819 "Execute the last keystroke in the summary buffer."
10821 (let ((obuf (current-buffer))
10822 (owin (current-window-configuration))
10824 (switch-to-buffer gnus-summary-buffer 'norecord)
10825 (setq func (lookup-key (current-local-map) (this-command-keys)))
10826 (call-interactively func)
10828 (set-window-configuration owin)
10829 (set-window-start (get-buffer-window (current-buffer)) (point))))
10831 (defun gnus-article-summary-command-nosave ()
10832 "Execute the last keystroke in the summary buffer."
10835 (switch-to-buffer gnus-summary-buffer 'norecord)
10836 (setq func (lookup-key (current-local-map) (this-command-keys)))
10837 (call-interactively func)))
10839 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
10840 ;; Modified by tower@prep Nov 86
10841 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
10843 (defun gnus-caesar-region (&optional n)
10844 "Caesar rotation of region by N, default 13, for decrypting netnews.
10845 ROT47 will be performed for Japanese text in any case."
10846 (interactive (if current-prefix-arg ; Was there a prefix arg?
10847 (list (prefix-numeric-value current-prefix-arg))
10849 (cond ((not (numberp n)) (setq n 13))
10850 (t (setq n (mod n 26)))) ;canonicalize N
10851 (if (not (zerop n)) ; no action needed for a rot of 0
10853 (if (or (not (boundp 'caesar-translate-table))
10854 (not caesar-translate-table)
10855 (/= (aref caesar-translate-table ?a) (+ ?a n)))
10857 (lower "abcdefghijklmnopqrstuvwxyz")
10859 (gnus-message 9 "Building caesar-translate-table...")
10860 (setq caesar-translate-table (make-vector 256 0))
10862 (aset caesar-translate-table i i)
10864 (setq lower (concat lower lower)
10865 upper (upcase lower)
10868 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
10869 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
10871 ;; ROT47 for Japanese text.
10872 ;; Thanks to ichikawa@flab.fujitsu.junet.
10874 (let ((t1 (logior ?O 128))
10875 (t2 (logior ?! 128))
10876 (t3 (logior ?~ 128)))
10878 (aset caesar-translate-table i
10879 (let ((v (aref caesar-translate-table i)))
10880 (if (<= v t1) (if (< v t2) v (+ v 47))
10881 (if (<= v t3) (- v 47) v))))
10883 (gnus-message 9 "Building caesar-translate-table...done")))
10884 (let ((from (region-beginning))
10887 (setq str (buffer-substring from to))
10888 (setq len (length str))
10890 (aset str i (aref caesar-translate-table (aref str i)))
10893 (delete-region from to)
10897 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10900 (defalias 'gnus-batch-kill 'gnus-batch-score)
10902 (defun gnus-batch-score ()
10903 "Run batched scoring.
10904 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10905 Newsgroups is a list of strings in Bnews format. If you want to score
10906 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10907 score the alt hierarchy, you'd say \"!alt.all\"."
10910 (gnus-newsrc-parse-options
10911 (apply (function concat)
10912 (mapcar (lambda (g) (concat g " "))
10913 command-line-args-left))))
10914 (gnus-expert-user t)
10915 (nnmail-spool-file nil)
10916 (gnus-use-dribble-file nil)
10917 (yes (car yes-and-no))
10918 (no (cdr yes-and-no))
10920 ;; Disable verbose message.
10921 gnus-novice-user gnus-large-newsgroup)
10922 ;; Eat all arguments.
10923 (setq command-line-args-left nil)
10926 ;; Apply kills to specified newsgroups in command line arguments.
10927 (setq newsrc (cdr gnus-newsrc-alist))
10929 (setq group (car (car newsrc)))
10930 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10931 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10933 (or (eq (car entry) t)
10934 (not (zerop (car entry)))))
10935 (if yes (string-match yes group) t)
10936 (or (null no) (not (string-match no group))))
10938 (gnus-summary-read-group group nil t)
10939 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10940 (gnus-summary-exit))))
10941 (setq newsrc (cdr newsrc)))
10943 (switch-to-buffer gnus-group-buffer)
10944 (gnus-group-save-newsrc)))
10946 (defun gnus-apply-kill-file ()
10947 "Apply a kill file to the current newsgroup.
10948 Returns the number of articles marked as read."
10949 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10950 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10951 (gnus-apply-kill-file-internal)
10954 (defun gnus-kill-save-kill-buffer ()
10956 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10957 (if (get-file-buffer file)
10959 (set-buffer (get-file-buffer file))
10960 (and (buffer-modified-p) (save-buffer))
10961 (kill-buffer (current-buffer)))))))
10963 (defvar gnus-kill-file-name "KILL"
10964 "Suffix of the kill files.")
10966 (defun gnus-newsgroup-kill-file (newsgroup)
10967 "Return the name of a kill file name for NEWSGROUP.
10968 If NEWSGROUP is nil, return the global kill file name instead."
10969 (cond ((or (null newsgroup)
10970 (string-equal newsgroup ""))
10971 ;; The global KILL file is placed at top of the directory.
10972 (expand-file-name gnus-kill-file-name
10973 (or gnus-kill-files-directory "~/News")))
10974 ((gnus-use-long-file-name 'not-kill)
10975 ;; Append ".KILL" to newsgroup name.
10976 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10977 (or gnus-kill-files-directory "~/News")))
10979 ;; Place "KILL" under the hierarchical directory.
10980 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10981 "/" gnus-kill-file-name)
10982 (or gnus-kill-files-directory "~/News")))))
10989 (defvar gnus-dribble-ignore nil)
10991 (defun gnus-dribble-file-name ()
10992 (concat gnus-startup-file "-dribble"))
10994 (defun gnus-dribble-open ()
10997 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10998 (buffer-disable-undo (current-buffer))
10999 (bury-buffer gnus-dribble-buffer)
11001 (goto-char (point-max))))
11003 (defun gnus-dribble-enter (string)
11004 (if (and (not gnus-dribble-ignore)
11005 gnus-dribble-buffer
11006 (buffer-name gnus-dribble-buffer))
11007 (let ((obuf (current-buffer)))
11008 (set-buffer gnus-dribble-buffer)
11009 (insert string "\n")
11010 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11011 (set-buffer obuf))))
11013 (defun gnus-dribble-read-file ()
11014 (let ((dribble-file (gnus-dribble-file-name)))
11016 (set-buffer (setq gnus-dribble-buffer
11018 (file-name-nondirectory dribble-file))))
11019 (gnus-add-current-to-buffer-list)
11021 (set-visited-file-name dribble-file)
11022 (buffer-disable-undo (current-buffer))
11023 (bury-buffer (current-buffer))
11024 (set-buffer-modified-p nil)
11025 (let ((auto (make-auto-save-file-name))
11026 (gnus-dribble-ignore t))
11027 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11029 (if (file-newer-than-file-p auto dribble-file)
11030 (setq dribble-file auto))
11031 (insert-file-contents dribble-file)
11032 (if (not (zerop (buffer-size)))
11033 (set-buffer-modified-p t))
11035 "Auto-save file exists. Do you want to read it? ")
11037 (gnus-message 5 "Reading %s..." dribble-file)
11038 (eval-buffer (current-buffer))
11039 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
11041 (defun gnus-dribble-delete-file ()
11042 (if (file-exists-p (gnus-dribble-file-name))
11043 (delete-file (gnus-dribble-file-name)))
11044 (if gnus-dribble-buffer
11046 (set-buffer gnus-dribble-buffer)
11047 (let ((auto (make-auto-save-file-name)))
11048 (if (file-exists-p auto)
11049 (delete-file auto))
11051 (set-buffer-modified-p nil)))))
11053 (defun gnus-dribble-save ()
11054 (if (and gnus-dribble-buffer
11055 (buffer-name gnus-dribble-buffer))
11057 (set-buffer gnus-dribble-buffer)
11060 (defun gnus-dribble-clear ()
11062 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11064 (set-buffer gnus-dribble-buffer)
11066 (set-buffer-modified-p nil)
11067 (setq buffer-saved-size (buffer-size))))))
11070 ;;; Server Communication
11073 ;; All the Gnus backends have the same interface, and should return
11074 ;; data in a similar format. Below is an overview of what functions
11075 ;; these packages must supply and what results they should return.
11079 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11082 ;; Functions for the imaginary backend `choke':
11084 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11085 ;; Should return all headers for all ARTICLES, or return NOV lines for
11088 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11089 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11090 ;; must be returned.
11092 ;; `choke-close-group GROUP &optional SERVER'
11093 ;; Close group. Most backends won't have to do anything with this
11094 ;; call, but it is an opportunity to clean up, if that is needed. It
11095 ;; is called when Gnus exits a group.
11097 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11098 ;; Return ARTICLE, which is either an article number or
11099 ;; message-id. Note that not all backends can return articles based on
11102 ;; `choke-request-list SERVER'
11103 ;; Return a list of all newsgroups on SERVER.
11105 ;; `choke-request-list-newsgroups SERVER'
11106 ;; Return a list of descriptions of all newsgroups on SERVER.
11108 ;; `choke-request-newgroups DATE &optional SERVER'
11109 ;; Return a list of all groups that have arrived after DATE on
11110 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11111 ;; always check whether the groups are old or not. Backends that do
11112 ;; not store date information may just return the entire list of
11113 ;; groups, although this might not be a good idea in general.
11115 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11116 ;; Should return a buffer that is suitable for "posting". nnspool and
11117 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11118 ;; buffer. This function should fill out the appropriate headers.
11120 ;; `choke-request-post &optional SERVER'
11121 ;; Function that will be called from a buffer to be posted.
11123 ;; `choke-open-server SERVER &optional ARGUMENT'
11124 ;; Open a connection to SERVER.
11126 ;; `choke-close-server &optional SERVER'
11127 ;; Close the connection to SERVER.
11129 ;; `choke-server-opened &optional SERVER'
11130 ;; Whether the conenction to SERVER is opened or not.
11132 ;; `choke-server-status &optional SERVER'
11133 ;; Should return a status string (not in the nntp buffer, but as the
11134 ;; result of the function).
11136 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11137 ;; Optional function for retrieving active file info on all groups in
11138 ;; GROUPS. Two return formats are supported: The normal active file
11139 ;; format, and a list of GROUP lines. This function should return (as
11140 ;; a function value) either `active' or `group', depending on what
11141 ;; format it returns.
11143 ;; The following functions are optional and apply only to backends
11144 ;; that are able to control the contents of their groups totally
11145 ;; (ie. mail backends.) Backends that aren't able to do that
11146 ;; shouldn't define these functions at all. Gnus will check for their
11147 ;; presence before attempting to call them.
11149 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11150 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11151 ;; backends will not be able to expire articles. Should return a list
11152 ;; of all articles that were not expired.
11154 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11155 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11156 ;; Removes any information it has added to the article (extra headers,
11157 ;; whatever - make it as clean as possible), and then passes the
11158 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11159 ;; function described below. If the ACCEPT-FORM returns a non-nil
11160 ;; value, the article should then be deleted. If LAST is nil, that
11161 ;; means that there will be further calls to this function. This might
11162 ;; be taken as an advice not to save buffers/internal variables just
11163 ;; yet, but wait until the last call to speed things up.
11165 ;; `choke-request-accept-article GROUP &optional LAST'
11166 ;; The contents of the current buffer will be put into GROUP. There
11167 ;; should, of course, be an article in the current buffer. This
11168 ;; function is normally only called by the function described above,
11169 ;; and LAST works the same way as in that function.
11171 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11172 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11173 ;; This provides an easy interface for allowing editing of
11174 ;; articles. Note that even headers may be edited, so the backend has
11175 ;; to update any tables (nov buffers, etc) that it maintains after
11176 ;; replacing the article.
11178 ;; `choke-request-create-group GROUP &optional SERVER'
11179 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11180 ;; might be a group that already exists, but hasn't been registered
11183 ;; All these functions must return nil if they couldn't service the
11184 ;; request. If the optional arguments are not supplied, some "current"
11185 ;; or "default" values should be used. In short, one should emulate an
11186 ;; NNTP server, in a way.
11188 ;; If you want to write a new backend, you just have to supply the
11189 ;; functions listed above. In addition, you must enter the new backend
11190 ;; into the list of valid select methods:
11191 ;; (setq gnus-valid-select-methods
11192 ;; (cons '("choke" mail) gnus-valid-select-methods))
11193 ;; The first element in this list is the name of the backend. Other
11194 ;; elemnets may be `mail' (for mail groups), `post' (for news
11195 ;; groups), `none' (neither), `respool' (for groups that can control
11196 ;; their contents).
11198 (defun gnus-start-news-server (&optional confirm)
11199 "Open a method for getting news.
11200 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11202 (if gnus-current-select-method
11203 ;; Stream is already opened.
11205 ;; Open NNTP server.
11206 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11209 ;; Read server name with completion.
11210 (setq gnus-nntp-server
11211 (completing-read "NNTP server: "
11212 (mapcar (lambda (server) (list server))
11213 (cons (list gnus-nntp-server)
11214 gnus-secondary-servers))
11215 nil nil gnus-nntp-server))))
11217 (if (and gnus-nntp-server
11218 (stringp gnus-nntp-server)
11219 (not (string= gnus-nntp-server "")))
11220 (setq gnus-select-method
11221 (cond ((or (string= gnus-nntp-server "")
11222 (string= gnus-nntp-server "::"))
11223 (list 'nnspool (system-name)))
11224 ((string-match "^:" gnus-nntp-server)
11225 (list 'nnmh gnus-nntp-server
11226 (list 'nnmh-directory
11227 (file-name-as-directory
11229 (concat "~/" (substring
11230 gnus-nntp-server 1)))))
11231 (list 'nnmh-get-new-mail nil)))
11233 (list 'nntp gnus-nntp-server)))))
11235 (setq how (car gnus-select-method))
11236 (cond ((eq how 'nnspool)
11238 (gnus-message 5 "Looking up local news spool..."))
11241 (gnus-message 5 "Looking up mh spool..."))
11244 (setq gnus-current-select-method gnus-select-method)
11245 (run-hooks 'gnus-open-server-hook)
11247 ;; gnus-open-server-hook might have opened it
11248 (gnus-server-opened gnus-select-method)
11249 (gnus-open-server gnus-select-method)
11252 "%s server on %s can't be opened. Continue? "
11253 (car gnus-select-method) (nth 1 gnus-select-method)))
11255 (gnus-message 1 "Couldn't open server on %s"
11256 (nth 1 gnus-select-method))
11260 (defun gnus-check-news-server (&optional method)
11261 "If the news server is down, start it up again."
11262 (let ((method (if method method gnus-select-method)))
11263 (and (stringp method)
11264 (setq method (gnus-server-to-method method)))
11265 (if (gnus-server-opened method)
11266 ;; Stream is already opened.
11269 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11270 (run-hooks 'gnus-open-server-hook)
11271 (or (gnus-server-opened method)
11272 (gnus-open-server method))
11275 (defun gnus-nntp-message (&optional message)
11276 "Check the status of the NNTP server.
11277 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11278 is returned insted of the status string."
11279 (let ((status (gnus-status-message (gnus-find-method-for-group
11280 gnus-newsgroup-name)))
11281 (message (or message "")))
11282 (if (and (stringp status) (> (length status) 0))
11285 (defun gnus-get-function (method function)
11286 (and (stringp method)
11287 (setq method (gnus-server-to-method method)))
11288 (let ((func (intern (format "%s-%s" (car method) function))))
11289 (if (not (fboundp func))
11291 (require (car method))
11292 (if (not (fboundp func))
11293 (error "No such function: %s" func))))
11296 ;;; Interface functions to the backends.
11298 (defun gnus-open-server (method)
11299 (funcall (gnus-get-function method 'open-server)
11300 (nth 1 method) (nthcdr 2 method)))
11302 (defun gnus-close-server (method)
11303 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11305 (defun gnus-request-list (method)
11306 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11308 (defun gnus-request-list-newsgroups (method)
11309 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11311 (defun gnus-request-newgroups (date method)
11312 (funcall (gnus-get-function method 'request-newgroups)
11313 date (nth 1 method)))
11315 (defun gnus-server-opened (method)
11316 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11318 (defun gnus-status-message (method)
11319 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11321 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11323 (defun gnus-request-group (group &optional dont-check)
11324 (let ((method (gnus-find-method-for-group group)))
11325 ; (and t (message "%s GROUP %s" (car method) group))
11326 (funcall (gnus-get-function method 'request-group)
11327 (gnus-group-real-name group) (nth 1 method) dont-check)))
11329 (defun gnus-request-asynchronous (group &optional articles)
11330 (let ((method (gnus-find-method-for-group group)))
11331 (funcall (gnus-get-function method 'request-asynchronous)
11332 (gnus-group-real-name group) (nth 1 method) articles)))
11334 (defun gnus-list-active-group (group)
11335 (let ((method (gnus-find-method-for-group group))
11336 (func 'list-active-group))
11337 (and (gnus-check-backend-function func group)
11338 (funcall (gnus-get-function method func)
11339 (gnus-group-real-name group) (nth 1 method)))))
11341 (defun gnus-request-group-description (group)
11342 (let ((method (gnus-find-method-for-group group))
11343 (func 'request-group-description))
11344 (and (gnus-check-backend-function func group)
11345 (funcall (gnus-get-function method func)
11346 (gnus-group-real-name group) (nth 1 method)))))
11348 (defun gnus-close-group (group)
11349 (let ((method (gnus-find-method-for-group group)))
11350 (funcall (gnus-get-function method 'close-group)
11351 (gnus-group-real-name group) (nth 1 method))))
11353 (defun gnus-retrieve-headers (articles group)
11354 (let ((method (gnus-find-method-for-group group)))
11355 (if (and gnus-use-cache (numberp (car articles)))
11356 (gnus-cache-retrieve-headers articles group)
11357 (funcall (gnus-get-function method 'retrieve-headers)
11358 articles (gnus-group-real-name group) (nth 1 method)))))
11360 (defun gnus-retrieve-groups (groups method)
11361 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11363 (defun gnus-request-article (article group &optional buffer)
11364 (let ((method (gnus-find-method-for-group group)))
11365 (funcall (gnus-get-function method 'request-article)
11366 article (gnus-group-real-name group) (nth 1 method) buffer)))
11368 (defun gnus-request-head (article group)
11369 (let ((method (gnus-find-method-for-group group)))
11370 (funcall (gnus-get-function method 'request-head)
11371 article (gnus-group-real-name group) (nth 1 method))))
11373 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11374 (defun gnus-request-post-buffer (post group subject header artbuf
11375 info follow-to respect-poster)
11376 (let* ((info (or info (and group (nth 2 (gnus-gethash
11377 group gnus-newsrc-hashtb)))))
11379 (if (and gnus-post-method
11380 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11382 (format "%s" (car (gnus-find-method-for-group
11383 gnus-newsgroup-name)))
11384 gnus-valid-select-methods)))
11386 (gnus-find-method-for-group gnus-newsgroup-name))))
11387 (or (gnus-server-opened method)
11388 (gnus-open-server method)
11389 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11390 (let ((mail-self-blind nil)
11391 (mail-archive-file-name nil))
11392 (funcall (gnus-get-function method 'request-post-buffer)
11393 post group subject header artbuf info follow-to
11396 (defun gnus-request-post (method &optional force)
11397 (and (stringp method)
11398 (setq method (gnus-server-to-method method)))
11399 (and (not force) gnus-post-method
11400 (memq 'post (assoc (format "%s" (car method))
11401 gnus-valid-select-methods))
11402 (setq method gnus-post-method))
11403 (funcall (gnus-get-function method 'request-post)
11406 (defun gnus-request-expire-articles (articles group &optional force)
11407 (let ((method (gnus-find-method-for-group group)))
11408 (funcall (gnus-get-function method 'request-expire-articles)
11409 articles (gnus-group-real-name group) (nth 1 method)
11412 (defun gnus-request-move-article
11413 (article group server accept-function &optional last)
11414 (let ((method (gnus-find-method-for-group group)))
11415 (funcall (gnus-get-function method 'request-move-article)
11416 article (gnus-group-real-name group)
11417 (nth 1 method) accept-function last)))
11419 (defun gnus-request-accept-article (group &optional last)
11420 (let ((func (if (symbolp group) group
11421 (car (gnus-find-method-for-group group)))))
11422 (funcall (intern (format "%s-request-accept-article" func))
11423 (if (stringp group) (gnus-group-real-name group) group)
11426 (defun gnus-request-replace-article (article group buffer)
11427 (let ((func (car (gnus-find-method-for-group group))))
11428 (funcall (intern (format "%s-request-replace-article" func))
11429 article (gnus-group-real-name group) buffer)))
11431 (defun gnus-request-create-group (group)
11432 (let ((method (gnus-find-method-for-group group)))
11433 (funcall (gnus-get-function method 'request-create-group)
11434 (gnus-group-real-name group) (nth 1 method))))
11436 (defun gnus-member-of-valid (symbol group)
11437 (memq symbol (assoc
11438 (format "%s" (car (gnus-find-method-for-group group)))
11439 gnus-valid-select-methods)))
11441 (defsubst gnus-secondary-method-p (method)
11442 (member method gnus-secondary-select-methods))
11444 (defun gnus-find-method-for-group (group &optional info)
11445 (or gnus-override-method
11447 gnus-select-method)
11448 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11451 (not (setq method (nth 4 info))))
11452 (setq method gnus-select-method)
11454 (cond ((stringp method)
11455 (gnus-server-to-method method))
11456 ((stringp (car method))
11457 (gnus-server-extend-method group method))
11460 (gnus-server-add-address method))))
11462 (defun gnus-check-backend-function (func group)
11463 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11465 (fboundp (intern (format "%s-%s" method func)))))
11467 (defun gnus-methods-using (method)
11468 (let ((valids gnus-valid-select-methods)
11471 (if (memq method (car valids))
11472 (setq outs (cons (car valids) outs)))
11473 (setq valids (cdr valids)))
11477 ;;; Active & Newsrc File Handling
11480 ;; Newsrc related functions.
11481 ;; Gnus internal format of gnus-newsrc-alist:
11482 ;; (("alt.general" 3 (1 . 1))
11483 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11484 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11485 ;; The first item is the group name; the second is the subscription
11486 ;; level; the third is either a range of a list of ranges of read
11487 ;; articles, the optional fourth element is a list of marked articles,
11488 ;; the optional fifth element is the select method.
11490 ;; Gnus internal format of gnus-newsrc-hashtb:
11491 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11492 ;; This is the entry for "alt.misc". The first element is the number
11493 ;; of unread articles in "alt.misc". The cdr of this entry is the
11494 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11495 ;; trivial to remove or add new elements into gnus-newsrc-alist
11496 ;; without scanning the entire list. So, to get the actual information
11497 ;; of "alt.misc", you'd say something like
11498 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11500 ;; Gnus internal format of gnus-active-hashtb:
11504 ;; The only element in each entry in this hash table is a range of
11505 ;; (possibly) available articles. (Articles in this range may have
11506 ;; been expired or canceled.)
11508 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11509 ;; ("alt.misc" "alt.test" "alt.general" ...)
11511 (defun gnus-setup-news (&optional rawfile level)
11512 "Setup news information.
11513 If RAWFILE is non-nil, the .newsrc file will also be read.
11514 If LEVEL is non-nil, the news will be set up at level LEVEL."
11515 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
11516 ;; Clear some variables to re-initialize news information.
11517 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
11519 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11520 (if init (gnus-read-newsrc-file rawfile))
11522 ;; Read the active file and create `gnus-active-hashtb'.
11523 ;; If `gnus-read-active-file' is nil, then we just create an empty
11524 ;; hash table. The partial filling out of the hash table will be
11525 ;; done in `gnus-get-unread-articles'.
11526 (if (and gnus-read-active-file
11528 (gnus-read-active-file)
11529 (setq gnus-active-hashtb (make-vector 4095 0)))
11531 (and init gnus-use-dribble-file (gnus-dribble-read-file))
11533 ;; Find the number of unread articles in each non-dead group.
11534 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
11535 ;; Find new newsgroups and treat them.
11536 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
11537 (gnus-server-opened gnus-select-method))
11538 (gnus-find-new-newsgroups))
11539 (if (and init gnus-check-bogus-newsgroups
11540 gnus-read-active-file (not level)
11541 (gnus-server-opened gnus-select-method))
11542 (gnus-check-bogus-newsgroups))))
11544 (defun gnus-find-new-newsgroups ()
11545 "Search for new newsgroups and add them.
11546 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11547 The `-n' option line from .newsrc is respected."
11549 (or (gnus-check-first-time-used)
11550 (if (or (consp gnus-check-new-newsgroups)
11551 (eq gnus-check-new-newsgroups 'ask-server))
11552 (gnus-ask-server-for-new-groups)
11554 group new-newsgroups)
11555 (or gnus-have-read-active-file (gnus-read-active-file))
11556 (setq gnus-newsrc-last-checked-date (current-time-string))
11557 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11558 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11559 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11562 (setq group (symbol-name sym))
11563 (if (or (gnus-gethash group gnus-killed-hashtb)
11564 (gnus-gethash group gnus-newsrc-hashtb))
11566 (let ((do-sub (gnus-matches-options-n group)))
11567 (cond ((eq do-sub 'subscribe)
11568 (setq groups (1+ groups))
11569 (gnus-sethash group group gnus-killed-hashtb)
11571 gnus-subscribe-options-newsgroup-method group))
11572 ((eq do-sub 'ignore)
11575 (setq groups (1+ groups))
11576 (gnus-sethash group group gnus-killed-hashtb)
11577 (if gnus-subscribe-hierarchical-interactive
11578 (setq new-newsgroups (cons group new-newsgroups))
11579 (funcall gnus-subscribe-newsgroup-method group)))))))
11580 gnus-active-hashtb)
11582 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11583 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11585 (gnus-message 6 "%d new newsgroup%s arrived."
11586 groups (if (> groups 1) "s have" " has")))))))
11588 (defun gnus-matches-options-n (group)
11589 ;; Returns `subscribe' if the group is to be uncoditionally
11590 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
11591 ;; no match for the group.
11593 ;; First we check the two user variables.
11595 ((and gnus-options-subscribe
11596 (string-match gnus-options-subscribe group))
11598 ((and gnus-options-not-subscribe
11599 (string-match gnus-options-not-subscribe group))
11601 ;; Then we go through the list that was retrieved from the .newsrc
11602 ;; file. This list has elements on the form
11603 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11604 ;; is in the reverse order of the options line) is returned.
11606 (let ((regs gnus-newsrc-options-n))
11608 (not (string-match (car (car regs)) group)))
11609 (setq regs (cdr regs)))
11610 (and regs (cdr (car regs)))))))
11612 (defun gnus-ask-server-for-new-groups ()
11613 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11614 (methods (cons gnus-select-method
11616 (and (consp gnus-check-new-newsgroups)
11617 gnus-check-new-newsgroups)
11618 gnus-secondary-select-methods)))
11620 (new-date (current-time-string))
11621 hashtb group new-newsgroups got-new)
11622 ;; Go thorugh both primary and secondary select methods and
11623 ;; request new newsgroups.
11625 (and (or (gnus-server-opened (car methods))
11626 (gnus-open-server (car methods)))
11627 (gnus-request-newgroups date (car methods))
11630 (set-buffer nntp-server-buffer)
11631 (or hashtb (setq hashtb (gnus-make-hashtable
11632 (count-lines (point-min) (point-max)))))
11633 ;; Enter all the new groups in a hashtable.
11634 (gnus-active-to-gnus-format (car methods) hashtb 'ignore)))
11635 (setq methods (cdr methods)))
11636 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11637 ;; Now all new groups from all select methods are in `hashtb'.
11639 (lambda (group-sym)
11640 (setq group (symbol-name group-sym))
11641 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11642 (member group gnus-zombie-list)
11643 (member group gnus-killed-list))
11644 ;; The group is already known.
11646 (and (symbol-value group-sym)
11647 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
11648 (let ((do-sub (gnus-matches-options-n group)))
11649 (cond ((eq do-sub 'subscribe)
11650 (setq groups (1+ groups))
11651 (gnus-sethash group group gnus-killed-hashtb)
11653 gnus-subscribe-options-newsgroup-method group))
11654 ((eq do-sub 'ignore)
11657 (setq groups (1+ groups))
11658 (gnus-sethash group group gnus-killed-hashtb)
11659 (if gnus-subscribe-hierarchical-interactive
11660 (setq new-newsgroups (cons group new-newsgroups))
11661 (funcall gnus-subscribe-newsgroup-method group)))))))
11664 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11665 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11667 (gnus-message 6 "%d new newsgroup%s arrived."
11668 groups (if (> groups 1) "s have" " has")))
11671 (defun gnus-check-first-time-used ()
11672 (if (or (> (length gnus-newsrc-alist) 1)
11673 (file-exists-p gnus-startup-file)
11674 (file-exists-p (concat gnus-startup-file ".el"))
11675 (file-exists-p (concat gnus-startup-file ".eld")))
11677 (gnus-message 6 "First time user; subscribing you to default groups")
11678 (or gnus-have-read-active-file (gnus-read-active-file))
11679 (setq gnus-newsrc-last-checked-date (current-time-string))
11680 (let ((groups gnus-default-subscribed-newsgroups)
11684 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11687 (setq group (symbol-name sym))
11688 (let ((do-sub (gnus-matches-options-n group)))
11689 (cond ((eq do-sub 'subscribe)
11690 (gnus-sethash group group gnus-killed-hashtb)
11692 gnus-subscribe-options-newsgroup-method group))
11693 ((eq do-sub 'ignore)
11696 (setq gnus-killed-list (cons group gnus-killed-list))))))
11697 gnus-active-hashtb)
11699 (if (gnus-gethash (car groups) gnus-active-hashtb)
11700 (gnus-group-change-level
11701 (car groups) gnus-level-default-subscribed gnus-level-killed))
11702 (setq groups (cdr groups)))
11703 (gnus-group-make-help-group)
11704 (and gnus-novice-user
11705 (gnus-message 7 "`A k' to list killed groups"))))))
11707 (defun gnus-subscribe-group (group previous &optional method)
11708 (gnus-group-change-level
11710 (list t group gnus-level-default-subscribed nil nil method)
11712 gnus-level-default-subscribed gnus-level-killed previous t))
11714 ;; `gnus-group-change-level' is the fundamental function for changing
11715 ;; subscription levels of newsgroups. This might mean just changing
11716 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11717 ;; again, which subscribes/unsubscribes a group, which is equally
11718 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11719 ;; from 8-9 to 1-7 means that you remove the group from the list of
11720 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11721 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11722 ;; which is trivial.
11723 ;; ENTRY can either be a string (newsgroup name) or a list (if
11724 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11725 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11727 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11728 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11730 (defun gnus-group-change-level (entry level &optional oldlevel
11731 previous fromkilled)
11732 (let (group info active num)
11733 ;; Glean what info we can from the arguments
11735 (if fromkilled (setq group (nth 1 entry))
11736 (setq group (car (nth 2 entry))))
11737 (setq group entry))
11738 (if (and (stringp entry)
11740 (< oldlevel gnus-level-zombie))
11741 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11742 (if (and (not oldlevel)
11744 (setq oldlevel (car (cdr (nth 2 entry)))))
11745 (if (stringp previous)
11746 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11748 (gnus-dribble-enter
11749 (format "(gnus-group-change-level %S %S %S %S %S)"
11750 group level oldlevel (car (nth 2 previous)) fromkilled))
11752 ;; Then we remove the newgroup from any old structures, if needed.
11753 ;; If the group was killed, we remove it from the killed or zombie
11754 ;; list. If not, and it is in fact going to be killed, we remove
11755 ;; it from the newsrc hash table and assoc.
11756 (cond ((>= oldlevel gnus-level-zombie)
11757 (if (= oldlevel gnus-level-zombie)
11758 (setq gnus-zombie-list (delete group gnus-zombie-list))
11759 (setq gnus-killed-list (delete group gnus-killed-list))))
11761 (if (>= level gnus-level-zombie)
11763 (gnus-sethash (car (nth 2 entry))
11764 nil gnus-newsrc-hashtb)
11766 (setcdr (gnus-gethash (car (nth 3 entry))
11767 gnus-newsrc-hashtb)
11769 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11771 ;; Finally we enter (if needed) the list where it is supposed to
11772 ;; go, and change the subscription level. If it is to be killed,
11773 ;; we enter it into the killed or zombie list.
11774 (cond ((>= level gnus-level-zombie)
11775 ;; Remove from the hash table.
11776 (gnus-sethash group nil gnus-newsrc-hashtb)
11777 (or (gnus-group-foreign-p group)
11778 ;; We do not enter foreign groups into the list of dead
11780 (if (= level gnus-level-zombie)
11781 (setq gnus-zombie-list (cons group gnus-zombie-list))
11782 (setq gnus-killed-list (cons group gnus-killed-list)))))
11784 ;; If the list is to be entered into the newsrc assoc, and
11785 ;; it was killed, we have to create an entry in the newsrc
11786 ;; hashtb format and fix the pointers in the newsrc assoc.
11787 (if (>= oldlevel gnus-level-zombie)
11791 (setq info (cdr entry))
11792 (setq num (car entry)))
11793 (setq active (gnus-gethash group gnus-active-hashtb))
11794 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11795 ;; Check whether the group is foreign. If so, the
11796 ;; foreign select method has to be entered into the
11798 (let ((method (gnus-group-method-name group)))
11799 (if (eq method gnus-select-method)
11800 (setq info (list group level nil))
11801 (setq info (list group level nil nil method)))))
11804 (let ((p gnus-newsrc-alist))
11805 (while (cdr (cdr p))
11808 (setq entry (cons info (cdr (cdr previous))))
11811 (setcdr (cdr previous) entry)
11812 (gnus-sethash group (cons num (cdr previous))
11813 gnus-newsrc-hashtb))
11814 (setcdr previous entry)
11815 (gnus-sethash group (cons num previous)
11816 gnus-newsrc-hashtb))
11818 (setcdr (gnus-gethash (car (car (cdr entry)))
11819 gnus-newsrc-hashtb)
11821 ;; It was alive, and it is going to stay alive, so we
11822 ;; just change the level and don't change any pointers or
11823 ;; hash table entries.
11824 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11826 (defun gnus-kill-newsgroup (newsgroup)
11827 "Obsolete function. Kills a newsgroup."
11828 (gnus-group-change-level
11829 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11831 (defun gnus-check-bogus-newsgroups (&optional confirm)
11832 "Remove bogus newsgroups.
11833 If CONFIRM is non-nil, the user has to confirm the deletion of every
11835 (let ((newsrc (cdr gnus-newsrc-alist))
11837 (gnus-message 5 "Checking bogus newsgroups...")
11838 (or gnus-have-read-active-file (gnus-read-active-file))
11839 ;; Find all bogus newsgroup that are subscribed.
11841 (setq group (car (car newsrc)))
11842 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
11843 (nth 4 (car newsrc)) ; Foreign
11845 (not (gnus-y-or-n-p
11846 (format "Remove bogus newsgroup: %s " group)))))
11849 ;; Found a bogus newsgroup.
11850 (setq bogus (cons group bogus)))
11851 (setq newsrc (cdr newsrc)))
11852 ;; Remove all bogus subscribed groups by first killing them, and
11853 ;; then removing them from the list of killed groups.
11855 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
11857 (gnus-group-change-level entry gnus-level-killed)
11858 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
11859 (setq bogus (cdr bogus)))
11860 ;; Then we remove all bogus groups from the list of killed and
11861 ;; zombie groups. They are are removed without confirmation.
11862 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11865 (setq killed (symbol-value (car dead-lists)))
11867 (setq group (car killed))
11868 (or (gnus-gethash group gnus-active-hashtb)
11869 ;; The group is bogus.
11870 (set (car dead-lists)
11871 (delete group (symbol-value (car dead-lists)))))
11872 (setq killed (cdr killed)))
11873 (setq dead-lists (cdr dead-lists))))
11874 (gnus-message 5 "Checking bogus newsgroups...done")))
11876 (defun gnus-check-duplicate-killed-groups ()
11877 "Remove duplicates from the list of killed groups."
11879 (let ((killed gnus-killed-list))
11881 (gnus-message 9 "%d" (length killed))
11882 (setcdr killed (delete (car killed) (cdr killed)))
11883 (setq killed (cdr killed)))))
11885 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11886 ;; and compute how many unread articles there are in each group.
11887 (defun gnus-get-unread-articles (&optional level)
11888 (let* ((newsrc (cdr gnus-newsrc-alist))
11889 (level (or level (1+ gnus-level-subscribed)))
11892 (cond ((and gnus-activate-foreign-newsgroups
11893 (not (numberp gnus-activate-foreign-newsgroups)))
11894 (1+ gnus-level-subscribed))
11895 ((numberp gnus-activate-foreign-newsgroups)
11896 gnus-activate-foreign-newsgroups)
11899 info group active virtuals method)
11900 (gnus-message 5 "Checking new news...")
11903 (setq info (car newsrc)
11905 active (gnus-gethash group gnus-active-hashtb))
11907 ;; Check newsgroups. If the user doesn't want to check them, or
11908 ;; they can't be checked (for instance, if the news server can't
11909 ;; be reached) we just set the number of unread articles in this
11910 ;; newsgroup to t. This means that Gnus thinks that there are
11911 ;; unread articles, but it has no idea how many.
11912 (if (and (setq method (nth 4 info))
11913 (not (gnus-server-equal gnus-select-method
11914 (gnus-server-get-method nil method)))
11915 (not (gnus-secondary-method-p method)))
11916 ;; These groups are foreign. Check the level.
11917 (if (<= (nth 1 info) foreign-level)
11918 (if (eq (car (if (stringp method)
11919 (gnus-server-to-method method)
11920 (nth 4 info))) 'nnvirtual)
11921 ;; We have to activate the virtual groups after all
11922 ;; the others, so we just pop them on a list for
11924 (setq virtuals (cons info virtuals))
11925 (and (setq active (gnus-activate-newsgroup (car info)))
11926 ;; Close the groups as we look at them!
11927 (gnus-close-group group))))
11929 ;; These groups are native or secondary.
11930 (if (and (not gnus-have-read-active-file)
11931 (<= (nth 1 info) level))
11932 (setq active (gnus-activate-newsgroup (car info)))))
11935 (gnus-get-unread-articles-in-group info active)
11936 ;; The group couldn't be reached, so we nix out the number of
11937 ;; unread articles and stuff.
11938 (gnus-sethash group nil gnus-active-hashtb)
11939 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
11941 (setq newsrc (cdr newsrc)))
11943 ;; Activate the virtual groups. This has to be done after all the
11945 ;; !!! If one virtual group contains another virtual group, even
11946 ;; doing it this way might cause problems.
11948 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11949 (gnus-get-unread-articles-in-group (car virtuals) active))
11950 (setq virtuals (cdr virtuals)))
11952 (gnus-message 5 "Checking new news...done")))
11954 ;; Create a hash table out of the newsrc alist. The `car's of the
11955 ;; alist elements are used as keys.
11956 (defun gnus-make-hashtable-from-newsrc-alist ()
11957 (let ((alist gnus-newsrc-alist)
11958 (ohashtb gnus-newsrc-hashtb)
11960 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11962 (setq prev (setq gnus-newsrc-alist
11963 (if (equal (car (car gnus-newsrc-alist))
11966 (cons (list "dummy.group" 0 nil) alist)))))
11968 (gnus-sethash (car (car alist))
11969 (cons (and ohashtb (car (gnus-gethash
11970 (car (car alist)) ohashtb)))
11971 prev) gnus-newsrc-hashtb)
11973 alist (cdr alist)))))
11975 (defun gnus-make-hashtable-from-killed ()
11976 "Create a hash table from the killed and zombie lists."
11977 (let ((lists '(gnus-killed-list gnus-zombie-list))
11979 (setq gnus-killed-hashtb
11980 (gnus-make-hashtable
11981 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11983 (setq list (symbol-value (car lists)))
11984 (setq lists (cdr lists))
11986 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11987 (setq list (cdr list))))))
11989 (defun gnus-get-unread-articles-in-group (info active)
11990 (let* ((range (nth 2 info))
11992 (marked (nth 3 info)))
11993 ;; If a cache is present, we may have to alter the active info.
11994 (and gnus-use-cache
11995 (gnus-cache-possibly-alter-active (car info) active))
11996 ;; Modify the list of read articles according to what articles
11997 ;; are available; then tally the unread articles and add the
11998 ;; number to the group hash table entry.
11999 (cond ((zerop (cdr active))
12002 (setq num (- (1+ (cdr active)) (car active))))
12003 ((not (listp (cdr range)))
12004 ;; Fix a single (num . num) range according to the
12005 ;; active hash table.
12006 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12007 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12008 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12009 ;; Compute number of unread articles.
12010 (setq num (max 0 (- (cdr active)
12011 (- (1+ (cdr range)) (car range))))))
12013 ;; The read list is a list of ranges. Fix them according to
12014 ;; the active hash table.
12015 ;; First peel off any elements that are below the lower
12017 (while (and (cdr range)
12019 (or (and (atom (car (cdr range))) (car (cdr range)))
12020 (car (car (cdr range))))))
12021 (if (numberp (car range))
12024 (or (and (numberp (car (cdr range)))
12026 (cdr (car (cdr range))))))
12027 (setcdr (car range)
12028 (or (and (numberp (nth 1 range)) (nth 1 range))
12029 (cdr (car (cdr range))))))
12030 (setcdr range (cdr (cdr range))))
12031 ;; Adjust the first element to be the same as the lower limit.
12032 (if (and (not (atom (car range)))
12033 (< (cdr (car range)) (car active)))
12034 (setcdr (car range) (1- (car active))))
12035 ;; Then we want to peel off any elements that are higher
12036 ;; than the upper active limit.
12037 (let ((srange range))
12038 ;; Go past all legal elements.
12039 (while (and (cdr srange)
12040 (<= (or (and (atom (car (cdr srange)))
12041 (car (cdr srange)))
12042 (car (car (cdr srange)))) (cdr active)))
12043 (setq srange (cdr srange)))
12045 ;; Nuke all remaining illegal elements.
12046 (setcdr srange nil))
12048 ;; Adjust the final element.
12049 (if (and (not (atom (car srange)))
12050 (> (cdr (car srange)) (cdr active)))
12051 (setcdr (car srange) (cdr active))))
12052 ;; Compute the number of unread articles.
12054 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12055 (cdr (car range))))
12056 (or (and (atom (car range)) (car range))
12057 (car (car range))))))
12058 (setq range (cdr range)))
12059 (setq num (max 0 (- (cdr active) num)))))
12062 (and (assq 'tick marked)
12063 (inline (gnus-remove-illegal-marked-articles
12064 (assq 'tick marked) (nth 2 info))))
12065 (and (assq 'dormant marked)
12066 (inline (gnus-remove-illegal-marked-articles
12067 (assq 'dormant marked) (nth 2 info))))
12069 (gnus-gethash (car info) gnus-newsrc-hashtb)
12070 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12071 (length (cdr (assq 'dormant marked)))))))))
12074 (defun gnus-remove-illegal-marked-articles (marked ranges)
12075 (let ((m (cdr marked)))
12076 ;; Make sure that all ticked articles are a subset of the unread
12079 (if (gnus-member-of-range (car m) ranges)
12080 (setcdr marked (cdr m))
12082 (setq m (cdr m)))))
12084 (defun gnus-activate-newsgroup (group)
12085 (let ((method (gnus-find-method-for-group group))
12087 (and (or (gnus-server-opened method) (gnus-open-server method))
12088 (gnus-request-group group)
12090 (set-buffer nntp-server-buffer)
12091 (goto-char (point-min))
12092 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12094 (goto-char (match-beginning 1))
12096 group (setq active (cons (read (current-buffer))
12097 (read (current-buffer))))
12098 gnus-active-hashtb))
12101 (defun gnus-update-read-articles
12102 (group unread unselected ticked &optional domarks replied expirable killed
12103 dormant bookmark score)
12104 "Update the list of read and ticked articles in GROUP using the
12105 UNREAD and TICKED lists.
12106 Note: UNSELECTED has to be sorted over `<'.
12107 Returns whether the updating was successful."
12108 (let* ((active (or gnus-newsgroup-active
12109 (gnus-gethash group gnus-active-hashtb)))
12110 (entry (gnus-gethash group gnus-newsrc-hashtb))
12111 (info (nth 2 entry))
12112 (marked (nth 3 info))
12114 (unread (sort (copy-sequence unread) (function <)))
12116 (if (or (not info) (not active))
12117 ;; There is no info on this group if it was, in fact,
12118 ;; killed. Gnus stores no information on killed groups, so
12119 ;; there's nothing to be done.
12120 ;; One could store the information somewhere temporarily,
12121 ;; perhaps... Hmmm...
12123 ;; Remove any negative articles numbers.
12124 (while (and unread (< (car unread) 0))
12125 (setq unread (cdr unread)))
12126 ;; Remove any expired article numbers
12127 (while (and unread (< (car unread) (car active)))
12128 (setq unread (cdr unread)))
12129 (while (and ticked (< (car ticked) (car active)))
12130 (setq ticked (cdr ticked)))
12131 (while (and dormant (< (car dormant) (car active)))
12132 (setq dormant (cdr dormant)))
12133 (setq unread (sort (append unselected unread) '<))
12134 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12135 (setcar entry (max 0 (- (length unread) (length ticked)
12136 (length dormant))))
12137 ;; Compute the ranges of read articles by looking at the list of
12138 ;; unread articles.
12140 (if (/= (car unread) prev)
12141 (setq read (cons (if (= prev (1- (car unread))) prev
12142 (cons prev (1- (car unread)))) read)))
12143 (setq prev (1+ (car unread)))
12144 (setq unread (cdr unread)))
12145 (if (<= prev (cdr active))
12146 (setq read (cons (cons prev (cdr active)) read)))
12147 ;; Enter this list into the group info.
12148 (setcar (cdr (cdr info))
12149 (if (> (length read) 1) (nreverse read) read))
12150 ;; Enter the list of ticked articles.
12151 (gnus-set-marked-articles
12153 (if domarks replied (cdr (assq 'reply marked)))
12154 (if domarks expirable (cdr (assq 'expire marked)))
12155 (if domarks killed (cdr (assq 'killed marked)))
12156 (if domarks dormant (cdr (assq 'dormant marked)))
12157 (if domarks bookmark (cdr (assq 'bookmark marked)))
12158 (if domarks score (cdr (assq 'score marked))))
12161 (defun gnus-make-articles-unread (group articles)
12162 "Mark ARTICLES in GROUP as unread."
12163 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12164 (gnus-gethash (gnus-group-real-name group)
12165 gnus-newsrc-hashtb))))
12166 (ranges (nth 2 info))
12169 (and (gnus-member-of-range (car articles) ranges)
12170 (setq news (cons (car articles) news)))
12171 (setq articles (cdr articles)))
12174 (setcar (nthcdr 2 info)
12175 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12176 (gnus-group-update-group group t))))
12178 ;; Get the active file(s) from the backend(s).
12179 (defun gnus-read-active-file ()
12180 (gnus-group-set-mode-line)
12181 (let ((methods (if (or (gnus-server-opened gnus-select-method)
12182 (gnus-open-server gnus-select-method))
12183 ;; The native server is available.
12184 (cons gnus-select-method gnus-secondary-select-methods)
12185 ;; The native server is down, so we just do the
12187 gnus-secondary-select-methods))
12189 (setq gnus-have-read-active-file nil)
12191 (set-buffer nntp-server-buffer)
12193 (let* ((where (nth 1 (car methods)))
12194 (mesg (format "Reading active file%s via %s..."
12195 (if (and where (not (zerop (length where))))
12196 (concat " from " where) "")
12197 (car (car methods)))))
12198 (gnus-message 5 mesg)
12199 (gnus-check-news-server (car methods))
12201 ((and (eq gnus-read-active-file 'some)
12202 (gnus-check-backend-function
12203 'retrieve-groups (car (car methods))))
12204 (let ((newsrc (cdr gnus-newsrc-alist))
12207 (and (gnus-server-equal
12208 (gnus-find-method-for-group
12209 (car (car newsrc)) (car newsrc))
12210 (gnus-server-get-method nil (car methods)))
12211 (setq groups (cons (car (car newsrc)) groups)))
12212 (setq newsrc (cdr newsrc)))
12213 (setq list-type (gnus-retrieve-groups groups (car methods)))
12214 (cond ((not list-type)
12216 1 "Cannot read partial active file from %s server."
12217 (car (car methods)))
12220 ((eq list-type 'active)
12221 (gnus-active-to-gnus-format (car methods)))
12223 (gnus-groups-to-gnus-format (car methods))))))
12225 (if (not (gnus-request-list (car methods)))
12227 (gnus-message 1 "Cannot read active file from %s server."
12228 (car (car methods)))
12230 (gnus-active-to-gnus-format (car methods))
12231 (setq gnus-have-read-active-file t)
12232 (gnus-message 5 "%sdone" mesg)))))
12233 (setq methods (cdr methods))))))
12235 ;; Read an active file and place the results in `gnus-active-hashtb'.
12236 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12237 (let ((cur (current-buffer))
12239 (if (and gnus-active-hashtb
12240 (not (equal method gnus-select-method)))
12242 (setq gnus-active-hashtb
12243 (if (equal method gnus-select-method)
12244 (gnus-make-hashtable
12245 (count-lines (point-min) (point-max)))
12246 (gnus-make-hashtable 4096)))))))
12247 ;; Delete unnecessary lines.
12248 (goto-char (point-min))
12249 (while (search-forward "\nto." nil t)
12250 (delete-region (1+ (match-beginning 0))
12251 (progn (forward-line 1) (point))))
12252 (or (string= gnus-ignored-newsgroups "")
12254 (goto-char (point-min))
12255 (delete-matching-lines gnus-ignored-newsgroups)))
12256 ;; If these are groups from a foreign select method, we insert the
12257 ;; group prefix in front of the group names.
12258 (and method (not (eq method gnus-select-method))
12259 (let ((prefix (gnus-group-prefixed-name "" method)))
12260 (goto-char (point-min))
12261 (while (and (not (eobp))
12262 (progn (insert prefix)
12263 (zerop (forward-line 1)))))))
12264 (goto-char (point-min))
12265 ;; Store active file in hashtable.
12266 (goto-char (point-min))
12267 (if (string-match "%[oO]" gnus-group-line-format)
12268 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12269 ;; If we want information on moderated groups, we use this
12271 (let* ((mod-hashtb (make-vector 7 0))
12272 (m (intern "m" mod-hashtb))
12274 (while (not (eobp))
12275 (condition-case nil
12277 (narrow-to-region (point) (gnus-point-at-eol))
12278 (setq group (let ((obarray hashtb)) (read cur)))
12279 (if (and (numberp (setq max (read cur)))
12280 (numberp (setq min (read cur))))
12281 (set group (cons min max))
12283 ;; Enter moderated groups into a list.
12284 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12285 (setq gnus-moderated-list
12286 (cons (symbol-name group) gnus-moderated-list))))
12290 ;; And if we do not care about moderation, we use this loop,
12291 ;; which is faster.
12292 (let (group max min)
12293 (while (not (eobp))
12296 (narrow-to-region (point) (gnus-point-at-eol))
12297 ;; group gets set to a symbol interned in the hash table
12299 (setq group (let ((obarray hashtb)) (read cur)))
12300 (if (and (numberp (setq max (read cur)))
12301 (numberp (setq min (read cur))))
12302 (set group (cons min max))
12309 (gnus-message 3 "Warning - illegal active: %s"
12311 (gnus-point-at-bol) (gnus-point-at-eol)))
12314 (forward-line 1))))))
12316 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12317 ;; Parse a "groups" active file.
12318 (let ((cur (current-buffer))
12322 (setq gnus-active-hashtb
12323 (gnus-make-hashtable
12324 (count-lines (point-min) (point-max)))))))
12325 (prefix (and method (not (eq method gnus-select-method))
12326 (gnus-group-prefixed-name "" method))))
12328 (goto-char (point-min))
12330 ;; We split this into to separate loops, one with the prefix
12331 ;; and one without to speed the reading up somewhat.
12333 (let (min max opoint)
12334 (while (not (eobp))
12335 (read cur) (read cur)
12336 (setq min (read cur)
12339 (skip-chars-forward " \t")
12342 (set (let ((obarray hashtb)) (read cur))
12346 (while (not (eobp))
12347 (if (= (following-char) ?2)
12349 (read cur) (read cur)
12350 (setq min (read cur)
12352 (set (let ((obarray hashtb)) (read cur))
12354 (forward-line 1))))
12356 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
12358 (defun gnus-read-newsrc-file (&optional force)
12359 "Read startup file.
12360 If FORCE is non-nil, the .newsrc file is read."
12361 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12362 ;; Reset variables that might be defined in the .newsrc.eld file.
12363 (let ((variables gnus-variable-list))
12365 (set (car variables) nil)
12366 (setq variables (cdr variables))))
12367 (let* ((newsrc-file gnus-current-startup-file)
12368 (quick-file (concat newsrc-file ".el")))
12370 ;; We always load the .newsrc.eld file. If always contains
12371 ;; much information that can not be gotten from the .newsrc
12372 ;; file (ticked articles, killed groups, foreign methods, etc.)
12373 (gnus-read-newsrc-el-file quick-file)
12376 (and (file-newer-than-file-p newsrc-file quick-file)
12377 (file-newer-than-file-p newsrc-file
12378 (concat quick-file "d")))
12379 (not gnus-newsrc-alist))
12380 ;; We read the .newsrc file. Note that if there if a
12381 ;; .newsrc.eld file exists, it has already been read, and
12382 ;; the `gnus-newsrc-hashtb' has been created. While reading
12383 ;; the .newsrc file, Gnus will only use the information it
12384 ;; can find there for changing the data already read -
12385 ;; ie. reading the .newsrc file will not trash the data
12386 ;; already read (except for read articles).
12388 (gnus-message 5 "Reading %s..." newsrc-file)
12389 (set-buffer (find-file-noselect newsrc-file))
12390 (buffer-disable-undo (current-buffer))
12391 (gnus-newsrc-to-gnus-format)
12392 (kill-buffer (current-buffer))
12393 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12395 (defun gnus-read-newsrc-el-file (file)
12396 (let ((ding-file (concat file "d")))
12397 ;; We always, always read the .eld file.
12398 (gnus-message 5 "Reading %s..." ding-file)
12399 (let (gnus-newsrc-assoc)
12400 (condition-case nil
12401 (load ding-file t t t)
12403 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12404 (let ((inhibit-quit t))
12405 (gnus-uncompress-newsrc-alist))
12406 (gnus-make-hashtable-from-newsrc-alist)
12407 (if (not (file-newer-than-file-p file ding-file))
12409 ;; Old format quick file
12410 (gnus-message 5 "Reading %s..." file)
12411 ;; The .el file is newer than the .eld file, so we read that one
12413 (gnus-read-old-newsrc-el-file file))))
12415 ;; Parse the old-style quick startup file
12416 (defun gnus-read-old-newsrc-el-file (file)
12417 (let (newsrc killed marked group m)
12419 (let ((gnus-killed-assoc nil)
12420 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12422 (condition-case nil
12425 (setq newsrc gnus-newsrc-assoc
12426 killed gnus-killed-assoc
12427 marked gnus-marked-assoc)))
12428 (setq gnus-newsrc-alist nil)
12430 (setq group (car newsrc))
12431 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12434 (setcar (nthcdr 2 info) (cdr (cdr group)))
12436 (if (nth 1 group) gnus-level-default-subscribed
12437 gnus-level-default-unsubscribed))
12438 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
12439 (setq gnus-newsrc-alist
12443 (if (nth 1 group) gnus-level-default-subscribed
12444 gnus-level-default-unsubscribed)
12445 (cdr (cdr group))))
12446 gnus-newsrc-alist)))
12447 (if (setq m (assoc (car group) marked))
12448 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12449 (setq newsrc (cdr newsrc)))
12450 (setq newsrc killed)
12452 (setcar newsrc (car (car newsrc)))
12453 (setq newsrc (cdr newsrc)))
12454 (setq gnus-killed-list killed))
12455 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
12456 (gnus-make-hashtable-from-newsrc-alist)))
12458 (defun gnus-make-newsrc-file (file)
12459 "Make server dependent file name by catenating FILE and server host name."
12460 (let* ((file (expand-file-name file nil))
12461 (real-file (concat file "-" (nth 1 gnus-select-method))))
12462 (if (file-exists-p real-file)
12465 (defun gnus-uncompress-newsrc-alist ()
12466 ;; Uncompress all lists of marked articles in the newsrc assoc.
12467 (let ((newsrc gnus-newsrc-alist)
12470 (if (not (setq marked (nth 3 (car newsrc))))
12473 (or (eq 'score (car (car marked)))
12474 (eq 'bookmark (car (car marked)))
12475 (eq 'killed (car (car marked)))
12476 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12477 (setq marked (cdr marked))))
12478 (setq newsrc (cdr newsrc)))))
12480 (defun gnus-compress-newsrc-alist ()
12481 ;; Compress all lists of marked articles in the newsrc assoc.
12482 (let ((newsrc gnus-newsrc-alist)
12485 (if (not (setq marked (nth 3 (car newsrc))))
12488 (or (eq 'score (car (car marked)))
12489 (eq 'bookmark (car (car marked)))
12490 (eq 'killed (car (car marked)))
12491 (setcdr (car marked)
12493 (gnus-compress-sequence
12494 (sort (cdr (car marked)) '<) t)
12495 (error (cdr (car marked))))))
12496 (setq marked (cdr marked))))
12497 (setq newsrc (cdr newsrc)))))
12499 (defun gnus-newsrc-to-gnus-format ()
12500 (setq gnus-newsrc-options "")
12501 (setq gnus-newsrc-options-n nil)
12503 (or gnus-active-hashtb
12504 (setq gnus-active-hashtb (make-vector 4095 0)))
12505 (let ((buf (current-buffer))
12506 (already-read (> (length gnus-newsrc-alist) 1))
12507 group subscribed options-symbol newsrc
12509 (goto-char (point-min))
12510 ;; We intern the symbol `options' in the active hashtb so that we
12511 ;; can `eq' against it later.
12512 (setq options-symbol (intern "options" gnus-active-hashtb))
12514 (while (not (eobp))
12515 ;; We first read the first word on the line by narrowing and
12516 ;; then reading into `gnus-active-hashtb'. Most groups will
12517 ;; already exist in that hashtb, so this will save some string
12521 (progn (skip-chars-forward "^ \t!:\n") (point)))
12522 (goto-char (point-min))
12524 (and (/= (point-min) (point-max))
12525 (let ((obarray gnus-active-hashtb)) (read buf))))
12527 ;; Now, the symbol we have read is either `options' or a group
12528 ;; name. If it is an options line, we just add it to a string.
12530 ((eq symbol options-symbol)
12531 (setq gnus-newsrc-options
12532 ;; This concatting is quite inefficient, but since our
12533 ;; thorough studies show that approx 99.37% of all
12534 ;; .newsrc files only contain a single options line, we
12535 ;; don't give a damn, frankly, my dear.
12536 (concat gnus-newsrc-options
12538 (gnus-point-at-bol)
12539 ;; Options may continue on the next line.
12540 (or (and (re-search-forward "^[^ \t]" nil 'move)
12541 (progn (beginning-of-line) (point)))
12544 ;; It was a group name.
12545 (setq subscribed (= (following-char) ?:)
12546 group (symbol-name symbol)
12549 ;; If the line ends here, this is clearly a buggy line, so
12550 ;; we put point a the beginning of line and let the cond
12551 ;; below do the error handling.
12552 (beginning-of-line)
12553 ;; We skip to the beginning of the ranges.
12554 (skip-chars-forward "!: \t"))
12555 ;; We are now at the beginning of the list of read articles.
12556 ;; We read them range by range.
12559 ((looking-at "[0-9]+")
12560 ;; We narrow and read a number instead of buffer-substring/
12561 ;; string-to-int because it's faster. narrow/widen is
12562 ;; faster than save-restriction/narrow, and save-restriction
12563 ;; produces a garbage object.
12565 (narrow-to-region (match-beginning 0) (match-end 0))
12568 ;; If the next character is a dash, then this is a range.
12569 (if (= (following-char) ?-)
12571 ;; We read the upper bound of the range.
12573 (if (not (looking-at "[0-9]+"))
12574 ;; This is a buggy line, by we pretend that
12575 ;; it's kinda OK. Perhaps the user should be
12577 (setq reads (cons num1 reads))
12581 (narrow-to-region (match-beginning 0)
12586 ;; It was just a simple number, so we add it to the
12588 (setq reads (cons num1 reads)))
12589 ;; If the next char in ?\n, then we have reached the end
12590 ;; of the line and return nil.
12591 (/= (following-char) ?\n))
12592 ((= (following-char) ?\n)
12593 ;; End of line, so we end.
12596 ;; Not numbers and not eol, so this might be a buggy
12598 (or (eobp) ; If it was eob instead of ?\n, we allow it.
12600 ;; The line was buggy.
12602 (gnus-message 3 "Mangled line: %s"
12603 (buffer-substring (gnus-point-at-bol)
12604 (gnus-point-at-eol)))
12608 ;; Skip past ", ". Spaces are illegal in these ranges, but
12609 ;; we allow them, because it's a common mistake to put a
12610 ;; space after the comma.
12611 (skip-chars-forward ", "))
12613 ;; We have already read .newsrc.eld, so we gently update the
12614 ;; data in the hash table with the information we have just
12618 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12621 ;; There is an entry for this file in the alist.
12623 (setcar (nthcdr 2 info) (nreverse reads))
12624 ;; We update the level very gently. In fact, we
12625 ;; only change it if there's been a status change
12626 ;; from subscribed to unsubscribed, or vice versa.
12627 (setq level (nth 1 info))
12628 (cond ((and (<= level gnus-level-subscribed)
12630 (setq level (if reads
12631 gnus-level-default-unsubscribed
12632 (1+ gnus-level-default-unsubscribed))))
12633 ((and (> level gnus-level-subscribed) subscribed)
12634 (setq level gnus-level-default-subscribed)))
12635 (setcar (cdr info) level))
12636 ;; This is a new group.
12637 (setq info (list group
12639 gnus-level-default-subscribed
12641 (1+ gnus-level-subscribed)
12642 gnus-level-default-unsubscribed))
12643 (nreverse reads))))
12644 (setq newsrc (cons info newsrc))))))
12647 (setq newsrc (nreverse newsrc))
12649 (if (not already-read)
12651 ;; We now have two newsrc lists - `newsrc', which is what we
12652 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
12653 ;; what we've read from .newsrc.eld. We have to merge these
12654 ;; lists. We do this by "attaching" any (foreign) groups in the
12655 ;; gnus-newsrc-alist to the (native) group that precedes them.
12656 (let ((rc (cdr gnus-newsrc-alist))
12657 (prev gnus-newsrc-alist)
12660 (or (null (nth 4 (car rc))) ; It's a native group.
12661 (assoc (car (car rc)) newsrc) ; It's already in the alist.
12662 (if (setq entry (assoc (car (car prev)) newsrc))
12663 (setcdr (setq mentry (memq entry newsrc))
12664 (cons (car rc) (cdr mentry)))
12665 (setq newsrc (cons (car rc) newsrc))))
12669 (setq gnus-newsrc-alist newsrc)
12670 ;; We make the newsrc hashtb.
12671 (gnus-make-hashtable-from-newsrc-alist)
12673 ;; Finally, if we read some options lines, we parse them.
12674 (or (string= gnus-newsrc-options "")
12675 (gnus-newsrc-parse-options gnus-newsrc-options))))
12677 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12678 ;; The return value will be a list on the form
12679 ;; ((regexp1 . ignore)
12680 ;; (regexp2 . subscribe)...)
12681 ;; When handling new newsgroups, groups that match a `ignore' regexp
12682 ;; will be ignored, and groups that match a `subscribe' regexp will be
12683 ;; subscribed. A line like
12684 ;; options -n !all rec.all
12685 ;; will lead to a list that looks like
12686 ;; (("^rec\\..+" . subscribe)
12687 ;; ("^.+" . ignore))
12688 ;; So all "rec.*" groups will be subscribed, while all the other
12689 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12690 ;; different from "options -n rec.all !all".
12691 (defun gnus-newsrc-parse-options (options)
12694 (gnus-set-work-buffer)
12695 (insert (regexp-quote options))
12696 ;; First we treat all continuation lines.
12697 (goto-char (point-min))
12698 (while (re-search-forward "\n[ \t]+" nil t)
12699 (replace-match " " t t))
12700 ;; Then we transform all "all"s into ".+"s.
12701 (goto-char (point-min))
12702 (while (re-search-forward "\\ball\\b" nil t)
12703 (replace-match ".+" t t))
12704 (goto-char (point-min))
12705 ;; We remove all other options than the "-n" ones.
12706 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12707 (replace-match " ")
12709 (goto-char (point-min))
12711 ;; We are only interested in "options -n" lines - we
12712 ;; ignore the other option lines.
12713 (while (re-search-forward "[ \t]-n" nil t)
12715 (or (save-excursion
12716 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12718 (gnus-point-at-eol)))
12719 ;; Search for all "words"...
12720 (while (re-search-forward "[^ \t,\n]+" eol t)
12721 (if (= (char-after (match-beginning 0)) ?!)
12722 ;; If the word begins with a bang (!), this is a "not"
12723 ;; spec. We put this spec (minus the bang) and the
12724 ;; symbol `ignore' into the list.
12725 (setq out (cons (cons (concat
12726 "^" (buffer-substring
12727 (1+ (match-beginning 0))
12730 ;; There was no bang, so this is a "yes" spec.
12731 (setq out (cons (cons (concat
12732 "^" (buffer-substring (match-beginning 0)
12734 'subscribe) out)))))
12736 (setq gnus-newsrc-options-n out))))
12739 (defun gnus-save-newsrc-file ()
12740 "Save .newsrc file."
12741 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12742 ;; from the variable gnus-newsrc-alist.
12743 (and (or gnus-newsrc-alist gnus-killed-list)
12744 gnus-current-startup-file
12745 (let ((make-backup-files t)
12746 (version-control nil)
12747 (require-final-newline t)) ;Don't ask even if requested.
12748 ;; You can stop or change version control of backup file.
12749 ;; Suggested by jason@violet.berkeley.edu.
12750 (run-hooks 'gnus-save-newsrc-hook)
12752 (if (or (not gnus-dribble-buffer)
12753 (not (buffer-name gnus-dribble-buffer))
12754 (zerop (save-excursion
12755 (set-buffer gnus-dribble-buffer)
12757 (gnus-message 4 "(No changes need to be saved)")
12758 (if gnus-save-newsrc-file
12760 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12761 ;; Make backup file of master newsrc.
12762 (gnus-gnus-to-newsrc-format)
12763 (gnus-message 5 "Saving %s...done"
12764 gnus-current-startup-file)))
12765 ;; Quickly loadable .newsrc.
12766 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12767 (gnus-add-current-to-buffer-list)
12768 (buffer-disable-undo (current-buffer))
12770 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12771 (gnus-gnus-to-quick-newsrc-format)
12772 (write-region 1 (point-max)
12773 (concat gnus-current-startup-file ".eld")
12775 (kill-buffer (current-buffer))
12776 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
12777 (gnus-dribble-delete-file))))))
12779 (defun gnus-gnus-to-quick-newsrc-format ()
12780 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12781 (insert ";; (ding) Gnus startup file.\n")
12782 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12783 (insert ";; to read .newsrc.\n")
12784 (let ((variables gnus-variable-list)
12786 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12788 ;; insert lisp expressions.
12789 (gnus-compress-newsrc-alist)
12791 (setq variable (car variables))
12792 (and (boundp variable)
12793 (symbol-value variable)
12794 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12795 (insert "(setq " (symbol-name variable) " '"
12796 (prin1-to-string (symbol-value variable))
12798 (setq variables (cdr variables)))
12799 (gnus-uncompress-newsrc-alist)))
12802 (defun gnus-gnus-to-newsrc-format ()
12803 ;; Generate and save the .newsrc file.
12804 (let ((newsrc (cdr gnus-newsrc-alist))
12807 (set-buffer (create-file-buffer gnus-startup-file))
12808 (buffer-disable-undo (current-buffer))
12811 (if gnus-newsrc-options (insert gnus-newsrc-options))
12812 ;; Write subscribed and unsubscribed.
12814 (setq info (car newsrc))
12815 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12817 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12819 (if (setq ranges (nth 2 info))
12822 (if (not (listp (cdr ranges)))
12823 (if (= (car ranges) (cdr ranges))
12824 (insert (int-to-string (car ranges)))
12825 (insert (int-to-string (car ranges)) "-"
12826 (int-to-string (cdr ranges))))
12828 (setq range (car ranges)
12829 ranges (cdr ranges))
12830 (if (or (atom range) (= (car range) (cdr range)))
12831 (insert (int-to-string
12832 (or (and (atom range) range)
12834 (insert (int-to-string (car range)) "-"
12835 (int-to-string (cdr range))))
12836 (if ranges (insert ","))))))
12838 (setq newsrc (cdr newsrc)))
12839 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12840 (kill-buffer (current-buffer)))))
12842 (defun gnus-read-all-descriptions-files ()
12843 (let ((methods (nconc (list gnus-select-method)
12844 gnus-secondary-select-methods)))
12846 (gnus-read-descriptions-file (car methods))
12847 (setq methods (cdr methods)))
12850 (defun gnus-read-descriptions-file (&optional method)
12851 (let ((method (or method gnus-select-method)))
12852 ;; We create the hashtable whether we manage to read the desc file
12853 ;; to avoid trying to re-read after a failed read.
12854 (or gnus-description-hashtb
12855 (setq gnus-description-hashtb
12856 (gnus-make-hashtable (length gnus-active-hashtb))))
12857 ;; Mark this method's desc file as read.
12858 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
12859 gnus-description-hashtb)
12861 (gnus-message 5 "Reading descriptions file via %s..." (car method))
12863 ((not (or (gnus-server-opened method)
12864 (gnus-open-server method)))
12865 (gnus-message 1 "Couldn't open server")
12867 ((not (gnus-request-list-newsgroups method))
12868 (gnus-message 1 "Couldn't read newsgroups descriptions")
12874 (set-buffer nntp-server-buffer)
12875 (goto-char (point-min))
12876 (if (or (search-forward "\n.\n" nil t)
12877 (goto-char (point-max)))
12879 (beginning-of-line)
12880 (narrow-to-region (point-min) (point))))
12881 (goto-char (point-min))
12882 (while (not (eobp))
12883 ;; If we get an error, we set group to 0, which is not a
12887 (let ((obarray gnus-description-hashtb))
12888 ;; Group is set to a symbol interned in this
12890 (read nntp-server-buffer))
12892 (skip-chars-forward " \t")
12893 ;; ... which leads to this line being effectively ignored.
12894 (and (symbolp group)
12895 (set group (buffer-substring
12896 (point) (progn (end-of-line) (point)))))
12897 (forward-line 1))))
12898 (gnus-message 5 "Reading descriptions file...done")
12901 (defun gnus-group-get-description (group)
12902 ;; Get the description of a group by sending XGTITLE to the server.
12903 (and (gnus-request-group-description group)
12905 (set-buffer nntp-server-buffer)
12906 (goto-char (point-min))
12907 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12908 (buffer-substring (match-beginning 1) (match-end 1))))))
12914 (defvar gnus-server-mode-hook nil
12915 "Hook run in `gnus-server-mode' buffers.")
12917 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12918 "Format of server lines.
12919 It works along the same lines as a normal formatting string,
12920 with some simple extensions.")
12922 (defvar gnus-server-mode-line-format "(ding) List of servers"
12923 "The format specification for the server mode line.")
12925 (defconst gnus-server-line-format-alist
12926 (list (list ?h 'how ?s)
12928 (list ?w 'where ?s)
12931 (defconst gnus-server-mode-line-format-alist
12932 (list (list ?S 'news-server ?s)
12933 (list ?M 'news-method ?s)
12934 (list ?u 'user-defined ?s)))
12936 (defvar gnus-server-line-format-spec nil)
12937 (defvar gnus-server-mode-line-format-spec nil)
12938 (defvar gnus-server-killed-servers nil)
12940 (defvar gnus-server-mode-map nil)
12941 (put 'gnus-server-mode 'mode-class 'special)
12943 (if gnus-server-mode-map
12945 (setq gnus-server-mode-map (make-sparse-keymap))
12946 (suppress-keymap gnus-server-mode-map)
12947 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12948 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12949 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12950 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12951 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12952 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12953 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12954 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12955 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12956 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12958 (defun gnus-server-mode ()
12959 "Major mode for listing and editing servers.
12961 All normal editing commands are switched off.
12962 \\<gnus-server-mode-map>
12964 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12966 The following commands are available:
12968 \\{gnus-server-mode-map}"
12970 (if gnus-visual (gnus-server-make-menu-bar))
12971 (kill-all-local-variables)
12972 (setq mode-line-modified "-- ")
12973 (make-local-variable 'mode-line-format)
12974 (setq mode-line-format (copy-sequence mode-line-format))
12975 (and (equal (nth 3 mode-line-format) " ")
12976 (setcar (nthcdr 3 mode-line-format) ""))
12977 (setq major-mode 'gnus-server-mode)
12978 (setq mode-name "Server")
12979 ; (gnus-group-set-mode-line)
12980 (setq mode-line-process nil)
12981 (use-local-map gnus-server-mode-map)
12982 (buffer-disable-undo (current-buffer))
12983 (setq truncate-lines t)
12984 (setq buffer-read-only t)
12985 (run-hooks 'gnus-server-mode-hook))
12987 (defun gnus-server-insert-server-line (sformat name method)
12988 (let* ((sformat (or sformat gnus-server-line-format-spec))
12990 (where (nth 1 method))
12992 (beginning-of-line)
12994 ;; Insert the text.
12995 (insert (eval sformat))
12996 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
12998 (defun gnus-server-setup-buffer ()
12999 (if (get-buffer gnus-server-buffer)
13002 (set-buffer (get-buffer-create gnus-server-buffer))
13004 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13006 (defun gnus-server-prepare ()
13007 (setq gnus-server-mode-line-format-spec
13008 (gnus-parse-format gnus-server-mode-line-format
13009 gnus-server-mode-line-format-alist))
13010 (setq gnus-server-line-format-spec
13011 (gnus-parse-format gnus-server-line-format
13012 gnus-server-line-format-alist))
13013 (let ((alist gnus-server-alist)
13014 (buffer-read-only nil))
13017 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13018 (setq alist (cdr alist))))
13019 (goto-char (point-min))
13020 (gnus-server-position-cursor))
13022 (defun gnus-server-server-name ()
13023 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13024 (and server (symbol-name server))))
13026 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13028 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13030 (defun gnus-server-update-server (server)
13032 (set-buffer gnus-server-buffer)
13033 (let ((buffer-read-only nil)
13034 (info (cdr (assoc server gnus-server-alist))))
13035 (gnus-dribble-enter
13036 (concat "(gnus-server-set-info \"" server "\" '"
13037 (prin1-to-string info) ")"))
13038 ;; Buffer may be narrowed.
13041 (if (gnus-server-goto-server server)
13042 (delete-region (progn (beginning-of-line) (point))
13043 (progn (forward-line 1) (point))))
13044 (let ((entry (assoc server gnus-server-alist)))
13045 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13046 (gnus-server-position-cursor))))))
13048 (defun gnus-server-set-info (server info)
13049 ;; Enter a select method into the virtual server alist.
13050 (gnus-dribble-enter
13051 (concat "(gnus-server-set-info \"" server "\" '"
13052 (prin1-to-string info) ")"))
13053 (let* ((server (nth 1 info))
13054 (entry (assoc server gnus-server-alist)))
13055 (if entry (setcdr entry info)
13056 (setq gnus-server-alist
13057 (nconc gnus-server-alist (list (cons server info)))))))
13059 (defun gnus-server-to-method (server)
13060 ;; Map virtual server names to select methods.
13061 (or (and (equal server "native") gnus-select-method)
13062 (cdr (assoc server gnus-server-alist))))
13064 (defun gnus-server-extend-method (group method)
13065 ;; This function "extends" a virtual server. If the server is
13066 ;; "hello", and the select method is ("hello" (my-var "something"))
13067 ;; in the group "alt.alt", this will result in a new virtual server
13068 ;; called "helly+alt.alt".
13070 (gnus-copy-sequence
13071 (if (equal (car method) "native") gnus-select-method
13072 (cdr (assoc (car method) gnus-server-alist))))))
13073 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13074 (nconc entry (cdr method))))
13076 (defun gnus-server-get-method (group method)
13077 ;; Input either a server name, and extended server name, or a
13078 ;; select method, and return a select method.
13079 (cond ((stringp method)
13080 (gnus-server-to-method method))
13081 ((stringp (car method))
13082 (gnus-server-extend-method group method))
13084 (gnus-server-add-address method))))
13086 (defun gnus-server-add-address (method)
13087 (let ((method-name (symbol-name (car method))))
13088 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13089 (not (assq (intern (concat method-name "-address")) method)))
13090 (append method (list (list (intern (concat method-name "-address"))
13094 (defun gnus-server-equal (s1 s2)
13096 (and (= (length s1) (length s2))
13098 (while (and s1 (member (car s1) s2))
13099 (setq s1 (cdr s1)))
13102 ;;; Interactive server functions.
13104 (defun gnus-server-kill-server (server)
13105 "Kill the server on the current line."
13106 (interactive (list (gnus-server-server-name)))
13107 (or (gnus-server-goto-server server)
13108 (if server (error "No such server: %s" server)
13109 (error "No server on the current line")))
13110 (let ((buffer-read-only nil))
13111 (delete-region (progn (beginning-of-line) (point))
13112 (progn (forward-line 1) (point))))
13113 (setq gnus-server-killed-servers
13114 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13115 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13116 gnus-server-alist))
13117 (gnus-server-position-cursor))
13119 (defun gnus-server-yank-server ()
13120 "Yank the previously killed server."
13122 (or gnus-server-killed-servers
13123 (error "No killed servers to be yanked"))
13124 (let ((alist gnus-server-alist)
13125 (server (gnus-server-server-name))
13126 (killed (car gnus-server-killed-servers)))
13128 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13129 (if (string= server (car (car gnus-server-alist)))
13130 (setq gnus-server-alist (cons killed gnus-server-alist))
13131 (while (and (cdr alist)
13132 (not (string= server (car (car (cdr alist))))))
13133 (setq alist (cdr alist)))
13134 (setcdr alist (cons killed (cdr alist)))))
13135 (gnus-server-update-server (car killed))
13136 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13137 (gnus-server-position-cursor)))
13139 (defun gnus-server-exit ()
13140 "Return to the group buffer."
13142 (kill-buffer (current-buffer))
13143 (switch-to-buffer gnus-group-buffer))
13145 (defun gnus-server-list-servers ()
13146 "List all available servers."
13148 (let ((cur (gnus-server-server-name)))
13149 (gnus-server-prepare)
13150 (if cur (gnus-server-goto-server cur)
13151 (goto-char (point-max))
13153 (gnus-server-position-cursor)))
13155 (defun gnus-server-copy-server (from to)
13158 (or (gnus-server-server-name)
13159 (error "No server on the current line"))
13160 (read-string "Copy to: ")))
13161 (or from (error "No server on current line"))
13162 (or (and to (not (string= to ""))) (error "No name to copy to"))
13163 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13164 (or (assoc from gnus-server-alist)
13165 (error "%s: no such server" from))
13166 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13167 (setcar to-entry to)
13168 (setcar (nthcdr 2 to-entry) to)
13169 (setq gnus-server-killed-servers
13170 (cons to-entry gnus-server-killed-servers))
13171 (gnus-server-yank-server)))
13173 (defun gnus-server-add-server (how where)
13175 (list (intern (completing-read "Server method: "
13176 gnus-valid-select-methods nil t))
13177 (read-string "Server name: ")))
13178 (setq gnus-server-killed-servers
13179 (cons (list where how where) gnus-server-killed-servers))
13180 (gnus-server-yank-server))
13182 (defun gnus-server-goto-server (server)
13183 "Jump to a server line."
13185 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13186 (let ((to (text-property-any (point-min) (point-max)
13187 'gnus-server (intern server))))
13191 (gnus-server-position-cursor)))))
13193 (defun gnus-server-edit-server (server)
13194 "Edit the server on the current line."
13195 (interactive (list (gnus-server-server-name)))
13197 (error "No server on current line"))
13198 (let ((winconf (current-window-configuration)))
13199 (get-buffer-create gnus-server-edit-buffer)
13200 (gnus-configure-windows 'edit-server)
13201 (gnus-add-current-to-buffer-list)
13203 (make-local-variable 'gnus-prev-winconf)
13204 (setq gnus-prev-winconf winconf)
13205 (use-local-map (copy-keymap (current-local-map)))
13206 (let ((done-func '(lambda ()
13207 "Exit editing mode and update the information."
13209 (gnus-server-edit-server-done 'group))))
13210 (setcar (cdr (nth 4 done-func)) server)
13211 (local-set-key "\C-c\C-c" done-func))
13213 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13214 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13216 (defun gnus-server-edit-server-done (server)
13218 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13219 (goto-char (point-min))
13220 (let ((form (read (current-buffer)))
13221 (winconf gnus-prev-winconf))
13222 (gnus-server-set-info server form)
13223 (kill-buffer (current-buffer))
13224 (and winconf (set-window-configuration winconf))
13225 (set-buffer gnus-server-buffer)
13226 (gnus-server-update-server (gnus-server-server-name))
13227 (gnus-server-position-cursor)))
13229 (defun gnus-server-read-server (server)
13231 (interactive (list (gnus-server-server-name)))
13232 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13234 (defun gnus-mouse-pick-server (e)
13236 (mouse-set-point e)
13237 (gnus-server-read-server (gnus-server-server-name)))
13240 ;;; entry points into gnus-score.el
13243 ;;; Finding score files.
13245 (defvar gnus-global-score-files nil
13246 "*List of global score files and directories.
13247 Set this variable if you want to use people's score files. One entry
13248 for each score file or each score file directory. Gnus will decide
13249 by itself what score files are applicable to which group.
13251 Say you want to use the single score file
13252 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13253 score files in the \"/ftp.some-where:/pub/score\" directory.
13255 (setq gnus-global-score-files
13256 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13257 \"/ftp.some-where:/pub/score\"))")
13259 (defun gnus-score-score-files (group)
13260 "Return a list of all possible score files."
13261 ;; Search and set any global score files.
13262 (and gnus-global-score-files
13263 (or gnus-internal-global-score-files
13264 (gnus-score-search-global-directories gnus-global-score-files)))
13265 ;; Fix the kill-file dir variable.
13266 (setq gnus-kill-files-directory
13267 (file-name-as-directory
13268 (or gnus-kill-files-directory "~/News/")))
13269 ;; If we can't read it, there are no score files.
13270 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13271 (setq gnus-score-file-list nil)
13272 (if (gnus-use-long-file-name 'not-score)
13273 ;; We want long file names.
13274 (if (or (not gnus-score-file-list)
13275 (not (car gnus-score-file-list))
13276 (gnus-file-newer-than gnus-kill-files-directory
13277 (car gnus-score-file-list)))
13278 (setq gnus-score-file-list
13279 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13282 gnus-kill-files-directory t
13283 (gnus-score-file-regexp))))))
13284 ;; We do not use long file names, so we have to do some
13285 ;; directory traversing.
13286 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13287 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13290 (setq dir (expand-file-name
13291 (concat gnus-kill-files-directory
13292 (gnus-replace-chars-in-string group ?. ?/))))
13293 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13294 (setq suffix (car suffixes)
13295 suffixes (cdr suffixes))
13296 (if (file-exists-p (concat dir "/" suffix))
13297 (setq files (cons (concat dir "/" suffix) files)))
13298 (while (>= (1+ (length dir)) mdir)
13299 (and (file-exists-p (concat dir "/all/" suffix))
13300 (setq files (cons (concat dir "/all/" suffix) files)))
13301 (string-match "/[^/]*$" dir)
13302 (setq dir (substring dir 0 (match-beginning 0)))))
13303 (setq gnus-score-file-list
13304 (cons nil (nreverse files)))))
13305 (cdr gnus-score-file-list)))
13307 (defun gnus-score-file-regexp ()
13308 (concat "\\(" gnus-score-file-suffix
13309 "\\|" gnus-adaptive-file-suffix "\\)$"))
13311 (defun gnus-score-find-bnews (group)
13312 "Return a list of score files for GROUP.
13313 The score files are those files in the ~/News directory which matches
13314 GROUP using BNews sys file syntax."
13315 (let* ((sfiles (append (gnus-score-score-files group)
13316 gnus-internal-global-score-files))
13317 (kill-dir (file-name-as-directory
13318 (expand-file-name gnus-kill-files-directory)))
13319 (klen (length kill-dir))
13320 ofiles not-match regexp)
13322 (set-buffer (get-buffer-create "*gnus score files*"))
13323 (buffer-disable-undo (current-buffer))
13324 ;; Go through all score file names and create regexp with them
13328 (insert (car sfiles))
13329 (goto-char (point-min))
13330 ;; First remove the suffix itself.
13331 (re-search-forward (concat "." (gnus-score-file-regexp)))
13332 (replace-match "" t t)
13333 (goto-char (point-min))
13334 (if (looking-at (regexp-quote kill-dir))
13335 ;; If the file name was just "SCORE", `klen' is one character
13337 (delete-char (min (1- (point-max)) klen))
13338 (goto-char (point-max))
13339 (search-backward "/")
13340 (delete-region (1+ (point)) (point-min)))
13341 ;; If short file names were used, we have to translate slashes.
13342 (goto-char (point-min))
13343 (while (re-search-forward "[/:]" nil t)
13344 (replace-match "." t t))
13345 ;; Translate "all" to ".*".
13346 (while (search-forward "all" nil t)
13347 (replace-match ".*" t t))
13348 (goto-char (point-min))
13349 ;; Deal with "not."s.
13350 (if (looking-at "not.")
13353 (setq regexp (buffer-substring 5 (point-max))))
13354 (setq regexp (buffer-substring 1 (point-max)))
13355 (setq not-match nil))
13356 ;; Finally - if this resulting regexp matches the group name,
13357 ;; we add this score file to the list of score files
13358 ;; applicable to this group.
13359 (if (or (and not-match
13360 (not (string-match regexp group)))
13361 (and (not not-match)
13362 (string-match regexp group)))
13363 (setq ofiles (cons (car sfiles) ofiles)))
13364 (setq sfiles (cdr sfiles)))
13365 (kill-buffer (current-buffer))
13366 ;; Slight kludge here - the last score file returned should be
13367 ;; the local score file, whether it exists or not. This is so
13368 ;; that any score commands the user enters will go to the right
13369 ;; file, and not end up in some global score file.
13372 (if (gnus-use-long-file-name 'not-score)
13373 (concat gnus-kill-files-directory group "."
13374 gnus-score-file-suffix)
13375 (concat gnus-kill-files-directory
13376 (gnus-replace-chars-in-string group ?. ?/)
13377 "/" gnus-score-file-suffix)))))
13378 (and (member localscore ofiles)
13379 (delete localscore ofiles))
13380 (setq ofiles (cons localscore ofiles)))
13381 (nreverse ofiles))))
13383 (defun gnus-score-find-single (group)
13384 "Return list containing the score file for GROUP."
13385 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13386 (gnus-score-file-name group)))
13388 (defun gnus-score-find-hierarchical (group)
13389 "Return list of score files for GROUP.
13390 This includes the score file for the group and all its parents."
13391 (let ((all (copy-sequence '(nil)))
13393 (while (string-match "\\." group (1+ start))
13394 (setq start (match-beginning 0))
13395 (setq all (cons (substring group 0 start) all)))
13396 (setq all (cons group all))
13398 (mapcar (lambda (newsgroup)
13399 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
13400 (setq all (nreverse all)))
13401 (mapcar 'gnus-score-file-name all))))
13403 (defvar gnus-score-file-alist-cache nil)
13405 (defun gnus-score-find-alist (group)
13406 "Return list of score files for GROUP.
13407 The list is determined from the variable gnus-score-file-alist."
13408 (let ((alist gnus-score-file-multiple-match-alist)
13410 ;; if this group has been seen before, return the cached entry
13411 (if (setq score-files (assoc group gnus-score-file-alist-cache))
13412 (cdr score-files) ; ensures caching of groups with no matches
13413 ;; handle the multiple match alist
13415 (and (string-match (car (car alist)) group)
13417 (nconc score-files (cdr (car alist)))))
13418 (setq alist (cdr alist)))
13419 (setq alist gnus-score-file-single-match-alist)
13420 ;; handle the single match alist
13423 (and (string-match (car (car alist)) group)
13424 ;; progn used just in case ("regexp") has no files
13425 ;; and score-files is still nil. -sj
13426 ;; this can be construed as a "stop searching here" feature :>
13427 ;; and used to simplify regexps in the single-alist
13430 (append score-files (cdr (car alist))))
13431 (throw 'done nil)))
13432 (setq alist (cdr alist))))
13433 ;; cache the score files
13434 (setq gnus-score-file-alist-cache
13435 (cons (cons group score-files) gnus-score-file-alist-cache))
13439 (defun gnus-possibly-score-headers (&optional trace)
13440 (let ((func gnus-score-find-score-files-function)
13442 (and func (not (listp func))
13443 (setq func (list func)))
13444 ;; Go through all the functions for finding score files (or actual
13445 ;; scores) and add them to a list.
13446 (setq score-files (copy-sequence
13447 (gnus-score-find-alist gnus-newsgroup-name)))
13449 (and (symbolp (car func))
13450 (fboundp (car func))
13452 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
13453 (setq func (cdr func)))
13454 (if score-files (gnus-score-headers score-files trace))))
13456 (defun gnus-score-file-name (newsgroup &optional suffix)
13457 "Return the name of a score file for NEWSGROUP."
13458 (let ((suffix (or suffix gnus-score-file-suffix)))
13459 (cond ((or (null newsgroup)
13460 (string-equal newsgroup ""))
13461 ;; The global score file is placed at top of the directory.
13463 suffix (or gnus-kill-files-directory "~/News")))
13464 ((gnus-use-long-file-name 'not-score)
13465 ;; Append ".SCORE" to newsgroup name.
13466 (expand-file-name (concat newsgroup "." suffix)
13467 (or gnus-kill-files-directory "~/News")))
13469 ;; Place "SCORE" under the hierarchical directory.
13470 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13472 (or gnus-kill-files-directory "~/News"))))))
13474 (defun gnus-score-search-global-directories (files)
13475 "Scan all global score directories for score files."
13476 ;; Set the variable `gnus-internal-global-score-files' to all
13477 ;; available global score files.
13478 (interactive (list gnus-global-score-files))
13481 (if (string-match "/$" (car files))
13482 (setq out (nconc (directory-files
13484 (concat (gnus-score-file-regexp) "$"))))
13485 (setq out (cons (car files) out)))
13486 (setq files (cdr files)))
13487 (setq gnus-internal-global-score-files out)))
13489 ;; Allow redefinition of Gnus functions.
13491 (gnus-ems-redefine)
13495 ;;; gnus.el ends here