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 Gnus looks suspiciously like GNUS, it isn't quite the same
27 ;; beast. Most internal structures have been changed. If you have
28 ;; 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 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
168 "*Directory where the group FAQs are stored.
169 This will most commonly be on a remote machine, and the file will be
172 Note that Gnus uses an aol machine as the default directory. If this
173 feels fundamentally unclean, just think of it as a way to finally get
174 something of value back from them.
176 If the default site is too slow, try one of these:
178 North America: ftp.uu.net /usenet/news.answers
179 mirrors.aol.com /pub/rtfm/usenet
180 ftp.seas.gwu.edu /pub/rtfm
181 rtfm.mit.edu /pub/usenet/news.answers
182 Europe: ftp.uni-paderborn.de /pub/FAQ
183 ftp.Germany.EU.net /pub/newsarchive/news.answers
184 ftp.sunet.se /pub/usenet
185 Asia: nctuccca.edu.tw /USENET/FAQ
186 hwarang.postech.ac.kr /pub/usenet/news.answers
187 ftp.hk.super.net /mirror/faqs")
189 (defvar gnus-group-archive-directory
190 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
191 "*The address of the (ding) archives.")
193 (defvar gnus-group-recent-archive-directory
194 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
195 "*The address of the most recent (ding) articles.")
197 (defvar gnus-default-subscribed-newsgroups nil
198 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
199 It should be a list of strings.
200 If it is `t', Gnus will not do anything special the first time it is
201 started; it'll just use the normal newsgroups subscription methods.")
203 (defvar gnus-use-cross-reference t
204 "*Non-nil means that cross referenced articles will be marked as read.
205 If nil, ignore cross references. If t, mark articles as read in
206 subscribed newsgroups. If neither t nor nil, mark as read in all
209 (defvar gnus-use-dribble-file t
210 "*Non-nil means that Gnus will use a dribble file to store user updates.
211 If Emacs should crash without saving the .newsrc files, complete
212 information can be restored from the dribble file.")
214 (defvar gnus-asynchronous nil
215 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
217 (defvar gnus-asynchronous-article-function nil
218 "*Function for picking articles to pre-fetch, possibly.")
220 (defvar gnus-score-file-single-match-alist nil
221 "*Alist mapping regexps to lists of score files.
222 Each element of this alist should be of the form
223 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
225 If the name of a group is matched by REGEXP, the corresponding scorefiles
226 will be used for that group.
227 The first match found is used, subsequent matching entries are ignored (to
228 use multiple matches, see gnus-score-file-multiple-match-alist).
230 These score files are loaded in addition to any files returned by
231 gnus-score-find-score-files-function (which see).")
233 (defvar gnus-score-file-multiple-match-alist nil
234 "*Alist mapping regexps to lists of score files.
235 Each element of this alist should be of the form
236 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
238 If the name of a group is matched by REGEXP, the corresponding scorefiles
239 will be used for that group.
240 If multiple REGEXPs match a group, the score files corresponding to each
241 match will be used (for only one match to be used, see
242 gnus-score-file-single-match-alist).
244 These score files are loaded in addition to any files returned by
245 gnus-score-find-score-files-function (which see).")
248 (defvar gnus-score-file-suffix "SCORE"
249 "*Suffix of the score files.")
251 (defvar gnus-adaptive-file-suffix "ADAPT"
252 "*Suffix of the adaptive score files.")
254 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
255 "*Function used to find score files.
256 The function will be called with the group name as the argument, and
257 should return a list of score files to apply to that group. The score
258 files do not actually have to exist.
260 Predefined values are:
262 gnus-score-find-single: Only apply the group's own score file.
263 gnus-score-find-hierarchical: Also apply score files from parent groups.
264 gnus-score-find-bnews: Apply score files whose names matches.
266 See the documentation to these functions for more information.
268 This variable can also be a list of functions to be called. Each
269 function should either return a list of score files, or a list of
272 (defvar gnus-score-interactive-default-score 1000
273 "*Scoring commands will raise/lower the score with this number as the default.")
275 (defvar gnus-large-newsgroup 200
276 "*The number of articles which indicates a large newsgroup.
277 If the number of articles in a newsgroup is greater than this value,
278 confirmation is required for selecting the newsgroup.")
280 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
281 (defvar gnus-no-groups-message "No news is horrible news"
282 "*Message displayed by Gnus when no groups are available.")
284 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
285 "*Non-nil means that the default name of a file to save articles in is the group name.
286 If it's nil, the directory form of the group name is used instead.
288 If this variable is a list, and the list contains the element
289 `not-score', long file names will not be used for score files; if it
290 contains the element `not-save', long file names will not be used for
291 saving; and if it contains the element `not-kill', long file names
292 will not be used for kill files.")
294 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
295 "*Name of the directory articles will be saved in (default \"~/News\").
296 Initialized from the SAVEDIR environment variable.")
298 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
299 "*Name of the directory where kill files will be stored (default \"~/News\").
300 Initialized from the SAVEDIR environment variable.")
302 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
303 "*A function to save articles in your favorite format.
304 The function must be interactively callable (in other words, it must
305 be an Emacs command).
307 Gnus provides the following functions:
309 * gnus-summary-save-in-rmail (Rmail format)
310 * gnus-summary-save-in-mail (Unix mail format)
311 * gnus-summary-save-in-folder (MH folder)
312 * gnus-summary-save-in-file (article format).
313 * gnus-summary-save-in-vm (use VM's folder format).")
315 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
316 "*A function generating a file name to save articles in Rmail format.
317 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
319 (defvar gnus-mail-save-name (function gnus-plain-save-name)
320 "*A function generating a file name to save articles in Unix mail format.
321 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
323 (defvar gnus-folder-save-name (function gnus-folder-save-name)
324 "*A function generating a file name to save articles in MH folder.
325 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
327 (defvar gnus-file-save-name (function gnus-numeric-save-name)
328 "*A function generating a file name to save articles in article format.
329 The function is called with NEWSGROUP, HEADERS, and optional
332 (defvar gnus-split-methods nil
333 "*Variable used to suggest where articles are to be saved.
334 The syntax of this variable is the same as `nnmail-split-methods'.
336 For instance, if you would like to save articles related to Gnus in
337 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
338 you could set this variable to something like:
340 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
341 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
343 (defvar gnus-save-score nil
344 "*If non-nil, save group scoring info.")
346 (defvar gnus-use-adaptive-scoring nil
347 "*If non-nil, use some adaptive scoring scheme.")
349 (defvar gnus-use-cache nil
350 "*If non-nil, Gnus will cache (some) articles locally.")
352 (defvar gnus-use-scoring t
353 "*If non-nil, enable scoring.")
355 (defvar gnus-fetch-old-headers nil
356 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
357 If an unread article in the group refers to an older, already read (or
358 just marked as read) article, the old article will not normally be
359 displayed in the Summary buffer. If this variable is non-nil, Gnus
360 will attempt to grab the headers to the old articles, and thereby
361 build complete threads. If it has the value `some', only enough
362 headers to connect otherwise loose threads will be displayed.
364 The server has to support XOVER for any of this to work.")
367 ;(defvar gnus-visual t
368 ; "*If non-nil, will do various highlighting.
369 ;If nil, no mouse highlights (or any other highlights) will be
370 ;performed. This might speed up Gnus some when generating large group
371 ;and summary buffers.")
373 (defvar gnus-novice-user t
374 "*Non-nil means that you are a usenet novice.
375 If non-nil, verbose messages may be displayed and confirmations may be
378 (defvar gnus-expert-user nil
379 "*Non-nil means that you will never be asked for confirmation about anything.
380 And that means *anything*.")
382 (defvar gnus-verbose 7
383 "*Integer that says how verbose Gnus should be.
384 The higher the number, the more messages Gnus will flash to say what
385 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
386 display most important messages; and at ten, Gnus will keep on
387 jabbering all the time.")
389 (defvar gnus-keep-same-level nil
390 "*Non-nil means that the next newsgroup after the current will be on the same level.
391 When you type, for instance, `n' after reading the last article in the
392 current newsgroup, you will go to the next newsgroup. If this variable
393 is nil, the next newsgroup will be the next from the group
395 If this variable is non-nil, Gnus will either put you in the
396 next newsgroup with the same level, or, if no such newsgroup is
397 available, the next newsgroup with the lowest possible level higher
398 than the current level.
399 If this variable is `best', Gnus will make the next newsgroup the one
400 with the best level.")
402 (defvar gnus-summary-make-false-root 'adopt
403 "*nil means that Gnus won't gather loose threads.
404 If the root of a thread has expired or been read in a previous
405 session, the information necessary to build a complete thread has been
406 lost. Instead of having many small sub-threads from this original thread
407 scattered all over the summary buffer, Gnus can gather them.
409 If non-nil, Gnus will try to gather all loose sub-threads from an
410 original thread into one large thread.
412 If this variable is non-nil, it should be one of `none', `adopt',
415 If this variable is `none', Gnus will not make a false root, but just
416 present the sub-threads after another.
417 If this variable is `dummy', Gnus will create a dummy root that will
418 have all the sub-threads as children.
419 If this variable is `adopt', Gnus will make one of the \"children\"
420 the parent and mark all the step-children as such.
421 If this variable is `empty', the \"children\" are printed with empty
422 subject fields. (Or rather, they will be printed with a string
423 given by the `gnus-summary-same-subject' variable.)")
425 (defvar gnus-summary-gather-subject-limit nil
426 "*Maximum length of subject comparisons when gathering loose threads.
427 Use nil to compare full subjects. Setting this variable to a low
428 number will help gather threads that have been corrupted by
429 newsreaders chopping off subject lines, but it might also mean that
430 unrelated articles that have subject that happen to begin with the
431 same few characters will be incorrectly gathered.
433 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
434 comparing subjects.")
436 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
437 (defvar gnus-summary-same-subject ""
438 "*String indicating that the current article has the same subject as the previous.
439 This variable will only be used if the value of
440 `gnus-summary-make-false-root' is `empty'.")
442 (defvar gnus-summary-goto-unread t
443 "*If non-nil, marking commands will go to the next unread article.")
445 (defvar gnus-group-goto-unread t
446 "*If non-nil, movement commands will go to the next unread and subscribed group.")
448 (defvar gnus-check-new-newsgroups t
449 "*Non-nil means that Gnus will add new newsgroups at startup.
450 If this variable is `ask-server', Gnus will ask the server for new
451 groups since the last time it checked. This means that the killed list
452 is no longer necessary, so you could set `gnus-save-killed-list' to
455 A variant is to have this variable be a list of select methods. Gnus
456 will then use the `ask-server' method on all these select methods to
457 query for new groups from all those servers.
460 (setq gnus-check-new-newsgroups
461 '((nntp \"some.server\") (nntp \"other.server\")))
463 If this variable is nil, then you have to tell Gnus explicitly to
464 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
466 (defvar gnus-check-bogus-newsgroups nil
467 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
468 If this variable is nil, then you have to tell Gnus explicitly to
469 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
471 (defvar gnus-read-active-file t
472 "*Non-nil means that Gnus will read the entire active file at startup.
473 If this variable is nil, Gnus will only know about the groups in your
476 If this variable is `some', Gnus will try to only read the relevant
477 parts of the active file from the server. Not all servers support
478 this, and it might be quite slow with other servers, but this should
479 generally be faster than both the t and nil value.
481 If you set this variable to nil or `some', you probably still want to
482 be told about new newsgroups that arrive. To do that, set
483 `gnus-check-new-newsgroups' to `ask-server'. This may not work
484 properly with all servers.")
486 (defvar gnus-level-subscribed 5
487 "*Groups with levels less than or equal to this variable are subscribed.")
489 (defvar gnus-level-unsubscribed 7
490 "*Groups with levels less than or equal to this variable are unsubscribed.
491 Groups with levels less than `gnus-level-subscribed', which should be
492 less than this variable, are subscribed.")
494 (defvar gnus-level-zombie 8
495 "*Groups with this level are zombie groups.")
497 (defvar gnus-level-killed 9
498 "*Groups with this level are killed.")
500 (defvar gnus-level-default-subscribed 3
501 "*New subscribed groups will be subscribed at this level.")
503 (defvar gnus-level-default-unsubscribed 6
504 "*New unsubscribed groups will be unsubscribed at this level.")
506 (defvar gnus-activate-foreign-newsgroups 4
507 "*If nil, Gnus will not check foreign newsgroups at startup.
508 If it is non-nil, it should be a number between one and nine. Foreign
509 newsgroups that have a level lower or equal to this number will be
510 activated on startup. For instance, if you want to active all
511 subscribed newsgroups, but not the rest, you'd set this variable to
512 `gnus-level-subscribed'.
514 If you subscribe to lots of newsgroups from different servers, startup
515 might take a while. By setting this variable to nil, you'll save time,
516 but you won't be told how many unread articles there are in the
519 (defvar gnus-save-newsrc-file t
520 "*Non-nil means that Gnus will save the `.newsrc' file.
521 Gnus always saves its own startup file, which is called
522 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
523 be readily understood by other newsreaders. If you don't plan on
524 using other newsreaders, set this variable to nil to save some time on
527 (defvar gnus-save-killed-list t
528 "*If non-nil, save the list of killed groups to the startup file.
529 This will save both time (when starting and quitting) and space (both
530 memory and disk), but it will also mean that Gnus has no record of
531 which groups are new and which are old, so the automatic new
532 newsgroups subscription methods become meaningless. You should always
533 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
536 (defvar gnus-interactive-catchup t
537 "*If non-nil, require your confirmation when catching up a group.")
539 (defvar gnus-interactive-post t
540 "*If non-nil, group name will be asked for when posting.")
542 (defvar gnus-interactive-exit t
543 "*If non-nil, require your confirmation when exiting Gnus.")
545 (defvar gnus-kill-killed t
546 "*If non-nil, Gnus will apply kill files to already killed articles.
547 If it is nil, Gnus will never apply kill files to articles that have
548 already been through the scoring process, which might very well save lots
551 (defvar gnus-extract-address-components 'gnus-extract-address-components
552 "*Function for extracting address components from a From header.
553 Two pre-defined function exist: `gnus-extract-address-components',
554 which is the default, quite fast, and too simplistic solution, and
555 `mail-extract-address-components', which works much better, but is
558 (defvar gnus-summary-default-score 0
559 "*Default article score level.
560 If this variable is nil, scoring will be disabled.")
562 (defvar gnus-summary-zcore-fuzz 0
563 "*Fuzziness factor for the zcore in the summary buffer.
564 Articles with scores closer than this to `gnus-summary-default-score'
565 will not be marked.")
567 (defvar gnus-simplify-subject-fuzzy-regexp nil
568 "*Regular expression that will be removed from subject strings if
569 fuzzy subject simplification is selected.")
571 (defvar gnus-group-default-list-level gnus-level-subscribed
572 "*Default listing level.
573 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
575 (defvar gnus-group-use-permanent-levels nil
576 "*If non-nil, once you set a level, Gnus will use this level.")
578 (defvar gnus-show-mime nil
579 "*If non-nil, do mime processing of articles.
580 The articles will simply be fed to the function given by
581 `gnus-show-mime-method'.")
583 (defvar gnus-strict-mime t
584 "*If nil, decode MIME header even if there is not Mime-Version field.")
586 (defvar gnus-show-mime-method (function metamail-buffer)
587 "*Function to process a MIME message.
588 The function is called from the article buffer.")
590 (defvar gnus-show-threads t
591 "*If non-nil, display threads in summary mode.")
593 (defvar gnus-thread-hide-subtree nil
594 "*If non-nil, hide all threads initially.
595 If threads are hidden, you have to run the command
596 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
597 to expose hidden threads.")
599 (defvar gnus-thread-hide-killed t
600 "*If non-nil, hide killed threads automatically.")
602 (defvar gnus-thread-ignore-subject nil
603 "*If non-nil, ignore subjects and do all threading based on the Reference header.
604 If nil, which is the default, articles that have different subjects
605 from their parents will start separate threads.")
607 (defvar gnus-thread-indent-level 4
608 "*Number that says how much each sub-thread should be indented.")
610 (defvar gnus-ignored-newsgroups
611 (purecopy (mapconcat 'identity
612 '("^to\\." ; not "real" groups
613 "^[0-9. \t]+ " ; all digits in name
614 "[][\"#'()]" ; bogus characters
617 "*A regexp to match uninteresting newsgroups in the active file.
618 Any lines in the active file matching this regular expression are
619 removed from the newsgroup list before anything else is done to it,
620 thus making them effectively non-existent.")
622 (defvar gnus-ignored-headers
623 "^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:"
624 "*All headers that match this regexp will be hidden.
625 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
627 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
628 "*All headers that do not match this regexp will be hidden.
629 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
631 (defvar gnus-sorted-header-list
632 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
633 "^Cc:" "^Date:" "^Organization:")
634 "*This variable is a list of regular expressions.
635 If it is non-nil, headers that match the regular expressions will
636 be placed first in the article buffer in the sequence specified by
639 (defvar gnus-show-all-headers nil
640 "*If non-nil, don't hide any headers.")
642 (defvar gnus-save-all-headers t
643 "*If non-nil, don't remove any headers before saving.")
645 (defvar gnus-inhibit-startup-message nil
646 "*If non-nil, the startup message will not be displayed.")
648 (defvar gnus-signature-separator "^-- *$"
649 "Regexp matching signature separator.")
651 (defvar gnus-auto-extend-newsgroup t
652 "*If non-nil, extend newsgroup forward and backward when requested.")
654 (defvar gnus-auto-select-first t
655 "*If non-nil, select the first unread article when entering a group.
656 If you want to prevent automatic selection of the first unread article
657 in some newsgroups, set the variable to nil in
658 `gnus-select-group-hook'.")
660 (defvar gnus-auto-select-next t
661 "*If non-nil, offer to go to the next group from the end of the previous.
662 If the value is t and the next newsgroup is empty, Gnus will exit
663 summary mode and go back to group mode. If the value is neither nil
664 nor t, Gnus will select the following unread newsgroup. In
665 particular, if the value is the symbol `quietly', the next unread
666 newsgroup will be selected without any confirmations.")
668 (defvar gnus-auto-select-same nil
669 "*If non-nil, select the next article with the same subject.")
671 (defvar gnus-summary-check-current nil
672 "*If non-nil, consider the current article when moving.
673 The \"unread\" movement commands will stay on the same line if the
674 current article is unread.")
676 (defvar gnus-auto-center-summary t
677 "*If non-nil, always center the current summary buffer.")
679 (defvar gnus-break-pages t
680 "*If non-nil, do page breaking on articles.
681 The page delimiter is specified by the `gnus-page-delimiter'
684 (defvar gnus-page-delimiter "^\^L"
685 "*Regexp describing what to use as article page delimiters.
686 The default value is \"^\^L\", which is a form linefeed at the
687 beginning of a line.")
689 (defvar gnus-use-full-window t
690 "*If non-nil, use the entire Emacs screen.")
692 (defvar gnus-window-configuration nil
693 "Obsolete variable. See `gnus-buffer-configuration'.")
695 (defvar gnus-buffer-configuration
696 '((group ([group 1.0 point]
697 (if gnus-carpal [group-carpal 4])))
698 (summary ([summary 1.0 point]
699 (if gnus-carpal [summary-carpal 4])))
700 (article ([summary 0.25 point]
701 (if gnus-carpal [summary-carpal 4])
703 (server ([server 1.0 point]
704 (if gnus-carpal [server-carpal 2])))
705 (browse ([browse 1.0 point]
706 (if gnus-carpal [browse-carpal 2])))
707 (group-mail ([mail 1.0 point]))
708 (summary-mail ([mail 1.0 point]))
709 (summary-reply ([article 0.5]
711 (info ([nil 1.0 point]))
712 (summary-faq ([summary 0.25]
714 (edit-group ([group 0.5]
715 [edit-group 1.0 point]))
716 (edit-server ([server 0.5]
717 [edit-server 1.0 point]))
718 (edit-score ([summary 0.25]
719 [edit-score 1.0 point]))
720 (post ([post 1.0 point]))
721 (reply ([article 0.5]
723 (mail-forward ([mail 1.0 point]))
724 (post-forward ([post 1.0 point]))
725 (reply-yank ([mail 1.0 point]))
726 (followup ([article 0.5]
728 (followup-yank ([post 1.0 point])))
729 "Window configuration for all possible Gnus buffers.
730 This variable is a list of lists. Each of these lists has a NAME and
731 a RULE. The NAMEs are commonsense names like `group', which names a
732 rule used when displaying the group buffer; `summary', which names a
733 rule for what happens when you enter a group and do not display an
734 article buffer; and so on. See the value of this variable for a
735 complete list of NAMEs.
737 Each RULE is a list of vectors. The first element in this vector is
738 the name of the buffer to be displayed; the second element is the
739 percentage of the screen this buffer is to occupy (a number in the
740 0.0-0.99 range); the optional third element is `point', which should
741 be present to denote which buffer point is to go to after making this
742 buffer configuration.")
744 (defvar gnus-window-to-buffer
745 '((group . gnus-group-buffer)
746 (summary . gnus-summary-buffer)
747 (article . gnus-article-buffer)
748 (server . gnus-server-buffer)
749 (browse . "*Gnus Browse Server*")
750 (edit-group . gnus-group-edit-buffer)
751 (edit-server . gnus-server-edit-buffer)
752 (group-carpal . gnus-carpal-group-buffer)
753 (summary-carpal . gnus-carpal-summary-buffer)
754 (server-carpal . gnus-carpal-server-buffer)
755 (browse-carpal . gnus-carpal-browse-buffer)
756 (edit-score . gnus-score-edit-buffer)
757 (mail . gnus-mail-buffer)
758 (post . gnus-post-news-buffer)
759 (faq . gnus-faq-buffer))
760 "Mapping from short symbols to buffer names or buffer variables.")
762 (defvar gnus-carpal nil
763 "*If non-nil, display clickable icons.")
765 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
766 "*Function called with a group name when new group is detected.
767 A few pre-made functions are supplied: `gnus-subscribe-randomly'
768 inserts new groups at the beginning of the list of groups;
769 `gnus-subscribe-alphabetically' inserts new groups in strict
770 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
771 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
774 ;; Suggested by a bug report by Hallvard B Furuseth.
775 ;; <h.b.furuseth@usit.uio.no>.
776 (defvar gnus-subscribe-options-newsgroup-method
777 (function gnus-subscribe-alphabetically)
778 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
779 If, for instance, you want to subscribe to all newsgroups in the
780 \"no\" and \"alt\" hierarchies, you'd put the following in your
783 options -n no.all alt.all
785 Gnus will the subscribe all new newsgroups in these hierarchies with
786 the subscription method in this variable.")
788 (defvar gnus-subscribe-hierarchical-interactive nil
789 "*If non-nil, Gnus will offer to subscribe hierarchically.
790 When a new hierarchy appears, Gnus will ask the user:
792 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
794 If the user pressed `d', Gnus will descend the hierarchy, `y' will
795 subscribe to all newsgroups in the hierarchy and `s' will skip this
796 hierarchy in its entirety.")
798 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
799 "*Function used for sorting the group buffer.
800 This function will be called with group info entries as the arguments
801 for the groups to be sorted. Pre-made functions include
802 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
803 `gnus-group-sort-by-level'")
805 ;; Mark variables suggested by Thomas Michanek
806 ;; <Thomas.Michanek@telelogic.se>.
807 (defvar gnus-unread-mark ?
808 "*Mark used for unread articles.")
809 (defvar gnus-ticked-mark ?!
810 "*Mark used for ticked articles.")
811 (defvar gnus-dormant-mark ??
812 "*Mark used for dormant articles.")
813 (defvar gnus-del-mark ?r
814 "*Mark used for del'd articles.")
815 (defvar gnus-read-mark ?R
816 "*Mark used for read articles.")
817 (defvar gnus-expirable-mark ?E
818 "*Mark used for expirable articles.")
819 (defvar gnus-killed-mark ?K
820 "*Mark used for killed articles.")
821 (defvar gnus-kill-file-mark ?X
822 "*Mark used for articles killed by kill files.")
823 (defvar gnus-low-score-mark ?Y
824 "*Mark used for articles with a low score.")
825 (defvar gnus-catchup-mark ?C
826 "*Mark used for articles that are caught up.")
827 (defvar gnus-replied-mark ?A
828 "*Mark used for articles that have been replied to.")
829 (defvar gnus-process-mark ?#
831 (defvar gnus-ancient-mark ?O
832 "*Mark used for ancient articles.")
833 (defvar gnus-canceled-mark ?G
834 "*Mark used for canceled articles.")
835 (defvar gnus-score-over-mark ?+
836 "*Score mark used for articles with high scores.")
837 (defvar gnus-score-below-mark ?-
838 "*Score mark used for articles with low scores.")
839 (defvar gnus-empty-thread-mark ?
840 "*There is no thread under the article.")
841 (defvar gnus-not-empty-thread-mark ?=
842 "*There is a thread under the article.")
843 (defvar gnus-dummy-mark ?Z
844 "*This is a dummy article.")
846 (defvar gnus-view-pseudo-asynchronously nil
847 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
849 (defvar gnus-view-pseudos nil
850 "*If `automatic', pseudo-articles will be viewed automatically.
851 If `not-confirm', pseudos will be viewed automatically, and the user
852 will not be asked to confirm the command.")
854 (defvar gnus-view-pseudos-separately t
855 "*If non-nil, one pseudo-article will be created for each file to be viewed.
856 If nil, all files that use the same viewing command will be given as a
857 list of parameters to that command.")
859 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
860 "*Format of group lines.
861 It works along the same lines as a normal formatting string,
862 with some simple extensions.
864 %M Only marked articles (character, \"*\" or \" \")
865 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
866 %L Level of subscribedness (integer)
867 %N Number of unread articles (integer)
868 %I Number of dormant articles (integer)
869 %i Number of ticked and dormant (integer)
870 %T Number of ticked articles (integer)
871 %R Number of read articles (integer)
872 %t Total number of articles (integer)
873 %y Number of unread, unticked articles (integer)
874 %G Group name (string)
875 %g Qualified group name (string)
876 %D Group description (string)
877 %s Select method (string)
878 %o Moderated group (char, \"m\")
879 %p Process mark (char)
880 %O Moderated group (string, \"(m)\" or \"\")
881 %n Select from where (string)
882 %z A string that look like `<%s:%n>' if a foreign select method is used
883 %u User defined specifier. The next character in the format string should
884 be a letter. Gnus will call the function gnus-user-format-function-X,
885 where X is the letter following %u. The function will be passed the
886 current header as argument. The function should return a string, which
887 will be inserted into the buffer just like information from any other
890 Text between %( and %) will be highlighted with `gnus-mouse-face' when
891 the mouse point move inside the area. There can only be one such area.
893 Note that this format specification is not always respected. For
894 reasons of efficiency, when listing killed groups, this specification
895 is ignored altogether. If the spec is changed considerably, your
896 output may end up looking strange when listing both alive and killed
899 If you use %o or %O, reading the active file will be slower and quite
900 a bit of extra memory will be used. %D will also worsen performance.
901 Also note that if you change the format specification to include any
902 of these specs, you must probably re-start Gnus to see them go into
905 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
906 "*The format specification of the lines in the summary buffer.
908 It works along the same lines as a normal formatting string,
909 with some simple extensions.
911 %N Article number, left padded with spaces (string)
913 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
914 %n Name of the poster (string)
915 %a Extracted name of the poster (string)
916 %A Extracted address of the poster (string)
917 %F Contents of the From: header (string)
918 %x Contents of the Xref: header (string)
919 %D Date of the article (string)
920 %d Date of the article (string) in DD-MMM format
921 %M Message-id of the article (string)
922 %r References of the article (string)
923 %c Number of characters in the article (integer)
924 %L Number of lines in the article (integer)
925 %I Indentation based on thread level (a string of spaces)
926 %T A string with two possible values: 80 spaces if the article
927 is on thread level two or larger and 0 spaces on level one
928 %R \"R\" if this article has been replied to, \" \" otherwise (character)
929 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
930 %[ Opening bracket (character, \"[\" or \"<\")
931 %] Closing bracket (character, \"]\" or \">\")
932 %> Spaces of length thread-level (string)
933 %< Spaces of length (- 20 thread-level) (string)
934 %i Article score (number)
935 %z Article zcore (character)
936 %t Number of articles under the current thread (number).
937 %e Whether the thread is empty or not (character).
938 %u User defined specifier. The next character in the format string should
939 be a letter. Gnus will call the function gnus-user-format-function-X,
940 where X is the letter following %u. The function will be passed the
941 current header as argument. The function should return a string, which
942 will be inserted into the summary just like information from any other
945 Text between %( and %) will be highlighted with `gnus-mouse-face'
946 when the mouse point is placed inside the area. There can only be one
949 The %U (status), %R (replied) and %z (zcore) specs have to be handled
950 with care. For reasons of efficiency, Gnus will compute what column
951 these characters will end up in, and \"hard-code\" that. This means that
952 it is illegal to have these specs after a variable-length spec. Well,
953 you might not be arrested, but your summary buffer will look strange,
956 The smart choice is to have these specs as for to the left as
959 This restriction may disappear in later versions of Gnus.")
961 (defvar gnus-summary-dummy-line-format "* : : %S\n"
962 "*The format specification for the dummy roots in the summary buffer.
963 It works along the same lines as a normal formatting string,
964 with some simple extensions.
968 (defvar gnus-summary-mode-line-format "Gnus %G/%A %Z"
969 "*The format specification for the summary mode line.")
971 (defvar gnus-article-mode-line-format "Gnus %G/%A %S"
972 "*The format specification for the article mode line.")
974 (defvar gnus-group-mode-line-format "Gnus List of groups {%M:%S} "
975 "*The format specification for the group mode line.")
977 (defvar gnus-valid-select-methods
978 '(("nntp" post address prompt-address)
980 ("nnvirtual" none virtual prompt-address)
981 ("nnmbox" mail respool)
982 ("nnml" mail respool)
983 ("nnmh" mail respool)
984 ("nndir" none prompt-address address)
985 ("nneething" none prompt-address)
987 ("nndoc" none prompt-address)
988 ("nnbabyl" mail respool)
989 ("nnkiboze" post virtual)
991 ("nnfolder" mail respool))
992 "An alist of valid select methods.
993 The first element of each list lists should be a string with the name
994 of the select method. The other elements may be be the category of
995 this method (ie. `post', `mail', `none' or whatever) or other
996 properties that this method has (like being respoolable).
997 If you implement a new select method, all you should have to change is
998 this variable. I think.")
1000 (defvar gnus-updated-mode-lines '(group article summary)
1001 "*List of buffers that should update their mode lines.
1002 The list may contain the symbols `group', `article' and `summary'. If
1003 the corresponding symbol is present, Gnus will keep that mode line
1004 updated with information that may be pertinent.
1005 If this variable is nil, screen refresh may be quicker.")
1007 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1008 (defvar gnus-mode-non-string-length 21
1009 "*Max length of mode-line non-string contents.
1010 If this is nil, Gnus will take space as is needed, leaving the rest
1011 of the modeline intact.")
1014 ;(defvar gnus-mouse-face 'highlight
1015 ; "*Face used for mouse highlighting in Gnus.
1016 ;No mouse highlights will be done if `gnus-visual' is nil.")
1018 (defvar gnus-summary-mark-below nil
1019 "*Mark all articles with a score below this variable as read.
1020 This variable is local to each summary buffer and usually set by the
1023 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1024 "*List of functions used for sorting threads in the summary buffer.
1025 By default, threads are sorted by article number.
1027 Each function takes two threads and return non-nil if the first thread
1028 should be sorted before the other. If you use more than one function,
1029 the primary sort function should be the last.
1031 Ready-mady functions include `gnus-thread-sort-by-number',
1032 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1033 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1034 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1036 (defvar gnus-thread-score-function '+
1037 "*Function used for calculating the total score of a thread.
1039 The function is called with the scores of the article and each
1040 subthread and should then return the score of the thread.
1042 Some functions you can use are `+', `max', or `min'.")
1044 (defvar gnus-options-subscribe nil
1045 "*All new groups matching this regexp will be subscribed unconditionally.
1046 Note that this variable deals only with new newsgroups. This variable
1047 does not affect old newsgroups.")
1049 (defvar gnus-options-not-subscribe nil
1050 "*All new groups matching this regexp will be ignored.
1051 Note that this variable deals only with new newsgroups. This variable
1052 does not affect old (already subscribed) newsgroups.")
1054 (defvar gnus-auto-expirable-newsgroups nil
1055 "*Groups in which to automatically mark read articles as expirable.
1056 If non-nil, this should be a regexp that should match all groups in
1057 which to perform auto-expiry. This only makes sense for mail groups.")
1059 (defvar gnus-hidden-properties '(invisible t intangible t)
1060 "Property list to use for hiding text.")
1062 (defvar gnus-modtime-botch nil
1063 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1064 due to the bogus appearance that .newsrc was modified on disc.")
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-prepare-exit-hook nil
1079 "*A hook called when preparing to exit from the summary buffer.
1080 It calls `gnus-summary-expire-articles' by default.")
1081 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1083 (defun gnus-summary-exit-hook nil
1084 "*A hook called on exit from the summary buffer.")
1086 (defvar gnus-open-server-hook nil
1087 "*A hook called just before opening connection to the news server.")
1089 (defvar gnus-startup-hook nil
1090 "*A hook called at startup.
1091 This hook is called after Gnus is connected to the NNTP server.")
1093 (defvar gnus-get-new-news-hook nil
1094 "*A hook run just before Gnus checks for new news.")
1096 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1097 "*A function that is called to generate the group buffer.
1098 The function is called with three arguments: The first is a number;
1099 all group with a level less or equal to that number should be listed,
1100 if the second is non-nil, empty groups should also be displayed. If
1101 the third is non-nil, it is a number. No groups with a level lower
1102 than this number should be displayed.
1104 The only current function implemented is `gnus-group-prepare-flat'.")
1106 (defvar gnus-group-prepare-hook nil
1107 "*A hook called after the group buffer has been generated.
1108 If you want to modify the group buffer, you can use this hook.")
1110 (defvar gnus-summary-prepare-hook nil
1111 "*A hook called after the summary buffer has been generated.
1112 If you want to modify the summary buffer, you can use this hook.")
1114 (defvar gnus-article-prepare-hook nil
1115 "*A hook called after an article has been prepared in the article buffer.
1116 If you want to run a special decoding program like nkf, use this hook.")
1118 ;(defvar gnus-article-display-hook nil
1119 ; "*A hook called after the article is displayed in the article buffer.
1120 ;The hook is designed to change the contents of the article
1121 ;buffer. Typical functions that this hook may contain are
1122 ;`gnus-article-hide-headers' (hide selected headers),
1123 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1124 ;`gnus-article-hide-signature' (hide signature) and
1125 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1126 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1127 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1128 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1130 (defvar gnus-article-x-face-command
1131 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1132 "String or function to be executed to display an X-Face header.
1133 If it is a string, the command will be executed in a sub-shell
1134 asynchronously. The compressed face will be piped to this command.")
1136 (defvar gnus-article-x-face-too-ugly nil
1137 "Regexp matching posters whose face shouldn't be shown automatically.")
1139 (defvar gnus-select-group-hook nil
1140 "*A hook called when a newsgroup is selected.
1142 If you'd like to simplify subjects like the
1143 `gnus-summary-next-same-subject' command does, you can use the
1146 (setq gnus-select-group-hook
1149 (mapcar (lambda (header)
1152 (gnus-simplify-subject
1153 (header-subject header) 're-only)))
1154 gnus-newsgroup-headers))))")
1156 (defvar gnus-select-article-hook
1157 '(gnus-summary-show-thread)
1158 "*A hook called when an article is selected.
1159 The default hook shows conversation thread subtrees of the selected
1160 article automatically using `gnus-summary-show-thread'.")
1162 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1163 "*A hook called to apply kill files to a group.
1164 This hook is intended to apply a kill file to the selected newsgroup.
1165 The function `gnus-apply-kill-file' is called by default.
1167 Since a general kill file is too heavy to use only for a few
1168 newsgroups, I recommend you to use a lighter hook function. For
1169 example, if you'd like to apply a kill file to articles which contains
1170 a string `rmgroup' in subject in newsgroup `control', you can use the
1173 (setq gnus-apply-kill-hook
1176 (cond ((string-match \"control\" gnus-newsgroup-name)
1177 (gnus-kill \"Subject\" \"rmgroup\")
1178 (gnus-expunge \"X\"))))))")
1180 (defvar gnus-visual-mark-article-hook
1181 (list 'gnus-highlight-selected-summary)
1182 "*Hook run after selecting an article in the summary buffer.
1183 It is meant to be used for highlighting the article in some way. It
1184 is not run if `gnus-visual' is nil.")
1186 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1187 "*A hook called after preparing body, but before preparing header headers.
1188 The default hook (`gnus-inews-insert-signature') inserts a signature
1189 file specified by the variable `gnus-signature-file'.")
1191 (defvar gnus-exit-group-hook nil
1192 "*A hook called when exiting (not quitting) summary mode.")
1194 (defvar gnus-suspend-gnus-hook nil
1195 "*A hook called when suspending (not exiting) Gnus.")
1197 (defvar gnus-exit-gnus-hook nil
1198 "*A hook called when exiting Gnus.")
1200 (defvar gnus-save-newsrc-hook nil
1201 "*A hook called when saving the newsrc file.")
1203 (defvar gnus-summary-update-hook
1204 (list 'gnus-summary-highlight-line)
1205 "*A hook called when a summary line is changed.
1206 The hook will not be called if `gnus-visual' is nil.
1208 The default function `gnus-summary-highlight-line' will
1209 highlight the line according to the `gnus-summary-highlight'
1212 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1213 "*A hook called when an article is selected for the first time.
1214 The hook is intended to mark an article as read (or unread)
1215 automatically when it is selected.")
1217 ;; Remove any hilit infestation.
1218 (add-hook 'gnus-startup-hook
1220 (remove-hook 'gnus-summary-prepare-hook
1221 'hilit-rehighlight-buffer-quietly)
1222 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1223 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1224 (remove-hook 'gnus-article-prepare-hook
1225 'hilit-rehighlight-buffer-quietly)))
1229 ;; Internal variables
1231 ;; Avoid highlighting in kill files.
1232 (defvar gnus-summary-inhibit-highlight nil)
1233 (defvar gnus-newsgroup-selected-overlay nil)
1235 (defvar gnus-article-mode-map nil)
1236 (defvar gnus-dribble-buffer nil)
1237 (defvar gnus-headers-retrieved-by nil)
1238 (defvar gnus-article-reply nil)
1239 (defvar gnus-override-method nil)
1240 (defvar gnus-article-check-size nil)
1242 (defvar gnus-current-score-file nil)
1243 (defvar gnus-internal-global-score-files nil)
1244 (defvar gnus-score-file-list nil)
1247 (defvar gnus-current-move-group nil)
1249 (defvar gnus-newsgroup-dependencies nil)
1250 (defvar gnus-newsgroup-threads nil)
1251 (defvar gnus-newsgroup-async nil)
1252 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1254 (defvar gnus-newsgroup-adaptive nil)
1256 (defvar gnus-summary-display-table nil)
1258 (defconst gnus-group-line-format-alist
1259 (list (list ?M 'marked ?c)
1260 (list ?S 'subscribed ?c)
1262 (list ?N 'number ?s)
1263 (list ?I 'number-of-dormant ?d)
1264 (list ?T 'number-of-ticked ?d)
1265 (list ?R 'number-of-read ?s)
1266 (list ?t 'number-total ?d)
1267 (list ?y 'number-of-unread-unticked ?s)
1268 (list ?i 'number-of-ticked-and-dormant ?d)
1270 (list ?G 'qualified-group ?s)
1271 (list ?D 'newsgroup-description ?s)
1272 (list ?o 'moderated ?c)
1273 (list ?O 'moderated-string ?s)
1274 (list ?p 'process-marked ?c)
1275 (list ?s 'news-server ?s)
1276 (list ?n 'news-method ?s)
1277 (list ?z 'news-method-string ?s)
1278 (list ?u 'user-defined ?s)))
1280 (defconst gnus-summary-line-format-alist
1281 (list (list ?N 'number ?d)
1282 (list ?S 'subject ?s)
1283 (list ?s 'subject-or-nil ?s)
1285 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1287 (list ?a '(or (car (funcall gnus-extract-address-components from))
1290 (list ?x (macroexpand '(header-xref header)) ?s)
1291 (list ?D (macroexpand '(header-date header)) ?s)
1292 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1293 (list ?M (macroexpand '(header-id header)) ?s)
1294 (list ?r (macroexpand '(header-references header)) ?s)
1295 (list ?c '(or (header-chars header) 0) ?d)
1297 (list ?I 'indentation ?s)
1298 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1299 (list ?R 'replied ?c)
1300 (list ?\[ 'opening-bracket ?c)
1301 (list ?\] 'closing-bracket ?c)
1302 (list ?\> '(make-string level ? ) ?s)
1303 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1305 (list ?z 'score-char ?c)
1306 (list ?U 'unread ?c)
1307 (list ?t '(gnus-summary-number-of-articles-in-thread
1308 (and (boundp 'thread) (car thread)))
1310 (list ?e '(gnus-summary-number-of-articles-in-thread
1311 (and (boundp 'thread) (car thread)) t)
1313 (list ?u 'user-defined ?s))
1314 "An alist of format specifications that can appear in summary lines,
1315 and what variables they correspond with, along with the type of the
1316 variable (string, integer, character, etc).")
1318 (defconst gnus-summary-dummy-line-format-alist
1319 (list (list ?S 'subject ?s)
1320 (list ?N 'number ?d)
1321 (list ?u 'user-defined ?s)))
1323 (defconst gnus-summary-mode-line-format-alist
1324 (list (list ?G 'group-name ?s)
1325 (list ?g '(gnus-short-group-name group-name) ?s)
1326 (list ?A 'article-number ?d)
1327 (list ?Z 'unread-and-unselected ?s)
1328 (list ?V 'gnus-version ?s)
1329 (list ?U 'unread ?d)
1330 (list ?S 'subject ?s)
1331 (list ?e 'unselected ?d)
1332 (list ?u 'user-defined ?s)
1333 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1335 (defconst gnus-group-mode-line-format-alist
1336 (list (list ?S 'news-server ?s)
1337 (list ?M 'news-method ?s)
1338 (list ?u 'user-defined ?s)))
1340 (defvar gnus-have-read-active-file nil)
1342 (defconst gnus-maintainer
1343 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1344 "The mail address of the Gnus maintainers.")
1346 (defconst gnus-version "(ding) Gnus v0.99.22"
1347 "Version number for this version of Gnus.")
1349 (defvar gnus-info-nodes
1350 '((gnus-group-mode "(gnus)The Group Buffer")
1351 (gnus-summary-mode "(gnus)The Summary Buffer")
1352 (gnus-article-mode "(gnus)The Article Buffer"))
1353 "Assoc list of major modes and related Info nodes.")
1355 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1356 "The location of the Gnus documentation group.")
1358 (defvar gnus-group-buffer "*Group*")
1359 (defvar gnus-summary-buffer "*Summary*")
1360 (defvar gnus-article-buffer "*Article*")
1361 (defvar gnus-server-buffer "*Server*")
1363 (defvar gnus-work-buffer " *gnus work*")
1365 (defvar gnus-buffer-list nil
1366 "Gnus buffers that should be killed on exit.")
1368 (defvar gnus-server-alist nil
1369 "List of available servers.")
1371 (defvar gnus-variable-list
1372 '(gnus-newsrc-options gnus-newsrc-options-n
1373 gnus-newsrc-last-checked-date
1374 gnus-newsrc-alist gnus-server-alist
1375 gnus-killed-list gnus-zombie-list)
1376 "Gnus variables saved in the quick startup file.")
1378 (defvar gnus-overload-functions
1379 '((news-inews gnus-inews-news "rnewspost"))
1380 "Functions overloaded by gnus.
1381 It is a list of `(original overload &optional file)'.")
1383 (defvar gnus-newsrc-options nil
1384 "Options line in the .newsrc file.")
1386 (defvar gnus-newsrc-options-n nil
1387 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1389 (defvar gnus-newsrc-last-checked-date nil
1390 "Date Gnus last asked server for new newsgroups.")
1392 (defvar gnus-newsrc-alist nil
1393 "Assoc list of read articles.
1394 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1396 (defvar gnus-newsrc-hashtb nil
1397 "Hashtable of gnus-newsrc-alist.")
1399 (defvar gnus-killed-list nil
1400 "List of killed newsgroups.")
1402 (defvar gnus-killed-hashtb nil
1403 "Hash table equivalent of gnus-killed-list.")
1405 (defvar gnus-zombie-list nil
1406 "List of almost dead newsgroups.")
1408 (defvar gnus-description-hashtb nil
1409 "Descriptions of newsgroups.")
1411 (defvar gnus-list-of-killed-groups nil
1412 "List of newsgroups that have recently been killed by the user.")
1414 (defvar gnus-active-hashtb nil
1415 "Hashtable of active articles.")
1417 (defvar gnus-moderated-list nil
1418 "List of moderated newsgroups.")
1420 (defvar gnus-group-marked nil)
1422 (defvar gnus-current-startup-file nil
1423 "Startup file for the current host.")
1425 (defvar gnus-last-search-regexp nil
1426 "Default regexp for article search command.")
1428 (defvar gnus-last-shell-command nil
1429 "Default shell command on article.")
1431 (defvar gnus-current-select-method nil
1432 "The current method for selecting a newsgroup.")
1434 (defvar gnus-group-list-mode nil)
1436 (defvar gnus-article-internal-prepare-hook nil)
1438 (defvar gnus-newsgroup-name nil)
1439 (defvar gnus-newsgroup-begin nil)
1440 (defvar gnus-newsgroup-end nil)
1441 (defvar gnus-newsgroup-last-rmail nil)
1442 (defvar gnus-newsgroup-last-mail nil)
1443 (defvar gnus-newsgroup-last-folder nil)
1444 (defvar gnus-newsgroup-last-file nil)
1445 (defvar gnus-newsgroup-auto-expire nil)
1446 (defvar gnus-newsgroup-active nil)
1448 (defvar gnus-newsgroup-unreads nil
1449 "List of unread articles in the current newsgroup.")
1451 (defvar gnus-newsgroup-unselected nil
1452 "List of unselected unread articles in the current newsgroup.")
1454 (defvar gnus-newsgroup-reads nil
1455 "Alist of read articles and article marks in the current newsgroup.")
1457 (defvar gnus-newsgroup-marked nil
1458 "List of ticked articles in the current newsgroup (a subset of unread art).")
1460 (defvar gnus-newsgroup-killed nil
1461 "List of ranges of articles that have been through the scoring process.")
1463 (defvar gnus-newsgroup-kill-headers nil)
1465 (defvar gnus-newsgroup-replied nil
1466 "List of articles that have been replied to in the current newsgroup.")
1468 (defvar gnus-newsgroup-expirable nil
1469 "List of articles in the current newsgroup that can be expired.")
1471 (defvar gnus-newsgroup-processable nil
1472 "List of articles in the current newsgroup that can be processed.")
1474 (defvar gnus-newsgroup-bookmarks nil
1475 "List of articles in the current newsgroup that have bookmarks.")
1477 (defvar gnus-newsgroup-dormant nil
1478 "List of dormant articles in the current newsgroup.")
1480 (defvar gnus-newsgroup-scored nil
1481 "List of scored articles in the current newsgroup.")
1483 (defvar gnus-newsgroup-headers nil
1484 "List of article headers in the current newsgroup.")
1485 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1487 (defvar gnus-newsgroup-ancient nil
1488 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1490 (defvar gnus-current-article nil)
1491 (defvar gnus-article-current nil)
1492 (defvar gnus-current-headers nil)
1493 (defvar gnus-have-all-headers nil)
1494 (defvar gnus-last-article nil)
1495 (defvar gnus-newsgroup-history nil)
1496 (defvar gnus-current-kill-article nil)
1498 ;; Save window configuration.
1499 (defvar gnus-prev-winconf nil)
1502 (defvar gnus-summary-line-format-spec nil)
1503 (defvar gnus-summary-dummy-line-format-spec nil)
1504 (defvar gnus-group-line-format-spec nil)
1505 (defvar gnus-summary-mode-line-format-spec nil)
1506 (defvar gnus-article-mode-line-format-spec nil)
1507 (defvar gnus-group-mode-line-format-spec nil)
1508 (defvar gnus-summary-mark-positions nil)
1509 (defvar gnus-group-mark-positions nil)
1511 (defvar gnus-summary-expunge-below nil)
1512 (defvar gnus-reffed-article-number nil)
1514 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1515 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1517 (defvar gnus-cache-removeable-articles nil)
1519 (defconst gnus-summary-local-variables
1520 '(gnus-newsgroup-name
1521 gnus-newsgroup-begin gnus-newsgroup-end
1522 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1523 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1524 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1525 gnus-newsgroup-unselected gnus-newsgroup-marked
1526 gnus-newsgroup-reads
1527 gnus-newsgroup-replied gnus-newsgroup-expirable
1528 gnus-newsgroup-processable gnus-newsgroup-killed
1529 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1530 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1531 gnus-current-article gnus-current-headers gnus-have-all-headers
1532 gnus-last-article gnus-article-internal-prepare-hook
1533 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1534 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1535 gnus-newsgroup-threads gnus-newsgroup-async
1536 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1537 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1538 gnus-newsgroup-history gnus-newsgroup-ancient
1539 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1540 gnus-cache-removeable-articles)
1541 "Variables that are buffer-local to the summary buffers.")
1543 (defconst gnus-bug-message
1544 "Sending a bug report to the Gnus Towers.
1545 ========================================
1547 The buffer below is a mail buffer. When you press `C-c C-c', it will
1548 be sent to the Gnus Bug Exterminators.
1550 At the bottom of the buffer you'll see lots of variable settings.
1551 Please do not delete those. They will tell the Bug People what your
1552 environment is, so that it will be easier to locate the bugs.
1554 If you have found a bug that makes Emacs go \"beep\", set
1555 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1556 and include the backtrace in your bug report.
1558 Please describe the bug in annoying, painstaking detail.
1560 Thank you for your help in stamping out bugs.
1563 ;;; End of variables.
1565 ;; Define some autoload functions Gnus might use.
1569 (autoload 'metamail-buffer "metamail")
1570 (autoload 'Info-goto-node "info")
1571 (autoload 'hexl-hex-string-to-integer "hexl")
1573 (autoload 'pp-to-string "pp")
1574 (autoload 'pp-eval-expression "pp")
1575 (autoload 'mail-extract-address-components "mail-extr")
1577 (autoload 'nnmail-split-fancy "nnmail")
1578 (autoload 'nnvirtual-catchup-group "nnvirtual")
1581 (autoload 'timezone-make-date-arpa-standard "timezone")
1582 (autoload 'timezone-fix-time "timezone")
1583 (autoload 'timezone-make-sortable-date "timezone")
1584 (autoload 'timezone-make-time-string "timezone")
1587 (autoload 'mail-position-on-field "sendmail")
1588 (autoload 'mail-setup "sendmail")
1589 (autoload 'rmail-output "rmailout")
1590 (autoload 'news-mail-other-window "rnewspost")
1591 (autoload 'news-reply-yank-original "rnewspost")
1592 (autoload 'news-caesar-buffer-body "rnewspost")
1593 (autoload 'rmail-insert-rmail-file-header "rmail")
1594 (autoload 'rmail-count-new-messages "rmail")
1595 (autoload 'rmail-show-message "rmail")
1598 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1599 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1600 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1601 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1602 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1603 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1604 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1607 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1608 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1609 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1610 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1611 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1612 (autoload 'gnus-Folder-save-name "gnus-mh")
1613 (autoload 'gnus-folder-save-name "gnus-mh")
1616 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1617 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1618 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1619 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1620 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1621 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1622 (autoload 'gnus-summary-highlight-line "gnus-vis")
1623 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1626 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1627 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1628 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1629 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1630 (autoload 'gnus-article-hide "gnus-vis" nil t)
1631 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1632 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1633 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1634 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1635 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1636 (autoload 'gnus-article-add-button "gnus-vis")
1639 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1640 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1641 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1644 (autoload 'gnus-kill "gnus-kill")
1645 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1646 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1647 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1648 (autoload 'gnus-execute "gnus-kill")
1649 (autoload 'gnus-expunge "gnus-kill")
1652 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1653 (autoload 'gnus-cache-save-buffers "gnus-cache")
1654 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1655 (autoload 'gnus-cache-request-article "gnus-cache")
1656 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1657 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1658 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1659 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1662 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1663 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1664 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1665 (autoload 'gnus-score-save "gnus-score")
1666 (autoload 'gnus-score-headers "gnus-score")
1667 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1668 (autoload 'gnus-score-adaptive "gnus-score")
1669 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1670 (autoload 'gnus-score-find-trace "gnus-score")
1673 (autoload 'gnus-score-customize "gnus-edit" nil t)
1676 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1677 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1678 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1679 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1680 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1681 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1682 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1683 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1684 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1685 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1686 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1687 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1688 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1689 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1690 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1691 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1692 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1693 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1694 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1695 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1696 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1697 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1700 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1701 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1702 (autoload 'gnus-group-mail "gnus-msg" nil t)
1703 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1704 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1705 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1706 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1707 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1708 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1709 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1710 (autoload 'gnus-post-news "gnus-msg" nil t)
1711 (autoload 'gnus-inews-news "gnus-msg" nil t)
1712 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1713 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1714 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1715 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1716 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1717 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1718 (autoload 'gnus-mail-yank-original "gnus-msg")
1719 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1720 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1721 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1722 (autoload 'gnus-article-mail-with-original "gnus-msg")
1723 (autoload 'gnus-article-mail "gnus-msg")
1724 (autoload 'gnus-bug "gnus-msg" nil t)
1727 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1728 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1729 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1730 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1731 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1732 (autoload 'gnus-yank-article "gnus-vm" nil t)
1738 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1739 ;; If you want the cursor to go somewhere else, set these two
1740 ;; functions in some startup hook to whatever you want.
1741 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1742 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1744 ;;; Various macros and substs.
1746 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1747 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1748 (` (let ((GnusStartBufferWindow (selected-window)))
1751 (pop-to-buffer (, buffer))
1753 (select-window GnusStartBufferWindow)))))
1755 (defmacro gnus-gethash (string hashtable)
1756 "Get hash value of STRING in HASHTABLE."
1757 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1758 ;;(` (abbrev-expansion (, string) (, hashtable)))
1759 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1761 (defmacro gnus-sethash (string value hashtable)
1762 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1763 ;; We cannot use define-abbrev since it only accepts string as value.
1764 ;; (set (intern string hashtable) value))
1765 (` (set (intern (, string) (, hashtable)) (, value))))
1767 (defsubst gnus-buffer-substring (beg end)
1768 (buffer-substring (match-beginning beg) (match-end end)))
1770 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1771 ;; function `substring' might cut on a middle of multi-octet
1773 (defun gnus-truncate-string (str width)
1774 (substring str 0 width))
1776 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1777 ;; to limit the length of a string. This function is necessary since
1778 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1779 (defsubst gnus-limit-string (str width)
1780 (if (> (length str) width)
1781 (substring str 0 width)
1784 (defsubst gnus-simplify-subject-re (subject)
1785 "Remove \"Re:\" from subject lines."
1786 (let ((case-fold-search t))
1787 (if (string-match "^re: *" subject)
1788 (substring subject (match-end 0))
1791 (defsubst gnus-goto-char (point)
1792 (and point (goto-char point)))
1794 (defmacro gnus-buffer-exists-p (buffer)
1796 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1799 (defmacro gnus-kill-buffer (buffer)
1800 (` (if (gnus-buffer-exists-p (, buffer))
1801 (kill-buffer (, buffer)))))
1803 (defsubst gnus-point-at-bol ()
1804 "Return point at the beginning of line."
1811 (defsubst gnus-point-at-eol ()
1812 "Return point at the beginning of line."
1819 ;; Delete the current line (and the next N lines.);
1820 (defmacro gnus-delete-line (&optional n)
1821 (` (delete-region (progn (beginning-of-line) (point))
1822 (progn (forward-line (, (or n 1))) (point)))))
1824 ;;; Load the compatability functions.
1831 ;;; Gnus Utility Functions
1834 (defun gnus-extract-address-components (from)
1836 ;; First find the address - the thing with the @ in it. This may
1837 ;; not be accurate in mail addresses, but does the trick most of
1838 ;; the time in news messages.
1839 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1840 (setq address (substring from (match-beginning 0) (match-end 0))))
1841 ;; Then we check whether the "name <address>" format is used.
1843 (string-match (concat "<" (regexp-quote address) ">") from)
1844 (and (setq name (substring from 0 (1- (match-beginning 0))))
1845 ;; Strip any quotes from the name.
1846 (string-match "\".*\"" name)
1847 (setq name (substring name 1 (1- (match-end 0))))))
1848 ;; If not, then "address (name)" is used.
1850 (and (string-match "(.+)" from)
1851 (setq name (substring from (1+ (match-beginning 0))
1852 (1- (match-end 0)))))
1853 (and (string-match "()" from)
1854 (setq name address))
1855 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1856 ;; XOVER might not support folded From headers.
1857 (and (string-match "(.*" from)
1858 (setq name (substring from (1+ (match-beginning 0))
1860 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1861 (list (or name from) (or address from))))
1863 (defun gnus-fetch-field (field)
1864 "Return the value of the header FIELD of current article."
1867 (let ((case-fold-search t))
1868 (gnus-narrow-to-headers)
1869 (mail-fetch-field field)))))
1871 (defun gnus-goto-colon ()
1873 (search-forward ":" (gnus-point-at-eol) t))
1875 (defun gnus-narrow-to-headers ()
1879 (goto-char (point-min))
1880 (if (search-forward "\n\n" nil t)
1884 (defvar gnus-old-specs nil)
1886 (defun gnus-update-format-specifications ()
1887 (gnus-make-thread-indent-array)
1889 (let ((formats '(summary summary-dummy group
1890 summary-mode group-mode article-mode))
1891 old-format new-format)
1893 (setq new-format (symbol-value
1894 (intern (format "gnus-%s-line-format" (car formats)))))
1895 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1896 (equal old-format new-format))
1897 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1901 (intern (format "gnus-%s-line-format-alist"
1902 (if (eq (car formats) 'article-mode)
1903 'summary-mode (car formats))))))))
1904 (setq gnus-old-specs (cons (cons (car formats) new-format)
1905 (delq (car formats) gnus-old-specs)))
1906 (setq formats (cdr formats))))
1908 (gnus-update-group-mark-positions)
1909 (gnus-update-summary-mark-positions)
1911 (if (and (string-match "%D" gnus-group-line-format)
1912 (not gnus-description-hashtb)
1913 gnus-read-active-file)
1914 (gnus-read-all-descriptions-files)))
1916 (defun gnus-update-summary-mark-positions ()
1918 (let ((gnus-replied-mark 129)
1919 (gnus-score-below-mark 130)
1920 (gnus-score-over-mark 130)
1923 (gnus-set-work-buffer)
1924 (gnus-summary-insert-line
1925 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1926 (goto-char (point-min))
1927 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1929 (goto-char (point-min))
1930 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1931 (- (point) 2))) pos))
1932 (goto-char (point-min))
1933 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1934 (- (point) 2))) pos))
1935 (setq gnus-summary-mark-positions pos))))
1937 (defun gnus-update-group-mark-positions ()
1939 (let ((gnus-process-mark 128)
1940 (gnus-group-marked '("dummy.group")))
1941 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
1942 (gnus-set-work-buffer)
1943 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1944 (goto-char (point-min))
1945 (setq gnus-group-mark-positions
1946 (list (cons 'process (and (search-forward "\200" nil t)
1947 (- (point) 2))))))))
1949 (defun gnus-mouse-face-function (form)
1950 (` (let ((string (, form)))
1951 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1954 (defun gnus-max-width-function (el max-width)
1955 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1956 (` (let* ((val (eval (, el)))
1957 (valstr (if (numberp val)
1958 (int-to-string val) val)))
1959 (if (> (length valstr) (, max-width))
1960 (substring valstr 0 (, max-width))
1963 (defun gnus-parse-format (format spec-alist)
1964 ;; This function parses the FORMAT string with the help of the
1965 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1966 ;; string. If the FORMAT string contains the specifiers %( and %)
1967 ;; the text between them will have the mouse-face text property.
1968 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1969 (if (and gnus-visual gnus-mouse-face)
1970 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1971 (button (substring format (match-beginning 2) (match-end 2)))
1972 (post (substring format (match-beginning 3) (match-end 3))))
1974 (gnus-parse-simple-format pre spec-alist)
1975 (gnus-mouse-face-function
1976 (gnus-parse-simple-format button spec-alist))
1977 (gnus-parse-simple-format post spec-alist)))
1978 (gnus-parse-simple-format
1979 (concat (substring format (match-beginning 1) (match-end 1))
1980 (substring format (match-beginning 2) (match-end 2))
1981 (substring format (match-beginning 3) (match-end 3)))
1983 (gnus-parse-simple-format format spec-alist)))
1985 (defun gnus-parse-simple-format (format spec-alist)
1986 ;; This function parses the FORMAT string with the help of the
1987 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1988 ;; string. The list will consist of the symbol `format', a format
1989 ;; specification string, and a list of forms depending on the
1992 spec flist fstring newspec elem beg)
1994 (gnus-set-work-buffer)
1996 (goto-char (point-min))
1997 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1998 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2000 ;; First check if there are any specs that look anything like
2001 ;; "%12,12A", ie. with a "max width specification". These have
2002 ;; to be treated specially.
2003 (if (setq beg (match-beginning 1))
2006 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2008 (setq beg (match-beginning 2)))
2009 ;; Find the specification from `spec-alist'.
2010 (if (not (setq elem (cdr (assq spec spec-alist))))
2011 (setq elem '("*" ?s)))
2012 ;; Treat user defined format specifiers specially
2013 (and (eq (car elem) 'user-defined)
2016 (list (intern (concat "gnus-user-format-function-"
2022 (delete-region (match-beginning 3) (match-end 3)))
2023 (if (not (zerop max-width))
2024 (let ((el (car elem)))
2025 (cond ((= (car (cdr elem)) ?c)
2026 (setq el (list 'char-to-string el)))
2027 ((= (car (cdr elem)) ?d)
2028 (numberp el) (setq el (list 'int-to-string el))))
2029 (setq flist (cons (gnus-max-width-function el max-width)
2032 (setq flist (cons (car elem) flist))
2033 (setq newspec (car (cdr elem))))
2034 ;; Remove the old specification (and possibly a ",12" string).
2035 (delete-region beg (match-end 2))
2036 ;; Insert the new specification.
2039 (setq fstring (buffer-substring 1 (point-max))))
2040 (cons 'format (cons fstring (nreverse flist)))))
2042 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2043 (defun gnus-read-init-file ()
2045 (or (and (file-exists-p gnus-init-file)
2046 ;; Don't try to load a directory.
2047 (not (file-directory-p gnus-init-file)))
2048 (file-exists-p (concat gnus-init-file ".el"))
2049 (file-exists-p (concat gnus-init-file ".elc")))
2050 (load gnus-init-file nil t)))
2052 (defun gnus-set-work-buffer ()
2053 (if (get-buffer gnus-work-buffer)
2055 (set-buffer gnus-work-buffer)
2057 (set-buffer (get-buffer-create gnus-work-buffer))
2058 (kill-all-local-variables)
2059 (buffer-disable-undo (current-buffer))
2060 (gnus-add-current-to-buffer-list)))
2062 ;; Article file names when saving.
2064 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2065 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2066 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2067 Otherwise, it is like ~/News/news/group/num."
2070 (concat (if (gnus-use-long-file-name 'not-save)
2071 (gnus-capitalize-newsgroup newsgroup)
2072 (gnus-newsgroup-directory-form newsgroup))
2073 "/" (int-to-string (header-number headers)))
2074 (or gnus-article-save-directory "~/News"))))
2076 (string-equal (file-name-directory default)
2077 (file-name-directory last-file))
2078 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2080 (or last-file default))))
2082 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2083 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2084 If variable `gnus-use-long-file-name' is non-nil, it is
2085 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2088 (concat (if (gnus-use-long-file-name 'not-save)
2090 (gnus-newsgroup-directory-form newsgroup))
2091 "/" (int-to-string (header-number headers)))
2092 (or gnus-article-save-directory "~/News"))))
2094 (string-equal (file-name-directory default)
2095 (file-name-directory last-file))
2096 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2098 (or last-file default))))
2100 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2101 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2102 If variable `gnus-use-long-file-name' is non-nil, it is
2103 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2106 (if (gnus-use-long-file-name 'not-save)
2107 (gnus-capitalize-newsgroup newsgroup)
2108 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2109 (or gnus-article-save-directory "~/News"))))
2111 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2112 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2113 If variable `gnus-use-long-file-name' is non-nil, it is
2114 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2117 (if (gnus-use-long-file-name 'not-save)
2119 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2120 (or gnus-article-save-directory "~/News"))))
2122 ;; For subscribing new newsgroup
2124 (defun gnus-subscribe-hierarchical-interactive (groups)
2125 (let ((groups (sort groups 'string<))
2126 prefixes prefix start ans group starts)
2128 (setq prefixes (list "^"))
2129 (while (and groups prefixes)
2130 (while (not (string-match (car prefixes) (car groups)))
2131 (setq prefixes (cdr prefixes)))
2132 (setq prefix (car prefixes))
2133 (setq start (1- (length prefix)))
2134 (if (and (string-match "[^\\.]\\." (car groups) start)
2137 (concat "^" (substring (car groups) 0 (match-end 0))))
2138 (string-match prefix (car (cdr groups))))
2140 (setq prefixes (cons prefix prefixes))
2141 (message "Descend hierarchy %s? ([y]nsq): "
2142 (substring prefix 1 (1- (length prefix))))
2143 (setq ans (read-char))
2146 (string-match prefix
2147 (setq group (car groups))))
2148 (setq gnus-killed-list
2149 (cons group gnus-killed-list))
2150 (gnus-sethash group group gnus-killed-hashtb)
2151 (setq groups (cdr groups)))
2152 (setq starts (cdr starts)))
2155 (string-match prefix
2156 (setq group (car groups))))
2157 (gnus-sethash group group gnus-killed-hashtb)
2158 (gnus-subscribe-alphabetically (car groups))
2159 (setq groups (cdr groups)))
2160 (setq starts (cdr starts)))
2163 (setq group (car groups))
2164 (setq gnus-killed-list (cons group gnus-killed-list))
2165 (gnus-sethash group group gnus-killed-hashtb)
2166 (setq groups (cdr groups))))
2168 (message "Subscribe %s? ([n]yq)" (car groups))
2169 (setq ans (read-char))
2170 (setq group (car groups))
2172 (gnus-subscribe-alphabetically (car groups))
2173 (gnus-sethash group group gnus-killed-hashtb))
2176 (setq group (car groups))
2177 (setq gnus-killed-list (cons group gnus-killed-list))
2178 (gnus-sethash group group gnus-killed-hashtb)
2179 (setq groups (cdr groups))))
2181 (setq gnus-killed-list (cons group gnus-killed-list))
2182 (gnus-sethash group group gnus-killed-hashtb)))
2183 (setq groups (cdr groups)))))))
2185 (defun gnus-subscribe-randomly (newsgroup)
2186 "Subscribe new NEWSGROUP by making it the first newsgroup."
2187 (gnus-subscribe-newsgroup newsgroup))
2189 (defun gnus-subscribe-alphabetically (newgroup)
2190 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2191 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2192 (let ((groups (cdr gnus-newsrc-alist))
2194 (while (and (not before) groups)
2195 (if (string< newgroup (car (car groups)))
2196 (setq before (car (car groups)))
2197 (setq groups (cdr groups))))
2198 (gnus-subscribe-newsgroup newgroup before)))
2200 (defun gnus-subscribe-hierarchically (newgroup)
2201 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2202 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2204 (set-buffer (find-file-noselect gnus-current-startup-file))
2205 (let ((groupkey newgroup)
2207 (while (and (not before) groupkey)
2208 (goto-char (point-min))
2210 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2211 (while (and (re-search-forward groupkey-re nil t)
2213 (setq before (buffer-substring
2214 (match-beginning 1) (match-end 1)))
2215 (string< before newgroup)))))
2216 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2218 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2219 (substring groupkey (match-beginning 1) (match-end 1)))))
2220 (gnus-subscribe-newsgroup newgroup before))))
2222 (defun gnus-subscribe-interactively (newsgroup)
2223 "Subscribe new NEWSGROUP interactively.
2224 It is inserted in hierarchical newsgroup order if subscribed. If not,
2226 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2227 (gnus-subscribe-hierarchically newsgroup)
2228 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2230 (defun gnus-subscribe-zombies (newsgroup)
2231 "Make new NEWSGROUP a zombie group."
2232 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2234 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2235 "Subscribe new NEWSGROUP.
2236 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2237 the first newsgroup."
2238 ;; We subscribe the group by changing its level to `subscribed'.
2239 (gnus-group-change-level
2240 newsgroup gnus-level-default-subscribed
2241 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2242 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2246 (defun gnus-newsgroup-directory-form (newsgroup)
2247 "Make hierarchical directory name from NEWSGROUP name."
2248 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2249 (len (length newsgroup))
2251 ;; If this is a foreign group, we don't want to translate the
2253 (if (setq idx (string-match ":" newsgroup))
2254 (aset newsgroup idx ?/)
2256 ;; Replace all occurrences of `.' with `/'.
2258 (if (= (aref newsgroup idx) ?.)
2259 (aset newsgroup idx ?/))
2260 (setq idx (1+ idx)))
2263 (defun gnus-newsgroup-saveable-name (group)
2264 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2266 (gnus-replace-chars-in-string group ?/ ?.))
2268 (defun gnus-make-directory (dir)
2269 "Make DIRECTORY recursively."
2270 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2271 ;; of the many mysteries of the universe.
2272 (let* ((dir (expand-file-name dir default-directory))
2274 (if (string-match "/$" dir)
2275 (setq dir (substring dir 0 (match-beginning 0))))
2276 ;; First go down the path until we find a directory that exists.
2277 (while (not (file-exists-p dir))
2278 (setq dirs (cons dir dirs))
2279 (string-match "/[^/]+$" dir)
2280 (setq dir (substring dir 0 (match-beginning 0))))
2281 ;; Then create all the subdirs.
2282 (while (and dirs (not err))
2284 (make-directory (car dirs))
2285 (error (setq err t)))
2286 (setq dirs (cdr dirs)))
2287 ;; We return whether we were successful or not.
2290 (defun gnus-capitalize-newsgroup (newsgroup)
2291 "Capitalize NEWSGROUP name."
2292 (and (not (zerop (length newsgroup)))
2293 (concat (char-to-string (upcase (aref newsgroup 0)))
2294 (substring newsgroup 1))))
2298 (defun gnus-simplify-subject (subject &optional re-only)
2299 "Remove `Re:' and words in parentheses.
2300 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2301 (let ((case-fold-search t)) ;Ignore case.
2302 ;; Remove `Re:' and `Re^N:'.
2303 (if (string-match "^re:[ \t]*" subject)
2304 (setq subject (substring subject (match-end 0))))
2305 ;; Remove words in parentheses from end.
2307 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2308 (setq subject (substring subject 0 (match-beginning 0)))))
2309 ;; Return subject string.
2312 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2314 (defun gnus-simplify-subject-fuzzy (subject)
2315 (let ((case-fold-search t))
2317 (gnus-set-work-buffer)
2319 (inline (gnus-simplify-buffer-fuzzy))
2322 (defun gnus-simplify-buffer-fuzzy ()
2323 (goto-char (point-min))
2324 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2325 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2327 (replace-match "" t t))
2328 (goto-char (point-min))
2329 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2330 (replace-match "" t t))
2331 (goto-char (point-min))
2332 (while (re-search-forward "[ \t]+" nil t)
2333 (replace-match " " t t))
2334 (goto-char (point-min))
2335 (while (re-search-forward "[ \t]+$" nil t)
2336 (replace-match "" t t))
2337 (goto-char (point-min))
2338 (while (re-search-forward "^[ \t]+" nil t)
2339 (replace-match "" t t))
2340 (if gnus-simplify-subject-fuzzy-regexp
2341 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2342 (replace-match "" t t))))
2344 ;; Add the current buffer to the list of buffers to be killed on exit.
2345 (defun gnus-add-current-to-buffer-list ()
2346 (or (memq (current-buffer) gnus-buffer-list)
2347 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2349 (defun gnus-string> (s1 s2)
2350 (not (or (string< s1 s2)
2353 ;; Functions accessing headers.
2354 ;; Functions are more convenient than macros in some cases.
2356 (defun gnus-header-number (header)
2357 (header-number header))
2359 (defun gnus-header-subject (header)
2360 (header-subject header))
2362 (defun gnus-header-from (header)
2363 (header-from header))
2365 (defun gnus-header-xref (header)
2366 (header-xref header))
2368 (defun gnus-header-lines (header)
2369 (header-lines header))
2371 (defun gnus-header-date (header)
2372 (header-date header))
2374 (defun gnus-header-id (header)
2377 (defun gnus-header-references (header)
2378 (header-references header))
2380 ;;; General various misc type functions.
2382 (defun gnus-clear-system ()
2383 "Clear all variables and buffers."
2384 ;; Clear Gnus variables.
2385 (let ((variables gnus-variable-list))
2387 (set (car variables) nil)
2388 (setq variables (cdr variables))))
2389 ;; Clear other internal variables.
2390 (setq gnus-list-of-killed-groups nil
2391 gnus-have-read-active-file nil
2392 gnus-newsrc-alist nil
2393 gnus-newsrc-hashtb nil
2394 gnus-killed-list nil
2395 gnus-zombie-list nil
2396 gnus-killed-hashtb nil
2397 gnus-active-hashtb nil
2398 gnus-moderated-list nil
2399 gnus-description-hashtb nil
2400 gnus-newsgroup-headers nil
2401 gnus-newsgroup-headers-hashtb-by-number nil
2402 gnus-newsgroup-name nil
2403 gnus-server-alist nil
2404 gnus-current-select-method nil)
2405 ;; Reset any score variables.
2406 (and (boundp 'gnus-score-cache)
2407 (set 'gnus-score-cache nil))
2408 (and (boundp 'gnus-internal-global-score-files)
2409 (set 'gnus-internal-global-score-files nil))
2410 ;; Kill the startup file.
2411 (and gnus-current-startup-file
2412 (get-file-buffer gnus-current-startup-file)
2413 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2414 ;; Save any cache buffers.
2415 (and gnus-use-cache (gnus-cache-save-buffers))
2416 ;; Clear the dribble buffer.
2417 (gnus-dribble-clear)
2418 ;; Kill global KILL file buffer.
2419 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2420 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2421 (gnus-kill-buffer nntp-server-buffer)
2422 ;; Kill Gnus buffers.
2423 (while gnus-buffer-list
2424 (gnus-kill-buffer (car gnus-buffer-list))
2425 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2427 (defun gnus-windows-old-to-new (setting)
2428 (if (symbolp setting)
2430 (cond ((eq setting 'SelectArticle)
2432 ((eq setting 'SelectSubject)
2434 ((eq setting 'SelectNewsgroup)
2437 (if (or (listp setting)
2438 (not (and gnus-window-configuration
2439 (memq setting '(group summary article)))))
2441 (let* ((setting (if (eq setting 'group)
2442 (if (assq 'newsgroup gnus-window-configuration)
2444 'newsgroups) setting))
2445 (elem (car (cdr (assq setting gnus-window-configuration))))
2446 (total (apply '+ elem))
2447 (types '(group summary article))
2448 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2453 (or (zerop (nth i elem))
2455 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2456 (setq out (cons (if (eq pbuf (nth i types))
2457 (vector (nth i types) perc 'point)
2458 (vector (nth i types) perc))
2461 (list (nreverse out)))))
2463 (defun gnus-add-configuration (conf)
2464 (setq gnus-buffer-configuration
2465 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2466 gnus-buffer-configuration))))
2468 (defun gnus-configure-windows (setting &optional force)
2469 (setq setting (gnus-windows-old-to-new setting))
2470 (let ((r (if (symbolp setting)
2471 (cdr (assq setting gnus-buffer-configuration))
2473 (in-buf (current-buffer))
2474 rule val w height hor ohor heights sub jump-buffer
2475 rel total to-buf all-visible)
2476 (or r (error "No such setting: %s" setting))
2478 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2479 ;; All the windows mentioned are already visibe, so we just
2480 ;; put point in the assigned buffer, and do not touch the
2482 (select-window (get-buffer-window all-visible))
2484 ;; Either remove all windows or just remove all Gnus windows.
2485 (if gnus-use-full-window
2486 (delete-other-windows)
2487 (gnus-remove-some-windows)
2488 (switch-to-buffer nntp-server-buffer))
2494 ;; We have to do the (possible) horizontal splitting before the
2496 (if (and (listp (car hor))
2497 (eq (car (car hor)) 'horizontal))
2501 (if (integerp (nth 1 (car hor)))
2503 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2505 (setq hor (cdr hor))))
2507 ;; Go through the rules and eval the elements that are to be
2510 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2512 ;; Expand short buffer name.
2513 (setq w (aref val 0))
2514 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2516 (setq val (apply 'vector (mapcar 'identity val)))
2518 (setq ohor (cons val ohor))))
2519 (setq hor (cdr hor)))
2520 (setq rule (cons (nreverse ohor) rule))
2522 (setq rule (nreverse rule))
2524 ;; We tally the window sizes.
2525 (setq total (window-height))
2527 (setq hor (car rule))
2528 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2529 (setq hor (cdr hor)))
2532 (setq rel (aref (car hor) 1)
2534 (cond ((and (floatp rel) (= 1.0 rel))
2539 (max (floor (* total rel)) 4)))
2541 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2543 (setq heights (nreverse heights)
2546 ;; We then go through these heighs and create windows for them.
2548 (setq height (car heights)
2549 heights (cdr heights))
2551 (setq height (- total sub)))
2553 (split-window nil height))
2554 (setq to-buf (aref (car hor) 0))
2559 (symbol-value (aref (car hor) 0)))
2561 (aref (car hor) 0))))
2562 (and (> (length (car hor)) 2)
2563 (eq (aref (car hor) 2) 'point)
2564 (setq jump-buffer (current-buffer)))
2566 (setq hor (cdr hor)))
2568 (setq rule (cdr rule)))
2570 ;; Finally, we pop to the buffer that's supposed to have point.
2571 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2573 (select-window (get-buffer-window jump-buffer))
2574 (set-buffer jump-buffer))))
2576 (defun gnus-all-windows-visible-p (rule)
2577 (let (invisible hor jump-buffer val buffer)
2578 ;; Go through the rules and eval the elements that are to be
2580 (while (and rule (not invisible))
2581 (setq hor (car rule)
2583 (while (and hor (not invisible))
2584 (if (setq val (if (vectorp (car hor))
2586 (if (not (eq (car (car hor)) 'horizontal))
2589 ;; Expand short buffer name.
2590 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2592 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2594 (and (> (length val) 2) (eq 'point (aref val 2))
2595 (setq jump-buffer buffer))
2596 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2597 (setq hor (cdr hor))))
2598 (and (not invisible) jump-buffer)))
2600 (defun gnus-window-top-edge (&optional window)
2601 (nth 1 (window-edges window)))
2603 (defun gnus-remove-some-windows ()
2604 (let ((buffers gnus-window-to-buffer)
2605 buf bufs lowest-buf lowest)
2607 ;; Remove windows on all known Gnus buffers.
2609 (setq buf (cdr (car buffers)))
2611 (setq buf (and (boundp buf) (symbol-value buf))))
2613 (get-buffer-window buf)
2615 (setq bufs (cons buf bufs))
2617 (if (or (not lowest)
2618 (< (gnus-window-top-edge) lowest))
2620 (setq lowest (gnus-window-top-edge))
2621 (setq lowest-buf buf)))))
2622 (setq buffers (cdr buffers)))
2623 ;; Remove windows on *all* summary buffers.
2627 (let ((buf (window-buffer win)))
2628 (if (string-match "^\\*Summary" (buffer-name buf))
2630 (setq bufs (cons buf bufs))
2632 (if (or (not lowest)
2633 (< (gnus-window-top-edge) lowest))
2635 (setq lowest-buf buf)
2636 (setq lowest (gnus-window-top-edge))))))))))
2639 (pop-to-buffer lowest-buf)
2640 (switch-to-buffer nntp-server-buffer)))
2642 (and (not (eq (car bufs) lowest-buf))
2643 (delete-windows-on (car bufs)))
2644 (setq bufs (cdr bufs))))))
2646 (defun gnus-version ()
2647 "Version numbers of this version of Gnus."
2649 (let ((methods gnus-valid-select-methods)
2652 ;; Go through all the legal select methods and add their version
2653 ;; numbers to the total version string. Only the backends that are
2654 ;; currently in use will have their message numbers taken into
2657 (setq meth (intern (concat (car (car methods)) "-version")))
2659 (stringp (symbol-value meth))
2660 (setq mess (concat mess "; " (symbol-value meth))))
2661 (setq methods (cdr methods)))
2662 (gnus-message 2 mess)))
2664 (defun gnus-info-find-node ()
2665 "Find Info documentation of Gnus."
2667 ;; Enlarge info window if needed.
2668 (let ((mode major-mode))
2669 (gnus-configure-windows 'info)
2670 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2672 (defun gnus-overload-functions (&optional overloads)
2673 "Overload functions specified by optional argument OVERLOADS.
2674 If nothing is specified, use the variable gnus-overload-functions."
2676 (overloads (or overloads gnus-overload-functions)))
2678 (setq defs (car overloads))
2679 (setq overloads (cdr overloads))
2680 ;; Load file before overloading function if necessary. Make
2681 ;; sure we cannot use `require' always.
2682 (and (not (fboundp (car defs)))
2683 (car (cdr (cdr defs)))
2684 (load (car (cdr (cdr defs))) nil 'nomessage))
2685 (fset (car defs) (car (cdr defs))))))
2687 (defun gnus-replace-chars-in-string (string from to)
2688 "Replace characters in STRING from FROM to TO."
2689 (let ((string (substring string 0)) ;Copy string.
2690 (len (length string))
2692 ;; Replace all occurrences of FROM with TO.
2694 (if (= (aref string idx) from)
2695 (aset string idx to))
2696 (setq idx (1+ idx)))
2699 (defun gnus-days-between (date1 date2)
2700 ;; Return the number of days between date1 and date2.
2701 (- (gnus-day-number date1) (gnus-day-number date2)))
2703 (defun gnus-day-number (date)
2704 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2705 (timezone-parse-date date))))
2706 (timezone-absolute-from-gregorian
2707 (nth 1 dat) (nth 2 dat) (car dat))))
2709 ;; Returns a floating point number that says how many seconds have
2710 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2711 (defun gnus-seconds-since-epoch (date)
2712 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2713 (timezone-parse-date date)))
2714 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2715 (timezone-parse-time
2716 (aref (timezone-parse-date date) 3))))
2717 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2718 (timezone-parse-date "Jan 1 12:00:00 1970")))
2719 (tday (- (timezone-absolute-from-gregorian
2720 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2721 (timezone-absolute-from-gregorian
2722 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2724 (* (nth 1 ttime) 60)
2725 (* 1.0 (nth 0 ttime) 60 60)
2726 (* 1.0 tday 60 60 24))))
2728 (defun gnus-file-newer-than (file date)
2729 (let ((fdate (nth 5 (file-attributes file))))
2730 (or (> (car fdate) (car date))
2731 (and (= (car fdate) (car date))
2732 (> (nth 1 fdate) (nth 1 date))))))
2734 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2736 (defun gnus-y-or-n-p (prompt)
2741 (defun gnus-yes-or-no-p (prompt)
2743 (yes-or-no-p prompt)
2746 ;; Check whether to use long file names.
2747 (defun gnus-use-long-file-name (symbol)
2748 ;; The variable has to be set...
2749 (and gnus-use-long-file-name
2750 ;; If it isn't a list, then we return t.
2751 (or (not (listp gnus-use-long-file-name))
2752 ;; If it is a list, and the list contains `symbol', we
2754 (not (memq symbol gnus-use-long-file-name)))))
2756 ;; I suspect there's a better way, but I haven't taken the time to do
2757 ;; it yet. -erik selberg@cs.washington.edu
2758 (defun gnus-dd-mmm (messy-date)
2759 "Return a string like DD-MMM from a big messy string"
2760 (let ((datevec (timezone-parse-date messy-date)))
2762 (or (aref datevec 2) "??")
2765 (nth (1- (string-to-number (aref datevec 1)))
2766 timezone-months-assoc))
2769 ;; Make a hash table (default and minimum size is 255).
2770 ;; Optional argument HASHSIZE specifies the table size.
2771 (defun gnus-make-hashtable (&optional hashsize)
2772 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2774 ;; Make a number that is suitable for hashing; bigger than MIN and one
2776 (defun gnus-create-hash-size (min)
2782 ;; Show message if message has a lower level than `gnus-verbose'.
2783 ;; Guide-line for numbers:
2784 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2785 ;; for things that take a long time, 7 - not very important messages
2786 ;; on stuff, 9 - messages inside loops.
2787 (defun gnus-message (level &rest args)
2788 (if (<= level gnus-verbose)
2789 (apply 'message args)
2790 ;; We have to do this format thingie here even if the result isn't
2791 ;; shown - the return value has to be the same as the return value
2793 (apply 'format args)))
2795 ;; Generate a unique new group name.
2796 (defun gnus-generate-new-group-name (leaf)
2799 (while (gnus-gethash name gnus-newsrc-hashtb)
2800 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2803 ;;; List and range functions
2805 (defun gnus-last-element (list)
2806 "Return last element of LIST."
2808 (setq list (cdr list)))
2811 (defun gnus-copy-sequence (list)
2812 "Do a complete, total copy of a list."
2813 (if (and (consp list) (not (consp (cdr list))))
2814 (cons (car list) (cdr list))
2815 (mapcar (lambda (elem) (if (consp elem)
2816 (if (consp (cdr elem))
2817 (gnus-copy-sequence elem)
2818 (cons (car elem) (cdr elem)))
2822 (defun gnus-set-difference (list1 list2)
2823 "Return a list of elements of LIST1 that do not appear in LIST2."
2824 (let ((list1 (copy-sequence list1)))
2826 (setq list1 (delq (car list2) list1))
2827 (setq list2 (cdr list2)))
2830 (defun gnus-sorted-complement (list1 list2)
2831 "Return a list of elements of LIST1 that do not appear in LIST2.
2832 Both lists have to be sorted over <."
2834 (if (or (null list1) (null list2))
2836 (while (and list1 list2)
2837 (cond ((= (car list1) (car list2))
2838 (setq list1 (cdr list1)
2840 ((< (car list1) (car list2))
2841 (setq out (cons (car list1) out))
2842 (setq list1 (cdr list1)))
2844 (setq out (cons (car list2) out))
2845 (setq list2 (cdr list2)))))
2846 (nconc (nreverse out) (or list1 list2)))))
2848 (defun gnus-intersection (list1 list2)
2851 (if (memq (car list2) list1)
2852 (setq result (cons (car list2) result)))
2853 (setq list2 (cdr list2)))
2856 (defun gnus-sorted-intersection (list1 list2)
2857 ;; LIST1 and LIST2 have to be sorted over <.
2859 (while (and list1 list2)
2860 (cond ((= (car list1) (car list2))
2861 (setq out (cons (car list1) out)
2864 ((< (car list1) (car list2))
2865 (setq list1 (cdr list1)))
2867 (setq list2 (cdr list2)))))
2870 (defun gnus-set-sorted-intersection (list1 list2)
2871 ;; LIST1 and LIST2 have to be sorted over <.
2872 ;; This function modifies LIST1.
2873 (let* ((top (cons nil list1))
2875 (while (and list1 list2)
2876 (cond ((= (car list1) (car list2))
2880 ((< (car list1) (car list2))
2881 (setcdr prev (cdr list1))
2882 (setq list1 (cdr list1)))
2884 (setq list2 (cdr list2)))))
2888 (defun gnus-compress-sequence (numbers &optional always-list)
2889 "Convert list of numbers to a list of ranges or a single range.
2890 If ALWAYS-LIST is non-nil, this function will always release a list of
2892 (let* ((first (car numbers))
2893 (last (car numbers))
2897 (if (not (listp (cdr numbers)))
2900 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2901 ((= (1+ last) (car numbers)) ;Still in sequence
2902 (setq last (car numbers)))
2903 (t ;End of one sequence
2905 (cons (if (= first last) first
2906 (cons first last)) result))
2907 (setq first (car numbers))
2908 (setq last (car numbers))))
2909 (setq numbers (cdr numbers)))
2910 (if (and (not always-list) (null result))
2911 (if (= first last) (list first) (cons first last))
2912 (nreverse (cons (if (= first last) first (cons first last))
2915 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2916 (defun gnus-uncompress-range (ranges)
2917 "Expand a list of ranges into a list of numbers.
2918 RANGES is either a single range on the form `(num . num)' or a list of
2920 (let (first last result)
2924 ((not (listp (cdr ranges)))
2925 (setq first (car ranges))
2926 (setq last (cdr ranges))
2927 (while (<= first last)
2928 (setq result (cons first result))
2929 (setq first (1+ first)))
2933 (if (atom (car ranges))
2934 (if (numberp (car ranges))
2935 (setq result (cons (car ranges) result)))
2936 (setq first (car (car ranges)))
2937 (setq last (cdr (car ranges)))
2938 (while (<= first last)
2939 (setq result (cons first result))
2940 (setq first (1+ first))))
2941 (setq ranges (cdr ranges)))
2942 (nreverse result)))))
2944 (defun gnus-add-to-range (ranges list)
2945 "Return a list of ranges that has all articles from both RANGES and LIST.
2946 Note: LIST has to be sorted over `<'."
2948 (gnus-compress-sequence list t)
2949 (setq list (copy-sequence list))
2950 (or (listp (cdr ranges))
2951 (setq ranges (list ranges)))
2953 ilist lowest highest temp)
2954 (while (and ranges list)
2956 (setq lowest (or (and (atom (car ranges)) (car ranges))
2957 (car (car ranges))))
2958 (while (and list (cdr list) (< (car (cdr list)) lowest))
2959 (setq list (cdr list)))
2960 (if (< (car ilist) lowest)
2963 (setq list (cdr list))
2965 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2966 (setq highest (or (and (atom (car ranges)) (car ranges))
2967 (cdr (car ranges))))
2968 (while (and list (<= (car list) highest))
2969 (setq list (cdr list)))
2970 (setq ranges (cdr ranges)))
2972 (setq out (nconc (gnus-compress-sequence list t) out)))
2973 (setq out (sort out (lambda (r1 r2)
2974 (< (or (and (atom r1) r1) (car r1))
2975 (or (and (atom r2) r2) (car r2))))))
2978 (if (atom (car ranges))
2980 (if (atom (car (cdr ranges)))
2981 (if (= (1+ (car ranges)) (car (cdr ranges)))
2983 (setcar ranges (cons (car ranges)
2984 (car (cdr ranges))))
2985 (setcdr ranges (cdr (cdr ranges)))))
2986 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2988 (setcar (car (cdr ranges)) (car ranges))
2989 (setcar ranges (car (cdr ranges)))
2990 (setcdr ranges (cdr (cdr ranges)))))))
2992 (if (atom (car (cdr ranges)))
2993 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2995 (setcdr (car ranges) (car (cdr ranges)))
2996 (setcdr ranges (cdr (cdr ranges)))))
2997 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2999 (setcdr (car ranges) (cdr (car (cdr ranges))))
3000 (setcdr ranges (cdr (cdr ranges))))))))
3001 (setq ranges (cdr ranges)))
3004 (defun gnus-remove-from-range (ranges list)
3005 "Return a list of ranges that has all articles from LIST removed from RANGES.
3006 Note: LIST has to be sorted over `<'."
3007 ;; !!! This function shouldn't look like this, but I've got a headache.
3008 (gnus-compress-sequence
3009 (gnus-sorted-complement
3010 (gnus-uncompress-range ranges) list)))
3012 (defun gnus-member-of-range (number ranges)
3013 (if (not (listp (cdr ranges)))
3014 (and (>= number (car ranges))
3015 (<= number (cdr ranges)))
3018 (if (numberp (car ranges))
3019 (>= number (car ranges))
3020 (>= number (car (car ranges))))
3022 (if (if (numberp (car ranges))
3023 (= number (car ranges))
3024 (and (>= number (car (car ranges)))
3025 (<= number (cdr (car ranges)))))
3026 (setq not-stop nil))
3027 (setq ranges (cdr ranges)))
3035 (defvar gnus-group-mode-map nil)
3036 (defvar gnus-group-group-map nil)
3037 (defvar gnus-group-mark-map nil)
3038 (defvar gnus-group-list-map nil)
3039 (defvar gnus-group-sub-map nil)
3040 (put 'gnus-group-mode 'mode-class 'special)
3042 (if gnus-group-mode-map
3044 (setq gnus-group-mode-map (make-keymap))
3045 (suppress-keymap gnus-group-mode-map)
3046 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3047 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3048 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3049 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3050 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3051 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3052 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3053 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3054 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3055 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
3056 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
3057 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3058 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3059 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3060 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3061 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3062 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3063 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3064 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3065 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3066 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3067 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3068 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3069 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3070 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3071 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3072 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3073 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3074 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3075 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3076 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3077 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3078 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3079 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3080 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3081 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3082 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3083 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3084 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3085 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3086 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3087 (define-key gnus-group-mode-map "V" 'gnus-version)
3088 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3089 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3090 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3091 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3092 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3093 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3094 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3095 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3096 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3097 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3098 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3099 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3100 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3101 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3102 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3104 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3105 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3106 (define-prefix-command 'gnus-group-mark-map)
3107 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3108 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3109 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3110 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3112 (define-prefix-command 'gnus-group-group-map)
3113 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3114 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3115 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3116 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3117 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3118 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3119 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3120 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3121 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3122 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3123 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3124 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3125 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3126 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3127 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3128 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3129 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3130 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3132 (define-prefix-command 'gnus-group-list-map)
3133 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3134 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3135 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3136 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3137 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3138 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3139 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3140 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3141 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3143 (define-prefix-command 'gnus-group-sub-map)
3144 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3145 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3146 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3147 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3148 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3149 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3150 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3151 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3153 (defun gnus-group-mode ()
3154 "Major mode for reading news.
3156 All normal editing commands are switched off.
3157 \\<gnus-group-mode-map>
3158 The group buffer lists (some of) the groups available. For instance,
3159 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3160 lists all zombie groups.
3162 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3163 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3165 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3167 The following commands are available:
3169 \\{gnus-group-mode-map}"
3171 (if gnus-visual (gnus-group-make-menu-bar))
3172 (kill-all-local-variables)
3173 (setq mode-line-modified "-- ")
3174 (make-local-variable 'mode-line-format)
3175 (setq mode-line-format (copy-sequence mode-line-format))
3176 (and (equal (nth 3 mode-line-format) " ")
3177 (setcar (nthcdr 3 mode-line-format) ""))
3178 (setq major-mode 'gnus-group-mode)
3179 (setq mode-name "Group")
3180 (gnus-group-set-mode-line)
3181 (setq mode-line-process nil)
3182 (use-local-map gnus-group-mode-map)
3183 (buffer-disable-undo (current-buffer))
3184 (setq truncate-lines t)
3185 (setq buffer-read-only t)
3186 (run-hooks 'gnus-group-mode-hook))
3188 (defun gnus-mouse-pick-group (e)
3191 (gnus-group-read-group nil))
3193 ;; Look at LEVEL and find out what the level is really supposed to be.
3194 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3195 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3196 (defun gnus-group-default-level (&optional level number-or-nil)
3198 (gnus-group-use-permanent-levels
3199 (setq gnus-group-default-list-level
3200 (or level gnus-group-default-list-level))
3201 (or gnus-group-default-list-level gnus-level-subscribed))
3205 (or level gnus-group-default-list-level gnus-level-subscribed))))
3209 (defun gnus-no-server (&optional arg)
3211 If ARG is a positive number, Gnus will use that as the
3212 startup level. If ARG is nil, Gnus will be started at level 2.
3213 If ARG is non-nil and not a positive number, Gnus will
3214 prompt the user for the name of an NNTP server to use.
3215 As opposed to `gnus', this command will not connect to the local server."
3217 (setq gnus-group-use-permanent-levels t)
3218 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3221 (defun gnus (&optional arg dont-connect)
3223 If ARG is non-nil and a positive number, Gnus will use that as the
3224 startup level. If ARG is non-nil and not a positive number, Gnus will
3225 prompt the user for the name of an NNTP server to use."
3227 (if (get-buffer gnus-group-buffer)
3229 (switch-to-buffer gnus-group-buffer)
3230 (gnus-group-get-new-news))
3234 (gnus-group-setup-buffer)
3235 (let ((buffer-read-only nil))
3237 (if (not gnus-inhibit-startup-message)
3239 (gnus-group-startup-message)
3242 (nnheader-init-server-buffer)
3243 (gnus-read-init-file)
3245 (let ((level (and arg (numberp arg) (> arg 0) arg))
3251 (gnus-start-news-server (and arg (not level))))))
3252 (if (and (not dont-connect)
3255 (run-hooks 'gnus-startup-hook)
3256 ;; NNTP server is successfully open.
3258 ;; Find the current startup file name.
3259 (setq gnus-current-startup-file
3260 (gnus-make-newsrc-file gnus-startup-file))
3262 ;; Read the dribble file.
3263 (and gnus-use-dribble-file (gnus-dribble-read-file))
3265 (gnus-summary-make-display-table)
3266 (gnus-setup-news nil level)
3267 (gnus-group-list-groups level)
3268 (gnus-configure-windows 'group))))))
3270 (defun gnus-unload ()
3271 "Unload all Gnus features."
3273 (or (boundp 'load-history)
3274 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3275 (let ((history load-history)
3278 (and (string-match "^gnus" (car (car history)))
3279 (setq feature (cdr (assq 'provide (car history))))
3280 (unload-feature feature 'force))
3281 (setq history (cdr history)))))
3283 (defun gnus-group-startup-message (&optional x y)
3284 "Insert startup message in current buffer."
3285 ;; Insert the message.
3290 _ ___ __ ___ __ _ ___
3308 Gnus * A newsreader for Emacsen
3309 A Praxis release * larsi@ifi.uio.no
3312 ;; And then hack it.
3313 ;; 18 is the longest line.
3314 (indent-rigidly (point-min) (point-max)
3315 (/ (max (- (window-width) (or x 46)) 0) 2))
3316 (goto-char (point-min))
3317 (let* ((pheight (count-lines (point-min) (point-max)))
3318 (wheight (window-height))
3319 (rest (- wheight pheight)))
3320 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3325 (goto-char (point-min))
3326 (search-forward "Praxis")
3327 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3328 (goto-char (point-min)))
3330 (defun gnus-group-startup-message-old (&optional x y)
3331 "Insert startup message in current buffer."
3332 ;; Insert the message.
3348 ;; And then hack it.
3349 ;; 18 is the longest line.
3350 (indent-rigidly (point-min) (point-max)
3351 (/ (max (- (window-width) (or x 28)) 0) 2))
3352 (goto-char (point-min))
3353 ;; +4 is fuzzy factor.
3354 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3357 (goto-char (point-min))
3358 (search-forward "Praxis")
3359 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3360 (goto-char (point-min)))
3362 (defun gnus-group-setup-buffer ()
3363 (or (get-buffer gnus-group-buffer)
3365 (switch-to-buffer gnus-group-buffer)
3366 (gnus-add-current-to-buffer-list)
3368 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3370 (defun gnus-group-list-groups (&optional level unread)
3371 "List newsgroups with level LEVEL or lower that have unread articles.
3372 Default is all subscribed groups.
3373 If argument UNREAD is non-nil, groups with no unread articles are also
3375 (interactive (list (if current-prefix-arg
3376 (prefix-numeric-value current-prefix-arg)
3378 (gnus-group-default-level nil t)
3379 gnus-group-default-list-level
3380 gnus-level-subscribed))))
3382 (setq level (car gnus-group-list-mode)
3383 unread (cdr gnus-group-list-mode)))
3384 (setq level (gnus-group-default-level level))
3385 (gnus-group-setup-buffer) ;May call from out of group buffer
3386 (let ((case-fold-search nil)
3387 (group (gnus-group-group-name)))
3388 (funcall gnus-group-prepare-function level unread nil)
3389 (if (zerop (buffer-size))
3390 (gnus-message 5 gnus-no-groups-message)
3391 (goto-char (point-min))
3393 ;; Go to the first group with unread articles.
3394 (gnus-group-search-forward nil nil nil t)
3395 ;; Find the right group to put point on. If the current group
3396 ;; has disapeared in the new listing, try to find the next
3397 ;; one. If no next one can be found, just leave point at the
3398 ;; first newsgroup in the buffer.
3399 (if (not (gnus-goto-char
3400 (text-property-any (point-min) (point-max)
3401 'gnus-group (intern group))))
3402 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3404 (not (gnus-goto-char
3406 (point-min) (point-max) 'gnus-group
3407 (intern (car (car newsrc)))))))
3408 (setq newsrc (cdr newsrc)))
3409 (or newsrc (progn (goto-char (point-max))
3410 (forward-line -1))))))
3411 ;; Adjust cursor point.
3412 (gnus-group-position-cursor))))
3414 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3415 "List all newsgroups with unread articles of level LEVEL or lower.
3416 If ALL is non-nil, list groups that have no unread articles.
3417 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3418 If REGEXP, only list groups matching REGEXP."
3419 (set-buffer gnus-group-buffer)
3420 (let ((buffer-read-only nil)
3421 (newsrc (cdr gnus-newsrc-alist))
3422 (lowest (or lowest 1))
3423 info clevel unread group)
3425 (if (< lowest gnus-level-zombie)
3426 ;; List living groups.
3428 (setq info (car newsrc)
3431 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3432 (and unread ; This group might be bogus
3434 (string-match regexp group))
3435 (<= (setq clevel (car (cdr info))) level)
3437 (or all ; We list all groups?
3438 (eq unread t) ; We list unactivated groups
3439 (> unread 0) ; We list groups with unread articles
3440 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3441 (gnus-group-insert-group-line
3442 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3444 ;; List dead groups.
3445 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3446 (gnus-group-prepare-flat-list-dead
3447 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3448 gnus-level-zombie ?Z
3450 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3451 (gnus-group-prepare-flat-list-dead
3452 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3453 gnus-level-killed ?K regexp))
3455 (gnus-group-set-mode-line)
3456 (setq gnus-group-list-mode (cons level all))
3457 (run-hooks 'gnus-group-prepare-hook)))
3459 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3460 ;; List zombies and killed lists somehwat faster, which was
3461 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3462 ;; this by ignoring the group format specification altogether.
3465 (setq group (car groups)
3466 groups (cdr groups))
3467 (if (or (not regexp)
3468 (string-match regexp group))
3471 (insert (format " %c *: %s\n" mark group))
3472 (add-text-properties
3474 (list 'gnus-group (intern group)
3476 'gnus-level level)))))))
3478 (defun gnus-group-real-name (group)
3479 "Find the real name of a foreign newsgroup."
3480 (if (string-match ":[^:]+$" group)
3481 (substring group (1+ (match-beginning 0)))
3484 (defun gnus-group-prefixed-name (group method)
3485 "Return the whole name from GROUP and METHOD."
3486 (and (stringp method) (setq method (gnus-server-to-method method)))
3487 (concat (format "%s" (car method))
3489 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3490 (not (string= (nth 1 method) "")))
3491 (concat "+" (nth 1 method)))
3494 (defun gnus-group-real-prefix (group)
3495 "Return the prefix of the current group name."
3496 (if (string-match "^[^:]+:" group)
3497 (substring group 0 (match-end 0))
3500 (defun gnus-group-method-name (group)
3501 "Return the method used for selecting GROUP."
3502 (let ((prefix (gnus-group-real-prefix group)))
3503 (if (equal prefix "")
3505 (if (string-match "^[^\\+]+\\+" prefix)
3506 (list (intern (substring prefix 0 (1- (match-end 0))))
3507 (substring prefix (match-end 0) (1- (length prefix))))
3508 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3510 (defun gnus-group-foreign-p (group)
3511 "Return nil if GROUP is native, non-nil if it is foreign."
3512 (string-match ":" group))
3514 (defun gnus-group-set-info (info &optional method-only-group part)
3515 (let* ((entry (gnus-gethash
3516 (or method-only-group (car info)) gnus-newsrc-hashtb))
3518 (info (if method-only-group (nth 2 entry) info)))
3519 (if (not method-only-group)
3522 (error "Trying to change non-existent group %s" method-only-group))
3523 ;; We have recevied parts of the actual group info - either the
3524 ;; select method or the group parameters. We first check
3525 ;; whether we have to extend the info, and if so, do that.
3526 (let ((len (length info))
3527 (total (if (eq part 'method) 5 6)))
3529 (setcdr (nthcdr (1- len) info)
3530 (make-list (- total len) nil)))
3531 ;; Then we enter the new info.
3532 (setcar (nthcdr (1- total) info) part-info)))
3533 ;; We uncompress some lists of marked articles.
3535 (if (not (setq marked (nth 3 info)))
3538 (or (eq 'score (car (car marked)))
3539 (eq 'bookmark (car (car marked)))
3540 (eq 'killed (car (car marked)))
3541 (setcdr (car marked)
3542 (gnus-uncompress-range (cdr (car marked)))))
3543 (setq marked (cdr marked)))))
3546 ;; This is a new group, so we just create it.
3548 (set-buffer gnus-group-buffer)
3550 ;; It's a foreign group...
3551 (gnus-group-make-group
3552 (gnus-group-real-name (car info))
3553 (prin1-to-string (car (nth 4 info)))
3554 (nth 1 (nth 4 info)))
3555 ;; It's a native group.
3556 (gnus-group-make-group
3558 (prin1-to-string (car gnus-select-method))
3559 (nth 1 gnus-select-method)))
3560 (gnus-message 6 "Note: New group created")
3562 (gnus-gethash (gnus-group-prefixed-name
3563 (gnus-group-real-name (car info))
3564 (or (nth 4 info) gnus-select-method))
3565 gnus-newsrc-hashtb))))
3566 ;; Whether it was a new group or not, we now have the entry, so we
3567 ;; can do the update.
3570 (setcar (nthcdr 2 entry) info)
3571 (if (and (not (eq (car entry) t))
3572 (gnus-gethash (car info) gnus-active-hashtb))
3573 (let ((marked (nth 3 info)))
3575 (max 0 (- (length (gnus-list-of-unread-articles
3577 (length (cdr (assq 'tick marked)))
3578 (length (cdr (assq 'dormant marked)))))))))
3579 (error "No such group: %s" (car info)))))
3581 (defun gnus-group-set-method-info (group select-method)
3582 (gnus-group-set-info select-method group 'method))
3584 (defun gnus-group-set-params-info (group params)
3585 (gnus-group-set-info params group 'params))
3587 (defun gnus-group-update-group-line ()
3588 "This function updates the current line in the newsgroup buffer and
3589 moves the point to the colon."
3590 (let* ((buffer-read-only nil)
3591 (group (gnus-group-group-name))
3592 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3595 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3598 (delete-region (point) (progn (forward-line 1) (point)))
3599 (gnus-group-insert-group-line-info group)
3601 (gnus-group-position-cursor)))
3603 (defun gnus-group-insert-group-line-info (group)
3604 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3608 (setq info (nth 2 entry))
3609 (gnus-group-insert-group-line
3610 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3611 (setq active (gnus-gethash group gnus-active-hashtb))
3612 (gnus-group-insert-group-line
3614 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3615 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3617 (defun gnus-group-insert-group-line (gformat group level marked number method)
3618 (let* ((gformat (or gformat gnus-group-line-format-spec))
3619 (active (gnus-gethash group gnus-active-hashtb))
3620 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3621 (number-of-dormant (length (cdr (assq 'dormant marked))))
3622 (number-of-ticked (length (cdr (assq 'tick marked))))
3623 (number-of-ticked-and-dormant
3624 (+ number-of-ticked number-of-dormant))
3625 (number-of-unread-unticked
3626 (if (numberp number) (int-to-string (max 0 number))
3629 (if (numberp number)
3630 (max 0 (- number-total number))
3632 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3633 ((<= level gnus-level-unsubscribed) ?U)
3634 ((= level gnus-level-zombie) ?Z)
3636 (qualified-group (gnus-group-real-name group))
3637 (newsgroup-description
3638 (if gnus-description-hashtb
3639 (or (gnus-gethash group gnus-description-hashtb) "")
3641 (moderated (if (member group gnus-moderated-list) ?m ? ))
3642 (moderated-string (if (eq moderated ?m) "(m)" ""))
3643 (method (gnus-server-get-method group method))
3644 (news-server (or (car (cdr method)) ""))
3645 (news-method (or (car method) ""))
3647 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3651 (> number-of-ticked 0))
3653 (number (if (eq number t) "*" (+ number number-of-dormant
3655 (process-marked (if (member qualified-group gnus-group-marked)
3656 gnus-process-mark ? ))
3657 (buffer-read-only nil)
3658 header ; passed as parameter to user-funcs.
3663 (insert (eval gformat))
3665 (add-text-properties
3666 b (1+ b) (list 'gnus-group (intern group)
3667 'gnus-unread (if (numberp number)
3668 (string-to-int number-of-unread-unticked)
3671 'gnus-level level))))
3673 (defun gnus-group-update-group (group &optional visible-only)
3674 "Update newsgroup info of GROUP.
3675 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3677 (set-buffer gnus-group-buffer)
3678 (let ((buffer-read-only nil)
3680 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3683 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3685 ;; Buffer may be narrowed.
3688 ;; Search a line to modify. If the buffer is large, the search
3689 ;; takes long time. In most cases, current point is on the line
3690 ;; we are looking for. So, first of all, check current line.
3693 (eq (get-text-property (point) 'gnus-group)
3698 (point-min) (point-max) 'gnus-group (intern group)))))
3699 ;; GROUP is listed in current buffer. So, delete old line.
3703 (delete-region (point) (progn (forward-line 1) (point))))
3704 ;; No such line in the buffer, find out where it's supposed to
3705 ;; go, and insert it there (or at the end of the buffer).
3706 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3709 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3715 (point-min) (point-max)
3716 'gnus-group (intern (car (car entry)))))))
3717 (setq entry (cdr entry)))
3718 (or entry (goto-char (point-max)))))))
3719 (if (or visible (not visible-only))
3720 (gnus-group-insert-group-line-info group))
3721 (gnus-group-set-mode-line))))
3723 (defun gnus-group-set-mode-line ()
3724 (if (memq 'group gnus-updated-mode-lines)
3725 (let* ((gformat (or gnus-group-mode-line-format-spec
3726 (setq gnus-group-mode-line-format-spec
3728 gnus-group-mode-line-format
3729 gnus-group-mode-line-format-alist))))
3730 (news-server (car (cdr gnus-select-method)))
3731 (news-method (car gnus-select-method))
3733 (mode-string (eval gformat)))
3734 (setq mode-string (eval gformat))
3735 (if (> (length mode-string) max-len)
3736 (setq mode-string (substring mode-string 0 (- max-len 4))))
3737 (setq mode-line-buffer-identification mode-string)
3738 (set-buffer-modified-p t))))
3740 (defun gnus-group-group-name ()
3741 "Get the name of the newsgroup on the current line."
3742 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3743 (and group (symbol-name group))))
3745 (defun gnus-group-group-level ()
3746 "Get the level of the newsgroup on the current line."
3747 (get-text-property (gnus-point-at-bol) 'gnus-level))
3749 (defun gnus-group-group-unread ()
3750 "Get the number of unread articles of the newsgroup on the current line."
3751 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3753 (defun gnus-group-search-forward (&optional backward all level first-too)
3754 "Find the next newsgroup with unread articles.
3755 If BACKWARD is non-nil, find the previous newsgroup instead.
3756 If ALL is non-nil, just find any newsgroup.
3757 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3759 If FIRST-TOO, the current line is also eligible as a target."
3760 (let ((way (if backward -1 1))
3761 (low gnus-level-killed)
3764 (if (and backward (progn (beginning-of-line)) (bobp))
3766 (or first-too (forward-line way))
3774 (get-text-property (point) 'gnus-unread)))
3775 (or (eq unread t) (and unread (> unread 0))))
3776 (setq lev (get-text-property (point)
3778 (<= lev gnus-level-subscribed)))
3780 (and (setq lev (get-text-property (point)
3789 (zerop (forward-line way)))))
3791 (progn (gnus-group-position-cursor) t)
3792 (goto-char (or pos beg))
3795 ;;; Gnus group mode commands
3799 (defun gnus-group-mark-group (n &optional unmark no-advance)
3800 "Mark the current group."
3802 (let ((buffer-read-only nil)
3806 (setq group (gnus-group-group-name))
3810 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3815 (setq gnus-group-marked (delete group gnus-group-marked)))
3817 (setq gnus-group-marked
3818 (cons group (delete group gnus-group-marked))))
3820 (or no-advance (zerop (gnus-group-next-group 1))))
3822 (gnus-summary-position-cursor)
3825 (defun gnus-group-unmark-group (n)
3826 "Remove the mark from the current group."
3828 (gnus-group-mark-group n 'unmark))
3830 (defun gnus-group-mark-region (unmark beg end)
3831 "Mark all groups between point and mark.
3832 If UNMARK, remove the mark instead."
3833 (interactive "P\nr")
3834 (let ((num (count-lines beg end)))
3837 (- num (gnus-group-mark-group num unmark)))))
3839 (defun gnus-group-remove-mark (group)
3840 (and (gnus-group-goto-group group)
3842 (gnus-group-mark-group 1 'unmark t))))
3844 ;; Return a list of groups to work on. Take into consideration N (the
3845 ;; prefix) and the list of marked groups.
3846 (defun gnus-group-process-prefix (n)
3848 (setq n (prefix-numeric-value n))
3849 ;; There is a prefix, so we return a list of the N next
3851 (let ((way (if (< n 0) -1 1))
3856 (setq group (gnus-group-group-name)))
3857 (setq groups (cons group groups))
3859 (forward-line way)))
3862 ;; No prefix, but a list of marked articles.
3863 (reverse gnus-group-marked))
3865 ;; Neither marked articles or a prefix, so we return the
3867 (let ((group (gnus-group-group-name)))
3868 (and group (list group))))))
3870 ;; Selecting groups.
3872 (defun gnus-group-read-group (&optional all no-article group)
3873 "Read news in this newsgroup.
3874 If the prefix argument ALL is non-nil, already read articles become
3875 readable. If the optional argument NO-ARTICLE is non-nil, no article
3876 will be auto-selected upon group entry."
3878 (let ((group (or group (gnus-group-group-name)))
3879 number active marked entry)
3880 (or group (error "No group on current line"))
3882 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3883 ;; This group might be a dead group. In that case we have to get
3884 ;; the number of unread articles from `gnus-active-hashtb'.
3886 (setq number (car entry))
3887 (if (setq active (gnus-gethash group gnus-active-hashtb))
3888 (setq number (- (1+ (cdr active)) (car active)))))
3889 (gnus-summary-read-group
3890 group (or all (and (numberp number)
3891 (zerop (+ number (length (cdr (assq 'tick marked)))
3892 (length (cdr (assq 'dormant marked)))))))
3895 (defun gnus-group-select-group (&optional all)
3896 "Select this newsgroup.
3897 No article is selected automatically.
3898 If argument ALL is non-nil, already read articles become readable."
3900 (gnus-group-read-group all t))
3902 (defun gnus-group-select-group-all ()
3903 "Select the current group and display all articles in it."
3905 (gnus-group-select-group 'all))
3907 ;; Enter a group that is not in the group buffer. Non-nil is returned
3908 ;; if selection was successful.
3909 (defun gnus-group-read-ephemeral-group
3910 (group method &optional activate quit-config)
3911 (let ((group (if (gnus-group-foreign-p group) group
3912 (gnus-group-prefixed-name group method))))
3915 (list t nil (list group gnus-level-default-subscribed nil nil
3919 (if quit-config quit-config
3920 (cons (current-buffer) 'summary)))))))
3922 (set-buffer gnus-group-buffer)
3923 (or (gnus-check-server method)
3924 (error "Unable to contact server: %s" (gnus-status-message method)))
3925 (if activate (or (gnus-request-group group)
3926 (error "Couldn't request group")))
3928 (gnus-group-read-group t t group)
3931 (not (equal major-mode 'gnus-group-mode))))
3933 (defun gnus-group-jump-to-group (group)
3934 "Jump to newsgroup GROUP."
3936 (list (completing-read
3937 "Group: " gnus-active-hashtb nil
3938 (memq gnus-select-method gnus-have-read-active-file))))
3940 (if (equal group "")
3941 (error "Empty group name"))
3943 (let ((b (text-property-any
3944 (point-min) (point-max) 'gnus-group (intern group))))
3946 ;; Either go to the line in the group buffer...
3948 ;; ... or insert the line.
3950 (gnus-gethash group gnus-active-hashtb)
3951 (gnus-activate-group group)
3952 (error "%s error: %s" group (gnus-status-message group)))
3954 (gnus-group-update-group group)
3955 (goto-char (text-property-any
3956 (point-min) (point-max) 'gnus-group (intern group)))))
3957 ;; Adjust cursor point.
3958 (gnus-group-position-cursor))
3960 (defun gnus-group-goto-group (group)
3961 "Goto to newsgroup GROUP."
3962 (let ((b (text-property-any (point-min) (point-max)
3963 'gnus-group (intern group))))
3964 (and b (goto-char b))))
3966 (defun gnus-group-next-group (n)
3967 "Go to next N'th newsgroup.
3968 If N is negative, search backward instead.
3969 Returns the difference between N and the number of skips actually
3972 (gnus-group-next-unread-group n t))
3974 (defun gnus-group-next-unread-group (n &optional all level)
3975 "Go to next N'th unread newsgroup.
3976 If N is negative, search backward instead.
3977 If ALL is non-nil, choose any newsgroup, unread or not.
3978 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3979 such group can be found, the next group with a level higher than
3981 Returns the difference between N and the number of skips actually
3984 (let ((backward (< n 0))
3987 (gnus-group-search-forward
3988 backward (or (not gnus-group-goto-unread) all) level))
3990 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3991 (if level " on this level or higher" "")))
3994 (defun gnus-group-prev-group (n)
3995 "Go to previous N'th newsgroup.
3996 Returns the difference between N and the number of skips actually
3999 (gnus-group-next-unread-group (- n) t))
4001 (defun gnus-group-prev-unread-group (n)
4002 "Go to previous N'th unread newsgroup.
4003 Returns the difference between N and the number of skips actually
4006 (gnus-group-next-unread-group (- n)))
4008 (defun gnus-group-next-unread-group-same-level (n)
4009 "Go to next N'th unread newsgroup on the same level.
4010 If N is negative, search backward instead.
4011 Returns the difference between N and the number of skips actually
4014 (gnus-group-next-unread-group n t (gnus-group-group-level))
4015 (gnus-group-position-cursor))
4017 (defun gnus-group-prev-unread-group-same-level (n)
4018 "Go to next N'th unread newsgroup on the same level.
4019 Returns the difference between N and the number of skips actually
4022 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4023 (gnus-group-position-cursor))
4025 (defun gnus-group-best-unread-group (&optional exclude-group)
4026 "Go to the group with the highest level.
4027 If EXCLUDE-GROUP, do not go to that group."
4029 (goto-char (point-min))
4032 (while (setq unread (get-text-property (point) 'gnus-unread))
4033 (if (and (numberp unread) (> unread 0))
4035 (if (and (< (get-text-property (point) 'gnus-level) best)
4036 (or (not exclude-group)
4037 (not (equal exclude-group (gnus-group-group-name)))))
4039 (setq best (get-text-property (point) 'gnus-level))
4040 (setq best-point (point))))))
4042 (if best-point (goto-char best-point))
4043 (gnus-summary-position-cursor)
4044 (and best-point (gnus-group-group-name))))
4046 (defun gnus-group-first-unread-group ()
4047 "Go to the first group with unread articles."
4050 (let ((opoint (point))
4052 (goto-char (point-min))
4053 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4054 (not (zerop unread)) ; Has unread articles.
4055 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4058 nil)) ; Not success.
4059 (gnus-group-position-cursor)))
4061 (defun gnus-group-enter-server-mode ()
4062 "Jump to the server buffer."
4064 (gnus-server-setup-buffer)
4065 (gnus-configure-windows 'server)
4066 (gnus-server-prepare))
4068 (defun gnus-group-make-group (name method &optional address)
4069 "Add a new newsgroup.
4070 The user will be prompted for a NAME, for a select METHOD, and an
4074 (read-string "Group name: ")
4077 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4079 (if (assoc method gnus-valid-select-methods)
4081 (if (memq 'prompt-address
4082 (assoc method gnus-valid-select-methods))
4083 (read-string "Address: ")
4085 (list method nil)))))
4087 (let* ((meth (if address (list (intern method) address) method))
4088 (nname (gnus-group-prefixed-name name meth))
4090 (and (gnus-gethash nname gnus-newsrc-hashtb)
4091 (error "Group %s already exists" nname))
4092 (gnus-group-change-level
4093 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4094 gnus-level-default-subscribed gnus-level-killed
4095 (and (gnus-group-group-name)
4096 (gnus-gethash (gnus-group-group-name)
4097 gnus-newsrc-hashtb))
4099 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4101 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
4102 (gnus-group-insert-group-line-info nname)
4104 (if (assoc method gnus-valid-select-methods)
4105 (require (intern method)))
4106 (and (gnus-check-backend-function 'request-create-group nname)
4107 (gnus-request-create-group nname))))
4109 (defun gnus-group-edit-group (group &optional part)
4110 "Edit the group on the current line."
4111 (interactive (list (gnus-group-group-name)))
4112 (let ((done-func '(lambda ()
4113 "Exit editing mode and update the information."
4115 (gnus-group-edit-group-done 'part 'group)))
4116 (part (or part 'info))
4117 (winconf (current-window-configuration))
4119 (or group (error "No group on current line"))
4120 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4121 (error "Killed group; can't be edited"))
4122 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4123 (gnus-configure-windows 'edit-group)
4124 (gnus-add-current-to-buffer-list)
4126 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4127 (use-local-map (copy-keymap emacs-lisp-mode-map))
4128 (local-set-key "\C-c\C-c" done-func)
4129 (make-local-variable 'gnus-prev-winconf)
4130 (setq gnus-prev-winconf winconf)
4131 ;; We modify the func to let it know what part it is editing.
4132 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4133 (setcar (cdr (cdr (nth 4 done-func))) group)
4138 ";; Type `C-c C-c' after editing the select method.\n\n")
4140 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4142 ";; Type `C-c C-c' after editing the group info.\n\n")))
4143 (let ((cinfo (gnus-copy-sequence info))
4145 (if (not (setq marked (nth 3 cinfo)))
4148 (or (eq 'score (car (car marked)))
4149 (eq 'bookmark (car (car marked)))
4150 (eq 'killed (car (car marked)))
4151 (not (numberp (car (cdr (car marked)))))
4152 (setcdr (car marked)
4153 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4154 (setq marked (cdr marked))))
4157 (cond ((eq part 'method)
4158 (or (nth 4 info) "native"))
4165 (defun gnus-group-edit-group-method (group)
4166 "Edit the select method of GROUP."
4167 (interactive (list (gnus-group-group-name)))
4168 (gnus-group-edit-group group 'method))
4170 (defun gnus-group-edit-group-parameters (group)
4171 "Edit the group parameters of GROUP."
4172 (interactive (list (gnus-group-group-name)))
4173 (gnus-group-edit-group group 'params))
4175 (defun gnus-group-edit-group-done (part group)
4176 "Get info from buffer, update variables and jump to the group buffer."
4177 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4178 (goto-char (point-min))
4179 (let ((form (read (current-buffer)))
4180 (winconf gnus-prev-winconf))
4182 (gnus-group-set-info form)
4183 (gnus-group-set-info form group part))
4184 (kill-buffer (current-buffer))
4185 (and winconf (set-window-configuration winconf))
4186 (set-buffer gnus-group-buffer)
4187 (gnus-group-update-group (gnus-group-group-name))
4188 (gnus-group-position-cursor)))
4190 (defun gnus-group-make-help-group ()
4191 "Create the Gnus documentation group."
4193 (let ((path load-path)
4195 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4196 "gnus-help" '(nndoc "gnus-help")))
4198 (error "Documentation group already exists"))
4200 (not (file-exists-p (concat (file-name-as-directory (car path))
4202 (setq path (cdr path)))
4203 (or path (error "Couldn't find doc group"))
4204 (gnus-group-make-group
4205 (gnus-group-real-name name)
4207 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4208 (list 'nndoc-article-type 'mbox))))
4209 (gnus-group-position-cursor))
4211 (defun gnus-group-make-doc-group (file type)
4212 "Create a group that uses a single file as the source."
4214 (list (read-file-name "File name: ")
4218 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4219 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4220 ((= char ?b) 'babyl)
4221 ((= char ?d) 'digest)
4222 (t (setq err (format "%c unknown. " char))
4225 (let* ((file (expand-file-name file))
4226 (name (gnus-generate-new-group-name
4227 (gnus-group-prefixed-name
4228 (file-name-nondirectory file) '(nndoc "")))))
4229 (gnus-group-make-group
4230 (gnus-group-real-name name)
4232 (list 'nndoc-address file)
4233 (list 'nndoc-article-type type)))))
4235 (defun gnus-group-make-archive-group (&optional all)
4236 "Create the (ding) Gnus archive group of the most recent articles.
4237 Given a prefix, create a full group."
4239 (let ((group (gnus-group-prefixed-name
4240 (if all "ding.archives" "ding.recent") '(nndir ""))))
4241 (and (gnus-gethash group gnus-newsrc-hashtb)
4242 (error "Archive group already exists"))
4243 (gnus-group-make-group
4244 (gnus-group-real-name group)
4246 (if all gnus-group-archive-directory
4247 gnus-group-recent-archive-directory)))
4248 (gnus-group-position-cursor))
4250 (defun gnus-group-make-directory-group (dir)
4251 "Create an nndir group.
4252 The user will be prompted for a directory. The contents of this
4253 directory will be used as a newsgroup. The directory should contain
4254 mail messages or news articles in files that have numeric names."
4256 (list (read-file-name "Create group from directory: ")))
4257 (or (file-exists-p dir) (error "No such directory"))
4258 (or (file-directory-p dir) (error "Not a directory"))
4259 (gnus-group-make-group dir "nndir" dir)
4260 (gnus-group-position-cursor))
4262 (defun gnus-group-make-kiboze-group (group address scores)
4263 "Create an nnkiboze group.
4264 The user will be prompted for a name, a regexp to match groups, and
4265 score file entries for articles to include in the group."
4268 (read-string "nnkiboze group name: ")
4269 (read-string "Source groups (regexp): ")
4270 (let ((headers (mapcar (lambda (group) (list group))
4271 '("subject" "from" "number" "date" "message-id"
4272 "references" "chars" "lines" "xref")))
4273 scores header regexp regexps)
4274 (while (not (equal "" (setq header (completing-read
4275 "Match on header: " headers nil t))))
4277 (while (not (equal "" (setq regexp (read-string
4278 (format "Match on %s (string): "
4280 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4281 (setq scores (cons (cons header regexps) scores)))
4283 (gnus-group-make-group group "nnkiboze" address)
4285 (gnus-set-work-buffer)
4286 (let (emacs-lisp-mode-hook)
4287 (pp scores (current-buffer)))
4288 (write-region (point-min) (point-max)
4289 (concat (or gnus-kill-files-directory "~/News")
4290 "nnkiboze:" group "." gnus-score-file-suffix)))
4291 (gnus-group-position-cursor))
4293 (defun gnus-group-add-to-virtual (n vgroup)
4294 "Add the current group to a virtual group."
4296 (list current-prefix-arg
4297 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4299 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4300 (error "%s is not an nnvirtual group" vgroup))
4301 (let* ((groups (gnus-group-process-prefix n))
4302 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4303 (setcar (cdr method)
4305 (nth 1 method) "\\|"
4308 (gnus-group-remove-mark s)
4309 (concat "\\(^" (regexp-quote s) "$\\)"))
4311 (gnus-group-position-cursor))
4313 (defun gnus-group-make-empty-virtual (group)
4314 "Create a new, fresh, empty virtual group."
4315 (interactive "sCreate new, empty virtual group: ")
4316 (let* ((method (list 'nnvirtual "^$"))
4317 (pgroup (gnus-group-prefixed-name group method)))
4318 ;; Check whether it exists already.
4319 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4320 (error "Group %s already exists." pgroup))
4321 ;; Subscribe the new group after the group on the current line.
4322 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4323 (gnus-group-update-group pgroup)
4325 (gnus-group-position-cursor)))
4327 (defun gnus-group-enter-directory (dir)
4328 "Enter an ephemeral nneething group."
4329 (interactive "DDirectory to read: ")
4330 (let* ((method (list 'nneething dir))
4331 (leaf (gnus-group-prefixed-name
4332 (file-name-nondirectory (directory-file-name dir))
4334 (name (gnus-generate-new-group-name leaf)))
4335 (let ((nneething-read-only t))
4336 (or (gnus-group-read-ephemeral-group
4338 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4340 (error "Couldn't enter %s" dir)))))
4342 ;; Group sorting commands
4343 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4345 (defun gnus-group-sort-groups ()
4346 "Sort the group buffer using `gnus-group-sort-function'."
4348 (setq gnus-newsrc-alist
4349 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4350 (gnus-make-hashtable-from-newsrc-alist)
4351 (gnus-group-list-groups))
4353 (defun gnus-group-sort-by-alphabet (info1 info2)
4354 (string< (car info1) (car info2)))
4356 (defun gnus-group-sort-by-unread (info1 info2)
4357 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4358 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4359 (< (or (and (numberp n1) n1) 0)
4360 (or (and (numberp n2) n2) 0))))
4362 (defun gnus-group-sort-by-level (info1 info2)
4363 (< (nth 1 info1) (nth 1 info2)))
4365 ;; Group catching up.
4367 (defun gnus-group-catchup-current (&optional n all)
4368 "Mark all articles not marked as unread in current newsgroup as read.
4369 If prefix argument N is numeric, the ARG next newsgroups will be
4370 caught up. If ALL is non-nil, marked articles will also be marked as
4371 read. Cross references (Xref: header) of articles are ignored.
4372 The difference between N and actual number of newsgroups that were
4373 caught up is returned."
4375 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4379 "Do you really want to mark all articles as read? "
4380 "Mark all unread articles as read? "))))
4382 (let ((groups (gnus-group-process-prefix n))
4385 ;; Virtual groups have to be given special treatment.
4386 (let ((method (gnus-find-method-for-group (car groups))))
4387 (if (eq 'nnvirtual (car method))
4388 (nnvirtual-catchup-group
4389 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4390 (gnus-group-remove-mark (car groups))
4392 (gnus-group-goto-group (car groups))
4393 (gnus-group-catchup (car groups) all))
4394 (gnus-group-update-group-line)
4395 (setq ret (1+ ret)))
4396 (setq groups (cdr groups)))
4397 (gnus-group-next-unread-group 1)
4400 (defun gnus-group-catchup-current-all (&optional n)
4401 "Mark all articles in current newsgroup as read.
4402 Cross references (Xref: header) of articles are ignored."
4404 (gnus-group-catchup-current n 'all))
4406 (defun gnus-group-catchup (group &optional all)
4407 "Mark all articles in GROUP as read.
4408 If ALL is non-nil, all articles are marked as read.
4409 The return value is the number of articles that were marked as read,
4410 or nil if no action could be taken."
4411 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4413 (marked (nth 3 (nth 2 entry))))
4414 (if (not (numberp (car entry)))
4415 (gnus-message 1 "Can't catch up; non-active group")
4416 ;; Do the updating only if the newsgroup isn't killed.
4419 (gnus-update-read-articles
4420 group (and (not all) (append (cdr (assq 'tick marked))
4421 (cdr (assq 'dormant marked))))
4422 nil (and (not all) (cdr (assq 'tick marked))))
4424 (setq marked (nth 3 (nth 2 entry)))
4425 (setcar (nthcdr 3 (nth 2 entry))
4426 (delq (assq 'dormant marked)
4427 (nth 3 (nth 2 entry)))))))
4430 (defun gnus-group-expire-articles (&optional n)
4431 "Expire all expirable articles in the current newsgroup."
4433 (let ((groups (gnus-group-process-prefix n))
4435 (or groups (error "No groups to expire"))
4437 (setq group (car groups)
4438 groups (cdr groups))
4439 (gnus-group-remove-mark group)
4440 (if (not (gnus-check-backend-function 'request-expire-articles group))
4442 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4443 (expirable (if (memq 'total-expire (nth 5 info))
4444 (cons nil (gnus-list-of-read-articles group))
4445 (assq 'expire (nth 3 info)))))
4448 (gnus-request-expire-articles
4449 (cdr expirable) group))))))))
4451 (defun gnus-group-expire-all-groups ()
4452 "Expire all expirable articles in all newsgroups."
4455 (gnus-message 5 "Expiring...")
4456 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4457 (cdr gnus-newsrc-alist))))
4458 (gnus-group-expire-articles nil)))
4459 (gnus-group-position-cursor)
4460 (gnus-message 5 "Expiring...done"))
4462 (defun gnus-group-set-current-level (n level)
4463 "Set the level of the next N groups to LEVEL."
4464 (interactive "P\nnLevel: ")
4465 (or (and (>= level 1) (<= level gnus-level-killed))
4466 (error "Illegal level: %d" level))
4467 (let ((groups (gnus-group-process-prefix n))
4470 (setq group (car groups)
4471 groups (cdr groups))
4472 (gnus-group-remove-mark group)
4473 (gnus-message 6 "Changed level of %s from %d to %d"
4474 group (gnus-group-group-level) level)
4475 (gnus-group-change-level group level
4476 (gnus-group-group-level))
4477 (gnus-group-update-group-line)))
4478 (gnus-group-position-cursor))
4480 (defun gnus-group-unsubscribe-current-group (&optional n)
4481 "Toggle subscription of the current group.
4482 If given numerical prefix, toggle the N next groups."
4484 (let ((groups (gnus-group-process-prefix n))
4487 (setq group (car groups)
4488 groups (cdr groups))
4489 (gnus-group-remove-mark group)
4490 (gnus-group-unsubscribe-group
4491 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4492 gnus-level-default-unsubscribed
4493 gnus-level-default-subscribed))
4494 (gnus-group-update-group-line))
4495 (gnus-group-next-group 1)))
4497 (defun gnus-group-unsubscribe-group (group &optional level)
4498 "Toggle subscribe from/to unsubscribe GROUP.
4499 New newsgroup is added to .newsrc automatically."
4501 (list (completing-read
4502 "Group: " gnus-active-hashtb nil
4503 (memq gnus-select-method gnus-have-read-active-file))))
4504 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4506 ;; Toggle subscription flag.
4507 (gnus-group-change-level
4508 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4509 gnus-level-subscribed)
4510 (1+ gnus-level-subscribed)
4511 gnus-level-default-subscribed)))
4512 (gnus-group-update-group group))
4513 ((and (stringp group)
4514 (or (not (memq gnus-select-method gnus-have-read-active-file))
4515 (gnus-gethash group gnus-active-hashtb)))
4516 ;; Add new newsgroup.
4517 (gnus-group-change-level
4519 (if level level gnus-level-default-subscribed)
4520 (or (and (member group gnus-zombie-list)
4523 (and (gnus-group-group-name)
4524 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4525 (gnus-group-update-group group))
4526 (t (error "No such newsgroup: %s" group)))
4527 (gnus-group-position-cursor)))
4529 (defun gnus-group-transpose-groups (n)
4530 "Move the current newsgroup up N places.
4531 If given a negative prefix, move down instead. The difference between
4532 N and the number of steps taken is returned."
4534 (or (gnus-group-group-name)
4535 (error "No group on current line"))
4536 (gnus-group-kill-group 1)
4538 (forward-line (- n))
4539 (gnus-group-yank-group)
4540 (gnus-group-position-cursor)))
4542 (defun gnus-group-kill-all-zombies ()
4543 "Kill all zombie newsgroups."
4545 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4546 (setq gnus-zombie-list nil)
4547 (gnus-group-list-groups))
4549 (defun gnus-group-kill-region (begin end)
4550 "Kill newsgroups in current region (excluding current point).
4551 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4566 (beginning-of-line) ;Important when LINES < 1
4567 (gnus-group-kill-group lines)))
4569 (defun gnus-group-kill-group (&optional n)
4570 "The the next N groups.
4571 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4572 However, only groups that were alive can be yanked; already killed
4573 groups or zombie groups can't be yanked.
4574 The return value is the name of the (last) group that was killed."
4576 (let ((buffer-read-only nil)
4577 (groups (gnus-group-process-prefix n))
4580 (setq group (car groups)
4581 groups (cdr groups))
4582 (gnus-group-remove-mark group)
4583 (setq level (gnus-group-group-level))
4585 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4586 (setq gnus-list-of-killed-groups
4587 (cons (cons (car entry) (nth 2 entry))
4588 gnus-list-of-killed-groups)))
4589 (gnus-group-change-level
4590 (if entry entry group) gnus-level-killed (if entry nil level)))
4591 (gnus-group-position-cursor)
4594 (defun gnus-group-yank-group (&optional arg)
4595 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4596 inserting it before the current newsgroup. The numeric ARG specifies
4597 how many newsgroups are to be yanked. The name of the (last)
4598 newsgroup yanked is returned."
4600 (if (not arg) (setq arg 1))
4601 (let (info group prev)
4602 (while (>= (setq arg (1- arg)) 0)
4603 (if (not (setq info (car gnus-list-of-killed-groups)))
4604 (error "No more newsgroups to yank"))
4605 (setq group (nth 2 info))
4606 ;; Find which newsgroup to insert this one before - search
4607 ;; backward until something suitable is found. If there are no
4608 ;; other newsgroups in this buffer, just make this newsgroup the
4610 (setq prev (gnus-group-group-name))
4611 (gnus-group-change-level
4612 info (nth 2 info) gnus-level-killed
4613 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4615 (gnus-group-insert-group-line-info (nth 1 info))
4616 (setq gnus-list-of-killed-groups
4617 (cdr gnus-list-of-killed-groups)))
4619 (gnus-group-position-cursor)
4622 (defun gnus-group-list-all-groups (&optional arg)
4623 "List all newsgroups with level ARG or lower.
4624 Default is gnus-level-unsubscribed, which lists all subscribed and most
4625 unsubscribed groups."
4627 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4629 (defun gnus-group-list-killed ()
4630 "List all killed newsgroups in the group buffer."
4632 (if (not gnus-killed-list)
4633 (gnus-message 6 "No killed groups")
4634 (let (gnus-group-list-mode)
4635 (funcall gnus-group-prepare-function
4636 gnus-level-killed t gnus-level-killed))
4637 (goto-char (point-min)))
4638 (gnus-group-position-cursor))
4640 (defun gnus-group-list-zombies ()
4641 "List all zombie newsgroups in the group buffer."
4643 (if (not gnus-zombie-list)
4644 (gnus-message 6 "No zombie groups")
4645 (let (gnus-group-list-mode)
4646 (funcall gnus-group-prepare-function
4647 gnus-level-zombie t gnus-level-zombie))
4648 (goto-char (point-min)))
4649 (gnus-group-position-cursor))
4651 (defun gnus-group-get-new-news (&optional arg)
4652 "Get newly arrived articles.
4653 If ARG is non-nil, it should be a number between one and nine to
4654 specify which levels you are interested in re-scanning."
4656 (run-hooks 'gnus-get-new-news-hook)
4657 (setq arg (gnus-group-default-level arg t))
4658 (if (and gnus-read-active-file (not arg))
4660 (gnus-read-active-file)
4661 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4662 (let ((gnus-read-active-file (not arg))
4663 (gnus-have-read-active-file
4664 (and (not arg) gnus-have-read-active-file)))
4665 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4666 (gnus-group-list-groups))
4668 (defun gnus-group-get-new-news-this-group (&optional n)
4669 "Check for newly arrived news in the current group (and the N-1 next groups).
4670 The difference between N and the number of newsgroup checked is returned.
4671 If N is negative, this group and the N-1 previous groups will be checked."
4673 (let* ((groups (gnus-group-process-prefix n))
4674 (ret (if (numberp n) (- n (length groups)) 0))
4677 (setq group (car groups)
4678 groups (cdr groups))
4679 (gnus-group-remove-mark group)
4680 (or (gnus-get-new-news-in-group group)
4683 (message "%s error: %s" group (gnus-status-message group))
4685 (gnus-group-next-unread-group 1 t)
4686 (gnus-summary-position-cursor)
4689 (defun gnus-get-new-news-in-group (group)
4691 (gnus-activate-group group)
4693 (gnus-get-unread-articles-in-group
4694 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4695 (gnus-gethash group gnus-active-hashtb))
4696 (gnus-group-update-group-line)
4699 (defun gnus-group-fetch-faq (group)
4700 "Fetch the FAQ for the current group."
4701 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4702 (or group (error "No group name given"))
4703 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group))))
4704 (if (not (file-exists-p file))
4705 (error "No such file: %s" file)
4708 (defun gnus-group-describe-group (force &optional group)
4709 "Display a description of the current newsgroup."
4710 (interactive (list current-prefix-arg (gnus-group-group-name)))
4711 (and force (setq gnus-description-hashtb nil))
4712 (let ((method (gnus-find-method-for-group group))
4714 (or group (error "No group name given"))
4715 (and (or (and gnus-description-hashtb
4716 ;; We check whether this group's method has been
4717 ;; queried for a description file.
4719 (gnus-group-prefixed-name "" method)
4720 gnus-description-hashtb))
4721 (setq desc (gnus-group-get-description group))
4722 (gnus-read-descriptions-file method))
4724 (or desc (gnus-gethash group gnus-description-hashtb)
4725 "No description available")))))
4727 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4728 (defun gnus-group-describe-all-groups (&optional force)
4729 "Pop up a buffer with descriptions of all newsgroups."
4731 (and force (setq gnus-description-hashtb nil))
4732 (if (not (or gnus-description-hashtb
4733 (gnus-read-all-descriptions-files)))
4734 (error "Couldn't request descriptions file"))
4735 (let ((buffer-read-only nil)
4741 (insert (format " *: %-20s %s\n" (symbol-name group)
4742 (symbol-value group)))
4743 (add-text-properties
4744 b (1+ b) (list 'gnus-group group
4745 'gnus-unread t 'gnus-marked nil
4746 'gnus-level (1+ gnus-level-subscribed))))
4747 gnus-description-hashtb)
4748 (goto-char (point-min))
4749 (gnus-group-position-cursor)))
4751 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4752 (defun gnus-group-apropos (regexp &optional search-description)
4753 "List all newsgroups that have names that match a regexp."
4754 (interactive "sGnus apropos (regexp): ")
4756 (obuf (current-buffer))
4758 ;; Go through all newsgroups that are known to Gnus.
4761 (and (symbol-name group)
4762 (string-match regexp (symbol-name group))
4763 (setq groups (cons (symbol-name group) groups))))
4765 ;; Go through all descriptions that are known to Gnus.
4766 (if search-description
4769 (and (string-match regexp (symbol-value group))
4770 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4771 (setq groups (cons (symbol-name group) groups))))
4772 gnus-description-hashtb))
4774 (gnus-message 3 "No groups matched \"%s\"." regexp)
4775 ;; Print out all the groups.
4777 (pop-to-buffer "*Gnus Help*")
4778 (buffer-disable-undo (current-buffer))
4780 (setq groups (sort groups 'string<))
4782 ;; Groups may be entered twice into the list of groups.
4783 (if (not (string= (car groups) prev))
4785 (insert (setq prev (car groups)) "\n")
4786 (if (and gnus-description-hashtb
4787 (setq des (gnus-gethash (car groups)
4788 gnus-description-hashtb)))
4789 (insert " " des "\n"))))
4790 (setq groups (cdr groups)))
4791 (goto-char (point-min))))
4792 (pop-to-buffer obuf)))
4794 (defun gnus-group-description-apropos (regexp)
4795 "List all newsgroups that have names or descriptions that match a regexp."
4796 (interactive "sGnus description apropos (regexp): ")
4797 (if (not (or gnus-description-hashtb
4798 (gnus-read-all-descriptions-files)))
4799 (error "Couldn't request descriptions file"))
4800 (gnus-group-apropos regexp t))
4802 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4803 (defun gnus-group-list-matching (level regexp &optional all lowest)
4804 "List all groups with unread articles that match REGEXP.
4805 If the prefix LEVEL is non-nil, it should be a number that says which
4806 level to cut off listing groups.
4807 If ALL, also list groups with no unread articles.
4808 If LOWEST, don't list groups with level lower than LOWEST."
4809 (interactive "P\nsList newsgroups matching: ")
4810 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4811 all (or lowest 1) regexp)
4812 (goto-char (point-min))
4813 (gnus-group-position-cursor))
4815 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4816 "List all groups that match REGEXP.
4817 If the prefix LEVEL is non-nil, it should be a number that says which
4818 level to cut off listing groups.
4819 If LOWEST, don't list groups with level lower than LOWEST."
4820 (interactive "P\nsList newsgroups matching: ")
4821 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4823 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4824 (defun gnus-group-save-newsrc ()
4825 "Save the Gnus startup files."
4827 (gnus-save-newsrc-file))
4829 (defun gnus-group-restart (&optional arg)
4830 "Force Gnus to read the .newsrc file."
4832 (gnus-save-newsrc-file)
4833 (gnus-setup-news 'force)
4834 (gnus-group-list-groups arg))
4836 (defun gnus-group-read-init-file ()
4837 "Read the Gnus elisp init file."
4839 (gnus-read-init-file))
4841 (defun gnus-group-check-bogus-groups (&optional silent)
4842 "Check bogus newsgroups.
4843 If given a prefix, don't ask for confirmation before removing a bogus
4846 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4847 (gnus-group-list-groups))
4849 (defun gnus-group-edit-global-kill (&optional article group)
4850 "Edit the global kill file.
4851 If GROUP, edit that local kill file instead."
4853 (setq gnus-current-kill-article article)
4854 (gnus-kill-file-edit-file group)
4856 (substitute-command-keys
4857 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4859 (defun gnus-group-edit-local-kill (article group)
4860 "Edit a local kill file."
4861 (interactive (list nil (gnus-group-group-name)))
4862 (gnus-group-edit-global-kill article group))
4864 (defun gnus-group-force-update ()
4865 "Update `.newsrc' file."
4867 (gnus-save-newsrc-file))
4869 (defun gnus-group-suspend ()
4870 "Suspend the current Gnus session.
4871 In fact, cleanup buffers except for group mode buffer.
4872 The hook gnus-suspend-gnus-hook is called before actually suspending."
4874 (run-hooks 'gnus-suspend-gnus-hook)
4875 ;; Kill Gnus buffers except for group mode buffer.
4876 (let ((group-buf (get-buffer gnus-group-buffer)))
4877 ;; Do this on a separate list in case the user does a ^G before we finish
4878 (let ((gnus-buffer-list
4879 (delq group-buf (delq gnus-dribble-buffer
4880 (append gnus-buffer-list nil)))))
4881 (while gnus-buffer-list
4882 (gnus-kill-buffer (car gnus-buffer-list))
4883 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4886 (setq gnus-buffer-list (list group-buf))
4887 (bury-buffer group-buf)
4888 (delete-windows-on group-buf t)))))
4890 (defun gnus-group-clear-dribble ()
4891 "Clear all information from the dribble buffer."
4893 (gnus-dribble-clear))
4895 (defun gnus-group-exit ()
4896 "Quit reading news after updating .newsrc.eld and .newsrc.
4897 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4899 (if (or noninteractive ;For gnus-batch-kill
4900 (zerop (buffer-size)) ;No news is good news.
4901 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4902 (not gnus-interactive-exit) ;Without confirmation
4904 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4906 (run-hooks 'gnus-exit-gnus-hook)
4907 ;; Offer to save data from non-quitted summary buffers.
4908 (gnus-offer-save-summaries)
4909 ;; Save the newsrc file(s).
4910 (gnus-save-newsrc-file)
4912 (gnus-close-backends)
4913 ;; Reset everything.
4914 (gnus-clear-system))))
4916 (defun gnus-close-backends ()
4917 ;; Send a close request to all backends that support such a request.
4918 (let ((methods gnus-valid-select-methods)
4921 (if (fboundp (setq func (intern (concat (car (car methods))
4922 "-request-close"))))
4924 (setq methods (cdr methods)))))
4926 (defun gnus-group-quit ()
4927 "Quit reading news without updating .newsrc.eld or .newsrc.
4928 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4930 (if (or noninteractive ;For gnus-batch-kill
4931 (zerop (buffer-size))
4932 (not (gnus-server-opened gnus-select-method))
4934 (not gnus-current-startup-file)
4936 (format "Quit reading news without saving %s? "
4937 (file-name-nondirectory gnus-current-startup-file))))
4939 (run-hooks 'gnus-exit-gnus-hook)
4940 (if gnus-use-full-window
4941 (delete-other-windows)
4942 (gnus-remove-some-windows))
4944 (gnus-close-backends)
4945 (gnus-clear-system))))
4947 (defun gnus-offer-save-summaries ()
4949 (let ((buflist (buffer-list))
4952 (and (setq bufname (buffer-name (car buflist)))
4953 (string-match "Summary" bufname)
4955 (set-buffer bufname)
4956 ;; We check that this is, indeed, a summary buffer.
4957 (eq major-mode 'gnus-summary-mode))
4958 (setq buffers (cons bufname buffers)))
4959 (setq buflist (cdr buflist)))
4962 "Update summary buffer %s? "
4965 (gnus-summary-exit))
4968 (defun gnus-group-describe-briefly ()
4969 "Give a one line description of the group mode commands."
4971 (gnus-message 7 (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-read-group]:Select \\[gnus-group-next-unread-group]:Forward \\[gnus-group-prev-unread-group]:Backward \\[gnus-group-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-group-describe-briefly]:This help")))
4973 (defun gnus-group-browse-foreign-server (method)
4974 "Browse a foreign news server.
4975 If called interactively, this function will ask for a select method
4976 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4977 If not, METHOD should be a list where the first element is the method
4978 and the second element is the address."
4980 (list (let ((how (completing-read
4982 (append gnus-valid-select-methods gnus-server-alist)
4984 ;; We either got a backend name or a virtual server name.
4985 ;; If the first, we also need an address.
4986 (if (assoc how gnus-valid-select-methods)
4988 ;; Suggested by mapjph@bath.ac.uk.
4991 (mapcar (lambda (server) (list server))
4992 gnus-secondary-servers)))
4993 ;; We got a server name, so we find the method.
4994 (gnus-server-to-method how)))))
4995 (gnus-browse-foreign-server method))
4999 ;;; Browse Server Mode
5002 (defvar gnus-browse-mode-hook nil)
5003 (defvar gnus-browse-mode-map nil)
5004 (put 'gnus-browse-mode 'mode-class 'special)
5006 (if gnus-browse-mode-map
5008 (setq gnus-browse-mode-map (make-keymap))
5009 (suppress-keymap gnus-browse-mode-map)
5010 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5011 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5012 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5013 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5014 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5015 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5016 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5017 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5018 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5019 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5020 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5021 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5022 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5023 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5024 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5025 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5026 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5027 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5030 (defvar gnus-browse-current-method nil)
5031 (defvar gnus-browse-return-buffer nil)
5033 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5035 (defun gnus-browse-foreign-server (method &optional return-buffer)
5036 (setq gnus-browse-current-method method)
5037 (setq gnus-browse-return-buffer return-buffer)
5038 (let ((gnus-select-method method)
5040 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5041 (or (gnus-check-server method)
5042 (error "Unable to contact server: %s" (gnus-status-message method)))
5043 (or (gnus-request-list method)
5044 (error "Couldn't request list: %s" (gnus-status-message method)))
5045 (get-buffer-create gnus-browse-buffer)
5046 (gnus-add-current-to-buffer-list)
5047 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5048 (gnus-configure-windows 'browse)
5049 (buffer-disable-undo (current-buffer))
5050 (let ((buffer-read-only nil))
5053 (setq mode-line-buffer-identification
5055 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5057 (set-buffer nntp-server-buffer)
5058 (let ((cur (current-buffer)))
5059 (goto-char (point-min))
5060 (or (string= gnus-ignored-newsgroups "")
5061 (delete-matching-lines gnus-ignored-newsgroups))
5062 (while (re-search-forward
5063 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5064 (goto-char (match-end 1))
5065 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5067 (max 0 (- (1+ (read cur)) (read cur))))
5069 (setq groups (sort groups
5071 (string< (car l1) (car l2)))))
5072 (let ((buffer-read-only nil))
5074 (setq group (car groups))
5076 (format "K%7d: %s\n" (cdr group) (car group)))
5077 (setq groups (cdr groups))))
5078 (switch-to-buffer (current-buffer))
5079 (goto-char (point-min))
5080 (gnus-group-position-cursor)))
5082 (defun gnus-browse-mode ()
5083 "Major mode for browsing a foreign server.
5085 All normal editing commands are switched off.
5087 \\<gnus-browse-mode-map>
5088 The only things you can do in this buffer is
5090 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5091 The group will be inserted into the group buffer upon exit from this
5094 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5096 3) `\\[gnus-browse-exit]' to return to the group buffer."
5098 (kill-all-local-variables)
5099 (if gnus-visual (gnus-browse-make-menu-bar))
5100 (setq mode-line-modified "-- ")
5101 (make-local-variable 'mode-line-format)
5102 (setq mode-line-format (copy-sequence mode-line-format))
5103 (and (equal (nth 3 mode-line-format) " ")
5104 (setcar (nthcdr 3 mode-line-format) ""))
5105 (setq major-mode 'gnus-browse-mode)
5106 (setq mode-name "Browse Server")
5107 (setq mode-line-process nil)
5108 (use-local-map gnus-browse-mode-map)
5109 (buffer-disable-undo (current-buffer))
5110 (setq truncate-lines t)
5111 (setq buffer-read-only t)
5112 (run-hooks 'gnus-browse-mode-hook))
5114 (defun gnus-browse-read-group (&optional no-article)
5115 "Enter the group at the current line."
5117 (let ((group (gnus-browse-group-name)))
5118 (or (gnus-group-read-ephemeral-group
5119 group gnus-browse-current-method nil
5120 (cons (current-buffer) 'browse))
5121 (error "Couldn't enter %s" group))))
5123 (defun gnus-browse-select-group ()
5124 "Select the current group."
5126 (gnus-browse-read-group 'no))
5128 (defun gnus-browse-next-group (n)
5129 "Go to the next group."
5133 (gnus-group-position-cursor)))
5135 (defun gnus-browse-prev-group (n)
5136 "Go to the next group."
5138 (gnus-browse-next-group (- n)))
5140 (defun gnus-browse-unsubscribe-current-group (arg)
5141 "(Un)subscribe to the next ARG groups."
5144 (error "No group at current line."))
5145 (let ((ward (if (< arg 0) -1 1))
5147 (while (and (> arg 0)
5149 (gnus-browse-unsubscribe-group)
5150 (zerop (gnus-browse-next-group ward)))
5151 (setq arg (1- arg)))
5152 (gnus-group-position-cursor)
5153 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5156 (defun gnus-browse-group-name ()
5159 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5161 (gnus-group-prefixed-name
5162 (buffer-substring (match-beginning 1) (match-end 1))
5163 gnus-browse-current-method))))
5165 (defun gnus-browse-unsubscribe-group ()
5167 (buffer-read-only nil)
5171 (if (= (following-char) ?K) (setq sub t))
5172 (setq group (gnus-browse-group-name))
5177 (gnus-group-change-level
5178 (list t group gnus-level-default-subscribed
5179 nil nil gnus-browse-current-method)
5180 gnus-level-default-subscribed gnus-level-killed
5181 (and (car (nth 1 gnus-newsrc-alist))
5182 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5183 gnus-newsrc-hashtb))
5186 (gnus-group-change-level
5187 group gnus-level-killed gnus-level-default-subscribed)
5191 (defun gnus-browse-exit ()
5192 "Quit browsing and return to the group buffer."
5194 (if (eq major-mode 'gnus-browse-mode)
5195 (kill-buffer (current-buffer)))
5196 (if gnus-browse-return-buffer
5197 (gnus-configure-windows 'server 'force)
5198 (gnus-configure-windows 'group 'force)
5199 (gnus-group-list-groups nil)))
5201 (defun gnus-browse-describe-briefly ()
5202 "Give a one line description of the group mode commands."
5205 (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")))
5209 ;;; Gnus summary mode
5212 (defvar gnus-summary-mode-map nil)
5213 (defvar gnus-summary-mark-map nil)
5214 (defvar gnus-summary-mscore-map nil)
5215 (defvar gnus-summary-article-map nil)
5216 (defvar gnus-summary-thread-map nil)
5217 (defvar gnus-summary-goto-map nil)
5218 (defvar gnus-summary-exit-map nil)
5219 (defvar gnus-summary-interest-map nil)
5220 (defvar gnus-summary-sort-map nil)
5221 (defvar gnus-summary-backend-map nil)
5222 (defvar gnus-summary-save-map nil)
5223 (defvar gnus-summary-wash-map nil)
5224 (defvar gnus-summary-wash-hide-map nil)
5225 (defvar gnus-summary-wash-highlight-map nil)
5226 (defvar gnus-summary-wash-time-map nil)
5227 (defvar gnus-summary-help-map nil)
5229 (put 'gnus-summary-mode 'mode-class 'special)
5231 (if gnus-summary-mode-map
5233 (setq gnus-summary-mode-map (make-keymap))
5234 (suppress-keymap gnus-summary-mode-map)
5236 ;; Non-orthogonal keys
5238 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5239 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5240 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5241 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5242 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5243 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5244 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5245 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5246 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5247 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5248 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5249 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5250 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5251 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5252 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5253 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5254 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5255 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5256 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5257 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5258 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5259 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5260 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5261 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5262 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5263 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5264 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5265 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5266 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5267 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5268 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5269 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5270 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5271 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5272 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5273 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5274 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5275 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5276 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5277 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5278 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5279 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5280 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5281 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5282 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5283 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5284 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5285 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5286 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5287 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5288 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5289 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5290 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5291 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5292 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5293 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5294 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5295 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5296 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5297 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5298 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5299 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5300 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5301 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5302 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5303 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5304 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5305 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5306 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5307 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5308 (define-key gnus-summary-mode-map "V" 'gnus-version)
5309 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5310 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5311 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5312 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5313 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5314 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5315 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5316 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5317 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5318 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5319 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5320 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5321 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5322 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5323 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5324 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5325 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5326 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5329 ;; Sort of orthogonal keymap
5330 (define-prefix-command 'gnus-summary-mark-map)
5331 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5332 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5333 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5334 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5335 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5336 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5337 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5338 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5339 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5340 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5341 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5342 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5343 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5344 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5345 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5346 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5347 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5348 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5349 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5350 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5351 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5352 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5353 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5354 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5356 (define-prefix-command 'gnus-summary-mscore-map)
5357 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5358 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5359 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5360 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5361 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5363 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5365 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5367 (define-prefix-command 'gnus-summary-goto-map)
5368 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5369 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5370 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5371 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5372 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5373 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5374 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5375 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5376 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5377 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5378 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5379 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5380 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5381 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5384 (define-prefix-command 'gnus-summary-thread-map)
5385 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5386 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5387 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5388 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5389 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5390 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5391 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5392 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5393 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5394 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5395 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5396 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5397 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5398 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5401 (define-prefix-command 'gnus-summary-exit-map)
5402 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5403 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5404 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5405 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5406 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5407 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5408 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5409 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5410 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5411 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5412 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5415 (define-prefix-command 'gnus-summary-article-map)
5416 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5417 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5418 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5419 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5420 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5421 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5422 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5423 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5424 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5425 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5426 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5427 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5428 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5429 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5433 (define-prefix-command 'gnus-summary-wash-map)
5434 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5436 (define-prefix-command 'gnus-summary-wash-hide-map)
5437 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5438 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5439 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5440 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5441 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5442 (define-key gnus-summary-wash-hide-map "\C-c" 'gnus-article-hide-citation-maybe)
5444 (define-prefix-command 'gnus-summary-wash-highlight-map)
5445 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5446 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5447 (define-key gnus-summary-wash-highlight-map "h" 'gnus-article-highlight-headers)
5448 (define-key gnus-summary-wash-highlight-map "c" 'gnus-article-highlight-citation)
5449 (define-key gnus-summary-wash-highlight-map "s" 'gnus-article-highlight-signature)
5451 (define-prefix-command 'gnus-summary-wash-time-map)
5452 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5453 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5454 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5455 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5456 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5458 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5459 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5460 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5461 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5462 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5463 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5464 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5465 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5466 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5467 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5470 (define-prefix-command 'gnus-summary-help-map)
5471 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5472 (define-key gnus-summary-help-map "v" 'gnus-version)
5473 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5474 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5475 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5476 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5479 (define-prefix-command 'gnus-summary-backend-map)
5480 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5481 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5482 (define-key gnus-summary-backend-map "\M-\C-e"
5483 'gnus-summary-expire-articles-now)
5484 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5485 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5486 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5487 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5488 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5489 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5490 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5493 (define-prefix-command 'gnus-summary-save-map)
5494 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5495 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5496 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5497 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5498 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5499 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5500 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5501 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5502 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5504 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5506 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5507 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5508 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5509 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5510 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5511 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5512 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5513 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5514 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5515 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5517 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5519 ; (define-prefix-command 'gnus-summary-sort-map)
5520 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5521 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5522 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5523 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5524 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5525 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5527 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5528 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5534 (defun gnus-summary-mode (&optional group)
5535 "Major mode for reading articles.
5537 All normal editing commands are switched off.
5538 \\<gnus-summary-mode-map>
5539 Each line in this buffer represents one article. To read an
5540 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5541 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5544 You can also post articles and send mail from this buffer. To
5545 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5546 of an article, type `\\[gnus-summary-reply]'.
5548 There are approx. one gazillion commands you can execute in this
5549 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5551 The following commands are available:
5553 \\{gnus-summary-mode-map}"
5555 (if gnus-visual (gnus-summary-make-menu-bar))
5556 (kill-all-local-variables)
5557 (let ((locals gnus-summary-local-variables))
5559 (if (consp (car locals))
5561 (make-local-variable (car (car locals)))
5562 (set (car (car locals)) (eval (cdr (car locals)))))
5563 (make-local-variable (car locals))
5564 (set (car locals) nil))
5565 (setq locals (cdr locals))))
5566 (gnus-make-thread-indent-array)
5567 (setq mode-line-modified "-- ")
5568 (make-local-variable 'mode-line-format)
5569 (setq mode-line-format (copy-sequence mode-line-format))
5570 (and (equal (nth 3 mode-line-format) " ")
5571 (setcar (nthcdr 3 mode-line-format) ""))
5572 (setq major-mode 'gnus-summary-mode)
5573 (setq mode-name "Summary")
5574 (make-local-variable 'minor-mode-alist)
5575 (use-local-map gnus-summary-mode-map)
5576 (buffer-disable-undo (current-buffer))
5577 (setq buffer-read-only t) ;Disable modification
5578 (setq truncate-lines t)
5579 (setq selective-display t)
5580 (setq selective-display-ellipses t) ;Display `...'
5581 (setq buffer-display-table gnus-summary-display-table)
5582 (setq gnus-newsgroup-name group)
5583 (run-hooks 'gnus-summary-mode-hook))
5585 (defun gnus-summary-make-display-table ()
5586 ;; Change the display table. Odd characters have a tendency to mess
5587 ;; up nicely formatted displays - we make all possible glyphs
5588 ;; display only a single character.
5590 ;; We start from the standard display table, if any.
5591 (setq gnus-summary-display-table
5592 (or (copy-sequence standard-display-table)
5593 (make-display-table)))
5594 ;; Nix out all the control chars...
5596 (while (>= (setq i (1- i)) 0)
5597 (aset gnus-summary-display-table i [??])))
5598 ;; ... but not newline and cr, of course. (cr is necessary for the
5599 ;; selective display).
5600 (aset gnus-summary-display-table ?\n nil)
5601 (aset gnus-summary-display-table ?\r nil)
5602 ;; We nix out any glyphs over 126 that are not set already.
5604 (while (>= (setq i (1- i)) 127)
5605 ;; Only modify if the entry is nil.
5606 (or (aref gnus-summary-display-table i)
5607 (aset gnus-summary-display-table i [??])))))
5609 (defun gnus-summary-clear-local-variables ()
5610 (let ((locals gnus-summary-local-variables))
5612 (if (consp (car locals))
5613 (and (vectorp (car (car locals)))
5614 (set (car (car locals)) nil))
5615 (and (vectorp (car locals))
5616 (set (car locals) nil)))
5617 (setq locals (cdr locals)))))
5619 ;; Some summary mode macros.
5621 ;; Return a header specified by a NUMBER.
5622 (defun gnus-get-header-by-number (number)
5624 (set-buffer gnus-summary-buffer)
5625 (or gnus-newsgroup-headers-hashtb-by-number
5626 (gnus-make-headers-hashtable-by-number))
5627 (gnus-gethash (int-to-string number)
5628 gnus-newsgroup-headers-hashtb-by-number)))
5630 ;; Fast version of the function above.
5631 (defmacro gnus-get-header-by-num (number)
5632 (` (gnus-gethash (int-to-string (, number))
5633 gnus-newsgroup-headers-hashtb-by-number)))
5635 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5636 "Search for article forward.
5637 If UNREAD is non-nil, only unread articles are selected.
5638 If SUBJECT is non-nil, the article which has the same subject will be
5640 If BACKWARD is non-nil, the search will be performed backwards instead."
5641 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5643 (defmacro gnus-summary-search-backward (&optional unread subject)
5644 "Search for article backward.
5645 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5646 If 2nd optional argument SUBJECT is non-nil, the article which has
5647 the same subject will be searched for."
5648 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5650 (defmacro gnus-summary-article-number (&optional number-or-nil)
5651 "The article number of the article on the current line.
5652 If there isn's an article number here, then we return the current
5655 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5656 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5657 gnus-current-article)))
5659 (defmacro gnus-summary-thread-level ()
5660 "The thread level of the article on the current line."
5661 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5664 (defmacro gnus-summary-article-mark ()
5665 "The mark on the current line."
5666 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5668 (defun gnus-summary-subject-string ()
5669 "Return current subject string or nil if nothing."
5670 (let ((article (gnus-summary-article-number))
5673 (setq header (gnus-get-header-by-num article))
5675 (header-subject header))))
5677 ;; Various summary mode internalish functions.
5679 (defun gnus-mouse-pick-article (e)
5682 (gnus-summary-next-page nil t))
5684 (defun gnus-summary-setup-buffer (group)
5685 "Initialize summary buffer."
5686 (let ((buffer (concat "*Summary " group "*")))
5687 (if (get-buffer buffer)
5690 (not gnus-newsgroup-begin))
5691 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5692 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5693 (gnus-add-current-to-buffer-list)
5694 (gnus-summary-mode group)
5695 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5696 (setq gnus-newsgroup-name group)
5699 (defun gnus-set-global-variables ()
5700 ;; Set the global equivalents of the summary buffer-local variables
5701 ;; to the latest values they had. These reflect the summary buffer
5702 ;; that was in action when the last article was fetched.
5703 (if (eq major-mode 'gnus-summary-mode)
5705 (setq gnus-summary-buffer (current-buffer))
5706 (let ((name gnus-newsgroup-name)
5707 (marked gnus-newsgroup-marked)
5708 (unread gnus-newsgroup-unreads)
5709 (headers gnus-current-headers)
5710 (score-file gnus-current-score-file))
5712 (set-buffer gnus-group-buffer)
5713 (setq gnus-newsgroup-name name)
5714 (setq gnus-newsgroup-marked marked)
5715 (setq gnus-newsgroup-unreads unread)
5716 (setq gnus-current-headers headers)
5717 (setq gnus-current-score-file score-file))))))
5719 (defun gnus-summary-insert-dummy-line (sformat subject number)
5721 (setq sformat gnus-summary-dummy-line-format-spec))
5725 (insert (eval sformat))
5726 (add-text-properties
5728 (list 'gnus-number number
5729 'gnus-mark gnus-dummy-mark
5732 (defvar gnus-thread-indent-array nil)
5733 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5734 (defun gnus-make-thread-indent-array ()
5736 (if (and gnus-thread-indent-array
5737 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5739 (setq gnus-thread-indent-array (make-vector 201 "")
5740 gnus-thread-indent-array-level gnus-thread-indent-level)
5742 (aset gnus-thread-indent-array n
5743 (make-string (* n gnus-thread-indent-level) ? ))
5746 (defun gnus-summary-insert-line
5747 (sformat header level current unread replied expirable subject-or-nil
5748 &optional dummy score)
5749 (or sformat (setq sformat gnus-summary-line-format-spec))
5750 (let* ((indentation (aref gnus-thread-indent-array level))
5751 (lines (header-lines header))
5752 (score (or score gnus-summary-default-score 0))
5754 (if (or (null gnus-summary-default-score)
5755 (<= (abs (- score gnus-summary-default-score))
5756 gnus-summary-zcore-fuzz)) ?
5757 (if (< score gnus-summary-default-score)
5758 gnus-score-below-mark gnus-score-over-mark)))
5759 (replied (if replied gnus-replied-mark ? ))
5760 (from (header-from header))
5762 ((string-match "(.+)" from)
5763 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5764 ((string-match "<[^>]+> *$" from)
5765 (let ((beg (match-beginning 0)))
5766 (or (and (string-match "^\"[^\"]*\"" from)
5767 (substring from (1+ (match-beginning 0))
5768 (1- (match-end 0))))
5769 (substring from 0 beg))))
5771 (subject (header-subject header))
5772 (number (header-number header))
5773 (opening-bracket (if dummy ?\< ?\[))
5774 (closing-bracket (if dummy ?\> ?\]))
5775 (buffer-read-only nil)
5776 (b (progn (beginning-of-line) (point))))
5777 (or (numberp lines) (setq lines 0))
5778 (insert (eval sformat))
5779 (add-text-properties
5780 b (1+ b) (list 'gnus-number number
5781 'gnus-mark (or unread gnus-unread-mark)
5782 'gnus-level level))))
5784 (defun gnus-summary-update-line (&optional dont-update)
5785 ;; Update summary line after change.
5786 (or (not gnus-summary-default-score)
5787 gnus-summary-inhibit-highlight
5788 (let ((gnus-summary-inhibit-highlight t)
5789 (article (gnus-summary-article-number)))
5792 (if (and gnus-summary-mark-below
5793 (< (gnus-summary-article-score)
5794 gnus-summary-mark-below))
5795 (and (not (memq article gnus-newsgroup-marked))
5796 (not (memq article gnus-newsgroup-dormant))
5797 (memq article gnus-newsgroup-unreads)
5798 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5799 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5800 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5802 (run-hooks 'gnus-summary-update-hook))))))
5804 (defun gnus-summary-update-lines (&optional beg end)
5805 ;; Mark article as read (or not) by taking into account scores.
5806 (let ((beg (or beg (point-min)))
5807 (end (or end (point-max))))
5808 (if (or (not gnus-summary-default-score)
5809 gnus-summary-inhibit-highlight)
5811 (let ((gnus-summary-inhibit-highlight t)
5814 (set-buffer gnus-summary-buffer)
5817 (while (and (not (eobp)) (< (point) end))
5818 (if (and gnus-summary-mark-below
5820 (setq article (get-text-property
5821 (point) 'gnus-number))
5822 gnus-newsgroup-scored))
5823 gnus-summary-default-score 0)
5824 gnus-summary-mark-below))
5825 ;; We want to possibly mark it as read...
5826 (and (not (memq article gnus-newsgroup-marked))
5827 (not (memq article gnus-newsgroup-dormant))
5828 (memq article gnus-newsgroup-unreads)
5829 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5830 ;; We want to possibly mark it as unread.
5831 (and (eq (get-text-property (point) 'gnus-mark)
5832 gnus-low-score-mark)
5833 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5834 ;; Do the visual highlights at the same time.
5835 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5836 (forward-line 1)))))))
5838 (defvar gnus-tmp-gathered nil)
5840 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5841 ;; Sum up all elements (and sub-elements) in a list.
5843 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5844 (if (and (consp thread) (cdr thread))
5847 'gnus-summary-number-of-articles-in-thread
5851 (if (> number 1) gnus-not-empty-thread-mark
5852 gnus-empty-thread-mark)
5855 (defun gnus-summary-read-group
5856 (group &optional show-all no-article kill-buffer)
5857 "Start reading news in newsgroup GROUP.
5858 If SHOW-ALL is non-nil, already read articles are also listed.
5859 If NO-ARTICLE is non-nil, no article is selected initially."
5860 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5861 (let* ((new-group (gnus-summary-setup-buffer group))
5862 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5864 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5867 (gnus-set-global-variables)
5868 (gnus-kill-buffer kill-buffer)
5869 (gnus-configure-windows 'summary)
5870 (gnus-set-mode-line 'summary)
5871 (gnus-summary-position-cursor)
5875 (and (eq major-mode 'gnus-summary-mode)
5876 (not (equal (current-buffer) kill-buffer))
5878 (kill-buffer (current-buffer))
5879 (if (not quit-config)
5881 (set-buffer gnus-group-buffer)
5882 (gnus-group-jump-to-group group)
5883 (gnus-group-next-unread-group 1))
5884 (if (not (buffer-name (car quit-config)))
5885 (gnus-configure-windows 'group 'force)
5886 (set-buffer (car quit-config))
5887 (and (eq major-mode 'gnus-summary-mode)
5888 (gnus-set-global-variables))
5889 (gnus-configure-windows (cdr quit-config))))))
5890 (message "Can't select group")
5892 ((eq did-select 'quit)
5893 (and (eq major-mode 'gnus-summary-mode)
5894 (not (equal (current-buffer) kill-buffer))
5895 (kill-buffer (current-buffer)))
5896 (gnus-kill-buffer kill-buffer)
5897 (if (not quit-config)
5899 (set-buffer gnus-group-buffer)
5900 (gnus-group-jump-to-group group)
5901 (gnus-group-next-unread-group 1)
5902 (gnus-configure-windows 'group 'force))
5903 (if (not (buffer-name (car quit-config)))
5904 (gnus-configure-windows 'group 'force)
5905 (set-buffer (car quit-config))
5906 (and (eq major-mode 'gnus-summary-mode)
5907 (gnus-set-global-variables))
5908 (gnus-configure-windows (cdr quit-config))))
5911 (gnus-set-global-variables)
5912 ;; Save the active value in effect when the group was entered.
5913 (setq gnus-newsgroup-active
5915 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5916 ;; You can change the subjects in this hook.
5917 (run-hooks 'gnus-select-group-hook)
5918 ;; Do score processing.
5919 (and gnus-use-scoring (gnus-possibly-score-headers))
5920 (gnus-update-format-specifications)
5921 ;; Generate the summary buffer.
5922 (gnus-summary-prepare)
5923 ;; Create the header hashtb.
5924 (gnus-make-headers-hashtable-by-number)
5925 (if (zerop (buffer-size))
5926 (cond (gnus-newsgroup-dormant
5927 (gnus-summary-show-all-dormant))
5928 ((and gnus-newsgroup-scored show-all)
5929 (gnus-summary-show-all-expunged))))
5930 ;; Function `gnus-apply-kill-file' must be called in this hook.
5931 (run-hooks 'gnus-apply-kill-hook)
5932 (if (zerop (buffer-size))
5934 ;; This newsgroup is empty.
5935 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5936 (gnus-message 6 "No unread news")
5937 (gnus-kill-buffer kill-buffer)
5941 ;; (let ((gnus-summary-buffer kill-buffer))
5942 ;; (gnus-configure-windows 'group))))
5943 ;; Hide conversation thread subtrees. We cannot do this in
5944 ;; gnus-summary-prepare-hook since kill processing may not
5945 ;; work with hidden articles.
5946 (and gnus-show-threads
5947 gnus-thread-hide-subtree
5948 (gnus-summary-hide-all-threads))
5949 ;; Show first unread article if requested.
5950 (goto-char (point-min))
5951 (if (and (not no-article)
5952 gnus-auto-select-first
5953 (gnus-summary-first-unread-article))
5955 (gnus-configure-windows 'summary))
5956 (gnus-set-mode-line 'summary)
5957 (gnus-summary-position-cursor)
5958 ;; If in async mode, we send some info to the backend.
5959 (and gnus-newsgroup-async
5960 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5961 (gnus-request-asynchronous
5963 (if (and gnus-asynchronous-article-function
5964 (fboundp gnus-asynchronous-article-function))
5965 (funcall gnus-asynchronous-article-function
5966 gnus-newsgroup-threads)
5967 gnus-newsgroup-threads)))
5968 (gnus-kill-buffer kill-buffer)
5969 (if (not (get-buffer-window gnus-group-buffer))
5971 ;; gotta use windows, because recenter does wierd stuff if
5972 ;; the current buffer ain't the displayed window.
5973 (let ((owin (selected-window)))
5974 (select-window (get-buffer-window gnus-group-buffer))
5975 (and (gnus-group-goto-group group)
5977 (select-window owin))))
5980 (defun gnus-summary-prepare ()
5981 ;; Generate the summary buffer.
5982 (let ((buffer-read-only nil))
5984 (gnus-summary-prepare-threads
5985 (if gnus-show-threads
5986 (gnus-gather-threads
5988 (if (and gnus-summary-expunge-below
5989 (not gnus-fetch-old-headers))
5990 (gnus-make-threads-and-expunge)
5991 (gnus-make-threads))))
5992 gnus-newsgroup-headers)
5994 (gnus-summary-update-lines)
5995 ;; Remove the final newline.
5996 ;;(goto-char (point-max))
5998 ;; Call hooks for modifying summary buffer.
5999 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6000 (goto-char (point-min))
6001 (run-hooks 'gnus-summary-prepare-hook)))
6003 (defun gnus-gather-threads (threads)
6004 "Gather threads that have lost their roots."
6005 (if (not gnus-summary-make-false-root)
6007 (let ((hashtb (gnus-make-hashtable 1023))
6010 subject hthread whole-subject)
6013 (setq subject (header-subject (car (car threads)))))
6014 (if gnus-summary-gather-subject-limit
6015 (or (and (numberp gnus-summary-gather-subject-limit)
6016 (> (length subject) gnus-summary-gather-subject-limit)
6018 (substring subject 0
6019 gnus-summary-gather-subject-limit)))
6020 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6021 (setq subject (gnus-simplify-subject-fuzzy subject))))
6022 (setq subject (gnus-simplify-subject-re subject)))
6024 (gnus-gethash subject hashtb))
6026 (or (stringp (car (car hthread)))
6027 (setcar hthread (list whole-subject (car hthread))))
6028 (setcdr (car hthread) (nconc (cdr (car hthread))
6029 (list (car threads))))
6030 (setcdr prev (cdr threads))
6031 (setq threads prev))
6032 (gnus-sethash subject threads hashtb))
6034 (setq threads (cdr threads)))
6037 (defun gnus-make-threads ()
6038 ;; This function takes the dependencies already made by
6039 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6040 ;; through the dependecies in the hash table and finds all the
6041 ;; roots. Roots do not refer back to any valid articles.
6042 (gnus-message 6 "Threading...")
6043 (let (roots new-roots)
6044 (and gnus-fetch-old-headers
6045 (eq gnus-headers-retrieved-by 'nov)
6046 (gnus-build-old-threads))
6049 (if (not (car (symbol-value refs)))
6050 (setq roots (append (cdr (symbol-value refs)) roots))
6051 ;; Ok, these refer back to valid articles, but if
6052 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6053 ;; the root has the same subject as its children. The children
6054 ;; that do not are made into roots and removed from the list
6056 (or gnus-thread-ignore-subject
6057 (let* ((prev (symbol-value refs))
6058 (subject (gnus-simplify-subject-re
6059 (header-subject (car prev))))
6060 (headers (cdr prev)))
6062 (if (not (string= subject
6063 (gnus-simplify-subject-re
6064 (header-subject (car headers)))))
6066 (setq new-roots (cons (car headers) new-roots))
6067 (setcdr prev (cdr headers)))
6068 (setq prev headers))
6069 (setq headers (cdr headers)))))))
6070 gnus-newsgroup-dependencies)
6072 ;; We enter the new roots into the dependencies structure to
6073 ;; ensure that any possible later thread-regeneration will be
6075 (let ((r new-roots))
6077 (gnus-sethash (concat (header-id (car r)) ".boo")
6078 (list nil (car r)) gnus-newsgroup-dependencies)
6081 (setq roots (nconc new-roots roots))
6084 (mapcar 'gnus-trim-thread
6086 (mapcar 'gnus-cut-thread
6087 (mapcar 'gnus-make-sub-thread roots))))
6088 (gnus-message 6 "Threading...done"))))
6091 (defun gnus-make-threads-and-expunge ()
6092 ;; This function takes the dependencies already made by
6093 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6094 ;; through the dependecies in the hash table and finds all the
6095 ;; roots. Roots do not refer back to any valid articles.
6096 (gnus-message 6 "Threading...")
6097 (let ((default (or gnus-summary-default-score 0))
6098 (below gnus-summary-expunge-below)
6099 roots article new-roots)
6100 (and gnus-fetch-old-headers
6101 (eq gnus-headers-retrieved-by 'nov)
6102 (gnus-build-old-threads))
6105 (if (not (car (symbol-value refs)))
6106 ;; These articles do not refer back to any other articles -
6108 (let ((headers (cdr (symbol-value refs))))
6109 ;; We weed out the low-scored articles.
6111 (if (not (< (or (cdr (assq (header-number (car headers))
6112 gnus-newsgroup-scored)) default)
6115 (setq roots (cons (car headers) roots))
6116 ;; It is below, so we mark it as read.
6117 (setq gnus-newsgroup-unreads
6118 (delq (header-number (car headers))
6119 gnus-newsgroup-unreads))
6120 (setq gnus-newsgroup-reads
6121 (cons (cons (header-number (car headers))
6122 gnus-low-score-mark)
6123 gnus-newsgroup-reads)))
6124 (setq headers (cdr headers))))
6125 ;; Ok, these refer back to valid articles, but if
6126 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6127 ;; the root has the same subject as its children. The children
6128 ;; that do not are made into roots and removed from the list
6130 (or gnus-thread-ignore-subject
6131 (let* ((prev (symbol-value refs))
6132 (subject (gnus-simplify-subject-re
6133 (header-subject (car prev))))
6134 (headers (cdr prev)))
6136 (if (not (string= subject
6137 (gnus-simplify-subject-re
6138 (header-subject (car headers)))))
6140 (if (not (< (or (cdr (assq (header-number (car headers))
6141 gnus-newsgroup-scored))
6143 (setq new-roots (cons (car headers) new-roots))
6144 (setq gnus-newsgroup-unreads
6145 (delq (header-number (car headers))
6146 gnus-newsgroup-unreads))
6147 (setq gnus-newsgroup-reads
6148 (cons (cons (header-number (car headers))
6149 gnus-low-score-mark)
6150 gnus-newsgroup-reads)))
6151 (setcdr prev (cdr headers)))
6152 (setq prev headers))
6153 (setq headers (cdr headers)))))
6154 ;; If this article is expunged, some of the children might be
6156 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
6157 gnus-newsgroup-scored)) default)
6159 (let* ((prev (symbol-value refs))
6160 (headers (cdr prev)))
6162 (setq article (header-number (car headers)))
6163 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6165 (progn (setq new-roots (cons (car headers) new-roots))
6166 (setq prev headers))
6167 (setq gnus-newsgroup-unreads
6168 (delq article gnus-newsgroup-unreads))
6169 (setq gnus-newsgroup-reads
6170 (cons (cons article gnus-low-score-mark)
6171 gnus-newsgroup-reads))
6172 (setcdr prev (cdr headers)))
6173 (setq headers (cdr headers))))
6174 ;; It was not expunged, but we look at expunged children.
6175 (let* ((prev (symbol-value refs))
6176 (headers (cdr prev))
6179 (setq article (header-number (car headers)))
6180 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6183 (setq gnus-newsgroup-unreads
6184 (delq article gnus-newsgroup-unreads))
6185 (setq gnus-newsgroup-reads
6186 (cons (cons article gnus-low-score-mark)
6187 gnus-newsgroup-reads))
6188 (setcdr prev (cdr headers)))
6189 (setq headers (cdr headers)))))))
6190 gnus-newsgroup-dependencies)
6192 ;; We enter the new roots into the dependencies structure to
6193 ;; ensure that any possible later thread-regeneration will be
6195 (let ((r new-roots))
6197 (gnus-sethash (concat (header-id (car r)) ".boo")
6198 (list nil (car r)) gnus-newsgroup-dependencies)
6201 (setq roots (nconc new-roots roots))
6204 (mapcar 'gnus-trim-thread
6206 (mapcar 'gnus-cut-thread
6207 (mapcar 'gnus-make-sub-thread roots))))
6208 (gnus-message 6 "Threading...done"))))
6211 (defun gnus-cut-thread (thread)
6212 ;; Remove leaf dormant or ancient articles from THREAD.
6213 (let ((head (car thread))
6214 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6215 (if (and (null tail)
6216 (let ((number (header-number head)))
6217 (or (memq number gnus-newsgroup-ancient)
6218 (memq number gnus-newsgroup-dormant)
6219 (and gnus-summary-expunge-below
6220 (eq gnus-fetch-old-headers 'some)
6221 (< (or (cdr (assq number gnus-newsgroup-scored))
6222 gnus-summary-default-score 0)
6223 gnus-summary-expunge-below)
6225 (setq gnus-newsgroup-unreads
6226 (delq number gnus-newsgroup-unreads))
6227 (setq gnus-newsgroup-reads
6228 (cons (cons number gnus-low-score-mark)
6229 gnus-newsgroup-reads))
6232 (list (cons head tail)))))
6234 (defun gnus-trim-thread (thread)
6235 ;; Remove root ancient articles with only one child from THREAD.
6236 (if (and (eq gnus-fetch-old-headers 'some)
6237 (memq (header-number (car thread)) gnus-newsgroup-ancient)
6238 (= (length thread) 2))
6239 (gnus-trim-thread (nth 1 thread))
6242 (defun gnus-make-sub-thread (root)
6243 ;; This function makes a sub-tree for a node in the tree.
6244 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
6245 gnus-newsgroup-dependencies)))))
6246 (cons root (mapcar 'gnus-make-sub-thread children))))
6248 (defun gnus-build-old-threads ()
6249 ;; Look at all the articles that refer back to old articles, and
6250 ;; fetch the headers for the articles that aren't there. This will
6251 ;; build complete threads - if the roots haven't been expired by the
6256 (if (not (car (symbol-value refs)))
6258 (setq heads (cdr (symbol-value refs)))
6260 (if (not (memq (header-number (car heads))
6261 gnus-newsgroup-dormant))
6263 (setq id (symbol-name refs))
6264 (while (and (setq id (gnus-build-get-header id))
6265 (not (car (gnus-gethash
6266 id gnus-newsgroup-dependencies)))))
6268 (setq heads (cdr heads)))))))
6269 gnus-newsgroup-dependencies)))
6271 (defun gnus-build-get-header (id)
6272 ;; Look through the buffer of NOV lines and find the header to
6273 ;; ID. Enter this line into the dependencies hash table, and return
6274 ;; the id of the parent article (if any).
6275 (let ((deps gnus-newsgroup-dependencies)
6279 (set-buffer nntp-server-buffer)
6280 (goto-char (point-min))
6281 (while (and (not found) (search-forward id nil t))
6283 (setq found (looking-at
6284 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6285 (regexp-quote id))))
6286 (or found (beginning-of-line 2)))
6291 (setq header (gnus-nov-parse-line
6292 (read (current-buffer)) deps))
6293 (setq ref (header-references header))
6294 (string-match "\\(<[^>]+>\\) *$" ref)
6295 (substring ref (match-beginning 1) (match-end 1))))))
6297 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6298 gnus-newsgroup-ancient (cons (header-number header)
6299 gnus-newsgroup-ancient))))))
6301 ;; Re-build the thread containing ID.
6302 (defun gnus-rebuild-thread (id)
6303 (let ((dep gnus-newsgroup-dependencies)
6304 (buffer-read-only nil)
6305 parent headers refs thread art)
6306 (while (and id (setq headers
6307 (car (setq art (gnus-gethash (downcase id) dep)))))
6309 (setq id (and (setq refs (header-references headers))
6310 (string-match "\\(<[^>]+>\\) *$" refs)
6311 (substring refs (match-beginning 1) (match-end 1)))))
6312 (setq thread (gnus-make-sub-thread (car parent)))
6313 (gnus-rebuild-remove-articles thread)
6314 (let ((beg (point)))
6315 (gnus-summary-prepare-threads (list thread))
6316 (gnus-summary-update-lines beg (point)))))
6318 ;; Delete all lines in the summary buffer that correspond to articles
6320 (defun gnus-rebuild-remove-articles (thread)
6321 (and (gnus-summary-goto-subject (header-number (car thread)))
6323 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6325 (defun gnus-sort-threads (threads)
6326 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6327 (let ((fun gnus-thread-sort-functions))
6329 (setq threads (sort threads (car fun))
6333 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6334 (defmacro gnus-thread-header (thread)
6335 ;; Return header of first article in THREAD.
6336 ;; Note that THREAD must never, evr be anything else than a variable -
6337 ;; using some other form will lead to serious barfage.
6338 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6339 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6340 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6343 (defun gnus-thread-sort-by-number (h1 h2)
6344 "Sort threads by root article number."
6345 (< (header-number (gnus-thread-header h1))
6346 (header-number (gnus-thread-header h2))))
6348 (defun gnus-thread-sort-by-author (h1 h2)
6349 "Sort threads by root author."
6351 (let ((extract (funcall
6352 gnus-extract-address-components
6353 (header-from (gnus-thread-header h1)))))
6354 (or (car extract) (cdr extract)))
6355 (let ((extract (funcall
6356 gnus-extract-address-components
6357 (header-from (gnus-thread-header h2)))))
6358 (or (car extract) (cdr extract)))))
6360 (defun gnus-thread-sort-by-subject (h1 h2)
6361 "Sort threads by root subject."
6363 (downcase (gnus-simplify-subject
6364 (header-subject (gnus-thread-header h1))))
6365 (downcase (gnus-simplify-subject
6366 (header-subject (gnus-thread-header h2))))))
6368 (defun gnus-thread-sort-by-date (h1 h2)
6369 "Sort threads by root article date."
6371 (gnus-sortable-date (header-date (gnus-thread-header h1)))
6372 (gnus-sortable-date (header-date (gnus-thread-header h2)))))
6374 (defun gnus-thread-sort-by-score (h1 h2)
6375 "Sort threads by root article score.
6376 Unscored articles will be counted as having a score of zero."
6377 (> (or (cdr (assq (header-number (gnus-thread-header h1))
6378 gnus-newsgroup-scored))
6379 gnus-summary-default-score 0)
6380 (or (cdr (assq (header-number (gnus-thread-header h2))
6381 gnus-newsgroup-scored))
6382 gnus-summary-default-score 0)))
6384 (defun gnus-thread-sort-by-total-score (h1 h2)
6385 "Sort threads by the sum of all scores in the thread.
6386 Unscored articles will be counted as having a score of zero."
6387 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6389 (defun gnus-thread-total-score (thread)
6390 ;; This function find the total score of THREAD.
6392 (if (stringp (car thread))
6393 (apply gnus-thread-score-function 0
6394 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6395 (gnus-thread-total-score-1 thread))
6396 (gnus-thread-total-score-1 (list thread))))
6398 (defun gnus-thread-total-score-1 (root)
6399 ;; This function find the total score of the thread below ROOT.
6400 (setq root (car root))
6401 (apply gnus-thread-score-function
6402 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
6403 gnus-summary-default-score 0)
6404 (mapcar 'gnus-thread-total-score
6405 (cdr (gnus-gethash (downcase (header-id root))
6406 gnus-newsgroup-dependencies)))))
6408 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6409 (defvar gnus-tmp-prev-subject "")
6411 (defun gnus-summary-prepare-threads (threads &optional cull)
6412 "Prepare summary buffer from THREADS and indentation LEVEL.
6413 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6414 or a straight list of headers."
6415 (message "Generating summary...")
6417 thread header number subject stack state gnus-tmp-gathered)
6418 (if (vectorp (car threads))
6419 ;; If this is a straight (sic) list of headers, then a
6420 ;; threaded summary display isn't required, so we just create
6421 ;; an unthreaded one.
6422 (gnus-summary-prepare-unthreaded threads cull)
6424 ;; Do the threaded display.
6426 (while (or threads stack)
6429 ;; If there are some threads, we do them before the
6430 ;; threads on the stack.
6431 (setq thread threads
6432 header (car (car thread)))
6433 ;; There were no current threads, so we pop something off
6435 (setq state (car stack)
6439 header (car (car thread))))
6441 (if (stringp header)
6443 ;; The header is a dummy root.
6445 ((eq gnus-summary-make-false-root 'adopt)
6446 ;; We let the first article adopt the rest.
6447 (let ((th (car (cdr (car thread)))))
6450 (setcdr th (cdr (cdr (car thread))))
6451 (setq gnus-tmp-gathered
6453 (lambda (h) (header-number (car h)))
6454 (cdr (cdr (car thread))))
6456 (setcdr (cdr (car thread)) nil))
6458 ((eq gnus-summary-make-false-root 'empty)
6459 ;; We print adopted articles with empty subject fields.
6460 (setq gnus-tmp-gathered
6462 (lambda (h) (header-number (car h)))
6463 (cdr (cdr (car thread))))
6466 ((eq gnus-summary-make-false-root 'dummy)
6467 ;; We output a dummy root.
6468 (gnus-summary-insert-dummy-line
6469 nil header (header-number (car (car (cdr (car thread)))))))
6471 ;; We do not make a root for the gathered
6472 ;; sub-threads at all.
6475 (setq number (header-number header)
6476 subject (header-subject header))
6478 ;; Do the async thing.
6479 (and gnus-newsgroup-async
6480 (setq gnus-newsgroup-threads
6481 (cons (cons number (header-lines header))
6482 gnus-newsgroup-threads)))
6484 ;; We may have to root out some bad articles...
6487 (cond ((and (memq (setq number (header-number header))
6488 gnus-newsgroup-dormant)
6491 ((and gnus-summary-expunge-below
6492 (< (or (cdr (assq number gnus-newsgroup-scored))
6493 gnus-summary-default-score 0)
6494 gnus-summary-expunge-below))
6496 (setq gnus-newsgroup-unreads
6497 (delq number gnus-newsgroup-unreads))
6498 (setq gnus-newsgroup-reads
6499 (cons (cons number gnus-low-score-mark)
6500 gnus-newsgroup-reads)))))
6506 (gnus-summary-insert-line
6507 nil header level nil
6509 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6510 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6511 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6512 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6513 (t (or (cdr (assq number gnus-newsgroup-reads))
6514 gnus-ancient-mark)))
6515 (memq number gnus-newsgroup-replied)
6516 (memq number gnus-newsgroup-expirable)
6517 (if (and (eq gnus-summary-make-false-root 'empty)
6518 (memq number gnus-tmp-gathered))
6519 gnus-summary-same-subject
6520 (if (or (zerop level)
6521 (and gnus-thread-ignore-subject
6523 (gnus-simplify-subject-re
6524 gnus-tmp-prev-subject)
6525 (gnus-simplify-subject-re
6528 gnus-summary-same-subject))
6529 (and (eq gnus-summary-make-false-root 'adopt)
6530 (memq number gnus-tmp-gathered))
6531 (cdr (assq number gnus-newsgroup-scored)))
6533 (setq gnus-tmp-prev-subject subject)))))
6536 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6537 (setq level (1+ level))
6538 (setq threads (cdr (car thread))))))
6539 (message "Generating summary...done"))
6543 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6544 (let (header number)
6546 ;; Do the async thing, if that is required.
6547 (if gnus-newsgroup-async
6548 (setq gnus-newsgroup-threads
6549 (mapcar (lambda (h) (cons (header-number h) (header-lines h)))
6553 (setq header (car headers)
6554 headers (cdr headers)
6555 number (header-number header))
6557 ;; We may have to root out some bad articles...
6560 (memq (setq number (header-number header))
6561 gnus-newsgroup-dormant)))
6562 ((and cull gnus-summary-expunge-below
6563 (< (or (cdr (assq number gnus-newsgroup-scored))
6564 gnus-summary-default-score 0)
6565 gnus-summary-expunge-below))
6566 (setq gnus-newsgroup-unreads
6567 (delq number gnus-newsgroup-unreads))
6568 (setq gnus-newsgroup-reads
6569 (cons (cons number gnus-low-score-mark)
6570 gnus-newsgroup-reads)))
6572 (gnus-summary-insert-line
6574 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6575 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6576 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6577 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6578 (t (or (cdr (assq number gnus-newsgroup-reads))
6579 gnus-ancient-mark)))
6580 (memq number gnus-newsgroup-replied)
6581 (memq number gnus-newsgroup-expirable)
6582 (header-subject header) nil
6583 (cdr (assq number gnus-newsgroup-scored))))))))
6585 (defun gnus-select-newsgroup (group &optional read-all)
6586 "Select newsgroup GROUP.
6587 If READ-ALL is non-nil, all articles in the group are selected."
6588 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6589 (info (nth 2 entry))
6592 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6594 (or (gnus-check-server gnus-current-select-method)
6595 (error "Couldn't open server"))
6597 (or (and (null entry)
6598 (gnus-activate-group group))
6599 (and (eq (car entry) t)
6600 (gnus-activate-group (car info)))
6601 (gnus-request-group group t)
6603 (kill-buffer (current-buffer))
6604 (error "Couldn't request group %s: %s"
6605 group (gnus-status-message group))))
6607 (setq gnus-newsgroup-name group)
6608 (setq gnus-newsgroup-unselected nil)
6609 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6611 (and gnus-asynchronous
6612 (gnus-check-backend-function
6613 'request-asynchronous gnus-newsgroup-name)
6614 (setq gnus-newsgroup-async
6615 (gnus-request-asynchronous gnus-newsgroup-name)))
6617 (setq articles (gnus-articles-to-read group read-all))
6621 (gnus-message 3 "Couldn't select newsgroup")
6623 ((eq articles 0) nil)
6625 ;; Init the dependencies hash table.
6626 (setq gnus-newsgroup-dependencies
6627 (gnus-make-hashtable (length articles)))
6628 ;; Retrieve the headers and read them in.
6629 (gnus-message 5 "Fetching headers...")
6630 (setq gnus-newsgroup-headers
6631 (if (eq 'nov (setq gnus-headers-retrieved-by
6632 ;; This is a naughty hack. To get the
6633 ;; retrieval of old headers to work, we
6634 ;; set `nntp-nov-gap' to nil (locally),
6635 ;; and then just retrieve the headers.
6637 (if gnus-fetch-old-headers
6639 (gnus-retrieve-headers
6640 (if (not (eq 1 (car articles)))
6643 gnus-newsgroup-name))
6644 (gnus-retrieve-headers
6645 articles gnus-newsgroup-name))))
6647 (gnus-get-newsgroup-headers-xover articles))
6648 ;; If we were to fetch old headers, but the backend didn't
6649 ;; support XOVER, then it is possible we fetched one article
6650 ;; that we shouldn't have. If that's the case, we remove it.
6651 (if (or (not gnus-fetch-old-headers)
6652 (eq 1 (car articles)))
6655 (set-buffer nntp-server-buffer)
6656 (goto-char (point-min))
6658 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6659 (delete-region ; So we delete this head.
6661 (search-forward "\n.\n" nil t)))))
6662 (gnus-get-newsgroup-headers)))
6663 (gnus-message 5 "Fetching headers...done")
6664 ;; Remove canceled articles from the list of unread articles.
6665 (setq gnus-newsgroup-unreads
6666 (gnus-set-sorted-intersection
6667 gnus-newsgroup-unreads
6668 (mapcar (lambda (headers) (header-number headers))
6669 gnus-newsgroup-headers)))
6670 ;; Adjust and set lists of article marks.
6673 (gnus-adjust-marked-articles info)
6674 (setq gnus-newsgroup-marked
6676 (cdr (assq 'tick (setq marked (nth 3 info))))))
6677 (setq gnus-newsgroup-replied
6678 (copy-sequence (cdr (assq 'reply marked))))
6679 (setq gnus-newsgroup-expirable
6680 (copy-sequence (cdr (assq 'expire marked))))
6681 (setq gnus-newsgroup-killed
6682 (copy-sequence (cdr (assq 'killed marked))))
6683 (setq gnus-newsgroup-bookmarks
6684 (copy-sequence (cdr (assq 'bookmark marked))))
6685 (setq gnus-newsgroup-dormant
6686 (copy-sequence (cdr (assq 'dormant marked))))
6687 (setq gnus-newsgroup-scored
6688 (copy-sequence (cdr (assq 'score marked))))
6689 (setq gnus-newsgroup-processable nil)))
6690 ;; Check whether auto-expire is to be done in this group.
6691 (setq gnus-newsgroup-auto-expire
6692 (or (and (stringp gnus-auto-expirable-newsgroups)
6693 (string-match gnus-auto-expirable-newsgroups group))
6694 (memq 'auto-expire (nth 5 info))))
6695 ;; First and last article in this newsgroup.
6696 (and gnus-newsgroup-headers
6697 (setq gnus-newsgroup-begin
6698 (header-number (car gnus-newsgroup-headers)))
6699 (setq gnus-newsgroup-end
6700 (header-number (gnus-last-element gnus-newsgroup-headers))))
6701 (setq gnus-reffed-article-number -1)
6702 ;; GROUP is successfully selected.
6703 (or gnus-newsgroup-headers t)))))
6705 (defun gnus-articles-to-read (group read-all)
6706 ;; Find out what articles the user wants to read.
6708 ;; Select all articles if `read-all' is non-nil, or if all the
6709 ;; unread articles are dormant articles.
6710 (if (or (and read-all (not (numberp read-all)))
6711 (= (length gnus-newsgroup-unreads)
6712 (length gnus-newsgroup-dormant)))
6713 (gnus-uncompress-range
6714 (gnus-gethash group gnus-active-hashtb))
6715 gnus-newsgroup-unreads))
6716 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6717 (scored (length scored-list))
6718 (number (length articles))
6719 (marked (+ (length gnus-newsgroup-marked)
6720 (length gnus-newsgroup-dormant)))
6727 (cond ((and (or (<= scored marked)
6729 (numberp gnus-large-newsgroup)
6730 (> number gnus-large-newsgroup))
6734 "How many articles from %s (default %d): "
6735 gnus-newsgroup-name number))))
6736 (if (string-match "^[ \t]*$" input)
6738 ((and (> scored marked) (< scored number))
6742 "%s %s (%d scored, %d total): "
6743 "How many articles from"
6744 group scored number))))
6745 (if (string-match "^[ \t]*$" input)
6749 (setq select (if (stringp select) (string-to-number select) select))
6750 (if (or (null select) (zerop select))
6752 (if (and (not (zerop scored)) (<= (abs select) scored))
6754 (setq articles (sort scored-list '<))
6755 (setq number (length articles)))
6756 (setq articles (copy-sequence articles)))
6758 (if (< (abs select) number)
6760 ;; Select the N oldest articles.
6761 (setcdr (nthcdr (1- (abs select)) articles) nil)
6762 ;; Select the N most recent articles.
6763 (setq articles (nthcdr (- number select) articles))))
6764 (setq gnus-newsgroup-unselected
6765 (gnus-sorted-intersection
6766 gnus-newsgroup-unreads
6767 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6770 (defun gnus-killed-articles (killed articles)
6773 (if (inline (gnus-member-of-range (car articles) killed))
6774 (setq out (cons (car articles) out)))
6775 (setq articles (cdr articles)))
6778 (defun gnus-adjust-marked-articles (info &optional active)
6779 "Remove all marked articles that are no longer legal."
6780 (let ((marked-lists (nth 3 info))
6781 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6783 ;; There are many types of marked articles.
6785 (setq m (cdr (setq prev (car marked-lists))))
6786 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6787 ;; Make sure that all ticked articles are a subset of the
6788 ;; unread/unselected articles.
6790 (if (or (memq (car m) gnus-newsgroup-unreads)
6791 (memq (car m) gnus-newsgroup-unselected))
6793 (setcdr prev (cdr m)))
6795 ((eq 'score (car prev))
6796 ;; Scored articles should be a subset of
6797 ;; unread/unselected articles.
6799 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6800 (memq (car (car m)) gnus-newsgroup-unreads))
6802 (setcdr prev (cdr m)))
6804 ((eq 'bookmark (car prev))
6805 ;; Bookmarks should be a subset of active articles.
6807 (if (< (car (car m)) (car active))
6808 (setcdr prev (cdr m))
6811 ((eq 'killed (car prev))
6812 ;; Articles that have been through the kill process are
6813 ;; to be a subset of active articles.
6814 (while (and m (< (or (and (numberp (car m)) (car m))
6817 (setcdr prev (cdr m))
6819 (if (and m (< (or (and (numberp (car m)) (car m))
6822 (setcar (if (numberp (car m)) m (car m)) (car active))))
6823 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6824 ;; The replied and expirable articles have to be articles
6827 (if (< (car m) (car active))
6828 (setcdr prev (cdr m))
6831 (setq marked-lists (cdr marked-lists)))
6832 ;; Remove all lists that are empty.
6833 (setq marked-lists (nth 3 info))
6836 (while (= 1 (length (car marked-lists)))
6837 (setq marked-lists (cdr marked-lists)))
6838 (setq m (cdr (setq prev marked-lists)))
6840 (if (= 1 (length (car m)))
6841 (setcdr prev (cdr m))
6844 (setcar (nthcdr 3 info) marked-lists)))
6845 ;; Finally, if there are no marked lists at all left, and if there
6846 ;; are no elements after the lists in the info list, we just chop
6847 ;; the info list off before the marked lists.
6848 (and (null marked-lists)
6849 (not (nthcdr 4 info))
6850 (setcdr (nthcdr 2 info) nil)))
6853 (defun gnus-set-marked-articles
6854 (info ticked replied expirable killed dormant bookmark score)
6855 "Enter the various lists of marked articles into the newsgroup info list."
6857 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6858 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6859 (and expirable (setq newmarked (cons (cons 'expire expirable)
6861 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6862 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6863 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6865 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6868 (setcar (nthcdr 3 info) newmarked)
6869 (and (not newmarked)
6870 (not (nthcdr 4 info))
6871 (setcdr (nthcdr 2 info) nil)))
6873 (setcdr (nthcdr 2 info) (list newmarked))))))
6875 (defun gnus-add-marked-articles (group type articles &optional info force)
6876 ;; Add ARTICLES of TYPE to the info of GROUP.
6877 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6878 ;; add, but replace marked articles of TYPE with ARTICLES.
6879 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6882 (and (not (setq marked (nthcdr 3 info)))
6883 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6884 (and (not (setq m (assq type (car marked))))
6885 (setcar marked (cons (cons type articles) (car marked))))
6888 (nconc m articles)))))
6890 (defun gnus-set-mode-line (where)
6891 "This function sets the mode line of the article or summary buffers.
6892 If WHERE is `summary', the summary mode line format will be used."
6893 (if (memq where gnus-updated-mode-lines)
6896 (set-buffer gnus-summary-buffer)
6897 (let* ((mformat (if (eq where 'article)
6898 gnus-article-mode-line-format-spec
6899 gnus-summary-mode-line-format-spec))
6900 (group-name gnus-newsgroup-name)
6901 (article-number (or gnus-current-article 0))
6902 (unread (- (length gnus-newsgroup-unreads)
6903 (length gnus-newsgroup-dormant)))
6904 (unread-and-unticked
6905 (- unread (length gnus-newsgroup-marked)))
6906 (unselected (length gnus-newsgroup-unselected))
6907 (unread-and-unselected
6908 (cond ((and (zerop unread-and-unticked)
6909 (zerop unselected)) "")
6911 (format "{%d more}" unread-and-unticked))
6912 (t (format "{%d(+%d) more}"
6913 unread-and-unticked unselected))))
6915 (if gnus-current-headers
6916 (header-subject gnus-current-headers) ""))
6917 (max-len (and gnus-mode-non-string-length
6918 (- (frame-width) gnus-mode-non-string-length)))
6919 header) ;; passed as argument to any user-format-funcs
6920 (setq mode-string (eval mformat))
6921 (or (numberp max-len)
6922 (setq max-len (length mode-string)))
6923 (if (< max-len 4) (setq max-len 4))
6924 (if (> (length mode-string) max-len)
6925 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6926 ;; function `substring' might cut on a middle
6927 ;; of multi-octet character.
6929 (concat (gnus-truncate-string mode-string (- max-len 3))
6931 (setq mode-string (format (format "%%-%ds" max-len)
6933 (setq mode-line-buffer-identification mode-string)
6934 (set-buffer-modified-p t))))
6936 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6937 "Go through the HEADERS list and add all Xrefs to a hash table.
6938 The resulting hash table is returned, or nil if no Xrefs were found."
6939 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6941 (gnus-group-foreign-p from-newsgroup)
6943 (assoc (symbol-name (car from-method))
6944 gnus-valid-select-methods))))
6945 (gnus-group-real-prefix from-newsgroup)))
6946 (xref-hashtb (make-vector 63 0))
6947 start group entry number xrefs header)
6949 (setq header (car headers))
6950 (if (and (setq xrefs (header-xref header))
6951 (not (memq (header-number header) unreads)))
6954 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6955 (setq start (match-end 0))
6956 (setq group (concat prefix (substring xrefs (match-beginning 1)
6959 (string-to-int (substring xrefs (match-beginning 2)
6961 (if (setq entry (gnus-gethash group xref-hashtb))
6962 (setcdr entry (cons number (cdr entry)))
6963 (gnus-sethash group (cons number nil) xref-hashtb)))))
6964 (setq headers (cdr headers)))
6965 (if start xref-hashtb nil)))
6967 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6968 "Look through all the headers and mark the Xrefs as read."
6969 (let ((virtual (memq 'virtual
6970 (assoc (symbol-name (car (gnus-find-method-for-group
6972 gnus-valid-select-methods)))
6973 name entry info xref-hashtb idlist method
6976 (set-buffer gnus-group-buffer)
6977 (if (setq xref-hashtb
6978 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6981 (if (string= from-newsgroup (setq name (symbol-name group)))
6983 (setq idlist (symbol-value group))
6984 ;; Dead groups are not updated.
6986 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6988 (if (stringp (setq nth4 (nth 4 info)))
6989 (setq nth4 (gnus-server-to-method nth4))))
6990 ;; Only do the xrefs if the group has the same
6991 ;; select method as the group we have just read.
6992 (or (gnus-methods-equal-p
6993 nth4 (gnus-find-method-for-group from-newsgroup))
6996 (setq method (gnus-find-method-for-group
6998 (and (equal (car nth4) (car method))
6999 (equal (nth 1 nth4) (nth 1 method))))
7000 gnus-use-cross-reference
7001 (or (not (eq gnus-use-cross-reference t))
7003 ;; Only do cross-references on subscribed
7004 ;; groups, if that is what is wanted.
7005 (<= (nth 1 info) gnus-level-subscribed)))
7006 (gnus-group-make-articles-read name idlist expirable))))
7009 (defun gnus-group-make-articles-read (group articles expirable)
7011 (entry (gnus-gethash group gnus-newsrc-hashtb))
7012 (info (nth 2 entry))
7013 (active (gnus-gethash group gnus-active-hashtb))
7014 exps expirable range)
7015 ;; First peel off all illegal article numbers.
7017 (let ((ids articles)
7018 (ticked (cdr (assq 'tick (nth 3 info))))
7019 (dormant (cdr (assq 'dormant (nth 3 info))))
7024 (if (or (> id (cdr active))
7028 (setq articles (delq id articles)))
7029 (and (memq id expirable)
7030 (setq exps (cons id exps)))
7031 (setq ids (cdr ids)))))
7032 ;; Update expirable articles.
7033 (gnus-add-marked-articles nil 'expirable exps info)
7037 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7038 (setcar (nthcdr 2 info)
7042 (setq articles (sort articles '<)))))
7043 ;; Then we have to re-compute how many unread
7044 ;; articles there are in this group.
7049 (setq num (- (1+ (cdr active)) (car active))))
7050 ((not (listp (cdr range)))
7051 (setq num (- (cdr active) (- (1+ (cdr range))
7055 (if (numberp (car range))
7057 (setq num (+ num (- (1+ (cdr (car range)))
7058 (car (car range))))))
7059 (setq range (cdr range)))
7060 (setq num (- (cdr active) num))))
7061 ;; Update the number of unread articles.
7065 (length (cdr (assq 'tick (nth 3 info))))
7067 (cdr (assq 'dormant (nth 3 info)))))))
7068 ;; Update the group buffer.
7069 (gnus-group-update-group group t)))))
7071 (defun gnus-methods-equal-p (m1 m2)
7072 (let ((m1 (or m1 gnus-select-method))
7073 (m2 (or m2 gnus-select-method)))
7075 (and (eq (car m1) (car m2))
7076 (or (not (memq 'address (assoc (symbol-name (car m1))
7077 gnus-valid-select-methods)))
7078 (equal (nth 1 m1) (nth 1 m2)))))))
7080 (defsubst gnus-header-value ()
7081 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7083 (defvar gnus-newsgroup-none-id 0)
7085 (defun gnus-get-newsgroup-headers ()
7086 (setq gnus-article-internal-prepare-hook nil)
7087 (let ((cur nntp-server-buffer)
7088 (dependencies gnus-newsgroup-dependencies)
7089 headers id dep end ref)
7091 (set-buffer nntp-server-buffer)
7092 (goto-char (point-min))
7093 ;; Search to the beginning of the next header. Error messages
7094 ;; do not begin with 2 or 3.
7095 (while (re-search-forward "^[23][0-9]+ " nil t)
7096 (let ((header (make-vector 9 nil))
7097 (case-fold-search t)
7102 (header-set-number header (read cur))
7103 ;; This implementation of this function, with nine
7104 ;; search-forwards instead of the one re-search-forward and
7105 ;; a case (which basically was the old function) is actually
7106 ;; about twice as fast, even though it looks messier. You
7107 ;; can't have everything, I guess. Speed and elegance
7108 ;; doesn't always come hand in hand.
7110 (narrow-to-region (point) (or (save-excursion
7111 (search-forward "\n.\n" nil t))
7113 (if (search-forward "\nfrom: " nil t)
7114 (header-set-from header (gnus-header-value))
7115 (header-set-from header "(nobody)"))
7117 (if (search-forward "\nsubject: " nil t)
7118 (header-set-subject header (gnus-header-value))
7119 (header-set-subject header "(none)"))
7121 (and (search-forward "\nxref: " nil t)
7122 (header-set-xref header (gnus-header-value)))
7124 (or (numberp (and (search-forward "\nlines: " nil t)
7125 (header-set-lines header (read cur))))
7126 (header-set-lines header 0))
7128 (and (search-forward "\ndate: " nil t)
7129 (header-set-date header (gnus-header-value)))
7131 (if (search-forward "\nmessage-id: " nil t)
7132 (header-set-id header (setq id (gnus-header-value)))
7133 ;; If there was no message-id, we just fake one to make
7134 ;; subsequent routines simpler.
7137 (setq id (concat "none+"
7139 (setq gnus-newsgroup-none-id
7140 (1+ gnus-newsgroup-none-id)))))))
7142 (if (search-forward "\nreferences: " nil t)
7144 (header-set-references header (gnus-header-value))
7145 (setq end (match-end 0))
7152 (search-backward ">" end t)
7155 (search-backward "<" end t)
7157 ;; Get the references from the in-reply-to header if there
7158 ;; ware no references and the in-reply-to header looks
7160 (if (and (search-forward "\nin-reply-to: " nil t)
7161 (setq in-reply-to (gnus-header-value))
7162 (string-match "<[^>]+>" in-reply-to))
7164 (header-set-references
7166 (setq ref (substring in-reply-to (match-beginning 0)
7168 (setq ref (downcase ref)))
7170 ;; We do some threading while we read the headers. The
7171 ;; message-id and the last reference are both entered into
7172 ;; the same hash table. Some tippy-toeing around has to be
7173 ;; done in case an article has arrived before the article
7174 ;; which it refers to.
7175 (if (boundp (setq dep (intern (downcase id) dependencies)))
7176 (if (car (symbol-value dep))
7177 ;; An article with this Message-ID has already
7178 ;; been seen, so we ignore this one, except we add
7179 ;; any additional Xrefs (in case the two articles
7180 ;; came from different servers.
7183 (car (symbol-value dep))
7184 (concat (or (header-xref (car (symbol-value dep))) "")
7185 (or (header-xref header) "")))
7187 (setcar (symbol-value dep) header))
7188 (set dep (list header)))
7191 (if (boundp (setq dep (intern ref dependencies)))
7192 (setcdr (symbol-value dep)
7193 (cons header (cdr (symbol-value dep))))
7194 (set dep (list nil header)))
7195 (setq headers (cons header headers))))
7196 (goto-char (point-max))))))
7197 (nreverse headers)))
7199 ;; The following macros and functions were written by Felix Lee
7200 ;; <flee@cse.psu.edu>.
7202 (defmacro gnus-nov-read-integer ()
7204 (if (= (following-char) ?\t)
7206 (let ((num (condition-case nil (read buffer) (error nil))))
7207 (if (numberp num) num 0)))
7208 (or (eobp) (forward-char 1))))
7210 (defmacro gnus-nov-skip-field ()
7211 '(search-forward "\t" eol 'move))
7213 (defmacro gnus-nov-field ()
7214 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7216 ;; Goes through the xover lines and returns a list of vectors
7217 (defun gnus-get-newsgroup-headers-xover (sequence)
7218 "Parse the news overview data in the server buffer, and return a
7219 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7220 ;; Get the Xref when the users reads the articles since most/some
7221 ;; NNTP servers do not include Xrefs when using XOVER.
7222 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7223 (let ((cur nntp-server-buffer)
7224 (dependencies gnus-newsgroup-dependencies)
7225 number headers header)
7227 (set-buffer nntp-server-buffer)
7228 (goto-char (point-min))
7229 (while (and sequence (not (eobp)))
7230 (setq number (read cur))
7231 (while (and sequence (< (car sequence) number))
7232 (setq sequence (cdr sequence)))
7234 (eq number (car sequence))
7236 (setq sequence (cdr sequence))
7238 (inline (gnus-nov-parse-line number dependencies)))
7239 (setq headers (cons header headers)))))
7241 (setq headers (nreverse headers)))
7244 ;; This function has to be called with point after the article number
7245 ;; on the beginning of the line.
7246 (defun gnus-nov-parse-line (number dependencies)
7248 (eol (gnus-point-at-eol))
7249 (buffer (current-buffer))
7252 ;; overview: [num subject from date id refs chars lines misc]
7253 (narrow-to-region (point) eol)
7260 (gnus-nov-field) ; subject
7261 (gnus-nov-field) ; from
7262 (gnus-nov-field) ; date
7263 (setq id (or (gnus-nov-field)
7266 (setq none (1+ none)))))) ; id
7269 (let ((beg (point)))
7270 (search-forward "\t" eol)
7271 (if (search-backward ">" beg t)
7277 (search-backward "<" beg t)
7280 (gnus-nov-field)) ; refs
7281 (gnus-nov-read-integer) ; chars
7282 (gnus-nov-read-integer) ; lines
7283 (if (= (following-char) ?\n)
7285 (gnus-nov-field)) ; misc
7289 (message "Strange nov line.")
7295 ;; We build the thread tree.
7297 (if (boundp (setq dep (intern (downcase id) dependencies)))
7298 (if (car (symbol-value dep))
7299 ;; An article with this Message-ID has already been seen,
7300 ;; so we ignore this one, except we add any additional
7301 ;; Xrefs (in case the two articles came from different
7305 (car (symbol-value dep))
7306 (concat (or (header-xref (car (symbol-value dep))) "")
7307 (or (header-xref header) "")))
7309 (setcar (symbol-value dep) header))
7310 (set dep (list header))))
7313 (if (boundp (setq dep (intern (or ref "none")
7315 (setcdr (symbol-value dep)
7316 (cons header (cdr (symbol-value dep))))
7317 (set dep (list nil header)))))
7320 (defun gnus-article-get-xrefs ()
7321 "Fill in the Xref value in `gnus-current-headers', if necessary.
7322 This is meant to be called in `gnus-article-internal-prepare-hook'."
7323 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7324 gnus-current-headers)))
7325 (or (not gnus-use-cross-reference)
7327 (and (header-xref headers)
7328 (not (string= (header-xref headers) "")))
7329 (let ((case-fold-search t)
7332 (gnus-narrow-to-headers)
7333 (goto-char (point-min))
7334 (if (or (and (eq (downcase (following-char)) ?x)
7335 (looking-at "Xref:"))
7336 (search-forward "\nXref:" nil t))
7338 (goto-char (1+ (match-end 0)))
7339 (setq xref (buffer-substring (point)
7340 (progn (end-of-line) (point))))
7341 (header-set-xref headers xref))))))))
7343 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7344 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7346 (defun gnus-make-headers-hashtable-by-number ()
7347 "Make hashtable for the variable gnus-newsgroup-headers by number."
7349 (set-buffer gnus-summary-buffer)
7350 (let ((headers gnus-newsgroup-headers)
7352 (setq gnus-newsgroup-headers-hashtb-by-number
7353 (gnus-make-hashtable (length headers)))
7355 (setq header (car headers))
7356 (gnus-sethash (int-to-string (header-number header))
7357 header gnus-newsgroup-headers-hashtb-by-number)
7358 (setq headers (cdr headers))))))
7360 (defun gnus-more-header-backward ()
7361 "Find new header backward."
7362 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7363 (artnum gnus-newsgroup-begin)
7365 (while (and (not header)
7367 (setq artnum (1- artnum))
7368 (setq header (gnus-read-header artnum)))
7371 (defun gnus-more-header-forward (&optional backward)
7372 "Find new header forward.
7373 If BACKWARD, find new header backward instead."
7375 (gnus-more-header-backward)
7376 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7377 (artnum gnus-newsgroup-end)
7379 (while (and (not header)
7381 (setq artnum (1+ artnum))
7382 (setq header (gnus-read-header artnum)))
7385 (defun gnus-extend-newsgroup (header &optional backward)
7386 "Extend newsgroup selection with HEADER.
7387 Optional argument BACKWARD means extend toward backward."
7389 (let ((artnum (header-number header)))
7390 (setq gnus-newsgroup-headers
7392 (cons header gnus-newsgroup-headers)
7393 (nconc gnus-newsgroup-headers (list header))))
7394 (setq gnus-newsgroup-unselected
7395 (delq artnum gnus-newsgroup-unselected))
7396 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7397 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7399 (defun gnus-summary-work-articles (n)
7400 "Return a list of articles to be worked upon. The prefix argument,
7401 the list of process marked articles, and the current article will be
7402 taken into consideration."
7404 (if (and n (numberp n))
7405 (let ((backward (< n 0))
7409 (setq articles (cons (gnus-summary-article-number)
7411 (gnus-summary-search-forward nil nil backward))
7413 (sort articles (function <)))
7414 (or (reverse gnus-newsgroup-processable)
7415 (list (gnus-summary-article-number))))))
7417 (defun gnus-summary-search-group (&optional backward use-level)
7418 "Search for next unread newsgroup.
7419 If optional argument BACKWARD is non-nil, search backward instead."
7421 (set-buffer gnus-group-buffer)
7422 (if (gnus-group-search-forward
7423 backward nil (if use-level (gnus-group-group-level) nil))
7424 (gnus-group-group-name))))
7426 (defun gnus-summary-best-group (&optional exclude-group)
7427 "Find the name of the best unread group.
7428 If EXCLUDE-GROUP, do not go to this group."
7430 (set-buffer gnus-group-buffer)
7432 (gnus-group-best-unread-group exclude-group))))
7434 (defun gnus-subject-equal (s1 s2)
7436 ((null gnus-summary-gather-subject-limit)
7437 (equal (gnus-simplify-subject-re s1)
7438 (gnus-simplify-subject-re s2)))
7439 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7440 (equal (gnus-simplify-subject-fuzzy s1)
7441 (gnus-simplify-subject-fuzzy s2)))
7442 ((numberp gnus-summary-gather-subject-limit)
7443 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7444 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7448 (defun gnus-summary-search-subject (&optional backward unread subject)
7449 "Search for article forward.
7450 If BACKWARD is non-nil, search backward.
7451 If UNREAD is non-nil, only unread articles are selected.
7452 If SUBJECT is non-nil, the article which has the same subject will be
7454 (let ((func (if backward 'previous-single-property-change
7455 'next-single-property-change))
7460 (and gnus-summary-check-current unread
7461 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7465 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7468 (setq pos (funcall func (point) 'gnus-number))
7469 (goto-char (if backward (1- pos) pos))
7473 (eq (get-text-property (point) 'gnus-mark)
7476 (and (setq psubject (inline (gnus-summary-subject-string)))
7477 (inline (gnus-subject-equal subject psubject)))))))
7478 (if backward (if (bobp) nil (forward-char -1) t)
7479 (if (eobp) nil (forward-char 1) t)))))
7481 (progn (goto-char beg) nil)
7483 (get-text-property (point) 'gnus-number)
7484 (gnus-summary-position-cursor)))))
7486 (defun gnus-summary-pseudo-article ()
7487 "The thread level of the article on the current line."
7488 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7490 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7491 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7492 (defun gnus-summary-article-score ()
7493 "Return current article score."
7494 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7495 gnus-summary-default-score 0))
7497 (defun gnus-summary-recenter ()
7498 "Center point in the summary window.
7499 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7500 displayed, no centering will be performed."
7501 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7502 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7503 (let* ((top (cond ((< (window-height) 4) 0)
7504 ((< (window-height) 7) 1)
7506 (height (1- (window-height)))
7507 (bottom (save-excursion (goto-char (point-max))
7508 (forward-line (- height))
7510 (window (get-buffer-window (current-buffer))))
7512 ;; The user has to want it,
7513 gnus-auto-center-summary
7514 ;; the article buffer must be displayed,
7515 (get-buffer-window gnus-article-buffer)
7516 ;; Set the window start to either `bottom', which is the biggest
7517 ;; possible valid number, or the second line from the top,
7518 ;; whichever is the least.
7520 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7522 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7523 (defun gnus-short-group-name (group &optional levels)
7524 "Collapse GROUP name LEVELS."
7525 (let* ((name "") (foreign "") (depth -1) (skip 1)
7528 (while (string-match "\\." group skip)
7529 (setq skip (match-end 0)
7532 (if (string-match ":" group)
7533 (setq foreign (substring group 0 (match-end 0))
7534 group (substring group (match-end 0))))
7536 (if (and (string-match "\\." group) (> levels 0))
7537 (setq name (concat name (substring group 0 1))
7538 group (substring group (match-end 0))
7540 name (concat name "."))
7541 (setq name (concat foreign name group)
7545 (defun gnus-summary-jump-to-group (newsgroup)
7546 "Move point to NEWSGROUP in group mode buffer."
7547 ;; Keep update point of group mode buffer if visible.
7548 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7549 (save-window-excursion
7550 ;; Take care of tree window mode.
7551 (if (get-buffer-window gnus-group-buffer)
7552 (pop-to-buffer gnus-group-buffer))
7553 (gnus-group-jump-to-group newsgroup))
7555 ;; Take care of tree window mode.
7556 (if (get-buffer-window gnus-group-buffer)
7557 (pop-to-buffer gnus-group-buffer)
7558 (set-buffer gnus-group-buffer))
7559 (gnus-group-jump-to-group newsgroup))))
7561 ;; This function returns a list of article numbers based on the
7562 ;; difference between the ranges of read articles in this group and
7563 ;; the range of active articles.
7564 (defun gnus-list-of-unread-articles (group)
7565 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7566 (active (gnus-gethash group gnus-active-hashtb))
7569 ;; If none are read, then all are unread.
7571 (setq first (car active))
7572 ;; If the range of read articles is a single range, then the
7573 ;; first unread article is the article after the last read
7574 ;; article. Sounds logical, doesn't it?
7575 (if (not (listp (cdr read)))
7576 (setq first (1+ (cdr read)))
7577 ;; `read' is a list of ranges.
7578 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7579 (car (car read)))) 1)
7583 (while (< first nlast)
7584 (setq unread (cons first unread))
7585 (setq first (1+ first))))
7586 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7587 (setq nlast (if (atom (car (cdr read)))
7589 (car (car (cdr read)))))
7590 (setq read (cdr read)))))
7591 ;; And add the last unread articles.
7592 (while (<= first last)
7593 (setq unread (cons first unread))
7594 (setq first (1+ first)))
7595 ;; Return the list of unread articles.
7598 (defun gnus-list-of-read-articles (group)
7599 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7600 (active (gnus-gethash group gnus-active-hashtb)))
7602 (gnus-sorted-complement
7603 (gnus-uncompress-range active)
7604 (gnus-list-of-unread-articles group)))))
7606 ;; Various summary commands
7608 (defun gnus-summary-universal-argument ()
7609 "Perform any operation on all articles marked with the process mark."
7611 (gnus-set-global-variables)
7612 (let ((articles (reverse gnus-newsgroup-processable))
7614 (or articles (error "No articles marked"))
7615 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7616 (error "Undefined key"))
7618 (gnus-summary-goto-subject (car articles))
7619 (command-execute func)
7620 (gnus-summary-remove-process-mark (car articles))
7621 (setq articles (cdr articles)))))
7623 (defun gnus-summary-toggle-truncation (&optional arg)
7624 "Toggle truncation of summary lines.
7625 With arg, turn line truncation on iff arg is positive."
7627 (setq truncate-lines
7628 (if (null arg) (not truncate-lines)
7629 (> (prefix-numeric-value arg) 0)))
7632 (defun gnus-summary-reselect-current-group (&optional all)
7633 "Once exit and then reselect the current newsgroup.
7634 The prefix argument ALL means to select all articles."
7636 (gnus-set-global-variables)
7637 (let ((current-subject (gnus-summary-article-number))
7638 (group gnus-newsgroup-name))
7639 (setq gnus-newsgroup-begin nil)
7640 (gnus-summary-exit t)
7641 ;; We have to adjust the point of group mode buffer because the
7642 ;; current point was moved to the next unread newsgroup by
7644 (gnus-summary-jump-to-group group)
7645 (gnus-group-read-group all t)
7646 (gnus-summary-goto-subject current-subject)))
7648 (defun gnus-summary-rescan-group (&optional all)
7649 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7651 (gnus-set-global-variables)
7652 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7653 (let ((group gnus-newsgroup-name))
7655 (gnus-summary-jump-to-group group)
7657 (set-buffer gnus-group-buffer)
7658 (gnus-group-get-new-news-this-group 1))
7659 (gnus-summary-jump-to-group group)
7660 (gnus-group-read-group all)))
7662 (defun gnus-summary-update-info ()
7663 (let* ((group gnus-newsgroup-name))
7664 (if gnus-newsgroup-kill-headers
7665 (setq gnus-newsgroup-killed
7666 (gnus-compress-sequence
7668 (gnus-set-sorted-intersection
7669 (gnus-uncompress-range gnus-newsgroup-killed)
7670 (setq gnus-newsgroup-unselected
7671 (sort gnus-newsgroup-unselected '<)))
7672 (setq gnus-newsgroup-unreads
7673 (sort gnus-newsgroup-unreads '<))) t)))
7674 (or (listp (cdr gnus-newsgroup-killed))
7675 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7676 (let ((headers gnus-newsgroup-headers))
7677 (gnus-close-group group)
7678 (run-hooks 'gnus-exit-group-hook)
7679 (gnus-update-read-articles
7680 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7681 gnus-newsgroup-marked
7682 t gnus-newsgroup-replied gnus-newsgroup-expirable
7683 gnus-newsgroup-killed gnus-newsgroup-dormant
7684 gnus-newsgroup-bookmarks
7685 (and gnus-save-score gnus-newsgroup-scored))
7686 (and gnus-use-cross-reference
7687 (gnus-mark-xrefs-as-read
7688 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7689 ;; Do adaptive scoring, and possibly save score files.
7690 (and gnus-newsgroup-adaptive
7691 (gnus-score-adaptive))
7692 (and gnus-use-scoring
7693 (fboundp 'gnus-score-save)
7694 (funcall 'gnus-score-save))
7695 ;; Do not switch windows but change the buffer to work.
7696 (set-buffer gnus-group-buffer)
7697 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7698 (gnus-group-update-group group)))))
7700 (defun gnus-summary-exit (&optional temporary)
7701 "Exit reading current newsgroup, and then return to group selection mode.
7702 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7704 (gnus-set-global-variables)
7705 (gnus-kill-save-kill-buffer)
7706 (let* ((group gnus-newsgroup-name)
7707 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7708 gnus-newsgroup-name))))
7710 (buf (current-buffer)))
7711 (run-hooks 'gnus-summary-prepare-exit-hook)
7712 (gnus-summary-update-info) ; Make all changes in this group permanent.
7714 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7715 ;; Make sure where I was, and go to next newsgroup.
7716 (set-buffer gnus-group-buffer)
7719 (gnus-group-jump-to-group group)
7720 (gnus-group-next-unread-group 1)))
7723 ;; We set all buffer-local variables to nil. It is unclear why
7724 ;; this is needed, but if we don't, buffer-local variables are
7725 ;; not garbage-collected, it seems. This would the lead to en
7726 ;; ever-growing Emacs.
7728 (gnus-summary-clear-local-variables)
7729 ;; We clear the global counterparts of the buffer-local
7730 ;; variables as well, just to be on the safe side.
7731 (gnus-configure-windows 'group 'force)
7732 (gnus-summary-clear-local-variables)
7733 ;; Return to group mode buffer.
7734 (if (eq mode 'gnus-summary-mode)
7735 (gnus-kill-buffer buf))
7736 (if (get-buffer gnus-article-buffer)
7737 (bury-buffer gnus-article-buffer))
7738 (setq gnus-current-select-method gnus-select-method)
7739 (pop-to-buffer gnus-group-buffer)
7740 (if (not quit-config)
7742 (gnus-group-jump-to-group group)
7743 (gnus-group-next-unread-group 1))
7744 (if (not (buffer-name (car quit-config)))
7745 (gnus-configure-windows 'group 'force)
7746 (set-buffer (car quit-config))
7747 (and (eq major-mode 'gnus-summary-mode)
7748 (gnus-set-global-variables))
7749 (gnus-configure-windows (cdr quit-config))))
7750 (run-hooks 'gnus-summary-exit-hook))))
7752 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7753 (defun gnus-summary-exit-no-update (&optional no-questions)
7754 "Quit reading current newsgroup without updating read article info."
7756 (gnus-set-global-variables)
7757 (let* ((group gnus-newsgroup-name)
7758 (quit-config (nth 1 (assoc 'quit-config
7759 (gnus-find-method-for-group group)))))
7760 (if (or no-questions
7762 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7764 (gnus-close-group group)
7765 (gnus-summary-clear-local-variables)
7766 (set-buffer gnus-group-buffer)
7767 (gnus-summary-clear-local-variables)
7768 ;; Return to group selection mode.
7769 (gnus-configure-windows 'group 'force)
7770 (if (get-buffer gnus-summary-buffer)
7771 (kill-buffer gnus-summary-buffer))
7772 (if (get-buffer gnus-article-buffer)
7773 (bury-buffer gnus-article-buffer))
7774 (if (equal (gnus-group-group-name) group)
7775 (gnus-group-next-unread-group 1))
7778 (if (not (buffer-name (car quit-config)))
7779 (gnus-configure-windows 'group 'force)
7780 (set-buffer (car quit-config))
7781 (and (eq major-mode 'gnus-summary-mode)
7782 (gnus-set-global-variables))
7783 (gnus-configure-windows (cdr quit-config)))))))))
7785 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7786 (defun gnus-summary-fetch-faq (group)
7787 "Fetch the FAQ for the current group."
7788 (interactive (list gnus-newsgroup-name))
7789 (let (gnus-faq-buffer)
7790 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group))
7791 (gnus-configure-windows 'summary-faq))))
7793 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7794 (defun gnus-summary-describe-group (&optional force)
7795 "Describe the current newsgroup."
7797 (gnus-group-describe-group force gnus-newsgroup-name))
7799 (defun gnus-summary-describe-briefly ()
7800 "Describe summary mode commands briefly."
7803 (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")))
7805 ;; Walking around group mode buffer from summary mode.
7807 (defun gnus-summary-next-group (&optional no-article target-group backward)
7808 "Exit current newsgroup and then select next unread newsgroup.
7809 If prefix argument NO-ARTICLE is non-nil, no article is selected
7810 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7811 previous group instead."
7813 (gnus-set-global-variables)
7814 (let ((current-group gnus-newsgroup-name)
7815 (current-buffer (current-buffer))
7817 ;; First we semi-exit this group to update Xrefs and all variables.
7818 ;; We can't do a real exit, because the window conf must remain
7819 ;; the same in case the user is prompted for info, and we don't
7820 ;; want the window conf to change before that...
7821 (gnus-summary-exit t)
7822 (while (not entered)
7823 ;; Then we find what group we are supposed to enter.
7824 (set-buffer gnus-group-buffer)
7825 (gnus-group-jump-to-group current-group)
7828 (if (eq gnus-keep-same-level 'best)
7829 (gnus-summary-best-group gnus-newsgroup-name)
7830 (gnus-summary-search-group backward gnus-keep-same-level))))
7831 (if (not target-group)
7832 ;; There are no further groups, so we return to the group
7835 (gnus-message 5 "Returning to the group buffer")
7837 (set-buffer current-buffer)
7838 (gnus-summary-exit))
7839 ;; We try to enter the target group.
7840 (gnus-group-jump-to-group target-group)
7841 (let ((unreads (gnus-group-group-unread)))
7842 (if (and (or (eq t unreads)
7843 (and unreads (not (zerop unreads))))
7844 (gnus-summary-read-group
7845 target-group nil no-article current-buffer))
7847 (setq current-group target-group
7848 target-group nil)))))))
7850 (defun gnus-summary-next-group-old (&optional no-article group backward)
7851 "Exit current newsgroup and then select next unread newsgroup.
7852 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7853 If BACKWARD, go to previous group instead."
7855 (gnus-set-global-variables)
7856 (let ((ingroup gnus-newsgroup-name)
7857 (sumbuf (current-buffer))
7859 (set-buffer gnus-group-buffer)
7861 (or (and (numberp (setq num (car (gnus-gethash
7862 group gnus-newsrc-hashtb))))
7866 (gnus-group-jump-to-group group)
7868 (gnus-group-jump-to-group ingroup))
7869 (gnus-summary-search-group backward)
7870 (let ((group (or group (gnus-summary-search-group backward))))
7872 (gnus-summary-exit t) ;Update all information.
7874 (gnus-summary-exit-no-update t)
7875 (gnus-group-jump-to-group ingroup)
7876 (setq group (gnus-summary-search-group backward))
7877 (gnus-message 5 "Selecting %s..." group)
7878 (set-buffer gnus-group-buffer)
7879 ;; We are now in group mode buffer.
7880 ;; Make sure group mode buffer point is on GROUP.
7881 (gnus-group-jump-to-group group)
7882 (if (not (eq gnus-auto-select-next 'quietly))
7884 (gnus-summary-read-group group nil no-article sumbuf)
7885 (and (string= gnus-newsgroup-name ingroup)
7886 (bufferp sumbuf) (buffer-name sumbuf)
7888 (set-buffer (setq gnus-summary-buffer sumbuf))
7889 (gnus-summary-exit-no-update t))))
7890 (let ((prevgroup group))
7891 (gnus-group-jump-to-group ingroup)
7892 (setq group (gnus-summary-search-group backward))
7893 (gnus-summary-read-group group nil no-article sumbuf)
7894 (while (and (string= gnus-newsgroup-name ingroup)
7896 (buffer-name sumbuf)
7897 (not (string= prevgroup (gnus-group-group-name))))
7898 (set-buffer gnus-group-buffer)
7899 (gnus-summary-read-group
7900 (setq prevgroup (gnus-group-group-name))
7901 nil no-article sumbuf))
7902 (and (string= prevgroup (gnus-group-group-name))
7903 ;; We have reached the final group in the group
7906 (if (buffer-name sumbuf)
7909 (gnus-summary-exit)))))))))))
7911 (defun gnus-summary-prev-group (&optional no-article)
7912 "Exit current newsgroup and then select previous unread newsgroup.
7913 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7915 (gnus-summary-next-group no-article nil t))
7917 ;; Walking around summary lines.
7919 (defun gnus-summary-first-subject (&optional unread)
7920 "Go to the first unread subject.
7921 If UNREAD is non-nil, go to the first unread article.
7922 Returns nil if there are no unread articles."
7926 (goto-char (point-min)))
7929 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7932 ;; There are no unread articles.
7933 (gnus-message 3 "No more unread articles")
7935 (gnus-summary-position-cursor)))
7937 (defun gnus-summary-next-subject (n &optional unread dont-display)
7938 "Go to next N'th summary line.
7939 If N is negative, go to the previous N'th subject line.
7940 If UNREAD is non-nil, only unread articles are selected.
7941 The difference between N and the actual number of steps taken is
7944 (let ((backward (< n 0))
7947 (gnus-summary-search-forward unread nil backward))
7949 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7950 (if unread " unread" "")))
7953 (gnus-summary-recenter)
7954 (gnus-summary-position-cursor)))
7957 (defun gnus-summary-next-unread-subject (n)
7958 "Go to next N'th unread summary line."
7960 (gnus-summary-next-subject n t))
7962 (defun gnus-summary-prev-subject (n &optional unread)
7963 "Go to previous N'th summary line.
7964 If optional argument UNREAD is non-nil, only unread article is selected."
7966 (gnus-summary-next-subject (- n) unread))
7968 (defun gnus-summary-prev-unread-subject (n)
7969 "Go to previous N'th unread summary line."
7971 (gnus-summary-next-subject (- n) t))
7973 (defun gnus-summary-goto-subject (article)
7974 "Go the subject line of ARTICLE."
7978 (completing-read "Article number: "
7982 (int-to-string (header-number headers))))
7983 gnus-newsgroup-headers)
7984 nil 'require-match))))
7985 (or article (error "No article number"))
7987 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
7988 'gnus-number article)))
7990 (gnus-summary-show-thread)
7991 ;; Skip dummy articles.
7992 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
7999 (gnus-summary-position-cursor)))))
8001 ;; Walking around summary lines with displaying articles.
8003 (defun gnus-summary-expand-window (&optional arg)
8004 "Make the summary buffer take up the entire Emacs frame.
8005 Given a prefix, will force an `article' buffer configuration."
8007 (gnus-set-global-variables)
8009 (gnus-configure-windows 'article 'force)
8010 (gnus-configure-windows 'summary 'force)))
8012 (defun gnus-summary-display-article (article &optional all-header)
8013 "Display ARTICLE in article buffer."
8014 (gnus-set-global-variables)
8018 (gnus-article-prepare article all-header)
8019 (gnus-summary-show-thread)
8020 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8023 (gnus-summary-position-cursor)))
8024 (run-hooks 'gnus-select-article-hook)
8025 (gnus-summary-recenter)
8026 (gnus-summary-goto-subject article)
8027 ;; Successfully display article.
8028 (gnus-summary-update-line)
8029 (gnus-article-set-window-start
8030 (cdr (assq article gnus-newsgroup-bookmarks)))
8033 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8034 "Select the current article.
8035 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8036 non-nil, the article will be re-fetched even if it already present in
8037 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8039 (and (not pseudo) (gnus-summary-pseudo-article)
8040 (error "This is a pseudo-article."))
8041 (let ((article (or article (gnus-summary-article-number)))
8042 (all-headers (not (not all-headers))) ;Must be T or NIL.
8046 (set-buffer gnus-summary-buffer)
8047 (if (or (null gnus-current-article)
8048 (null gnus-article-current)
8049 (null (get-buffer gnus-article-buffer))
8050 (not (eq article (cdr gnus-article-current)))
8051 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8053 ;; The requested article is different from the current article.
8055 (gnus-summary-display-article article all-headers)
8057 (if (or all-headers gnus-show-all-headers)
8058 (gnus-article-show-all-headers))
8061 (gnus-article-set-window-start
8062 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8064 (defun gnus-summary-set-current-mark (&optional current-mark)
8065 "Obsolete function."
8068 (defun gnus-summary-next-article (&optional unread subject backward)
8069 "Select the next article.
8070 If UNREAD, only unread articles are selected.
8071 If SUBJECT, only articles with SUBJECT are selected.
8072 If BACKWARD, the previous article is selected instead of the next."
8074 (gnus-set-global-variables)
8077 ;; Is there such an article?
8078 ((or (gnus-summary-display-article
8079 (gnus-summary-search-forward unread subject backward))
8080 (eq (gnus-summary-article-mark) gnus-canceled-mark))
8081 (gnus-summary-position-cursor))
8082 ;; If not, we try the first unread, if that is wanted.
8084 gnus-auto-select-same
8085 (or (gnus-summary-first-unread-article)
8086 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8087 (gnus-summary-position-cursor)
8088 (gnus-message 6 "Wrapped"))
8089 ;; Try to get next/previous article not displayed in this group.
8090 ((and gnus-auto-extend-newsgroup
8091 (not unread) (not subject)
8092 (setq header (gnus-more-header-forward backward)))
8093 (gnus-extend-newsgroup header backward)
8094 (let ((buffer-read-only nil))
8095 (goto-char (if backward (point-min) (point-max)))
8096 (gnus-summary-prepare-threads (list header)))
8097 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8098 gnus-newsgroup-end)))
8099 ;; Go to next/previous group.
8101 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8102 (gnus-summary-jump-to-group gnus-newsgroup-name))
8103 (let ((cmd last-command-char)
8105 (if (eq gnus-keep-same-level 'best)
8106 (gnus-summary-best-group gnus-newsgroup-name)
8107 (gnus-summary-search-group backward gnus-keep-same-level))))
8108 ;; For some reason, the group window gets selected. We change
8110 (select-window (get-buffer-window (current-buffer)))
8111 ;; Keep just the event type of CMD.
8112 ;(and (listp cmd) (setq cmd (car cmd)))
8113 ;; Select next unread newsgroup automagically.
8115 ((not gnus-auto-select-next)
8116 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8117 ((eq gnus-auto-select-next 'quietly)
8119 (if (assoc 'quit-config (gnus-find-method-for-group
8120 gnus-newsgroup-name))
8122 (gnus-message 7 "No more%s articles (%s)..."
8123 (if unread " unread" "")
8124 (if group (concat "selecting " group)
8126 (gnus-summary-next-group nil group backward)))
8128 (let ((keystrokes '(?\C-n ?\C-p))
8130 (while (or (null key) (memq key keystrokes))
8132 7 "No more%s articles%s" (if unread " unread" "")
8133 (if (and group (not (assoc 'quit-config
8134 (gnus-find-method-for-group
8135 gnus-newsgroup-name))))
8136 (format " (Type %s for %s [%s])"
8137 (single-key-description cmd) group
8138 (car (gnus-gethash group gnus-newsrc-hashtb)))
8139 (format " (Type %s to exit %s)"
8140 (single-key-description cmd)
8141 gnus-newsgroup-name)))
8142 ;; Confirm auto selection.
8143 (let* ((event (read-char)))
8144 (setq key (if (listp event) (car event) event))
8145 (if (memq key keystrokes)
8146 (let ((obuf (current-buffer)))
8147 (switch-to-buffer gnus-group-buffer)
8149 (gnus-group-jump-to-group group))
8151 (execute-kbd-macro (char-to-string key))
8153 (setq group (gnus-group-group-name))
8154 (switch-to-buffer obuf)))))
8156 (if (or (not group) (assoc 'quit-config
8157 (gnus-find-method-for-group
8158 gnus-newsgroup-name)))
8160 (gnus-summary-next-group nil group backward))
8161 (setq unread-command-events (list key)))))))))))
8163 (defun gnus-summary-next-unread-article ()
8164 "Select unread article after current one."
8166 (gnus-summary-next-article t (and gnus-auto-select-same
8167 (gnus-summary-subject-string))))
8169 (defun gnus-summary-prev-article (&optional unread subject)
8170 "Select the article after the current one.
8171 If UNREAD is non-nil, only unread articles are selected."
8173 (gnus-summary-next-article unread subject t))
8175 (defun gnus-summary-prev-unread-article ()
8176 "Select unred article before current one."
8178 (gnus-summary-prev-article t (and gnus-auto-select-same
8179 (gnus-summary-subject-string))))
8181 (defun gnus-summary-next-page (&optional lines circular)
8182 "Show next page of selected article.
8183 If end of article, select next article.
8184 Argument LINES specifies lines to be scrolled up.
8185 If CIRCULAR is non-nil, go to the start of the article instead of
8186 instead of selecting the next article when reaching the end of the
8189 (setq gnus-summary-buffer (current-buffer))
8190 (gnus-set-global-variables)
8191 (let ((article (gnus-summary-article-number))
8193 (gnus-configure-windows 'article)
8194 (if (or (null gnus-current-article)
8195 (null gnus-article-current)
8196 (/= article (cdr gnus-article-current))
8197 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8198 ;; Selected subject is different from current article's.
8199 (gnus-summary-display-article article)
8200 (gnus-eval-in-buffer-window
8202 (setq endp (gnus-article-next-page lines)))
8205 (gnus-summary-beginning-of-article))
8207 (gnus-message 3 "End of message"))
8209 (gnus-summary-next-unread-article)))))
8210 (gnus-summary-recenter)
8211 (gnus-summary-position-cursor)))
8213 (defun gnus-summary-prev-page (&optional lines)
8214 "Show previous page of selected article.
8215 Argument LINES specifies lines to be scrolled down."
8217 (gnus-set-global-variables)
8218 (let ((article (gnus-summary-article-number)))
8219 (gnus-configure-windows 'article)
8220 (if (or (null gnus-current-article)
8221 (null gnus-article-current)
8222 (/= article (cdr gnus-article-current))
8223 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8224 ;; Selected subject is different from current article's.
8225 (gnus-summary-display-article article)
8226 (gnus-summary-recenter)
8227 (gnus-eval-in-buffer-window gnus-article-buffer
8228 (gnus-article-prev-page lines))))
8229 (gnus-summary-position-cursor))
8231 (defun gnus-summary-scroll-up (lines)
8232 "Scroll up (or down) one line current article.
8233 Argument LINES specifies lines to be scrolled up (or down if negative)."
8235 (gnus-set-global-variables)
8236 (gnus-configure-windows 'article)
8237 (or (gnus-summary-select-article nil nil 'pseudo)
8238 (gnus-eval-in-buffer-window
8241 (if (gnus-article-next-page lines)
8242 (gnus-message 3 "End of message")))
8244 (gnus-article-prev-page (- lines))))))
8245 (gnus-summary-recenter)
8246 (gnus-summary-position-cursor))
8248 (defun gnus-summary-next-same-subject ()
8249 "Select next article which has the same subject as current one."
8251 (gnus-set-global-variables)
8252 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8254 (defun gnus-summary-prev-same-subject ()
8255 "Select previous article which has the same subject as current one."
8257 (gnus-set-global-variables)
8258 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8260 (defun gnus-summary-next-unread-same-subject ()
8261 "Select next unread article which has the same subject as current one."
8263 (gnus-set-global-variables)
8264 (gnus-summary-next-article t (gnus-summary-subject-string)))
8266 (defun gnus-summary-prev-unread-same-subject ()
8267 "Select previous unread article which has the same subject as current one."
8269 (gnus-set-global-variables)
8270 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8272 (defun gnus-summary-first-unread-article ()
8273 "Select the first unread article.
8274 Return nil if there are no unread articles."
8276 (gnus-set-global-variables)
8278 (if (gnus-summary-first-subject t)
8280 (gnus-summary-show-thread)
8281 (gnus-summary-first-subject t)
8282 (gnus-summary-display-article (gnus-summary-article-number))))
8283 (gnus-summary-position-cursor)))
8285 (defun gnus-summary-best-unread-article ()
8286 "Select the unread article with the highest score."
8288 (gnus-set-global-variables)
8289 (let ((scored gnus-newsgroup-scored)
8293 (or (> best (cdr (car scored)))
8294 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
8295 (not (memq art gnus-newsgroup-marked))
8296 (not (memq art gnus-newsgroup-dormant))
8297 (if (= best (cdr (car scored)))
8298 (setq article (min art article))
8300 (setq best (cdr (car scored))))))
8301 (setq scored (cdr scored)))
8303 ((or (not article) (null gnus-newsgroup-unreads))
8304 ;; We didn't find any scored articles, so we just jump to the
8306 (gnus-summary-first-unread-article))
8307 ((> best gnus-summary-default-score)
8308 ;; We found one, and it's bigger than the default score, so we
8310 (gnus-summary-goto-article article))
8312 ;; We found an article, but it has a score lower than the
8313 ;; defaults, so we try to find an article with the default
8315 (goto-char (point-min))
8316 (while (and (or (not (= (gnus-summary-article-mark) gnus-unread-mark))
8317 (and (assq (gnus-summary-article-number)
8318 gnus-newsgroup-scored)
8319 (< (cdr (assq (gnus-summary-article-number)
8320 gnus-newsgroup-scored))
8321 gnus-summary-default-score)))
8322 (zerop (forward-line 1))
8324 (if (= (gnus-summary-article-mark) gnus-unread-mark)
8325 ;; We jump to the article we have finally found.
8326 (gnus-summary-goto-article (gnus-summary-article-number))
8327 ;; Or there were no default-scored articles.
8328 (gnus-summary-goto-article article))))
8329 (gnus-summary-position-cursor)))
8331 (defun gnus-summary-goto-article (article &optional all-headers)
8332 "Fetch ARTICLE and display it if it exists.
8333 If ALL-HEADERS is non-nil, no header lines are hidden."
8339 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
8340 gnus-newsgroup-headers)
8341 nil 'require-match))))
8343 (and (gnus-summary-goto-subject article)
8344 (gnus-summary-display-article article all-headers))
8345 (gnus-summary-position-cursor)))
8347 (defun gnus-summary-goto-last-article ()
8348 "Go to the previously read article."
8351 (and gnus-last-article
8352 (gnus-summary-goto-article gnus-last-article))
8353 (gnus-summary-position-cursor)))
8355 (defun gnus-summary-pop-article (number)
8356 "Pop one article off the history and go to the previous.
8357 NUMBER articles will be popped off."
8360 (setq gnus-newsgroup-history
8361 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8363 (gnus-summary-goto-article (car to))
8364 (error "Article history empty")))
8365 (gnus-summary-position-cursor))
8367 ;; Summary article oriented commands
8369 (defun gnus-summary-refer-parent-article (n)
8370 "Refer parent article N times.
8371 The difference between N and the number of articles fetched is returned."
8373 (gnus-set-global-variables)
8377 (let ((ref (header-references (gnus-get-header-by-num
8378 (gnus-summary-article-number)))))
8379 (if (and ref (not (equal ref ""))
8380 (string-match "<[^<>]*>[ \t]*$" ref))
8381 (gnus-summary-refer-article
8382 (substring ref (match-beginning 0) (match-end 0)))
8383 (gnus-message 1 "No references in article %d"
8384 (gnus-summary-article-number))
8387 (gnus-summary-position-cursor)
8390 (defun gnus-summary-refer-article (message-id)
8391 "Refer article specified by MESSAGE-ID.
8392 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8393 (interactive "sMessage-ID: ")
8394 (if (or (not (stringp message-id))
8395 (zerop (length message-id)))
8397 ;; Construct the correct Message-ID if necessary.
8398 ;; Suggested by tale@pawl.rpi.edu.
8399 (or (string-match "^<" message-id)
8400 (setq message-id (concat "<" message-id)))
8401 (or (string-match ">$" message-id)
8402 (setq message-id (concat message-id ">")))
8403 (let ((header (car (gnus-gethash (downcase message-id)
8404 gnus-newsgroup-dependencies))))
8406 (or (gnus-summary-goto-article (header-number header))
8407 ;; The header has been read, but the article had been
8408 ;; expunged, so we insert it again.
8410 (gnus-summary-insert-line
8411 nil header 0 nil gnus-read-mark nil nil
8412 (header-subject header))
8414 (header-number header)))
8415 (let ((gnus-override-method gnus-refer-article-method)
8416 (gnus-ancient-mark gnus-read-mark)
8417 (tmp-point (window-start
8418 (get-buffer-window gnus-article-buffer)))
8420 (and gnus-refer-article-method
8421 (gnus-check-server gnus-refer-article-method))
8422 ;; Save the old article buffer.
8424 (set-buffer gnus-article-buffer)
8425 (gnus-kill-buffer " *temp Article*")
8426 (setq tmp-buf (rename-buffer " *temp Article*")))
8428 (if (gnus-article-prepare
8429 message-id nil (gnus-read-header message-id))
8431 (setq number (header-number gnus-current-headers))
8432 (gnus-rebuild-thread message-id)
8433 (gnus-summary-goto-subject number)
8434 (if (null gnus-use-full-window)
8436 (delete-windows-on tmp-buf)
8437 (gnus-configure-windows 'article 'force)))
8438 (gnus-summary-recenter)
8439 (gnus-article-set-window-start
8440 (cdr (assq number gnus-newsgroup-bookmarks)))
8442 ;; We restore the old article buffer.
8444 (kill-buffer gnus-article-buffer)
8445 (set-buffer tmp-buf)
8446 (rename-buffer gnus-article-buffer)
8447 (let ((buffer-read-only nil))
8449 (set-window-start (get-buffer-window (current-buffer))
8450 tmp-point)))))))))))
8452 (defun gnus-summary-enter-digest-group ()
8453 "Enter a digest group based on the current article."
8455 (gnus-set-global-variables)
8456 (gnus-summary-select-article)
8457 ;; We do not want a narrowed article.
8458 (gnus-summary-stop-page-breaking)
8459 (let ((name (format "%s-%d"
8460 (gnus-group-prefixed-name
8461 gnus-newsgroup-name (list 'nndoc ""))
8462 gnus-current-article))
8463 (ogroup gnus-newsgroup-name)
8464 (buf (current-buffer)))
8465 (if (gnus-group-read-ephemeral-group
8466 name (list 'nndoc name
8467 (list 'nndoc-address (get-buffer gnus-article-buffer))
8468 '(nndoc-article-type digest))
8470 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8471 (list (list (cons 'to-group ogroup))))
8472 (switch-to-buffer buf)
8473 (gnus-set-global-variables)
8474 (gnus-configure-windows 'summary)
8475 (gnus-message 3 "Article not a digest?"))))
8477 (defun gnus-summary-isearch-article ()
8478 "Do incremental search forward on current article."
8480 (gnus-set-global-variables)
8481 (gnus-summary-select-article)
8482 (gnus-eval-in-buffer-window
8483 gnus-article-buffer (isearch-forward)))
8485 (defun gnus-summary-search-article-forward (regexp &optional backward)
8486 "Search for an article containing REGEXP forward.
8487 If BACKWARD, search backward instead."
8490 (format "Search article %s (regexp%s): "
8491 (if current-prefix-arg "backward" "forward")
8492 (if gnus-last-search-regexp
8493 (concat ", default " gnus-last-search-regexp)
8495 current-prefix-arg))
8496 (gnus-set-global-variables)
8497 (if (string-equal regexp "")
8498 (setq regexp (or gnus-last-search-regexp ""))
8499 (setq gnus-last-search-regexp regexp))
8500 (if (gnus-summary-search-article regexp backward)
8501 (gnus-article-set-window-start
8502 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8503 (error "Search failed: \"%s\"" regexp)))
8505 (defun gnus-summary-search-article-backward (regexp)
8506 "Search for an article containing REGEXP backward."
8509 (format "Search article backward (regexp%s): "
8510 (if gnus-last-search-regexp
8511 (concat ", default " gnus-last-search-regexp)
8513 (gnus-summary-search-article-forward regexp 'backward))
8515 (defun gnus-summary-search-article (regexp &optional backward)
8516 "Search for an article containing REGEXP.
8517 Optional argument BACKWARD means do search for backward.
8518 gnus-select-article-hook is not called during the search."
8519 (let ((gnus-select-article-hook nil) ;Disable hook.
8520 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8523 (function re-search-backward) (function re-search-forward)))
8526 ;; Hidden thread subtrees must be searched for ,too.
8527 (gnus-summary-show-all-threads)
8528 (if (eobp) (forward-line -1))
8529 ;; First of all, search current article.
8530 ;; We don't want to read article again from NNTP server nor reset
8532 (gnus-summary-select-article)
8533 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8534 (setq last gnus-current-article)
8535 (gnus-eval-in-buffer-window gnus-article-buffer
8538 ;; Begin search from current point.
8539 (setq found (funcall re-search regexp nil t))))
8540 ;; Then search next articles.
8541 (while (and (not found)
8542 (gnus-summary-display-article
8543 (gnus-summary-search-subject backward nil nil)))
8544 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8545 (gnus-eval-in-buffer-window gnus-article-buffer
8548 (goto-char (if backward (point-max) (point-min)))
8549 (setq found (funcall re-search regexp nil t)))))
8551 ;; Adjust article pointer.
8552 (or (eq last gnus-current-article)
8553 (setq gnus-last-article last))
8554 ;; Return T if found such article.
8557 (defun gnus-summary-execute-command (header regexp command &optional backward)
8558 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8559 If HEADER is an empty string (or nil), the match is done on the entire
8560 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8562 (list (let ((completion-ignore-case t))
8565 (mapcar (lambda (string) (list string))
8566 '("Number" "Subject" "From" "Lines" "Date"
8567 "Message-ID" "Xref" "References"))
8568 nil 'require-match))
8569 (read-string "Regexp: ")
8570 (read-key-sequence "Command: ")
8571 current-prefix-arg))
8572 (gnus-set-global-variables)
8573 ;; Hidden thread subtrees must be searched as well.
8574 (gnus-summary-show-all-threads)
8575 ;; We don't want to change current point nor window configuration.
8577 (save-window-excursion
8578 (gnus-message 6 "Executing %s..." (key-description command))
8579 ;; We'd like to execute COMMAND interactively so as to give arguments.
8580 (gnus-execute header regexp
8582 (call-interactively '(, (key-binding command)))))
8584 (gnus-message 6 "Executing %s...done" (key-description command)))))
8586 (defun gnus-summary-beginning-of-article ()
8587 "Scroll the article back to the beginning."
8589 (gnus-set-global-variables)
8590 (gnus-summary-select-article)
8591 (gnus-configure-windows 'article)
8592 (gnus-eval-in-buffer-window
8595 (goto-char (point-min))
8596 (and gnus-break-pages (gnus-narrow-to-page))))
8598 (defun gnus-summary-end-of-article ()
8599 "Scroll to the end of the article."
8601 (gnus-set-global-variables)
8602 (gnus-summary-select-article)
8603 (gnus-configure-windows 'article)
8604 (gnus-eval-in-buffer-window
8607 (goto-char (point-max))
8609 (and gnus-break-pages (gnus-narrow-to-page))))
8611 (defun gnus-summary-show-article ()
8612 "Force re-fetching of the current article."
8614 (gnus-set-global-variables)
8615 (gnus-summary-select-article nil 'force)
8616 (gnus-configure-windows 'article)
8617 (gnus-summary-position-cursor))
8619 (defun gnus-summary-verbose-headers (&optional arg)
8620 "Toggle permanent full header display.
8621 If ARG is a positive number, turn header display on.
8622 If ARG is a negative number, turn header display off."
8624 (gnus-set-global-variables)
8625 (gnus-summary-toggle-header arg)
8626 (setq gnus-show-all-headers
8627 (cond ((or (not (numberp arg))
8629 (not gnus-show-all-headers))
8633 (defun gnus-summary-toggle-header (&optional arg)
8634 "Show the headers if they are hidden, or hide them if they are shown.
8635 If ARG is a positive number, show the entire header.
8636 If ARG is a negative number, hide the unwanted header lines."
8638 (gnus-set-global-variables)
8640 (set-buffer gnus-article-buffer)
8641 (let ((buffer-read-only nil))
8643 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8644 gnus-hidden-properties)
8645 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8646 (if (text-property-any (point-min) (point-max) 'invisible t)
8647 (remove-text-properties
8648 (point-min) (point-max) gnus-hidden-properties)
8649 ;; We hide the headers. This song and dance act below is
8650 ;; done because `gnus-have-all-headers' is buffer-local to
8651 ;; the summary buffer, and we only want to temporarily
8652 ;; change it in that buffer. Ugh.
8653 (let ((have gnus-have-all-headers))
8655 (set-buffer gnus-summary-buffer)
8656 (setq gnus-have-all-headers nil)
8658 (set-buffer gnus-article-buffer)
8659 (run-hooks 'gnus-article-display-hook))
8660 (setq gnus-have-all-headers have)))))
8661 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8663 (defun gnus-summary-show-all-headers ()
8664 "Make all header lines visible."
8666 (gnus-set-global-variables)
8667 (gnus-article-show-all-headers))
8669 (defun gnus-summary-toggle-mime (&optional arg)
8670 "Toggle MIME processing.
8671 If ARG is a positive number, turn MIME processing on."
8673 (gnus-set-global-variables)
8674 (setq gnus-show-mime
8675 (if (null arg) (not gnus-show-mime)
8676 (> (prefix-numeric-value arg) 0)))
8677 (gnus-summary-select-article t 'force))
8679 (defun gnus-summary-caesar-message (&optional arg)
8680 "Caesar rotate the current article by 13.
8681 The numerical prefix specifies how manu places to rotate each letter
8684 (gnus-set-global-variables)
8685 (gnus-summary-select-article)
8686 (let ((mail-header-separator ""))
8687 (gnus-eval-in-buffer-window
8691 (let ((start (window-start)))
8692 (news-caesar-buffer-body arg)
8693 (set-window-start (get-buffer-window (current-buffer)) start))))))
8695 (defun gnus-summary-stop-page-breaking ()
8696 "Stop page breaking in the current article."
8698 (gnus-set-global-variables)
8699 (gnus-summary-select-article)
8700 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8702 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8704 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8705 "Move the current article to a different newsgroup.
8706 If N is a positive number, move the N next articles.
8707 If N is a negative number, move the N previous articles.
8708 If N is nil and any articles have been marked with the process mark,
8709 move those articles instead.
8710 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8711 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8712 re-spool using this method.
8713 For this function to work, both the current newsgroup and the
8714 newsgroup that you want to move to have to support the `request-move'
8715 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8717 (gnus-set-global-variables)
8718 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8719 (error "The current newsgroup does not support article moving"))
8720 (let ((articles (gnus-summary-work-articles n))
8721 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8722 art-group to-method sel-met)
8723 (if (and (not to-newsgroup) (not select-method))
8726 (format "Where do you want to move %s? %s"
8727 (if (> (length articles) 1)
8728 (format "these %d articles" (length articles))
8730 (if gnus-current-move-group
8731 (format "(%s default) " gnus-current-move-group)
8733 gnus-active-hashtb nil nil prefix)))
8736 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8737 (setq to-newsgroup (or gnus-current-move-group "")))
8738 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8739 (gnus-activate-group to-newsgroup)
8740 (error "No such group: %s" to-newsgroup))
8741 (setq gnus-current-move-group to-newsgroup)))
8742 (setq to-method (if select-method (list select-method "")
8743 (gnus-find-method-for-group to-newsgroup)))
8744 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8745 (error "%s does not support article copying" (car to-method)))
8746 (or (gnus-check-server to-method)
8747 (error "Can't open server %s" (car to-method)))
8748 (gnus-message 6 "Moving to %s: %s..."
8749 (or select-method to-newsgroup) articles)
8752 (gnus-request-move-article
8753 (car articles) ; Article to move
8754 gnus-newsgroup-name ; From newsgrouo
8755 (nth 1 (gnus-find-method-for-group
8756 gnus-newsgroup-name)) ; Server
8757 (list 'gnus-request-accept-article
8759 (list 'quote select-method)
8761 (not (cdr articles))) ; Accept form
8762 (not (cdr articles)))) ; Only save nov last time
8763 (let* ((buffer-read-only nil)
8766 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8768 (gnus-group-prefixed-name
8770 (if select-method (list select-method "")
8771 (gnus-find-method-for-group to-newsgroup)))
8772 gnus-newsrc-hashtb)))
8773 (info (nth 2 entry))
8774 (article (car articles)))
8775 (gnus-summary-goto-subject article)
8777 (delete-region (point) (progn (forward-line 1) (point)))
8778 ;; Update the group that has been moved to.
8780 () ; This group does not exist yet.
8781 (if (not (memq article gnus-newsgroup-unreads))
8782 (setcar (cdr (cdr info))
8783 (gnus-add-to-range (nth 2 info)
8784 (list (cdr art-group)))))
8785 ;; Copy any marks over to the new group.
8786 (let ((marks '((tick . gnus-newsgroup-marked)
8787 (dormant . gnus-newsgroup-dormant)
8788 (expire . gnus-newsgroup-expirable)
8789 (bookmark . gnus-newsgroup-bookmarks)
8790 (reply . gnus-newsgroup-replied)))
8791 (to-article (cdr art-group)))
8793 (if (memq article (symbol-value (cdr (car marks))))
8794 (gnus-add-marked-articles
8795 (car info) (car (car marks)) (list to-article) info))
8796 (setq marks (cdr marks)))))
8798 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8799 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8800 (setq gnus-newsgroup-dormant
8801 (delq article gnus-newsgroup-dormant))
8802 (setq gnus-newsgroup-reads
8803 (cons (cons article gnus-canceled-mark)
8804 gnus-newsgroup-reads)))
8805 (gnus-message 1 "Couldn't move article %s" (car articles)))
8806 (gnus-summary-remove-process-mark (car articles))
8807 (setq articles (cdr articles)))))
8809 (defun gnus-summary-respool-article (&optional n respool-method)
8810 "Respool the current article.
8811 The article will be squeezed through the mail spooling process again,
8812 which means that it will be put in some mail newsgroup or other
8813 depending on `nnmail-split-methods'.
8814 If N is a positive number, respool the N next articles.
8815 If N is a negative number, respool the N previous articles.
8816 If N is nil and any articles have been marked with the process mark,
8817 respool those articles instead.
8819 Respooling can be done both from mail groups and \"real\" newsgroups.
8820 In the former case, the articles in question will be moved from the
8821 current group into whatever groups they are destined to. In the
8822 latter case, they will be copied into the relevant groups."
8824 (gnus-set-global-variables)
8825 (let ((respool-methods (gnus-methods-using 'respool))
8827 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8829 (setq respool-method
8831 "What method do you want to use when respooling? "
8832 respool-methods nil t methname)))
8833 (or (string= respool-method "")
8834 (if (assoc (symbol-name
8835 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8837 (gnus-summary-move-article n nil (intern respool-method))
8838 (gnus-summary-copy-article n nil (intern respool-method))))))
8840 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8841 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8842 "Move the current article to a different newsgroup.
8843 If N is a positive number, move the N next articles.
8844 If N is a negative number, move the N previous articles.
8845 If N is nil and any articles have been marked with the process mark,
8846 move those articles instead.
8847 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8848 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8849 re-spool using this method.
8850 For this function to work, the newsgroup that you want to move to have
8851 to support the `request-move' and `request-accept'
8852 functions. (Ie. mail newsgroups at present.)"
8854 (gnus-set-global-variables)
8855 (let ((articles (gnus-summary-work-articles n))
8856 (copy-buf (get-buffer-create "*copy work*"))
8857 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8858 art-group to-method)
8859 (buffer-disable-undo copy-buf)
8860 (if (and (not to-newsgroup) (not select-method))
8863 (format "Where do you want to copy %s? %s"
8864 (if (> (length articles) 1)
8865 (format "these %d articles" (length articles))
8867 (if gnus-current-move-group
8868 (format "(%s default) " gnus-current-move-group)
8870 gnus-active-hashtb nil nil prefix)))
8873 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8874 (setq to-newsgroup (or gnus-current-move-group "")))
8875 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8876 (gnus-activate-group to-newsgroup)
8877 (error "No such group: %s" to-newsgroup))
8878 (setq gnus-current-move-group to-newsgroup)))
8879 (setq to-method (if select-method (list select-method "")
8880 (gnus-find-method-for-group to-newsgroup)))
8881 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8882 (error "%s does not support article copying" (car to-method)))
8883 (or (gnus-check-server to-method)
8884 (error "Can't open server %s" (car to-method)))
8886 (gnus-message 6 "Copying to %s: %s..."
8887 (or select-method to-newsgroup) articles)
8890 (set-buffer copy-buf)
8891 (gnus-request-article-this-buffer
8892 (car articles) gnus-newsgroup-name)
8893 (gnus-request-accept-article
8894 (if select-method (quote select-method) to-newsgroup)
8895 (not (cdr articles)))))
8898 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8900 (gnus-group-prefixed-name
8902 (if select-method (list select-method "")
8903 (gnus-find-method-for-group to-newsgroup)))
8904 gnus-newsrc-hashtb)))
8905 (info (nth 2 entry))
8906 (article (car articles)))
8907 ;; We copy the info over to the new group.
8909 () ; This group does not exist (yet).
8910 (if (not (memq article gnus-newsgroup-unreads))
8911 (setcar (cdr (cdr info))
8912 (gnus-add-to-range (nth 2 info)
8913 (list (cdr art-group)))))
8914 ;; Copy any marks over to the new group.
8915 (let ((marks '((tick . gnus-newsgroup-marked)
8916 (dormant . gnus-newsgroup-dormant)
8917 (expire . gnus-newsgroup-expirable)
8918 (bookmark . gnus-newsgroup-bookmarks)
8919 (reply . gnus-newsgroup-replied)))
8920 (to-article (cdr art-group)))
8922 (if (memq article (symbol-value (cdr (car marks))))
8923 (gnus-add-marked-articles
8924 (car info) (car (car marks)) (list to-article) info))
8925 (setq marks (cdr marks))))))
8926 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8927 (gnus-summary-remove-process-mark (car articles))
8928 (setq articles (cdr articles)))
8929 (kill-buffer copy-buf)))
8931 (defun gnus-summary-import-article (file)
8932 "Import a random file into a mail newsgroup."
8933 (interactive "fImport file: ")
8934 (let ((group gnus-newsgroup-name)
8936 (or (gnus-check-backend-function 'request-accept-article group)
8937 (error "%s does not support article importing" group))
8938 (or (file-readable-p file)
8939 (not (file-regular-p file))
8940 (error "Can't read %s" file))
8942 (set-buffer (get-buffer-create " *import file*"))
8943 (buffer-disable-undo (current-buffer))
8945 (insert-file-contents file)
8946 (goto-char (point-min))
8947 (if (nnheader-article-p)
8949 (setq atts (file-attributes file))
8950 (insert "From: " (read-string "From: ") "\n"
8951 "Subject: " (read-string "Subject: ") "\n"
8952 "Date: " (current-time-string (nth 5 atts)) "\n"
8953 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8954 (gnus-request-accept-article group t)
8955 (kill-buffer (current-buffer)))))
8957 (defun gnus-summary-expire-articles ()
8958 "Expire all articles that are marked as expirable in the current group."
8960 (if (not (gnus-check-backend-function
8961 'request-expire-articles gnus-newsgroup-name))
8963 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
8964 gnus-newsrc-hashtb)))
8965 (total (memq 'total-expire (nth 5 info)))
8966 (expirable (if total
8967 (gnus-list-of-read-articles gnus-newsgroup-name)
8968 (setq gnus-newsgroup-expirable
8969 (sort gnus-newsgroup-expirable '<))))
8973 (gnus-message 6 "Expiring articles...")
8974 ;; The list of articles that weren't expired is returned.
8975 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
8976 (or total (setq gnus-newsgroup-expirable es))
8977 ;; We go through the old list of expirable, and mark all
8978 ;; really expired articles as non-existant.
8979 (or (eq es expirable) ; If nothing was expired, we don't mark.
8980 (let ((gnus-use-cache nil))
8982 (or (memq (car expirable) es)
8983 (gnus-summary-mark-article
8984 (car expirable) gnus-canceled-mark))
8985 (setq expirable (cdr expirable)))))
8986 (gnus-message 6 "Expiring articles...done")))))
8988 (defun gnus-summary-expire-articles-now ()
8989 "Expunge all expirable articles in the current group.
8990 This means that *all* articles that are marked as expirable will be
8991 deleted forever, right now."
8993 (or gnus-expert-user
8995 "Are you really, really, really sure you want to expunge? ")
8997 (let ((nnmail-expiry-wait -1)
8998 (nnmail-expiry-wait-function nil))
8999 (gnus-summary-expire-articles)))
9001 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9002 (defun gnus-summary-delete-article (&optional n)
9003 "Delete the N next (mail) articles.
9004 This command actually deletes articles. This is not a marking
9005 command. The article will disappear forever from you life, never to
9007 If N is negative, delete backwards.
9008 If N is nil and articles have been marked with the process mark,
9009 delete these instead."
9011 (or (gnus-check-backend-function 'request-expire-articles
9012 gnus-newsgroup-name)
9013 (error "The current newsgroup does not support article deletion."))
9014 ;; Compute the list of articles to delete.
9015 (let ((articles (gnus-summary-work-articles n))
9017 (if (and gnus-novice-user
9019 (format "Do you really want to delete %s forever? "
9020 (if (> (length articles) 1) "these articles"
9023 ;; Delete the articles.
9024 (setq not-deleted (gnus-request-expire-articles
9025 articles gnus-newsgroup-name 'force))
9027 (gnus-summary-remove-process-mark (car articles))
9028 ;; The backend might not have been able to delete the article
9030 (or (memq (car articles) not-deleted)
9031 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9032 (setq articles (cdr articles))))
9033 (gnus-summary-position-cursor)
9036 (defun gnus-summary-edit-article ()
9037 "Enter into a buffer and edit the current article.
9038 This will have permanent effect only in mail groups."
9040 (or (gnus-check-backend-function
9041 'request-replace-article gnus-newsgroup-name)
9042 (error "The current newsgroup does not support article editing."))
9043 (gnus-summary-select-article t)
9044 (gnus-configure-windows 'article)
9045 (select-window (get-buffer-window gnus-article-buffer))
9046 (gnus-message 6 "C-c C-c to end edits")
9047 (setq buffer-read-only nil)
9049 (use-local-map (copy-keymap (current-local-map)))
9050 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9051 (buffer-enable-undo)
9053 (goto-char (point-min))
9054 (search-forward "\n\n" nil t))
9056 (defun gnus-summary-edit-article-done ()
9057 "Make edits to the current article permanent."
9059 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9062 (if (not (gnus-request-replace-article
9063 (cdr gnus-article-current) (car gnus-article-current)
9065 (error "Couldn't replace article.")
9067 (use-local-map gnus-article-mode-map)
9068 (setq buffer-read-only t)
9069 (buffer-disable-undo (current-buffer))
9070 (gnus-configure-windows 'summary))
9071 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook))))
9073 (defun gnus-summary-edit-article-postpone ()
9074 "Postpone changes to the current article."
9077 (use-local-map gnus-article-mode-map)
9078 (setq buffer-read-only t)
9079 (buffer-disable-undo (current-buffer))
9080 (gnus-configure-windows 'summary)
9081 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9083 (defun gnus-summary-fancy-query ()
9084 "Query where the fancy respool algorithm would put this article."
9086 (gnus-summary-select-article)
9088 (set-buffer gnus-article-buffer)
9090 (goto-char (point-min))
9091 (search-forward "\n\n")
9092 (narrow-to-region (point-min) (point))
9093 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9095 ;; Summary score commands.
9097 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9099 (defun gnus-summary-raise-score (n)
9100 "Raise the score of the current article by N."
9102 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9104 (defun gnus-summary-set-score (n)
9105 "Set the score of the current article to N."
9107 ;; Skip dummy header line.
9109 (gnus-summary-show-thread)
9110 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9112 (let ((buffer-read-only nil))
9114 (gnus-summary-update-mark
9115 (if (= n (or gnus-summary-default-score 0)) ?
9116 (if (< n (or gnus-summary-default-score 0))
9117 gnus-score-below-mark gnus-score-over-mark)) 'score))
9118 (let* ((article (gnus-summary-article-number))
9119 (score (assq article gnus-newsgroup-scored)))
9120 (if score (setcdr score n)
9121 (setq gnus-newsgroup-scored
9122 (cons (cons article n) gnus-newsgroup-scored))))
9123 (gnus-summary-update-line)))
9125 (defun gnus-summary-current-score ()
9126 "Return the score of the current article."
9128 (message "%s" (gnus-summary-article-score)))
9130 ;; Summary marking commands.
9132 (defun gnus-summary-raise-same-subject-and-select (score)
9133 "Raise articles which has the same subject with SCORE and select the next."
9135 (let ((subject (gnus-summary-subject-string)))
9136 (gnus-summary-raise-score score)
9137 (while (gnus-summary-search-subject nil nil subject)
9138 (gnus-summary-raise-score score))
9139 (gnus-summary-next-article t)))
9141 (defun gnus-summary-raise-same-subject (score)
9142 "Raise articles which has the same subject with SCORE."
9144 (let ((subject (gnus-summary-subject-string)))
9145 (gnus-summary-raise-score score)
9146 (while (gnus-summary-search-subject nil nil subject)
9147 (gnus-summary-raise-score score))
9148 (gnus-summary-next-subject 1 t)))
9150 (defun gnus-score-default (level)
9151 (if level (prefix-numeric-value level)
9152 gnus-score-interactive-default-score))
9154 (defun gnus-summary-raise-thread (&optional score)
9155 "Raise the score of the articles in the current thread with SCORE."
9157 (setq score (gnus-score-default score))
9160 (let ((level (gnus-summary-thread-level)))
9161 (gnus-summary-raise-score score)
9162 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9163 (> (gnus-summary-thread-level) level))
9164 (gnus-summary-raise-score score))
9166 (let ((gnus-summary-check-current t))
9167 (or (zerop (gnus-summary-next-subject 1 t))
9169 (gnus-summary-recenter)
9170 (gnus-summary-position-cursor)
9171 (gnus-set-mode-line 'summary))
9173 (defun gnus-summary-lower-same-subject-and-select (score)
9174 "Raise articles which has the same subject with SCORE and select the next."
9176 (gnus-summary-raise-same-subject-and-select (- score)))
9178 (defun gnus-summary-lower-same-subject (score)
9179 "Raise articles which has the same subject with SCORE."
9181 (gnus-summary-raise-same-subject (- score)))
9183 (defun gnus-summary-lower-thread (&optional score)
9184 "Lower score of articles in the current thread with SCORE."
9186 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9188 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9189 "Mark articles which has the same subject as read, and then select the next.
9190 If UNMARK is positive, remove any kind of mark.
9191 If UNMARK is negative, tick articles."
9194 (setq unmark (prefix-numeric-value unmark)))
9196 (gnus-summary-mark-same-subject
9197 (gnus-summary-subject-string) unmark)))
9198 ;; Select next unread article. If auto-select-same mode, should
9199 ;; select the first unread article.
9200 (gnus-summary-next-article t (and gnus-auto-select-same
9201 (gnus-summary-subject-string)))
9202 (gnus-message 7 "%d article%s marked as %s"
9203 count (if (= count 1) " is" "s are")
9204 (if unmark "unread" "read"))))
9206 (defun gnus-summary-kill-same-subject (&optional unmark)
9207 "Mark articles which has the same subject as read.
9208 If UNMARK is positive, remove any kind of mark.
9209 If UNMARK is negative, tick articles."
9212 (setq unmark (prefix-numeric-value unmark)))
9214 (gnus-summary-mark-same-subject
9215 (gnus-summary-subject-string) unmark)))
9216 ;; If marked as read, go to next unread subject.
9218 ;; Go to next unread subject.
9219 (gnus-summary-next-subject 1 t))
9220 (gnus-message 7 "%d articles are marked as %s"
9221 count (if unmark "unread" "read"))))
9223 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9224 "Mark articles with same SUBJECT as read, and return marked number.
9225 If optional argument UNMARK is positive, remove any kinds of marks.
9226 If optional argument UNMARK is negative, mark articles as unread instead."
9230 ((null unmark) ; Mark as read.
9233 (gnus-summary-mark-article-as-read gnus-killed-mark)
9234 (gnus-summary-show-thread) t)
9235 (gnus-summary-search-forward nil subject))
9236 (setq count (1+ count))))
9237 ((> unmark 0) ; Tick.
9240 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9241 (gnus-summary-show-thread) t)
9242 (gnus-summary-search-forward nil subject))
9243 (setq count (1+ count))))
9244 (t ; Mark as unread.
9247 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9248 (gnus-summary-show-thread) t)
9249 (gnus-summary-search-forward nil subject))
9250 (setq count (1+ count)))))
9251 (gnus-set-mode-line 'summary)
9252 ;; Return the number of marked articles.
9255 (defun gnus-summary-mark-as-processable (n &optional unmark)
9256 "Set the process mark on the next N articles.
9257 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9258 the process mark instead. The difference between N and the actual
9259 number of articles marked is returned."
9261 (let ((backward (< n 0))
9266 (gnus-summary-remove-process-mark (gnus-summary-article-number))
9267 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9268 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9270 (if (/= 0 n) (gnus-message 7 "No more articles"))
9271 (gnus-summary-recenter)
9272 (gnus-summary-position-cursor)
9275 (defun gnus-summary-unmark-as-processable (n)
9276 "Remove the process mark from the next N articles.
9277 If N is negative, mark backward instead. The difference between N and
9278 the actual number of articles marked is returned."
9280 (gnus-summary-mark-as-processable n t))
9282 (defun gnus-summary-unmark-all-processable ()
9283 "Remove the process mark from all articles."
9286 (while gnus-newsgroup-processable
9287 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9288 (gnus-summary-position-cursor))
9290 (defun gnus-summary-mark-as-expirable (n)
9291 "Mark N articles forward as expirable.
9292 If N is negative, mark backward instead. The difference between N and
9293 the actual number of articles marked is returned."
9295 (gnus-summary-mark-forward n gnus-expirable-mark))
9297 (defun gnus-summary-mark-article-as-replied (article)
9298 "Mark ARTICLE replied and update the summary line."
9299 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9300 (let ((buffer-read-only nil))
9301 (if (gnus-summary-goto-subject article)
9303 (gnus-summary-update-mark gnus-replied-mark 'replied)
9306 (defun gnus-summary-set-bookmark (article)
9307 "Set a bookmark in current article."
9308 (interactive (list (gnus-summary-article-number)))
9309 (if (or (not (get-buffer gnus-article-buffer))
9310 (not gnus-current-article)
9311 (not gnus-article-current)
9312 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9313 (error "No current article selected"))
9314 ;; Remove old bookmark, if one exists.
9315 (let ((old (assq article gnus-newsgroup-bookmarks)))
9316 (if old (setq gnus-newsgroup-bookmarks
9317 (delq old gnus-newsgroup-bookmarks))))
9318 ;; Set the new bookmark, which is on the form
9319 ;; (article-number . line-number-in-body).
9320 (setq gnus-newsgroup-bookmarks
9324 (set-buffer gnus-article-buffer)
9328 (goto-char (point-min))
9329 (search-forward "\n\n" nil t)
9332 gnus-newsgroup-bookmarks))
9333 (gnus-message 6 "A bookmark has been added to the current article."))
9335 (defun gnus-summary-remove-bookmark (article)
9336 "Remove the bookmark from the current article."
9337 (interactive (list (gnus-summary-article-number)))
9338 ;; Remove old bookmark, if one exists.
9339 (let ((old (assq article gnus-newsgroup-bookmarks)))
9342 (setq gnus-newsgroup-bookmarks
9343 (delq old gnus-newsgroup-bookmarks))
9344 (gnus-message 6 "Removed bookmark."))
9345 (gnus-message 6 "No bookmark in current article."))))
9347 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9348 (defun gnus-summary-mark-as-dormant (n)
9349 "Mark N articles forward as dormant.
9350 If N is negative, mark backward instead. The difference between N and
9351 the actual number of articles marked is returned."
9353 (gnus-summary-mark-forward n gnus-dormant-mark))
9355 (defun gnus-summary-set-process-mark (article)
9356 "Set the process mark on ARTICLE and update the summary line."
9357 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9358 (let ((buffer-read-only nil))
9359 (if (gnus-summary-goto-subject article)
9361 (gnus-summary-show-thread)
9362 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9364 (gnus-summary-update-mark gnus-process-mark 'replied)
9367 (defun gnus-summary-remove-process-mark (article)
9368 "Remove the process mark from ARTICLE and update the summary line."
9369 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9370 (let ((buffer-read-only nil))
9371 (if (gnus-summary-goto-subject article)
9373 (gnus-summary-show-thread)
9374 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9376 (gnus-summary-update-mark ? 'replied)
9377 (if (memq article gnus-newsgroup-replied)
9378 (gnus-summary-update-mark gnus-replied-mark 'replied))
9381 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9382 "Mark N articles as read forwards.
9383 If N is negative, mark backwards instead.
9384 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9386 The difference between N and the actual number of articles marked is
9389 (gnus-set-global-variables)
9390 (let ((backward (< n 0))
9391 (gnus-summary-goto-unread
9392 (and gnus-summary-goto-unread
9393 (not (memq mark (list gnus-unread-mark
9394 gnus-ticked-mark gnus-dormant-mark)))))
9396 (mark (or mark gnus-del-mark)))
9398 (gnus-summary-mark-article nil mark no-expire)
9399 (zerop (gnus-summary-next-subject
9400 (if backward -1 1) gnus-summary-goto-unread t)))
9402 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9403 (gnus-summary-recenter)
9404 (gnus-summary-position-cursor)
9405 (gnus-set-mode-line 'summary)
9408 (defun gnus-summary-mark-article-as-read (mark)
9409 "Mark the current article quickly as read with MARK."
9410 (let ((article (gnus-summary-article-number)))
9411 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9412 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9413 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9414 (setq gnus-newsgroup-reads
9415 (cons (cons article mark) gnus-newsgroup-reads))
9416 ;; Possibly remove from cache, if that is used.
9417 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9418 (and gnus-newsgroup-auto-expire
9419 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9420 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9421 (= mark gnus-read-mark))
9423 (setq mark gnus-expirable-mark)
9424 (setq gnus-newsgroup-expirable
9425 (cons article gnus-newsgroup-expirable))))
9426 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9429 (gnus-summary-update-mark mark 'unread)
9432 (defun gnus-summary-mark-article-as-unread (mark)
9433 "Mark the current article quickly as unread with MARK."
9434 (let ((article (gnus-summary-article-number)))
9435 (or (memq article gnus-newsgroup-unreads)
9436 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9437 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9438 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9439 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9440 (setq gnus-newsgroup-reads
9441 (delq (assq article gnus-newsgroup-reads)
9442 gnus-newsgroup-reads))
9443 (if (= mark gnus-ticked-mark)
9444 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9445 (if (= mark gnus-dormant-mark)
9446 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9448 ;; See whether the article is to be put in the cache.
9450 (vectorp (gnus-get-header-by-num article))
9452 (gnus-cache-possibly-enter-article
9453 gnus-newsgroup-name article
9454 (gnus-get-header-by-num article)
9455 (= mark gnus-ticked-mark)
9456 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9458 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9461 (gnus-summary-update-mark mark 'unread)
9464 (defun gnus-summary-mark-article (&optional article mark no-expire)
9465 "Mark ARTICLE with MARK. MARK can be any character.
9466 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9467 (dormant) and `?E' (expirable).
9468 If MARK is nil, then the default character `?D' is used.
9469 If ARTICLE is nil, then the article on the current line will be
9472 (setq mark (aref mark 0)))
9473 ;; If no mark is given, then we check auto-expiring.
9474 (and (not no-expire)
9475 gnus-newsgroup-auto-expire
9478 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9479 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9480 (= mark gnus-read-mark))))
9481 (setq mark gnus-expirable-mark))
9482 (let* ((mark (or mark gnus-del-mark))
9483 (article (or article (gnus-summary-article-number))))
9484 (or article (error "No article on current line"))
9485 (if (or (= mark gnus-unread-mark)
9486 (= mark gnus-ticked-mark)
9487 (= mark gnus-dormant-mark))
9488 (gnus-mark-article-as-unread article mark)
9489 (gnus-mark-article-as-read article mark))
9491 ;; See whether the article is to be put in the cache.
9493 (not (= mark gnus-canceled-mark))
9494 (vectorp (gnus-get-header-by-num article))
9496 (gnus-cache-possibly-enter-article
9497 gnus-newsgroup-name article
9498 (gnus-get-header-by-num article)
9499 (= mark gnus-ticked-mark)
9500 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9502 (if (gnus-summary-goto-subject article)
9503 (let ((buffer-read-only nil))
9504 (gnus-summary-show-thread)
9505 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9508 (gnus-summary-update-mark mark 'unread)
9511 (defun gnus-summary-update-mark (mark type)
9513 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9514 (buffer-read-only nil)
9518 (forward-char forward)
9519 (setq plist (text-properties-at (point)))
9522 (and plist (add-text-properties (1- (point)) (point) plist))
9523 (and (eq type 'unread)
9524 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9525 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9527 (defun gnus-mark-article-as-read (article &optional mark)
9528 "Enter ARTICLE in the pertinent lists and remove it from others."
9529 ;; Make the article expirable.
9530 (let ((mark (or mark gnus-del-mark)))
9531 (if (= mark gnus-expirable-mark)
9532 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9533 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9534 ;; Remove from unread and marked lists.
9535 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9536 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9537 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9538 (setq gnus-newsgroup-reads
9539 (cons (cons article mark) gnus-newsgroup-reads))
9540 ;; Possibly remove from cache, if that is used.
9541 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9543 (defun gnus-mark-article-as-unread (article &optional mark)
9544 "Enter ARTICLE in the pertinent lists and remove it from others."
9545 (let ((mark (or mark gnus-ticked-mark)))
9546 ;; Add to unread list.
9547 (or (memq article gnus-newsgroup-unreads)
9548 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9549 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9550 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9551 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9552 (setq gnus-newsgroup-reads
9553 (delq (assq article gnus-newsgroup-reads)
9554 gnus-newsgroup-reads))
9555 (if (= mark gnus-ticked-mark)
9556 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9557 (if (= mark gnus-dormant-mark)
9558 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9560 (defalias 'gnus-summary-mark-as-unread-forward
9561 'gnus-summary-tick-article-forward)
9562 (make-obsolete 'gnus-summary-mark-as-unread-forward
9563 'gnus-summary-tick-article-forward)
9564 (defun gnus-summary-tick-article-forward (n)
9565 "Tick N articles forwards.
9566 If N is negative, tick backwards instead.
9567 The difference between N and the number of articles ticked is returned."
9569 (gnus-summary-mark-forward n gnus-ticked-mark))
9571 (defalias 'gnus-summary-mark-as-unread-backward
9572 'gnus-summary-tick-article-backward)
9573 (make-obsolete 'gnus-summary-mark-as-unread-backward
9574 'gnus-summary-tick-article-backward)
9575 (defun gnus-summary-tick-article-backward (n)
9576 "Tick N articles backwards.
9577 The difference between N and the number of articles ticked is returned."
9579 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9581 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9582 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9583 (defun gnus-summary-tick-article (&optional article clear-mark)
9584 "Mark current article as unread.
9585 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9586 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9587 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9590 (defun gnus-summary-mark-as-read-forward (n)
9591 "Mark N articles as read forwards.
9592 If N is negative, mark backwards instead.
9593 The difference between N and the actual number of articles marked is
9596 (gnus-summary-mark-forward n gnus-del-mark t))
9598 (defun gnus-summary-mark-as-read-backward (n)
9599 "Mark the N articles as read backwards.
9600 The difference between N and the actual number of articles marked is
9603 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9605 (defun gnus-summary-mark-as-read (&optional article mark)
9606 "Mark current article as read.
9607 ARTICLE specifies the article to be marked as read.
9608 MARK specifies a string to be inserted at the beginning of the line."
9609 (gnus-summary-mark-article article mark))
9611 (defun gnus-summary-clear-mark-forward (n)
9612 "Clear marks from N articles forward.
9613 If N is negative, clear backward instead.
9614 The difference between N and the number of marks cleared is returned."
9616 (gnus-summary-mark-forward n gnus-unread-mark))
9618 (defun gnus-summary-clear-mark-backward (n)
9619 "Clear marks from N articles backward.
9620 The difference between N and the number of marks cleared is returned."
9622 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9624 (defun gnus-summary-mark-unread-as-read ()
9625 "Intended to be used by `gnus-summary-mark-article-hook'."
9626 (or (memq gnus-current-article gnus-newsgroup-marked)
9627 (memq gnus-current-article gnus-newsgroup-dormant)
9628 (memq gnus-current-article gnus-newsgroup-expirable)
9629 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9631 (defun gnus-summary-mark-region-as-read (point mark all)
9632 "Mark all unread articles between point and mark as read.
9633 If given a prefix, mark all articles between point and mark as read,
9634 even ticked and dormant ones."
9635 (interactive "r\nP")
9645 (not (memq (gnus-summary-article-number)
9646 gnus-newsgroup-marked))
9647 (not (memq (gnus-summary-article-number)
9648 gnus-newsgroup-dormant))))
9649 (gnus-summary-mark-article
9650 (gnus-summary-article-number) gnus-del-mark))
9652 (zerop (forward-line 1))))))
9654 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9655 (defalias 'gnus-summary-delete-marked-as-read
9656 'gnus-summary-remove-lines-marked-as-read)
9657 (make-obsolete 'gnus-summary-delete-marked-as-read
9658 'gnus-summary-remove-lines-marked-as-read)
9659 (defun gnus-summary-remove-lines-marked-as-read ()
9660 "Remove lines that are marked as read."
9662 (gnus-summary-remove-lines-marked-with
9664 (lambda (char) (char-to-string (symbol-value char)))
9665 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9666 gnus-killed-mark gnus-kill-file-mark
9667 gnus-low-score-mark gnus-expirable-mark
9668 gnus-canceled-mark gnus-catchup-mark)
9671 (defalias 'gnus-summary-delete-marked-with
9672 'gnus-summary-remove-lines-marked-with)
9673 (make-obsolete 'gnus-summary-delete-marked-with
9674 'gnus-summary-remove-lines-marked-with)
9675 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9676 (defun gnus-summary-remove-lines-marked-with (marks)
9677 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9678 (interactive "sMarks: ")
9679 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9680 (gnus-set-global-variables)
9681 (let ((buffer-read-only nil)
9682 (marks (concat "^[" marks "]")))
9683 (goto-char (point-min))
9684 (if gnus-newsgroup-adaptive
9685 (gnus-score-remove-lines-adaptive marks)
9686 (while (re-search-forward marks nil t)
9687 (gnus-delete-line)))
9688 ;; If we use dummy roots, we have to do an additional sweep over
9690 (if (not (eq gnus-summary-make-false-root 'dummy))
9692 (goto-char (point-min))
9693 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9694 (while (re-search-forward marks nil t)
9695 (if (gnus-subject-equal
9696 (gnus-summary-subject-string)
9699 (gnus-summary-subject-string)))
9702 (gnus-delete-line)))))
9703 (or (zerop (buffer-size))
9705 (gnus-summary-prev-subject 1)
9706 (gnus-summary-position-cursor))))
9708 (defun gnus-summary-expunge-below (&optional score)
9709 "Remove articles with score less than SCORE."
9711 (gnus-set-global-variables)
9712 (setq score (if score
9713 (prefix-numeric-value score)
9714 (or gnus-summary-default-score 0)))
9716 (set-buffer gnus-summary-buffer)
9717 (goto-char (point-min))
9718 (let ((buffer-read-only nil)
9721 (if (< (gnus-summary-article-score) score)
9725 (delete-region beg (point)))
9728 (or (zerop (buffer-size))
9730 (gnus-summary-prev-subject 1)
9731 (gnus-summary-position-cursor))))))
9733 (defun gnus-summary-mark-below (score mark)
9734 "Mark articles with score less than SCORE with MARK."
9735 (interactive "P\ncMark: ")
9736 (gnus-set-global-variables)
9737 (setq score (if score
9738 (prefix-numeric-value score)
9739 (or gnus-summary-default-score 0)))
9741 (set-buffer gnus-summary-buffer)
9742 (goto-char (point-min))
9744 (and (< (gnus-summary-article-score) score)
9745 (gnus-summary-mark-article nil mark))
9748 (defun gnus-summary-kill-below (&optional score)
9749 "Mark articles with score below SCORE as read."
9751 (gnus-set-global-variables)
9752 (gnus-summary-mark-below score gnus-killed-mark))
9754 (defun gnus-summary-clear-above (&optional score)
9755 "Clear all marks from articles with score above SCORE."
9757 (gnus-set-global-variables)
9758 (gnus-summary-mark-above score gnus-unread-mark))
9760 (defun gnus-summary-tick-above (&optional score)
9761 "Tick all articles with score above SCORE."
9763 (gnus-set-global-variables)
9764 (gnus-summary-mark-above score gnus-ticked-mark))
9766 (defun gnus-summary-mark-above (score mark)
9767 "Mark articles with score over SCORE with MARK."
9768 (interactive "P\ncMark: ")
9769 (gnus-set-global-variables)
9770 (setq score (if score
9771 (prefix-numeric-value score)
9772 (or gnus-summary-default-score 0)))
9774 (set-buffer gnus-summary-buffer)
9775 (goto-char (point-min))
9777 (if (> (gnus-summary-article-score) score)
9779 (gnus-summary-mark-article nil mark)
9781 (forward-line 1)))))
9783 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9784 (defun gnus-summary-show-all-expunged ()
9785 "Display all the hidden articles that were expunged for low scores."
9787 (gnus-set-global-variables)
9788 (let ((buffer-read-only nil))
9789 (let ((scored gnus-newsgroup-scored)
9792 (or (gnus-summary-goto-subject (car (car scored)))
9793 (and (setq h (gnus-get-header-by-num (car (car scored))))
9794 (< (cdr (car scored)) gnus-summary-expunge-below)
9795 (setq headers (cons h headers))))
9796 (setq scored (cdr scored)))
9797 (or headers (error "No expunged articles hidden."))
9798 (goto-char (point-min))
9800 (gnus-summary-update-lines
9803 (gnus-summary-prepare-unthreaded (nreverse headers))
9805 (goto-char (point-min))
9806 (gnus-summary-position-cursor)))
9808 (defun gnus-summary-show-all-dormant ()
9809 "Display all the hidden articles that are marked as dormant."
9811 (gnus-set-global-variables)
9812 (let ((buffer-read-only nil))
9813 (let ((dormant gnus-newsgroup-dormant)
9816 (or (gnus-summary-goto-subject (car dormant))
9817 (and (setq h (gnus-get-header-by-num (car dormant)))
9818 (setq headers (cons h headers))))
9819 (setq dormant (cdr dormant)))
9820 (or headers (error "No dormant articles hidden."))
9821 (goto-char (point-min))
9823 (gnus-summary-update-lines
9826 (gnus-summary-prepare-unthreaded (nreverse headers))
9828 (goto-char (point-min))
9829 (gnus-summary-position-cursor)))
9831 (defun gnus-summary-hide-all-dormant ()
9832 "Hide all dormant articles."
9834 (gnus-set-global-variables)
9835 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9836 (gnus-summary-position-cursor))
9838 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9839 "Mark all articles not marked as unread in this newsgroup as read.
9840 If prefix argument ALL is non-nil, all articles are marked as read.
9841 If QUIETLY is non-nil, no questions will be asked.
9842 If TO-HERE is non-nil, it should be a point in the buffer. All
9843 articles before this point will be marked as read.
9844 The number of articles marked as read is returned."
9846 (gnus-set-global-variables)
9849 (not gnus-interactive-catchup) ;Without confirmation?
9853 "Mark absolutely all articles as read? "
9854 "Mark all unread articles as read? ")))
9856 (not gnus-newsgroup-adaptive)
9857 (not gnus-newsgroup-auto-expire))
9859 (and all (setq gnus-newsgroup-marked nil
9860 gnus-newsgroup-dormant nil))
9861 (setq gnus-newsgroup-unreads
9862 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9863 ;; We actually mark all articles as canceled, which we
9864 ;; have to do when using auto-expiry or adaptive scoring.
9865 (let ((unreads (length gnus-newsgroup-unreads)))
9866 (gnus-summary-show-all-threads)
9867 (if (gnus-summary-first-subject (not all))
9869 (if to-here (< (point) to-here) t)
9870 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9871 (gnus-summary-search-subject nil (not all)))))
9872 (- unreads (length gnus-newsgroup-unreads))
9874 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9875 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9876 (if (and (not to-here) (eq 'nnvirtual (car method)))
9877 (nnvirtual-catchup-group
9878 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9879 (gnus-summary-position-cursor)))
9881 (defun gnus-summary-catchup-to-here (&optional all)
9882 "Mark all unticked articles before the current one as read.
9883 If ALL is non-nil, also mark ticked and dormant articles as read."
9885 (gnus-set-global-variables)
9887 (and (zerop (forward-line -1))
9890 (gnus-summary-catchup all t (point))
9891 (gnus-set-mode-line 'summary))))
9892 (gnus-summary-position-cursor))
9894 (defun gnus-summary-catchup-all (&optional quietly)
9895 "Mark all articles in this newsgroup as read."
9897 (gnus-set-global-variables)
9898 (gnus-summary-catchup t quietly))
9900 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9901 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9902 If prefix argument ALL is non-nil, all articles are marked as read."
9904 (gnus-set-global-variables)
9905 (gnus-summary-catchup all quietly nil 'fast)
9906 ;; Select next newsgroup or exit.
9907 (if (eq gnus-auto-select-next 'quietly)
9908 (gnus-summary-next-group nil)
9909 (gnus-summary-exit)))
9911 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9912 "Mark all articles in this newsgroup as read, and then exit."
9914 (gnus-set-global-variables)
9915 (gnus-summary-catchup-and-exit t quietly))
9917 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9918 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9919 "Mark all articles in this group as read and select the next group.
9920 If given a prefix, mark all articles, unread as well as ticked, as
9923 (gnus-set-global-variables)
9924 (gnus-summary-catchup all)
9925 (gnus-summary-next-group))
9927 ;; Thread-based commands.
9929 (defun gnus-summary-toggle-threads (&optional arg)
9930 "Toggle showing conversation threads.
9931 If ARG is positive number, turn showing conversation threads on."
9933 (gnus-set-global-variables)
9934 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9935 (setq gnus-show-threads
9936 (if (null arg) (not gnus-show-threads)
9937 (> (prefix-numeric-value arg) 0)))
9938 (gnus-summary-prepare)
9939 (gnus-summary-goto-subject current)
9940 (gnus-summary-position-cursor)))
9942 (defun gnus-summary-show-all-threads ()
9945 (gnus-set-global-variables)
9947 (let ((buffer-read-only nil))
9948 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9949 (gnus-summary-position-cursor))
9951 (defun gnus-summary-show-thread ()
9952 "Show thread subtrees.
9953 Returns nil if no thread was there to be shown."
9955 (gnus-set-global-variables)
9956 (let ((buffer-read-only nil)
9958 ;; first goto end then to beg, to have point at beg after let
9959 (end (progn (end-of-line) (point)))
9960 (beg (progn (beginning-of-line) (point))))
9962 ;; Any hidden lines here?
9963 (search-forward "\r" end t)
9964 (subst-char-in-region beg end ?\^M ?\n t)
9966 (gnus-summary-position-cursor))))
9968 (defun gnus-summary-hide-all-threads ()
9969 "Hide all thread subtrees."
9971 (gnus-set-global-variables)
9973 (goto-char (point-min))
9974 (gnus-summary-hide-thread)
9975 (while (and (not (eobp)) (zerop (forward-line 1)))
9976 (gnus-summary-hide-thread)))
9977 (gnus-summary-position-cursor))
9979 (defun gnus-summary-hide-thread ()
9980 "Hide thread subtrees.
9981 Returns nil if no threads were there to be hidden."
9983 (gnus-set-global-variables)
9984 (let ((buffer-read-only nil)
9986 (level (gnus-summary-thread-level))
9988 ;; Go forward until either the buffer ends or the subthread
9992 (while (and (zerop (forward-line 1))
9993 (> (gnus-summary-thread-level) level))
9998 (search-backward "\n" start t))
9999 (subst-char-in-region start end ?\n ?\^M t)
10000 (forward-line -1)))))
10002 (defun gnus-summary-go-to-next-thread (&optional previous)
10003 "Go to the same level (or less) next thread.
10004 If PREVIOUS is non-nil, go to previous thread instead.
10005 Return the article number moved to, or nil if moving was impossible."
10006 (let ((level (gnus-summary-thread-level))
10007 (article (gnus-summary-article-number)))
10009 (while (and (zerop (forward-line -1))
10010 (> (gnus-summary-thread-level) level)))
10011 (while (and (save-excursion
10014 (zerop (forward-line 1))
10015 (> (gnus-summary-thread-level) level))))
10016 (gnus-summary-recenter)
10017 (gnus-summary-position-cursor)
10018 (let ((oart (gnus-summary-article-number)))
10019 (and (/= oart article) oart))))
10021 (defun gnus-summary-next-thread (n)
10022 "Go to the same level next N'th thread.
10023 If N is negative, search backward instead.
10024 Returns the difference between N and the number of skips actually
10027 (gnus-set-global-variables)
10028 (let ((backward (< n 0))
10030 (while (and (> n 0)
10031 (gnus-summary-go-to-next-thread backward))
10033 (gnus-summary-position-cursor)
10034 (if (/= 0 n) (gnus-message 7 "No more threads"))
10037 (defun gnus-summary-prev-thread (n)
10038 "Go to the same level previous N'th thread.
10039 Returns the difference between N and the number of skips actually
10042 (gnus-set-global-variables)
10043 (gnus-summary-next-thread (- n)))
10045 (defun gnus-summary-go-down-thread (&optional same)
10046 "Go down one level in the current thread.
10047 If SAME is non-nil, also move to articles of the same level."
10048 (let ((level (gnus-summary-thread-level))
10050 (if (and (zerop (forward-line 1))
10051 (> (gnus-summary-thread-level) level))
10056 (defun gnus-summary-go-up-thread ()
10057 "Go up one level in the current thread."
10058 (let ((level (gnus-summary-thread-level))
10060 (while (and (zerop (forward-line -1))
10061 (>= (gnus-summary-thread-level) level)))
10062 (if (>= (gnus-summary-thread-level) level)
10068 (defun gnus-summary-down-thread (n)
10069 "Go down thread N steps.
10070 If N is negative, go up instead.
10071 Returns the difference between N and how many steps down that were
10074 (gnus-set-global-variables)
10077 (while (and (> n 0)
10078 (if up (gnus-summary-go-up-thread)
10079 (gnus-summary-go-down-thread)))
10081 (gnus-summary-position-cursor)
10082 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10085 (defun gnus-summary-up-thread (n)
10086 "Go up thread N steps.
10087 If N is negative, go up instead.
10088 Returns the difference between N and how many steps down that were
10091 (gnus-set-global-variables)
10092 (gnus-summary-down-thread (- n)))
10094 (defun gnus-summary-kill-thread (&optional unmark)
10095 "Mark articles under current thread as read.
10096 If the prefix argument is positive, remove any kinds of marks.
10097 If the prefix argument is negative, tick articles instead."
10099 (gnus-set-global-variables)
10101 (setq unmark (prefix-numeric-value unmark)))
10103 (level (gnus-summary-thread-level)))
10106 ;; Mark the article...
10107 (cond ((null unmark) (gnus-summary-mark-article-as-read
10109 ((> unmark 0) (gnus-summary-mark-article-as-unread
10111 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10112 ;; ...and go forward until either the buffer ends or the subtree
10114 (if (not (and (zerop (forward-line 1))
10115 (> (gnus-summary-thread-level) level)))
10116 (setq killing nil))))
10117 ;; Hide killed subtrees.
10119 gnus-thread-hide-killed
10120 (gnus-summary-hide-thread))
10121 ;; If marked as read, go to next unread subject.
10123 ;; Go to next unread subject.
10124 (gnus-summary-next-subject 1 t)))
10125 (gnus-set-mode-line 'summary))
10127 ;; Summary sorting commands
10129 (defun gnus-summary-sort-by-number (&optional reverse)
10130 "Sort summary buffer by article number.
10131 Argument REVERSE means reverse order."
10133 (gnus-set-global-variables)
10135 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10136 ;; a function, so we wrap it.
10137 (cons (lambda () (gnus-summary-article-number))
10138 'gnus-thread-sort-by-number) reverse))
10140 (defun gnus-summary-sort-by-author (&optional reverse)
10141 "Sort summary buffer by author name alphabetically.
10142 If case-fold-search is non-nil, case of letters is ignored.
10143 Argument REVERSE means reverse order."
10145 (gnus-set-global-variables)
10149 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10151 gnus-extract-address-components
10152 (header-from header))))
10153 (concat (or (car extract) (cdr extract))
10154 "\r" (header-subject header))))
10155 'gnus-thread-sort-by-author)
10158 (defun gnus-summary-sort-by-subject (&optional reverse)
10159 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10160 If case-fold-search is non-nil, case of letters is ignored.
10161 Argument REVERSE means reverse order."
10163 (gnus-set-global-variables)
10167 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10169 gnus-extract-address-components
10170 (header-from header))))
10172 (downcase (gnus-simplify-subject (gnus-summary-subject-string)))
10173 "\r" (or (car extract) (cdr extract)))))
10174 'gnus-thread-sort-by-subject)
10177 (defun gnus-summary-sort-by-date (&optional reverse)
10178 "Sort summary buffer by date.
10179 Argument REVERSE means reverse order."
10181 (gnus-set-global-variables)
10185 (gnus-sortable-date
10187 (gnus-get-header-by-num (gnus-summary-article-number)))))
10188 'gnus-thread-sort-by-date)
10191 (defun gnus-summary-sort-by-score (&optional reverse)
10192 "Sort summary buffer by score.
10193 Argument REVERSE means reverse order."
10195 (gnus-set-global-variables)
10197 (cons (lambda () (gnus-summary-article-score))
10198 'gnus-thread-sort-by-score)
10201 (defvar gnus-summary-already-sorted nil)
10202 (defun gnus-summary-sort (predicate reverse)
10203 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10204 (if gnus-summary-already-sorted
10206 (let (buffer-read-only)
10207 (if (not gnus-show-threads)
10208 ;; We do untreaded sorting...
10210 (goto-char (point-min))
10211 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10212 ;; ... or we do threaded sorting.
10213 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10214 (gnus-summary-prepare-hook nil)
10215 (gnus-summary-already-sorted nil))
10216 ;; We do that by simply regenerating the threads.
10217 (gnus-summary-prepare)
10218 (and gnus-show-threads
10219 gnus-thread-hide-subtree
10220 (gnus-summary-hide-all-threads))
10221 ;; If in async mode, we send some info to the backend.
10222 (and gnus-newsgroup-async
10223 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10224 (gnus-request-asynchronous
10225 gnus-newsgroup-name
10226 (if (and gnus-asynchronous-article-function
10227 (fboundp gnus-asynchronous-article-function))
10228 (funcall gnus-asynchronous-article-function
10229 gnus-newsgroup-threads)))))))))
10232 (defun gnus-sortable-date (date)
10233 "Make sortable string by string-lessp from DATE.
10234 Timezone package is used."
10235 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10236 (year (aref date 0))
10237 (month (aref date 1))
10238 (day (aref date 2)))
10239 (timezone-make-sortable-date
10241 (timezone-make-time-string
10242 (aref date 3) (aref date 4) (aref date 5)))))
10245 ;; Summary saving commands.
10247 (defun gnus-summary-save-article (&optional n)
10248 "Save the current article using the default saver function.
10249 If N is a positive number, save the N next articles.
10250 If N is a negative number, save the N previous articles.
10251 If N is nil and any articles have been marked with the process mark,
10252 save those articles instead.
10253 The variable `gnus-default-article-saver' specifies the saver function."
10255 (gnus-set-global-variables)
10256 (let ((articles (gnus-summary-work-articles n)))
10258 (let ((header (gnus-get-header-by-num (car articles))))
10259 (if (vectorp header)
10261 (save-window-excursion
10262 (gnus-summary-select-article t nil nil (car articles)))
10263 (or gnus-save-all-headers
10264 (gnus-article-hide-headers t))
10265 ;; Remove any X-Gnus lines.
10268 (set-buffer gnus-article-buffer)
10269 (let ((buffer-read-only nil))
10270 (goto-char (point-min))
10271 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10273 (while (re-search-forward "^X-Gnus" nil t)
10274 (beginning-of-line)
10275 (delete-region (point)
10276 (progn (forward-line 1) (point))))
10278 (save-window-excursion
10279 (if gnus-default-article-saver
10280 (funcall gnus-default-article-saver)
10281 (error "No default saver is defined."))))
10282 (if (assq 'name header)
10283 (gnus-copy-file (cdr (assq 'name header)))
10284 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10285 (gnus-summary-remove-process-mark (car articles))
10286 (setq articles (cdr articles)))
10287 (gnus-summary-position-cursor)
10290 (defun gnus-summary-pipe-output (&optional arg)
10291 "Pipe the current article to a subprocess.
10292 If N is a positive number, pipe the N next articles.
10293 If N is a negative number, pipe the N previous articles.
10294 If N is nil and any articles have been marked with the process mark,
10295 pipe those articles instead."
10297 (gnus-set-global-variables)
10298 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10299 (gnus-summary-save-article arg)))
10301 (defun gnus-summary-save-article-mail (&optional arg)
10302 "Append the current article to an mail file.
10303 If N is a positive number, save the N next articles.
10304 If N is a negative number, save the N previous articles.
10305 If N is nil and any articles have been marked with the process mark,
10306 save those articles instead."
10308 (gnus-set-global-variables)
10309 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10310 (gnus-summary-save-article arg)))
10312 (defun gnus-summary-save-article-rmail (&optional arg)
10313 "Append the current article to an rmail file.
10314 If N is a positive number, save the N next articles.
10315 If N is a negative number, save the N previous articles.
10316 If N is nil and any articles have been marked with the process mark,
10317 save those articles instead."
10319 (gnus-set-global-variables)
10320 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10321 (gnus-summary-save-article arg)))
10323 (defun gnus-summary-save-article-file (&optional arg)
10324 "Append the current article to a file.
10325 If N is a positive number, save the N next articles.
10326 If N is a negative number, save the N previous articles.
10327 If N is nil and any articles have been marked with the process mark,
10328 save those articles instead."
10330 (gnus-set-global-variables)
10331 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10332 (gnus-summary-save-article arg)))
10334 (defun gnus-read-save-file-name (prompt default-name)
10335 (let ((methods gnus-split-methods)
10337 (if (not gnus-split-methods)
10340 (set-buffer gnus-article-buffer)
10341 (gnus-narrow-to-headers)
10343 (goto-char (point-min))
10344 (and (condition-case ()
10345 (re-search-forward (car (car methods)) nil t)
10347 (setq split-name (cons (nth 1 (car methods)) split-name)))
10348 (setq methods (cdr methods)))
10350 (cond ((null split-name)
10352 (concat prompt " (default "
10353 (file-name-nondirectory default-name) ") ")
10354 (file-name-directory default-name)
10356 ((= 1 (length split-name))
10358 (concat prompt " (default " (car split-name) ") ")
10359 gnus-article-save-directory
10360 (concat gnus-article-save-directory (car split-name))))
10362 (setq split-name (mapcar (lambda (el) (list el))
10363 (nreverse split-name)))
10364 (let ((result (completing-read
10365 (concat prompt " ")
10366 split-name nil nil)))
10367 (concat gnus-article-save-directory
10368 (if (string= result "")
10369 (car (car split-name))
10372 (defun gnus-summary-save-in-rmail (&optional filename)
10373 "Append this article to Rmail file.
10374 Optional argument FILENAME specifies file name.
10375 Directory to save to is default to `gnus-article-save-directory' which
10376 is initialized from the SAVEDIR environment variable."
10378 (gnus-set-global-variables)
10379 (let ((default-name
10380 (funcall gnus-rmail-save-name gnus-newsgroup-name
10381 gnus-current-headers gnus-newsgroup-last-rmail)))
10383 (setq filename (gnus-read-save-file-name
10384 "Save in rmail file:" default-name)))
10385 (gnus-make-directory (file-name-directory filename))
10386 (gnus-eval-in-buffer-window
10387 gnus-article-buffer
10391 (gnus-output-to-rmail filename))))
10392 ;; Remember the directory name to save articles
10393 (setq gnus-newsgroup-last-rmail filename)))
10395 (defun gnus-summary-save-in-mail (&optional filename)
10396 "Append this article to Unix mail file.
10397 Optional argument FILENAME specifies file name.
10398 Directory to save to is default to `gnus-article-save-directory' which
10399 is initialized from the SAVEDIR environment variable."
10401 (gnus-set-global-variables)
10402 (let ((default-name
10403 (funcall gnus-mail-save-name gnus-newsgroup-name
10404 gnus-current-headers gnus-newsgroup-last-mail)))
10406 (setq filename (gnus-read-save-file-name
10407 "Save in Unix mail file:" default-name)))
10409 (expand-file-name filename
10411 (file-name-directory default-name))))
10412 (gnus-make-directory (file-name-directory filename))
10413 (gnus-eval-in-buffer-window
10414 gnus-article-buffer
10418 (if (and (file-readable-p filename) (rmail-file-p filename))
10419 (gnus-output-to-rmail filename)
10420 (rmail-output filename 1 t t)))))
10421 ;; Remember the directory name to save articles.
10422 (setq gnus-newsgroup-last-mail filename)))
10424 (defun gnus-summary-save-in-file (&optional filename)
10425 "Append this article to file.
10426 Optional argument FILENAME specifies file name.
10427 Directory to save to is default to `gnus-article-save-directory' which
10428 is initialized from the SAVEDIR environment variable."
10430 (gnus-set-global-variables)
10431 (let ((default-name
10432 (funcall gnus-file-save-name gnus-newsgroup-name
10433 gnus-current-headers gnus-newsgroup-last-file)))
10435 (setq filename (gnus-read-save-file-name
10436 "Save in file:" default-name)))
10437 (gnus-make-directory (file-name-directory filename))
10438 (gnus-eval-in-buffer-window
10439 gnus-article-buffer
10443 (gnus-output-to-file filename))))
10444 ;; Remember the directory name to save articles.
10445 (setq gnus-newsgroup-last-file filename)))
10447 (defun gnus-summary-save-in-pipe (&optional command)
10448 "Pipe this article to subprocess."
10450 (gnus-set-global-variables)
10451 (let ((command (read-string "Shell command on article: "
10452 gnus-last-shell-command)))
10453 (if (string-equal command "")
10454 (setq command gnus-last-shell-command))
10455 (gnus-eval-in-buffer-window
10456 gnus-article-buffer
10459 (shell-command-on-region (point-min) (point-max) command nil)))
10460 (setq gnus-last-shell-command command)))
10462 ;; Summary extract commands
10464 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10465 (let ((buffer-read-only nil)
10466 (article (gnus-summary-article-number))
10468 (or (gnus-summary-goto-subject article)
10469 (error (format "No such article: %d" article)))
10470 (gnus-summary-position-cursor)
10471 ;; If all commands are to be bunched up on one line, we collect
10473 (if gnus-view-pseudos-separately
10475 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10478 (setq action (cdr (assq 'action (car ps))))
10479 (setq files (list (cdr (assq 'name (car ps)))))
10480 (while (and ps (cdr ps)
10481 (string= (or action "1")
10482 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10483 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10484 (setcdr ps (cdr (cdr ps))))
10487 (if (not (string-match "%s" action))
10488 (setq files (cons " " files)))
10489 (setq files (cons " " files))
10490 (and (assq 'execute (car ps))
10491 (setcdr (assq 'execute (car ps))
10492 (funcall (if (string-match "%s" action)
10495 (mapconcat (lambda (f) f) files " ")))))
10496 (setq ps (cdr ps)))))
10497 (if (and gnus-view-pseudos (not not-view))
10499 (and (assq 'execute (car pslist))
10500 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10501 (eq gnus-view-pseudos 'not-confirm)))
10502 (setq pslist (cdr pslist)))
10505 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10506 (gnus-summary-article-number)))
10509 (insert " " (file-name-nondirectory
10510 (cdr (assq 'name (car pslist))))
10511 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10512 (add-text-properties
10513 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10514 'gnus-mark gnus-unread-mark
10516 'gnus-pseudo (car pslist)))
10518 (gnus-sethash (int-to-string gnus-reffed-article-number)
10519 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10520 (setq gnus-newsgroup-unreads
10521 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10522 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10523 (setq pslist (cdr pslist)))))))
10525 (defun gnus-pseudos< (p1 p2)
10526 (let ((c1 (cdr (assq 'action p1)))
10527 (c2 (cdr (assq 'action p2))))
10528 (and c1 c2 (string< c1 c2))))
10530 (defun gnus-request-pseudo-article (props)
10531 (cond ((assq 'execute props)
10532 (gnus-execute-command (cdr (assq 'execute props)))))
10533 (let ((gnus-current-article (gnus-summary-article-number)))
10534 (run-hooks 'gnus-mark-article-hook)))
10536 (defun gnus-execute-command (command &optional automatic)
10538 (gnus-article-setup-buffer)
10539 (set-buffer gnus-article-buffer)
10540 (let ((command (if automatic command (read-string "Command: " command)))
10541 (buffer-read-only nil))
10543 (insert "$ " command "\n\n")
10544 (if gnus-view-pseudo-asynchronously
10545 (start-process "gnus-execute" nil "sh" "-c" command)
10546 (call-process "sh" nil t nil "-c" command)))))
10548 (defun gnus-copy-file (file &optional to)
10551 (list (read-file-name "Copy file: " default-directory)
10552 (read-file-name "Copy file to: " default-directory)))
10553 (gnus-set-global-variables)
10554 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10555 (and (file-directory-p to)
10556 (setq to (concat (file-name-as-directory to)
10557 (file-name-nondirectory file))))
10558 (copy-file file to))
10560 ;; Summary kill commands.
10562 (defun gnus-summary-edit-global-kill (article)
10563 "Edit the \"global\" kill file."
10564 (interactive (list (gnus-summary-article-number)))
10565 (gnus-set-global-variables)
10566 (gnus-group-edit-global-kill article))
10568 (defun gnus-summary-edit-local-kill ()
10569 "Edit a local kill file applied to the current newsgroup."
10571 (gnus-set-global-variables)
10572 (setq gnus-current-headers
10574 (int-to-string (gnus-summary-article-number))
10575 gnus-newsgroup-headers-hashtb-by-number))
10576 (gnus-set-global-variables)
10577 (gnus-group-edit-local-kill
10578 (gnus-summary-article-number) gnus-newsgroup-name))
10582 ;;; Gnus article mode
10585 (put 'gnus-article-mode 'mode-class 'special)
10587 (if gnus-article-mode-map
10589 (setq gnus-article-mode-map (make-keymap))
10590 (suppress-keymap gnus-article-mode-map)
10591 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10592 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10593 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10594 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10595 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10596 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10597 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10598 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10599 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10600 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10601 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10602 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10604 ;; Duplicate almost all summary keystrokes in the article mode map.
10607 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10608 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10609 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10610 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10611 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10612 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10613 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10614 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10615 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10616 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10617 "\C-c\C-v\C-v" "\C-d" "v"
10618 ;; "Mt" "M!" "Md" "Mr"
10619 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10620 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10621 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10622 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10623 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10624 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10625 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10626 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10627 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10628 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10629 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10631 (while (and nil commands) ; disabled
10632 (define-key gnus-article-mode-map (car commands)
10633 'gnus-article-summary-command)
10634 (setq commands (cdr commands))))
10636 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10637 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10638 "=" "n" "^" "\M-^")))
10639 (while (and nil commands) ; disabled
10640 (define-key gnus-article-mode-map (car commands)
10641 'gnus-article-summary-command-nosave)
10642 (setq commands (cdr commands)))))
10645 (defun gnus-article-mode ()
10646 "Major mode for displaying an article.
10648 All normal editing commands are switched off.
10650 The following commands are available:
10652 \\<gnus-article-mode-map>
10653 \\[gnus-article-next-page]\t Scroll the article one page forwards
10654 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10655 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10656 \\[gnus-article-show-summary]\t Display the summary buffer
10657 \\[gnus-article-mail]\t Send a reply to the address near point
10658 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10659 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10660 \\[gnus-info-find-node]\t Go to the Gnus info node"
10662 (if gnus-visual (gnus-article-make-menu-bar))
10663 (kill-all-local-variables)
10664 (setq mode-line-modified "-- ")
10665 (make-local-variable 'mode-line-format)
10666 (setq mode-line-format (copy-sequence mode-line-format))
10667 (and (equal (nth 3 mode-line-format) " ")
10668 (setcar (nthcdr 3 mode-line-format) ""))
10669 (setq mode-name "Article")
10670 (setq major-mode 'gnus-article-mode)
10671 (make-local-variable 'minor-mode-alist)
10672 (or (assq 'gnus-show-mime minor-mode-alist)
10673 (setq minor-mode-alist
10674 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10675 (use-local-map gnus-article-mode-map)
10676 (make-local-variable 'page-delimiter)
10677 (setq page-delimiter gnus-page-delimiter)
10678 (buffer-disable-undo (current-buffer))
10679 (setq buffer-read-only t) ;Disable modification
10680 (run-hooks 'gnus-article-mode-hook))
10682 (defun gnus-article-setup-buffer ()
10683 "Initialize article mode buffer."
10684 (if (get-buffer gnus-article-buffer)
10686 (set-buffer gnus-article-buffer)
10687 (buffer-disable-undo (current-buffer))
10688 (setq buffer-read-only t)
10689 (gnus-add-current-to-buffer-list)
10690 (or (eq major-mode 'gnus-article-mode)
10691 (gnus-article-mode)))
10693 (set-buffer (get-buffer-create gnus-article-buffer))
10694 (gnus-add-current-to-buffer-list)
10695 (gnus-article-mode))))
10697 ;; Set article window start at LINE, where LINE is the number of lines
10698 ;; from the head of the article.
10699 (defun gnus-article-set-window-start (&optional line)
10701 (get-buffer-window gnus-article-buffer)
10703 (set-buffer gnus-article-buffer)
10704 (goto-char (point-min))
10707 (gnus-message 6 "Moved to bookmark")
10708 (search-forward "\n\n" nil t)
10709 (forward-line line)
10712 (defun gnus-request-article-this-buffer (article group)
10713 "Get an article and insert it into this buffer."
10714 (setq group (or group gnus-newsgroup-name))
10716 ;; Open server if it has closed.
10717 (gnus-check-server (gnus-find-method-for-group group))
10719 ;; Using `gnus-request-article' directly will insert the article into
10720 ;; `nntp-server-buffer' - so we'll save some time by not having to
10721 ;; copy it from the server buffer into the article buffer.
10723 ;; We only request an article by message-id when we do not have the
10724 ;; headers for it, so we'll have to get those.
10725 (and (stringp article)
10726 (let ((gnus-override-method gnus-refer-article-method))
10727 (gnus-read-header article)))
10729 ;; If the article number is negative, that means that this article
10730 ;; doesn't belong in this newsgroup (possibly), so we find its
10731 ;; message-id and request it by id instead of number.
10732 (if (not (numberp article))
10735 (set-buffer gnus-summary-buffer)
10736 (let ((header (gnus-get-header-by-num article)))
10738 (if (vectorp header)
10739 ;; It's a real article.
10740 (setq article (header-id header))
10741 ;; It is an extracted pseudo-article.
10742 (setq article 'pseudo)
10743 (gnus-request-pseudo-article header)))
10745 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10746 (if (not (eq (car method) 'nneething))
10748 (let ((dir (concat (file-name-as-directory (nth 1 method))
10749 (header-subject header))))
10750 (if (file-directory-p dir)
10752 (setq article 'nneething)
10753 (gnus-group-enter-directory dir)))))))))
10755 ;; Check the cache.
10756 (if (and gnus-use-cache
10758 (gnus-cache-request-article article group))
10760 ;; Get the article and into the article buffer.
10761 (if (or (stringp article) (numberp article))
10764 (let ((gnus-override-method
10765 (and (stringp article) gnus-refer-article-method)))
10766 (and (gnus-request-article article group (current-buffer))
10770 (defun gnus-read-header (id)
10771 "Read the headers of article ID and enter them into the Gnus system."
10773 (if (not (setq header
10774 (car (if (let ((gnus-nov-is-evil t))
10775 (gnus-retrieve-headers
10776 (list id) gnus-newsgroup-name))
10777 (gnus-get-newsgroup-headers)))))
10780 (header-set-number header gnus-reffed-article-number))
10781 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10782 (gnus-sethash (int-to-string (header-number header)) header
10783 gnus-newsgroup-headers-hashtb-by-number)
10785 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10786 (setq gnus-current-headers header)
10789 (defun gnus-article-prepare (article &optional all-headers header)
10790 "Prepare ARTICLE in article mode buffer.
10791 ARTICLE should either be an article number or a Message-ID.
10792 If ARTICLE is an id, HEADER should be the article headers.
10793 If ALL-HEADERS is non-nil, no headers are hidden."
10795 ;; Make sure we start in a summary buffer.
10796 (or (eq major-mode 'gnus-summary-mode)
10797 (set-buffer gnus-summary-buffer))
10798 (setq gnus-summary-buffer (current-buffer))
10799 ;; Make sure the connection to the server is alive.
10800 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10803 (gnus-find-method-for-group gnus-newsgroup-name))
10804 (gnus-request-group gnus-newsgroup-name t)))
10805 (let* ((article (if header (header-number header) article))
10806 (summary-buffer (current-buffer))
10807 (internal-hook gnus-article-internal-prepare-hook)
10808 (group gnus-newsgroup-name)
10811 (gnus-article-setup-buffer)
10812 (set-buffer gnus-article-buffer)
10813 (if (not (setq result (let ((buffer-read-only nil))
10814 (gnus-request-article-this-buffer
10816 ;; There is no such article.
10818 (if (not (numberp article))
10820 (setq gnus-article-current
10821 (cons gnus-newsgroup-name article))
10822 (set-buffer gnus-summary-buffer)
10823 (setq gnus-current-article article)
10824 (gnus-summary-mark-article article gnus-canceled-mark))
10825 (gnus-message 1 "No such article (may be canceled)")
10828 (if (or (eq result 'pseudo) (eq result 'nneething))
10831 (set-buffer summary-buffer)
10832 (setq gnus-last-article gnus-current-article
10833 gnus-newsgroup-history (cons gnus-current-article
10834 gnus-newsgroup-history)
10835 gnus-current-article 0
10836 gnus-current-headers nil
10837 gnus-article-current nil)
10838 (if (eq result 'nneething)
10839 (gnus-configure-windows 'summary)
10840 (gnus-configure-windows 'article))
10841 (gnus-set-global-variables))
10842 (gnus-set-mode-line 'article))
10843 ;; The result from the `request' was an actual article -
10844 ;; or at least some text that is now displayed in the
10846 (if (and (numberp article)
10847 (not (eq article gnus-current-article)))
10848 ;; Seems like a new article has been selected.
10849 ;; `gnus-current-article' must be an article number.
10851 (set-buffer summary-buffer)
10852 (setq gnus-last-article gnus-current-article
10853 gnus-newsgroup-history (cons gnus-current-article
10854 gnus-newsgroup-history)
10855 gnus-current-article article
10856 gnus-current-headers
10857 (gnus-get-header-by-num gnus-current-article)
10858 gnus-article-current
10859 (cons gnus-newsgroup-name gnus-current-article))
10860 (gnus-summary-show-thread)
10861 (run-hooks 'gnus-mark-article-hook)
10862 (gnus-set-mode-line 'summary)
10864 (run-hooks 'gnus-visual-mark-article-hook))
10865 ;; Set the global newsgroup variables here.
10866 ;; Suggested by Jim Sisolak
10867 ;; <sisolak@trans4.neep.wisc.edu>.
10868 (gnus-set-global-variables)
10869 (setq gnus-have-all-headers
10870 (or all-headers gnus-show-all-headers))
10871 (and gnus-use-cache
10872 (vectorp (gnus-get-header-by-number article))
10873 (gnus-cache-possibly-enter-article
10875 (gnus-get-header-by-number article)
10876 (memq article gnus-newsgroup-marked)
10877 (memq article gnus-newsgroup-dormant)
10878 (memq article gnus-newsgroup-unreads)))))
10879 ;; Hooks for getting information from the article.
10880 ;; This hook must be called before being narrowed.
10881 (let (buffer-read-only)
10882 (run-hooks 'internal-hook)
10883 (run-hooks 'gnus-article-prepare-hook)
10884 ;; Decode MIME message.
10885 (if (and gnus-show-mime
10886 (or (not gnus-strict-mime)
10887 (gnus-fetch-field "Mime-Version")))
10888 (funcall gnus-show-mime-method))
10889 ;; Perform the article display hooks.
10890 (run-hooks 'gnus-article-display-hook))
10892 (goto-char (point-min))
10893 (and gnus-break-pages (gnus-narrow-to-page))
10894 (gnus-set-mode-line 'article)
10895 (gnus-configure-windows 'article)
10896 (goto-char (point-min))
10899 (defun gnus-article-show-all-headers ()
10900 "Show all article headers in article mode buffer."
10902 (gnus-article-setup-buffer)
10903 (set-buffer gnus-article-buffer)
10904 (let ((buffer-read-only nil))
10905 (remove-text-properties (point-min) (point-max)
10906 gnus-hidden-properties))))
10908 (defun gnus-article-hide-headers-if-wanted ()
10909 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10910 Provided for backwards compatability."
10911 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10912 (gnus-article-hide-headers)))
10914 (defun gnus-article-hide-headers (&optional delete)
10915 "Hide unwanted headers and possibly sort them as well."
10918 (set-buffer gnus-article-buffer)
10920 (let ((sorted gnus-sorted-header-list)
10921 (buffer-read-only nil)
10922 want-list beg want-l)
10923 ;; First we narrow to just the headers.
10925 (goto-char (point-min))
10926 ;; Hide any "From " lines at the beginning of (mail) articles.
10927 (while (looking-at "From ")
10930 (add-text-properties (point-min) (point) gnus-hidden-properties))
10931 ;; Then treat the rest of the header lines.
10934 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10935 ;; Then we use the two regular expressions
10936 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10937 ;; select which header lines is to remain visible in the
10939 (goto-char (point-min))
10940 (while (re-search-forward "^[^ \t]*:" nil t)
10941 (beginning-of-line)
10942 ;; We add the headers we want to keep to a list and delete
10943 ;; them from the buffer.
10944 (if (or (and (stringp gnus-visible-headers)
10945 (looking-at gnus-visible-headers))
10946 (and (not (stringp gnus-visible-headers))
10947 (stringp gnus-ignored-headers)
10948 (not (looking-at gnus-ignored-headers))))
10952 ;; Be sure to get multi-line headers...
10953 (re-search-forward "^[^ \t]*:" nil t)
10954 (beginning-of-line)
10956 (cons (buffer-substring beg (point)) want-list))
10957 (delete-region beg (point))
10960 ;; Next we perform the sorting by looking at
10961 ;; `gnus-sorted-header-list'.
10962 (goto-char (point-min))
10963 (while (and sorted want-list)
10964 (setq want-l want-list)
10966 (not (string-match (car sorted) (car want-l))))
10967 (setq want-l (cdr want-l)))
10970 (insert (car want-l))
10971 (setq want-list (delq (car want-l) want-list))))
10972 (setq sorted (cdr sorted)))
10973 ;; Any headers that were not matched by the sorted list we
10974 ;; just tack on the end of the visible header list.
10976 (insert (car want-list))
10977 (setq want-list (cdr want-list)))
10978 ;; And finally we make the unwanted headers invisible.
10980 (delete-region (point) (point-max))
10981 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
10982 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
10984 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
10985 (defun gnus-article-treat-overstrike ()
10986 "Translate overstrikes into bold text."
10989 (set-buffer gnus-article-buffer)
10990 (let ((buffer-read-only nil))
10991 (while (search-forward "\b" nil t)
10992 (let ((next (following-char))
10993 (previous (char-after (- (point) 2))))
10994 (cond ((eq next previous)
10995 (put-text-property (- (point) 2) (point)
10997 (put-text-property (point) (1+ (point))
11000 (put-text-property (1- (point)) (1+ (point))
11002 (put-text-property (1- (point)) (point)
11005 (put-text-property (- (point) 2) (point)
11007 (put-text-property (point) (1+ (point))
11008 'face 'underline))))))))
11010 (defun gnus-article-word-wrap ()
11011 "Format too long lines."
11014 (set-buffer gnus-article-buffer)
11015 (let ((buffer-read-only nil))
11016 (goto-char (point-min))
11017 (search-forward "\n\n" nil t)
11019 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11020 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11021 (adaptive-fill-mode t))
11022 (while (not (eobp))
11023 (and (>= (current-column) (min fill-column (window-width)))
11024 (/= (preceding-char) ?:)
11025 (fill-paragraph nil))
11026 (end-of-line 2))))))
11028 (defun gnus-article-remove-cr ()
11029 "Remove carriage returns from an article."
11032 (set-buffer gnus-article-buffer)
11033 (let ((buffer-read-only nil))
11034 (goto-char (point-min))
11035 (while (search-forward "\r" nil t)
11036 (replace-match "" t t)))))
11038 (defun gnus-article-display-x-face (&optional force)
11039 "Look for an X-Face header and display it if present."
11040 (interactive (list 'force))
11042 (set-buffer gnus-article-buffer)
11043 (let ((inhibit-point-motion-hooks t)
11044 (case-fold-search nil))
11046 (goto-char (point-min))
11047 (search-forward "\n\n")
11048 (narrow-to-region (point-min) (point))
11049 (goto-char (point-min))
11050 (if (not (and gnus-article-x-face-command
11052 (not gnus-article-x-face-too-ugly)
11053 (and gnus-article-x-face-too-ugly
11054 (not (string-match gnus-article-x-face-too-ugly
11055 (mail-fetch-field "from")))))
11057 (goto-char (point-min))
11058 (re-search-forward "^X-Face: " nil t))))
11060 (let ((beg (point))
11061 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11062 (if (symbolp gnus-article-x-face-command)
11063 (and (or (fboundp gnus-article-x-face-command)
11064 (error "%s is not a function"
11065 gnus-article-x-face-command))
11066 (funcall gnus-article-x-face-command beg end))
11067 (call-process-region beg end "sh" nil 0 nil
11068 "-c" gnus-article-x-face-command))))))))
11070 (defun gnus-article-de-quoted-unreadable (&optional force)
11071 "Do a naïve translation of a quoted-printable-encoded article.
11072 This is in no way, shape or form meant as a replacement for real MIME
11073 processing, but is simply a stop-gap measure until MIME support is
11075 If FORCE, decode the article whether it is marked as quoted-printable
11077 (interactive (list 'force))
11079 (set-buffer gnus-article-buffer)
11080 (let ((case-fold-search t)
11081 (buffer-read-only nil)
11082 (type (gnus-fetch-field "content-transfer-encoding")))
11083 (if (or force (and type (string-match "quoted-printable" type)))
11085 (goto-char (point-min))
11086 (search-forward "\n\n" nil 'move)
11087 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11089 (defun gnus-mime-decode-quoted-printable (from to)
11090 ;; Decode quoted-printable from region between FROM and TO.
11093 (while (search-forward "=" to t)
11094 (cond ((eq (following-char) ?\n)
11097 ((looking-at "[0-9A-F][0-9A-F]")
11099 (insert (hexl-hex-string-to-integer
11100 (buffer-substring (point) (+ 2 (point)))))
11104 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11106 (defvar gnus-article-time-units
11107 (list (cons 'year (* 365.25 24 60 60))
11108 (cons 'week (* 7 24 60 60))
11109 (cons 'day (* 24 60 60))
11110 (cons 'hour (* 60 60))
11114 (defun gnus-article-date-ut (&optional type)
11115 "Convert DATE date to universal time in the current article.
11116 If TYPE is `local', convert to local time; if it is `lapsed', output
11117 how much time has lapsed since DATE."
11118 (interactive (list 'ut))
11119 (let ((date (header-date (or gnus-current-headers
11120 (gnus-get-header-by-number
11121 (gnus-summary-article-number))"")))
11122 (date-regexp "^Date: \\|^X-Sent: "))
11127 (set-buffer gnus-article-buffer)
11128 (let ((buffer-read-only nil))
11129 (goto-char (point-min))
11130 (if (and (re-search-forward date-regexp nil t)
11132 (beginning-of-line)
11133 (looking-at date-regexp)))
11134 (delete-region (gnus-point-at-bol)
11135 (progn (end-of-line) (1+ (point))))
11136 (goto-char (point-min))
11137 (goto-char (- (search-forward "\n\n") 2)))
11141 (concat "Date: " (condition-case ()
11142 (timezone-make-date-arpa-standard date)
11148 (timezone-make-date-arpa-standard date nil "UT")
11152 ;; If the date is seriously mangled, the timezone
11153 ;; functions are liable to bug out, so we condition-case
11154 ;; the entire thing.
11155 (let* ((real-sec (condition-case ()
11156 (- (gnus-seconds-since-epoch
11157 (timezone-make-date-arpa-standard
11158 (current-time-string)
11159 (current-time-zone) "UT"))
11160 (gnus-seconds-since-epoch
11161 (timezone-make-date-arpa-standard
11164 (sec (abs real-sec))
11172 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11174 (setq sec (- sec (* num (cdr unit))))
11176 (concat (if prev ", " "") (int-to-string
11178 " " (symbol-name (car unit))
11179 (if (> num 1) "s" ""))
11181 gnus-article-time-units "")
11184 " in the future\n")))))
11186 (error "Unknown conversion type: %s" type)))))))))
11188 (defun gnus-article-date-local ()
11189 "Convert the current article date to the local timezone."
11191 (gnus-article-date-ut 'local))
11193 (defun gnus-article-date-lapsed ()
11194 "Convert the current article date to time lapsed since it was sent."
11196 (gnus-article-date-ut 'lapsed))
11198 (defun gnus-article-maybe-highlight ()
11199 "Do some article highlighting if `gnus-visual' is non-nil."
11200 (if gnus-visual (gnus-article-highlight-some)))
11204 (defun gnus-output-to-rmail (file-name)
11205 "Append the current article to an Rmail file named FILE-NAME."
11207 ;; Most of these codes are borrowed from rmailout.el.
11208 (setq file-name (expand-file-name file-name))
11209 (setq rmail-default-rmail-file file-name)
11210 (let ((artbuf (current-buffer))
11211 (tmpbuf (get-buffer-create " *Gnus-output*")))
11213 (or (get-file-buffer file-name)
11214 (file-exists-p file-name)
11215 (if (gnus-yes-or-no-p
11216 (concat "\"" file-name "\" does not exist, create it? "))
11217 (let ((file-buffer (create-file-buffer file-name)))
11219 (set-buffer file-buffer)
11220 (rmail-insert-rmail-file-header)
11221 (let ((require-final-newline nil))
11222 (write-region (point-min) (point-max) file-name t 1)))
11223 (kill-buffer file-buffer))
11224 (error "Output file does not exist")))
11225 (set-buffer tmpbuf)
11226 (buffer-disable-undo (current-buffer))
11228 (insert-buffer-substring artbuf)
11229 (gnus-convert-article-to-rmail)
11230 ;; Decide whether to append to a file or to an Emacs buffer.
11231 (let ((outbuf (get-file-buffer file-name)))
11233 (append-to-file (point-min) (point-max) file-name)
11234 ;; File has been visited, in buffer OUTBUF.
11235 (set-buffer outbuf)
11236 (let ((buffer-read-only nil)
11237 (msg (and (boundp 'rmail-current-message)
11238 (symbol-value 'rmail-current-message))))
11239 ;; If MSG is non-nil, buffer is in RMAIL mode.
11242 (narrow-to-region (point-max) (point-max))))
11243 (insert-buffer-substring tmpbuf)
11246 (goto-char (point-min))
11248 (search-backward "\^_")
11249 (narrow-to-region (point) (point-max))
11250 (goto-char (1+ (point-min)))
11251 (rmail-count-new-messages t)
11252 (rmail-show-message msg)))))))
11253 (kill-buffer tmpbuf)))
11255 (defun gnus-output-to-file (file-name)
11256 "Append the current article to a file named FILE-NAME."
11257 (setq file-name (expand-file-name file-name))
11258 (let ((artbuf (current-buffer))
11259 (tmpbuf (get-buffer-create " *Gnus-output*")))
11261 (set-buffer tmpbuf)
11262 (buffer-disable-undo (current-buffer))
11264 (insert-buffer-substring artbuf)
11265 ;; Append newline at end of the buffer as separator, and then
11266 ;; save it to file.
11267 (goto-char (point-max))
11269 (append-to-file (point-min) (point-max) file-name))
11270 (kill-buffer tmpbuf)))
11272 (defun gnus-convert-article-to-rmail ()
11273 "Convert article in current buffer to Rmail message format."
11274 (let ((buffer-read-only nil))
11275 ;; Convert article directly into Babyl format.
11276 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11277 (goto-char (point-min))
11278 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11279 (while (search-forward "\n\^_" nil t) ;single char
11280 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11281 (goto-char (point-max))
11284 (defun gnus-narrow-to-page (&optional arg)
11285 "Make text outside current page invisible except for page delimiter.
11286 A numeric arg specifies to move forward or backward by that many pages,
11287 thus showing a page other than the one point was originally in."
11289 (setq arg (if arg (prefix-numeric-value arg) 0))
11291 (forward-page -1) ;Beginning of current page.
11296 (forward-page (1- arg))))
11297 ;; Find the end of the page.
11299 ;; If we stopped due to end of buffer, stay there.
11300 ;; If we stopped after a page delimiter, put end of restriction
11301 ;; at the beginning of that line.
11302 ;; These are commented out.
11303 ;; (if (save-excursion (beginning-of-line)
11304 ;; (looking-at page-delimiter))
11305 ;; (beginning-of-line))
11306 (narrow-to-region (point)
11308 ;; Find the top of the page.
11310 ;; If we found beginning of buffer, stay there.
11311 ;; If extra text follows page delimiter on same line,
11313 ;; Otherwise, show text starting with following line.
11314 (if (and (eolp) (not (bobp)))
11318 (defun gnus-gmt-to-local ()
11319 "Rewrite Date header described in GMT to local in current buffer.
11320 Intended to be used with gnus-article-prepare-hook."
11324 (goto-char (point-min))
11325 (narrow-to-region (point-min)
11326 (progn (search-forward "\n\n" nil 'move) (point)))
11327 (goto-char (point-min))
11328 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11329 (let ((buffer-read-only nil)
11330 (date (buffer-substring-no-properties
11331 (match-beginning 1) (match-end 1))))
11332 (delete-region (match-beginning 1) (match-end 1))
11334 (timezone-make-date-arpa-standard
11335 date nil (current-time-zone))))))))
11338 ;; Article mode commands
11340 (defun gnus-article-next-page (&optional lines)
11341 "Show next page of current article.
11342 If end of article, return non-nil. Otherwise return nil.
11343 Argument LINES specifies lines to be scrolled up."
11345 (move-to-window-line -1)
11346 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11347 (if (save-excursion
11349 (and (pos-visible-in-window-p) ;Not continuation line.
11351 ;; Nothing in this page.
11352 (if (or (not gnus-break-pages)
11355 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11357 (gnus-narrow-to-page 1) ;Go to next page.
11359 ;; More in this page.
11363 ;; Long lines may cause an end-of-buffer error.
11364 (goto-char (point-max))))
11367 (defun gnus-article-prev-page (&optional lines)
11368 "Show previous page of current article.
11369 Argument LINES specifies lines to be scrolled down."
11371 (move-to-window-line 0)
11372 (if (and gnus-break-pages
11374 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11376 (gnus-narrow-to-page -1) ;Go to previous page.
11377 (goto-char (point-max))
11379 (scroll-down lines)))
11381 (defun gnus-article-refer-article ()
11382 "Read article specified by message-id around point."
11384 (search-forward ">" nil t) ;Move point to end of "<....>".
11385 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11387 (buffer-substring (match-beginning 1) (match-end 1))))
11388 (set-buffer gnus-summary-buffer)
11389 (gnus-summary-refer-article message-id))
11390 (error "No references around point")))
11392 (defun gnus-article-show-summary ()
11393 "Reconfigure windows to show summary buffer."
11395 (gnus-configure-windows 'article)
11396 (gnus-summary-goto-subject gnus-current-article))
11398 (defun gnus-article-describe-briefly ()
11399 "Describe article mode commands briefly."
11402 (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")))
11404 (defun gnus-article-summary-command ()
11405 "Execute the last keystroke in the summary buffer."
11407 (let ((obuf (current-buffer))
11408 (owin (current-window-configuration))
11410 (switch-to-buffer gnus-summary-buffer 'norecord)
11411 (setq func (lookup-key (current-local-map) (this-command-keys)))
11412 (call-interactively func)
11414 (set-window-configuration owin)
11415 (set-window-point (get-buffer-window (current-buffer)) (point))))
11417 (defun gnus-article-summary-command-nosave ()
11418 "Execute the last keystroke in the summary buffer."
11421 (pop-to-buffer gnus-summary-buffer 'norecord)
11422 (setq func (lookup-key (current-local-map) (this-command-keys)))
11423 (call-interactively func)))
11426 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11429 (defalias 'gnus-batch-kill 'gnus-batch-score)
11431 (defun gnus-batch-score ()
11432 "Run batched scoring.
11433 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11434 Newsgroups is a list of strings in Bnews format. If you want to score
11435 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11436 score the alt hierarchy, you'd say \"!alt.all\"."
11439 (gnus-newsrc-parse-options
11440 (apply (function concat)
11441 (mapcar (lambda (g) (concat g " "))
11442 command-line-args-left))))
11443 (gnus-expert-user t)
11444 (nnmail-spool-file nil)
11445 (gnus-use-dribble-file nil)
11446 (yes (car yes-and-no))
11447 (no (cdr yes-and-no))
11449 ;; Disable verbose message.
11450 gnus-novice-user gnus-large-newsgroup)
11451 ;; Eat all arguments.
11452 (setq command-line-args-left nil)
11455 ;; Apply kills to specified newsgroups in command line arguments.
11456 (setq newsrc (cdr gnus-newsrc-alist))
11458 (setq group (car (car newsrc)))
11459 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11460 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11462 (or (eq (car entry) t)
11463 (not (zerop (car entry)))))
11464 (if yes (string-match yes group) t)
11465 (or (null no) (not (string-match no group))))
11467 (gnus-summary-read-group group nil t)
11468 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11469 (gnus-summary-exit))))
11470 (setq newsrc (cdr newsrc)))
11472 (switch-to-buffer gnus-group-buffer)
11473 (gnus-group-save-newsrc)))
11475 (defun gnus-apply-kill-file ()
11476 "Apply a kill file to the current newsgroup.
11477 Returns the number of articles marked as read."
11478 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11479 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11480 (gnus-apply-kill-file-internal)
11483 (defun gnus-kill-save-kill-buffer ()
11485 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11486 (if (get-file-buffer file)
11488 (set-buffer (get-file-buffer file))
11489 (and (buffer-modified-p) (save-buffer))
11490 (kill-buffer (current-buffer)))))))
11492 (defvar gnus-kill-file-name "KILL"
11493 "Suffix of the kill files.")
11495 (defun gnus-newsgroup-kill-file (newsgroup)
11496 "Return the name of a kill file name for NEWSGROUP.
11497 If NEWSGROUP is nil, return the global kill file name instead."
11498 (cond ((or (null newsgroup)
11499 (string-equal newsgroup ""))
11500 ;; The global KILL file is placed at top of the directory.
11501 (expand-file-name gnus-kill-file-name
11502 (or gnus-kill-files-directory "~/News")))
11503 ((gnus-use-long-file-name 'not-kill)
11504 ;; Append ".KILL" to newsgroup name.
11505 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
11506 "." gnus-kill-file-name)
11507 (or gnus-kill-files-directory "~/News")))
11509 ;; Place "KILL" under the hierarchical directory.
11510 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11511 "/" gnus-kill-file-name)
11512 (or gnus-kill-files-directory "~/News")))))
11519 (defvar gnus-dribble-ignore nil)
11520 (defvar gnus-dribble-eval-file nil)
11522 (defun gnus-dribble-file-name ()
11523 (concat gnus-current-startup-file "-dribble"))
11525 (defun gnus-dribble-enter (string)
11526 (if (and (not gnus-dribble-ignore)
11527 gnus-dribble-buffer
11528 (buffer-name gnus-dribble-buffer))
11529 (let ((obuf (current-buffer)))
11530 (set-buffer gnus-dribble-buffer)
11531 (insert string "\n")
11532 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11533 (set-buffer obuf))))
11535 (defun gnus-dribble-read-file ()
11536 (let ((dribble-file (gnus-dribble-file-name)))
11538 (set-buffer (setq gnus-dribble-buffer
11540 (file-name-nondirectory dribble-file))))
11541 (gnus-add-current-to-buffer-list)
11543 (set-visited-file-name dribble-file)
11544 (buffer-disable-undo (current-buffer))
11545 (bury-buffer (current-buffer))
11546 (set-buffer-modified-p nil)
11547 (let ((auto (make-auto-save-file-name))
11548 (gnus-dribble-ignore t))
11549 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11551 (if (file-newer-than-file-p auto dribble-file)
11552 (setq dribble-file auto))
11553 (insert-file-contents dribble-file)
11554 (if (not (zerop (buffer-size)))
11555 (set-buffer-modified-p t))
11557 "Auto-save file exists. Do you want to read it? ")
11558 (setq gnus-dribble-eval-file t))))))))
11560 (defun gnus-dribble-eval-file ()
11561 (if (not gnus-dribble-eval-file)
11563 (setq gnus-dribble-eval-file nil)
11565 (let ((gnus-dribble-ignore t))
11566 (set-buffer gnus-dribble-buffer)
11567 (eval-buffer (current-buffer))))))
11569 (defun gnus-dribble-delete-file ()
11570 (if (file-exists-p (gnus-dribble-file-name))
11571 (delete-file (gnus-dribble-file-name)))
11572 (if gnus-dribble-buffer
11574 (set-buffer gnus-dribble-buffer)
11575 (let ((auto (make-auto-save-file-name)))
11576 (if (file-exists-p auto)
11577 (delete-file auto))
11579 (set-buffer-modified-p nil)))))
11581 (defun gnus-dribble-save ()
11582 (if (and gnus-dribble-buffer
11583 (buffer-name gnus-dribble-buffer))
11585 (set-buffer gnus-dribble-buffer)
11588 (defun gnus-dribble-clear ()
11590 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11592 (set-buffer gnus-dribble-buffer)
11594 (set-buffer-modified-p nil)
11595 (setq buffer-saved-size (buffer-size))))))
11598 ;;; Server Communication
11601 ;; All the Gnus backends have the same interface, and should return
11602 ;; data in a similar format. Below is an overview of what functions
11603 ;; these packages must supply and what results they should return.
11607 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11610 ;; Functions for the imaginary backend `choke':
11612 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11613 ;; Should return all headers for all ARTICLES, or return NOV lines for
11616 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11617 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11618 ;; must be returned.
11620 ;; `choke-close-group GROUP &optional SERVER'
11621 ;; Close group. Most backends won't have to do anything with this
11622 ;; call, but it is an opportunity to clean up, if that is needed. It
11623 ;; is called when Gnus exits a group.
11625 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11626 ;; Return ARTICLE, which is either an article number or
11627 ;; message-id. Note that not all backends can return articles based on
11630 ;; `choke-request-list SERVER'
11631 ;; Return a list of all newsgroups on SERVER.
11633 ;; `choke-request-list-newsgroups SERVER'
11634 ;; Return a list of descriptions of all newsgroups on SERVER.
11636 ;; `choke-request-newgroups DATE &optional SERVER'
11637 ;; Return a list of all groups that have arrived after DATE on
11638 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11639 ;; always check whether the groups are old or not. Backends that do
11640 ;; not store date information may just return the entire list of
11641 ;; groups, although this might not be a good idea in general.
11643 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11644 ;; Should return a buffer that is suitable for "posting". nnspool and
11645 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11646 ;; buffer. This function should fill out the appropriate headers.
11648 ;; `choke-request-post &optional SERVER'
11649 ;; Function that will be called from a buffer to be posted.
11651 ;; `choke-open-server SERVER &optional ARGUMENT'
11652 ;; Open a connection to SERVER.
11654 ;; `choke-close-server &optional SERVER'
11655 ;; Close the connection to SERVER.
11657 ;; `choke-server-opened &optional SERVER'
11658 ;; Whether the conenction to SERVER is opened or not.
11660 ;; `choke-server-status &optional SERVER'
11661 ;; Should return a status string (not in the nntp buffer, but as the
11662 ;; result of the function).
11664 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11665 ;; Optional function for retrieving active file info on all groups in
11666 ;; GROUPS. Two return formats are supported: The normal active file
11667 ;; format, and a list of GROUP lines. This function should return (as
11668 ;; a function value) either `active' or `group', depending on what
11669 ;; format it returns.
11671 ;; The following functions are optional and apply only to backends
11672 ;; that are able to control the contents of their groups totally
11673 ;; (ie. mail backends.) Backends that aren't able to do that
11674 ;; shouldn't define these functions at all. Gnus will check for their
11675 ;; presence before attempting to call them.
11677 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11678 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11679 ;; backends will not be able to expire articles. Should return a list
11680 ;; of all articles that were not expired.
11682 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11683 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11684 ;; Removes any information it has added to the article (extra headers,
11685 ;; whatever - make it as clean as possible), and then passes the
11686 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11687 ;; function described below. If the ACCEPT-FORM returns a non-nil
11688 ;; value, the article should then be deleted. If LAST is nil, that
11689 ;; means that there will be further calls to this function. This might
11690 ;; be taken as an advice not to save buffers/internal variables just
11691 ;; yet, but wait until the last call to speed things up.
11693 ;; `choke-request-accept-article GROUP &optional LAST'
11694 ;; The contents of the current buffer will be put into GROUP. There
11695 ;; should, of course, be an article in the current buffer. This
11696 ;; function is normally only called by the function described above,
11697 ;; and LAST works the same way as in that function.
11699 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11700 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11701 ;; This provides an easy interface for allowing editing of
11702 ;; articles. Note that even headers may be edited, so the backend has
11703 ;; to update any tables (nov buffers, etc) that it maintains after
11704 ;; replacing the article.
11706 ;; `choke-request-create-group GROUP &optional SERVER'
11707 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11708 ;; might be a group that already exists, but hasn't been registered
11711 ;; All these functions must return nil if they couldn't service the
11712 ;; request. If the optional arguments are not supplied, some "current"
11713 ;; or "default" values should be used. In short, one should emulate an
11714 ;; NNTP server, in a way.
11716 ;; If you want to write a new backend, you just have to supply the
11717 ;; functions listed above. In addition, you must enter the new backend
11718 ;; into the list of valid select methods:
11719 ;; (setq gnus-valid-select-methods
11720 ;; (cons '("choke" mail) gnus-valid-select-methods))
11721 ;; The first element in this list is the name of the backend. Other
11722 ;; elemnets may be `mail' (for mail groups), `post' (for news
11723 ;; groups), `none' (neither), `respool' (for groups that can control
11724 ;; their contents).
11726 (defun gnus-start-news-server (&optional confirm)
11727 "Open a method for getting news.
11728 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11730 (if gnus-current-select-method
11731 ;; Stream is already opened.
11733 ;; Open NNTP server.
11734 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11737 ;; Read server name with completion.
11738 (setq gnus-nntp-server
11739 (completing-read "NNTP server: "
11740 (mapcar (lambda (server) (list server))
11741 (cons (list gnus-nntp-server)
11742 gnus-secondary-servers))
11743 nil nil gnus-nntp-server))))
11745 (if (and gnus-nntp-server
11746 (stringp gnus-nntp-server)
11747 (not (string= gnus-nntp-server "")))
11748 (setq gnus-select-method
11749 (cond ((or (string= gnus-nntp-server "")
11750 (string= gnus-nntp-server "::"))
11751 (list 'nnspool (system-name)))
11752 ((string-match "^:" gnus-nntp-server)
11753 (list 'nnmh gnus-nntp-server
11754 (list 'nnmh-directory
11755 (file-name-as-directory
11757 (concat "~/" (substring
11758 gnus-nntp-server 1)))))
11759 (list 'nnmh-get-new-mail nil)))
11761 (list 'nntp gnus-nntp-server)))))
11763 (setq how (car gnus-select-method))
11764 (cond ((eq how 'nnspool)
11766 (gnus-message 5 "Looking up local news spool..."))
11769 (gnus-message 5 "Looking up mh spool..."))
11772 (setq gnus-current-select-method gnus-select-method)
11773 (run-hooks 'gnus-open-server-hook)
11775 ;; gnus-open-server-hook might have opened it
11776 (gnus-server-opened gnus-select-method)
11777 (gnus-open-server gnus-select-method)
11780 "%s server on %s can't be opened. Continue? "
11781 (car gnus-select-method) (nth 1 gnus-select-method)))
11783 (gnus-message 1 "Couldn't open server on %s"
11784 (nth 1 gnus-select-method))
11788 (defun gnus-check-server (&optional method)
11789 "If the news server is down, start it up again."
11790 (let ((method (if method method gnus-select-method)))
11791 (and (stringp method)
11792 (setq method (gnus-server-to-method method)))
11793 (if (gnus-server-opened method)
11794 ;; Stream is already opened.
11797 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11798 (run-hooks 'gnus-open-server-hook)
11800 (gnus-open-server method)
11803 (defun gnus-nntp-message (&optional message)
11804 "Check the status of the NNTP server.
11805 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11806 is returned insted of the status string."
11807 (let ((status (gnus-status-message (gnus-find-method-for-group
11808 gnus-newsgroup-name)))
11809 (message (or message "")))
11810 (if (and (stringp status) (> (length status) 0))
11813 (defun gnus-get-function (method function)
11814 (and (stringp method)
11815 (setq method (gnus-server-to-method method)))
11816 (let ((func (intern (format "%s-%s" (car method) function))))
11817 (if (not (fboundp func))
11819 (require (car method))
11820 (if (not (fboundp func))
11821 (error "No such function: %s" func))))
11824 ;;; Interface functions to the backends.
11826 (defun gnus-open-server (method)
11827 (funcall (gnus-get-function method 'open-server)
11828 (nth 1 method) (nthcdr 2 method)))
11830 (defun gnus-close-server (method)
11831 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11833 (defun gnus-request-list (method)
11834 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11836 (defun gnus-request-list-newsgroups (method)
11837 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11839 (defun gnus-request-newgroups (date method)
11840 (funcall (gnus-get-function method 'request-newgroups)
11841 date (nth 1 method)))
11843 (defun gnus-server-opened (method)
11844 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11846 (defun gnus-status-message (method)
11847 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11849 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11851 (defun gnus-request-group (group &optional dont-check)
11852 (let ((method (gnus-find-method-for-group group)))
11853 ; (and t (message "%s GROUP %s" (car method) group))
11854 (funcall (gnus-get-function method 'request-group)
11855 (gnus-group-real-name group) (nth 1 method) dont-check)))
11857 (defun gnus-request-asynchronous (group &optional articles)
11858 (let ((method (gnus-find-method-for-group group)))
11859 (funcall (gnus-get-function method 'request-asynchronous)
11860 (gnus-group-real-name group) (nth 1 method) articles)))
11862 (defun gnus-list-active-group (group)
11863 (let ((method (gnus-find-method-for-group group))
11864 (func 'list-active-group))
11865 (and (gnus-check-backend-function func group)
11866 (funcall (gnus-get-function method func)
11867 (gnus-group-real-name group) (nth 1 method)))))
11869 (defun gnus-request-group-description (group)
11870 (let ((method (gnus-find-method-for-group group))
11871 (func 'request-group-description))
11872 (and (gnus-check-backend-function func group)
11873 (funcall (gnus-get-function method func)
11874 (gnus-group-real-name group) (nth 1 method)))))
11876 (defun gnus-close-group (group)
11877 (let ((method (gnus-find-method-for-group group)))
11878 (funcall (gnus-get-function method 'close-group)
11879 (gnus-group-real-name group) (nth 1 method))))
11881 (defun gnus-retrieve-headers (articles group)
11882 (let ((method (gnus-find-method-for-group group)))
11883 (if (and gnus-use-cache (numberp (car articles)))
11884 (gnus-cache-retrieve-headers articles group)
11885 (funcall (gnus-get-function method 'retrieve-headers)
11886 articles (gnus-group-real-name group) (nth 1 method)))))
11888 (defun gnus-retrieve-groups (groups method)
11889 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11891 (defun gnus-request-article (article group &optional buffer)
11892 (let ((method (gnus-find-method-for-group group)))
11893 (funcall (gnus-get-function method 'request-article)
11894 article (gnus-group-real-name group) (nth 1 method) buffer)))
11896 (defun gnus-request-head (article group)
11897 (let ((method (gnus-find-method-for-group group)))
11898 (funcall (gnus-get-function method 'request-head)
11899 article (gnus-group-real-name group) (nth 1 method))))
11901 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11902 (defun gnus-request-post-buffer (post group subject header artbuf
11903 info follow-to respect-poster)
11904 (let* ((info (or info (and group (nth 2 (gnus-gethash
11905 group gnus-newsrc-hashtb)))))
11907 (if (and gnus-post-method
11908 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11910 (format "%s" (car (gnus-find-method-for-group
11911 gnus-newsgroup-name)))
11912 gnus-valid-select-methods)))
11914 (gnus-find-method-for-group gnus-newsgroup-name))))
11915 (or (gnus-check-server method)
11916 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11917 (let ((mail-self-blind nil)
11918 (mail-archive-file-name nil))
11919 (funcall (gnus-get-function method 'request-post-buffer)
11920 post group subject header artbuf info follow-to
11923 (defun gnus-request-post (method &optional force)
11924 (and (stringp method)
11925 (setq method (gnus-server-to-method method)))
11926 (and (not force) gnus-post-method
11927 (memq 'post (assoc (format "%s" (car method))
11928 gnus-valid-select-methods))
11929 (setq method gnus-post-method))
11930 (funcall (gnus-get-function method 'request-post)
11933 (defun gnus-request-expire-articles (articles group &optional force)
11934 (let ((method (gnus-find-method-for-group group)))
11935 (funcall (gnus-get-function method 'request-expire-articles)
11936 articles (gnus-group-real-name group) (nth 1 method)
11939 (defun gnus-request-move-article
11940 (article group server accept-function &optional last)
11941 (let ((method (gnus-find-method-for-group group)))
11942 (funcall (gnus-get-function method 'request-move-article)
11943 article (gnus-group-real-name group)
11944 (nth 1 method) accept-function last)))
11946 (defun gnus-request-accept-article (group &optional last)
11947 (let ((func (if (symbolp group) group
11948 (car (gnus-find-method-for-group group)))))
11949 (funcall (intern (format "%s-request-accept-article" func))
11950 (if (stringp group) (gnus-group-real-name group) group)
11953 (defun gnus-request-replace-article (article group buffer)
11954 (let ((func (car (gnus-find-method-for-group group))))
11955 (funcall (intern (format "%s-request-replace-article" func))
11956 article (gnus-group-real-name group) buffer)))
11958 (defun gnus-request-create-group (group)
11959 (let ((method (gnus-find-method-for-group group)))
11960 (funcall (gnus-get-function method 'request-create-group)
11961 (gnus-group-real-name group) (nth 1 method))))
11963 (defun gnus-member-of-valid (symbol group)
11964 (memq symbol (assoc
11965 (format "%s" (car (gnus-find-method-for-group group)))
11966 gnus-valid-select-methods)))
11968 (defun gnus-secondary-method-p (method)
11969 (let ((methods gnus-secondary-select-methods)
11970 (gmethod (gnus-server-get-method nil method)))
11971 (while (and methods
11972 (not (equal (gnus-server-get-method nil (car methods))
11974 (setq methods (cdr methods)))
11977 (defun gnus-find-method-for-group (group &optional info)
11978 (or gnus-override-method
11980 gnus-select-method)
11981 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11984 (not (setq method (nth 4 info))))
11985 (setq method gnus-select-method)
11987 (cond ((stringp method)
11988 (gnus-server-to-method method))
11989 ((stringp (car method))
11990 (gnus-server-extend-method group method))
11993 (gnus-server-add-address method))))
11995 (defun gnus-check-backend-function (func group)
11996 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11998 (fboundp (intern (format "%s-%s" method func)))))
12000 (defun gnus-methods-using (method)
12001 (let ((valids gnus-valid-select-methods)
12004 (if (memq method (car valids))
12005 (setq outs (cons (car valids) outs)))
12006 (setq valids (cdr valids)))
12010 ;;; Active & Newsrc File Handling
12013 ;; Newsrc related functions.
12014 ;; Gnus internal format of gnus-newsrc-alist:
12015 ;; (("alt.general" 3 (1 . 1))
12016 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12017 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12018 ;; The first item is the group name; the second is the subscription
12019 ;; level; the third is either a range of a list of ranges of read
12020 ;; articles, the optional fourth element is a list of marked articles,
12021 ;; the optional fifth element is the select method.
12023 ;; Gnus internal format of gnus-newsrc-hashtb:
12024 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12025 ;; This is the entry for "alt.misc". The first element is the number
12026 ;; of unread articles in "alt.misc". The cdr of this entry is the
12027 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12028 ;; trivial to remove or add new elements into gnus-newsrc-alist
12029 ;; without scanning the entire list. So, to get the actual information
12030 ;; of "alt.misc", you'd say something like
12031 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12033 ;; Gnus internal format of gnus-active-hashtb:
12037 ;; The only element in each entry in this hash table is a range of
12038 ;; (possibly) available articles. (Articles in this range may have
12039 ;; been expired or canceled.)
12041 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12042 ;; ("alt.misc" "alt.test" "alt.general" ...)
12044 (defun gnus-setup-news (&optional rawfile level)
12045 "Setup news information.
12046 If RAWFILE is non-nil, the .newsrc file will also be read.
12047 If LEVEL is non-nil, the news will be set up at level LEVEL."
12048 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12049 ;; Clear some variables to re-initialize news information.
12050 (if init (setq gnus-newsrc-alist nil
12051 gnus-active-hashtb nil))
12053 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12054 (if init (gnus-read-newsrc-file rawfile))
12056 ;; If we don't read the complete active file, we fill in the
12058 (if (or (null gnus-read-active-file)
12059 (eq gnus-read-active-file 'some))
12060 (gnus-update-active-hashtb-from-killed))
12062 ;; Read the active file and create `gnus-active-hashtb'.
12063 ;; If `gnus-read-active-file' is nil, then we just create an empty
12064 ;; hash table. The partial filling out of the hash table will be
12065 ;; done in `gnus-get-unread-articles'.
12066 (and gnus-read-active-file
12068 (gnus-read-active-file))
12070 (or gnus-active-hashtb
12071 (setq gnus-active-hashtb (make-vector 4095 0)))
12073 ;; Possibly eval the dribble file.
12074 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12076 (gnus-update-format-specifications)
12078 ;; Find the number of unread articles in each non-dead group.
12079 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12080 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12081 ;; Find new newsgroups and treat them.
12082 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12083 (gnus-server-opened gnus-select-method))
12084 (gnus-find-new-newsgroups))
12085 (if (and init gnus-check-bogus-newsgroups
12086 gnus-read-active-file (not level)
12087 (gnus-server-opened gnus-select-method))
12088 (gnus-check-bogus-newsgroups))))
12090 (defun gnus-find-new-newsgroups ()
12091 "Search for new newsgroups and add them.
12092 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12093 The `-n' option line from .newsrc is respected."
12095 (or (gnus-check-first-time-used)
12096 (if (or (consp gnus-check-new-newsgroups)
12097 (eq gnus-check-new-newsgroups 'ask-server))
12098 (gnus-ask-server-for-new-groups)
12100 group new-newsgroups)
12101 (gnus-message 5 "Checking for new newsgroups...")
12102 (or gnus-have-read-active-file (gnus-read-active-file))
12103 (setq gnus-newsrc-last-checked-date (current-time-string))
12104 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12105 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12106 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12109 (if (or (null (setq group (symbol-name sym)))
12110 (null (symbol-value sym))
12111 (gnus-gethash group gnus-killed-hashtb)
12112 (gnus-gethash group gnus-newsrc-hashtb))
12114 (let ((do-sub (gnus-matches-options-n group)))
12116 ((eq do-sub 'subscribe)
12117 (setq groups (1+ groups))
12118 (gnus-sethash group group gnus-killed-hashtb)
12119 (funcall gnus-subscribe-options-newsgroup-method group))
12120 ((eq do-sub 'ignore)
12123 (setq groups (1+ groups))
12124 (gnus-sethash group group gnus-killed-hashtb)
12125 (if gnus-subscribe-hierarchical-interactive
12126 (setq new-newsgroups (cons group new-newsgroups))
12127 (funcall gnus-subscribe-newsgroup-method group)))))))
12128 gnus-active-hashtb)
12130 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12131 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12133 (gnus-message 6 "%d new newsgroup%s arrived."
12134 groups (if (> groups 1) "s have" " has"))
12135 (gnus-message 6 "No new newsgroups."))))))
12137 (defun gnus-matches-options-n (group)
12138 ;; Returns `subscribe' if the group is to be uncoditionally
12139 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12140 ;; no match for the group.
12142 ;; First we check the two user variables.
12144 ((and gnus-options-subscribe
12145 (string-match gnus-options-subscribe group))
12147 ((and gnus-options-not-subscribe
12148 (string-match gnus-options-not-subscribe group))
12150 ;; Then we go through the list that was retrieved from the .newsrc
12151 ;; file. This list has elements on the form
12152 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12153 ;; is in the reverse order of the options line) is returned.
12155 (let ((regs gnus-newsrc-options-n))
12157 (not (string-match (car (car regs)) group)))
12158 (setq regs (cdr regs)))
12159 (and regs (cdr (car regs)))))))
12161 (defun gnus-ask-server-for-new-groups ()
12162 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12163 (methods (cons gnus-select-method
12165 (and (consp gnus-check-new-newsgroups)
12166 gnus-check-new-newsgroups)
12167 gnus-secondary-select-methods)))
12169 (new-date (current-time-string))
12170 (hashtb (gnus-make-hashtable 100))
12171 group new-newsgroups got-new method)
12172 ;; Go through both primary and secondary select methods and
12173 ;; request new newsgroups.
12175 (setq method (gnus-server-get-method nil (car methods)))
12176 (and (gnus-check-server method)
12177 (gnus-request-newgroups date method)
12180 (set-buffer nntp-server-buffer)
12181 ;; Enter all the new groups in a hashtable.
12182 (gnus-active-to-gnus-format method hashtb 'ignore)))
12183 (setq methods (cdr methods)))
12184 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12185 ;; Now all new groups from all select methods are in `hashtb'.
12187 (lambda (group-sym)
12188 (setq group (symbol-name group-sym))
12189 (if (or (null group)
12190 (null (symbol-value group-sym))
12191 (gnus-gethash group gnus-newsrc-hashtb)
12192 (member group gnus-zombie-list)
12193 (member group gnus-killed-list))
12194 ;; The group is already known.
12196 (and (symbol-value group-sym)
12197 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12198 (let ((do-sub (gnus-matches-options-n group)))
12199 (cond ((eq do-sub 'subscribe)
12200 (setq groups (1+ groups))
12201 (gnus-sethash group group gnus-killed-hashtb)
12203 gnus-subscribe-options-newsgroup-method group))
12204 ((eq do-sub 'ignore)
12207 (setq groups (1+ groups))
12208 (gnus-sethash group group gnus-killed-hashtb)
12209 (if gnus-subscribe-hierarchical-interactive
12210 (setq new-newsgroups (cons group new-newsgroups))
12211 (funcall gnus-subscribe-newsgroup-method group)))))))
12214 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12215 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12217 (gnus-message 6 "%d new newsgroup%s arrived."
12218 groups (if (> groups 1) "s have" " has")))
12221 (defun gnus-check-first-time-used ()
12222 (if (or (> (length gnus-newsrc-alist) 1)
12223 (file-exists-p gnus-startup-file)
12224 (file-exists-p (concat gnus-startup-file ".el"))
12225 (file-exists-p (concat gnus-startup-file ".eld")))
12227 (gnus-message 6 "First time user; subscribing you to default groups")
12228 (or gnus-have-read-active-file (gnus-read-active-file))
12229 (setq gnus-newsrc-last-checked-date (current-time-string))
12230 (let ((groups gnus-default-subscribed-newsgroups)
12234 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12237 (if (null (setq group (symbol-name sym)))
12239 (let ((do-sub (gnus-matches-options-n group)))
12241 ((eq do-sub 'subscribe)
12242 (gnus-sethash group group gnus-killed-hashtb)
12243 (funcall gnus-subscribe-options-newsgroup-method group))
12244 ((eq do-sub 'ignore)
12247 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12248 gnus-active-hashtb)
12250 (if (gnus-gethash (car groups) gnus-active-hashtb)
12251 (gnus-group-change-level
12252 (car groups) gnus-level-default-subscribed gnus-level-killed))
12253 (setq groups (cdr groups)))
12254 (gnus-group-make-help-group)
12255 (and gnus-novice-user
12256 (gnus-message 7 "`A k' to list killed groups"))))))
12258 (defun gnus-subscribe-group (group previous &optional method)
12259 (gnus-group-change-level
12261 (list t group gnus-level-default-subscribed nil nil method)
12263 gnus-level-default-subscribed gnus-level-killed previous t))
12265 ;; `gnus-group-change-level' is the fundamental function for changing
12266 ;; subscription levels of newsgroups. This might mean just changing
12267 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12268 ;; again, which subscribes/unsubscribes a group, which is equally
12269 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12270 ;; from 8-9 to 1-7 means that you remove the group from the list of
12271 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12272 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12273 ;; which is trivial.
12274 ;; ENTRY can either be a string (newsgroup name) or a list (if
12275 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12276 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12278 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12279 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12281 (defun gnus-group-change-level (entry level &optional oldlevel
12282 previous fromkilled)
12283 (let (group info active num)
12284 ;; Glean what info we can from the arguments
12286 (if fromkilled (setq group (nth 1 entry))
12287 (setq group (car (nth 2 entry))))
12288 (setq group entry))
12289 (if (and (stringp entry)
12291 (< oldlevel gnus-level-zombie))
12292 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12293 (if (and (not oldlevel)
12295 (setq oldlevel (car (cdr (nth 2 entry)))))
12296 (if (stringp previous)
12297 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12299 (if (and (>= oldlevel gnus-level-zombie)
12300 (gnus-gethash group gnus-newsrc-hashtb))
12301 ;; We are trying to subscribe a group that is already
12305 (gnus-dribble-enter
12306 (format "(gnus-group-change-level %S %S %S %S %S)"
12307 group level oldlevel (car (nth 2 previous)) fromkilled))
12309 ;; Then we remove the newgroup from any old structures, if needed.
12310 ;; If the group was killed, we remove it from the killed or zombie
12311 ;; list. If not, and it is in fact going to be killed, we remove
12312 ;; it from the newsrc hash table and assoc.
12313 (cond ((>= oldlevel gnus-level-zombie)
12314 (if (= oldlevel gnus-level-zombie)
12315 (setq gnus-zombie-list (delete group gnus-zombie-list))
12316 (setq gnus-killed-list (delete group gnus-killed-list))))
12318 (if (and (>= level gnus-level-zombie)
12321 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12323 (setcdr (gnus-gethash (car (nth 3 entry))
12324 gnus-newsrc-hashtb)
12326 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12328 ;; Finally we enter (if needed) the list where it is supposed to
12329 ;; go, and change the subscription level. If it is to be killed,
12330 ;; we enter it into the killed or zombie list.
12331 (cond ((>= level gnus-level-zombie)
12332 ;; Remove from the hash table.
12333 (gnus-sethash group nil gnus-newsrc-hashtb)
12334 (or (gnus-group-foreign-p group)
12335 ;; We do not enter foreign groups into the list of dead
12337 (if (= level gnus-level-zombie)
12338 (setq gnus-zombie-list (cons group gnus-zombie-list))
12339 (setq gnus-killed-list (cons group gnus-killed-list)))))
12341 ;; If the list is to be entered into the newsrc assoc, and
12342 ;; it was killed, we have to create an entry in the newsrc
12343 ;; hashtb format and fix the pointers in the newsrc assoc.
12344 (if (>= oldlevel gnus-level-zombie)
12348 (setq info (cdr entry))
12349 (setq num (car entry)))
12350 (setq active (gnus-gethash group gnus-active-hashtb))
12352 (if active (- (1+ (cdr active)) (car active)) t))
12353 ;; Check whether the group is foreign. If so, the
12354 ;; foreign select method has to be entered into the
12356 (let ((method (gnus-group-method-name group)))
12357 (if (eq method gnus-select-method)
12358 (setq info (list group level nil))
12359 (setq info (list group level nil nil method)))))
12362 (let ((p gnus-newsrc-alist))
12363 (while (cdr (cdr p))
12366 (setq entry (cons info (cdr (cdr previous))))
12369 (setcdr (cdr previous) entry)
12370 (gnus-sethash group (cons num (cdr previous))
12371 gnus-newsrc-hashtb))
12372 (setcdr previous entry)
12373 (gnus-sethash group (cons num previous)
12374 gnus-newsrc-hashtb))
12376 (setcdr (gnus-gethash (car (car (cdr entry)))
12377 gnus-newsrc-hashtb)
12379 ;; It was alive, and it is going to stay alive, so we
12380 ;; just change the level and don't change any pointers or
12381 ;; hash table entries.
12382 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12384 (defun gnus-kill-newsgroup (newsgroup)
12385 "Obsolete function. Kills a newsgroup."
12386 (gnus-group-change-level
12387 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12389 (defun gnus-check-bogus-newsgroups (&optional confirm)
12390 "Remove bogus newsgroups.
12391 If CONFIRM is non-nil, the user has to confirm the deletion of every
12393 (let ((newsrc (cdr gnus-newsrc-alist))
12395 (gnus-message 5 "Checking bogus newsgroups...")
12396 (or gnus-have-read-active-file (gnus-read-active-file))
12397 ;; Find all bogus newsgroup that are subscribed.
12399 (setq group (car (car newsrc)))
12400 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12401 (nth 4 (car newsrc)) ; Foreign
12403 (not (gnus-y-or-n-p
12404 (format "Remove bogus newsgroup: %s " group)))))
12407 ;; Found a bogus newsgroup.
12408 (setq bogus (cons group bogus)))
12409 (setq newsrc (cdr newsrc)))
12410 ;; Remove all bogus subscribed groups by first killing them, and
12411 ;; then removing them from the list of killed groups.
12413 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12415 (gnus-group-change-level entry gnus-level-killed)
12416 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12417 (setq bogus (cdr bogus)))
12418 ;; Then we remove all bogus groups from the list of killed and
12419 ;; zombie groups. They are are removed without confirmation.
12420 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12423 (setq killed (symbol-value (car dead-lists)))
12425 (setq group (car killed))
12426 (or (gnus-gethash group gnus-active-hashtb)
12427 ;; The group is bogus.
12428 (set (car dead-lists)
12429 (delete group (symbol-value (car dead-lists)))))
12430 (setq killed (cdr killed)))
12431 (setq dead-lists (cdr dead-lists))))
12432 (gnus-message 5 "Checking bogus newsgroups...done")))
12434 (defun gnus-check-duplicate-killed-groups ()
12435 "Remove duplicates from the list of killed groups."
12437 (let ((killed gnus-killed-list))
12439 (gnus-message 9 "%d" (length killed))
12440 (setcdr killed (delete (car killed) (cdr killed)))
12441 (setq killed (cdr killed)))))
12443 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12444 ;; and compute how many unread articles there are in each group.
12445 (defun gnus-get-unread-articles (&optional level)
12446 (let* ((newsrc (cdr gnus-newsrc-alist))
12447 (level (or level (1+ gnus-level-subscribed)))
12450 (cond ((and gnus-activate-foreign-newsgroups
12451 (not (numberp gnus-activate-foreign-newsgroups)))
12452 (1+ gnus-level-subscribed))
12453 ((numberp gnus-activate-foreign-newsgroups)
12454 gnus-activate-foreign-newsgroups)
12457 info group active virtuals method)
12458 (gnus-message 5 "Checking new news...")
12461 (setq info (car newsrc)
12463 active (gnus-gethash group gnus-active-hashtb))
12465 ;; Check newsgroups. If the user doesn't want to check them, or
12466 ;; they can't be checked (for instance, if the news server can't
12467 ;; be reached) we just set the number of unread articles in this
12468 ;; newsgroup to t. This means that Gnus thinks that there are
12469 ;; unread articles, but it has no idea how many.
12470 (if (and (setq method (nth 4 info))
12471 (not (gnus-server-equal gnus-select-method
12472 (gnus-server-get-method nil method)))
12473 (not (gnus-secondary-method-p method)))
12474 ;; These groups are foreign. Check the level.
12475 (if (<= (nth 1 info) foreign-level)
12476 (if (eq (car (if (stringp method)
12477 (gnus-server-to-method method)
12478 (nth 4 info))) 'nnvirtual)
12479 ;; We have to activate the virtual groups after all
12480 ;; the others, so we just pop them on a list for
12482 (setq virtuals (cons info virtuals))
12483 (and (setq active (gnus-activate-group (car info)))
12484 ;; Close the groups as we look at them!
12485 (gnus-close-group group))))
12487 ;; These groups are native or secondary.
12488 (if (and (not gnus-read-active-file)
12489 (<= (nth 1 info) level))
12491 (or gnus-read-active-file (gnus-check-server method))
12492 (setq active (gnus-activate-group (car info))))))
12495 (gnus-get-unread-articles-in-group info active)
12496 ;; The group couldn't be reached, so we nix out the number of
12497 ;; unread articles and stuff.
12498 (gnus-sethash group nil gnus-active-hashtb)
12499 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12501 (setq newsrc (cdr newsrc)))
12503 ;; Activate the virtual groups. This has to be done after all the
12505 ;; !!! If one virtual group contains another virtual group, even
12506 ;; doing it this way might cause problems.
12508 (and (setq active (gnus-activate-group (car (car virtuals))))
12509 (gnus-get-unread-articles-in-group (car virtuals) active))
12510 (setq virtuals (cdr virtuals)))
12512 (gnus-message 5 "Checking new news...done")))
12514 ;; Create a hash table out of the newsrc alist. The `car's of the
12515 ;; alist elements are used as keys.
12516 (defun gnus-make-hashtable-from-newsrc-alist ()
12517 (let ((alist gnus-newsrc-alist)
12518 (ohashtb gnus-newsrc-hashtb)
12520 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12522 (setq prev (setq gnus-newsrc-alist
12523 (if (equal (car (car gnus-newsrc-alist))
12526 (cons (list "dummy.group" 0 nil) alist)))))
12528 (gnus-sethash (car (car alist))
12529 (cons (and ohashtb (car (gnus-gethash
12530 (car (car alist)) ohashtb)))
12531 prev) gnus-newsrc-hashtb)
12533 alist (cdr alist)))))
12535 (defun gnus-make-hashtable-from-killed ()
12536 "Create a hash table from the killed and zombie lists."
12537 (let ((lists '(gnus-killed-list gnus-zombie-list))
12539 (setq gnus-killed-hashtb
12540 (gnus-make-hashtable
12541 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12543 (setq list (symbol-value (car lists)))
12544 (setq lists (cdr lists))
12546 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12547 (setq list (cdr list))))))
12549 (defun gnus-get-unread-articles-in-group (info active)
12550 (let* ((range (nth 2 info))
12552 (marked (nth 3 info)))
12553 ;; If a cache is present, we may have to alter the active info.
12554 (and gnus-use-cache
12555 (gnus-cache-possibly-alter-active (car info) active))
12556 ;; Modify the list of read articles according to what articles
12557 ;; are available; then tally the unread articles and add the
12558 ;; number to the group hash table entry.
12560 ((zerop (cdr active))
12563 (setq num (- (1+ (cdr active)) (car active))))
12564 ((not (listp (cdr range)))
12565 ;; Fix a single (num . num) range according to the
12566 ;; active hash table.
12567 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12568 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12569 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12570 ;; Compute number of unread articles.
12571 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12573 ;; The read list is a list of ranges. Fix them according to
12574 ;; the active hash table.
12575 ;; First peel off any elements that are below the lower
12577 (while (and (cdr range)
12579 (or (and (atom (car (cdr range))) (car (cdr range)))
12580 (car (car (cdr range))))))
12581 (if (numberp (car range))
12584 (or (and (numberp (car (cdr range)))
12586 (cdr (car (cdr range))))))
12587 (setcdr (car range)
12588 (or (and (numberp (nth 1 range)) (nth 1 range))
12589 (cdr (car (cdr range))))))
12590 (setcdr range (cdr (cdr range))))
12591 ;; Adjust the first element to be the same as the lower limit.
12592 (if (and (not (atom (car range)))
12593 (< (cdr (car range)) (car active)))
12594 (setcdr (car range) (1- (car active))))
12595 ;; Then we want to peel off any elements that are higher
12596 ;; than the upper active limit.
12597 (let ((srange range))
12598 ;; Go past all legal elements.
12599 (while (and (cdr srange)
12600 (<= (or (and (atom (car (cdr srange)))
12601 (car (cdr srange)))
12602 (car (car (cdr srange)))) (cdr active)))
12603 (setq srange (cdr srange)))
12605 ;; Nuke all remaining illegal elements.
12606 (setcdr srange nil))
12608 ;; Adjust the final element.
12609 (if (and (not (atom (car srange)))
12610 (> (cdr (car srange)) (cdr active)))
12611 (setcdr (car srange) (cdr active))))
12612 ;; Compute the number of unread articles.
12614 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12615 (cdr (car range))))
12616 (or (and (atom (car range)) (car range))
12617 (car (car range))))))
12618 (setq range (cdr range)))
12619 (setq num (max 0 (- (cdr active) num)))))
12622 (and (assq 'tick marked)
12623 (inline (gnus-remove-illegal-marked-articles
12624 (assq 'tick marked) (nth 2 info))))
12625 (and (assq 'dormant marked)
12626 (inline (gnus-remove-illegal-marked-articles
12627 (assq 'dormant marked) (nth 2 info))))
12629 (gnus-gethash (car info) gnus-newsrc-hashtb)
12630 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12631 (length (cdr (assq 'dormant marked)))))))))
12634 (defun gnus-remove-illegal-marked-articles (marked ranges)
12635 (let ((m (cdr marked)))
12636 ;; Make sure that all ticked articles are a subset of the unread
12639 (if (gnus-member-of-range (car m) ranges)
12640 (setcdr marked (cdr m))
12642 (setq m (cdr m)))))
12644 (defun gnus-activate-group (group)
12645 ;; Check whether a group has been activated or not.
12646 (let ((method (gnus-find-method-for-group group))
12648 (and (gnus-check-server method)
12649 ;; We escape all bugs and quits here to make it possible to
12650 ;; continue if a group is so out-there that it reports bugs
12653 (gnus-request-group group)
12657 (set-buffer nntp-server-buffer)
12658 (goto-char (point-min))
12659 ;; Parse the result we got from `gnus-request-group'.
12660 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12662 (goto-char (match-beginning 1))
12664 group (setq active (cons (read (current-buffer))
12665 (read (current-buffer))))
12666 gnus-active-hashtb))
12667 ;; Return the new active info.
12670 (defun gnus-update-read-articles
12671 (group unread unselected ticked &optional domarks replied expirable killed
12672 dormant bookmark score)
12673 "Update the list of read and ticked articles in GROUP using the
12674 UNREAD and TICKED lists.
12675 Note: UNSELECTED has to be sorted over `<'.
12676 Returns whether the updating was successful."
12677 (let* ((active (or gnus-newsgroup-active
12678 (gnus-gethash group gnus-active-hashtb)))
12679 (entry (gnus-gethash group gnus-newsrc-hashtb))
12680 (info (nth 2 entry))
12681 (marked (nth 3 info))
12683 (unread (sort (copy-sequence unread) (function <)))
12685 (if (or (not info) (not active))
12686 ;; There is no info on this group if it was, in fact,
12687 ;; killed. Gnus stores no information on killed groups, so
12688 ;; there's nothing to be done.
12689 ;; One could store the information somewhere temporarily,
12690 ;; perhaps... Hmmm...
12692 ;; Remove any negative articles numbers.
12693 (while (and unread (< (car unread) 0))
12694 (setq unread (cdr unread)))
12695 ;; Remove any expired article numbers
12696 (while (and unread (< (car unread) (car active)))
12697 (setq unread (cdr unread)))
12698 (while (and ticked (< (car ticked) (car active)))
12699 (setq ticked (cdr ticked)))
12700 (while (and dormant (< (car dormant) (car active)))
12701 (setq dormant (cdr dormant)))
12702 (setq unread (sort (append unselected unread) '<))
12703 ;; Compute the ranges of read articles by looking at the list of
12704 ;; unread articles.
12706 (if (/= (car unread) prev)
12707 (setq read (cons (if (= prev (1- (car unread))) prev
12708 (cons prev (1- (car unread)))) read)))
12709 (setq prev (1+ (car unread)))
12710 (setq unread (cdr unread)))
12711 (if (<= prev (cdr active))
12712 (setq read (cons (cons prev (cdr active)) read)))
12713 ;; Enter this list into the group info.
12714 (setcar (cdr (cdr info))
12715 (if (> (length read) 1) (nreverse read) read))
12716 ;; Enter the list of ticked articles.
12717 (gnus-set-marked-articles
12719 (if domarks replied (cdr (assq 'reply marked)))
12720 (if domarks expirable (cdr (assq 'expire marked)))
12721 (if domarks killed (cdr (assq 'killed marked)))
12722 (if domarks dormant (cdr (assq 'dormant marked)))
12723 (if domarks bookmark (cdr (assq 'bookmark marked)))
12724 (if domarks score (cdr (assq 'score marked))))
12725 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12726 (gnus-get-unread-articles-in-group
12727 info (gnus-gethash group gnus-active-hashtb))
12730 (defun gnus-make-articles-unread (group articles)
12731 "Mark ARTICLES in GROUP as unread."
12732 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12733 (gnus-gethash (gnus-group-real-name group)
12734 gnus-newsrc-hashtb))))
12735 (ranges (nth 2 info))
12738 (and (gnus-member-of-range (car articles) ranges)
12739 (setq news (cons (car articles) news)))
12740 (setq articles (cdr articles)))
12743 (setcar (nthcdr 2 info)
12744 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12745 (gnus-group-update-group group t))))
12747 ;; Enter all dead groups into the hashtb.
12748 (defun gnus-update-active-hashtb-from-killed ()
12749 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12750 (lists (list gnus-killed-list gnus-zombie-list))
12753 (setq killed (car lists))
12755 (gnus-sethash (car killed) nil hashtb)
12756 (setq killed (cdr killed)))
12757 (setq lists (cdr lists)))))
12759 ;; Get the active file(s) from the backend(s).
12760 (defun gnus-read-active-file ()
12761 (gnus-group-set-mode-line)
12762 (let ((methods (if (gnus-check-server gnus-select-method)
12763 ;; The native server is available.
12764 (cons gnus-select-method gnus-secondary-select-methods)
12765 ;; The native server is down, so we just do the
12767 gnus-secondary-select-methods))
12769 (setq gnus-have-read-active-file nil)
12771 (set-buffer nntp-server-buffer)
12773 (let* ((method (gnus-server-get-method nil (car methods)))
12774 (where (nth 1 method))
12775 (mesg (format "Reading active file%s via %s..."
12776 (if (and where (not (zerop (length where))))
12777 (concat " from " where) "")
12779 (gnus-message 5 mesg)
12780 (gnus-check-server method)
12782 ((and (eq gnus-read-active-file 'some)
12783 (gnus-check-backend-function 'retrieve-groups (car method)))
12784 (let ((newsrc (cdr gnus-newsrc-alist))
12785 (gmethod (gnus-server-get-method nil method))
12788 (and (gnus-server-equal
12789 (gnus-find-method-for-group
12790 (car (car newsrc)) (car newsrc))
12792 (setq groups (cons (gnus-group-real-name
12793 (car (car newsrc))) groups)))
12794 (setq newsrc (cdr newsrc)))
12795 (gnus-check-server method)
12796 (setq list-type (gnus-retrieve-groups groups method))
12797 (cond ((not list-type)
12799 1 "Cannot read partial active file from %s server."
12803 ((eq list-type 'active)
12804 (gnus-active-to-gnus-format method gnus-active-hashtb))
12806 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12808 (if (not (gnus-request-list method))
12810 (gnus-message 1 "Cannot read active file from %s server."
12813 (gnus-active-to-gnus-format method)
12814 ;; We mark this active file as read.
12815 (setq gnus-have-read-active-file
12816 (cons method gnus-have-read-active-file))
12817 (gnus-message 5 "%sdone" mesg)))))
12818 (setq methods (cdr methods))))))
12820 ;; Read an active file and place the results in `gnus-active-hashtb'.
12821 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12822 (let ((cur (current-buffer))
12824 (if (and gnus-active-hashtb
12825 (not (equal method gnus-select-method)))
12827 (setq gnus-active-hashtb
12828 (if (equal method gnus-select-method)
12829 (gnus-make-hashtable
12830 (count-lines (point-min) (point-max)))
12831 (gnus-make-hashtable 4096))))))
12832 (flag-hashtb (gnus-make-hashtable 60)))
12833 ;; Delete unnecessary lines.
12834 (goto-char (point-min))
12835 (while (search-forward "\nto." nil t)
12836 (delete-region (1+ (match-beginning 0))
12837 (progn (forward-line 1) (point))))
12838 (or (string= gnus-ignored-newsgroups "")
12840 (goto-char (point-min))
12841 (delete-matching-lines gnus-ignored-newsgroups)))
12842 ;; Make the group names readable as a lisp expression even if they
12843 ;; contain special characters.
12844 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12845 (goto-char (point-max))
12846 (while (re-search-backward "[][';?()#]" nil t)
12848 ;; If these are groups from a foreign select method, we insert the
12849 ;; group prefix in front of the group names.
12850 (and method (not (gnus-server-equal
12851 (gnus-server-get-method nil method)
12852 (gnus-server-get-method nil gnus-select-method)))
12853 (let ((prefix (gnus-group-prefixed-name "" method)))
12854 (goto-char (point-min))
12855 (while (and (not (eobp))
12856 (progn (insert prefix)
12857 (zerop (forward-line 1)))))))
12858 ;; Store the active file in a hash table.
12859 (goto-char (point-min))
12860 (if (string-match "%[oO]" gnus-group-line-format)
12861 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12862 ;; If we want information on moderated groups, we use this
12864 (let* ((mod-hashtb (make-vector 7 0))
12865 (m (intern "m" mod-hashtb))
12867 (while (not (eobp))
12868 (condition-case nil
12870 (narrow-to-region (point) (gnus-point-at-eol))
12871 (setq group (let ((obarray hashtb)) (read cur)))
12872 (if (and (numberp (setq max (read cur)))
12873 (numberp (setq min (read cur)))
12875 (skip-chars-forward " \t")
12877 (or (= (following-char) ?=)
12878 (= (following-char) ?x)
12879 (= (following-char) ?j)))))
12880 (set group (cons min max))
12882 ;; Enter moderated groups into a list.
12883 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12884 (setq gnus-moderated-list
12885 (cons (symbol-name group) gnus-moderated-list))))
12892 ;; And if we do not care about moderation, we use this loop,
12893 ;; which is faster.
12894 (let (group max min)
12895 (while (not (eobp))
12898 (narrow-to-region (point) (gnus-point-at-eol))
12899 ;; group gets set to a symbol interned in the hash table
12900 ;; (what a hack!!) - jwz
12901 (setq group (let ((obarray hashtb)) (read cur)))
12902 (if (and (numberp (setq max (read cur)))
12903 (numberp (setq min (read cur)))
12905 (skip-chars-forward " \t")
12907 (or (= (following-char) ?=)
12908 (= (following-char) ?x)
12909 (= (following-char) ?j)))))
12910 (set group (cons min max))
12918 (gnus-message 3 "Warning - illegal active: %s"
12920 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12922 (forward-line 1))))))
12924 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12925 ;; Parse a "groups" active file.
12926 (let ((cur (current-buffer))
12928 (if (and method gnus-active-hashtb)
12930 (setq gnus-active-hashtb
12931 (gnus-make-hashtable
12932 (count-lines (point-min) (point-max)))))))
12933 (prefix (and method
12934 (not (gnus-server-equal
12935 (gnus-server-get-method nil method)
12936 (gnus-server-get-method nil gnus-select-method)))
12937 (gnus-group-prefixed-name "" method))))
12939 (goto-char (point-min))
12940 ;; We split this into to separate loops, one with the prefix
12941 ;; and one without to speed the reading up somewhat.
12943 (let (min max opoint group)
12944 (while (not (eobp))
12947 (read cur) (read cur)
12948 (setq min (read cur)
12951 (skip-chars-forward " \t")
12954 (set (let ((obarray hashtb)) (read cur))
12956 (error (and group (symbolp group) (set group nil))))
12958 (let (min max group)
12959 (while (not (eobp))
12961 (if (= (following-char) ?2)
12963 (read cur) (read cur)
12964 (setq min (read cur)
12966 (set (setq group (let ((obarray hashtb)) (read cur)))
12968 (error (and group (symbolp group) (set group nil))))
12969 (forward-line 1))))))
12971 (defun gnus-read-newsrc-file (&optional force)
12972 "Read startup file.
12973 If FORCE is non-nil, the .newsrc file is read."
12974 ;; Reset variables that might be defined in the .newsrc.eld file.
12975 (let ((variables gnus-variable-list))
12977 (set (car variables) nil)
12978 (setq variables (cdr variables))))
12979 (let* ((newsrc-file gnus-current-startup-file)
12980 (quick-file (concat newsrc-file ".el")))
12982 ;; We always load the .newsrc.eld file. If always contains
12983 ;; much information that can not be gotten from the .newsrc
12984 ;; file (ticked articles, killed groups, foreign methods, etc.)
12985 (gnus-read-newsrc-el-file quick-file)
12988 (and (file-newer-than-file-p newsrc-file quick-file)
12989 (file-newer-than-file-p newsrc-file
12990 (concat quick-file "d")))
12991 (not gnus-newsrc-alist))
12992 ;; We read the .newsrc file. Note that if there if a
12993 ;; .newsrc.eld file exists, it has already been read, and
12994 ;; the `gnus-newsrc-hashtb' has been created. While reading
12995 ;; the .newsrc file, Gnus will only use the information it
12996 ;; can find there for changing the data already read -
12997 ;; ie. reading the .newsrc file will not trash the data
12998 ;; already read (except for read articles).
13000 (gnus-message 5 "Reading %s..." newsrc-file)
13001 (set-buffer (find-file-noselect newsrc-file))
13002 (buffer-disable-undo (current-buffer))
13003 (gnus-newsrc-to-gnus-format)
13004 (kill-buffer (current-buffer))
13005 (gnus-message 5 "Reading %s...done" newsrc-file))))))
13007 (defun gnus-read-newsrc-el-file (file)
13008 (let ((ding-file (concat file "d")))
13009 ;; We always, always read the .eld file.
13010 (gnus-message 5 "Reading %s..." ding-file)
13011 (let (gnus-newsrc-assoc)
13012 (condition-case nil
13013 (load ding-file t t t)
13015 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
13016 (let ((inhibit-quit t))
13017 (gnus-uncompress-newsrc-alist))
13018 (gnus-make-hashtable-from-newsrc-alist)
13019 (if (not (file-newer-than-file-p file ding-file))
13021 ;; Old format quick file
13022 (gnus-message 5 "Reading %s..." file)
13023 ;; The .el file is newer than the .eld file, so we read that one
13025 (gnus-read-old-newsrc-el-file file))))
13027 ;; Parse the old-style quick startup file
13028 (defun gnus-read-old-newsrc-el-file (file)
13029 (let (newsrc killed marked group m)
13031 (let ((gnus-killed-assoc nil)
13032 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13034 (condition-case nil
13037 (setq newsrc gnus-newsrc-assoc
13038 killed gnus-killed-assoc
13039 marked gnus-marked-assoc)))
13040 (setq gnus-newsrc-alist nil)
13042 (setq group (car newsrc))
13043 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13046 (setcar (nthcdr 2 info) (cdr (cdr group)))
13048 (if (nth 1 group) gnus-level-default-subscribed
13049 gnus-level-default-unsubscribed))
13050 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13051 (setq gnus-newsrc-alist
13055 (if (nth 1 group) gnus-level-default-subscribed
13056 gnus-level-default-unsubscribed)
13057 (cdr (cdr group))))
13058 gnus-newsrc-alist)))
13059 (if (setq m (assoc (car group) marked))
13060 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
13061 (setq newsrc (cdr newsrc)))
13062 (setq newsrc killed)
13064 (setcar newsrc (car (car newsrc)))
13065 (setq newsrc (cdr newsrc)))
13066 (setq gnus-killed-list killed))
13067 ;; The .el file version of this variable does not begin with
13068 ;; "options", while the .eld version does, so we just add it if it
13071 gnus-newsrc-options
13073 (and (not (string-match "^ *options" gnus-newsrc-options))
13074 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13075 (and (not (string-match "\n$" gnus-newsrc-options))
13076 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))))
13077 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13078 (gnus-make-hashtable-from-newsrc-alist)))
13080 (defun gnus-make-newsrc-file (file)
13081 "Make server dependent file name by catenating FILE and server host name."
13082 (let* ((file (expand-file-name file nil))
13083 (real-file (concat file "-" (nth 1 gnus-select-method))))
13084 (if (or (file-exists-p real-file)
13085 (file-exists-p (concat real-file ".el"))
13086 (file-exists-p (concat real-file ".eld")))
13089 (defun gnus-uncompress-newsrc-alist ()
13090 ;; Uncompress all lists of marked articles in the newsrc assoc.
13091 (let ((newsrc gnus-newsrc-alist)
13094 (if (not (setq marked (nth 3 (car newsrc))))
13097 (or (eq 'score (car (car marked)))
13098 (eq 'bookmark (car (car marked)))
13099 (eq 'killed (car (car marked)))
13100 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13101 (setq marked (cdr marked))))
13102 (setq newsrc (cdr newsrc)))))
13104 (defun gnus-compress-newsrc-alist ()
13105 ;; Compress all lists of marked articles in the newsrc assoc.
13106 (let ((newsrc gnus-newsrc-alist)
13109 (if (not (setq marked (nth 3 (car newsrc))))
13112 (or (eq 'score (car (car marked)))
13113 (eq 'bookmark (car (car marked)))
13114 (eq 'killed (car (car marked)))
13115 (setcdr (car marked)
13117 (gnus-compress-sequence
13118 (sort (cdr (car marked)) '<) t)
13119 (error (cdr (car marked))))))
13120 (setq marked (cdr marked))))
13121 (setq newsrc (cdr newsrc)))))
13123 (defun gnus-newsrc-to-gnus-format ()
13124 (setq gnus-newsrc-options "")
13125 (setq gnus-newsrc-options-n nil)
13127 (or gnus-active-hashtb
13128 (setq gnus-active-hashtb (make-vector 4095 0)))
13129 (let ((buf (current-buffer))
13130 (already-read (> (length gnus-newsrc-alist) 1))
13131 group subscribed options-symbol newsrc Options-symbol
13133 (goto-char (point-min))
13134 ;; We intern the symbol `options' in the active hashtb so that we
13135 ;; can `eq' against it later.
13136 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13137 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13139 (while (not (eobp))
13140 ;; We first read the first word on the line by narrowing and
13141 ;; then reading into `gnus-active-hashtb'. Most groups will
13142 ;; already exist in that hashtb, so this will save some string
13146 (progn (skip-chars-forward "^ \t!:\n") (point)))
13147 (goto-char (point-min))
13149 (and (/= (point-min) (point-max))
13150 (let ((obarray gnus-active-hashtb)) (read buf))))
13152 ;; Now, the symbol we have read is either `options' or a group
13153 ;; name. If it is an options line, we just add it to a string.
13155 ((or (eq symbol options-symbol)
13156 (eq symbol Options-symbol))
13157 (setq gnus-newsrc-options
13158 ;; This concatting is quite inefficient, but since our
13159 ;; thorough studies show that approx 99.37% of all
13160 ;; .newsrc files only contain a single options line, we
13161 ;; don't give a damn, frankly, my dear.
13162 (concat gnus-newsrc-options
13164 (gnus-point-at-bol)
13165 ;; Options may continue on the next line.
13166 (or (and (re-search-forward "^[^ \t]" nil 'move)
13167 (progn (beginning-of-line) (point)))
13170 (or (boundp symbol) (set symbol nil))
13171 ;; It was a group name.
13172 (setq subscribed (= (following-char) ?:)
13173 group (symbol-name symbol)
13176 ;; If the line ends here, this is clearly a buggy line, so
13177 ;; we put point a the beginning of line and let the cond
13178 ;; below do the error handling.
13179 (beginning-of-line)
13180 ;; We skip to the beginning of the ranges.
13181 (skip-chars-forward "!: \t"))
13182 ;; We are now at the beginning of the list of read articles.
13183 ;; We read them range by range.
13186 ((looking-at "[0-9]+")
13187 ;; We narrow and read a number instead of buffer-substring/
13188 ;; string-to-int because it's faster. narrow/widen is
13189 ;; faster than save-restriction/narrow, and save-restriction
13190 ;; produces a garbage object.
13192 (narrow-to-region (match-beginning 0) (match-end 0))
13195 ;; If the next character is a dash, then this is a range.
13196 (if (= (following-char) ?-)
13198 ;; We read the upper bound of the range.
13200 (if (not (looking-at "[0-9]+"))
13201 ;; This is a buggy line, by we pretend that
13202 ;; it's kinda OK. Perhaps the user should be
13204 (setq reads (cons num1 reads))
13208 (narrow-to-region (match-beginning 0)
13213 ;; It was just a simple number, so we add it to the
13215 (setq reads (cons num1 reads)))
13216 ;; If the next char in ?\n, then we have reached the end
13217 ;; of the line and return nil.
13218 (/= (following-char) ?\n))
13219 ((= (following-char) ?\n)
13220 ;; End of line, so we end.
13223 ;; Not numbers and not eol, so this might be a buggy
13225 (or (eobp) ; If it was eob instead of ?\n, we allow it.
13227 ;; The line was buggy.
13229 (gnus-message 3 "Mangled line: %s"
13230 (buffer-substring (gnus-point-at-bol)
13231 (gnus-point-at-eol)))
13235 ;; Skip past ", ". Spaces are illegal in these ranges, but
13236 ;; we allow them, because it's a common mistake to put a
13237 ;; space after the comma.
13238 (skip-chars-forward ", "))
13240 ;; We have already read .newsrc.eld, so we gently update the
13241 ;; data in the hash table with the information we have just
13245 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13248 ;; There is an entry for this file in the alist.
13250 (setcar (nthcdr 2 info) (nreverse reads))
13251 ;; We update the level very gently. In fact, we
13252 ;; only change it if there's been a status change
13253 ;; from subscribed to unsubscribed, or vice versa.
13254 (setq level (nth 1 info))
13255 (cond ((and (<= level gnus-level-subscribed)
13257 (setq level (if reads
13258 gnus-level-default-unsubscribed
13259 (1+ gnus-level-default-unsubscribed))))
13260 ((and (> level gnus-level-subscribed) subscribed)
13261 (setq level gnus-level-default-subscribed)))
13262 (setcar (cdr info) level))
13263 ;; This is a new group.
13264 (setq info (list group
13266 gnus-level-default-subscribed
13268 (1+ gnus-level-subscribed)
13269 gnus-level-default-unsubscribed))
13270 (nreverse reads))))
13271 (setq newsrc (cons info newsrc))))))
13274 (setq newsrc (nreverse newsrc))
13276 (if (not already-read)
13278 ;; We now have two newsrc lists - `newsrc', which is what we
13279 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13280 ;; what we've read from .newsrc.eld. We have to merge these
13281 ;; lists. We do this by "attaching" any (foreign) groups in the
13282 ;; gnus-newsrc-alist to the (native) group that precedes them.
13283 (let ((rc (cdr gnus-newsrc-alist))
13284 (prev gnus-newsrc-alist)
13287 (or (null (nth 4 (car rc))) ; It's a native group.
13288 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13289 (if (setq entry (assoc (car (car prev)) newsrc))
13290 (setcdr (setq mentry (memq entry newsrc))
13291 (cons (car rc) (cdr mentry)))
13292 (setq newsrc (cons (car rc) newsrc))))
13296 (setq gnus-newsrc-alist newsrc)
13297 ;; We make the newsrc hashtb.
13298 (gnus-make-hashtable-from-newsrc-alist)
13300 ;; Finally, if we read some options lines, we parse them.
13301 (or (string= gnus-newsrc-options "")
13302 (gnus-newsrc-parse-options gnus-newsrc-options))))
13304 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13305 ;; The return value will be a list on the form
13306 ;; ((regexp1 . ignore)
13307 ;; (regexp2 . subscribe)...)
13308 ;; When handling new newsgroups, groups that match a `ignore' regexp
13309 ;; will be ignored, and groups that match a `subscribe' regexp will be
13310 ;; subscribed. A line like
13311 ;; options -n !all rec.all
13312 ;; will lead to a list that looks like
13313 ;; (("^rec\\..+" . subscribe)
13314 ;; ("^.+" . ignore))
13315 ;; So all "rec.*" groups will be subscribed, while all the other
13316 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13317 ;; different from "options -n rec.all !all".
13318 (defun gnus-newsrc-parse-options (options)
13321 (gnus-set-work-buffer)
13322 (insert (regexp-quote options))
13323 ;; First we treat all continuation lines.
13324 (goto-char (point-min))
13325 (while (re-search-forward "\n[ \t]+" nil t)
13326 (replace-match " " t t))
13327 ;; Then we transform all "all"s into ".+"s.
13328 (goto-char (point-min))
13329 (while (re-search-forward "\\ball\\b" nil t)
13330 (replace-match ".+" t t))
13331 (goto-char (point-min))
13332 ;; We remove all other options than the "-n" ones.
13333 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13334 (replace-match " ")
13336 (goto-char (point-min))
13338 ;; We are only interested in "options -n" lines - we
13339 ;; ignore the other option lines.
13340 (while (re-search-forward "[ \t]-n" nil t)
13342 (or (save-excursion
13343 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13345 (gnus-point-at-eol)))
13346 ;; Search for all "words"...
13347 (while (re-search-forward "[^ \t,\n]+" eol t)
13348 (if (= (char-after (match-beginning 0)) ?!)
13349 ;; If the word begins with a bang (!), this is a "not"
13350 ;; spec. We put this spec (minus the bang) and the
13351 ;; symbol `ignore' into the list.
13352 (setq out (cons (cons (concat
13353 "^" (buffer-substring
13354 (1+ (match-beginning 0))
13357 ;; There was no bang, so this is a "yes" spec.
13358 (setq out (cons (cons (concat
13359 "^" (buffer-substring (match-beginning 0)
13361 'subscribe) out)))))
13363 (setq gnus-newsrc-options-n out))))
13366 (defun gnus-save-newsrc-file ()
13367 "Save .newsrc file."
13368 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13369 ;; from the variable gnus-newsrc-alist.
13370 (and (or gnus-newsrc-alist gnus-killed-list)
13371 gnus-current-startup-file
13373 (run-hooks 'gnus-save-newsrc-hook)
13375 (if (and gnus-use-dribble-file
13376 (or (not gnus-dribble-buffer)
13377 (not (buffer-name gnus-dribble-buffer))
13378 (zerop (save-excursion
13379 (set-buffer gnus-dribble-buffer)
13381 (gnus-message 4 "(No changes need to be saved)")
13382 (if gnus-save-newsrc-file
13384 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13385 ;; Make backup file of master newsrc.
13386 (gnus-gnus-to-newsrc-format)
13387 (gnus-message 5 "Saving %s...done"
13388 gnus-current-startup-file)))
13389 ;; Quickly loadable .newsrc.
13390 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13391 (setq buffer-file-name (concat gnus-current-startup-file ".eld"))
13392 (gnus-add-current-to-buffer-list)
13393 (buffer-disable-undo (current-buffer))
13395 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13396 (gnus-gnus-to-quick-newsrc-format)
13398 (kill-buffer (current-buffer))
13399 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13400 (gnus-dribble-delete-file))))))
13402 (defun gnus-gnus-to-quick-newsrc-format ()
13403 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13404 (insert ";; Gnus startup file.\n")
13405 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13406 (insert ";; to read .newsrc.\n")
13407 (insert "(setq gnus-newsrc-file-version "
13408 (prin1-to-string gnus-version) ")\n")
13409 (let ((variables gnus-variable-list)
13411 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13413 ;; insert lisp expressions.
13414 (gnus-compress-newsrc-alist)
13416 (setq variable (car variables))
13417 (and (boundp variable)
13418 (symbol-value variable)
13419 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13420 (insert "(setq " (symbol-name variable) " '"
13421 (prin1-to-string (symbol-value variable))
13423 (setq variables (cdr variables)))
13424 (gnus-uncompress-newsrc-alist)))
13427 (defun gnus-gnus-to-newsrc-format ()
13428 ;; Generate and save the .newsrc file.
13429 (let ((newsrc (cdr gnus-newsrc-alist))
13432 (set-buffer (create-file-buffer gnus-current-startup-file))
13433 (setq buffer-file-name gnus-current-startup-file)
13434 (buffer-disable-undo (current-buffer))
13437 (if gnus-newsrc-options (insert gnus-newsrc-options))
13438 ;; Write subscribed and unsubscribed.
13440 (setq info (car newsrc))
13441 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13443 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13445 (if (setq ranges (nth 2 info))
13448 (if (not (listp (cdr ranges)))
13449 (if (= (car ranges) (cdr ranges))
13450 (insert (int-to-string (car ranges)))
13451 (insert (int-to-string (car ranges)) "-"
13452 (int-to-string (cdr ranges))))
13454 (setq range (car ranges)
13455 ranges (cdr ranges))
13456 (if (or (atom range) (= (car range) (cdr range)))
13457 (insert (int-to-string
13458 (or (and (atom range) range)
13460 (insert (int-to-string (car range)) "-"
13461 (int-to-string (cdr range))))
13462 (if ranges (insert ","))))))
13464 (setq newsrc (cdr newsrc)))
13465 ;; It has been reported that sometime the modtime on the .newsrc
13466 ;; file seems to be off. We really do want to overwrite it, so
13467 ;; we clear the modtime here before saving. It's a bit odd,
13469 ;; sometimes the modtime clear isn't sufficient. most brute force:
13470 ;; delete the silly thing entirely first. but this fails to provide
13471 ;; such niceties as .newsrc~ creation.
13472 (if gnus-modtime-botch
13473 (delete-file gnus-startup-file)
13474 (clear-visited-file-modtime))
13476 (kill-buffer (current-buffer)))))
13478 (defun gnus-read-all-descriptions-files ()
13479 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13481 (gnus-read-descriptions-file (car methods))
13482 (setq methods (cdr methods)))
13485 (defun gnus-read-descriptions-file (&optional method)
13486 (let ((method (or method gnus-select-method)))
13487 ;; We create the hashtable whether we manage to read the desc file
13488 ;; to avoid trying to re-read after a failed read.
13489 (or gnus-description-hashtb
13490 (setq gnus-description-hashtb
13491 (gnus-make-hashtable (length gnus-active-hashtb))))
13492 ;; Mark this method's desc file as read.
13493 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13494 gnus-description-hashtb)
13496 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13498 ((not (gnus-check-server method))
13499 (gnus-message 1 "Couldn't open server")
13501 ((not (gnus-request-list-newsgroups method))
13502 (gnus-message 1 "Couldn't read newsgroups descriptions")
13508 (set-buffer nntp-server-buffer)
13509 (goto-char (point-min))
13510 (if (or (search-forward "\n.\n" nil t)
13511 (goto-char (point-max)))
13513 (beginning-of-line)
13514 (narrow-to-region (point-min) (point))))
13515 (goto-char (point-min))
13516 (while (not (eobp))
13517 ;; If we get an error, we set group to 0, which is not a
13521 (let ((obarray gnus-description-hashtb))
13522 ;; Group is set to a symbol interned in this
13524 (read nntp-server-buffer))
13526 (skip-chars-forward " \t")
13527 ;; ... which leads to this line being effectively ignored.
13528 (and (symbolp group)
13529 (set group (buffer-substring
13530 (point) (progn (end-of-line) (point)))))
13531 (forward-line 1))))
13532 (gnus-message 5 "Reading descriptions file...done")
13535 (defun gnus-group-get-description (group)
13536 ;; Get the description of a group by sending XGTITLE to the server.
13537 (and (gnus-request-group-description group)
13539 (set-buffer nntp-server-buffer)
13540 (goto-char (point-min))
13541 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13542 (buffer-substring (match-beginning 1) (match-end 1))))))
13548 (defvar gnus-server-mode-hook nil
13549 "Hook run in `gnus-server-mode' buffers.")
13551 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13552 "Format of server lines.
13553 It works along the same lines as a normal formatting string,
13554 with some simple extensions.")
13556 (defvar gnus-server-mode-line-format "Gnus List of servers"
13557 "The format specification for the server mode line.")
13559 (defconst gnus-server-line-format-alist
13560 (list (list ?h 'how ?s)
13562 (list ?w 'where ?s)
13565 (defconst gnus-server-mode-line-format-alist
13566 (list (list ?S 'news-server ?s)
13567 (list ?M 'news-method ?s)
13568 (list ?u 'user-defined ?s)))
13570 (defvar gnus-server-line-format-spec nil)
13571 (defvar gnus-server-mode-line-format-spec nil)
13572 (defvar gnus-server-killed-servers nil)
13574 (defvar gnus-server-mode-map nil)
13575 (put 'gnus-server-mode 'mode-class 'special)
13577 (if gnus-server-mode-map
13579 (setq gnus-server-mode-map (make-sparse-keymap))
13580 (suppress-keymap gnus-server-mode-map)
13581 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13582 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13583 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13584 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13585 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13586 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13587 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13588 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13589 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13590 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13592 (defun gnus-server-mode ()
13593 "Major mode for listing and editing servers.
13595 All normal editing commands are switched off.
13596 \\<gnus-server-mode-map>
13598 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13600 The following commands are available:
13602 \\{gnus-server-mode-map}"
13604 (if gnus-visual (gnus-server-make-menu-bar))
13605 (kill-all-local-variables)
13606 (setq mode-line-modified "-- ")
13607 (make-local-variable 'mode-line-format)
13608 (setq mode-line-format (copy-sequence mode-line-format))
13609 (and (equal (nth 3 mode-line-format) " ")
13610 (setcar (nthcdr 3 mode-line-format) ""))
13611 (setq major-mode 'gnus-server-mode)
13612 (setq mode-name "Server")
13613 ; (gnus-group-set-mode-line)
13614 (setq mode-line-process nil)
13615 (use-local-map gnus-server-mode-map)
13616 (buffer-disable-undo (current-buffer))
13617 (setq truncate-lines t)
13618 (setq buffer-read-only t)
13619 (run-hooks 'gnus-server-mode-hook))
13621 (defun gnus-server-insert-server-line (sformat name method)
13622 (let* ((sformat (or sformat gnus-server-line-format-spec))
13624 (where (nth 1 method))
13626 (beginning-of-line)
13628 ;; Insert the text.
13629 (insert (eval sformat))
13630 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13632 (defun gnus-server-setup-buffer ()
13633 (if (get-buffer gnus-server-buffer)
13636 (set-buffer (get-buffer-create gnus-server-buffer))
13638 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13640 (defun gnus-server-prepare ()
13641 (setq gnus-server-mode-line-format-spec
13642 (gnus-parse-format gnus-server-mode-line-format
13643 gnus-server-mode-line-format-alist))
13644 (setq gnus-server-line-format-spec
13645 (gnus-parse-format gnus-server-line-format
13646 gnus-server-line-format-alist))
13647 (let ((alist gnus-server-alist)
13648 (buffer-read-only nil))
13651 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13652 (setq alist (cdr alist))))
13653 (goto-char (point-min))
13654 (gnus-server-position-cursor))
13656 (defun gnus-server-server-name ()
13657 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13658 (and server (symbol-name server))))
13660 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13662 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13664 (defun gnus-server-update-server (server)
13666 (set-buffer gnus-server-buffer)
13667 (let ((buffer-read-only nil)
13668 (info (cdr (assoc server gnus-server-alist))))
13669 (gnus-dribble-enter
13670 (concat "(gnus-server-set-info \"" server "\" '"
13671 (prin1-to-string info) ")"))
13672 ;; Buffer may be narrowed.
13675 (if (gnus-server-goto-server server)
13676 (delete-region (progn (beginning-of-line) (point))
13677 (progn (forward-line 1) (point))))
13678 (let ((entry (assoc server gnus-server-alist)))
13679 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13680 (gnus-server-position-cursor))))))
13682 (defun gnus-server-set-info (server info)
13683 ;; Enter a select method into the virtual server alist.
13684 (gnus-dribble-enter
13685 (concat "(gnus-server-set-info \"" server "\" '"
13686 (prin1-to-string info) ")"))
13687 (let* ((server (nth 1 info))
13688 (entry (assoc server gnus-server-alist)))
13689 (if entry (setcdr entry info)
13690 (setq gnus-server-alist
13691 (nconc gnus-server-alist (list (cons server info)))))))
13693 (defun gnus-server-to-method (server)
13694 ;; Map virtual server names to select methods.
13695 (or (and (equal server "native") gnus-select-method)
13696 (cdr (assoc server gnus-server-alist))))
13698 (defun gnus-server-extend-method (group method)
13699 ;; This function "extends" a virtual server. If the server is
13700 ;; "hello", and the select method is ("hello" (my-var "something"))
13701 ;; in the group "alt.alt", this will result in a new virtual server
13702 ;; called "helly+alt.alt".
13704 (gnus-copy-sequence
13705 (if (equal (car method) "native") gnus-select-method
13706 (cdr (assoc (car method) gnus-server-alist))))))
13707 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13708 (nconc entry (cdr method))))
13710 (defun gnus-server-get-method (group method)
13711 ;; Input either a server name, and extended server name, or a
13712 ;; select method, and return a select method.
13713 (cond ((stringp method)
13714 (gnus-server-to-method method))
13715 ((and (stringp (car method)) group)
13716 (gnus-server-extend-method group method))
13718 (gnus-server-add-address method))))
13720 (defun gnus-server-add-address (method)
13721 (let ((method-name (symbol-name (car method))))
13722 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13723 (not (assq (intern (concat method-name "-address")) method)))
13724 (append method (list (list (intern (concat method-name "-address"))
13728 (defun gnus-server-equal (s1 s2)
13730 (and (= (length s1) (length s2))
13732 (while (and s1 (member (car s1) s2))
13733 (setq s1 (cdr s1)))
13736 ;;; Interactive server functions.
13738 (defun gnus-server-kill-server (server)
13739 "Kill the server on the current line."
13740 (interactive (list (gnus-server-server-name)))
13741 (or (gnus-server-goto-server server)
13742 (if server (error "No such server: %s" server)
13743 (error "No server on the current line")))
13744 (let ((buffer-read-only nil))
13745 (delete-region (progn (beginning-of-line) (point))
13746 (progn (forward-line 1) (point))))
13747 (setq gnus-server-killed-servers
13748 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13749 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13750 gnus-server-alist))
13751 (gnus-server-position-cursor))
13753 (defun gnus-server-yank-server ()
13754 "Yank the previously killed server."
13756 (or gnus-server-killed-servers
13757 (error "No killed servers to be yanked"))
13758 (let ((alist gnus-server-alist)
13759 (server (gnus-server-server-name))
13760 (killed (car gnus-server-killed-servers)))
13762 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13763 (if (string= server (car (car gnus-server-alist)))
13764 (setq gnus-server-alist (cons killed gnus-server-alist))
13765 (while (and (cdr alist)
13766 (not (string= server (car (car (cdr alist))))))
13767 (setq alist (cdr alist)))
13768 (setcdr alist (cons killed (cdr alist)))))
13769 (gnus-server-update-server (car killed))
13770 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13771 (gnus-server-position-cursor)))
13773 (defun gnus-server-exit ()
13774 "Return to the group buffer."
13776 (kill-buffer (current-buffer))
13777 (switch-to-buffer gnus-group-buffer))
13779 (defun gnus-server-list-servers ()
13780 "List all available servers."
13782 (let ((cur (gnus-server-server-name)))
13783 (gnus-server-prepare)
13784 (if cur (gnus-server-goto-server cur)
13785 (goto-char (point-max))
13787 (gnus-server-position-cursor)))
13789 (defun gnus-server-copy-server (from to)
13792 (or (gnus-server-server-name)
13793 (error "No server on the current line"))
13794 (read-string "Copy to: ")))
13795 (or from (error "No server on current line"))
13796 (or (and to (not (string= to ""))) (error "No name to copy to"))
13797 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13798 (or (assoc from gnus-server-alist)
13799 (error "%s: no such server" from))
13800 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13801 (setcar to-entry to)
13802 (setcar (nthcdr 2 to-entry) to)
13803 (setq gnus-server-killed-servers
13804 (cons to-entry gnus-server-killed-servers))
13805 (gnus-server-yank-server)))
13807 (defun gnus-server-add-server (how where)
13809 (list (intern (completing-read "Server method: "
13810 gnus-valid-select-methods nil t))
13811 (read-string "Server name: ")))
13812 (setq gnus-server-killed-servers
13813 (cons (list where how where) gnus-server-killed-servers))
13814 (gnus-server-yank-server))
13816 (defun gnus-server-goto-server (server)
13817 "Jump to a server line."
13819 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13820 (let ((to (text-property-any (point-min) (point-max)
13821 'gnus-server (intern server))))
13825 (gnus-server-position-cursor)))))
13827 (defun gnus-server-edit-server (server)
13828 "Edit the server on the current line."
13829 (interactive (list (gnus-server-server-name)))
13831 (error "No server on current line"))
13832 (let ((winconf (current-window-configuration)))
13833 (get-buffer-create gnus-server-edit-buffer)
13834 (gnus-configure-windows 'edit-server)
13835 (gnus-add-current-to-buffer-list)
13837 (make-local-variable 'gnus-prev-winconf)
13838 (setq gnus-prev-winconf winconf)
13839 (use-local-map (copy-keymap (current-local-map)))
13840 (let ((done-func '(lambda ()
13841 "Exit editing mode and update the information."
13843 (gnus-server-edit-server-done 'group))))
13844 (setcar (cdr (nth 4 done-func)) server)
13845 (local-set-key "\C-c\C-c" done-func))
13847 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13848 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13850 (defun gnus-server-edit-server-done (server)
13852 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13853 (goto-char (point-min))
13854 (let ((form (read (current-buffer)))
13855 (winconf gnus-prev-winconf))
13856 (gnus-server-set-info server form)
13857 (kill-buffer (current-buffer))
13858 (and winconf (set-window-configuration winconf))
13859 (set-buffer gnus-server-buffer)
13860 (gnus-server-update-server (gnus-server-server-name))
13861 (gnus-server-position-cursor)))
13863 (defun gnus-server-read-server (server)
13865 (interactive (list (gnus-server-server-name)))
13866 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13868 (defun gnus-mouse-pick-server (e)
13870 (mouse-set-point e)
13871 (gnus-server-read-server (gnus-server-server-name)))
13874 ;;; entry points into gnus-score.el
13877 ;;; Finding score files.
13879 (defvar gnus-global-score-files nil
13880 "*List of global score files and directories.
13881 Set this variable if you want to use people's score files. One entry
13882 for each score file or each score file directory. Gnus will decide
13883 by itself what score files are applicable to which group.
13885 Say you want to use the single score file
13886 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13887 score files in the \"/ftp.some-where:/pub/score\" directory.
13889 (setq gnus-global-score-files
13890 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13891 \"/ftp.some-where:/pub/score\"))")
13893 (defun gnus-score-score-files (group)
13894 "Return a list of all possible score files."
13895 ;; Search and set any global score files.
13896 (and gnus-global-score-files
13897 (or gnus-internal-global-score-files
13898 (gnus-score-search-global-directories gnus-global-score-files)))
13899 ;; Fix the kill-file dir variable.
13900 (setq gnus-kill-files-directory
13901 (file-name-as-directory
13902 (or gnus-kill-files-directory "~/News/")))
13903 ;; If we can't read it, there are no score files.
13904 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13905 (setq gnus-score-file-list nil)
13906 (if (gnus-use-long-file-name 'not-score)
13907 ;; We want long file names.
13908 (if (or (not gnus-score-file-list)
13909 (not (car gnus-score-file-list))
13910 (gnus-file-newer-than gnus-kill-files-directory
13911 (car gnus-score-file-list)))
13912 (setq gnus-score-file-list
13913 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13916 gnus-kill-files-directory t
13917 (gnus-score-file-regexp))))))
13918 ;; We do not use long file names, so we have to do some
13919 ;; directory traversing.
13920 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13921 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13924 (setq dir (expand-file-name
13925 (concat gnus-kill-files-directory
13926 (gnus-replace-chars-in-string group ?. ?/))))
13927 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13928 (setq suffix (car suffixes)
13929 suffixes (cdr suffixes))
13930 (if (file-exists-p (concat dir "/" suffix))
13931 (setq files (cons (concat dir "/" suffix) files)))
13932 (while (>= (1+ (length dir)) mdir)
13933 (and (file-exists-p (concat dir "/all/" suffix))
13934 (setq files (cons (concat dir "/all/" suffix) files)))
13935 (string-match "/[^/]*$" dir)
13936 (setq dir (substring dir 0 (match-beginning 0)))))
13937 (setq gnus-score-file-list
13938 (cons nil (nreverse files)))))
13939 (cdr gnus-score-file-list)))
13941 (defun gnus-score-file-regexp ()
13942 (concat "\\(" gnus-score-file-suffix
13943 "\\|" gnus-adaptive-file-suffix "\\)$"))
13945 (defun gnus-score-find-bnews (group)
13946 "Return a list of score files for GROUP.
13947 The score files are those files in the ~/News directory which matches
13948 GROUP using BNews sys file syntax."
13949 (let* ((sfiles (append (gnus-score-score-files group)
13950 gnus-internal-global-score-files))
13951 (kill-dir (file-name-as-directory
13952 (expand-file-name gnus-kill-files-directory)))
13953 (klen (length kill-dir))
13954 ofiles not-match regexp)
13956 (set-buffer (get-buffer-create "*gnus score files*"))
13957 (buffer-disable-undo (current-buffer))
13958 ;; Go through all score file names and create regexp with them
13962 (insert (car sfiles))
13963 (goto-char (point-min))
13964 ;; First remove the suffix itself.
13965 (re-search-forward (concat "." (gnus-score-file-regexp)))
13966 (replace-match "" t t)
13967 (goto-char (point-min))
13968 (if (looking-at (regexp-quote kill-dir))
13969 ;; If the file name was just "SCORE", `klen' is one character
13971 (delete-char (min (1- (point-max)) klen))
13972 (goto-char (point-max))
13973 (search-backward "/")
13974 (delete-region (1+ (point)) (point-min)))
13975 ;; If short file names were used, we have to translate slashes.
13976 (goto-char (point-min))
13977 (while (re-search-forward "[/:]" nil t)
13978 (replace-match "." t t))
13979 ;; Translate "all" to ".*".
13980 (while (search-forward "all" nil t)
13981 (replace-match ".*" t t))
13982 (goto-char (point-min))
13983 ;; Deal with "not."s.
13984 (if (looking-at "not.")
13987 (setq regexp (buffer-substring 5 (point-max))))
13988 (setq regexp (buffer-substring 1 (point-max)))
13989 (setq not-match nil))
13990 ;; Finally - if this resulting regexp matches the group name,
13991 ;; we add this score file to the list of score files
13992 ;; applicable to this group.
13993 (if (or (and not-match
13994 (not (string-match regexp group)))
13995 (and (not not-match)
13996 (string-match regexp group)))
13997 (setq ofiles (cons (car sfiles) ofiles)))
13998 (setq sfiles (cdr sfiles)))
13999 (kill-buffer (current-buffer))
14000 ;; Slight kludge here - the last score file returned should be
14001 ;; the local score file, whether it exists or not. This is so
14002 ;; that any score commands the user enters will go to the right
14003 ;; file, and not end up in some global score file.
14006 (if (gnus-use-long-file-name 'not-score)
14007 (concat gnus-kill-files-directory group "."
14008 gnus-score-file-suffix)
14009 (concat gnus-kill-files-directory
14010 (gnus-replace-chars-in-string group ?. ?/)
14011 "/" gnus-score-file-suffix)))))
14012 (and (member localscore ofiles)
14013 (delete localscore ofiles))
14014 (setq ofiles (cons localscore ofiles)))
14015 (nreverse ofiles))))
14017 (defun gnus-score-find-single (group)
14018 "Return list containing the score file for GROUP."
14019 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
14020 (gnus-score-file-name group)))
14022 (defun gnus-score-find-hierarchical (group)
14023 "Return list of score files for GROUP.
14024 This includes the score file for the group and all its parents."
14025 (let ((all (copy-sequence '(nil)))
14027 (while (string-match "\\." group (1+ start))
14028 (setq start (match-beginning 0))
14029 (setq all (cons (substring group 0 start) all)))
14030 (setq all (cons group all))
14032 (mapcar (lambda (newsgroup)
14033 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14034 (setq all (nreverse all)))
14035 (mapcar 'gnus-score-file-name all))))
14037 (defvar gnus-score-file-alist-cache nil)
14039 (defun gnus-score-find-alist (group)
14040 "Return list of score files for GROUP.
14041 The list is determined from the variable gnus-score-file-alist."
14042 (let ((alist gnus-score-file-multiple-match-alist)
14044 ;; if this group has been seen before, return the cached entry
14045 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14046 (cdr score-files) ; ensures caching of groups with no matches
14047 ;; handle the multiple match alist
14049 (and (string-match (car (car alist)) group)
14051 (nconc score-files (copy-sequence (cdr (car alist))))))
14052 (setq alist (cdr alist)))
14053 (setq alist gnus-score-file-single-match-alist)
14054 ;; handle the single match alist
14056 (and (string-match (car (car alist)) group)
14057 ;; progn used just in case ("regexp") has no files
14058 ;; and score-files is still nil. -sj
14059 ;; this can be construed as a "stop searching here" feature :>
14060 ;; and used to simplify regexps in the single-alist
14063 (nconc score-files (copy-sequence (cdr (car alist)))))
14065 (setq alist (cdr alist)))
14066 ;; cache the score files
14067 (setq gnus-score-file-alist-cache
14068 (cons (cons group score-files) gnus-score-file-alist-cache))
14072 (defun gnus-possibly-score-headers (&optional trace)
14073 (let ((func gnus-score-find-score-files-function)
14075 (and func (not (listp func))
14076 (setq func (list func)))
14077 ;; Go through all the functions for finding score files (or actual
14078 ;; scores) and add them to a list.
14079 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14081 (and (symbolp (car func))
14082 (fboundp (car func))
14084 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14085 (setq func (cdr func)))
14086 (if score-files (gnus-score-headers score-files trace))))
14088 (defun gnus-score-file-name (newsgroup &optional suffix)
14089 "Return the name of a score file for NEWSGROUP."
14090 (let ((suffix (or suffix gnus-score-file-suffix)))
14092 ((or (null newsgroup)
14093 (string-equal newsgroup ""))
14094 ;; The global score file is placed at top of the directory.
14096 suffix (or gnus-kill-files-directory "~/News")))
14097 ((gnus-use-long-file-name 'not-score)
14098 ;; Append ".SCORE" to newsgroup name.
14099 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14101 (or gnus-kill-files-directory "~/News")))
14103 ;; Place "SCORE" under the hierarchical directory.
14104 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14106 (or gnus-kill-files-directory "~/News"))))))
14108 (defun gnus-score-search-global-directories (files)
14109 "Scan all global score directories for score files."
14110 ;; Set the variable `gnus-internal-global-score-files' to all
14111 ;; available global score files.
14112 (interactive (list gnus-global-score-files))
14115 (if (string-match "/$" (car files))
14116 (setq out (nconc (directory-files
14118 (concat (gnus-score-file-regexp) "$"))))
14119 (setq out (cons (car files) out)))
14120 (setq files (cdr files)))
14121 (setq gnus-internal-global-score-files out)))
14123 ;; Allow redefinition of Gnus functions.
14125 (gnus-ems-redefine)
14129 ;;; gnus.el ends here