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
36 (eval '(run-hooks 'gnus-load-hook))
42 ;; Site dependent variables. These variables should be defined in
45 (defvar gnus-default-nntp-server nil
46 "Specify a default NNTP server.
47 This variable should be defined in paths.el, and should never be set
49 If you want to change servers, you should use `gnus-select-method'.
50 See the documentation to that variable.")
52 (defconst gnus-backup-default-subscribed-newsgroups
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
54 "Default default new newsgroups the first time Gnus is run.
55 Should be set in paths.el, and shouldn't be touched by the user.")
57 (defvar gnus-local-domain nil
58 "Local domain name without a host name.
59 The DOMAINNAME environment variable is used instead if it is defined.
60 If the `system-name' function returns the full Internet name, there is
61 no need to set this variable.")
63 (defvar gnus-local-organization nil
64 "String with a description of what organization (if any) the user belongs to.
65 The ORGANIZATION environment variable is used instead if it is defined.
66 If this variable contains a function, this function will be called
67 with the current newsgroup name as the argument. The function should
70 In any case, if the string (either in the variable, in the environment
71 variable, or returned by the function) is a file name, the contents of
72 this file will be used as the organization.")
74 (defvar gnus-use-generic-from nil
75 "If nil, the full host name will be the system name prepended to the domain name.
76 If this is a string, the full host name will be this string.
77 If this is non-nil, non-string, the domain name will be used as the
80 (defvar gnus-use-generic-path nil
81 "If nil, use the NNTP server name in the Path header.
82 If stringp, use this; if non-nil, use no host name (user name only).")
85 ;; Customization variables
87 ;; Don't touch this variable.
88 (defvar gnus-nntp-service "nntp"
89 "*NNTP service name (\"nntp\" or 119).
90 This is an obsolete variable, which is scarcely used. If you use an
91 nntp server for your newsgroup and want to change the port number
92 used to 899, you would say something along these lines:
94 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
96 (defvar gnus-select-method
98 (list 'nntp (or (getenv "NNTPSERVER")
99 (if (and gnus-default-nntp-server
100 (not (string= gnus-default-nntp-server "")))
101 gnus-default-nntp-server)
103 (if (equal gnus-nntp-service "nntp") nil (list gnus-nntp-service)))
104 "*Default method for selecting a newsgroup.
105 This variable should be a list, where the first element is how the
106 news is to be fetched, the second is the address.
108 For instance, if you want to get your news via NNTP from
109 \"flab.flab.edu\", you could say:
111 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
113 If you want to use your local spool, say:
115 (setq gnus-select-method (list 'nnspool (system-name)))
117 If you use this variable, you must set `gnus-nntp-server' to nil.
119 There is a lot more to know about select methods and virtual servers -
120 see the manual for details.")
122 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
123 (defvar gnus-post-method nil
124 "*Preferred method for posting USENET news.
125 If this variable is nil, Gnus will use the current method to decide
126 which method to use when posting. If it is non-nil, it will override
127 the current method. This method will not be used in mail groups and
128 the like, only in \"real\" newsgroups.
130 The value must be a valid method as discussed in the documentation of
131 `gnus-select-method'.")
133 (defvar gnus-refer-article-method nil
134 "*Preferred method for fetching an article by Message-ID.
135 If you are reading news from the local spool (with nnspool), fetching
136 articles by Message-ID is painfully slow. By setting this method to an
137 nntp method, you might get acceptable results.
139 The value of this variable must be a valid select method as discussed
140 in the documentation of `gnus-select-method'")
142 (defvar gnus-secondary-select-methods nil
143 "*A list of secondary methods that will be used for reading news.
144 This is a list where each element is a complete select method (see
145 `gnus-select-method').
147 If, for instance, you want to read your mail with the nnml backend,
148 you could set this variable:
150 (setq gnus-secondary-select-methods '((nnml \"\")))")
152 (defvar gnus-secondary-servers nil
153 "*List of NNTP servers that the user can choose between interactively.
154 To make Gnus query you for a server, you have to give `gnus' a
155 non-numeric prefix - `C-u M-x gnus', in short.")
157 (defvar gnus-nntp-server nil
158 "*The name of the host running the NNTP server.
159 This variable is semi-obsolete. Use the `gnus-select-method'
162 (defvar gnus-startup-file "~/.newsrc"
163 "*Your `.newsrc' file.
164 `.newsrc-SERVER' will be used instead if that exists.")
166 (defvar gnus-init-file "~/.gnus"
167 "*Your Gnus elisp startup file.
168 If a file with the .el or .elc suffixes exist, it will be read
171 (defvar gnus-group-faq-directory
172 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
173 "*Directory where the group FAQs are stored.
174 This will most commonly be on a remote machine, and the file will be
177 Note that Gnus uses an aol machine as the default directory. If this
178 feels fundamentally unclean, just think of it as a way to finally get
179 something of value back from them.
181 If the default site is too slow, try one of these:
183 North America: ftp.uu.net /usenet/news.answers
184 mirrors.aol.com /pub/rtfm/usenet
185 ftp.seas.gwu.edu /pub/rtfm
186 rtfm.mit.edu /pub/usenet/news.answers
187 Europe: ftp.uni-paderborn.de /pub/FAQ
188 ftp.Germany.EU.net /pub/newsarchive/news.answers
189 ftp.sunet.se /pub/usenet
190 Asia: nctuccca.edu.tw /USENET/FAQ
191 hwarang.postech.ac.kr /pub/usenet/news.answers
192 ftp.hk.super.net /mirror/faqs")
194 (defvar gnus-group-archive-directory
195 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
196 "*The address of the (ding) archives.")
198 (defvar gnus-group-recent-archive-directory
199 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
200 "*The address of the most recent (ding) articles.")
202 (defvar gnus-default-subscribed-newsgroups nil
203 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
204 It should be a list of strings.
205 If it is `t', Gnus will not do anything special the first time it is
206 started; it'll just use the normal newsgroups subscription methods.")
208 (defvar gnus-use-cross-reference t
209 "*Non-nil means that cross referenced articles will be marked as read.
210 If nil, ignore cross references. If t, mark articles as read in
211 subscribed newsgroups. If neither t nor nil, mark as read in all
214 (defvar gnus-use-dribble-file t
215 "*Non-nil means that Gnus will use a dribble file to store user updates.
216 If Emacs should crash without saving the .newsrc files, complete
217 information can be restored from the dribble file.")
219 (defvar gnus-asynchronous nil
220 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
222 (defvar gnus-asynchronous-article-function nil
223 "*Function for picking articles to pre-fetch, possibly.")
225 (defvar gnus-score-file-single-match-alist nil
226 "*Alist mapping regexps to lists of score files.
227 Each element of this alist should be of the form
228 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
230 If the name of a group is matched by REGEXP, the corresponding scorefiles
231 will be used for that group.
232 The first match found is used, subsequent matching entries are ignored (to
233 use multiple matches, see gnus-score-file-multiple-match-alist).
235 These score files are loaded in addition to any files returned by
236 gnus-score-find-score-files-function (which see).")
238 (defvar gnus-score-file-multiple-match-alist nil
239 "*Alist mapping regexps to lists of score files.
240 Each element of this alist should be of the form
241 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
243 If the name of a group is matched by REGEXP, the corresponding scorefiles
244 will be used for that group.
245 If multiple REGEXPs match a group, the score files corresponding to each
246 match will be used (for only one match to be used, see
247 gnus-score-file-single-match-alist).
249 These score files are loaded in addition to any files returned by
250 gnus-score-find-score-files-function (which see).")
253 (defvar gnus-score-file-suffix "SCORE"
254 "*Suffix of the score files.")
256 (defvar gnus-adaptive-file-suffix "ADAPT"
257 "*Suffix of the adaptive score files.")
259 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
260 "*Function used to find score files.
261 The function will be called with the group name as the argument, and
262 should return a list of score files to apply to that group. The score
263 files do not actually have to exist.
265 Predefined values are:
267 gnus-score-find-single: Only apply the group's own score file.
268 gnus-score-find-hierarchical: Also apply score files from parent groups.
269 gnus-score-find-bnews: Apply score files whose names matches.
271 See the documentation to these functions for more information.
273 This variable can also be a list of functions to be called. Each
274 function should either return a list of score files, or a list of
277 (defvar gnus-score-interactive-default-score 1000
278 "*Scoring commands will raise/lower the score with this number as the default.")
280 (defvar gnus-large-newsgroup 200
281 "*The number of articles which indicates a large newsgroup.
282 If the number of articles in a newsgroup is greater than this value,
283 confirmation is required for selecting the newsgroup.")
285 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
286 (defvar gnus-no-groups-message "No news is horrible news"
287 "*Message displayed by Gnus when no groups are available.")
289 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
290 "*Non-nil means that the default name of a file to save articles in is the group name.
291 If it's nil, the directory form of the group name is used instead.
293 If this variable is a list, and the list contains the element
294 `not-score', long file names will not be used for score files; if it
295 contains the element `not-save', long file names will not be used for
296 saving; and if it contains the element `not-kill', long file names
297 will not be used for kill files.")
299 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
300 "*Name of the directory articles will be saved in (default \"~/News\").
301 Initialized from the SAVEDIR environment variable.")
303 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
304 "*Name of the directory where kill files will be stored (default \"~/News\").
305 Initialized from the SAVEDIR environment variable.")
307 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
308 "*A function to save articles in your favorite format.
309 The function must be interactively callable (in other words, it must
310 be an Emacs command).
312 Gnus provides the following functions:
314 * gnus-summary-save-in-rmail (Rmail format)
315 * gnus-summary-save-in-mail (Unix mail format)
316 * gnus-summary-save-in-folder (MH folder)
317 * gnus-summary-save-in-file (article format).
318 * gnus-summary-save-in-vm (use VM's folder format).")
320 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
321 "*A function generating a file name to save articles in Rmail format.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
324 (defvar gnus-mail-save-name (function gnus-plain-save-name)
325 "*A function generating a file name to save articles in Unix mail format.
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
328 (defvar gnus-folder-save-name (function gnus-folder-save-name)
329 "*A function generating a file name to save articles in MH folder.
330 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
332 (defvar gnus-file-save-name (function gnus-numeric-save-name)
333 "*A function generating a file name to save articles in article format.
334 The function is called with NEWSGROUP, HEADERS, and optional
337 (defvar gnus-split-methods nil
338 "*Variable used to suggest where articles are to be saved.
339 The syntax of this variable is the same as `nnmail-split-methods'.
341 For instance, if you would like to save articles related to Gnus in
342 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
343 you could set this variable to something like:
345 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
346 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
348 (defvar gnus-save-score nil
349 "*If non-nil, save group scoring info.")
351 (defvar gnus-use-adaptive-scoring nil
352 "*If non-nil, use some adaptive scoring scheme.")
354 (defvar gnus-use-cache nil
355 "*If non-nil, Gnus will cache (some) articles locally.")
357 (defvar gnus-use-scoring t
358 "*If non-nil, enable scoring.")
360 (defvar gnus-fetch-old-headers nil
361 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
362 If an unread article in the group refers to an older, already read (or
363 just marked as read) article, the old article will not normally be
364 displayed in the Summary buffer. If this variable is non-nil, Gnus
365 will attempt to grab the headers to the old articles, and thereby
366 build complete threads. If it has the value `some', only enough
367 headers to connect otherwise loose threads will be displayed.
369 The server has to support XOVER for any of this to work.")
372 ;(defvar gnus-visual t
373 ; "*If non-nil, will do various highlighting.
374 ;If nil, no mouse highlights (or any other highlights) will be
375 ;performed. This might speed up Gnus some when generating large group
376 ;and summary buffers.")
378 (defvar gnus-novice-user t
379 "*Non-nil means that you are a usenet novice.
380 If non-nil, verbose messages may be displayed and confirmations may be
383 (defvar gnus-expert-user nil
384 "*Non-nil means that you will never be asked for confirmation about anything.
385 And that means *anything*.")
387 (defvar gnus-verbose 7
388 "*Integer that says how verbose Gnus should be.
389 The higher the number, the more messages Gnus will flash to say what
390 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
391 display most important messages; and at ten, Gnus will keep on
392 jabbering all the time.")
394 (defvar gnus-keep-same-level nil
395 "*Non-nil means that the next newsgroup after the current will be on the same level.
396 When you type, for instance, `n' after reading the last article in the
397 current newsgroup, you will go to the next newsgroup. If this variable
398 is nil, the next newsgroup will be the next from the group
400 If this variable is non-nil, Gnus will either put you in the
401 next newsgroup with the same level, or, if no such newsgroup is
402 available, the next newsgroup with the lowest possible level higher
403 than the current level.
404 If this variable is `best', Gnus will make the next newsgroup the one
405 with the best level.")
407 (defvar gnus-summary-make-false-root 'adopt
408 "*nil means that Gnus won't gather loose threads.
409 If the root of a thread has expired or been read in a previous
410 session, the information necessary to build a complete thread has been
411 lost. Instead of having many small sub-threads from this original thread
412 scattered all over the summary buffer, Gnus can gather them.
414 If non-nil, Gnus will try to gather all loose sub-threads from an
415 original thread into one large thread.
417 If this variable is non-nil, it should be one of `none', `adopt',
420 If this variable is `none', Gnus will not make a false root, but just
421 present the sub-threads after another.
422 If this variable is `dummy', Gnus will create a dummy root that will
423 have all the sub-threads as children.
424 If this variable is `adopt', Gnus will make one of the \"children\"
425 the parent and mark all the step-children as such.
426 If this variable is `empty', the \"children\" are printed with empty
427 subject fields. (Or rather, they will be printed with a string
428 given by the `gnus-summary-same-subject' variable.)")
430 (defvar gnus-summary-gather-subject-limit nil
431 "*Maximum length of subject comparisons when gathering loose threads.
432 Use nil to compare full subjects. Setting this variable to a low
433 number will help gather threads that have been corrupted by
434 newsreaders chopping off subject lines, but it might also mean that
435 unrelated articles that have subject that happen to begin with the
436 same few characters will be incorrectly gathered.
438 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
439 comparing subjects.")
441 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
442 (defvar gnus-summary-same-subject ""
443 "*String indicating that the current article has the same subject as the previous.
444 This variable will only be used if the value of
445 `gnus-summary-make-false-root' is `empty'.")
447 (defvar gnus-summary-goto-unread t
448 "*If non-nil, marking commands will go to the next unread article.")
450 (defvar gnus-group-goto-unread t
451 "*If non-nil, movement commands will go to the next unread and subscribed group.")
453 (defvar gnus-check-new-newsgroups t
454 "*Non-nil means that Gnus will add new newsgroups at startup.
455 If this variable is `ask-server', Gnus will ask the server for new
456 groups since the last time it checked. This means that the killed list
457 is no longer necessary, so you could set `gnus-save-killed-list' to
460 A variant is to have this variable be a list of select methods. Gnus
461 will then use the `ask-server' method on all these select methods to
462 query for new groups from all those servers.
465 (setq gnus-check-new-newsgroups
466 '((nntp \"some.server\") (nntp \"other.server\")))
468 If this variable is nil, then you have to tell Gnus explicitly to
469 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
471 (defvar gnus-check-bogus-newsgroups nil
472 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
473 If this variable is nil, then you have to tell Gnus explicitly to
474 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
476 (defvar gnus-read-active-file t
477 "*Non-nil means that Gnus will read the entire active file at startup.
478 If this variable is nil, Gnus will only know about the groups in your
481 If this variable is `some', Gnus will try to only read the relevant
482 parts of the active file from the server. Not all servers support
483 this, and it might be quite slow with other servers, but this should
484 generally be faster than both the t and nil value.
486 If you set this variable to nil or `some', you probably still want to
487 be told about new newsgroups that arrive. To do that, set
488 `gnus-check-new-newsgroups' to `ask-server'. This may not work
489 properly with all servers.")
491 (defvar gnus-level-subscribed 5
492 "*Groups with levels less than or equal to this variable are subscribed.")
494 (defvar gnus-level-unsubscribed 7
495 "*Groups with levels less than or equal to this variable are unsubscribed.
496 Groups with levels less than `gnus-level-subscribed', which should be
497 less than this variable, are subscribed.")
499 (defvar gnus-level-zombie 8
500 "*Groups with this level are zombie groups.")
502 (defvar gnus-level-killed 9
503 "*Groups with this level are killed.")
505 (defvar gnus-level-default-subscribed 3
506 "*New subscribed groups will be subscribed at this level.")
508 (defvar gnus-level-default-unsubscribed 6
509 "*New unsubscribed groups will be unsubscribed at this level.")
511 (defvar gnus-activate-foreign-newsgroups 4
512 "*If nil, Gnus will not check foreign newsgroups at startup.
513 If it is non-nil, it should be a number between one and nine. Foreign
514 newsgroups that have a level lower or equal to this number will be
515 activated on startup. For instance, if you want to active all
516 subscribed newsgroups, but not the rest, you'd set this variable to
517 `gnus-level-subscribed'.
519 If you subscribe to lots of newsgroups from different servers, startup
520 might take a while. By setting this variable to nil, you'll save time,
521 but you won't be told how many unread articles there are in the
524 (defvar gnus-save-newsrc-file t
525 "*Non-nil means that Gnus will save the `.newsrc' file.
526 Gnus always saves its own startup file, which is called
527 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
528 be readily understood by other newsreaders. If you don't plan on
529 using other newsreaders, set this variable to nil to save some time on
532 (defvar gnus-save-killed-list t
533 "*If non-nil, save the list of killed groups to the startup file.
534 This will save both time (when starting and quitting) and space (both
535 memory and disk), but it will also mean that Gnus has no record of
536 which groups are new and which are old, so the automatic new
537 newsgroups subscription methods become meaningless. You should always
538 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
541 (defvar gnus-interactive-catchup t
542 "*If non-nil, require your confirmation when catching up a group.")
544 (defvar gnus-interactive-post t
545 "*If non-nil, group name will be asked for when posting.")
547 (defvar gnus-interactive-exit t
548 "*If non-nil, require your confirmation when exiting Gnus.")
550 (defvar gnus-kill-killed t
551 "*If non-nil, Gnus will apply kill files to already killed articles.
552 If it is nil, Gnus will never apply kill files to articles that have
553 already been through the scoring process, which might very well save lots
556 (defvar gnus-extract-address-components 'gnus-extract-address-components
557 "*Function for extracting address components from a From header.
558 Two pre-defined function exist: `gnus-extract-address-components',
559 which is the default, quite fast, and too simplistic solution, and
560 `mail-extract-address-components', which works much better, but is
563 (defvar gnus-summary-default-score 0
564 "*Default article score level.
565 If this variable is nil, scoring will be disabled.")
567 (defvar gnus-summary-zcore-fuzz 0
568 "*Fuzziness factor for the zcore in the summary buffer.
569 Articles with scores closer than this to `gnus-summary-default-score'
570 will not be marked.")
572 (defvar gnus-simplify-subject-fuzzy-regexp nil
573 "*Regular expression that will be removed from subject strings if
574 fuzzy subject simplification is selected.")
576 (defvar gnus-group-default-list-level gnus-level-subscribed
577 "*Default listing level.
578 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
580 (defvar gnus-group-use-permanent-levels nil
581 "*If non-nil, once you set a level, Gnus will use this level.")
583 (defvar gnus-show-mime nil
584 "*If non-nil, do mime processing of articles.
585 The articles will simply be fed to the function given by
586 `gnus-show-mime-method'.")
588 (defvar gnus-strict-mime t
589 "*If nil, decode MIME header even if there is not Mime-Version field.")
591 (defvar gnus-show-mime-method (function metamail-buffer)
592 "*Function to process a MIME message.
593 The function is called from the article buffer.")
595 (defvar gnus-show-threads t
596 "*If non-nil, display threads in summary mode.")
598 (defvar gnus-thread-hide-subtree nil
599 "*If non-nil, hide all threads initially.
600 If threads are hidden, you have to run the command
601 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
602 to expose hidden threads.")
604 (defvar gnus-thread-hide-killed t
605 "*If non-nil, hide killed threads automatically.")
607 (defvar gnus-thread-ignore-subject nil
608 "*If non-nil, ignore subjects and do all threading based on the Reference header.
609 If nil, which is the default, articles that have different subjects
610 from their parents will start separate threads.")
612 (defvar gnus-thread-indent-level 4
613 "*Number that says how much each sub-thread should be indented.")
615 (defvar gnus-ignored-newsgroups
616 (purecopy (mapconcat 'identity
617 '("^to\\." ; not "real" groups
618 "^[0-9. \t]+ " ; all digits in name
619 "[][\"#'()]" ; bogus characters
622 "*A regexp to match uninteresting newsgroups in the active file.
623 Any lines in the active file matching this regular expression are
624 removed from the newsgroup list before anything else is done to it,
625 thus making them effectively non-existent.")
627 (defvar gnus-ignored-headers
628 "^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:"
629 "*All headers that match this regexp will be hidden.
630 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
632 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
633 "*All headers that do not match this regexp will be hidden.
634 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
636 (defvar gnus-sorted-header-list
637 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
638 "^Cc:" "^Date:" "^Organization:")
639 "*This variable is a list of regular expressions.
640 If it is non-nil, headers that match the regular expressions will
641 be placed first in the article buffer in the sequence specified by
644 (defvar gnus-show-all-headers nil
645 "*If non-nil, don't hide any headers.")
647 (defvar gnus-save-all-headers t
648 "*If non-nil, don't remove any headers before saving.")
650 (defvar gnus-inhibit-startup-message nil
651 "*If non-nil, the startup message will not be displayed.")
653 (defvar gnus-signature-separator "^-- *$"
654 "Regexp matching signature separator.")
656 (defvar gnus-auto-extend-newsgroup t
657 "*If non-nil, extend newsgroup forward and backward when requested.")
659 (defvar gnus-auto-select-first t
660 "*If non-nil, select the first unread article when entering a group.
661 If you want to prevent automatic selection of the first unread article
662 in some newsgroups, set the variable to nil in
663 `gnus-select-group-hook'.")
665 (defvar gnus-auto-select-next t
666 "*If non-nil, offer to go to the next group from the end of the previous.
667 If the value is t and the next newsgroup is empty, Gnus will exit
668 summary mode and go back to group mode. If the value is neither nil
669 nor t, Gnus will select the following unread newsgroup. In
670 particular, if the value is the symbol `quietly', the next unread
671 newsgroup will be selected without any confirmations.")
673 (defvar gnus-auto-select-same nil
674 "*If non-nil, select the next article with the same subject.")
676 (defvar gnus-summary-check-current nil
677 "*If non-nil, consider the current article when moving.
678 The \"unread\" movement commands will stay on the same line if the
679 current article is unread.")
681 (defvar gnus-auto-center-summary t
682 "*If non-nil, always center the current summary buffer.")
684 (defvar gnus-break-pages t
685 "*If non-nil, do page breaking on articles.
686 The page delimiter is specified by the `gnus-page-delimiter'
689 (defvar gnus-page-delimiter "^\^L"
690 "*Regexp describing what to use as article page delimiters.
691 The default value is \"^\^L\", which is a form linefeed at the
692 beginning of a line.")
694 (defvar gnus-use-full-window t
695 "*If non-nil, use the entire Emacs screen.")
697 (defvar gnus-window-configuration nil
698 "Obsolete variable. See `gnus-buffer-configuration'.")
700 (defvar gnus-buffer-configuration
701 '((group ([group 1.0 point]
702 (if gnus-carpal [group-carpal 4])))
703 (summary ([summary 1.0 point]
704 (if gnus-carpal [summary-carpal 4])))
705 (article ([summary 0.25 point]
706 (if gnus-carpal [summary-carpal 4])
708 (server ([server 1.0 point]
709 (if gnus-carpal [server-carpal 2])))
710 (browse ([browse 1.0 point]
711 (if gnus-carpal [browse-carpal 2])))
712 (group-mail ([mail 1.0 point]))
713 (summary-mail ([mail 1.0 point]))
714 (summary-reply ([article 0.5]
716 (info ([nil 1.0 point]))
717 (summary-faq ([summary 0.25]
719 (edit-group ([group 0.5]
720 [edit-group 1.0 point]))
721 (edit-server ([server 0.5]
722 [edit-server 1.0 point]))
723 (edit-score ([summary 0.25]
724 [edit-score 1.0 point]))
725 (post ([post 1.0 point]))
726 (reply ([article 0.5]
728 (mail-forward ([mail 1.0 point]))
729 (post-forward ([post 1.0 point]))
730 (reply-yank ([mail 1.0 point]))
731 (followup ([article 0.5]
733 (followup-yank ([post 1.0 point])))
734 "Window configuration for all possible Gnus buffers.
735 This variable is a list of lists. Each of these lists has a NAME and
736 a RULE. The NAMEs are commonsense names like `group', which names a
737 rule used when displaying the group buffer; `summary', which names a
738 rule for what happens when you enter a group and do not display an
739 article buffer; and so on. See the value of this variable for a
740 complete list of NAMEs.
742 Each RULE is a list of vectors. The first element in this vector is
743 the name of the buffer to be displayed; the second element is the
744 percentage of the screen this buffer is to occupy (a number in the
745 0.0-0.99 range); the optional third element is `point', which should
746 be present to denote which buffer point is to go to after making this
747 buffer configuration.")
749 (defvar gnus-window-to-buffer
750 '((group . gnus-group-buffer)
751 (summary . gnus-summary-buffer)
752 (article . gnus-article-buffer)
753 (server . gnus-server-buffer)
754 (browse . "*Gnus Browse Server*")
755 (edit-group . gnus-group-edit-buffer)
756 (edit-server . gnus-server-edit-buffer)
757 (group-carpal . gnus-carpal-group-buffer)
758 (summary-carpal . gnus-carpal-summary-buffer)
759 (server-carpal . gnus-carpal-server-buffer)
760 (browse-carpal . gnus-carpal-browse-buffer)
761 (edit-score . gnus-score-edit-buffer)
762 (mail . gnus-mail-buffer)
763 (post . gnus-post-news-buffer)
764 (faq . gnus-faq-buffer))
765 "Mapping from short symbols to buffer names or buffer variables.")
767 (defvar gnus-carpal nil
768 "*If non-nil, display clickable icons.")
770 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
771 "*Function called with a group name when new group is detected.
772 A few pre-made functions are supplied: `gnus-subscribe-randomly'
773 inserts new groups at the beginning of the list of groups;
774 `gnus-subscribe-alphabetically' inserts new groups in strict
775 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
776 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
779 ;; Suggested by a bug report by Hallvard B Furuseth.
780 ;; <h.b.furuseth@usit.uio.no>.
781 (defvar gnus-subscribe-options-newsgroup-method
782 (function gnus-subscribe-alphabetically)
783 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
784 If, for instance, you want to subscribe to all newsgroups in the
785 \"no\" and \"alt\" hierarchies, you'd put the following in your
788 options -n no.all alt.all
790 Gnus will the subscribe all new newsgroups in these hierarchies with
791 the subscription method in this variable.")
793 (defvar gnus-subscribe-hierarchical-interactive nil
794 "*If non-nil, Gnus will offer to subscribe hierarchically.
795 When a new hierarchy appears, Gnus will ask the user:
797 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
799 If the user pressed `d', Gnus will descend the hierarchy, `y' will
800 subscribe to all newsgroups in the hierarchy and `s' will skip this
801 hierarchy in its entirety.")
803 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
804 "*Function used for sorting the group buffer.
805 This function will be called with group info entries as the arguments
806 for the groups to be sorted. Pre-made functions include
807 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
808 `gnus-group-sort-by-level'")
810 ;; Mark variables suggested by Thomas Michanek
811 ;; <Thomas.Michanek@telelogic.se>.
812 (defvar gnus-unread-mark ?
813 "*Mark used for unread articles.")
814 (defvar gnus-ticked-mark ?!
815 "*Mark used for ticked articles.")
816 (defvar gnus-dormant-mark ??
817 "*Mark used for dormant articles.")
818 (defvar gnus-del-mark ?r
819 "*Mark used for del'd articles.")
820 (defvar gnus-read-mark ?R
821 "*Mark used for read articles.")
822 (defvar gnus-expirable-mark ?E
823 "*Mark used for expirable articles.")
824 (defvar gnus-killed-mark ?K
825 "*Mark used for killed articles.")
826 (defvar gnus-kill-file-mark ?X
827 "*Mark used for articles killed by kill files.")
828 (defvar gnus-low-score-mark ?Y
829 "*Mark used for articles with a low score.")
830 (defvar gnus-catchup-mark ?C
831 "*Mark used for articles that are caught up.")
832 (defvar gnus-replied-mark ?A
833 "*Mark used for articles that have been replied to.")
834 (defvar gnus-process-mark ?#
836 (defvar gnus-ancient-mark ?O
837 "*Mark used for ancient articles.")
838 (defvar gnus-canceled-mark ?G
839 "*Mark used for canceled articles.")
840 (defvar gnus-score-over-mark ?+
841 "*Score mark used for articles with high scores.")
842 (defvar gnus-score-below-mark ?-
843 "*Score mark used for articles with low scores.")
844 (defvar gnus-empty-thread-mark ?
845 "*There is no thread under the article.")
846 (defvar gnus-not-empty-thread-mark ?=
847 "*There is a thread under the article.")
848 (defvar gnus-dummy-mark ?Z
849 "*This is a dummy article.")
851 (defvar gnus-view-pseudo-asynchronously nil
852 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
854 (defvar gnus-view-pseudos nil
855 "*If `automatic', pseudo-articles will be viewed automatically.
856 If `not-confirm', pseudos will be viewed automatically, and the user
857 will not be asked to confirm the command.")
859 (defvar gnus-view-pseudos-separately t
860 "*If non-nil, one pseudo-article will be created for each file to be viewed.
861 If nil, all files that use the same viewing command will be given as a
862 list of parameters to that command.")
864 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
865 "*Format of group lines.
866 It works along the same lines as a normal formatting string,
867 with some simple extensions.
869 %M Only marked articles (character, \"*\" or \" \")
870 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
871 %L Level of subscribedness (integer)
872 %N Number of unread articles (integer)
873 %I Number of dormant articles (integer)
874 %i Number of ticked and dormant (integer)
875 %T Number of ticked articles (integer)
876 %R Number of read articles (integer)
877 %t Total number of articles (integer)
878 %y Number of unread, unticked articles (integer)
879 %G Group name (string)
880 %g Qualified group name (string)
881 %D Group description (string)
882 %s Select method (string)
883 %o Moderated group (char, \"m\")
884 %p Process mark (char)
885 %O Moderated group (string, \"(m)\" or \"\")
886 %n Select from where (string)
887 %z A string that look like `<%s:%n>' if a foreign select method is used
888 %u User defined specifier. The next character in the format string should
889 be a letter. Gnus will call the function gnus-user-format-function-X,
890 where X is the letter following %u. The function will be passed the
891 current header as argument. The function should return a string, which
892 will be inserted into the buffer just like information from any other
895 Text between %( and %) will be highlighted with `gnus-mouse-face' when
896 the mouse point move inside the area. There can only be one such area.
898 Note that this format specification is not always respected. For
899 reasons of efficiency, when listing killed groups, this specification
900 is ignored altogether. If the spec is changed considerably, your
901 output may end up looking strange when listing both alive and killed
904 If you use %o or %O, reading the active file will be slower and quite
905 a bit of extra memory will be used. %D will also worsen performance.
906 Also note that if you change the format specification to include any
907 of these specs, you must probably re-start Gnus to see them go into
910 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
911 "*The format specification of the lines in the summary buffer.
913 It works along the same lines as a normal formatting string,
914 with some simple extensions.
916 %N Article number, left padded with spaces (string)
918 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
919 %n Name of the poster (string)
920 %a Extracted name of the poster (string)
921 %A Extracted address of the poster (string)
922 %F Contents of the From: header (string)
923 %x Contents of the Xref: header (string)
924 %D Date of the article (string)
925 %d Date of the article (string) in DD-MMM format
926 %M Message-id of the article (string)
927 %r References of the article (string)
928 %c Number of characters in the article (integer)
929 %L Number of lines in the article (integer)
930 %I Indentation based on thread level (a string of spaces)
931 %T A string with two possible values: 80 spaces if the article
932 is on thread level two or larger and 0 spaces on level one
933 %R \"R\" if this article has been replied to, \" \" otherwise (character)
934 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
935 %[ Opening bracket (character, \"[\" or \"<\")
936 %] Closing bracket (character, \"]\" or \">\")
937 %> Spaces of length thread-level (string)
938 %< Spaces of length (- 20 thread-level) (string)
939 %i Article score (number)
940 %z Article zcore (character)
941 %t Number of articles under the current thread (number).
942 %e Whether the thread is empty or not (character).
943 %u User defined specifier. The next character in the format string should
944 be a letter. Gnus will call the function gnus-user-format-function-X,
945 where X is the letter following %u. The function will be passed the
946 current header as argument. The function should return a string, which
947 will be inserted into the summary just like information from any other
950 Text between %( and %) will be highlighted with `gnus-mouse-face'
951 when the mouse point is placed inside the area. There can only be one
954 The %U (status), %R (replied) and %z (zcore) specs have to be handled
955 with care. For reasons of efficiency, Gnus will compute what column
956 these characters will end up in, and \"hard-code\" that. This means that
957 it is illegal to have these specs after a variable-length spec. Well,
958 you might not be arrested, but your summary buffer will look strange,
961 The smart choice is to have these specs as for to the left as
964 This restriction may disappear in later versions of Gnus.")
966 (defvar gnus-summary-dummy-line-format "* : : %S\n"
967 "*The format specification for the dummy roots in the summary buffer.
968 It works along the same lines as a normal formatting string,
969 with some simple extensions.
973 (defvar gnus-summary-mode-line-format "Gnus %G/%A %Z"
974 "*The format specification for the summary mode line.")
976 (defvar gnus-article-mode-line-format "Gnus %G/%A %S"
977 "*The format specification for the article mode line.")
979 (defvar gnus-group-mode-line-format "Gnus List of groups {%M:%S} "
980 "*The format specification for the group mode line.")
982 (defvar gnus-valid-select-methods
983 '(("nntp" post address prompt-address)
985 ("nnvirtual" none virtual prompt-address)
986 ("nnmbox" mail respool)
987 ("nnml" mail respool)
988 ("nnmh" mail respool)
989 ("nndir" none prompt-address address)
990 ("nneething" none prompt-address)
992 ("nndoc" none prompt-address)
993 ("nnbabyl" mail respool)
994 ("nnkiboze" post virtual)
996 ("nnfolder" mail respool))
997 "An alist of valid select methods.
998 The first element of each list lists should be a string with the name
999 of the select method. The other elements may be be the category of
1000 this method (ie. `post', `mail', `none' or whatever) or other
1001 properties that this method has (like being respoolable).
1002 If you implement a new select method, all you should have to change is
1003 this variable. I think.")
1005 (defvar gnus-updated-mode-lines '(group article summary)
1006 "*List of buffers that should update their mode lines.
1007 The list may contain the symbols `group', `article' and `summary'. If
1008 the corresponding symbol is present, Gnus will keep that mode line
1009 updated with information that may be pertinent.
1010 If this variable is nil, screen refresh may be quicker.")
1012 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1013 (defvar gnus-mode-non-string-length 21
1014 "*Max length of mode-line non-string contents.
1015 If this is nil, Gnus will take space as is needed, leaving the rest
1016 of the modeline intact.")
1019 ;(defvar gnus-mouse-face 'highlight
1020 ; "*Face used for mouse highlighting in Gnus.
1021 ;No mouse highlights will be done if `gnus-visual' is nil.")
1023 (defvar gnus-summary-mark-below nil
1024 "*Mark all articles with a score below this variable as read.
1025 This variable is local to each summary buffer and usually set by the
1028 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1029 "*List of functions used for sorting threads in the summary buffer.
1030 By default, threads are sorted by article number.
1032 Each function takes two threads and return non-nil if the first thread
1033 should be sorted before the other. If you use more than one function,
1034 the primary sort function should be the last.
1036 Ready-mady functions include `gnus-thread-sort-by-number',
1037 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1038 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1039 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1041 (defvar gnus-thread-score-function '+
1042 "*Function used for calculating the total score of a thread.
1044 The function is called with the scores of the article and each
1045 subthread and should then return the score of the thread.
1047 Some functions you can use are `+', `max', or `min'.")
1049 (defvar gnus-options-subscribe nil
1050 "*All new groups matching this regexp will be subscribed unconditionally.
1051 Note that this variable deals only with new newsgroups. This variable
1052 does not affect old newsgroups.")
1054 (defvar gnus-options-not-subscribe nil
1055 "*All new groups matching this regexp will be ignored.
1056 Note that this variable deals only with new newsgroups. This variable
1057 does not affect old (already subscribed) newsgroups.")
1059 (defvar gnus-auto-expirable-newsgroups nil
1060 "*Groups in which to automatically mark read articles as expirable.
1061 If non-nil, this should be a regexp that should match all groups in
1062 which to perform auto-expiry. This only makes sense for mail groups.")
1064 (defvar gnus-hidden-properties '(invisible t intangible t)
1065 "Property list to use for hiding text.")
1067 (defvar gnus-modtime-botch nil
1068 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1069 due to the bogus appearance that .newsrc was modified on disc.")
1073 (defvar gnus-group-mode-hook nil
1074 "*A hook for Gnus group mode.")
1076 (defvar gnus-summary-mode-hook nil
1077 "*A hook for Gnus summary mode.
1078 This hook is run before any variables are set in the summary buffer.")
1080 (defvar gnus-article-mode-hook nil
1081 "*A hook for Gnus article mode.")
1083 (defun gnus-summary-prepare-exit-hook nil
1084 "*A hook called when preparing to exit from the summary buffer.
1085 It calls `gnus-summary-expire-articles' by default.")
1086 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1088 (defun gnus-summary-exit-hook nil
1089 "*A hook called on exit from the summary buffer.")
1091 (defvar gnus-open-server-hook nil
1092 "*A hook called just before opening connection to the news server.")
1094 (defvar gnus-load-hook nil
1095 "*A hook run while Gnus is loaded.")
1097 (defvar gnus-startup-hook nil
1098 "*A hook called at startup.
1099 This hook is called after Gnus is connected to the NNTP server.")
1101 (defvar gnus-get-new-news-hook nil
1102 "*A hook run just before Gnus checks for new news.")
1104 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1105 "*A function that is called to generate the group buffer.
1106 The function is called with three arguments: The first is a number;
1107 all group with a level less or equal to that number should be listed,
1108 if the second is non-nil, empty groups should also be displayed. If
1109 the third is non-nil, it is a number. No groups with a level lower
1110 than this number should be displayed.
1112 The only current function implemented is `gnus-group-prepare-flat'.")
1114 (defvar gnus-group-prepare-hook nil
1115 "*A hook called after the group buffer has been generated.
1116 If you want to modify the group buffer, you can use this hook.")
1118 (defvar gnus-summary-prepare-hook nil
1119 "*A hook called after the summary buffer has been generated.
1120 If you want to modify the summary buffer, you can use this hook.")
1122 (defvar gnus-article-prepare-hook nil
1123 "*A hook called after an article has been prepared in the article buffer.
1124 If you want to run a special decoding program like nkf, use this hook.")
1126 ;(defvar gnus-article-display-hook nil
1127 ; "*A hook called after the article is displayed in the article buffer.
1128 ;The hook is designed to change the contents of the article
1129 ;buffer. Typical functions that this hook may contain are
1130 ;`gnus-article-hide-headers' (hide selected headers),
1131 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1132 ;`gnus-article-hide-signature' (hide signature) and
1133 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1134 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1135 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1136 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1138 (defvar gnus-article-x-face-command
1139 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1140 "String or function to be executed to display an X-Face header.
1141 If it is a string, the command will be executed in a sub-shell
1142 asynchronously. The compressed face will be piped to this command.")
1144 (defvar gnus-article-x-face-too-ugly nil
1145 "Regexp matching posters whose face shouldn't be shown automatically.")
1147 (defvar gnus-select-group-hook nil
1148 "*A hook called when a newsgroup is selected.
1150 If you'd like to simplify subjects like the
1151 `gnus-summary-next-same-subject' command does, you can use the
1154 (setq gnus-select-group-hook
1157 (mapcar (lambda (header)
1158 (mail-header-set-subject
1160 (gnus-simplify-subject
1161 (mail-header-subject header) 're-only)))
1162 gnus-newsgroup-headers))))")
1164 (defvar gnus-select-article-hook
1165 '(gnus-summary-show-thread)
1166 "*A hook called when an article is selected.
1167 The default hook shows conversation thread subtrees of the selected
1168 article automatically using `gnus-summary-show-thread'.")
1170 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1171 "*A hook called to apply kill files to a group.
1172 This hook is intended to apply a kill file to the selected newsgroup.
1173 The function `gnus-apply-kill-file' is called by default.
1175 Since a general kill file is too heavy to use only for a few
1176 newsgroups, I recommend you to use a lighter hook function. For
1177 example, if you'd like to apply a kill file to articles which contains
1178 a string `rmgroup' in subject in newsgroup `control', you can use the
1181 (setq gnus-apply-kill-hook
1184 (cond ((string-match \"control\" gnus-newsgroup-name)
1185 (gnus-kill \"Subject\" \"rmgroup\")
1186 (gnus-expunge \"X\"))))))")
1188 (defvar gnus-visual-mark-article-hook
1189 (list 'gnus-highlight-selected-summary)
1190 "*Hook run after selecting an article in the summary buffer.
1191 It is meant to be used for highlighting the article in some way. It
1192 is not run if `gnus-visual' is nil.")
1194 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1195 "*A hook called after preparing body, but before preparing header headers.
1196 The default hook (`gnus-inews-insert-signature') inserts a signature
1197 file specified by the variable `gnus-signature-file'.")
1199 (defvar gnus-exit-group-hook nil
1200 "*A hook called when exiting (not quitting) summary mode.")
1202 (defvar gnus-suspend-gnus-hook nil
1203 "*A hook called when suspending (not exiting) Gnus.")
1205 (defvar gnus-exit-gnus-hook nil
1206 "*A hook called when exiting Gnus.")
1208 (defvar gnus-save-newsrc-hook nil
1209 "*A hook called when saving the newsrc file.")
1211 (defvar gnus-summary-update-hook
1212 (list 'gnus-summary-highlight-line)
1213 "*A hook called when a summary line is changed.
1214 The hook will not be called if `gnus-visual' is nil.
1216 The default function `gnus-summary-highlight-line' will
1217 highlight the line according to the `gnus-summary-highlight'
1220 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1221 "*A hook called when an article is selected for the first time.
1222 The hook is intended to mark an article as read (or unread)
1223 automatically when it is selected.")
1225 ;; Remove any hilit infestation.
1226 (add-hook 'gnus-startup-hook
1228 (remove-hook 'gnus-summary-prepare-hook
1229 'hilit-rehighlight-buffer-quietly)
1230 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1231 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1232 (remove-hook 'gnus-article-prepare-hook
1233 'hilit-rehighlight-buffer-quietly)))
1237 ;; Internal variables
1239 ;; Avoid highlighting in kill files.
1240 (defvar gnus-summary-inhibit-highlight nil)
1241 (defvar gnus-newsgroup-selected-overlay nil)
1243 (defvar gnus-article-mode-map nil)
1244 (defvar gnus-dribble-buffer nil)
1245 (defvar gnus-headers-retrieved-by nil)
1246 (defvar gnus-article-reply nil)
1247 (defvar gnus-override-method nil)
1248 (defvar gnus-article-check-size nil)
1250 (defvar gnus-current-score-file nil)
1251 (defvar gnus-internal-global-score-files nil)
1252 (defvar gnus-score-file-list nil)
1255 (defvar gnus-current-move-group nil)
1257 (defvar gnus-newsgroup-dependencies nil)
1258 (defvar gnus-newsgroup-threads nil)
1259 (defvar gnus-newsgroup-async nil)
1260 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1262 (defvar gnus-newsgroup-adaptive nil)
1264 (defvar gnus-summary-display-table nil)
1266 (defconst gnus-group-line-format-alist
1267 (list (list ?M 'marked ?c)
1268 (list ?S 'subscribed ?c)
1270 (list ?N 'number ?s)
1271 (list ?I 'number-of-dormant ?d)
1272 (list ?T 'number-of-ticked ?d)
1273 (list ?R 'number-of-read ?s)
1274 (list ?t 'number-total ?d)
1275 (list ?y 'number-of-unread-unticked ?s)
1276 (list ?i 'number-of-ticked-and-dormant ?d)
1278 (list ?G 'qualified-group ?s)
1279 (list ?D 'newsgroup-description ?s)
1280 (list ?o 'moderated ?c)
1281 (list ?O 'moderated-string ?s)
1282 (list ?p 'process-marked ?c)
1283 (list ?s 'news-server ?s)
1284 (list ?n 'news-method ?s)
1285 (list ?z 'news-method-string ?s)
1286 (list ?u 'user-defined ?s)))
1288 (defconst gnus-summary-line-format-alist
1289 (list (list ?N 'number ?d)
1290 (list ?S 'subject ?s)
1291 (list ?s 'subject-or-nil ?s)
1293 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1295 (list ?a '(or (car (funcall gnus-extract-address-components from))
1298 (list ?x (macroexpand '(mail-header-xref header)) ?s)
1299 (list ?D (macroexpand '(mail-header-date header)) ?s)
1300 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s)
1301 (list ?M (macroexpand '(mail-header-id header)) ?s)
1302 (list ?r (macroexpand '(mail-header-references header)) ?s)
1303 (list ?c '(or (mail-header-chars header) 0) ?d)
1305 (list ?I 'indentation ?s)
1306 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1307 (list ?R 'replied ?c)
1308 (list ?\[ 'opening-bracket ?c)
1309 (list ?\] 'closing-bracket ?c)
1310 (list ?\> '(make-string level ? ) ?s)
1311 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1313 (list ?z 'score-char ?c)
1314 (list ?U 'unread ?c)
1315 (list ?t '(gnus-summary-number-of-articles-in-thread
1316 (and (boundp 'thread) (car thread)))
1318 (list ?e '(gnus-summary-number-of-articles-in-thread
1319 (and (boundp 'thread) (car thread)) t)
1321 (list ?u 'user-defined ?s))
1322 "An alist of format specifications that can appear in summary lines,
1323 and what variables they correspond with, along with the type of the
1324 variable (string, integer, character, etc).")
1326 (defconst gnus-summary-dummy-line-format-alist
1327 (list (list ?S 'subject ?s)
1328 (list ?N 'number ?d)
1329 (list ?u 'user-defined ?s)))
1331 (defconst gnus-summary-mode-line-format-alist
1332 (list (list ?G 'group-name ?s)
1333 (list ?g '(gnus-short-group-name group-name) ?s)
1334 (list ?A 'article-number ?d)
1335 (list ?Z 'unread-and-unselected ?s)
1336 (list ?V 'gnus-version ?s)
1337 (list ?U 'unread ?d)
1338 (list ?S 'subject ?s)
1339 (list ?e 'unselected ?d)
1340 (list ?u 'user-defined ?s)
1341 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1343 (defconst gnus-group-mode-line-format-alist
1344 (list (list ?S 'news-server ?s)
1345 (list ?M 'news-method ?s)
1346 (list ?u 'user-defined ?s)))
1348 (defvar gnus-have-read-active-file nil)
1350 (defconst gnus-maintainer
1351 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1352 "The mail address of the Gnus maintainers.")
1354 (defconst gnus-version "Gnus v5.0.2"
1355 "Version number for this version of Gnus.")
1357 (defvar gnus-info-nodes
1358 '((gnus-group-mode "(gnus)The Group Buffer")
1359 (gnus-summary-mode "(gnus)The Summary Buffer")
1360 (gnus-article-mode "(gnus)The Article Buffer"))
1361 "Assoc list of major modes and related Info nodes.")
1363 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1364 "The location of the Gnus documentation group.")
1366 (defvar gnus-group-buffer "*Group*")
1367 (defvar gnus-summary-buffer "*Summary*")
1368 (defvar gnus-article-buffer "*Article*")
1369 (defvar gnus-server-buffer "*Server*")
1371 (defvar gnus-work-buffer " *gnus work*")
1373 (defvar gnus-buffer-list nil
1374 "Gnus buffers that should be killed on exit.")
1376 (defvar gnus-server-alist nil
1377 "List of available servers.")
1379 (defvar gnus-variable-list
1380 '(gnus-newsrc-options gnus-newsrc-options-n
1381 gnus-newsrc-last-checked-date
1382 gnus-newsrc-alist gnus-server-alist
1383 gnus-killed-list gnus-zombie-list)
1384 "Gnus variables saved in the quick startup file.")
1386 (defvar gnus-overload-functions
1387 '((news-inews gnus-inews-news "rnewspost"))
1388 "Functions overloaded by gnus.
1389 It is a list of `(original overload &optional file)'.")
1391 (defvar gnus-newsrc-options nil
1392 "Options line in the .newsrc file.")
1394 (defvar gnus-newsrc-options-n nil
1395 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1397 (defvar gnus-newsrc-last-checked-date nil
1398 "Date Gnus last asked server for new newsgroups.")
1400 (defvar gnus-newsrc-alist nil
1401 "Assoc list of read articles.
1402 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1404 (defvar gnus-newsrc-hashtb nil
1405 "Hashtable of gnus-newsrc-alist.")
1407 (defvar gnus-killed-list nil
1408 "List of killed newsgroups.")
1410 (defvar gnus-killed-hashtb nil
1411 "Hash table equivalent of gnus-killed-list.")
1413 (defvar gnus-zombie-list nil
1414 "List of almost dead newsgroups.")
1416 (defvar gnus-description-hashtb nil
1417 "Descriptions of newsgroups.")
1419 (defvar gnus-list-of-killed-groups nil
1420 "List of newsgroups that have recently been killed by the user.")
1422 (defvar gnus-active-hashtb nil
1423 "Hashtable of active articles.")
1425 (defvar gnus-moderated-list nil
1426 "List of moderated newsgroups.")
1428 (defvar gnus-group-marked nil)
1430 (defvar gnus-current-startup-file nil
1431 "Startup file for the current host.")
1433 (defvar gnus-last-search-regexp nil
1434 "Default regexp for article search command.")
1436 (defvar gnus-last-shell-command nil
1437 "Default shell command on article.")
1439 (defvar gnus-current-select-method nil
1440 "The current method for selecting a newsgroup.")
1442 (defvar gnus-group-list-mode nil)
1444 (defvar gnus-article-internal-prepare-hook nil)
1446 (defvar gnus-newsgroup-name nil)
1447 (defvar gnus-newsgroup-begin nil)
1448 (defvar gnus-newsgroup-end nil)
1449 (defvar gnus-newsgroup-last-rmail nil)
1450 (defvar gnus-newsgroup-last-mail nil)
1451 (defvar gnus-newsgroup-last-folder nil)
1452 (defvar gnus-newsgroup-last-file nil)
1453 (defvar gnus-newsgroup-auto-expire nil)
1454 (defvar gnus-newsgroup-active nil)
1456 (defvar gnus-newsgroup-unreads nil
1457 "List of unread articles in the current newsgroup.")
1459 (defvar gnus-newsgroup-unselected nil
1460 "List of unselected unread articles in the current newsgroup.")
1462 (defvar gnus-newsgroup-reads nil
1463 "Alist of read articles and article marks in the current newsgroup.")
1465 (defvar gnus-newsgroup-marked nil
1466 "List of ticked articles in the current newsgroup (a subset of unread art).")
1468 (defvar gnus-newsgroup-killed nil
1469 "List of ranges of articles that have been through the scoring process.")
1471 (defvar gnus-newsgroup-kill-headers nil)
1473 (defvar gnus-newsgroup-replied nil
1474 "List of articles that have been replied to in the current newsgroup.")
1476 (defvar gnus-newsgroup-expirable nil
1477 "List of articles in the current newsgroup that can be expired.")
1479 (defvar gnus-newsgroup-processable nil
1480 "List of articles in the current newsgroup that can be processed.")
1482 (defvar gnus-newsgroup-bookmarks nil
1483 "List of articles in the current newsgroup that have bookmarks.")
1485 (defvar gnus-newsgroup-dormant nil
1486 "List of dormant articles in the current newsgroup.")
1488 (defvar gnus-newsgroup-scored nil
1489 "List of scored articles in the current newsgroup.")
1491 (defvar gnus-newsgroup-headers nil
1492 "List of article headers in the current newsgroup.")
1493 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1495 (defvar gnus-newsgroup-ancient nil
1496 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1498 (defvar gnus-current-article nil)
1499 (defvar gnus-article-current nil)
1500 (defvar gnus-current-headers nil)
1501 (defvar gnus-have-all-headers nil)
1502 (defvar gnus-last-article nil)
1503 (defvar gnus-newsgroup-history nil)
1504 (defvar gnus-current-kill-article nil)
1506 ;; Save window configuration.
1507 (defvar gnus-prev-winconf nil)
1510 (defvar gnus-summary-line-format-spec nil)
1511 (defvar gnus-summary-dummy-line-format-spec nil)
1512 (defvar gnus-group-line-format-spec nil)
1513 (defvar gnus-summary-mode-line-format-spec nil)
1514 (defvar gnus-article-mode-line-format-spec nil)
1515 (defvar gnus-group-mode-line-format-spec nil)
1516 (defvar gnus-summary-mark-positions nil)
1517 (defvar gnus-group-mark-positions nil)
1519 (defvar gnus-summary-expunge-below nil)
1520 (defvar gnus-reffed-article-number nil)
1522 ; Let the byte-compiler know that we know about this variable.
1523 (defvar rmail-default-rmail-file)
1525 (defvar gnus-cache-removeable-articles nil)
1527 (defconst gnus-summary-local-variables
1528 '(gnus-newsgroup-name
1529 gnus-newsgroup-begin gnus-newsgroup-end
1530 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1531 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1532 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1533 gnus-newsgroup-unselected gnus-newsgroup-marked
1534 gnus-newsgroup-reads
1535 gnus-newsgroup-replied gnus-newsgroup-expirable
1536 gnus-newsgroup-processable gnus-newsgroup-killed
1537 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1538 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1539 gnus-current-article gnus-current-headers gnus-have-all-headers
1540 gnus-last-article gnus-article-internal-prepare-hook
1541 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1542 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1543 gnus-newsgroup-threads gnus-newsgroup-async
1544 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1545 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1546 gnus-newsgroup-history gnus-newsgroup-ancient
1547 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1548 gnus-cache-removeable-articles)
1549 "Variables that are buffer-local to the summary buffers.")
1551 (defconst gnus-bug-message
1552 "Sending a bug report to the Gnus Towers.
1553 ========================================
1555 The buffer below is a mail buffer. When you press `C-c C-c', it will
1556 be sent to the Gnus Bug Exterminators.
1558 At the bottom of the buffer you'll see lots of variable settings.
1559 Please do not delete those. They will tell the Bug People what your
1560 environment is, so that it will be easier to locate the bugs.
1562 If you have found a bug that makes Emacs go \"beep\", set
1563 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1564 and include the backtrace in your bug report.
1566 Please describe the bug in annoying, painstaking detail.
1568 Thank you for your help in stamping out bugs.
1571 ;;; End of variables.
1573 ;; Define some autoload functions Gnus might use.
1577 (autoload 'metamail-buffer "metamail")
1578 (autoload 'Info-goto-node "info")
1579 (autoload 'hexl-hex-string-to-integer "hexl")
1581 (autoload 'pp-to-string "pp")
1582 (autoload 'pp-eval-expression "pp")
1583 (autoload 'mail-extract-address-components "mail-extr")
1585 (autoload 'nnmail-split-fancy "nnmail")
1586 (autoload 'nnvirtual-catchup-group "nnvirtual")
1589 (autoload 'timezone-make-date-arpa-standard "timezone")
1590 (autoload 'timezone-fix-time "timezone")
1591 (autoload 'timezone-make-sortable-date "timezone")
1592 (autoload 'timezone-make-time-string "timezone")
1595 (autoload 'mail-position-on-field "sendmail")
1596 (autoload 'mail-setup "sendmail")
1597 (autoload 'rmail-output "rmailout")
1598 (autoload 'news-mail-other-window "rnewspost")
1599 (autoload 'news-reply-yank-original "rnewspost")
1600 (autoload 'news-caesar-buffer-body "rnewspost")
1601 (autoload 'rmail-insert-rmail-file-header "rmail")
1602 (autoload 'rmail-count-new-messages "rmail")
1603 (autoload 'rmail-show-message "rmail")
1606 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1607 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1608 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1609 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1610 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1611 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1612 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1615 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1616 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1617 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1618 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1619 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1620 (autoload 'gnus-Folder-save-name "gnus-mh")
1621 (autoload 'gnus-folder-save-name "gnus-mh")
1624 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1625 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1626 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1627 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1628 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1629 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1630 (autoload 'gnus-summary-highlight-line "gnus-vis")
1631 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1634 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1635 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1636 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1637 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1638 (autoload 'gnus-article-hide "gnus-vis" nil t)
1639 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1640 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1641 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1642 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1643 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1644 (autoload 'gnus-article-add-button "gnus-vis")
1647 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1648 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1649 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1652 (autoload 'gnus-kill "gnus-kill")
1653 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1654 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1655 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1656 (autoload 'gnus-execute "gnus-kill")
1657 (autoload 'gnus-expunge "gnus-kill")
1660 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1661 (autoload 'gnus-cache-save-buffers "gnus-cache")
1662 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1663 (autoload 'gnus-cache-request-article "gnus-cache")
1664 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1665 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1666 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1667 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1670 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1671 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1672 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1673 (autoload 'gnus-score-save "gnus-score")
1674 (autoload 'gnus-score-headers "gnus-score")
1675 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1676 (autoload 'gnus-score-adaptive "gnus-score")
1677 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1678 (autoload 'gnus-score-find-trace "gnus-score")
1681 (autoload 'gnus-score-customize "gnus-edit" nil t)
1684 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1685 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1686 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1687 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1688 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1689 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1690 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1691 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1692 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1693 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1694 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1695 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1696 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1697 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1698 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1699 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1700 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1701 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1702 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1703 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1704 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1705 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1708 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1709 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1710 (autoload 'gnus-group-mail "gnus-msg" nil t)
1711 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1712 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1713 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1714 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1715 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1716 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1717 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1718 (autoload 'gnus-post-news "gnus-msg" nil t)
1719 (autoload 'gnus-inews-news "gnus-msg" nil t)
1720 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1721 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1722 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1723 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1724 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1725 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1726 (autoload 'gnus-mail-yank-original "gnus-msg")
1727 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1728 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1729 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1730 (autoload 'gnus-article-mail-with-original "gnus-msg")
1731 (autoload 'gnus-article-mail "gnus-msg")
1732 (autoload 'gnus-bug "gnus-msg" nil t)
1735 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1736 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1737 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1738 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1739 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1740 (autoload 'gnus-yank-article "gnus-vm" nil t)
1746 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1747 ;; If you want the cursor to go somewhere else, set these two
1748 ;; functions in some startup hook to whatever you want.
1749 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1750 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1752 ;;; Various macros and substs.
1754 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1755 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1756 (` (let ((GnusStartBufferWindow (selected-window)))
1759 (pop-to-buffer (, buffer))
1761 (select-window GnusStartBufferWindow)))))
1763 (defmacro gnus-gethash (string hashtable)
1764 "Get hash value of STRING in HASHTABLE."
1765 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1766 ;;(` (abbrev-expansion (, string) (, hashtable)))
1767 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1769 (defmacro gnus-sethash (string value hashtable)
1770 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1771 ;; We cannot use define-abbrev since it only accepts string as value.
1772 ;; (set (intern string hashtable) value))
1773 (` (set (intern (, string) (, hashtable)) (, value))))
1775 (defsubst gnus-buffer-substring (beg end)
1776 (buffer-substring (match-beginning beg) (match-end end)))
1778 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1779 ;; function `substring' might cut on a middle of multi-octet
1781 (defun gnus-truncate-string (str width)
1782 (substring str 0 width))
1784 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1785 ;; to limit the length of a string. This function is necessary since
1786 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1787 (defsubst gnus-limit-string (str width)
1788 (if (> (length str) width)
1789 (substring str 0 width)
1792 (defsubst gnus-simplify-subject-re (subject)
1793 "Remove \"Re:\" from subject lines."
1794 (let ((case-fold-search t))
1795 (if (string-match "^re: *" subject)
1796 (substring subject (match-end 0))
1799 (defsubst gnus-goto-char (point)
1800 (and point (goto-char point)))
1802 (defmacro gnus-buffer-exists-p (buffer)
1804 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1807 (defmacro gnus-kill-buffer (buffer)
1808 (` (if (gnus-buffer-exists-p (, buffer))
1809 (kill-buffer (, buffer)))))
1811 (defsubst gnus-point-at-bol ()
1812 "Return point at the beginning of line."
1819 (defsubst gnus-point-at-eol ()
1820 "Return point at the beginning of line."
1827 ;; Delete the current line (and the next N lines.);
1828 (defmacro gnus-delete-line (&optional n)
1829 (` (delete-region (progn (beginning-of-line) (point))
1830 (progn (forward-line (, (or n 1))) (point)))))
1832 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1833 (defvar gnus-init-inhibit nil)
1834 (defun gnus-read-init-file (&optional inhibit-next)
1835 (if gnus-init-inhibit
1836 (setq gnus-init-inhibit nil)
1837 (setq gnus-init-inhibit inhibit-next)
1839 (or (and (file-exists-p gnus-init-file)
1840 ;; Don't try to load a directory.
1841 (not (file-directory-p gnus-init-file)))
1842 (file-exists-p (concat gnus-init-file ".el"))
1843 (file-exists-p (concat gnus-init-file ".elc")))
1844 (load gnus-init-file nil t))))
1846 ;;; Load the user startup file.
1847 ;; (eval '(gnus-read-init-file 'inhibit))
1849 ;;; Load the compatability functions.
1856 ;;; Gnus Utility Functions
1859 (defun gnus-extract-address-components (from)
1861 ;; First find the address - the thing with the @ in it. This may
1862 ;; not be accurate in mail addresses, but does the trick most of
1863 ;; the time in news messages.
1864 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1865 (setq address (substring from (match-beginning 0) (match-end 0))))
1866 ;; Then we check whether the "name <address>" format is used.
1868 (string-match (concat "<" (regexp-quote address) ">") from)
1869 (and (setq name (substring from 0 (1- (match-beginning 0))))
1870 ;; Strip any quotes from the name.
1871 (string-match "\".*\"" name)
1872 (setq name (substring name 1 (1- (match-end 0))))))
1873 ;; If not, then "address (name)" is used.
1875 (and (string-match "(.+)" from)
1876 (setq name (substring from (1+ (match-beginning 0))
1877 (1- (match-end 0)))))
1878 (and (string-match "()" from)
1879 (setq name address))
1880 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1881 ;; XOVER might not support folded From headers.
1882 (and (string-match "(.*" from)
1883 (setq name (substring from (1+ (match-beginning 0))
1885 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1886 (list (or name from) (or address from))))
1888 (defun gnus-fetch-field (field)
1889 "Return the value of the header FIELD of current article."
1892 (let ((case-fold-search t))
1893 (gnus-narrow-to-headers)
1894 (mail-fetch-field field)))))
1896 (defun gnus-goto-colon ()
1898 (search-forward ":" (gnus-point-at-eol) t))
1900 (defun gnus-narrow-to-headers ()
1904 (goto-char (point-min))
1905 (if (search-forward "\n\n" nil t)
1909 (defvar gnus-old-specs nil)
1911 (defun gnus-update-format-specifications ()
1912 (gnus-make-thread-indent-array)
1914 (let ((formats '(summary summary-dummy group
1915 summary-mode group-mode article-mode))
1916 old-format new-format)
1918 (setq new-format (symbol-value
1919 (intern (format "gnus-%s-line-format" (car formats)))))
1920 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1921 (equal old-format new-format))
1922 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1926 (intern (format "gnus-%s-line-format-alist"
1927 (if (eq (car formats) 'article-mode)
1928 'summary-mode (car formats))))))))
1929 (setq gnus-old-specs (cons (cons (car formats) new-format)
1930 (delq (car formats) gnus-old-specs)))
1931 (setq formats (cdr formats))))
1933 (gnus-update-group-mark-positions)
1934 (gnus-update-summary-mark-positions)
1936 (if (and (string-match "%D" gnus-group-line-format)
1937 (not gnus-description-hashtb)
1938 gnus-read-active-file)
1939 (gnus-read-all-descriptions-files)))
1941 (defun gnus-update-summary-mark-positions ()
1943 (let ((gnus-replied-mark 129)
1944 (gnus-score-below-mark 130)
1945 (gnus-score-over-mark 130)
1948 (gnus-set-work-buffer)
1949 (gnus-summary-insert-line
1950 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1951 (goto-char (point-min))
1952 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1954 (goto-char (point-min))
1955 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1956 (- (point) 2))) pos))
1957 (goto-char (point-min))
1958 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1959 (- (point) 2))) pos))
1960 (setq gnus-summary-mark-positions pos))))
1962 (defun gnus-update-group-mark-positions ()
1964 (let ((gnus-process-mark 128)
1965 (gnus-group-marked '("dummy.group")))
1966 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
1967 (gnus-set-work-buffer)
1968 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1969 (goto-char (point-min))
1970 (setq gnus-group-mark-positions
1971 (list (cons 'process (and (search-forward "\200" nil t)
1972 (- (point) 2))))))))
1974 (defun gnus-mouse-face-function (form)
1975 (` (let ((string (, form)))
1976 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1979 (defun gnus-max-width-function (el max-width)
1980 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1981 (` (let* ((val (eval (, el)))
1982 (valstr (if (numberp val)
1983 (int-to-string val) val)))
1984 (if (> (length valstr) (, max-width))
1985 (substring valstr 0 (, max-width))
1988 (defun gnus-parse-format (format spec-alist)
1989 ;; This function parses the FORMAT string with the help of the
1990 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1991 ;; string. If the FORMAT string contains the specifiers %( and %)
1992 ;; the text between them will have the mouse-face text property.
1993 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1994 (if (and gnus-visual gnus-mouse-face)
1995 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1996 (button (substring format (match-beginning 2) (match-end 2)))
1997 (post (substring format (match-beginning 3) (match-end 3))))
1999 (gnus-parse-simple-format pre spec-alist)
2000 (gnus-mouse-face-function
2001 (gnus-parse-simple-format button spec-alist))
2002 (gnus-parse-simple-format post spec-alist)))
2003 (gnus-parse-simple-format
2004 (concat (substring format (match-beginning 1) (match-end 1))
2005 (substring format (match-beginning 2) (match-end 2))
2006 (substring format (match-beginning 3) (match-end 3)))
2008 (gnus-parse-simple-format format spec-alist)))
2010 (defun gnus-parse-simple-format (format spec-alist)
2011 ;; This function parses the FORMAT string with the help of the
2012 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2013 ;; string. The list will consist of the symbol `format', a format
2014 ;; specification string, and a list of forms depending on the
2017 spec flist fstring newspec elem beg)
2019 (gnus-set-work-buffer)
2021 (goto-char (point-min))
2022 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
2023 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2025 ;; First check if there are any specs that look anything like
2026 ;; "%12,12A", ie. with a "max width specification". These have
2027 ;; to be treated specially.
2028 (if (setq beg (match-beginning 1))
2031 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2033 (setq beg (match-beginning 2)))
2034 ;; Find the specification from `spec-alist'.
2035 (if (not (setq elem (cdr (assq spec spec-alist))))
2036 (setq elem '("*" ?s)))
2037 ;; Treat user defined format specifiers specially
2038 (and (eq (car elem) 'user-defined)
2041 (list (intern (concat "gnus-user-format-function-"
2047 (delete-region (match-beginning 3) (match-end 3)))
2048 (if (not (zerop max-width))
2049 (let ((el (car elem)))
2050 (cond ((= (car (cdr elem)) ?c)
2051 (setq el (list 'char-to-string el)))
2052 ((= (car (cdr elem)) ?d)
2053 (numberp el) (setq el (list 'int-to-string el))))
2054 (setq flist (cons (gnus-max-width-function el max-width)
2057 (setq flist (cons (car elem) flist))
2058 (setq newspec (car (cdr elem))))
2059 ;; Remove the old specification (and possibly a ",12" string).
2060 (delete-region beg (match-end 2))
2061 ;; Insert the new specification.
2064 (setq fstring (buffer-substring 1 (point-max))))
2065 (cons 'format (cons fstring (nreverse flist)))))
2067 (defun gnus-set-work-buffer ()
2068 (if (get-buffer gnus-work-buffer)
2070 (set-buffer gnus-work-buffer)
2072 (set-buffer (get-buffer-create gnus-work-buffer))
2073 (kill-all-local-variables)
2074 (buffer-disable-undo (current-buffer))
2075 (gnus-add-current-to-buffer-list)))
2077 ;; Article file names when saving.
2079 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2080 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2081 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2082 Otherwise, it is like ~/News/news/group/num."
2085 (concat (if (gnus-use-long-file-name 'not-save)
2086 (gnus-capitalize-newsgroup newsgroup)
2087 (gnus-newsgroup-directory-form newsgroup))
2088 "/" (int-to-string (mail-header-number headers)))
2089 (or gnus-article-save-directory "~/News"))))
2091 (string-equal (file-name-directory default)
2092 (file-name-directory last-file))
2093 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2095 (or last-file default))))
2097 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2098 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2099 If variable `gnus-use-long-file-name' is non-nil, it is
2100 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2103 (concat (if (gnus-use-long-file-name 'not-save)
2105 (gnus-newsgroup-directory-form newsgroup))
2106 "/" (int-to-string (mail-header-number headers)))
2107 (or gnus-article-save-directory "~/News"))))
2109 (string-equal (file-name-directory default)
2110 (file-name-directory last-file))
2111 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2113 (or last-file default))))
2115 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2116 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2117 If variable `gnus-use-long-file-name' is non-nil, it is
2118 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2121 (if (gnus-use-long-file-name 'not-save)
2122 (gnus-capitalize-newsgroup newsgroup)
2123 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2124 (or gnus-article-save-directory "~/News"))))
2126 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2127 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2128 If variable `gnus-use-long-file-name' is non-nil, it is
2129 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2132 (if (gnus-use-long-file-name 'not-save)
2134 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2135 (or gnus-article-save-directory "~/News"))))
2137 ;; For subscribing new newsgroup
2139 (defun gnus-subscribe-hierarchical-interactive (groups)
2140 (let ((groups (sort groups 'string<))
2141 prefixes prefix start ans group starts)
2143 (setq prefixes (list "^"))
2144 (while (and groups prefixes)
2145 (while (not (string-match (car prefixes) (car groups)))
2146 (setq prefixes (cdr prefixes)))
2147 (setq prefix (car prefixes))
2148 (setq start (1- (length prefix)))
2149 (if (and (string-match "[^\\.]\\." (car groups) start)
2152 (concat "^" (substring (car groups) 0 (match-end 0))))
2153 (string-match prefix (car (cdr groups))))
2155 (setq prefixes (cons prefix prefixes))
2156 (message "Descend hierarchy %s? ([y]nsq): "
2157 (substring prefix 1 (1- (length prefix))))
2158 (setq ans (read-char))
2161 (string-match prefix
2162 (setq group (car groups))))
2163 (setq gnus-killed-list
2164 (cons group gnus-killed-list))
2165 (gnus-sethash group group gnus-killed-hashtb)
2166 (setq groups (cdr groups)))
2167 (setq starts (cdr starts)))
2170 (string-match prefix
2171 (setq group (car groups))))
2172 (gnus-sethash group group gnus-killed-hashtb)
2173 (gnus-subscribe-alphabetically (car groups))
2174 (setq groups (cdr groups)))
2175 (setq starts (cdr starts)))
2178 (setq group (car groups))
2179 (setq gnus-killed-list (cons group gnus-killed-list))
2180 (gnus-sethash group group gnus-killed-hashtb)
2181 (setq groups (cdr groups))))
2183 (message "Subscribe %s? ([n]yq)" (car groups))
2184 (setq ans (read-char))
2185 (setq group (car groups))
2187 (gnus-subscribe-alphabetically (car groups))
2188 (gnus-sethash group group gnus-killed-hashtb))
2191 (setq group (car groups))
2192 (setq gnus-killed-list (cons group gnus-killed-list))
2193 (gnus-sethash group group gnus-killed-hashtb)
2194 (setq groups (cdr groups))))
2196 (setq gnus-killed-list (cons group gnus-killed-list))
2197 (gnus-sethash group group gnus-killed-hashtb)))
2198 (setq groups (cdr groups)))))))
2200 (defun gnus-subscribe-randomly (newsgroup)
2201 "Subscribe new NEWSGROUP by making it the first newsgroup."
2202 (gnus-subscribe-newsgroup newsgroup))
2204 (defun gnus-subscribe-alphabetically (newgroup)
2205 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2206 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2207 (let ((groups (cdr gnus-newsrc-alist))
2209 (while (and (not before) groups)
2210 (if (string< newgroup (car (car groups)))
2211 (setq before (car (car groups)))
2212 (setq groups (cdr groups))))
2213 (gnus-subscribe-newsgroup newgroup before)))
2215 (defun gnus-subscribe-hierarchically (newgroup)
2216 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2217 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2219 (set-buffer (find-file-noselect gnus-current-startup-file))
2220 (let ((groupkey newgroup)
2222 (while (and (not before) groupkey)
2223 (goto-char (point-min))
2225 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2226 (while (and (re-search-forward groupkey-re nil t)
2228 (setq before (buffer-substring
2229 (match-beginning 1) (match-end 1)))
2230 (string< before newgroup)))))
2231 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2233 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2234 (substring groupkey (match-beginning 1) (match-end 1)))))
2235 (gnus-subscribe-newsgroup newgroup before))))
2237 (defun gnus-subscribe-interactively (newsgroup)
2238 "Subscribe new NEWSGROUP interactively.
2239 It is inserted in hierarchical newsgroup order if subscribed. If not,
2241 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2242 (gnus-subscribe-hierarchically newsgroup)
2243 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2245 (defun gnus-subscribe-zombies (newsgroup)
2246 "Make new NEWSGROUP a zombie group."
2247 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2249 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2250 "Subscribe new NEWSGROUP.
2251 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2252 the first newsgroup."
2253 ;; We subscribe the group by changing its level to `subscribed'.
2254 (gnus-group-change-level
2255 newsgroup gnus-level-default-subscribed
2256 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2257 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2261 (defun gnus-newsgroup-directory-form (newsgroup)
2262 "Make hierarchical directory name from NEWSGROUP name."
2263 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2264 (len (length newsgroup))
2266 ;; If this is a foreign group, we don't want to translate the
2268 (if (setq idx (string-match ":" newsgroup))
2269 (aset newsgroup idx ?/)
2271 ;; Replace all occurrences of `.' with `/'.
2273 (if (= (aref newsgroup idx) ?.)
2274 (aset newsgroup idx ?/))
2275 (setq idx (1+ idx)))
2278 (defun gnus-newsgroup-saveable-name (group)
2279 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2281 (gnus-replace-chars-in-string group ?/ ?.))
2283 (defun gnus-make-directory (dir)
2284 "Make DIRECTORY recursively."
2285 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2286 ;; of the many mysteries of the universe.
2287 (let* ((dir (expand-file-name dir default-directory))
2289 (if (string-match "/$" dir)
2290 (setq dir (substring dir 0 (match-beginning 0))))
2291 ;; First go down the path until we find a directory that exists.
2292 (while (not (file-exists-p dir))
2293 (setq dirs (cons dir dirs))
2294 (string-match "/[^/]+$" dir)
2295 (setq dir (substring dir 0 (match-beginning 0))))
2296 ;; Then create all the subdirs.
2297 (while (and dirs (not err))
2299 (make-directory (car dirs))
2300 (error (setq err t)))
2301 (setq dirs (cdr dirs)))
2302 ;; We return whether we were successful or not.
2305 (defun gnus-capitalize-newsgroup (newsgroup)
2306 "Capitalize NEWSGROUP name."
2307 (and (not (zerop (length newsgroup)))
2308 (concat (char-to-string (upcase (aref newsgroup 0)))
2309 (substring newsgroup 1))))
2313 (defun gnus-simplify-subject (subject &optional re-only)
2314 "Remove `Re:' and words in parentheses.
2315 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2316 (let ((case-fold-search t)) ;Ignore case.
2317 ;; Remove `Re:' and `Re^N:'.
2318 (if (string-match "^re:[ \t]*" subject)
2319 (setq subject (substring subject (match-end 0))))
2320 ;; Remove words in parentheses from end.
2322 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2323 (setq subject (substring subject 0 (match-beginning 0)))))
2324 ;; Return subject string.
2327 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2329 (defun gnus-simplify-subject-fuzzy (subject)
2330 (let ((case-fold-search t))
2332 (gnus-set-work-buffer)
2334 (inline (gnus-simplify-buffer-fuzzy))
2337 (defun gnus-simplify-buffer-fuzzy ()
2338 (goto-char (point-min))
2339 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2340 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2342 (replace-match "" t t))
2343 (goto-char (point-min))
2344 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2345 (replace-match "" t t))
2346 (goto-char (point-min))
2347 (while (re-search-forward "[ \t]+" nil t)
2348 (replace-match " " t t))
2349 (goto-char (point-min))
2350 (while (re-search-forward "[ \t]+$" nil t)
2351 (replace-match "" t t))
2352 (goto-char (point-min))
2353 (while (re-search-forward "^[ \t]+" nil t)
2354 (replace-match "" t t))
2355 (if gnus-simplify-subject-fuzzy-regexp
2356 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2357 (replace-match "" t t))))
2359 ;; Add the current buffer to the list of buffers to be killed on exit.
2360 (defun gnus-add-current-to-buffer-list ()
2361 (or (memq (current-buffer) gnus-buffer-list)
2362 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2364 (defun gnus-string> (s1 s2)
2365 (not (or (string< s1 s2)
2368 ;; Functions accessing headers.
2369 ;; Functions are more convenient than macros in some cases.
2371 (defun gnus-header-number (header)
2372 (mail-header-number header))
2374 (defun gnus-header-subject (header)
2375 (mail-header-subject header))
2377 (defun gnus-header-from (header)
2378 (mail-header-from header))
2380 (defun gnus-header-xref (header)
2381 (mail-header-xref header))
2383 (defun gnus-header-lines (header)
2384 (mail-header-lines header))
2386 (defun gnus-header-date (header)
2387 (mail-header-date header))
2389 (defun gnus-header-id (header)
2390 (mail-header-id header))
2392 (defun gnus-header-message-id (header)
2393 (mail-header-id header))
2395 (defun gnus-header-chars (header)
2396 (mail-header-chars header))
2398 (defun gnus-header-references (header)
2399 (mail-header-references header))
2401 ;;; General various misc type functions.
2403 (defun gnus-clear-system ()
2404 "Clear all variables and buffers."
2405 ;; Clear Gnus variables.
2406 (let ((variables gnus-variable-list))
2408 (set (car variables) nil)
2409 (setq variables (cdr variables))))
2410 ;; Clear other internal variables.
2411 (setq gnus-list-of-killed-groups nil
2412 gnus-have-read-active-file nil
2413 gnus-newsrc-alist nil
2414 gnus-newsrc-hashtb nil
2415 gnus-killed-list nil
2416 gnus-zombie-list nil
2417 gnus-killed-hashtb nil
2418 gnus-active-hashtb nil
2419 gnus-moderated-list nil
2420 gnus-description-hashtb nil
2421 gnus-newsgroup-headers nil
2422 gnus-newsgroup-headers-hashtb-by-number nil
2423 gnus-newsgroup-name nil
2424 gnus-server-alist nil
2425 gnus-current-select-method nil)
2426 ;; Reset any score variables.
2427 (and (boundp 'gnus-score-cache)
2428 (set 'gnus-score-cache nil))
2429 (and (boundp 'gnus-internal-global-score-files)
2430 (set 'gnus-internal-global-score-files nil))
2431 ;; Kill the startup file.
2432 (and gnus-current-startup-file
2433 (get-file-buffer gnus-current-startup-file)
2434 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2435 ;; Save any cache buffers.
2436 (and gnus-use-cache (gnus-cache-save-buffers))
2437 ;; Clear the dribble buffer.
2438 (gnus-dribble-clear)
2439 ;; Kill global KILL file buffer.
2440 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2441 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2442 (gnus-kill-buffer nntp-server-buffer)
2443 ;; Kill Gnus buffers.
2444 (while gnus-buffer-list
2445 (gnus-kill-buffer (car gnus-buffer-list))
2446 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2448 (defun gnus-windows-old-to-new (setting)
2449 (if (symbolp setting)
2451 (cond ((eq setting 'SelectArticle)
2453 ((eq setting 'SelectSubject)
2455 ((eq setting 'SelectNewsgroup)
2458 (if (or (listp setting)
2459 (not (and gnus-window-configuration
2460 (memq setting '(group summary article)))))
2462 (let* ((setting (if (eq setting 'group)
2463 (if (assq 'newsgroup gnus-window-configuration)
2465 'newsgroups) setting))
2466 (elem (car (cdr (assq setting gnus-window-configuration))))
2467 (total (apply '+ elem))
2468 (types '(group summary article))
2469 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2474 (or (zerop (nth i elem))
2476 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2477 (setq out (cons (if (eq pbuf (nth i types))
2478 (vector (nth i types) perc 'point)
2479 (vector (nth i types) perc))
2482 (list (nreverse out)))))
2484 (defun gnus-add-configuration (conf)
2485 (setq gnus-buffer-configuration
2486 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2487 gnus-buffer-configuration))))
2489 (defun gnus-configure-windows (setting &optional force)
2490 (setq setting (gnus-windows-old-to-new setting))
2491 (let ((r (if (symbolp setting)
2492 (cdr (assq setting gnus-buffer-configuration))
2494 (in-buf (current-buffer))
2495 rule val w height hor ohor heights sub jump-buffer
2496 rel total to-buf all-visible)
2497 (or r (error "No such setting: %s" setting))
2499 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2500 ;; All the windows mentioned are already visibe, so we just
2501 ;; put point in the assigned buffer, and do not touch the
2503 (select-window (get-buffer-window all-visible))
2505 ;; Either remove all windows or just remove all Gnus windows.
2506 (if gnus-use-full-window
2507 (delete-other-windows)
2508 (gnus-remove-some-windows)
2509 (switch-to-buffer nntp-server-buffer))
2515 ;; We have to do the (possible) horizontal splitting before the
2517 (if (and (listp (car hor))
2518 (eq (car (car hor)) 'horizontal))
2522 (if (integerp (nth 1 (car hor)))
2524 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2526 (setq hor (cdr hor))))
2528 ;; Go through the rules and eval the elements that are to be
2531 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2533 ;; Expand short buffer name.
2534 (setq w (aref val 0))
2535 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2537 (setq val (apply 'vector (mapcar 'identity val)))
2539 (setq ohor (cons val ohor))))
2540 (setq hor (cdr hor)))
2541 (setq rule (cons (nreverse ohor) rule))
2543 (setq rule (nreverse rule))
2545 ;; We tally the window sizes.
2546 (setq total (window-height))
2548 (setq hor (car rule))
2549 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2550 (setq hor (cdr hor)))
2553 (setq rel (aref (car hor) 1)
2555 (cond ((and (floatp rel) (= 1.0 rel))
2560 (max (floor (* total rel)) 4)))
2562 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2564 (setq heights (nreverse heights)
2567 ;; We then go through these heighs and create windows for them.
2569 (setq height (car heights)
2570 heights (cdr heights))
2572 (setq height (- total sub)))
2574 (split-window nil height))
2575 (setq to-buf (aref (car hor) 0))
2580 (symbol-value (aref (car hor) 0)))
2582 (aref (car hor) 0))))
2583 (and (> (length (car hor)) 2)
2584 (eq (aref (car hor) 2) 'point)
2585 (setq jump-buffer (current-buffer)))
2587 (setq hor (cdr hor)))
2589 (setq rule (cdr rule)))
2591 ;; Finally, we pop to the buffer that's supposed to have point.
2592 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2594 (select-window (get-buffer-window jump-buffer))
2595 (set-buffer jump-buffer))))
2597 (defun gnus-all-windows-visible-p (rule)
2598 (let (invisible hor jump-buffer val buffer)
2599 ;; Go through the rules and eval the elements that are to be
2601 (while (and rule (not invisible))
2602 (setq hor (car rule)
2604 (while (and hor (not invisible))
2605 (if (setq val (if (vectorp (car hor))
2607 (if (not (eq (car (car hor)) 'horizontal))
2610 ;; Expand short buffer name.
2611 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2613 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2615 (and (> (length val) 2) (eq 'point (aref val 2))
2616 (setq jump-buffer buffer))
2617 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2618 (setq hor (cdr hor))))
2619 (and (not invisible) jump-buffer)))
2621 (defun gnus-window-top-edge (&optional window)
2622 (nth 1 (window-edges window)))
2624 (defun gnus-remove-some-windows ()
2625 (let ((buffers gnus-window-to-buffer)
2626 buf bufs lowest-buf lowest)
2628 ;; Remove windows on all known Gnus buffers.
2630 (setq buf (cdr (car buffers)))
2632 (setq buf (and (boundp buf) (symbol-value buf))))
2634 (get-buffer-window buf)
2636 (setq bufs (cons buf bufs))
2638 (if (or (not lowest)
2639 (< (gnus-window-top-edge) lowest))
2641 (setq lowest (gnus-window-top-edge))
2642 (setq lowest-buf buf)))))
2643 (setq buffers (cdr buffers)))
2644 ;; Remove windows on *all* summary buffers.
2648 (let ((buf (window-buffer win)))
2649 (if (string-match "^\\*Summary" (buffer-name buf))
2651 (setq bufs (cons buf bufs))
2653 (if (or (not lowest)
2654 (< (gnus-window-top-edge) lowest))
2656 (setq lowest-buf buf)
2657 (setq lowest (gnus-window-top-edge))))))))))
2660 (pop-to-buffer lowest-buf)
2661 (switch-to-buffer nntp-server-buffer)))
2663 (and (not (eq (car bufs) lowest-buf))
2664 (delete-windows-on (car bufs)))
2665 (setq bufs (cdr bufs))))))
2667 (defun gnus-version ()
2668 "Version numbers of this version of Gnus."
2670 (let ((methods gnus-valid-select-methods)
2673 ;; Go through all the legal select methods and add their version
2674 ;; numbers to the total version string. Only the backends that are
2675 ;; currently in use will have their message numbers taken into
2678 (setq meth (intern (concat (car (car methods)) "-version")))
2680 (stringp (symbol-value meth))
2681 (setq mess (concat mess "; " (symbol-value meth))))
2682 (setq methods (cdr methods)))
2683 (gnus-message 2 mess)))
2685 (defun gnus-info-find-node ()
2686 "Find Info documentation of Gnus."
2688 ;; Enlarge info window if needed.
2689 (let ((mode major-mode))
2690 (gnus-configure-windows 'info)
2691 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2693 (defun gnus-overload-functions (&optional overloads)
2694 "Overload functions specified by optional argument OVERLOADS.
2695 If nothing is specified, use the variable gnus-overload-functions."
2697 (overloads (or overloads gnus-overload-functions)))
2699 (setq defs (car overloads))
2700 (setq overloads (cdr overloads))
2701 ;; Load file before overloading function if necessary. Make
2702 ;; sure we cannot use `require' always.
2703 (and (not (fboundp (car defs)))
2704 (car (cdr (cdr defs)))
2705 (load (car (cdr (cdr defs))) nil 'nomessage))
2706 (fset (car defs) (car (cdr defs))))))
2708 (defun gnus-replace-chars-in-string (string &rest pairs)
2709 "Replace characters in STRING from FROM to TO."
2710 (let ((string (substring string 0)) ;Copy string.
2711 (len (length string))
2714 (or (zerop (% (length pairs) 2))
2715 (error "Odd number of translation pairs"))
2716 (setplist 'sym pairs)
2717 ;; Replace all occurrences of FROM with TO.
2719 (if (setq to (get 'sym (aref string idx)))
2720 (aset string idx to))
2721 (setq idx (1+ idx)))
2724 (defun gnus-days-between (date1 date2)
2725 ;; Return the number of days between date1 and date2.
2726 (- (gnus-day-number date1) (gnus-day-number date2)))
2728 (defun gnus-day-number (date)
2729 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2730 (timezone-parse-date date))))
2731 (timezone-absolute-from-gregorian
2732 (nth 1 dat) (nth 2 dat) (car dat))))
2734 ;; Returns a floating point number that says how many seconds have
2735 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2736 (defun gnus-seconds-since-epoch (date)
2737 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2738 (timezone-parse-date date)))
2739 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2740 (timezone-parse-time
2741 (aref (timezone-parse-date date) 3))))
2742 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2743 (timezone-parse-date "Jan 1 12:00:00 1970")))
2744 (tday (- (timezone-absolute-from-gregorian
2745 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2746 (timezone-absolute-from-gregorian
2747 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2749 (* (nth 1 ttime) 60)
2750 (* 1.0 (nth 0 ttime) 60 60)
2751 (* 1.0 tday 60 60 24))))
2753 (defun gnus-file-newer-than (file date)
2754 (let ((fdate (nth 5 (file-attributes file))))
2755 (or (> (car fdate) (car date))
2756 (and (= (car fdate) (car date))
2757 (> (nth 1 fdate) (nth 1 date))))))
2759 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2761 (defun gnus-y-or-n-p (prompt)
2766 (defun gnus-yes-or-no-p (prompt)
2768 (yes-or-no-p prompt)
2771 ;; Check whether to use long file names.
2772 (defun gnus-use-long-file-name (symbol)
2773 ;; The variable has to be set...
2774 (and gnus-use-long-file-name
2775 ;; If it isn't a list, then we return t.
2776 (or (not (listp gnus-use-long-file-name))
2777 ;; If it is a list, and the list contains `symbol', we
2779 (not (memq symbol gnus-use-long-file-name)))))
2781 ;; I suspect there's a better way, but I haven't taken the time to do
2782 ;; it yet. -erik selberg@cs.washington.edu
2783 (defun gnus-dd-mmm (messy-date)
2784 "Return a string like DD-MMM from a big messy string"
2785 (let ((datevec (timezone-parse-date messy-date)))
2787 (or (aref datevec 2) "??")
2790 (nth (1- (string-to-number (aref datevec 1)))
2791 timezone-months-assoc))
2794 ;; Make a hash table (default and minimum size is 255).
2795 ;; Optional argument HASHSIZE specifies the table size.
2796 (defun gnus-make-hashtable (&optional hashsize)
2797 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2799 ;; Make a number that is suitable for hashing; bigger than MIN and one
2801 (defun gnus-create-hash-size (min)
2807 ;; Show message if message has a lower level than `gnus-verbose'.
2808 ;; Guide-line for numbers:
2809 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2810 ;; for things that take a long time, 7 - not very important messages
2811 ;; on stuff, 9 - messages inside loops.
2812 (defun gnus-message (level &rest args)
2813 (if (<= level gnus-verbose)
2814 (apply 'message args)
2815 ;; We have to do this format thingie here even if the result isn't
2816 ;; shown - the return value has to be the same as the return value
2818 (apply 'format args)))
2820 ;; Generate a unique new group name.
2821 (defun gnus-generate-new-group-name (leaf)
2824 (while (gnus-gethash name gnus-newsrc-hashtb)
2825 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2828 ;;; List and range functions
2830 (defun gnus-last-element (list)
2831 "Return last element of LIST."
2833 (setq list (cdr list)))
2836 (defun gnus-copy-sequence (list)
2837 "Do a complete, total copy of a list."
2838 (if (and (consp list) (not (consp (cdr list))))
2839 (cons (car list) (cdr list))
2840 (mapcar (lambda (elem) (if (consp elem)
2841 (if (consp (cdr elem))
2842 (gnus-copy-sequence elem)
2843 (cons (car elem) (cdr elem)))
2847 (defun gnus-set-difference (list1 list2)
2848 "Return a list of elements of LIST1 that do not appear in LIST2."
2849 (let ((list1 (copy-sequence list1)))
2851 (setq list1 (delq (car list2) list1))
2852 (setq list2 (cdr list2)))
2855 (defun gnus-sorted-complement (list1 list2)
2856 "Return a list of elements of LIST1 that do not appear in LIST2.
2857 Both lists have to be sorted over <."
2859 (if (or (null list1) (null list2))
2861 (while (and list1 list2)
2862 (cond ((= (car list1) (car list2))
2863 (setq list1 (cdr list1)
2865 ((< (car list1) (car list2))
2866 (setq out (cons (car list1) out))
2867 (setq list1 (cdr list1)))
2869 (setq out (cons (car list2) out))
2870 (setq list2 (cdr list2)))))
2871 (nconc (nreverse out) (or list1 list2)))))
2873 (defun gnus-intersection (list1 list2)
2876 (if (memq (car list2) list1)
2877 (setq result (cons (car list2) result)))
2878 (setq list2 (cdr list2)))
2881 (defun gnus-sorted-intersection (list1 list2)
2882 ;; LIST1 and LIST2 have to be sorted over <.
2884 (while (and list1 list2)
2885 (cond ((= (car list1) (car list2))
2886 (setq out (cons (car list1) out)
2889 ((< (car list1) (car list2))
2890 (setq list1 (cdr list1)))
2892 (setq list2 (cdr list2)))))
2895 (defun gnus-set-sorted-intersection (list1 list2)
2896 ;; LIST1 and LIST2 have to be sorted over <.
2897 ;; This function modifies LIST1.
2898 (let* ((top (cons nil list1))
2900 (while (and list1 list2)
2901 (cond ((= (car list1) (car list2))
2905 ((< (car list1) (car list2))
2906 (setcdr prev (cdr list1))
2907 (setq list1 (cdr list1)))
2909 (setq list2 (cdr list2)))))
2913 (defun gnus-compress-sequence (numbers &optional always-list)
2914 "Convert list of numbers to a list of ranges or a single range.
2915 If ALWAYS-LIST is non-nil, this function will always release a list of
2917 (let* ((first (car numbers))
2918 (last (car numbers))
2922 (if (not (listp (cdr numbers)))
2925 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2926 ((= (1+ last) (car numbers)) ;Still in sequence
2927 (setq last (car numbers)))
2928 (t ;End of one sequence
2930 (cons (if (= first last) first
2931 (cons first last)) result))
2932 (setq first (car numbers))
2933 (setq last (car numbers))))
2934 (setq numbers (cdr numbers)))
2935 (if (and (not always-list) (null result))
2936 (if (= first last) (list first) (cons first last))
2937 (nreverse (cons (if (= first last) first (cons first last))
2940 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2941 (defun gnus-uncompress-range (ranges)
2942 "Expand a list of ranges into a list of numbers.
2943 RANGES is either a single range on the form `(num . num)' or a list of
2945 (let (first last result)
2949 ((not (listp (cdr ranges)))
2950 (setq first (car ranges))
2951 (setq last (cdr ranges))
2952 (while (<= first last)
2953 (setq result (cons first result))
2954 (setq first (1+ first)))
2958 (if (atom (car ranges))
2959 (if (numberp (car ranges))
2960 (setq result (cons (car ranges) result)))
2961 (setq first (car (car ranges)))
2962 (setq last (cdr (car ranges)))
2963 (while (<= first last)
2964 (setq result (cons first result))
2965 (setq first (1+ first))))
2966 (setq ranges (cdr ranges)))
2967 (nreverse result)))))
2969 (defun gnus-add-to-range (ranges list)
2970 "Return a list of ranges that has all articles from both RANGES and LIST.
2971 Note: LIST has to be sorted over `<'."
2973 (gnus-compress-sequence list t)
2974 (setq list (copy-sequence list))
2975 (or (listp (cdr ranges))
2976 (setq ranges (list ranges)))
2978 ilist lowest highest temp)
2979 (while (and ranges list)
2981 (setq lowest (or (and (atom (car ranges)) (car ranges))
2982 (car (car ranges))))
2983 (while (and list (cdr list) (< (car (cdr list)) lowest))
2984 (setq list (cdr list)))
2985 (if (< (car ilist) lowest)
2988 (setq list (cdr list))
2990 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2991 (setq highest (or (and (atom (car ranges)) (car ranges))
2992 (cdr (car ranges))))
2993 (while (and list (<= (car list) highest))
2994 (setq list (cdr list)))
2995 (setq ranges (cdr ranges)))
2997 (setq out (nconc (gnus-compress-sequence list t) out)))
2998 (setq out (sort out (lambda (r1 r2)
2999 (< (or (and (atom r1) r1) (car r1))
3000 (or (and (atom r2) r2) (car r2))))))
3003 (if (atom (car ranges))
3005 (if (atom (car (cdr ranges)))
3006 (if (= (1+ (car ranges)) (car (cdr ranges)))
3008 (setcar ranges (cons (car ranges)
3009 (car (cdr ranges))))
3010 (setcdr ranges (cdr (cdr ranges)))))
3011 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3013 (setcar (car (cdr ranges)) (car ranges))
3014 (setcar ranges (car (cdr ranges)))
3015 (setcdr ranges (cdr (cdr ranges)))))))
3017 (if (atom (car (cdr ranges)))
3018 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3020 (setcdr (car ranges) (car (cdr ranges)))
3021 (setcdr ranges (cdr (cdr ranges)))))
3022 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3024 (setcdr (car ranges) (cdr (car (cdr ranges))))
3025 (setcdr ranges (cdr (cdr ranges))))))))
3026 (setq ranges (cdr ranges)))
3029 (defun gnus-remove-from-range (ranges list)
3030 "Return a list of ranges that has all articles from LIST removed from RANGES.
3031 Note: LIST has to be sorted over `<'."
3032 ;; !!! This function shouldn't look like this, but I've got a headache.
3033 (gnus-compress-sequence
3034 (gnus-sorted-complement
3035 (gnus-uncompress-range ranges) list)))
3037 (defun gnus-member-of-range (number ranges)
3038 (if (not (listp (cdr ranges)))
3039 (and (>= number (car ranges))
3040 (<= number (cdr ranges)))
3043 (if (numberp (car ranges))
3044 (>= number (car ranges))
3045 (>= number (car (car ranges))))
3047 (if (if (numberp (car ranges))
3048 (= number (car ranges))
3049 (and (>= number (car (car ranges)))
3050 (<= number (cdr (car ranges)))))
3051 (setq not-stop nil))
3052 (setq ranges (cdr ranges)))
3060 (defvar gnus-group-mode-map nil)
3061 (defvar gnus-group-group-map nil)
3062 (defvar gnus-group-mark-map nil)
3063 (defvar gnus-group-list-map nil)
3064 (defvar gnus-group-sub-map nil)
3065 (put 'gnus-group-mode 'mode-class 'special)
3067 (if gnus-group-mode-map
3069 (setq gnus-group-mode-map (make-keymap))
3070 (suppress-keymap gnus-group-mode-map)
3071 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3072 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3073 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3074 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3075 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3076 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3077 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3078 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3079 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3080 (define-key gnus-group-mode-map
3081 "\M-n" 'gnus-group-next-unread-group-same-level)
3082 (define-key gnus-group-mode-map
3083 "\M-p" 'gnus-group-prev-unread-group-same-level)
3084 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3085 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3086 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3087 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3088 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3089 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3090 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3091 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3092 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3093 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3094 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3095 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3096 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3097 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3098 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3099 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3100 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3101 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3102 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3103 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3104 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3105 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3106 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3107 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3108 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3109 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3110 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3111 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3112 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3113 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3114 (define-key gnus-group-mode-map "V" 'gnus-version)
3115 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3116 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3117 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3118 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3119 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3120 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3121 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3122 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3123 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3124 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3125 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3126 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3127 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3128 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3129 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3131 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3132 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3133 (define-prefix-command 'gnus-group-mark-map)
3134 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3135 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3136 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3137 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3139 (define-prefix-command 'gnus-group-group-map)
3140 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3141 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3142 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3143 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3144 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3145 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3146 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3147 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3148 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3149 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3150 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3151 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3152 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3153 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3154 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3155 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3156 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3157 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3159 (define-prefix-command 'gnus-group-list-map)
3160 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3161 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3162 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3163 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3164 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3165 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3166 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3167 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3168 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3170 (define-prefix-command 'gnus-group-sub-map)
3171 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3172 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3173 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3174 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3175 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3176 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3177 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3178 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3180 (defun gnus-group-mode ()
3181 "Major mode for reading news.
3183 All normal editing commands are switched off.
3184 \\<gnus-group-mode-map>
3185 The group buffer lists (some of) the groups available. For instance,
3186 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3187 lists all zombie groups.
3189 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3190 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3192 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3194 The following commands are available:
3196 \\{gnus-group-mode-map}"
3198 (if gnus-visual (gnus-group-make-menu-bar))
3199 (kill-all-local-variables)
3200 (setq mode-line-modified "-- ")
3201 (make-local-variable 'mode-line-format)
3202 (setq mode-line-format (copy-sequence mode-line-format))
3203 (and (equal (nth 3 mode-line-format) " ")
3204 (setcar (nthcdr 3 mode-line-format) ""))
3205 (setq major-mode 'gnus-group-mode)
3206 (setq mode-name "Group")
3207 (gnus-group-set-mode-line)
3208 (setq mode-line-process nil)
3209 (use-local-map gnus-group-mode-map)
3210 (buffer-disable-undo (current-buffer))
3211 (setq truncate-lines t)
3212 (setq buffer-read-only t)
3213 (run-hooks 'gnus-group-mode-hook))
3215 (defun gnus-mouse-pick-group (e)
3218 (gnus-group-read-group nil))
3220 ;; Look at LEVEL and find out what the level is really supposed to be.
3221 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3222 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3223 (defun gnus-group-default-level (&optional level number-or-nil)
3225 (gnus-group-use-permanent-levels
3226 (setq gnus-group-default-list-level
3227 (or level gnus-group-default-list-level))
3228 (or gnus-group-default-list-level gnus-level-subscribed))
3232 (or level gnus-group-default-list-level gnus-level-subscribed))))
3236 (defun gnus-no-server (&optional arg)
3238 If ARG is a positive number, Gnus will use that as the
3239 startup level. If ARG is nil, Gnus will be started at level 2.
3240 If ARG is non-nil and not a positive number, Gnus will
3241 prompt the user for the name of an NNTP server to use.
3242 As opposed to `gnus', this command will not connect to the local server."
3244 (setq gnus-group-use-permanent-levels t)
3245 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3248 (defun gnus (&optional arg dont-connect)
3250 If ARG is non-nil and a positive number, Gnus will use that as the
3251 startup level. If ARG is non-nil and not a positive number, Gnus will
3252 prompt the user for the name of an NNTP server to use."
3254 (if (get-buffer gnus-group-buffer)
3256 (switch-to-buffer gnus-group-buffer)
3257 (gnus-group-get-new-news))
3261 (nnheader-init-server-buffer)
3262 (gnus-read-init-file)
3264 (gnus-group-setup-buffer)
3265 (let ((buffer-read-only nil))
3267 (if (not gnus-inhibit-startup-message)
3269 (gnus-group-startup-message)
3272 (let ((level (and arg (numberp arg) (> arg 0) arg))
3278 (gnus-start-news-server (and arg (not level))))))
3279 (if (and (not dont-connect)
3282 (run-hooks 'gnus-startup-hook)
3283 ;; NNTP server is successfully open.
3285 ;; Find the current startup file name.
3286 (setq gnus-current-startup-file
3287 (gnus-make-newsrc-file gnus-startup-file))
3289 ;; Read the dribble file.
3290 (and gnus-use-dribble-file (gnus-dribble-read-file))
3292 (gnus-summary-make-display-table)
3293 (gnus-setup-news nil level)
3294 (gnus-group-list-groups level)
3295 (gnus-configure-windows 'group))))))
3297 (defun gnus-unload ()
3298 "Unload all Gnus features."
3300 (or (boundp 'load-history)
3301 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3302 (let ((history load-history)
3305 (and (string-match "^gnus" (car (car history)))
3306 (setq feature (cdr (assq 'provide (car history))))
3307 (unload-feature feature 'force))
3308 (setq history (cdr history)))))
3310 (defun gnus-group-startup-message (&optional x y)
3311 "Insert startup message in current buffer."
3312 ;; Insert the message.
3317 _ ___ __ ___ __ _ ___
3335 Gnus * A newsreader for Emacsen
3336 A Praxis release * larsi@ifi.uio.no
3339 ;; And then hack it.
3340 ;; 18 is the longest line.
3341 (indent-rigidly (point-min) (point-max)
3342 (/ (max (- (window-width) (or x 46)) 0) 2))
3343 (goto-char (point-min))
3344 (let* ((pheight (count-lines (point-min) (point-max)))
3345 (wheight (window-height))
3346 (rest (- wheight pheight)))
3347 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3352 (goto-char (point-min))
3353 (search-forward "Praxis")
3354 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3355 (goto-char (point-min)))
3357 (defun gnus-group-startup-message-old (&optional x y)
3358 "Insert startup message in current buffer."
3359 ;; Insert the message.
3375 ;; And then hack it.
3376 ;; 18 is the longest line.
3377 (indent-rigidly (point-min) (point-max)
3378 (/ (max (- (window-width) (or x 28)) 0) 2))
3379 (goto-char (point-min))
3380 ;; +4 is fuzzy factor.
3381 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3384 (goto-char (point-min))
3385 (search-forward "Praxis")
3386 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3387 (goto-char (point-min)))
3389 (defun gnus-group-setup-buffer ()
3390 (or (get-buffer gnus-group-buffer)
3392 (switch-to-buffer gnus-group-buffer)
3393 (gnus-add-current-to-buffer-list)
3395 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3397 (defun gnus-group-list-groups (&optional level unread)
3398 "List newsgroups with level LEVEL or lower that have unread articles.
3399 Default is all subscribed groups.
3400 If argument UNREAD is non-nil, groups with no unread articles are also
3402 (interactive (list (if current-prefix-arg
3403 (prefix-numeric-value current-prefix-arg)
3405 (gnus-group-default-level nil t)
3406 gnus-group-default-list-level
3407 gnus-level-subscribed))))
3409 (setq level (car gnus-group-list-mode)
3410 unread (cdr gnus-group-list-mode)))
3411 (setq level (gnus-group-default-level level))
3412 (gnus-group-setup-buffer) ;May call from out of group buffer
3413 (let ((case-fold-search nil)
3414 (group (gnus-group-group-name)))
3415 (funcall gnus-group-prepare-function level unread nil)
3416 (if (zerop (buffer-size))
3417 (gnus-message 5 gnus-no-groups-message)
3418 (goto-char (point-min))
3420 ;; Go to the first group with unread articles.
3421 (gnus-group-search-forward nil nil nil t)
3422 ;; Find the right group to put point on. If the current group
3423 ;; has disapeared in the new listing, try to find the next
3424 ;; one. If no next one can be found, just leave point at the
3425 ;; first newsgroup in the buffer.
3426 (if (not (gnus-goto-char
3427 (text-property-any (point-min) (point-max)
3428 'gnus-group (intern group))))
3429 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3431 (not (gnus-goto-char
3433 (point-min) (point-max) 'gnus-group
3434 (intern (car (car newsrc)))))))
3435 (setq newsrc (cdr newsrc)))
3436 (or newsrc (progn (goto-char (point-max))
3437 (forward-line -1))))))
3438 ;; Adjust cursor point.
3439 (gnus-group-position-cursor))))
3441 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3442 "List all newsgroups with unread articles of level LEVEL or lower.
3443 If ALL is non-nil, list groups that have no unread articles.
3444 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3445 If REGEXP, only list groups matching REGEXP."
3446 (set-buffer gnus-group-buffer)
3447 (let ((buffer-read-only nil)
3448 (newsrc (cdr gnus-newsrc-alist))
3449 (lowest (or lowest 1))
3450 info clevel unread group)
3452 (if (< lowest gnus-level-zombie)
3453 ;; List living groups.
3455 (setq info (car newsrc)
3458 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3459 (and unread ; This group might be bogus
3461 (string-match regexp group))
3462 (<= (setq clevel (car (cdr info))) level)
3464 (or all ; We list all groups?
3465 (eq unread t) ; We list unactivated groups
3466 (> unread 0) ; We list groups with unread articles
3467 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3468 (gnus-group-insert-group-line
3469 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3471 ;; List dead groups.
3472 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3473 (gnus-group-prepare-flat-list-dead
3474 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3475 gnus-level-zombie ?Z
3477 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3478 (gnus-group-prepare-flat-list-dead
3479 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3480 gnus-level-killed ?K regexp))
3482 (gnus-group-set-mode-line)
3483 (setq gnus-group-list-mode (cons level all))
3484 (run-hooks 'gnus-group-prepare-hook)))
3486 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3487 ;; List zombies and killed lists somehwat faster, which was
3488 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3489 ;; this by ignoring the group format specification altogether.
3492 (setq group (car groups)
3493 groups (cdr groups))
3494 (if (or (not regexp)
3495 (string-match regexp group))
3498 (insert (format " %c *: %s\n" mark group))
3499 (add-text-properties
3501 (list 'gnus-group (intern group)
3503 'gnus-level level)))))))
3505 (defun gnus-group-real-name (group)
3506 "Find the real name of a foreign newsgroup."
3507 (if (string-match ":[^:]+$" group)
3508 (substring group (1+ (match-beginning 0)))
3511 (defun gnus-group-prefixed-name (group method)
3512 "Return the whole name from GROUP and METHOD."
3513 (and (stringp method) (setq method (gnus-server-to-method method)))
3514 (concat (format "%s" (car method))
3516 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3517 (not (string= (nth 1 method) "")))
3518 (concat "+" (nth 1 method)))
3521 (defun gnus-group-real-prefix (group)
3522 "Return the prefix of the current group name."
3523 (if (string-match "^[^:]+:" group)
3524 (substring group 0 (match-end 0))
3527 (defun gnus-group-method-name (group)
3528 "Return the method used for selecting GROUP."
3529 (let ((prefix (gnus-group-real-prefix group)))
3530 (if (equal prefix "")
3532 (if (string-match "^[^\\+]+\\+" prefix)
3533 (list (intern (substring prefix 0 (1- (match-end 0))))
3534 (substring prefix (match-end 0) (1- (length prefix))))
3535 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3537 (defun gnus-group-foreign-p (group)
3538 "Return nil if GROUP is native, non-nil if it is foreign."
3539 (string-match ":" group))
3541 (defun gnus-group-set-info (info &optional method-only-group part)
3542 (let* ((entry (gnus-gethash
3543 (or method-only-group (car info)) gnus-newsrc-hashtb))
3545 (info (if method-only-group (nth 2 entry) info)))
3546 (if (not method-only-group)
3549 (error "Trying to change non-existent group %s" method-only-group))
3550 ;; We have recevied parts of the actual group info - either the
3551 ;; select method or the group parameters. We first check
3552 ;; whether we have to extend the info, and if so, do that.
3553 (let ((len (length info))
3554 (total (if (eq part 'method) 5 6)))
3556 (setcdr (nthcdr (1- len) info)
3557 (make-list (- total len) nil)))
3558 ;; Then we enter the new info.
3559 (setcar (nthcdr (1- total) info) part-info)))
3560 ;; We uncompress some lists of marked articles.
3562 (if (not (setq marked (nth 3 info)))
3565 (or (eq 'score (car (car marked)))
3566 (eq 'bookmark (car (car marked)))
3567 (eq 'killed (car (car marked)))
3568 (setcdr (car marked)
3569 (gnus-uncompress-range (cdr (car marked)))))
3570 (setq marked (cdr marked)))))
3573 ;; This is a new group, so we just create it.
3575 (set-buffer gnus-group-buffer)
3577 ;; It's a foreign group...
3578 (gnus-group-make-group
3579 (gnus-group-real-name (car info))
3580 (prin1-to-string (car (nth 4 info)))
3581 (nth 1 (nth 4 info)))
3582 ;; It's a native group.
3583 (gnus-group-make-group
3585 (prin1-to-string (car gnus-select-method))
3586 (nth 1 gnus-select-method)))
3587 (gnus-message 6 "Note: New group created")
3589 (gnus-gethash (gnus-group-prefixed-name
3590 (gnus-group-real-name (car info))
3591 (or (nth 4 info) gnus-select-method))
3592 gnus-newsrc-hashtb))))
3593 ;; Whether it was a new group or not, we now have the entry, so we
3594 ;; can do the update.
3597 (setcar (nthcdr 2 entry) info)
3598 (if (and (not (eq (car entry) t))
3599 (gnus-gethash (car info) gnus-active-hashtb))
3600 (let ((marked (nth 3 info)))
3602 (max 0 (- (length (gnus-list-of-unread-articles
3604 (length (cdr (assq 'tick marked)))
3605 (length (cdr (assq 'dormant marked)))))))))
3606 (error "No such group: %s" (car info)))))
3608 (defun gnus-group-set-method-info (group select-method)
3609 (gnus-group-set-info select-method group 'method))
3611 (defun gnus-group-set-params-info (group params)
3612 (gnus-group-set-info params group 'params))
3614 (defun gnus-group-update-group-line ()
3615 "This function updates the current line in the newsgroup buffer and
3616 moves the point to the colon."
3617 (let* ((buffer-read-only nil)
3618 (group (gnus-group-group-name))
3619 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3622 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3625 (delete-region (point) (progn (forward-line 1) (point)))
3626 (gnus-group-insert-group-line-info group)
3628 (gnus-group-position-cursor)))
3630 (defun gnus-group-insert-group-line-info (group)
3631 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3635 (setq info (nth 2 entry))
3636 (gnus-group-insert-group-line
3637 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3638 (setq active (gnus-gethash group gnus-active-hashtb))
3639 (gnus-group-insert-group-line
3641 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3642 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3644 (defun gnus-group-insert-group-line (gformat group level marked number method)
3645 (let* ((gformat (or gformat gnus-group-line-format-spec))
3646 (active (gnus-gethash group gnus-active-hashtb))
3647 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3648 (number-of-dormant (length (cdr (assq 'dormant marked))))
3649 (number-of-ticked (length (cdr (assq 'tick marked))))
3650 (number-of-ticked-and-dormant
3651 (+ number-of-ticked number-of-dormant))
3652 (number-of-unread-unticked
3653 (if (numberp number) (int-to-string (max 0 number))
3656 (if (numberp number)
3657 (max 0 (- number-total number))
3659 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3660 ((<= level gnus-level-unsubscribed) ?U)
3661 ((= level gnus-level-zombie) ?Z)
3663 (qualified-group (gnus-group-real-name group))
3664 (newsgroup-description
3665 (if gnus-description-hashtb
3666 (or (gnus-gethash group gnus-description-hashtb) "")
3668 (moderated (if (member group gnus-moderated-list) ?m ? ))
3669 (moderated-string (if (eq moderated ?m) "(m)" ""))
3670 (method (gnus-server-get-method group method))
3671 (news-server (or (car (cdr method)) ""))
3672 (news-method (or (car method) ""))
3674 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3678 (> number-of-ticked 0))
3680 (number (if (eq number t) "*" (+ number number-of-dormant
3682 (process-marked (if (member group gnus-group-marked)
3683 gnus-process-mark ? ))
3684 (buffer-read-only nil)
3685 header ; passed as parameter to user-funcs.
3690 (insert (eval gformat))
3692 (add-text-properties
3693 b (1+ b) (list 'gnus-group (intern group)
3694 'gnus-unread (if (numberp number)
3695 (string-to-int number-of-unread-unticked)
3698 'gnus-level level))))
3700 (defun gnus-group-update-group (group &optional visible-only)
3701 "Update newsgroup info of GROUP.
3702 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3704 (set-buffer gnus-group-buffer)
3705 (let ((buffer-read-only nil)
3707 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3710 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3712 ;; Buffer may be narrowed.
3715 ;; Search a line to modify. If the buffer is large, the search
3716 ;; takes long time. In most cases, current point is on the line
3717 ;; we are looking for. So, first of all, check current line.
3720 (eq (get-text-property (point) 'gnus-group)
3725 (point-min) (point-max) 'gnus-group (intern group)))))
3726 ;; GROUP is listed in current buffer. So, delete old line.
3730 (delete-region (point) (progn (forward-line 1) (point))))
3731 ;; No such line in the buffer, find out where it's supposed to
3732 ;; go, and insert it there (or at the end of the buffer).
3733 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3736 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3742 (point-min) (point-max)
3743 'gnus-group (intern (car (car entry)))))))
3744 (setq entry (cdr entry)))
3745 (or entry (goto-char (point-max)))))))
3746 (if (or visible (not visible-only))
3747 (gnus-group-insert-group-line-info group))
3748 (gnus-group-set-mode-line))))
3750 (defun gnus-group-set-mode-line ()
3751 (if (memq 'group gnus-updated-mode-lines)
3752 (let* ((gformat (or gnus-group-mode-line-format-spec
3753 (setq gnus-group-mode-line-format-spec
3755 gnus-group-mode-line-format
3756 gnus-group-mode-line-format-alist))))
3757 (news-server (car (cdr gnus-select-method)))
3758 (news-method (car gnus-select-method))
3760 (mode-string (eval gformat)))
3761 (setq mode-string (eval gformat))
3762 (if (> (length mode-string) max-len)
3763 (setq mode-string (substring mode-string 0 (- max-len 4))))
3764 (setq mode-line-buffer-identification mode-string)
3765 (set-buffer-modified-p t))))
3767 (defun gnus-group-group-name ()
3768 "Get the name of the newsgroup on the current line."
3769 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3770 (and group (symbol-name group))))
3772 (defun gnus-group-group-level ()
3773 "Get the level of the newsgroup on the current line."
3774 (get-text-property (gnus-point-at-bol) 'gnus-level))
3776 (defun gnus-group-group-unread ()
3777 "Get the number of unread articles of the newsgroup on the current line."
3778 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3780 (defun gnus-group-search-forward (&optional backward all level first-too)
3781 "Find the next newsgroup with unread articles.
3782 If BACKWARD is non-nil, find the previous newsgroup instead.
3783 If ALL is non-nil, just find any newsgroup.
3784 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3786 If FIRST-TOO, the current line is also eligible as a target."
3787 (let ((way (if backward -1 1))
3788 (low gnus-level-killed)
3791 (if (and backward (progn (beginning-of-line)) (bobp))
3793 (or first-too (forward-line way))
3801 (get-text-property (point) 'gnus-unread)))
3802 (or (eq unread t) (and unread (> unread 0))))
3803 (setq lev (get-text-property (point)
3805 (<= lev gnus-level-subscribed)))
3807 (and (setq lev (get-text-property (point)
3816 (zerop (forward-line way)))))
3818 (progn (gnus-group-position-cursor) t)
3819 (goto-char (or pos beg))
3822 ;;; Gnus group mode commands
3826 (defun gnus-group-mark-group (n &optional unmark no-advance)
3827 "Mark the current group."
3829 (let ((buffer-read-only nil)
3833 (setq group (gnus-group-group-name))
3837 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3842 (setq gnus-group-marked (delete group gnus-group-marked)))
3844 (setq gnus-group-marked
3845 (cons group (delete group gnus-group-marked))))
3847 (or no-advance (zerop (gnus-group-next-group 1))))
3849 (gnus-summary-position-cursor)
3852 (defun gnus-group-unmark-group (n)
3853 "Remove the mark from the current group."
3855 (gnus-group-mark-group n 'unmark))
3857 (defun gnus-group-mark-region (unmark beg end)
3858 "Mark all groups between point and mark.
3859 If UNMARK, remove the mark instead."
3860 (interactive "P\nr")
3861 (let ((num (count-lines beg end)))
3864 (- num (gnus-group-mark-group num unmark)))))
3866 (defun gnus-group-remove-mark (group)
3867 (and (gnus-group-goto-group group)
3869 (gnus-group-mark-group 1 'unmark t))))
3871 ;; Return a list of groups to work on. Take into consideration N (the
3872 ;; prefix) and the list of marked groups.
3873 (defun gnus-group-process-prefix (n)
3875 (setq n (prefix-numeric-value n))
3876 ;; There is a prefix, so we return a list of the N next
3878 (let ((way (if (< n 0) -1 1))
3883 (setq group (gnus-group-group-name)))
3884 (setq groups (cons group groups))
3886 (forward-line way)))
3889 ;; No prefix, but a list of marked articles.
3890 (reverse gnus-group-marked))
3892 ;; Neither marked articles or a prefix, so we return the
3894 (let ((group (gnus-group-group-name)))
3895 (and group (list group))))))
3897 ;; Selecting groups.
3899 (defun gnus-group-read-group (&optional all no-article group)
3900 "Read news in this newsgroup.
3901 If the prefix argument ALL is non-nil, already read articles become
3902 readable. If the optional argument NO-ARTICLE is non-nil, no article
3903 will be auto-selected upon group entry."
3905 (let ((group (or group (gnus-group-group-name)))
3906 number active marked entry)
3907 (or group (error "No group on current line"))
3909 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3910 ;; This group might be a dead group. In that case we have to get
3911 ;; the number of unread articles from `gnus-active-hashtb'.
3913 (setq number (car entry))
3914 (if (setq active (gnus-gethash group gnus-active-hashtb))
3915 (setq number (- (1+ (cdr active)) (car active)))))
3916 (gnus-summary-read-group
3917 group (or all (and (numberp number)
3918 (zerop (+ number (length (cdr (assq 'tick marked)))
3919 (length (cdr (assq 'dormant marked)))))))
3922 (defun gnus-group-select-group (&optional all)
3923 "Select this newsgroup.
3924 No article is selected automatically.
3925 If argument ALL is non-nil, already read articles become readable."
3927 (gnus-group-read-group all t))
3929 (defun gnus-group-select-group-all ()
3930 "Select the current group and display all articles in it."
3932 (gnus-group-select-group 'all))
3934 ;; Enter a group that is not in the group buffer. Non-nil is returned
3935 ;; if selection was successful.
3936 (defun gnus-group-read-ephemeral-group
3937 (group method &optional activate quit-config)
3938 (let ((group (if (gnus-group-foreign-p group) group
3939 (gnus-group-prefixed-name group method))))
3942 (list t nil (list group gnus-level-default-subscribed nil nil
3946 (if quit-config quit-config
3947 (cons (current-buffer) 'summary)))))))
3949 (set-buffer gnus-group-buffer)
3950 (or (gnus-check-server method)
3951 (error "Unable to contact server: %s" (gnus-status-message method)))
3952 (if activate (or (gnus-request-group group)
3953 (error "Couldn't request group")))
3955 (gnus-group-read-group t t group)
3958 (not (equal major-mode 'gnus-group-mode))))
3960 (defun gnus-group-jump-to-group (group)
3961 "Jump to newsgroup GROUP."
3963 (list (completing-read
3964 "Group: " gnus-active-hashtb nil
3965 (memq gnus-select-method gnus-have-read-active-file))))
3967 (if (equal group "")
3968 (error "Empty group name"))
3970 (let ((b (text-property-any
3971 (point-min) (point-max) 'gnus-group (intern group))))
3973 ;; Either go to the line in the group buffer...
3975 ;; ... or insert the line.
3977 (gnus-gethash group gnus-active-hashtb)
3978 (gnus-activate-group group)
3979 (error "%s error: %s" group (gnus-status-message group)))
3981 (gnus-group-update-group group)
3982 (goto-char (text-property-any
3983 (point-min) (point-max) 'gnus-group (intern group)))))
3984 ;; Adjust cursor point.
3985 (gnus-group-position-cursor))
3987 (defun gnus-group-goto-group (group)
3988 "Goto to newsgroup GROUP."
3989 (let ((b (text-property-any (point-min) (point-max)
3990 'gnus-group (intern group))))
3991 (and b (goto-char b))))
3993 (defun gnus-group-next-group (n)
3994 "Go to next N'th newsgroup.
3995 If N is negative, search backward instead.
3996 Returns the difference between N and the number of skips actually
3999 (gnus-group-next-unread-group n t))
4001 (defun gnus-group-next-unread-group (n &optional all level)
4002 "Go to next N'th unread newsgroup.
4003 If N is negative, search backward instead.
4004 If ALL is non-nil, choose any newsgroup, unread or not.
4005 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4006 such group can be found, the next group with a level higher than
4008 Returns the difference between N and the number of skips actually
4011 (let ((backward (< n 0))
4014 (gnus-group-search-forward
4015 backward (or (not gnus-group-goto-unread) all) level))
4017 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4018 (if level " on this level or higher" "")))
4021 (defun gnus-group-prev-group (n)
4022 "Go to previous N'th newsgroup.
4023 Returns the difference between N and the number of skips actually
4026 (gnus-group-next-unread-group (- n) t))
4028 (defun gnus-group-prev-unread-group (n)
4029 "Go to previous N'th unread newsgroup.
4030 Returns the difference between N and the number of skips actually
4033 (gnus-group-next-unread-group (- n)))
4035 (defun gnus-group-next-unread-group-same-level (n)
4036 "Go to next N'th unread newsgroup on the same level.
4037 If N is negative, search backward instead.
4038 Returns the difference between N and the number of skips actually
4041 (gnus-group-next-unread-group n t (gnus-group-group-level))
4042 (gnus-group-position-cursor))
4044 (defun gnus-group-prev-unread-group-same-level (n)
4045 "Go to next N'th unread newsgroup on the same level.
4046 Returns the difference between N and the number of skips actually
4049 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4050 (gnus-group-position-cursor))
4052 (defun gnus-group-best-unread-group (&optional exclude-group)
4053 "Go to the group with the highest level.
4054 If EXCLUDE-GROUP, do not go to that group."
4056 (goto-char (point-min))
4059 (while (setq unread (get-text-property (point) 'gnus-unread))
4060 (if (and (numberp unread) (> unread 0))
4062 (if (and (< (get-text-property (point) 'gnus-level) best)
4063 (or (not exclude-group)
4064 (not (equal exclude-group (gnus-group-group-name)))))
4066 (setq best (get-text-property (point) 'gnus-level))
4067 (setq best-point (point))))))
4069 (if best-point (goto-char best-point))
4070 (gnus-summary-position-cursor)
4071 (and best-point (gnus-group-group-name))))
4073 (defun gnus-group-first-unread-group ()
4074 "Go to the first group with unread articles."
4077 (let ((opoint (point))
4079 (goto-char (point-min))
4080 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4081 (not (zerop unread)) ; Has unread articles.
4082 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4085 nil)) ; Not success.
4086 (gnus-group-position-cursor)))
4088 (defun gnus-group-enter-server-mode ()
4089 "Jump to the server buffer."
4091 (gnus-server-setup-buffer)
4092 (gnus-configure-windows 'server)
4093 (gnus-server-prepare))
4095 (defun gnus-group-make-group (name method &optional address)
4096 "Add a new newsgroup.
4097 The user will be prompted for a NAME, for a select METHOD, and an
4101 (read-string "Group name: ")
4104 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4106 (if (assoc method gnus-valid-select-methods)
4108 (if (memq 'prompt-address
4109 (assoc method gnus-valid-select-methods))
4110 (read-string "Address: ")
4112 (list method nil)))))
4114 (let* ((meth (if address (list (intern method) address) method))
4115 (nname (gnus-group-prefixed-name name meth))
4117 (and (gnus-gethash nname gnus-newsrc-hashtb)
4118 (error "Group %s already exists" nname))
4119 (gnus-group-change-level
4120 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4121 gnus-level-default-subscribed gnus-level-killed
4122 (and (gnus-group-group-name)
4123 (gnus-gethash (gnus-group-group-name)
4124 gnus-newsrc-hashtb))
4126 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4128 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
4129 (gnus-group-insert-group-line-info nname)
4131 (if (assoc method gnus-valid-select-methods)
4132 (require (intern method)))
4133 (and (gnus-check-backend-function 'request-create-group nname)
4134 (gnus-request-create-group nname))))
4136 (defun gnus-group-edit-group (group &optional part)
4137 "Edit the group on the current line."
4138 (interactive (list (gnus-group-group-name)))
4139 (let ((done-func '(lambda ()
4140 "Exit editing mode and update the information."
4142 (gnus-group-edit-group-done 'part 'group)))
4143 (part (or part 'info))
4144 (winconf (current-window-configuration))
4146 (or group (error "No group on current line"))
4147 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4148 (error "Killed group; can't be edited"))
4149 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4150 (gnus-configure-windows 'edit-group)
4151 (gnus-add-current-to-buffer-list)
4153 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4154 (use-local-map (copy-keymap emacs-lisp-mode-map))
4155 (local-set-key "\C-c\C-c" done-func)
4156 (make-local-variable 'gnus-prev-winconf)
4157 (setq gnus-prev-winconf winconf)
4158 ;; We modify the func to let it know what part it is editing.
4159 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4160 (setcar (cdr (cdr (nth 4 done-func))) group)
4165 ";; Type `C-c C-c' after editing the select method.\n\n")
4167 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4169 ";; Type `C-c C-c' after editing the group info.\n\n")))
4170 (let ((cinfo (gnus-copy-sequence info))
4172 (if (not (setq marked (nth 3 cinfo)))
4175 (or (eq 'score (car (car marked)))
4176 (eq 'bookmark (car (car marked)))
4177 (eq 'killed (car (car marked)))
4178 (not (numberp (car (cdr (car marked)))))
4179 (setcdr (car marked)
4180 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4181 (setq marked (cdr marked))))
4184 (cond ((eq part 'method)
4185 (or (nth 4 info) "native"))
4192 (defun gnus-group-edit-group-method (group)
4193 "Edit the select method of GROUP."
4194 (interactive (list (gnus-group-group-name)))
4195 (gnus-group-edit-group group 'method))
4197 (defun gnus-group-edit-group-parameters (group)
4198 "Edit the group parameters of GROUP."
4199 (interactive (list (gnus-group-group-name)))
4200 (gnus-group-edit-group group 'params))
4202 (defun gnus-group-edit-group-done (part group)
4203 "Get info from buffer, update variables and jump to the group buffer."
4204 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4205 (goto-char (point-min))
4206 (let ((form (read (current-buffer)))
4207 (winconf gnus-prev-winconf))
4209 (gnus-group-set-info form)
4210 (gnus-group-set-info form group part))
4211 (kill-buffer (current-buffer))
4212 (and winconf (set-window-configuration winconf))
4213 (set-buffer gnus-group-buffer)
4214 (gnus-group-update-group (gnus-group-group-name))
4215 (gnus-group-position-cursor)))
4217 (defun gnus-group-make-help-group ()
4218 "Create the Gnus documentation group."
4220 (let ((path load-path)
4222 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4223 "gnus-help" '(nndoc "gnus-help")))
4225 (error "Documentation group already exists"))
4227 (not (file-exists-p (concat (file-name-as-directory (car path))
4229 (setq path (cdr path)))
4230 (or path (error "Couldn't find doc group"))
4231 (gnus-group-make-group
4232 (gnus-group-real-name name)
4234 (list 'nndoc-address
4235 (concat (file-name-as-directory (car path)) "doc.txt"))
4236 (list 'nndoc-article-type 'mbox))))
4237 (gnus-group-position-cursor))
4239 (defun gnus-group-make-doc-group (file type)
4240 "Create a group that uses a single file as the source."
4242 (list (read-file-name "File name: ")
4246 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4247 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4248 ((= char ?b) 'babyl)
4249 ((= char ?d) 'digest)
4250 (t (setq err (format "%c unknown. " char))
4253 (let* ((file (expand-file-name file))
4254 (name (gnus-generate-new-group-name
4255 (gnus-group-prefixed-name
4256 (file-name-nondirectory file) '(nndoc "")))))
4257 (gnus-group-make-group
4258 (gnus-group-real-name name)
4260 (list 'nndoc-address file)
4261 (list 'nndoc-article-type type)))))
4263 (defun gnus-group-make-archive-group (&optional all)
4264 "Create the (ding) Gnus archive group of the most recent articles.
4265 Given a prefix, create a full group."
4267 (let ((group (gnus-group-prefixed-name
4268 (if all "ding.archives" "ding.recent") '(nndir ""))))
4269 (and (gnus-gethash group gnus-newsrc-hashtb)
4270 (error "Archive group already exists"))
4271 (gnus-group-make-group
4272 (gnus-group-real-name group)
4274 (if all gnus-group-archive-directory
4275 gnus-group-recent-archive-directory)))
4276 (gnus-group-position-cursor))
4278 (defun gnus-group-make-directory-group (dir)
4279 "Create an nndir group.
4280 The user will be prompted for a directory. The contents of this
4281 directory will be used as a newsgroup. The directory should contain
4282 mail messages or news articles in files that have numeric names."
4284 (list (read-file-name "Create group from directory: ")))
4285 (or (file-exists-p dir) (error "No such directory"))
4286 (or (file-directory-p dir) (error "Not a directory"))
4287 (gnus-group-make-group dir "nndir" dir)
4288 (gnus-group-position-cursor))
4290 (defun gnus-group-make-kiboze-group (group address scores)
4291 "Create an nnkiboze group.
4292 The user will be prompted for a name, a regexp to match groups, and
4293 score file entries for articles to include in the group."
4296 (read-string "nnkiboze group name: ")
4297 (read-string "Source groups (regexp): ")
4298 (let ((headers (mapcar (lambda (group) (list group))
4299 '("subject" "from" "number" "date" "message-id"
4300 "references" "chars" "lines" "xref")))
4301 scores header regexp regexps)
4302 (while (not (equal "" (setq header (completing-read
4303 "Match on header: " headers nil t))))
4305 (while (not (equal "" (setq regexp (read-string
4306 (format "Match on %s (string): "
4308 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4309 (setq scores (cons (cons header regexps) scores)))
4311 (gnus-group-make-group group "nnkiboze" address)
4313 (gnus-set-work-buffer)
4314 (let (emacs-lisp-mode-hook)
4315 (pp scores (current-buffer)))
4316 (write-region (point-min) (point-max)
4317 (concat (or gnus-kill-files-directory "~/News")
4318 "nnkiboze:" group "." gnus-score-file-suffix)))
4319 (gnus-group-position-cursor))
4321 (defun gnus-group-add-to-virtual (n vgroup)
4322 "Add the current group to a virtual group."
4324 (list current-prefix-arg
4325 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4327 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4328 (error "%s is not an nnvirtual group" vgroup))
4329 (let* ((groups (gnus-group-process-prefix n))
4330 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4331 (setcar (cdr method)
4333 (nth 1 method) "\\|"
4336 (gnus-group-remove-mark s)
4337 (concat "\\(^" (regexp-quote s) "$\\)"))
4339 (gnus-group-position-cursor))
4341 (defun gnus-group-make-empty-virtual (group)
4342 "Create a new, fresh, empty virtual group."
4343 (interactive "sCreate new, empty virtual group: ")
4344 (let* ((method (list 'nnvirtual "^$"))
4345 (pgroup (gnus-group-prefixed-name group method)))
4346 ;; Check whether it exists already.
4347 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4348 (error "Group %s already exists." pgroup))
4349 ;; Subscribe the new group after the group on the current line.
4350 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4351 (gnus-group-update-group pgroup)
4353 (gnus-group-position-cursor)))
4355 (defun gnus-group-enter-directory (dir)
4356 "Enter an ephemeral nneething group."
4357 (interactive "DDirectory to read: ")
4358 (let* ((method (list 'nneething dir))
4359 (leaf (gnus-group-prefixed-name
4360 (file-name-nondirectory (directory-file-name dir))
4362 (name (gnus-generate-new-group-name leaf)))
4363 (let ((nneething-read-only t))
4364 (or (gnus-group-read-ephemeral-group
4366 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4368 (error "Couldn't enter %s" dir)))))
4370 ;; Group sorting commands
4371 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4373 (defun gnus-group-sort-groups ()
4374 "Sort the group buffer using `gnus-group-sort-function'."
4376 (setq gnus-newsrc-alist
4377 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4378 (gnus-make-hashtable-from-newsrc-alist)
4379 (gnus-group-list-groups))
4381 (defun gnus-group-sort-by-alphabet (info1 info2)
4382 (string< (car info1) (car info2)))
4384 (defun gnus-group-sort-by-unread (info1 info2)
4385 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4386 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4387 (< (or (and (numberp n1) n1) 0)
4388 (or (and (numberp n2) n2) 0))))
4390 (defun gnus-group-sort-by-level (info1 info2)
4391 (< (nth 1 info1) (nth 1 info2)))
4393 ;; Group catching up.
4395 (defun gnus-group-catchup-current (&optional n all)
4396 "Mark all articles not marked as unread in current newsgroup as read.
4397 If prefix argument N is numeric, the ARG next newsgroups will be
4398 caught up. If ALL is non-nil, marked articles will also be marked as
4399 read. Cross references (Xref: header) of articles are ignored.
4400 The difference between N and actual number of newsgroups that were
4401 caught up is returned."
4403 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4407 "Do you really want to mark all articles as read? "
4408 "Mark all unread articles as read? "))))
4410 (let ((groups (gnus-group-process-prefix n))
4413 ;; Virtual groups have to be given special treatment.
4414 (let ((method (gnus-find-method-for-group (car groups))))
4415 (if (eq 'nnvirtual (car method))
4416 (nnvirtual-catchup-group
4417 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4418 (gnus-group-remove-mark (car groups))
4420 (gnus-group-goto-group (car groups))
4421 (gnus-group-catchup (car groups) all))
4422 (gnus-group-update-group-line)
4423 (setq ret (1+ ret)))
4424 (setq groups (cdr groups)))
4425 (gnus-group-next-unread-group 1)
4428 (defun gnus-group-catchup-current-all (&optional n)
4429 "Mark all articles in current newsgroup as read.
4430 Cross references (Xref: header) of articles are ignored."
4432 (gnus-group-catchup-current n 'all))
4434 (defun gnus-group-catchup (group &optional all)
4435 "Mark all articles in GROUP as read.
4436 If ALL is non-nil, all articles are marked as read.
4437 The return value is the number of articles that were marked as read,
4438 or nil if no action could be taken."
4439 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4441 (marked (nth 3 (nth 2 entry))))
4442 (if (not (numberp (car entry)))
4443 (gnus-message 1 "Can't catch up; non-active group")
4444 ;; Do the updating only if the newsgroup isn't killed.
4447 (gnus-update-read-articles
4448 group (and (not all) (append (cdr (assq 'tick marked))
4449 (cdr (assq 'dormant marked))))
4450 nil (and (not all) (cdr (assq 'tick marked))))
4452 (setq marked (nth 3 (nth 2 entry)))
4453 (setcar (nthcdr 3 (nth 2 entry))
4454 (delq (assq 'dormant marked)
4455 (nth 3 (nth 2 entry)))))))
4458 (defun gnus-group-expire-articles (&optional n)
4459 "Expire all expirable articles in the current newsgroup."
4461 (let ((groups (gnus-group-process-prefix n))
4463 (or groups (error "No groups to expire"))
4465 (setq group (car groups)
4466 groups (cdr groups))
4467 (gnus-group-remove-mark group)
4468 (if (not (gnus-check-backend-function 'request-expire-articles group))
4470 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4471 (expirable (if (memq 'total-expire (nth 5 info))
4472 (cons nil (gnus-list-of-read-articles group))
4473 (assq 'expire (nth 3 info)))))
4476 (gnus-request-expire-articles
4477 (cdr expirable) group))))))))
4479 (defun gnus-group-expire-all-groups ()
4480 "Expire all expirable articles in all newsgroups."
4483 (gnus-message 5 "Expiring...")
4484 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4485 (cdr gnus-newsrc-alist))))
4486 (gnus-group-expire-articles nil)))
4487 (gnus-group-position-cursor)
4488 (gnus-message 5 "Expiring...done"))
4490 (defun gnus-group-set-current-level (n level)
4491 "Set the level of the next N groups to LEVEL."
4492 (interactive "P\nnLevel: ")
4493 (or (and (>= level 1) (<= level gnus-level-killed))
4494 (error "Illegal level: %d" level))
4495 (let ((groups (gnus-group-process-prefix n))
4498 (setq group (car groups)
4499 groups (cdr groups))
4500 (gnus-group-remove-mark group)
4501 (gnus-message 6 "Changed level of %s from %d to %d"
4502 group (gnus-group-group-level) level)
4503 (gnus-group-change-level group level
4504 (gnus-group-group-level))
4505 (gnus-group-update-group-line)))
4506 (gnus-group-position-cursor))
4508 (defun gnus-group-unsubscribe-current-group (&optional n)
4509 "Toggle subscription of the current group.
4510 If given numerical prefix, toggle the N next groups."
4512 (let ((groups (gnus-group-process-prefix n))
4515 (setq group (car groups)
4516 groups (cdr groups))
4517 (gnus-group-remove-mark group)
4518 (gnus-group-unsubscribe-group
4519 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4520 gnus-level-default-unsubscribed
4521 gnus-level-default-subscribed))
4522 (gnus-group-update-group-line))
4523 (gnus-group-next-group 1)))
4525 (defun gnus-group-unsubscribe-group (group &optional level)
4526 "Toggle subscribe from/to unsubscribe GROUP.
4527 New newsgroup is added to .newsrc automatically."
4529 (list (completing-read
4530 "Group: " gnus-active-hashtb nil
4531 (memq gnus-select-method gnus-have-read-active-file))))
4532 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4534 ((string-match "^[ \t]$" group)
4535 (error "Empty group name"))
4537 ;; Toggle subscription flag.
4538 (gnus-group-change-level
4539 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4540 gnus-level-subscribed)
4541 (1+ gnus-level-subscribed)
4542 gnus-level-default-subscribed)))
4543 (gnus-group-update-group group))
4544 ((and (stringp group)
4545 (or (not (memq gnus-select-method gnus-have-read-active-file))
4546 (gnus-gethash group gnus-active-hashtb)))
4547 ;; Add new newsgroup.
4548 (gnus-group-change-level
4550 (if level level gnus-level-default-subscribed)
4551 (or (and (member group gnus-zombie-list)
4554 (and (gnus-group-group-name)
4555 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4556 (gnus-group-update-group group))
4557 (t (error "No such newsgroup: %s" group)))
4558 (gnus-group-position-cursor)))
4560 (defun gnus-group-transpose-groups (n)
4561 "Move the current newsgroup up N places.
4562 If given a negative prefix, move down instead. The difference between
4563 N and the number of steps taken is returned."
4565 (or (gnus-group-group-name)
4566 (error "No group on current line"))
4567 (gnus-group-kill-group 1)
4569 (forward-line (- n))
4570 (gnus-group-yank-group)
4571 (gnus-group-position-cursor)))
4573 (defun gnus-group-kill-all-zombies ()
4574 "Kill all zombie newsgroups."
4576 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4577 (setq gnus-zombie-list nil)
4578 (gnus-group-list-groups))
4580 (defun gnus-group-kill-region (begin end)
4581 "Kill newsgroups in current region (excluding current point).
4582 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4597 (beginning-of-line) ;Important when LINES < 1
4598 (gnus-group-kill-group lines)))
4600 (defun gnus-group-kill-group (&optional n)
4601 "The the next N groups.
4602 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4603 However, only groups that were alive can be yanked; already killed
4604 groups or zombie groups can't be yanked.
4605 The return value is the name of the (last) group that was killed."
4607 (let ((buffer-read-only nil)
4608 (groups (gnus-group-process-prefix n))
4611 (setq group (car groups)
4612 groups (cdr groups))
4613 (gnus-group-remove-mark group)
4614 (setq level (gnus-group-group-level))
4616 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4617 (setq gnus-list-of-killed-groups
4618 (cons (cons (car entry) (nth 2 entry))
4619 gnus-list-of-killed-groups)))
4620 (gnus-group-change-level
4621 (if entry entry group) gnus-level-killed (if entry nil level)))
4622 (gnus-group-position-cursor)
4625 (defun gnus-group-yank-group (&optional arg)
4626 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4627 inserting it before the current newsgroup. The numeric ARG specifies
4628 how many newsgroups are to be yanked. The name of the (last)
4629 newsgroup yanked is returned."
4631 (if (not arg) (setq arg 1))
4632 (let (info group prev)
4633 (while (>= (setq arg (1- arg)) 0)
4634 (if (not (setq info (car gnus-list-of-killed-groups)))
4635 (error "No more newsgroups to yank"))
4636 (setq group (nth 2 info))
4637 ;; Find which newsgroup to insert this one before - search
4638 ;; backward until something suitable is found. If there are no
4639 ;; other newsgroups in this buffer, just make this newsgroup the
4641 (setq prev (gnus-group-group-name))
4642 (gnus-group-change-level
4643 info (nth 2 info) gnus-level-killed
4644 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4646 (gnus-group-insert-group-line-info (nth 1 info))
4647 (setq gnus-list-of-killed-groups
4648 (cdr gnus-list-of-killed-groups)))
4650 (gnus-group-position-cursor)
4653 (defun gnus-group-list-all-groups (&optional arg)
4654 "List all newsgroups with level ARG or lower.
4655 Default is gnus-level-unsubscribed, which lists all subscribed and most
4656 unsubscribed groups."
4658 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4660 (defun gnus-group-list-killed ()
4661 "List all killed newsgroups in the group buffer."
4663 (if (not gnus-killed-list)
4664 (gnus-message 6 "No killed groups")
4665 (let (gnus-group-list-mode)
4666 (funcall gnus-group-prepare-function
4667 gnus-level-killed t gnus-level-killed))
4668 (goto-char (point-min)))
4669 (gnus-group-position-cursor))
4671 (defun gnus-group-list-zombies ()
4672 "List all zombie newsgroups in the group buffer."
4674 (if (not gnus-zombie-list)
4675 (gnus-message 6 "No zombie groups")
4676 (let (gnus-group-list-mode)
4677 (funcall gnus-group-prepare-function
4678 gnus-level-zombie t gnus-level-zombie))
4679 (goto-char (point-min)))
4680 (gnus-group-position-cursor))
4682 (defun gnus-group-get-new-news (&optional arg)
4683 "Get newly arrived articles.
4684 If ARG is non-nil, it should be a number between one and nine to
4685 specify which levels you are interested in re-scanning."
4687 (run-hooks 'gnus-get-new-news-hook)
4688 (setq arg (gnus-group-default-level arg t))
4689 (if (and gnus-read-active-file (not arg))
4691 (gnus-read-active-file)
4692 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4693 (let ((gnus-read-active-file (not arg))
4694 (gnus-have-read-active-file
4695 (and (not arg) gnus-have-read-active-file)))
4696 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4697 (gnus-group-list-groups))
4699 (defun gnus-group-get-new-news-this-group (&optional n)
4700 "Check for newly arrived news in the current group (and the N-1 next groups).
4701 The difference between N and the number of newsgroup checked is returned.
4702 If N is negative, this group and the N-1 previous groups will be checked."
4704 (let* ((groups (gnus-group-process-prefix n))
4705 (ret (if (numberp n) (- n (length groups)) 0))
4708 (setq group (car groups)
4709 groups (cdr groups))
4710 (gnus-group-remove-mark group)
4711 (or (gnus-get-new-news-in-group group)
4714 (message "%s error: %s" group (gnus-status-message group))
4716 (gnus-group-next-unread-group 1 t)
4717 (gnus-summary-position-cursor)
4720 (defun gnus-get-new-news-in-group (group)
4722 (gnus-activate-group group)
4724 (gnus-get-unread-articles-in-group
4725 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4726 (gnus-gethash group gnus-active-hashtb))
4727 (gnus-group-update-group-line)
4730 (defun gnus-group-fetch-faq (group)
4731 "Fetch the FAQ for the current group."
4732 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4733 (or group (error "No group name given"))
4734 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group))))
4735 (if (not (file-exists-p file))
4736 (error "No such file: %s" file)
4739 (defun gnus-group-describe-group (force &optional group)
4740 "Display a description of the current newsgroup."
4741 (interactive (list current-prefix-arg (gnus-group-group-name)))
4742 (and force (setq gnus-description-hashtb nil))
4743 (let ((method (gnus-find-method-for-group group))
4745 (or group (error "No group name given"))
4746 (and (or (and gnus-description-hashtb
4747 ;; We check whether this group's method has been
4748 ;; queried for a description file.
4750 (gnus-group-prefixed-name "" method)
4751 gnus-description-hashtb))
4752 (setq desc (gnus-group-get-description group))
4753 (gnus-read-descriptions-file method))
4755 (or desc (gnus-gethash group gnus-description-hashtb)
4756 "No description available")))))
4758 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4759 (defun gnus-group-describe-all-groups (&optional force)
4760 "Pop up a buffer with descriptions of all newsgroups."
4762 (and force (setq gnus-description-hashtb nil))
4763 (if (not (or gnus-description-hashtb
4764 (gnus-read-all-descriptions-files)))
4765 (error "Couldn't request descriptions file"))
4766 (let ((buffer-read-only nil)
4772 (insert (format " *: %-20s %s\n" (symbol-name group)
4773 (symbol-value group)))
4774 (add-text-properties
4775 b (1+ b) (list 'gnus-group group
4776 'gnus-unread t 'gnus-marked nil
4777 'gnus-level (1+ gnus-level-subscribed))))
4778 gnus-description-hashtb)
4779 (goto-char (point-min))
4780 (gnus-group-position-cursor)))
4782 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4783 (defun gnus-group-apropos (regexp &optional search-description)
4784 "List all newsgroups that have names that match a regexp."
4785 (interactive "sGnus apropos (regexp): ")
4787 (obuf (current-buffer))
4789 ;; Go through all newsgroups that are known to Gnus.
4792 (and (symbol-name group)
4793 (string-match regexp (symbol-name group))
4794 (setq groups (cons (symbol-name group) groups))))
4796 ;; Go through all descriptions that are known to Gnus.
4797 (if search-description
4800 (and (string-match regexp (symbol-value group))
4801 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4802 (setq groups (cons (symbol-name group) groups))))
4803 gnus-description-hashtb))
4805 (gnus-message 3 "No groups matched \"%s\"." regexp)
4806 ;; Print out all the groups.
4808 (pop-to-buffer "*Gnus Help*")
4809 (buffer-disable-undo (current-buffer))
4811 (setq groups (sort groups 'string<))
4813 ;; Groups may be entered twice into the list of groups.
4814 (if (not (string= (car groups) prev))
4816 (insert (setq prev (car groups)) "\n")
4817 (if (and gnus-description-hashtb
4818 (setq des (gnus-gethash (car groups)
4819 gnus-description-hashtb)))
4820 (insert " " des "\n"))))
4821 (setq groups (cdr groups)))
4822 (goto-char (point-min))))
4823 (pop-to-buffer obuf)))
4825 (defun gnus-group-description-apropos (regexp)
4826 "List all newsgroups that have names or descriptions that match a regexp."
4827 (interactive "sGnus description apropos (regexp): ")
4828 (if (not (or gnus-description-hashtb
4829 (gnus-read-all-descriptions-files)))
4830 (error "Couldn't request descriptions file"))
4831 (gnus-group-apropos regexp t))
4833 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4834 (defun gnus-group-list-matching (level regexp &optional all lowest)
4835 "List all groups with unread articles that match REGEXP.
4836 If the prefix LEVEL is non-nil, it should be a number that says which
4837 level to cut off listing groups.
4838 If ALL, also list groups with no unread articles.
4839 If LOWEST, don't list groups with level lower than LOWEST."
4840 (interactive "P\nsList newsgroups matching: ")
4841 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4842 all (or lowest 1) regexp)
4843 (goto-char (point-min))
4844 (gnus-group-position-cursor))
4846 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4847 "List all groups that match REGEXP.
4848 If the prefix LEVEL is non-nil, it should be a number that says which
4849 level to cut off listing groups.
4850 If LOWEST, don't list groups with level lower than LOWEST."
4851 (interactive "P\nsList newsgroups matching: ")
4852 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4854 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4855 (defun gnus-group-save-newsrc ()
4856 "Save the Gnus startup files."
4858 (gnus-save-newsrc-file))
4860 (defun gnus-group-restart (&optional arg)
4861 "Force Gnus to read the .newsrc file."
4863 (gnus-save-newsrc-file)
4864 (gnus-setup-news 'force)
4865 (gnus-group-list-groups arg))
4867 (defun gnus-group-read-init-file ()
4868 "Read the Gnus elisp init file."
4870 (gnus-read-init-file))
4872 (defun gnus-group-check-bogus-groups (&optional silent)
4873 "Check bogus newsgroups.
4874 If given a prefix, don't ask for confirmation before removing a bogus
4877 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4878 (gnus-group-list-groups))
4880 (defun gnus-group-edit-global-kill (&optional article group)
4881 "Edit the global kill file.
4882 If GROUP, edit that local kill file instead."
4884 (setq gnus-current-kill-article article)
4885 (gnus-kill-file-edit-file group)
4888 (substitute-command-keys
4889 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4891 (defun gnus-group-edit-local-kill (article group)
4892 "Edit a local kill file."
4893 (interactive (list nil (gnus-group-group-name)))
4894 (gnus-group-edit-global-kill article group))
4896 (defun gnus-group-force-update ()
4897 "Update `.newsrc' file."
4899 (gnus-save-newsrc-file))
4901 (defun gnus-group-suspend ()
4902 "Suspend the current Gnus session.
4903 In fact, cleanup buffers except for group mode buffer.
4904 The hook gnus-suspend-gnus-hook is called before actually suspending."
4906 (run-hooks 'gnus-suspend-gnus-hook)
4907 ;; Kill Gnus buffers except for group mode buffer.
4908 (let ((group-buf (get-buffer gnus-group-buffer)))
4909 ;; Do this on a separate list in case the user does a ^G before we finish
4910 (let ((gnus-buffer-list
4911 (delq group-buf (delq gnus-dribble-buffer
4912 (append gnus-buffer-list nil)))))
4913 (while gnus-buffer-list
4914 (gnus-kill-buffer (car gnus-buffer-list))
4915 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4918 (setq gnus-buffer-list (list group-buf))
4919 (bury-buffer group-buf)
4920 (delete-windows-on group-buf t)))))
4922 (defun gnus-group-clear-dribble ()
4923 "Clear all information from the dribble buffer."
4925 (gnus-dribble-clear))
4927 (defun gnus-group-exit ()
4928 "Quit reading news after updating .newsrc.eld and .newsrc.
4929 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4931 (if (or noninteractive ;For gnus-batch-kill
4932 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4933 (not gnus-interactive-exit) ;Without confirmation
4935 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4937 (run-hooks 'gnus-exit-gnus-hook)
4938 ;; Offer to save data from non-quitted summary buffers.
4939 (gnus-offer-save-summaries)
4940 ;; Save the newsrc file(s).
4941 (gnus-save-newsrc-file)
4943 (gnus-close-backends)
4944 ;; Reset everything.
4945 (gnus-clear-system))))
4947 (defun gnus-close-backends ()
4948 ;; Send a close request to all backends that support such a request.
4949 (let ((methods gnus-valid-select-methods)
4952 (if (fboundp (setq func (intern (concat (car (car methods))
4953 "-request-close"))))
4955 (setq methods (cdr methods)))))
4957 (defun gnus-group-quit ()
4958 "Quit reading news without updating .newsrc.eld or .newsrc.
4959 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4961 (if (or noninteractive ;For gnus-batch-kill
4962 (zerop (buffer-size))
4963 (not (gnus-server-opened gnus-select-method))
4965 (not gnus-current-startup-file)
4967 (format "Quit reading news without saving %s? "
4968 (file-name-nondirectory gnus-current-startup-file))))
4970 (run-hooks 'gnus-exit-gnus-hook)
4971 (if gnus-use-full-window
4972 (delete-other-windows)
4973 (gnus-remove-some-windows))
4975 (gnus-close-backends)
4976 (gnus-clear-system))))
4978 (defun gnus-offer-save-summaries ()
4980 (let ((buflist (buffer-list))
4983 (and (setq bufname (buffer-name (car buflist)))
4984 (string-match "Summary" bufname)
4986 (set-buffer bufname)
4987 ;; We check that this is, indeed, a summary buffer.
4988 (eq major-mode 'gnus-summary-mode))
4989 (setq buffers (cons bufname buffers)))
4990 (setq buflist (cdr buflist)))
4993 "Update summary buffer %s? "
4996 (gnus-summary-exit))
4999 (defun gnus-group-describe-briefly ()
5000 "Give a one line description of the group mode commands."
5002 (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")))
5004 (defun gnus-group-browse-foreign-server (method)
5005 "Browse a foreign news server.
5006 If called interactively, this function will ask for a select method
5007 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5008 If not, METHOD should be a list where the first element is the method
5009 and the second element is the address."
5011 (list (let ((how (completing-read
5013 (append gnus-valid-select-methods gnus-server-alist)
5015 ;; We either got a backend name or a virtual server name.
5016 ;; If the first, we also need an address.
5017 (if (assoc how gnus-valid-select-methods)
5019 ;; Suggested by mapjph@bath.ac.uk.
5022 (mapcar (lambda (server) (list server))
5023 gnus-secondary-servers)))
5024 ;; We got a server name, so we find the method.
5025 (gnus-server-to-method how)))))
5026 (gnus-browse-foreign-server method))
5030 ;;; Browse Server Mode
5033 (defvar gnus-browse-mode-hook nil)
5034 (defvar gnus-browse-mode-map nil)
5035 (put 'gnus-browse-mode 'mode-class 'special)
5037 (if gnus-browse-mode-map
5039 (setq gnus-browse-mode-map (make-keymap))
5040 (suppress-keymap gnus-browse-mode-map)
5041 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5042 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5043 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5044 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5045 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5046 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5047 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5048 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5049 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5050 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5051 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5052 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5053 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5054 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5055 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5056 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5057 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5058 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5061 (defvar gnus-browse-current-method nil)
5062 (defvar gnus-browse-return-buffer nil)
5064 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5066 (defun gnus-browse-foreign-server (method &optional return-buffer)
5067 (setq gnus-browse-current-method method)
5068 (setq gnus-browse-return-buffer return-buffer)
5069 (let ((gnus-select-method method)
5071 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5072 (or (gnus-check-server method)
5073 (error "Unable to contact server: %s" (gnus-status-message method)))
5074 (or (gnus-request-list method)
5075 (error "Couldn't request list: %s" (gnus-status-message method)))
5076 (get-buffer-create gnus-browse-buffer)
5077 (gnus-add-current-to-buffer-list)
5078 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5079 (gnus-configure-windows 'browse)
5080 (buffer-disable-undo (current-buffer))
5081 (let ((buffer-read-only nil))
5084 (setq mode-line-buffer-identification
5086 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5088 (set-buffer nntp-server-buffer)
5089 (let ((cur (current-buffer)))
5090 (goto-char (point-min))
5091 (or (string= gnus-ignored-newsgroups "")
5092 (delete-matching-lines gnus-ignored-newsgroups))
5093 (while (re-search-forward
5094 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5095 (goto-char (match-end 1))
5096 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5098 (max 0 (- (1+ (read cur)) (read cur))))
5100 (setq groups (sort groups
5102 (string< (car l1) (car l2)))))
5103 (let ((buffer-read-only nil))
5105 (setq group (car groups))
5107 (format "K%7d: %s\n" (cdr group) (car group)))
5108 (setq groups (cdr groups))))
5109 (switch-to-buffer (current-buffer))
5110 (goto-char (point-min))
5111 (gnus-group-position-cursor)))
5113 (defun gnus-browse-mode ()
5114 "Major mode for browsing a foreign server.
5116 All normal editing commands are switched off.
5118 \\<gnus-browse-mode-map>
5119 The only things you can do in this buffer is
5121 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5122 The group will be inserted into the group buffer upon exit from this
5125 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5127 3) `\\[gnus-browse-exit]' to return to the group buffer."
5129 (kill-all-local-variables)
5130 (if gnus-visual (gnus-browse-make-menu-bar))
5131 (setq mode-line-modified "-- ")
5132 (make-local-variable 'mode-line-format)
5133 (setq mode-line-format (copy-sequence mode-line-format))
5134 (and (equal (nth 3 mode-line-format) " ")
5135 (setcar (nthcdr 3 mode-line-format) ""))
5136 (setq major-mode 'gnus-browse-mode)
5137 (setq mode-name "Browse Server")
5138 (setq mode-line-process nil)
5139 (use-local-map gnus-browse-mode-map)
5140 (buffer-disable-undo (current-buffer))
5141 (setq truncate-lines t)
5142 (setq buffer-read-only t)
5143 (run-hooks 'gnus-browse-mode-hook))
5145 (defun gnus-browse-read-group (&optional no-article)
5146 "Enter the group at the current line."
5148 (let ((group (gnus-browse-group-name)))
5149 (or (gnus-group-read-ephemeral-group
5150 group gnus-browse-current-method nil
5151 (cons (current-buffer) 'browse))
5152 (error "Couldn't enter %s" group))))
5154 (defun gnus-browse-select-group ()
5155 "Select the current group."
5157 (gnus-browse-read-group 'no))
5159 (defun gnus-browse-next-group (n)
5160 "Go to the next group."
5164 (gnus-group-position-cursor)))
5166 (defun gnus-browse-prev-group (n)
5167 "Go to the next group."
5169 (gnus-browse-next-group (- n)))
5171 (defun gnus-browse-unsubscribe-current-group (arg)
5172 "(Un)subscribe to the next ARG groups."
5175 (error "No group at current line."))
5176 (let ((ward (if (< arg 0) -1 1))
5178 (while (and (> arg 0)
5180 (gnus-browse-unsubscribe-group)
5181 (zerop (gnus-browse-next-group ward)))
5182 (setq arg (1- arg)))
5183 (gnus-group-position-cursor)
5184 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5187 (defun gnus-browse-group-name ()
5190 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5192 (gnus-group-prefixed-name
5193 (buffer-substring (match-beginning 1) (match-end 1))
5194 gnus-browse-current-method))))
5196 (defun gnus-browse-unsubscribe-group ()
5198 (buffer-read-only nil)
5202 (if (= (following-char) ?K) (setq sub t))
5203 (setq group (gnus-browse-group-name))
5208 (gnus-group-change-level
5209 (list t group gnus-level-default-subscribed
5210 nil nil gnus-browse-current-method)
5211 gnus-level-default-subscribed gnus-level-killed
5212 (and (car (nth 1 gnus-newsrc-alist))
5213 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5214 gnus-newsrc-hashtb))
5217 (gnus-group-change-level
5218 group gnus-level-killed gnus-level-default-subscribed)
5222 (defun gnus-browse-exit ()
5223 "Quit browsing and return to the group buffer."
5225 (if (eq major-mode 'gnus-browse-mode)
5226 (kill-buffer (current-buffer)))
5227 (if gnus-browse-return-buffer
5228 (gnus-configure-windows 'server 'force)
5229 (gnus-configure-windows 'group 'force)
5230 (gnus-group-list-groups nil)))
5232 (defun gnus-browse-describe-briefly ()
5233 "Give a one line description of the group mode commands."
5236 (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")))
5240 ;;; Gnus summary mode
5243 (defvar gnus-summary-mode-map nil)
5244 (defvar gnus-summary-mark-map nil)
5245 (defvar gnus-summary-mscore-map nil)
5246 (defvar gnus-summary-article-map nil)
5247 (defvar gnus-summary-thread-map nil)
5248 (defvar gnus-summary-goto-map nil)
5249 (defvar gnus-summary-exit-map nil)
5250 (defvar gnus-summary-interest-map nil)
5251 (defvar gnus-summary-sort-map nil)
5252 (defvar gnus-summary-backend-map nil)
5253 (defvar gnus-summary-save-map nil)
5254 (defvar gnus-summary-wash-map nil)
5255 (defvar gnus-summary-wash-hide-map nil)
5256 (defvar gnus-summary-wash-highlight-map nil)
5257 (defvar gnus-summary-wash-time-map nil)
5258 (defvar gnus-summary-help-map nil)
5260 (put 'gnus-summary-mode 'mode-class 'special)
5262 (if gnus-summary-mode-map
5264 (setq gnus-summary-mode-map (make-keymap))
5265 (suppress-keymap gnus-summary-mode-map)
5267 ;; Non-orthogonal keys
5269 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5270 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5271 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5272 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5273 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5274 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5275 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5276 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5277 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5278 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5279 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5280 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5281 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5282 (define-key gnus-summary-mode-map
5283 "\M-s" 'gnus-summary-search-article-forward)
5284 (define-key gnus-summary-mode-map
5285 "\M-r" 'gnus-summary-search-article-backward)
5286 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5287 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5288 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5289 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5290 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5291 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5292 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5293 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5294 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5295 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5296 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5297 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5298 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5299 (define-key gnus-summary-mode-map
5300 "k" 'gnus-summary-kill-same-subject-and-select)
5301 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5302 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5303 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5304 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5305 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5306 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5307 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5308 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5309 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5310 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5311 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5312 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5313 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5314 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5315 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5316 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5317 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5318 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5319 (define-key gnus-summary-mode-map
5320 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5321 (define-key gnus-summary-mode-map
5322 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5323 (define-key gnus-summary-mode-map
5324 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5325 (define-key gnus-summary-mode-map
5326 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5327 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5328 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5329 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5330 (define-key gnus-summary-mode-map
5331 "\C-x\C-s" 'gnus-summary-reselect-current-group)
5332 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5333 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5334 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5335 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5336 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5337 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5338 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5339 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5340 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5341 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5342 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5343 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5344 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5345 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5346 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5347 (define-key gnus-summary-mode-map "V" 'gnus-version)
5348 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5349 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5350 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5351 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5352 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5353 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5354 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5355 (define-key gnus-summary-mode-map
5356 "x" 'gnus-summary-remove-lines-marked-as-read)
5357 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5358 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5359 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5360 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5361 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5362 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5363 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5364 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5365 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5366 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5369 ;; Sort of orthogonal keymap
5370 (define-prefix-command 'gnus-summary-mark-map)
5371 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5372 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5373 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5374 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5375 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5376 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5377 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5378 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5379 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5380 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5381 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5382 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5383 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5384 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5385 (define-key gnus-summary-mark-map
5386 "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5387 (define-key gnus-summary-mark-map
5388 "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5389 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5390 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5391 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5392 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5393 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5394 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5395 (define-key gnus-summary-mark-map
5396 "k" 'gnus-summary-kill-same-subject-and-select)
5397 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5399 (define-prefix-command 'gnus-summary-mscore-map)
5400 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5401 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5402 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5403 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5404 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5406 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5408 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5410 (define-prefix-command 'gnus-summary-goto-map)
5411 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5412 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5413 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5414 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5415 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5416 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5417 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5418 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5419 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5420 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5421 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5422 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5423 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5424 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5427 (define-prefix-command 'gnus-summary-thread-map)
5428 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5429 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5430 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5431 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5432 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5433 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5434 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5435 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5436 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5437 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5438 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5439 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5440 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5441 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5444 (define-prefix-command 'gnus-summary-exit-map)
5445 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5446 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5447 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5448 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5449 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5450 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5451 (define-key gnus-summary-exit-map
5452 "n" 'gnus-summary-catchup-and-goto-next-group)
5453 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5454 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5455 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5456 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5459 (define-prefix-command 'gnus-summary-article-map)
5460 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5461 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5462 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5463 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5464 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5465 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5466 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5467 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5468 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5469 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5470 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5471 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5472 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5473 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5477 (define-prefix-command 'gnus-summary-wash-map)
5478 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5480 (define-prefix-command 'gnus-summary-wash-hide-map)
5481 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5482 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5483 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5484 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5485 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5486 (define-key gnus-summary-wash-hide-map
5487 "\C-c" 'gnus-article-hide-citation-maybe)
5489 (define-prefix-command 'gnus-summary-wash-highlight-map)
5490 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5491 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5492 (define-key gnus-summary-wash-highlight-map
5493 "h" 'gnus-article-highlight-headers)
5494 (define-key gnus-summary-wash-highlight-map
5495 "c" 'gnus-article-highlight-citation)
5496 (define-key gnus-summary-wash-highlight-map
5497 "s" 'gnus-article-highlight-signature)
5499 (define-prefix-command 'gnus-summary-wash-time-map)
5500 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5501 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5502 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5503 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5504 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5506 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5507 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5508 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5509 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5510 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5511 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5512 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5513 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5514 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5515 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5518 (define-prefix-command 'gnus-summary-help-map)
5519 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5520 (define-key gnus-summary-help-map "v" 'gnus-version)
5521 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5522 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5523 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5524 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5527 (define-prefix-command 'gnus-summary-backend-map)
5528 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5529 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5530 (define-key gnus-summary-backend-map "\M-\C-e"
5531 'gnus-summary-expire-articles-now)
5532 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5533 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5534 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5535 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5536 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5537 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5538 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5541 (define-prefix-command 'gnus-summary-save-map)
5542 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5543 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5544 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5545 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5546 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5547 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5548 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5549 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5550 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5552 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5554 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5555 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5556 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5557 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5558 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5559 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5560 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5561 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5562 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5563 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5565 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5567 ; (define-prefix-command 'gnus-summary-sort-map)
5568 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5569 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5570 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5571 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5572 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5573 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5575 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5576 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5582 (defun gnus-summary-mode (&optional group)
5583 "Major mode for reading articles.
5585 All normal editing commands are switched off.
5586 \\<gnus-summary-mode-map>
5587 Each line in this buffer represents one article. To read an
5588 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5589 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5592 You can also post articles and send mail from this buffer. To
5593 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5594 of an article, type `\\[gnus-summary-reply]'.
5596 There are approx. one gazillion commands you can execute in this
5597 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5599 The following commands are available:
5601 \\{gnus-summary-mode-map}"
5603 (if gnus-visual (gnus-summary-make-menu-bar))
5604 (kill-all-local-variables)
5605 (let ((locals gnus-summary-local-variables))
5607 (if (consp (car locals))
5609 (make-local-variable (car (car locals)))
5610 (set (car (car locals)) (eval (cdr (car locals)))))
5611 (make-local-variable (car locals))
5612 (set (car locals) nil))
5613 (setq locals (cdr locals))))
5614 (gnus-make-thread-indent-array)
5615 (setq mode-line-modified "-- ")
5616 (make-local-variable 'mode-line-format)
5617 (setq mode-line-format (copy-sequence mode-line-format))
5618 (and (equal (nth 3 mode-line-format) " ")
5619 (setcar (nthcdr 3 mode-line-format) ""))
5620 (setq major-mode 'gnus-summary-mode)
5621 (setq mode-name "Summary")
5622 (make-local-variable 'minor-mode-alist)
5623 (use-local-map gnus-summary-mode-map)
5624 (buffer-disable-undo (current-buffer))
5625 (setq buffer-read-only t) ;Disable modification
5626 (setq truncate-lines t)
5627 (setq selective-display t)
5628 (setq selective-display-ellipses t) ;Display `...'
5629 (setq buffer-display-table gnus-summary-display-table)
5630 (setq gnus-newsgroup-name group)
5631 (run-hooks 'gnus-summary-mode-hook))
5633 (defun gnus-summary-make-display-table ()
5634 ;; Change the display table. Odd characters have a tendency to mess
5635 ;; up nicely formatted displays - we make all possible glyphs
5636 ;; display only a single character.
5638 ;; We start from the standard display table, if any.
5639 (setq gnus-summary-display-table
5640 (or (copy-sequence standard-display-table)
5641 (make-display-table)))
5642 ;; Nix out all the control chars...
5644 (while (>= (setq i (1- i)) 0)
5645 (aset gnus-summary-display-table i [??])))
5646 ;; ... but not newline and cr, of course. (cr is necessary for the
5647 ;; selective display).
5648 (aset gnus-summary-display-table ?\n nil)
5649 (aset gnus-summary-display-table ?\r nil)
5650 ;; We nix out any glyphs over 126 that are not set already.
5652 (while (>= (setq i (1- i)) 127)
5653 ;; Only modify if the entry is nil.
5654 (or (aref gnus-summary-display-table i)
5655 (aset gnus-summary-display-table i [??])))))
5657 (defun gnus-summary-clear-local-variables ()
5658 (let ((locals gnus-summary-local-variables))
5660 (if (consp (car locals))
5661 (and (vectorp (car (car locals)))
5662 (set (car (car locals)) nil))
5663 (and (vectorp (car locals))
5664 (set (car locals) nil)))
5665 (setq locals (cdr locals)))))
5667 ;; Some summary mode macros.
5669 ;; Return a header specified by a NUMBER.
5670 (defun gnus-get-header-by-number (number)
5672 (set-buffer gnus-summary-buffer)
5673 (or gnus-newsgroup-headers-hashtb-by-number
5674 (gnus-make-headers-hashtable-by-number))
5675 (gnus-gethash (int-to-string number)
5676 gnus-newsgroup-headers-hashtb-by-number)))
5678 ;; Fast version of the function above.
5679 (defmacro gnus-get-header-by-num (number)
5680 (` (gnus-gethash (int-to-string (, number))
5681 gnus-newsgroup-headers-hashtb-by-number)))
5683 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5684 "Search for article forward.
5685 If UNREAD is non-nil, only unread articles are selected.
5686 If SUBJECT is non-nil, the article which has the same subject will be
5688 If BACKWARD is non-nil, the search will be performed backwards instead."
5689 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5691 (defmacro gnus-summary-search-backward (&optional unread subject)
5692 "Search for article backward.
5693 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5694 If 2nd optional argument SUBJECT is non-nil, the article which has
5695 the same subject will be searched for."
5696 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5698 (defmacro gnus-summary-article-number (&optional number-or-nil)
5699 "The article number of the article on the current line.
5700 If there isn's an article number here, then we return the current
5703 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5704 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5705 gnus-current-article)))
5707 (defmacro gnus-summary-thread-level ()
5708 "The thread level of the article on the current line."
5709 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5712 (defmacro gnus-summary-article-mark ()
5713 "The mark on the current line."
5714 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5716 (defun gnus-summary-subject-string ()
5717 "Return current subject string or nil if nothing."
5718 (let ((article (gnus-summary-article-number))
5721 (setq header (gnus-get-header-by-num article))
5723 (mail-header-subject header))))
5725 ;; Various summary mode internalish functions.
5727 (defun gnus-mouse-pick-article (e)
5730 (gnus-summary-next-page nil t))
5732 (defun gnus-summary-setup-buffer (group)
5733 "Initialize summary buffer."
5734 (let ((buffer (concat "*Summary " group "*")))
5735 (if (get-buffer buffer)
5738 (not gnus-newsgroup-begin))
5739 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5740 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5741 (gnus-add-current-to-buffer-list)
5742 (gnus-summary-mode group)
5743 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5744 (setq gnus-newsgroup-name group)
5747 (defun gnus-set-global-variables ()
5748 ;; Set the global equivalents of the summary buffer-local variables
5749 ;; to the latest values they had. These reflect the summary buffer
5750 ;; that was in action when the last article was fetched.
5751 (if (eq major-mode 'gnus-summary-mode)
5753 (setq gnus-summary-buffer (current-buffer))
5754 (let ((name gnus-newsgroup-name)
5755 (marked gnus-newsgroup-marked)
5756 (unread gnus-newsgroup-unreads)
5757 (headers gnus-current-headers)
5758 (score-file gnus-current-score-file))
5760 (set-buffer gnus-group-buffer)
5761 (setq gnus-newsgroup-name name)
5762 (setq gnus-newsgroup-marked marked)
5763 (setq gnus-newsgroup-unreads unread)
5764 (setq gnus-current-headers headers)
5765 (setq gnus-current-score-file score-file))))))
5767 (defun gnus-summary-insert-dummy-line (sformat subject number)
5769 (setq sformat gnus-summary-dummy-line-format-spec))
5773 (insert (eval sformat))
5774 (add-text-properties
5776 (list 'gnus-number number
5777 'gnus-mark gnus-dummy-mark
5780 (defvar gnus-thread-indent-array nil)
5781 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5782 (defun gnus-make-thread-indent-array ()
5784 (if (and gnus-thread-indent-array
5785 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5787 (setq gnus-thread-indent-array (make-vector 201 "")
5788 gnus-thread-indent-array-level gnus-thread-indent-level)
5790 (aset gnus-thread-indent-array n
5791 (make-string (* n gnus-thread-indent-level) ? ))
5794 (defun gnus-summary-insert-line
5795 (sformat header level current unread replied expirable subject-or-nil
5796 &optional dummy score)
5797 (or sformat (setq sformat gnus-summary-line-format-spec))
5798 (let* ((indentation (aref gnus-thread-indent-array level))
5799 (lines (mail-header-lines header))
5800 (score (or score gnus-summary-default-score 0))
5802 (if (or (null gnus-summary-default-score)
5803 (<= (abs (- score gnus-summary-default-score))
5804 gnus-summary-zcore-fuzz)) ?
5805 (if (< score gnus-summary-default-score)
5806 gnus-score-below-mark gnus-score-over-mark)))
5807 (replied (if replied gnus-replied-mark ? ))
5808 (from (mail-header-from header))
5810 ((string-match "(.+)" from)
5811 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5812 ((string-match "<[^>]+> *$" from)
5813 (let ((beg (match-beginning 0)))
5814 (or (and (string-match "^\"[^\"]*\"" from)
5815 (substring from (1+ (match-beginning 0))
5816 (1- (match-end 0))))
5817 (substring from 0 beg))))
5819 (subject (mail-header-subject header))
5820 (number (mail-header-number header))
5821 (opening-bracket (if dummy ?\< ?\[))
5822 (closing-bracket (if dummy ?\> ?\]))
5823 (buffer-read-only nil)
5824 (b (progn (beginning-of-line) (point))))
5825 (or (numberp lines) (setq lines 0))
5826 (insert (eval sformat))
5827 (add-text-properties
5828 b (1+ b) (list 'gnus-number number
5829 'gnus-mark (or unread gnus-unread-mark)
5830 'gnus-level level))))
5832 (defun gnus-summary-update-line (&optional dont-update)
5833 ;; Update summary line after change.
5834 (or (not gnus-summary-default-score)
5835 gnus-summary-inhibit-highlight
5836 (let ((gnus-summary-inhibit-highlight t)
5837 (article (gnus-summary-article-number)))
5840 (if (and gnus-summary-mark-below
5841 (< (gnus-summary-article-score)
5842 gnus-summary-mark-below))
5843 (and (not (memq article gnus-newsgroup-marked))
5844 (not (memq article gnus-newsgroup-dormant))
5845 (memq article gnus-newsgroup-unreads)
5846 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5847 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5848 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5850 (run-hooks 'gnus-summary-update-hook))))))
5852 (defun gnus-summary-update-lines (&optional beg end)
5853 ;; Mark article as read (or not) by taking into account scores.
5854 (let ((beg (or beg (point-min)))
5855 (end (or end (point-max))))
5856 (if (or (not gnus-summary-default-score)
5857 gnus-summary-inhibit-highlight)
5859 (let ((gnus-summary-inhibit-highlight t)
5862 (set-buffer gnus-summary-buffer)
5865 (while (and (not (eobp)) (< (point) end))
5866 (if (and gnus-summary-mark-below
5868 (setq article (get-text-property
5869 (point) 'gnus-number))
5870 gnus-newsgroup-scored))
5871 gnus-summary-default-score 0)
5872 gnus-summary-mark-below))
5873 ;; We want to possibly mark it as read...
5874 (and (not (memq article gnus-newsgroup-marked))
5875 (not (memq article gnus-newsgroup-dormant))
5876 (memq article gnus-newsgroup-unreads)
5877 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5878 ;; We want to possibly mark it as unread.
5879 (and (eq (get-text-property (point) 'gnus-mark)
5880 gnus-low-score-mark)
5881 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5882 ;; Do the visual highlights at the same time.
5883 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5884 (forward-line 1)))))))
5886 (defvar gnus-tmp-gathered nil)
5888 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5889 ;; Sum up all elements (and sub-elements) in a list.
5891 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5892 (if (and (consp thread) (cdr thread))
5895 'gnus-summary-number-of-articles-in-thread
5899 (if (> number 1) gnus-not-empty-thread-mark
5900 gnus-empty-thread-mark)
5903 (defun gnus-summary-read-group
5904 (group &optional show-all no-article kill-buffer)
5905 "Start reading news in newsgroup GROUP.
5906 If SHOW-ALL is non-nil, already read articles are also listed.
5907 If NO-ARTICLE is non-nil, no article is selected initially."
5908 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5909 (let* ((new-group (gnus-summary-setup-buffer group))
5910 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5912 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5915 (gnus-set-global-variables)
5916 (gnus-kill-buffer kill-buffer)
5917 (gnus-configure-windows 'summary 'force)
5918 (gnus-set-mode-line 'summary)
5919 (gnus-summary-position-cursor)
5923 (and (eq major-mode 'gnus-summary-mode)
5924 (not (equal (current-buffer) kill-buffer))
5926 (kill-buffer (current-buffer))
5927 (if (not quit-config)
5929 (set-buffer gnus-group-buffer)
5930 (gnus-group-jump-to-group group)
5931 (gnus-group-next-unread-group 1))
5932 (if (not (buffer-name (car quit-config)))
5933 (gnus-configure-windows 'group 'force)
5934 (set-buffer (car quit-config))
5935 (and (eq major-mode 'gnus-summary-mode)
5936 (gnus-set-global-variables))
5937 (gnus-configure-windows (cdr quit-config))))))
5938 (message "Can't select group")
5940 ((eq did-select 'quit)
5941 (and (eq major-mode 'gnus-summary-mode)
5942 (not (equal (current-buffer) kill-buffer))
5943 (kill-buffer (current-buffer)))
5944 (gnus-kill-buffer kill-buffer)
5945 (if (not quit-config)
5947 (set-buffer gnus-group-buffer)
5948 (gnus-group-jump-to-group group)
5949 (gnus-group-next-unread-group 1)
5950 (gnus-configure-windows 'group 'force))
5951 (if (not (buffer-name (car quit-config)))
5952 (gnus-configure-windows 'group 'force)
5953 (set-buffer (car quit-config))
5954 (and (eq major-mode 'gnus-summary-mode)
5955 (gnus-set-global-variables))
5956 (gnus-configure-windows (cdr quit-config))))
5959 (gnus-set-global-variables)
5960 ;; Save the active value in effect when the group was entered.
5961 (setq gnus-newsgroup-active
5963 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5964 ;; You can change the subjects in this hook.
5965 (run-hooks 'gnus-select-group-hook)
5966 ;; Do score processing.
5967 (and gnus-use-scoring (gnus-possibly-score-headers))
5968 (gnus-update-format-specifications)
5969 ;; Generate the summary buffer.
5970 (gnus-summary-prepare)
5971 (if (zerop (buffer-size))
5972 (cond (gnus-newsgroup-dormant
5973 (gnus-summary-show-all-dormant))
5974 ((and gnus-newsgroup-scored show-all)
5975 (gnus-summary-show-all-expunged))))
5976 ;; Function `gnus-apply-kill-file' must be called in this hook.
5977 (run-hooks 'gnus-apply-kill-hook)
5978 (if (zerop (buffer-size))
5980 ;; This newsgroup is empty.
5981 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5982 (gnus-message 6 "No unread news")
5983 (gnus-kill-buffer kill-buffer)
5987 ;; (let ((gnus-summary-buffer kill-buffer))
5988 ;; (gnus-configure-windows 'group))))
5989 ;; Hide conversation thread subtrees. We cannot do this in
5990 ;; gnus-summary-prepare-hook since kill processing may not
5991 ;; work with hidden articles.
5992 (and gnus-show-threads
5993 gnus-thread-hide-subtree
5994 (gnus-summary-hide-all-threads))
5995 ;; Show first unread article if requested.
5996 (goto-char (point-min))
5997 (if (and (not no-article)
5998 gnus-auto-select-first
5999 (gnus-summary-first-unread-article))
6001 (gnus-configure-windows 'summary 'force))
6002 (gnus-set-mode-line 'summary)
6003 (gnus-summary-position-cursor)
6004 ;; If in async mode, we send some info to the backend.
6005 (and gnus-newsgroup-async
6006 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
6007 (gnus-request-asynchronous
6009 (if (and gnus-asynchronous-article-function
6010 (fboundp gnus-asynchronous-article-function))
6011 (funcall gnus-asynchronous-article-function
6012 gnus-newsgroup-threads)
6013 gnus-newsgroup-threads)))
6014 (gnus-kill-buffer kill-buffer)
6015 (if (not (get-buffer-window gnus-group-buffer))
6017 ;; gotta use windows, because recenter does wierd stuff if
6018 ;; the current buffer ain't the displayed window.
6019 (let ((owin (selected-window)))
6020 (select-window (get-buffer-window gnus-group-buffer))
6021 (and (gnus-group-goto-group group)
6023 (select-window owin))))
6026 (defun gnus-summary-prepare ()
6027 ;; Generate the summary buffer.
6028 (let ((buffer-read-only nil))
6030 (gnus-summary-prepare-threads
6031 (if gnus-show-threads
6032 (gnus-gather-threads
6034 (if (and gnus-summary-expunge-below
6035 (not gnus-fetch-old-headers))
6036 (gnus-make-threads-and-expunge)
6037 (gnus-make-threads))))
6038 gnus-newsgroup-headers)
6040 (gnus-summary-update-lines)
6041 ;; Create the header hashtb.
6042 (gnus-make-headers-hashtable-by-number)
6043 ;; Call hooks for modifying summary buffer.
6044 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6045 (goto-char (point-min))
6046 (run-hooks 'gnus-summary-prepare-hook)))
6048 (defun gnus-gather-threads (threads)
6049 "Gather threads that have lost their roots."
6050 (if (not gnus-summary-make-false-root)
6052 (let ((hashtb (gnus-make-hashtable 1023))
6055 subject hthread whole-subject)
6058 (setq subject (mail-header-subject (car (car threads)))))
6059 (if gnus-summary-gather-subject-limit
6060 (or (and (numberp gnus-summary-gather-subject-limit)
6061 (> (length subject) gnus-summary-gather-subject-limit)
6063 (substring subject 0
6064 gnus-summary-gather-subject-limit)))
6065 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6066 (setq subject (gnus-simplify-subject-fuzzy subject))))
6067 (setq subject (gnus-simplify-subject-re subject)))
6069 (gnus-gethash subject hashtb))
6071 (or (stringp (car (car hthread)))
6072 (setcar hthread (list whole-subject (car hthread))))
6073 (setcdr (car hthread) (nconc (cdr (car hthread))
6074 (list (car threads))))
6075 (setcdr prev (cdr threads))
6076 (setq threads prev))
6077 (gnus-sethash subject threads hashtb))
6079 (setq threads (cdr threads)))
6082 (defun gnus-make-threads ()
6083 ;; This function takes the dependencies already made by
6084 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6085 ;; through the dependecies in the hash table and finds all the
6086 ;; roots. Roots do not refer back to any valid articles.
6087 (gnus-message 6 "Threading...")
6088 (let (roots new-roots)
6089 (and gnus-fetch-old-headers
6090 (eq gnus-headers-retrieved-by 'nov)
6091 (gnus-build-old-threads))
6094 (if (not (car (symbol-value refs)))
6095 (setq roots (append (cdr (symbol-value refs)) roots))
6096 ;; Ok, these refer back to valid articles, but if
6097 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6098 ;; the root has the same subject as its children. The children
6099 ;; that do not are made into roots and removed from the list
6101 (or gnus-thread-ignore-subject
6102 (let* ((prev (symbol-value refs))
6103 (subject (gnus-simplify-subject-re
6104 (mail-header-subject (car prev))))
6105 (headers (cdr prev)))
6107 (if (not (string= subject
6108 (gnus-simplify-subject-re
6109 (mail-header-subject (car headers)))))
6111 (setq new-roots (cons (car headers) new-roots))
6112 (setcdr prev (cdr headers)))
6113 (setq prev headers))
6114 (setq headers (cdr headers)))))))
6115 gnus-newsgroup-dependencies)
6117 ;; We enter the new roots into the dependencies structure to
6118 ;; ensure that any possible later thread-regeneration will be
6120 (let ((r new-roots))
6122 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6123 (list nil (car r)) gnus-newsgroup-dependencies)
6126 (setq roots (nconc new-roots roots))
6129 (mapcar 'gnus-trim-thread
6131 (mapcar 'gnus-cut-thread
6132 (mapcar 'gnus-make-sub-thread roots))))
6133 (gnus-message 6 "Threading...done"))))
6136 (defun gnus-make-threads-and-expunge ()
6137 ;; This function takes the dependencies already made by
6138 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6139 ;; through the dependecies in the hash table and finds all the
6140 ;; roots. Roots do not refer back to any valid articles.
6141 (gnus-message 6 "Threading...")
6142 (let ((default (or gnus-summary-default-score 0))
6143 (below gnus-summary-expunge-below)
6144 roots article new-roots)
6145 (and gnus-fetch-old-headers
6146 (eq gnus-headers-retrieved-by 'nov)
6147 (gnus-build-old-threads))
6150 (if (not (car (symbol-value refs)))
6151 ;; These articles do not refer back to any other articles -
6153 (let ((headers (cdr (symbol-value refs))))
6154 ;; We weed out the low-scored articles.
6156 (if (not (< (or (cdr (assq (mail-header-number (car headers))
6157 gnus-newsgroup-scored)) default)
6160 (setq roots (cons (car headers) roots))
6161 ;; It is below, so we mark it as read.
6162 (setq gnus-newsgroup-unreads
6163 (delq (mail-header-number (car headers))
6164 gnus-newsgroup-unreads))
6165 (setq gnus-newsgroup-reads
6166 (cons (cons (mail-header-number (car headers))
6167 gnus-low-score-mark)
6168 gnus-newsgroup-reads)))
6169 (setq headers (cdr headers))))
6170 ;; Ok, these refer back to valid articles, but if
6171 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6172 ;; the root has the same subject as its children. The children
6173 ;; that do not are made into roots and removed from the list
6175 (or gnus-thread-ignore-subject
6176 (let* ((prev (symbol-value refs))
6177 (subject (gnus-simplify-subject-re
6178 (mail-header-subject (car prev))))
6179 (headers (cdr prev)))
6181 (if (not (string= subject
6182 (gnus-simplify-subject-re
6183 (mail-header-subject (car headers)))))
6185 (if (not (< (or (cdr (assq (mail-header-number
6187 gnus-newsgroup-scored))
6189 (setq new-roots (cons (car headers) new-roots))
6190 (setq gnus-newsgroup-unreads
6191 (delq (mail-header-number (car headers))
6192 gnus-newsgroup-unreads))
6193 (setq gnus-newsgroup-reads
6194 (cons (cons (mail-header-number (car headers))
6195 gnus-low-score-mark)
6196 gnus-newsgroup-reads)))
6197 (setcdr prev (cdr headers)))
6198 (setq prev headers))
6199 (setq headers (cdr headers)))))
6200 ;; If this article is expunged, some of the children might be
6202 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs)))
6203 gnus-newsgroup-scored)) default)
6205 (let* ((prev (symbol-value refs))
6206 (headers (cdr prev)))
6208 (setq article (mail-header-number (car headers)))
6209 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6211 (progn (setq new-roots (cons (car headers) new-roots))
6212 (setq prev headers))
6213 (setq gnus-newsgroup-unreads
6214 (delq article gnus-newsgroup-unreads))
6215 (setq gnus-newsgroup-reads
6216 (cons (cons article gnus-low-score-mark)
6217 gnus-newsgroup-reads))
6218 (setcdr prev (cdr headers)))
6219 (setq headers (cdr headers))))
6220 ;; It was not expunged, but we look at expunged children.
6221 (let* ((prev (symbol-value refs))
6222 (headers (cdr prev))
6225 (setq article (mail-header-number (car headers)))
6226 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6229 (setq gnus-newsgroup-unreads
6230 (delq article gnus-newsgroup-unreads))
6231 (setq gnus-newsgroup-reads
6232 (cons (cons article gnus-low-score-mark)
6233 gnus-newsgroup-reads))
6234 (setcdr prev (cdr headers)))
6235 (setq headers (cdr headers)))))))
6236 gnus-newsgroup-dependencies)
6238 ;; We enter the new roots into the dependencies structure to
6239 ;; ensure that any possible later thread-regeneration will be
6241 (let ((r new-roots))
6243 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6244 (list nil (car r)) gnus-newsgroup-dependencies)
6247 (setq roots (nconc new-roots roots))
6250 (mapcar 'gnus-trim-thread
6252 (mapcar 'gnus-cut-thread
6253 (mapcar 'gnus-make-sub-thread roots))))
6254 (gnus-message 6 "Threading...done"))))
6257 (defun gnus-cut-thread (thread)
6258 ;; Remove leaf dormant or ancient articles from THREAD.
6259 (let ((head (car thread))
6260 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6261 (if (and (null tail)
6262 (let ((number (mail-header-number head)))
6263 (or (memq number gnus-newsgroup-ancient)
6264 (memq number gnus-newsgroup-dormant)
6265 (and gnus-summary-expunge-below
6266 (eq gnus-fetch-old-headers 'some)
6267 (< (or (cdr (assq number gnus-newsgroup-scored))
6268 gnus-summary-default-score 0)
6269 gnus-summary-expunge-below)
6271 (setq gnus-newsgroup-unreads
6272 (delq number gnus-newsgroup-unreads))
6273 (setq gnus-newsgroup-reads
6274 (cons (cons number gnus-low-score-mark)
6275 gnus-newsgroup-reads))
6278 (list (cons head tail)))))
6280 (defun gnus-trim-thread (thread)
6281 ;; Remove root ancient articles with only one child from THREAD.
6282 (if (and (eq gnus-fetch-old-headers 'some)
6283 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6284 (= (length thread) 2))
6285 (gnus-trim-thread (nth 1 thread))
6288 (defun gnus-make-sub-thread (root)
6289 ;; This function makes a sub-tree for a node in the tree.
6290 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6291 gnus-newsgroup-dependencies)))))
6292 (cons root (mapcar 'gnus-make-sub-thread children))))
6294 (defun gnus-build-old-threads ()
6295 ;; Look at all the articles that refer back to old articles, and
6296 ;; fetch the headers for the articles that aren't there. This will
6297 ;; build complete threads - if the roots haven't been expired by the
6302 (if (not (car (symbol-value refs)))
6304 (setq heads (cdr (symbol-value refs)))
6306 (if (not (memq (mail-header-number (car heads))
6307 gnus-newsgroup-dormant))
6309 (setq id (symbol-name refs))
6310 (while (and (setq id (gnus-build-get-header id))
6311 (not (car (gnus-gethash
6312 id gnus-newsgroup-dependencies)))))
6314 (setq heads (cdr heads)))))))
6315 gnus-newsgroup-dependencies)))
6317 (defun gnus-build-get-header (id)
6318 ;; Look through the buffer of NOV lines and find the header to
6319 ;; ID. Enter this line into the dependencies hash table, and return
6320 ;; the id of the parent article (if any).
6321 (let ((deps gnus-newsgroup-dependencies)
6325 (set-buffer nntp-server-buffer)
6326 (goto-char (point-min))
6327 (while (and (not found) (search-forward id nil t))
6329 (setq found (looking-at
6330 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6331 (regexp-quote id))))
6332 (or found (beginning-of-line 2)))
6337 (setq header (gnus-nov-parse-line
6338 (read (current-buffer)) deps))
6339 (setq ref (mail-header-references header))
6340 (string-match "\\(<[^>]+>\\) *$" ref)
6341 (substring ref (match-beginning 1) (match-end 1))))))
6343 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6344 gnus-newsgroup-ancient (cons (mail-header-number header)
6345 gnus-newsgroup-ancient))))))
6347 ;; Re-build the thread containing ID.
6348 (defun gnus-rebuild-thread (id)
6349 (let ((dep gnus-newsgroup-dependencies)
6350 (buffer-read-only nil)
6351 parent headers refs thread art)
6352 (while (and id (setq headers
6353 (car (setq art (gnus-gethash (downcase id) dep)))))
6355 (setq id (and (setq refs (mail-header-references headers))
6356 (string-match "\\(<[^>]+>\\) *$" refs)
6357 (substring refs (match-beginning 1) (match-end 1)))))
6358 (setq thread (gnus-make-sub-thread (car parent)))
6359 (gnus-rebuild-remove-articles thread)
6360 (let ((beg (point)))
6361 (gnus-summary-prepare-threads (list thread))
6362 (gnus-summary-update-lines beg (point)))))
6364 ;; Delete all lines in the summary buffer that correspond to articles
6366 (defun gnus-rebuild-remove-articles (thread)
6367 (and (gnus-summary-goto-subject (mail-header-number (car thread)))
6369 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6371 (defun gnus-sort-threads (threads)
6372 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6373 (let ((fun gnus-thread-sort-functions))
6375 (setq threads (sort threads (car fun))
6379 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6380 (defmacro gnus-thread-header (thread)
6381 ;; Return header of first article in THREAD.
6382 ;; Note that THREAD must never, evr be anything else than a variable -
6383 ;; using some other form will lead to serious barfage.
6384 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6385 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6386 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6389 (defun gnus-thread-sort-by-number (h1 h2)
6390 "Sort threads by root article number."
6391 (< (mail-header-number (gnus-thread-header h1))
6392 (mail-header-number (gnus-thread-header h2))))
6394 (defun gnus-thread-sort-by-author (h1 h2)
6395 "Sort threads by root author."
6397 (let ((extract (funcall
6398 gnus-extract-address-components
6399 (mail-header-from (gnus-thread-header h1)))))
6400 (or (car extract) (cdr extract)))
6401 (let ((extract (funcall
6402 gnus-extract-address-components
6403 (mail-header-from (gnus-thread-header h2)))))
6404 (or (car extract) (cdr extract)))))
6406 (defun gnus-thread-sort-by-subject (h1 h2)
6407 "Sort threads by root subject."
6409 (downcase (gnus-simplify-subject
6410 (mail-header-subject (gnus-thread-header h1))))
6411 (downcase (gnus-simplify-subject
6412 (mail-header-subject (gnus-thread-header h2))))))
6414 (defun gnus-thread-sort-by-date (h1 h2)
6415 "Sort threads by root article date."
6417 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6418 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6420 (defun gnus-thread-sort-by-score (h1 h2)
6421 "Sort threads by root article score.
6422 Unscored articles will be counted as having a score of zero."
6423 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6424 gnus-newsgroup-scored))
6425 gnus-summary-default-score 0)
6426 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6427 gnus-newsgroup-scored))
6428 gnus-summary-default-score 0)))
6430 (defun gnus-thread-sort-by-total-score (h1 h2)
6431 "Sort threads by the sum of all scores in the thread.
6432 Unscored articles will be counted as having a score of zero."
6433 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6435 (defun gnus-thread-total-score (thread)
6436 ;; This function find the total score of THREAD.
6438 (if (stringp (car thread))
6439 (apply gnus-thread-score-function 0
6440 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6441 (gnus-thread-total-score-1 thread))
6442 (gnus-thread-total-score-1 (list thread))))
6444 (defun gnus-thread-total-score-1 (root)
6445 ;; This function find the total score of the thread below ROOT.
6446 (setq root (car root))
6447 (apply gnus-thread-score-function
6448 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6449 gnus-summary-default-score 0)
6450 (mapcar 'gnus-thread-total-score
6451 (cdr (gnus-gethash (downcase (mail-header-id root))
6452 gnus-newsgroup-dependencies)))))
6454 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6455 (defvar gnus-tmp-prev-subject "")
6457 (defun gnus-summary-prepare-threads (threads &optional cull)
6458 "Prepare summary buffer from THREADS and indentation LEVEL.
6459 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6460 or a straight list of headers."
6461 (message "Generating summary...")
6463 thread header number subject stack state gnus-tmp-gathered)
6464 (if (vectorp (car threads))
6465 ;; If this is a straight (sic) list of headers, then a
6466 ;; threaded summary display isn't required, so we just create
6467 ;; an unthreaded one.
6468 (gnus-summary-prepare-unthreaded threads cull)
6470 ;; Do the threaded display.
6472 (while (or threads stack)
6475 ;; If there are some threads, we do them before the
6476 ;; threads on the stack.
6477 (setq thread threads
6478 header (car (car thread)))
6479 ;; There were no current threads, so we pop something off
6481 (setq state (car stack)
6485 header (car (car thread))))
6487 (if (stringp header)
6489 ;; The header is a dummy root.
6491 ((eq gnus-summary-make-false-root 'adopt)
6492 ;; We let the first article adopt the rest.
6493 (let ((th (car (cdr (car thread)))))
6496 (setcdr th (cdr (cdr (car thread))))
6497 (setq gnus-tmp-gathered
6499 (lambda (h) (mail-header-number (car h)))
6500 (cdr (cdr (car thread))))
6502 (setcdr (cdr (car thread)) nil))
6504 ((eq gnus-summary-make-false-root 'empty)
6505 ;; We print adopted articles with empty subject fields.
6506 (setq gnus-tmp-gathered
6508 (lambda (h) (mail-header-number (car h)))
6509 (cdr (cdr (car thread))))
6512 ((eq gnus-summary-make-false-root 'dummy)
6513 ;; We output a dummy root.
6514 (gnus-summary-insert-dummy-line
6515 nil header (mail-header-number
6516 (car (car (cdr (car thread)))))))
6518 ;; We do not make a root for the gathered
6519 ;; sub-threads at all.
6522 (setq number (mail-header-number header)
6523 subject (mail-header-subject header))
6525 ;; Do the async thing.
6526 (and gnus-newsgroup-async
6527 (setq gnus-newsgroup-threads
6528 (cons (cons number (mail-header-lines header))
6529 gnus-newsgroup-threads)))
6531 ;; We may have to root out some bad articles...
6534 (cond ((and (memq (setq number (mail-header-number header))
6535 gnus-newsgroup-dormant)
6538 ((and gnus-summary-expunge-below
6539 (< (or (cdr (assq number gnus-newsgroup-scored))
6540 gnus-summary-default-score 0)
6541 gnus-summary-expunge-below))
6543 (setq gnus-newsgroup-unreads
6544 (delq number gnus-newsgroup-unreads))
6545 (setq gnus-newsgroup-reads
6546 (cons (cons number gnus-low-score-mark)
6547 gnus-newsgroup-reads)))))
6553 (gnus-summary-insert-line
6554 nil header level nil
6556 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6557 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6558 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6559 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6560 (t (or (cdr (assq number gnus-newsgroup-reads))
6561 gnus-ancient-mark)))
6562 (memq number gnus-newsgroup-replied)
6563 (memq number gnus-newsgroup-expirable)
6565 ((and gnus-thread-ignore-subject
6567 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6568 (gnus-simplify-subject-re subject))))
6571 (if (and (eq gnus-summary-make-false-root 'empty)
6572 (memq number gnus-tmp-gathered))
6573 gnus-summary-same-subject
6575 (t gnus-summary-same-subject))
6576 (and (eq gnus-summary-make-false-root 'adopt)
6577 (memq number gnus-tmp-gathered))
6578 (cdr (assq number gnus-newsgroup-scored)))
6580 (setq gnus-tmp-prev-subject subject)))))
6583 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6584 (setq level (1+ level))
6585 (setq threads (cdr (car thread))))))
6586 (message "Generating summary...done"))
6590 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6591 (let (header number)
6593 ;; Do the async thing, if that is required.
6594 (if gnus-newsgroup-async
6595 (setq gnus-newsgroup-threads
6597 (cons (mail-header-number h) (mail-header-lines h)))
6601 (setq header (car headers)
6602 headers (cdr headers)
6603 number (mail-header-number header))
6605 ;; We may have to root out some bad articles...
6608 (memq (setq number (mail-header-number header))
6609 gnus-newsgroup-dormant)))
6610 ((and cull gnus-summary-expunge-below
6611 (< (or (cdr (assq number gnus-newsgroup-scored))
6612 gnus-summary-default-score 0)
6613 gnus-summary-expunge-below))
6614 (setq gnus-newsgroup-unreads
6615 (delq number gnus-newsgroup-unreads))
6616 (setq gnus-newsgroup-reads
6617 (cons (cons number gnus-low-score-mark)
6618 gnus-newsgroup-reads)))
6620 (gnus-summary-insert-line
6622 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6623 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6624 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6625 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6626 (t (or (cdr (assq number gnus-newsgroup-reads))
6627 gnus-ancient-mark)))
6628 (memq number gnus-newsgroup-replied)
6629 (memq number gnus-newsgroup-expirable)
6630 (mail-header-subject header) nil
6631 (cdr (assq number gnus-newsgroup-scored))))))))
6633 (defun gnus-select-newsgroup (group &optional read-all)
6634 "Select newsgroup GROUP.
6635 If READ-ALL is non-nil, all articles in the group are selected."
6636 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6637 (info (nth 2 entry))
6640 (or (gnus-check-server
6641 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6642 (error "Couldn't open server"))
6644 (or (and entry (not (eq (car entry) t))) ; Either it's active...
6645 (gnus-activate-group group) ; Or we can activate it...
6646 (progn ; Or we bug out.
6647 (kill-buffer (current-buffer))
6648 (error "Couldn't request group %s: %s"
6649 group (gnus-status-message group))))
6651 (setq gnus-newsgroup-name group)
6652 (setq gnus-newsgroup-unselected nil)
6653 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6655 (and gnus-asynchronous
6656 (gnus-check-backend-function
6657 'request-asynchronous gnus-newsgroup-name)
6658 (setq gnus-newsgroup-async
6659 (gnus-request-asynchronous gnus-newsgroup-name)))
6661 (setq articles (gnus-articles-to-read group read-all))
6665 (gnus-message 3 "Couldn't select newsgroup")
6667 ((eq articles 0) nil)
6669 ;; Init the dependencies hash table.
6670 (setq gnus-newsgroup-dependencies
6671 (gnus-make-hashtable (length articles)))
6672 ;; Retrieve the headers and read them in.
6673 (gnus-message 5 "Fetching headers...")
6674 (setq gnus-newsgroup-headers
6675 (if (eq 'nov (setq gnus-headers-retrieved-by
6676 ;; This is a naughty hack. To get the
6677 ;; retrieval of old headers to work, we
6678 ;; set `nntp-nov-gap' to nil (locally),
6679 ;; and then just retrieve the headers.
6681 (if gnus-fetch-old-headers
6683 (gnus-retrieve-headers
6684 (if (not (eq 1 (car articles)))
6687 gnus-newsgroup-name))
6688 (gnus-retrieve-headers
6689 articles gnus-newsgroup-name))))
6691 (gnus-get-newsgroup-headers-xover articles))
6692 ;; If we were to fetch old headers, but the backend didn't
6693 ;; support XOVER, then it is possible we fetched one article
6694 ;; that we shouldn't have. If that's the case, we remove it.
6695 (if (or (not gnus-fetch-old-headers)
6696 (eq 1 (car articles)))
6699 (set-buffer nntp-server-buffer)
6700 (goto-char (point-min))
6702 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6703 (delete-region ; So we delete this head.
6705 (search-forward "\n.\n" nil t)))))
6706 (gnus-get-newsgroup-headers)))
6707 (gnus-message 5 "Fetching headers...done")
6708 ;; Remove canceled articles from the list of unread articles.
6709 (setq gnus-newsgroup-unreads
6710 (gnus-set-sorted-intersection
6711 gnus-newsgroup-unreads
6712 (mapcar (lambda (headers) (mail-header-number headers))
6713 gnus-newsgroup-headers)))
6714 ;; Adjust and set lists of article marks.
6717 (gnus-adjust-marked-articles info)
6718 (setq gnus-newsgroup-marked
6720 (cdr (assq 'tick (setq marked (nth 3 info))))))
6721 (setq gnus-newsgroup-replied
6722 (copy-sequence (cdr (assq 'reply marked))))
6723 (setq gnus-newsgroup-expirable
6724 (copy-sequence (cdr (assq 'expire marked))))
6725 (setq gnus-newsgroup-killed
6726 (copy-sequence (cdr (assq 'killed marked))))
6727 (setq gnus-newsgroup-bookmarks
6728 (copy-sequence (cdr (assq 'bookmark marked))))
6729 (setq gnus-newsgroup-dormant
6730 (copy-sequence (cdr (assq 'dormant marked))))
6731 (setq gnus-newsgroup-scored
6732 (copy-sequence (cdr (assq 'score marked))))
6733 (setq gnus-newsgroup-processable nil)))
6734 ;; Check whether auto-expire is to be done in this group.
6735 (setq gnus-newsgroup-auto-expire
6736 (or (and (stringp gnus-auto-expirable-newsgroups)
6737 (string-match gnus-auto-expirable-newsgroups group))
6738 (memq 'auto-expire (nth 5 info))))
6739 ;; First and last article in this newsgroup.
6740 (and gnus-newsgroup-headers
6741 (setq gnus-newsgroup-begin
6742 (mail-header-number (car gnus-newsgroup-headers)))
6743 (setq gnus-newsgroup-end
6745 (gnus-last-element gnus-newsgroup-headers))))
6746 (setq gnus-reffed-article-number -1)
6747 ;; GROUP is successfully selected.
6748 (or gnus-newsgroup-headers t)))))
6750 (defun gnus-articles-to-read (group read-all)
6751 ;; Find out what articles the user wants to read.
6753 ;; Select all articles if `read-all' is non-nil, or if all the
6754 ;; unread articles are dormant articles.
6755 (if (or (and read-all (not (numberp read-all)))
6756 (= (length gnus-newsgroup-unreads)
6757 (length gnus-newsgroup-dormant)))
6758 (gnus-uncompress-range
6759 (gnus-gethash group gnus-active-hashtb))
6760 gnus-newsgroup-unreads))
6761 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6762 (scored (length scored-list))
6763 (number (length articles))
6764 (marked (+ (length gnus-newsgroup-marked)
6765 (length gnus-newsgroup-dormant)))
6772 (cond ((and (or (<= scored marked)
6774 (numberp gnus-large-newsgroup)
6775 (> number gnus-large-newsgroup))
6779 "How many articles from %s (default %d): "
6780 gnus-newsgroup-name number))))
6781 (if (string-match "^[ \t]*$" input)
6783 ((and (> scored marked) (< scored number))
6787 "%s %s (%d scored, %d total): "
6788 "How many articles from"
6789 group scored number))))
6790 (if (string-match "^[ \t]*$" input)
6794 (setq select (if (stringp select) (string-to-number select) select))
6795 (if (or (null select) (zerop select))
6797 (if (and (not (zerop scored)) (<= (abs select) scored))
6799 (setq articles (sort scored-list '<))
6800 (setq number (length articles)))
6801 (setq articles (copy-sequence articles)))
6803 (if (< (abs select) number)
6805 ;; Select the N oldest articles.
6806 (setcdr (nthcdr (1- (abs select)) articles) nil)
6807 ;; Select the N most recent articles.
6808 (setq articles (nthcdr (- number select) articles))))
6809 (setq gnus-newsgroup-unselected
6810 (gnus-sorted-intersection
6811 gnus-newsgroup-unreads
6812 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6815 (defun gnus-killed-articles (killed articles)
6818 (if (inline (gnus-member-of-range (car articles) killed))
6819 (setq out (cons (car articles) out)))
6820 (setq articles (cdr articles)))
6823 (defun gnus-adjust-marked-articles (info &optional active)
6824 "Remove all marked articles that are no longer legal."
6825 (let ((marked-lists (nth 3 info))
6826 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6828 ;; There are many types of marked articles.
6830 (setq m (cdr (setq prev (car marked-lists))))
6831 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6832 ;; Make sure that all ticked articles are a subset of the
6833 ;; unread/unselected articles.
6835 (if (or (memq (car m) gnus-newsgroup-unreads)
6836 (memq (car m) gnus-newsgroup-unselected))
6838 (setcdr prev (cdr m)))
6840 ((eq 'score (car prev))
6841 ;; Scored articles should be a subset of
6842 ;; unread/unselected articles.
6844 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6845 (memq (car (car m)) gnus-newsgroup-unreads))
6847 (setcdr prev (cdr m)))
6849 ((eq 'bookmark (car prev))
6850 ;; Bookmarks should be a subset of active articles.
6852 (if (< (car (car m)) (car active))
6853 (setcdr prev (cdr m))
6856 ((eq 'killed (car prev))
6857 ;; Articles that have been through the kill process are
6858 ;; to be a subset of active articles.
6859 (while (and m (< (or (and (numberp (car m)) (car m))
6862 (setcdr prev (cdr m))
6864 (if (and m (< (or (and (numberp (car m)) (car m))
6867 (setcar (if (numberp (car m)) m (car m)) (car active))))
6868 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6869 ;; The replied and expirable articles have to be articles
6872 (if (< (car m) (car active))
6873 (setcdr prev (cdr m))
6876 (setq marked-lists (cdr marked-lists)))
6877 ;; Remove all lists that are empty.
6878 (setq marked-lists (nth 3 info))
6881 (while (= 1 (length (car marked-lists)))
6882 (setq marked-lists (cdr marked-lists)))
6883 (setq m (cdr (setq prev marked-lists)))
6885 (if (= 1 (length (car m)))
6886 (setcdr prev (cdr m))
6889 (setcar (nthcdr 3 info) marked-lists)))
6890 ;; Finally, if there are no marked lists at all left, and if there
6891 ;; are no elements after the lists in the info list, we just chop
6892 ;; the info list off before the marked lists.
6893 (and (null marked-lists)
6894 (not (nthcdr 4 info))
6895 (setcdr (nthcdr 2 info) nil)))
6898 (defun gnus-set-marked-articles
6899 (info ticked replied expirable killed dormant bookmark score)
6900 "Enter the various lists of marked articles into the newsgroup info list."
6902 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6903 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6904 (and expirable (setq newmarked (cons (cons 'expire expirable)
6906 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6907 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6908 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6910 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6913 (setcar (nthcdr 3 info) newmarked)
6914 (and (not newmarked)
6915 (not (nthcdr 4 info))
6916 (setcdr (nthcdr 2 info) nil)))
6918 (setcdr (nthcdr 2 info) (list newmarked))))))
6920 (defun gnus-add-marked-articles (group type articles &optional info force)
6921 ;; Add ARTICLES of TYPE to the info of GROUP.
6922 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6923 ;; add, but replace marked articles of TYPE with ARTICLES.
6924 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6927 (and (not (setq marked (nthcdr 3 info)))
6928 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6929 (and (not (setq m (assq type (car marked))))
6930 (setcar marked (cons (cons type articles) (car marked))))
6933 (nconc m articles)))))
6935 (defun gnus-set-mode-line (where)
6936 "This function sets the mode line of the article or summary buffers.
6937 If WHERE is `summary', the summary mode line format will be used."
6938 (if (memq where gnus-updated-mode-lines)
6941 (set-buffer gnus-summary-buffer)
6942 (let* ((mformat (if (eq where 'article)
6943 gnus-article-mode-line-format-spec
6944 gnus-summary-mode-line-format-spec))
6945 (group-name gnus-newsgroup-name)
6946 (article-number (or gnus-current-article 0))
6947 (unread (- (length gnus-newsgroup-unreads)
6948 (length gnus-newsgroup-dormant)))
6949 (unread-and-unticked
6950 (- unread (length gnus-newsgroup-marked)))
6951 (unselected (length gnus-newsgroup-unselected))
6952 (unread-and-unselected
6953 (cond ((and (zerop unread-and-unticked)
6954 (zerop unselected)) "")
6956 (format "{%d more}" unread-and-unticked))
6957 (t (format "{%d(+%d) more}"
6958 unread-and-unticked unselected))))
6960 (if gnus-current-headers
6961 (mail-header-subject gnus-current-headers) ""))
6962 (max-len (and gnus-mode-non-string-length
6963 (- (frame-width) gnus-mode-non-string-length)))
6964 header);; passed as argument to any user-format-funcs
6965 (setq mode-string (eval mformat))
6966 (or (numberp max-len)
6967 (setq max-len (length mode-string)))
6968 (if (< max-len 4) (setq max-len 4))
6969 (if (> (length mode-string) max-len)
6970 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6971 ;; function `substring' might cut on a middle
6972 ;; of multi-octet character.
6974 (concat (gnus-truncate-string mode-string (- max-len 3))
6976 (setq mode-string (format (format "%%-%ds" max-len)
6978 (setq mode-line-buffer-identification mode-string)
6979 (set-buffer-modified-p t))))
6981 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6982 "Go through the HEADERS list and add all Xrefs to a hash table.
6983 The resulting hash table is returned, or nil if no Xrefs were found."
6984 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6986 (gnus-group-foreign-p from-newsgroup)
6988 (assoc (symbol-name (car from-method))
6989 gnus-valid-select-methods))))
6990 (gnus-group-real-prefix from-newsgroup)))
6991 (xref-hashtb (make-vector 63 0))
6992 start group entry number xrefs header)
6994 (setq header (car headers))
6995 (if (and (setq xrefs (mail-header-xref header))
6996 (not (memq (mail-header-number header) unreads)))
6999 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
7000 (setq start (match-end 0))
7001 (setq group (concat prefix (substring xrefs (match-beginning 1)
7004 (string-to-int (substring xrefs (match-beginning 2)
7006 (if (setq entry (gnus-gethash group xref-hashtb))
7007 (setcdr entry (cons number (cdr entry)))
7008 (gnus-sethash group (cons number nil) xref-hashtb)))))
7009 (setq headers (cdr headers)))
7010 (if start xref-hashtb nil)))
7012 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
7013 "Look through all the headers and mark the Xrefs as read."
7014 (let ((virtual (memq 'virtual
7015 (assoc (symbol-name (car (gnus-find-method-for-group
7017 gnus-valid-select-methods)))
7018 name entry info xref-hashtb idlist method
7021 (set-buffer gnus-group-buffer)
7022 (if (setq xref-hashtb
7023 (gnus-create-xref-hashtb from-newsgroup headers unreads))
7026 (if (string= from-newsgroup (setq name (symbol-name group)))
7028 (setq idlist (symbol-value group))
7029 ;; Dead groups are not updated.
7031 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7033 (if (stringp (setq nth4 (nth 4 info)))
7034 (setq nth4 (gnus-server-to-method nth4))))
7035 ;; Only do the xrefs if the group has the same
7036 ;; select method as the group we have just read.
7037 (or (gnus-methods-equal-p
7038 nth4 (gnus-find-method-for-group from-newsgroup))
7041 (setq method (gnus-find-method-for-group
7043 (and (equal (car nth4) (car method))
7044 (equal (nth 1 nth4) (nth 1 method))))
7045 gnus-use-cross-reference
7046 (or (not (eq gnus-use-cross-reference t))
7048 ;; Only do cross-references on subscribed
7049 ;; groups, if that is what is wanted.
7050 (<= (nth 1 info) gnus-level-subscribed)))
7051 (gnus-group-make-articles-read name idlist expirable))))
7054 (defun gnus-group-make-articles-read (group articles expirable)
7056 (entry (gnus-gethash group gnus-newsrc-hashtb))
7057 (info (nth 2 entry))
7058 (active (gnus-gethash group gnus-active-hashtb))
7059 exps expirable range)
7060 ;; First peel off all illegal article numbers.
7062 (let ((ids articles)
7063 (ticked (cdr (assq 'tick (nth 3 info))))
7064 (dormant (cdr (assq 'dormant (nth 3 info))))
7069 (if (and first (> id (cdr active)))
7071 ;; We'll end up in this situation in one particular
7072 ;; obscure situation. If you re-scan a group and get
7073 ;; a new article that is cross-posted to a different
7074 ;; group that has not been re-scanned, you might get
7075 ;; crossposted article that has a higher number than
7076 ;; Gnus believes possible. So we re-activate this
7077 ;; group as well. This might mean doing the
7078 ;; crossposting thingie will *increase* the number
7079 ;; of articles in some groups. Tsk, tsk.
7080 (setq active (or (gnus-activate-group group) active))))
7081 (if (or (> id (cdr active))
7085 (setq articles (delq id articles)))
7086 (and (memq id expirable)
7087 (setq exps (cons id exps)))
7088 (setq ids (cdr ids)))))
7089 ;; Update expirable articles.
7090 (gnus-add-marked-articles nil 'expirable exps info)
7094 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7095 (setcar (nthcdr 2 info)
7099 (setq articles (sort articles '<)))))
7100 ;; Then we have to re-compute how many unread
7101 ;; articles there are in this group.
7106 (setq num (- (1+ (cdr active)) (car active))))
7107 ((not (listp (cdr range)))
7108 (setq num (- (cdr active) (- (1+ (cdr range))
7112 (if (numberp (car range))
7114 (setq num (+ num (- (1+ (cdr (car range)))
7115 (car (car range))))))
7116 (setq range (cdr range)))
7117 (setq num (- (cdr active) num))))
7118 ;; Update the number of unread articles.
7122 (length (cdr (assq 'tick (nth 3 info))))
7124 (cdr (assq 'dormant (nth 3 info)))))))
7125 ;; Update the group buffer.
7126 (gnus-group-update-group group t)))))
7128 (defun gnus-methods-equal-p (m1 m2)
7129 (let ((m1 (or m1 gnus-select-method))
7130 (m2 (or m2 gnus-select-method)))
7132 (and (eq (car m1) (car m2))
7133 (or (not (memq 'address (assoc (symbol-name (car m1))
7134 gnus-valid-select-methods)))
7135 (equal (nth 1 m1) (nth 1 m2)))))))
7137 (defsubst gnus-header-value ()
7138 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7140 (defvar gnus-newsgroup-none-id 0)
7142 (defun gnus-get-newsgroup-headers ()
7143 (setq gnus-article-internal-prepare-hook nil)
7144 (let ((cur nntp-server-buffer)
7145 (dependencies gnus-newsgroup-dependencies)
7146 headers id dep end ref)
7148 (set-buffer nntp-server-buffer)
7149 (goto-char (point-min))
7150 ;; Search to the beginning of the next header. Error messages
7151 ;; do not begin with 2 or 3.
7152 (while (re-search-forward "^[23][0-9]+ " nil t)
7153 (let ((header (make-vector 9 nil))
7154 (case-fold-search t)
7159 (mail-header-set-number header (read cur))
7160 ;; This implementation of this function, with nine
7161 ;; search-forwards instead of the one re-search-forward and
7162 ;; a case (which basically was the old function) is actually
7163 ;; about twice as fast, even though it looks messier. You
7164 ;; can't have everything, I guess. Speed and elegance
7165 ;; doesn't always come hand in hand.
7167 (narrow-to-region (point) (or (save-excursion
7168 (search-forward "\n.\n" nil t))
7170 (if (search-forward "\nfrom: " nil t)
7171 (mail-header-set-from header (gnus-header-value))
7172 (mail-header-set-from header "(nobody)"))
7174 (if (search-forward "\nsubject: " nil t)
7175 (mail-header-set-subject header (gnus-header-value))
7176 (mail-header-set-subject header "(none)"))
7178 (and (search-forward "\nxref: " nil t)
7179 (mail-header-set-xref header (gnus-header-value)))
7181 (or (numberp (and (search-forward "\nlines: " nil t)
7182 (mail-header-set-lines header (read cur))))
7183 (mail-header-set-lines header 0))
7185 (and (search-forward "\ndate: " nil t)
7186 (mail-header-set-date header (gnus-header-value)))
7188 (if (search-forward "\nmessage-id: " nil t)
7189 (mail-header-set-id header (setq id (gnus-header-value)))
7190 ;; If there was no message-id, we just fake one to make
7191 ;; subsequent routines simpler.
7194 (setq id (concat "none+"
7196 (setq gnus-newsgroup-none-id
7197 (1+ gnus-newsgroup-none-id)))))))
7199 (if (search-forward "\nreferences: " nil t)
7201 (mail-header-set-references header (gnus-header-value))
7202 (setq end (match-end 0))
7209 (search-backward ">" end t)
7212 (search-backward "<" end t)
7214 ;; Get the references from the in-reply-to header if there
7215 ;; ware no references and the in-reply-to header looks
7217 (if (and (search-forward "\nin-reply-to: " nil t)
7218 (setq in-reply-to (gnus-header-value))
7219 (string-match "<[^>]+>" in-reply-to))
7221 (mail-header-set-references
7223 (setq ref (substring in-reply-to (match-beginning 0)
7225 (setq ref (downcase ref)))
7227 ;; We do some threading while we read the headers. The
7228 ;; message-id and the last reference are both entered into
7229 ;; the same hash table. Some tippy-toeing around has to be
7230 ;; done in case an article has arrived before the article
7231 ;; which it refers to.
7232 (if (boundp (setq dep (intern (downcase id) dependencies)))
7233 (if (car (symbol-value dep))
7234 ;; An article with this Message-ID has already
7235 ;; been seen, so we ignore this one, except we add
7236 ;; any additional Xrefs (in case the two articles
7237 ;; came from different servers.
7239 (mail-header-set-xref
7240 (car (symbol-value dep))
7241 (concat (or (mail-header-xref
7242 (car (symbol-value dep))) "")
7243 (or (mail-header-xref header) "")))
7245 (setcar (symbol-value dep) header))
7246 (set dep (list header)))
7249 (if (boundp (setq dep (intern ref dependencies)))
7250 (setcdr (symbol-value dep)
7251 (cons header (cdr (symbol-value dep))))
7252 (set dep (list nil header)))
7253 (setq headers (cons header headers))))
7254 (goto-char (point-max))))))
7255 (nreverse headers)))
7257 ;; The following macros and functions were written by Felix Lee
7258 ;; <flee@cse.psu.edu>.
7260 (defmacro gnus-nov-read-integer ()
7262 (if (= (following-char) ?\t)
7264 (let ((num (condition-case nil (read buffer) (error nil))))
7265 (if (numberp num) num 0)))
7266 (or (eobp) (forward-char 1))))
7268 (defmacro gnus-nov-skip-field ()
7269 '(search-forward "\t" eol 'move))
7271 (defmacro gnus-nov-field ()
7272 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7274 ;; Goes through the xover lines and returns a list of vectors
7275 (defun gnus-get-newsgroup-headers-xover (sequence)
7276 "Parse the news overview data in the server buffer, and return a
7277 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7278 ;; Get the Xref when the users reads the articles since most/some
7279 ;; NNTP servers do not include Xrefs when using XOVER.
7280 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7281 (let ((cur nntp-server-buffer)
7282 (dependencies gnus-newsgroup-dependencies)
7283 number headers header)
7285 (set-buffer nntp-server-buffer)
7286 (goto-char (point-min))
7287 (while (and sequence (not (eobp)))
7288 (setq number (read cur))
7289 (while (and sequence (< (car sequence) number))
7290 (setq sequence (cdr sequence)))
7292 (eq number (car sequence))
7294 (setq sequence (cdr sequence))
7296 (inline (gnus-nov-parse-line number dependencies)))
7297 (setq headers (cons header headers)))))
7299 (setq headers (nreverse headers)))
7302 ;; This function has to be called with point after the article number
7303 ;; on the beginning of the line.
7304 (defun gnus-nov-parse-line (number dependencies)
7306 (eol (gnus-point-at-eol))
7307 (buffer (current-buffer))
7310 ;; overview: [num subject from date id refs chars lines misc]
7311 (narrow-to-region (point) eol)
7318 (gnus-nov-field) ; subject
7319 (gnus-nov-field) ; from
7320 (gnus-nov-field) ; date
7321 (setq id (or (gnus-nov-field)
7324 (setq none (1+ none)))))) ; id
7327 (let ((beg (point)))
7328 (search-forward "\t" eol)
7329 (if (search-backward ">" beg t)
7335 (search-backward "<" beg t)
7338 (gnus-nov-field)) ; refs
7339 (gnus-nov-read-integer) ; chars
7340 (gnus-nov-read-integer) ; lines
7341 (if (= (following-char) ?\n)
7343 (gnus-nov-field)) ; misc
7347 (message "Strange nov line.")
7353 ;; We build the thread tree.
7355 (if (boundp (setq dep (intern (downcase id) dependencies)))
7356 (if (car (symbol-value dep))
7357 ;; An article with this Message-ID has already been seen,
7358 ;; so we ignore this one, except we add any additional
7359 ;; Xrefs (in case the two articles came from different
7362 (mail-header-set-xref
7363 (car (symbol-value dep))
7364 (concat (or (mail-header-xref (car (symbol-value dep))) "")
7365 (or (mail-header-xref header) "")))
7367 (setcar (symbol-value dep) header))
7368 (set dep (list header))))
7371 (if (boundp (setq dep (intern (or ref "none")
7373 (setcdr (symbol-value dep)
7374 (cons header (cdr (symbol-value dep))))
7375 (set dep (list nil header)))))
7378 (defun gnus-article-get-xrefs ()
7379 "Fill in the Xref value in `gnus-current-headers', if necessary.
7380 This is meant to be called in `gnus-article-internal-prepare-hook'."
7381 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7382 gnus-current-headers)))
7383 (or (not gnus-use-cross-reference)
7385 (and (mail-header-xref headers)
7386 (not (string= (mail-header-xref headers) "")))
7387 (let ((case-fold-search t)
7390 (gnus-narrow-to-headers)
7391 (goto-char (point-min))
7392 (if (or (and (eq (downcase (following-char)) ?x)
7393 (looking-at "Xref:"))
7394 (search-forward "\nXref:" nil t))
7396 (goto-char (1+ (match-end 0)))
7397 (setq xref (buffer-substring (point)
7398 (progn (end-of-line) (point))))
7399 (mail-header-set-xref headers xref))))))))
7401 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7402 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7404 (defun gnus-make-headers-hashtable-by-number ()
7405 "Make hashtable for the variable gnus-newsgroup-headers by number."
7407 (set-buffer gnus-summary-buffer)
7408 (let ((headers gnus-newsgroup-headers)
7410 (setq gnus-newsgroup-headers-hashtb-by-number
7411 (gnus-make-hashtable (length headers)))
7413 (setq header (car headers))
7414 (gnus-sethash (int-to-string (mail-header-number header))
7415 header gnus-newsgroup-headers-hashtb-by-number)
7416 (setq headers (cdr headers))))))
7418 (defun gnus-more-header-backward ()
7419 "Find new header backward."
7420 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7421 (artnum gnus-newsgroup-begin)
7423 (while (and (not header)
7425 (setq artnum (1- artnum))
7426 (setq header (gnus-read-header artnum)))
7429 (defun gnus-more-header-forward (&optional backward)
7430 "Find new header forward.
7431 If BACKWARD, find new header backward instead."
7433 (gnus-more-header-backward)
7434 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7435 (artnum gnus-newsgroup-end)
7437 (while (and (not header)
7439 (setq artnum (1+ artnum))
7440 (setq header (gnus-read-header artnum)))
7443 (defun gnus-extend-newsgroup (header &optional backward)
7444 "Extend newsgroup selection with HEADER.
7445 Optional argument BACKWARD means extend toward backward."
7447 (let ((artnum (mail-header-number header)))
7448 (setq gnus-newsgroup-headers
7450 (cons header gnus-newsgroup-headers)
7451 (nconc gnus-newsgroup-headers (list header))))
7452 (setq gnus-newsgroup-unselected
7453 (delq artnum gnus-newsgroup-unselected))
7454 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7455 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7457 (defun gnus-summary-work-articles (n)
7458 "Return a list of articles to be worked upon. The prefix argument,
7459 the list of process marked articles, and the current article will be
7460 taken into consideration."
7462 (if (and n (numberp n))
7463 (let ((backward (< n 0))
7467 (setq articles (cons (gnus-summary-article-number)
7469 (gnus-summary-search-forward nil nil backward))
7471 (sort articles (function <)))
7472 (or (reverse gnus-newsgroup-processable)
7473 (list (gnus-summary-article-number))))))
7475 (defun gnus-summary-search-group (&optional backward use-level)
7476 "Search for next unread newsgroup.
7477 If optional argument BACKWARD is non-nil, search backward instead."
7479 (set-buffer gnus-group-buffer)
7480 (if (gnus-group-search-forward
7481 backward nil (if use-level (gnus-group-group-level) nil))
7482 (gnus-group-group-name))))
7484 (defun gnus-summary-best-group (&optional exclude-group)
7485 "Find the name of the best unread group.
7486 If EXCLUDE-GROUP, do not go to this group."
7488 (set-buffer gnus-group-buffer)
7490 (gnus-group-best-unread-group exclude-group))))
7492 (defun gnus-subject-equal (s1 s2)
7494 ((null gnus-summary-gather-subject-limit)
7495 (equal (gnus-simplify-subject-re s1)
7496 (gnus-simplify-subject-re s2)))
7497 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7498 (equal (gnus-simplify-subject-fuzzy s1)
7499 (gnus-simplify-subject-fuzzy s2)))
7500 ((numberp gnus-summary-gather-subject-limit)
7501 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7502 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7506 (defun gnus-summary-search-subject (&optional backward unread subject)
7507 "Search for article forward.
7508 If BACKWARD is non-nil, search backward.
7509 If UNREAD is non-nil, only unread articles are selected.
7510 If SUBJECT is non-nil, the article which has the same subject will be
7512 (let ((func (if backward 'previous-single-property-change
7513 'next-single-property-change))
7518 (and gnus-summary-check-current unread
7519 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7523 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7526 (setq pos (funcall func (point) 'gnus-number))
7527 (goto-char (if backward (1- pos) pos))
7531 (eq (get-text-property (point) 'gnus-mark)
7535 (inline (gnus-summary-subject-string)))
7537 (gnus-subject-equal subject psubject)))))))
7538 (if backward (if (bobp) nil (forward-char -1) t)
7539 (if (eobp) nil (forward-char 1) t)))))
7541 (progn (goto-char beg) nil)
7543 (get-text-property (point) 'gnus-number)
7544 (gnus-summary-position-cursor)))))
7546 (defun gnus-summary-pseudo-article ()
7547 "The thread level of the article on the current line."
7548 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7550 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7551 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7552 (defun gnus-summary-article-score ()
7553 "Return current article score."
7554 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7555 gnus-summary-default-score 0))
7557 (defun gnus-summary-recenter ()
7558 "Center point in the summary window.
7559 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7560 displayed, no centering will be performed."
7561 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7562 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7563 (let* ((top (cond ((< (window-height) 4) 0)
7564 ((< (window-height) 7) 1)
7566 (height (1- (window-height)))
7567 (bottom (save-excursion (goto-char (point-max))
7568 (forward-line (- height))
7570 (window (get-buffer-window (current-buffer))))
7572 ;; The user has to want it,
7573 gnus-auto-center-summary
7574 ;; the article buffer must be displayed,
7575 (get-buffer-window gnus-article-buffer)
7576 ;; Set the window start to either `bottom', which is the biggest
7577 ;; possible valid number, or the second line from the top,
7578 ;; whichever is the least.
7580 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7582 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7583 (defun gnus-short-group-name (group &optional levels)
7584 "Collapse GROUP name LEVELS."
7585 (let* ((name "") (foreign "") (depth -1) (skip 1)
7588 (while (string-match "\\." group skip)
7589 (setq skip (match-end 0)
7592 (if (string-match ":" group)
7593 (setq foreign (substring group 0 (match-end 0))
7594 group (substring group (match-end 0))))
7596 (if (and (string-match "\\." group) (> levels 0))
7597 (setq name (concat name (substring group 0 1))
7598 group (substring group (match-end 0))
7600 name (concat name "."))
7601 (setq name (concat foreign name group)
7605 (defun gnus-summary-jump-to-group (newsgroup)
7606 "Move point to NEWSGROUP in group mode buffer."
7607 ;; Keep update point of group mode buffer if visible.
7608 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7609 (save-window-excursion
7610 ;; Take care of tree window mode.
7611 (if (get-buffer-window gnus-group-buffer)
7612 (pop-to-buffer gnus-group-buffer))
7613 (gnus-group-jump-to-group newsgroup))
7615 ;; Take care of tree window mode.
7616 (if (get-buffer-window gnus-group-buffer)
7617 (pop-to-buffer gnus-group-buffer)
7618 (set-buffer gnus-group-buffer))
7619 (gnus-group-jump-to-group newsgroup))))
7621 ;; This function returns a list of article numbers based on the
7622 ;; difference between the ranges of read articles in this group and
7623 ;; the range of active articles.
7624 (defun gnus-list-of-unread-articles (group)
7625 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7626 (active (gnus-gethash group gnus-active-hashtb))
7629 ;; If none are read, then all are unread.
7631 (setq first (car active))
7632 ;; If the range of read articles is a single range, then the
7633 ;; first unread article is the article after the last read
7634 ;; article. Sounds logical, doesn't it?
7635 (if (not (listp (cdr read)))
7636 (setq first (1+ (cdr read)))
7637 ;; `read' is a list of ranges.
7638 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7639 (car (car read)))) 1)
7643 (while (< first nlast)
7644 (setq unread (cons first unread))
7645 (setq first (1+ first))))
7646 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7647 (setq nlast (if (atom (car (cdr read)))
7649 (car (car (cdr read)))))
7650 (setq read (cdr read)))))
7651 ;; And add the last unread articles.
7652 (while (<= first last)
7653 (setq unread (cons first unread))
7654 (setq first (1+ first)))
7655 ;; Return the list of unread articles.
7658 (defun gnus-list-of-read-articles (group)
7659 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7660 (active (gnus-gethash group gnus-active-hashtb)))
7662 (gnus-sorted-complement
7663 (gnus-uncompress-range active)
7664 (gnus-list-of-unread-articles group)))))
7666 ;; Various summary commands
7668 (defun gnus-summary-universal-argument ()
7669 "Perform any operation on all articles marked with the process mark."
7671 (gnus-set-global-variables)
7672 (let ((articles (reverse gnus-newsgroup-processable))
7674 (or articles (error "No articles marked"))
7675 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7676 (error "Undefined key"))
7678 (gnus-summary-goto-subject (car articles))
7679 (command-execute func)
7680 (gnus-summary-remove-process-mark (car articles))
7681 (setq articles (cdr articles)))))
7683 (defun gnus-summary-toggle-truncation (&optional arg)
7684 "Toggle truncation of summary lines.
7685 With arg, turn line truncation on iff arg is positive."
7687 (setq truncate-lines
7688 (if (null arg) (not truncate-lines)
7689 (> (prefix-numeric-value arg) 0)))
7692 (defun gnus-summary-reselect-current-group (&optional all)
7693 "Once exit and then reselect the current newsgroup.
7694 The prefix argument ALL means to select all articles."
7696 (gnus-set-global-variables)
7697 (let ((current-subject (gnus-summary-article-number))
7698 (group gnus-newsgroup-name))
7699 (setq gnus-newsgroup-begin nil)
7700 (gnus-summary-exit t)
7701 ;; We have to adjust the point of group mode buffer because the
7702 ;; current point was moved to the next unread newsgroup by
7704 (gnus-summary-jump-to-group group)
7705 (gnus-group-read-group all t)
7706 (gnus-summary-goto-subject current-subject)))
7708 (defun gnus-summary-rescan-group (&optional all)
7709 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7711 (gnus-set-global-variables)
7712 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7713 (let ((group gnus-newsgroup-name))
7715 (gnus-summary-jump-to-group group)
7717 (set-buffer gnus-group-buffer)
7718 (gnus-group-get-new-news-this-group 1))
7719 (gnus-summary-jump-to-group group)
7720 (gnus-group-read-group all)))
7722 (defun gnus-summary-update-info ()
7723 (let* ((group gnus-newsgroup-name))
7724 (if gnus-newsgroup-kill-headers
7725 (setq gnus-newsgroup-killed
7726 (gnus-compress-sequence
7728 (gnus-set-sorted-intersection
7729 (gnus-uncompress-range gnus-newsgroup-killed)
7730 (setq gnus-newsgroup-unselected
7731 (sort gnus-newsgroup-unselected '<)))
7732 (setq gnus-newsgroup-unreads
7733 (sort gnus-newsgroup-unreads '<))) t)))
7734 (or (listp (cdr gnus-newsgroup-killed))
7735 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7736 (let ((headers gnus-newsgroup-headers))
7737 (gnus-close-group group)
7738 (run-hooks 'gnus-exit-group-hook)
7739 (gnus-update-read-articles
7740 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7741 gnus-newsgroup-marked
7742 t gnus-newsgroup-replied gnus-newsgroup-expirable
7743 gnus-newsgroup-killed gnus-newsgroup-dormant
7744 gnus-newsgroup-bookmarks
7745 (and gnus-save-score gnus-newsgroup-scored))
7746 (and gnus-use-cross-reference
7747 (gnus-mark-xrefs-as-read
7748 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7749 ;; Do adaptive scoring, and possibly save score files.
7750 (and gnus-newsgroup-adaptive
7751 (gnus-score-adaptive))
7752 (and gnus-use-scoring
7753 (fboundp 'gnus-score-save)
7754 (funcall 'gnus-score-save))
7755 ;; Do not switch windows but change the buffer to work.
7756 (set-buffer gnus-group-buffer)
7757 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7758 (gnus-group-update-group group)))))
7760 (defun gnus-summary-exit (&optional temporary)
7761 "Exit reading current newsgroup, and then return to group selection mode.
7762 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7764 (gnus-set-global-variables)
7765 (gnus-kill-save-kill-buffer)
7766 (let* ((group gnus-newsgroup-name)
7767 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7768 gnus-newsgroup-name))))
7770 (buf (current-buffer)))
7771 (run-hooks 'gnus-summary-prepare-exit-hook)
7772 ;; Make all changes in this group permanent.
7773 (gnus-summary-update-info)
7775 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7776 ;; Make sure where I was, and go to next newsgroup.
7777 (set-buffer gnus-group-buffer)
7780 (gnus-group-jump-to-group group)
7781 (gnus-group-next-unread-group 1)))
7784 ;; We set all buffer-local variables to nil. It is unclear why
7785 ;; this is needed, but if we don't, buffer-local variables are
7786 ;; not garbage-collected, it seems. This would the lead to en
7787 ;; ever-growing Emacs.
7789 (gnus-summary-clear-local-variables)
7790 ;; We clear the global counterparts of the buffer-local
7791 ;; variables as well, just to be on the safe side.
7792 (gnus-configure-windows 'group 'force)
7793 (gnus-summary-clear-local-variables)
7794 ;; Return to group mode buffer.
7795 (if (eq mode 'gnus-summary-mode)
7796 (gnus-kill-buffer buf))
7797 (if (get-buffer gnus-article-buffer)
7798 (bury-buffer gnus-article-buffer))
7799 (setq gnus-current-select-method gnus-select-method)
7800 (pop-to-buffer gnus-group-buffer)
7801 (if (not quit-config)
7803 (gnus-group-jump-to-group group)
7804 (gnus-group-next-unread-group 1))
7805 (if (not (buffer-name (car quit-config)))
7806 (gnus-configure-windows 'group 'force)
7807 (set-buffer (car quit-config))
7808 (and (eq major-mode 'gnus-summary-mode)
7809 (gnus-set-global-variables))
7810 (gnus-configure-windows (cdr quit-config))))
7811 (run-hooks 'gnus-summary-exit-hook))))
7813 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7814 (defun gnus-summary-exit-no-update (&optional no-questions)
7815 "Quit reading current newsgroup without updating read article info."
7817 (gnus-set-global-variables)
7818 (let* ((group gnus-newsgroup-name)
7819 (quit-config (nth 1 (assoc 'quit-config
7820 (gnus-find-method-for-group group)))))
7821 (if (or no-questions
7823 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7825 (gnus-close-group group)
7826 (gnus-summary-clear-local-variables)
7827 (set-buffer gnus-group-buffer)
7828 (gnus-summary-clear-local-variables)
7829 ;; Return to group selection mode.
7830 (gnus-configure-windows 'group 'force)
7831 (if (get-buffer gnus-summary-buffer)
7832 (kill-buffer gnus-summary-buffer))
7833 (if (get-buffer gnus-article-buffer)
7834 (bury-buffer gnus-article-buffer))
7835 (if (equal (gnus-group-group-name) group)
7836 (gnus-group-next-unread-group 1))
7839 (if (not (buffer-name (car quit-config)))
7840 (gnus-configure-windows 'group 'force)
7841 (set-buffer (car quit-config))
7842 (and (eq major-mode 'gnus-summary-mode)
7843 (gnus-set-global-variables))
7844 (gnus-configure-windows (cdr quit-config)))))))))
7846 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7847 (defun gnus-summary-fetch-faq (group)
7848 "Fetch the FAQ for the current group."
7849 (interactive (list gnus-newsgroup-name))
7850 (let (gnus-faq-buffer)
7851 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group))
7852 (gnus-configure-windows 'summary-faq))))
7854 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7855 (defun gnus-summary-describe-group (&optional force)
7856 "Describe the current newsgroup."
7858 (gnus-group-describe-group force gnus-newsgroup-name))
7860 (defun gnus-summary-describe-briefly ()
7861 "Describe summary mode commands briefly."
7864 (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")))
7866 ;; Walking around group mode buffer from summary mode.
7868 (defun gnus-summary-next-group (&optional no-article target-group backward)
7869 "Exit current newsgroup and then select next unread newsgroup.
7870 If prefix argument NO-ARTICLE is non-nil, no article is selected
7871 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7872 previous group instead."
7874 (gnus-set-global-variables)
7875 (let ((current-group gnus-newsgroup-name)
7876 (current-buffer (current-buffer))
7878 ;; First we semi-exit this group to update Xrefs and all variables.
7879 ;; We can't do a real exit, because the window conf must remain
7880 ;; the same in case the user is prompted for info, and we don't
7881 ;; want the window conf to change before that...
7882 (gnus-summary-exit t)
7883 (while (not entered)
7884 ;; Then we find what group we are supposed to enter.
7885 (set-buffer gnus-group-buffer)
7886 (gnus-group-jump-to-group current-group)
7889 (if (eq gnus-keep-same-level 'best)
7890 (gnus-summary-best-group gnus-newsgroup-name)
7891 (gnus-summary-search-group backward gnus-keep-same-level))))
7892 (if (not target-group)
7893 ;; There are no further groups, so we return to the group
7896 (gnus-message 5 "Returning to the group buffer")
7898 (set-buffer current-buffer)
7899 (gnus-summary-exit))
7900 ;; We try to enter the target group.
7901 (gnus-group-jump-to-group target-group)
7902 (let ((unreads (gnus-group-group-unread)))
7903 (if (and (or (eq t unreads)
7904 (and unreads (not (zerop unreads))))
7905 (gnus-summary-read-group
7906 target-group nil no-article current-buffer))
7908 (setq current-group target-group
7909 target-group nil)))))))
7911 (defun gnus-summary-next-group-old (&optional no-article group backward)
7912 "Exit current newsgroup and then select next unread newsgroup.
7913 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7914 If BACKWARD, go to previous group instead."
7916 (gnus-set-global-variables)
7917 (let ((ingroup gnus-newsgroup-name)
7918 (sumbuf (current-buffer))
7920 (set-buffer gnus-group-buffer)
7922 (or (and (numberp (setq num (car (gnus-gethash
7923 group gnus-newsrc-hashtb))))
7927 (gnus-group-jump-to-group group)
7929 (gnus-group-jump-to-group ingroup))
7930 (gnus-summary-search-group backward)
7931 (let ((group (or group (gnus-summary-search-group backward))))
7933 (gnus-summary-exit t) ;Update all information.
7935 (gnus-summary-exit-no-update t)
7936 (gnus-group-jump-to-group ingroup)
7937 (setq group (gnus-summary-search-group backward))
7938 (gnus-message 5 "Selecting %s..." group)
7939 (set-buffer gnus-group-buffer)
7940 ;; We are now in group mode buffer.
7941 ;; Make sure group mode buffer point is on GROUP.
7942 (gnus-group-jump-to-group group)
7943 (if (not (eq gnus-auto-select-next 'quietly))
7945 (gnus-summary-read-group group nil no-article sumbuf)
7946 (and (string= gnus-newsgroup-name ingroup)
7947 (bufferp sumbuf) (buffer-name sumbuf)
7949 (set-buffer (setq gnus-summary-buffer sumbuf))
7950 (gnus-summary-exit-no-update t))))
7951 (let ((prevgroup group))
7952 (gnus-group-jump-to-group ingroup)
7953 (setq group (gnus-summary-search-group backward))
7954 (gnus-summary-read-group group nil no-article sumbuf)
7955 (while (and (string= gnus-newsgroup-name ingroup)
7957 (buffer-name sumbuf)
7958 (not (string= prevgroup (gnus-group-group-name))))
7959 (set-buffer gnus-group-buffer)
7960 (gnus-summary-read-group
7961 (setq prevgroup (gnus-group-group-name))
7962 nil no-article sumbuf))
7963 (and (string= prevgroup (gnus-group-group-name))
7964 ;; We have reached the final group in the group
7967 (if (buffer-name sumbuf)
7970 (gnus-summary-exit)))))))))))
7972 (defun gnus-summary-prev-group (&optional no-article)
7973 "Exit current newsgroup and then select previous unread newsgroup.
7974 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7976 (gnus-summary-next-group no-article nil t))
7978 ;; Walking around summary lines.
7980 (defun gnus-summary-first-subject (&optional unread)
7981 "Go to the first unread subject.
7982 If UNREAD is non-nil, go to the first unread article.
7983 Returns nil if there are no unread articles."
7987 (goto-char (point-min)))
7990 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7993 ;; There are no unread articles.
7994 (gnus-message 3 "No more unread articles")
7996 (gnus-summary-position-cursor)))
7998 (defun gnus-summary-next-subject (n &optional unread dont-display)
7999 "Go to next N'th summary line.
8000 If N is negative, go to the previous N'th subject line.
8001 If UNREAD is non-nil, only unread articles are selected.
8002 The difference between N and the actual number of steps taken is
8005 (let ((backward (< n 0))
8008 (gnus-summary-search-forward unread nil backward))
8010 (if (/= 0 n) (gnus-message 7 "No more%s articles"
8011 (if unread " unread" "")))
8014 (gnus-summary-recenter)
8015 (gnus-summary-position-cursor)))
8018 (defun gnus-summary-next-unread-subject (n)
8019 "Go to next N'th unread summary line."
8021 (gnus-summary-next-subject n t))
8023 (defun gnus-summary-prev-subject (n &optional unread)
8024 "Go to previous N'th summary line.
8025 If optional argument UNREAD is non-nil, only unread article is selected."
8027 (gnus-summary-next-subject (- n) unread))
8029 (defun gnus-summary-prev-unread-subject (n)
8030 "Go to previous N'th unread summary line."
8032 (gnus-summary-next-subject (- n) t))
8034 (defun gnus-summary-goto-subject (article)
8035 "Go the subject line of ARTICLE."
8039 (completing-read "Article number: "
8043 (int-to-string (mail-header-number headers))))
8044 gnus-newsgroup-headers)
8045 nil 'require-match))))
8046 (or article (error "No article number"))
8048 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
8049 'gnus-number article)))
8051 (gnus-summary-show-thread)
8052 ;; Skip dummy articles.
8053 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8060 (gnus-summary-position-cursor)))))
8062 ;; Walking around summary lines with displaying articles.
8064 (defun gnus-summary-expand-window (&optional arg)
8065 "Make the summary buffer take up the entire Emacs frame.
8066 Given a prefix, will force an `article' buffer configuration."
8068 (gnus-set-global-variables)
8070 (gnus-configure-windows 'article 'force)
8071 (gnus-configure-windows 'summary 'force)))
8073 (defun gnus-summary-display-article (article &optional all-header)
8074 "Display ARTICLE in article buffer."
8075 (gnus-set-global-variables)
8079 (gnus-article-prepare article all-header)
8080 (gnus-summary-show-thread)
8081 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8084 (gnus-summary-position-cursor)))
8085 (run-hooks 'gnus-select-article-hook)
8086 (gnus-summary-recenter)
8087 (gnus-summary-goto-subject article)
8088 ;; Successfully display article.
8089 (gnus-summary-update-line)
8090 (gnus-article-set-window-start
8091 (cdr (assq article gnus-newsgroup-bookmarks)))
8094 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8095 "Select the current article.
8096 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8097 non-nil, the article will be re-fetched even if it already present in
8098 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8100 (and (not pseudo) (gnus-summary-pseudo-article)
8101 (error "This is a pseudo-article."))
8102 (let ((article (or article (gnus-summary-article-number)))
8103 (all-headers (not (not all-headers))) ;Must be T or NIL.
8107 (set-buffer gnus-summary-buffer)
8108 (if (or (null gnus-current-article)
8109 (null gnus-article-current)
8110 (null (get-buffer gnus-article-buffer))
8111 (not (eq article (cdr gnus-article-current)))
8112 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8114 ;; The requested article is different from the current article.
8116 (gnus-summary-display-article article all-headers)
8118 (if (or all-headers gnus-show-all-headers)
8119 (gnus-article-show-all-headers))
8122 (gnus-article-set-window-start
8123 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8125 (defun gnus-summary-set-current-mark (&optional current-mark)
8126 "Obsolete function."
8129 (defun gnus-summary-next-article (&optional unread subject backward)
8130 "Select the next article.
8131 If UNREAD, only unread articles are selected.
8132 If SUBJECT, only articles with SUBJECT are selected.
8133 If BACKWARD, the previous article is selected instead of the next."
8135 (gnus-set-global-variables)
8138 ;; Is there such an article?
8139 ((and (gnus-summary-search-forward unread subject backward)
8140 (or (gnus-summary-display-article (gnus-summary-article-number))
8141 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8142 (gnus-summary-position-cursor))
8143 ;; If not, we try the first unread, if that is wanted.
8145 gnus-auto-select-same
8146 (or (gnus-summary-first-unread-article)
8147 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8148 (gnus-summary-position-cursor)
8149 (gnus-message 6 "Wrapped"))
8150 ;; Try to get next/previous article not displayed in this group.
8151 ((and gnus-auto-extend-newsgroup
8152 (not unread) (not subject)
8153 (setq header (gnus-more-header-forward backward)))
8154 (gnus-extend-newsgroup header backward)
8155 (let ((buffer-read-only nil))
8156 (goto-char (if backward (point-min) (point-max)))
8157 (gnus-summary-prepare-threads (list header)))
8158 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8159 gnus-newsgroup-end)))
8160 ;; Go to next/previous group.
8162 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8163 (gnus-summary-jump-to-group gnus-newsgroup-name))
8164 (let ((cmd last-command-char)
8166 (if (eq gnus-keep-same-level 'best)
8167 (gnus-summary-best-group gnus-newsgroup-name)
8168 (gnus-summary-search-group backward gnus-keep-same-level))))
8169 ;; For some reason, the group window gets selected. We change
8171 (select-window (get-buffer-window (current-buffer)))
8172 ;; Keep just the event type of CMD.
8173 ;(and (listp cmd) (setq cmd (car cmd)))
8174 ;; Select next unread newsgroup automagically.
8176 ((not gnus-auto-select-next)
8177 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8178 ((eq gnus-auto-select-next 'quietly)
8180 (if (assoc 'quit-config (gnus-find-method-for-group
8181 gnus-newsgroup-name))
8183 (gnus-message 7 "No more%s articles (%s)..."
8184 (if unread " unread" "")
8185 (if group (concat "selecting " group)
8187 (gnus-summary-next-group nil group backward)))
8189 (let ((keystrokes '(?\C-n ?\C-p))
8191 (while (or (null key) (memq key keystrokes))
8193 7 "No more%s articles%s" (if unread " unread" "")
8194 (if (and group (not (assoc 'quit-config
8195 (gnus-find-method-for-group
8196 gnus-newsgroup-name))))
8197 (format " (Type %s for %s [%s])"
8198 (single-key-description cmd) group
8199 (car (gnus-gethash group gnus-newsrc-hashtb)))
8200 (format " (Type %s to exit %s)"
8201 (single-key-description cmd)
8202 gnus-newsgroup-name)))
8203 ;; Confirm auto selection.
8204 (let* ((event (read-char)))
8205 (setq key (if (listp event) (car event) event))
8206 (if (memq key keystrokes)
8207 (let ((obuf (current-buffer)))
8208 (switch-to-buffer gnus-group-buffer)
8210 (gnus-group-jump-to-group group))
8212 (execute-kbd-macro (char-to-string key))
8214 (setq group (gnus-group-group-name))
8215 (switch-to-buffer obuf)))))
8217 (if (or (not group) (assoc 'quit-config
8218 (gnus-find-method-for-group
8219 gnus-newsgroup-name)))
8221 (gnus-summary-next-group nil group backward))
8222 (execute-kbd-macro (char-to-string key)))))))))))
8224 (defun gnus-summary-next-unread-article ()
8225 "Select unread article after current one."
8227 (gnus-summary-next-article t (and gnus-auto-select-same
8228 (gnus-summary-subject-string))))
8230 (defun gnus-summary-prev-article (&optional unread subject)
8231 "Select the article after the current one.
8232 If UNREAD is non-nil, only unread articles are selected."
8234 (gnus-summary-next-article unread subject t))
8236 (defun gnus-summary-prev-unread-article ()
8237 "Select unred article before current one."
8239 (gnus-summary-prev-article t (and gnus-auto-select-same
8240 (gnus-summary-subject-string))))
8242 (defun gnus-summary-next-page (&optional lines circular)
8243 "Show next page of selected article.
8244 If end of article, select next article.
8245 Argument LINES specifies lines to be scrolled up.
8246 If CIRCULAR is non-nil, go to the start of the article instead of
8247 instead of selecting the next article when reaching the end of the
8250 (setq gnus-summary-buffer (current-buffer))
8251 (gnus-set-global-variables)
8252 (let ((article (gnus-summary-article-number))
8254 (gnus-configure-windows 'article)
8255 (if (or (null gnus-current-article)
8256 (null gnus-article-current)
8257 (/= article (cdr gnus-article-current))
8258 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8259 ;; Selected subject is different from current article's.
8260 (gnus-summary-display-article article)
8261 (gnus-eval-in-buffer-window
8263 (setq endp (gnus-article-next-page lines)))
8266 (gnus-summary-beginning-of-article))
8268 (gnus-message 3 "End of message"))
8270 (gnus-summary-next-unread-article)))))
8271 (gnus-summary-recenter)
8272 (gnus-summary-position-cursor)))
8274 (defun gnus-summary-prev-page (&optional lines)
8275 "Show previous page of selected article.
8276 Argument LINES specifies lines to be scrolled down."
8278 (gnus-set-global-variables)
8279 (let ((article (gnus-summary-article-number)))
8280 (gnus-configure-windows 'article)
8281 (if (or (null gnus-current-article)
8282 (null gnus-article-current)
8283 (/= article (cdr gnus-article-current))
8284 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8285 ;; Selected subject is different from current article's.
8286 (gnus-summary-display-article article)
8287 (gnus-summary-recenter)
8288 (gnus-eval-in-buffer-window gnus-article-buffer
8289 (gnus-article-prev-page lines))))
8290 (gnus-summary-position-cursor))
8292 (defun gnus-summary-scroll-up (lines)
8293 "Scroll up (or down) one line current article.
8294 Argument LINES specifies lines to be scrolled up (or down if negative)."
8296 (gnus-set-global-variables)
8297 (gnus-configure-windows 'article)
8298 (or (gnus-summary-select-article nil nil 'pseudo)
8299 (gnus-eval-in-buffer-window
8302 (if (gnus-article-next-page lines)
8303 (gnus-message 3 "End of message")))
8305 (gnus-article-prev-page (- lines))))))
8306 (gnus-summary-recenter)
8307 (gnus-summary-position-cursor))
8309 (defun gnus-summary-next-same-subject ()
8310 "Select next article which has the same subject as current one."
8312 (gnus-set-global-variables)
8313 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8315 (defun gnus-summary-prev-same-subject ()
8316 "Select previous article which has the same subject as current one."
8318 (gnus-set-global-variables)
8319 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8321 (defun gnus-summary-next-unread-same-subject ()
8322 "Select next unread article which has the same subject as current one."
8324 (gnus-set-global-variables)
8325 (gnus-summary-next-article t (gnus-summary-subject-string)))
8327 (defun gnus-summary-prev-unread-same-subject ()
8328 "Select previous unread article which has the same subject as current one."
8330 (gnus-set-global-variables)
8331 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8333 (defun gnus-summary-first-unread-article ()
8334 "Select the first unread article.
8335 Return nil if there are no unread articles."
8337 (gnus-set-global-variables)
8339 (if (gnus-summary-first-subject t)
8341 (gnus-summary-show-thread)
8342 (gnus-summary-first-subject t)
8343 (gnus-summary-display-article (gnus-summary-article-number))))
8344 (gnus-summary-position-cursor)))
8346 (defun gnus-summary-best-unread-article ()
8347 "Select the unread article with the highest score."
8349 (gnus-set-global-variables)
8350 (let ((scored gnus-newsgroup-scored)
8354 (or (> best (cdr (car scored)))
8355 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
8356 (not (memq art gnus-newsgroup-marked))
8357 (not (memq art gnus-newsgroup-dormant))
8358 (if (= best (cdr (car scored)))
8359 (setq article (min art article))
8361 (setq best (cdr (car scored))))))
8362 (setq scored (cdr scored)))
8364 ((or (not article) (null gnus-newsgroup-unreads))
8365 ;; We didn't find any scored articles, so we just jump to the
8367 (gnus-summary-first-unread-article))
8368 ((> best gnus-summary-default-score)
8369 ;; We found one, and it's bigger than the default score, so we
8371 (gnus-summary-goto-article article))
8373 ;; We found an article, but it has a score lower than the
8374 ;; defaults, so we try to find an article with the default
8376 (goto-char (point-min))
8377 (while (and (or (not (= (gnus-summary-article-mark) gnus-unread-mark))
8378 (and (assq (gnus-summary-article-number)
8379 gnus-newsgroup-scored)
8380 (< (cdr (assq (gnus-summary-article-number)
8381 gnus-newsgroup-scored))
8382 gnus-summary-default-score)))
8383 (zerop (forward-line 1))
8385 (if (= (gnus-summary-article-mark) gnus-unread-mark)
8386 ;; We jump to the article we have finally found.
8387 (gnus-summary-goto-article (gnus-summary-article-number))
8388 ;; Or there were no default-scored articles.
8389 (gnus-summary-goto-article article))))
8390 (gnus-summary-position-cursor)))
8392 (defun gnus-summary-goto-article (article &optional all-headers)
8393 "Fetch ARTICLE and display it if it exists.
8394 If ALL-HEADERS is non-nil, no header lines are hidden."
8400 (mapcar (lambda (headers)
8401 (list (int-to-string (mail-header-number headers))))
8402 gnus-newsgroup-headers)
8403 nil 'require-match))))
8405 (and (gnus-summary-goto-subject article)
8406 (gnus-summary-display-article article all-headers))
8407 (gnus-summary-position-cursor)))
8409 (defun gnus-summary-goto-last-article ()
8410 "Go to the previously read article."
8413 (and gnus-last-article
8414 (gnus-summary-goto-article gnus-last-article))
8415 (gnus-summary-position-cursor)))
8417 (defun gnus-summary-pop-article (number)
8418 "Pop one article off the history and go to the previous.
8419 NUMBER articles will be popped off."
8422 (setq gnus-newsgroup-history
8423 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8425 (gnus-summary-goto-article (car to))
8426 (error "Article history empty")))
8427 (gnus-summary-position-cursor))
8429 ;; Summary article oriented commands
8431 (defun gnus-summary-refer-parent-article (n)
8432 "Refer parent article N times.
8433 The difference between N and the number of articles fetched is returned."
8435 (gnus-set-global-variables)
8439 (let ((ref (mail-header-references (gnus-get-header-by-num
8440 (gnus-summary-article-number)))))
8441 (if (and ref (not (equal ref ""))
8442 (string-match "<[^<>]*>[ \t]*$" ref))
8443 (gnus-summary-refer-article
8444 (substring ref (match-beginning 0) (match-end 0)))
8445 (gnus-message 1 "No references in article %d"
8446 (gnus-summary-article-number))
8449 (gnus-summary-position-cursor)
8452 (defun gnus-summary-refer-article (message-id)
8453 "Refer article specified by MESSAGE-ID.
8454 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8455 (interactive "sMessage-ID: ")
8456 (if (or (not (stringp message-id))
8457 (zerop (length message-id)))
8459 ;; Construct the correct Message-ID if necessary.
8460 ;; Suggested by tale@pawl.rpi.edu.
8461 (or (string-match "^<" message-id)
8462 (setq message-id (concat "<" message-id)))
8463 (or (string-match ">$" message-id)
8464 (setq message-id (concat message-id ">")))
8465 (let ((header (car (gnus-gethash (downcase message-id)
8466 gnus-newsgroup-dependencies))))
8468 (or (gnus-summary-goto-article (mail-header-number header))
8469 ;; The header has been read, but the article had been
8470 ;; expunged, so we insert it again.
8472 (gnus-summary-insert-line
8473 nil header 0 nil gnus-read-mark nil nil
8474 (mail-header-subject header))
8476 (mail-header-number header)))
8477 (let ((gnus-override-method gnus-refer-article-method)
8478 (gnus-ancient-mark gnus-read-mark)
8479 (tmp-point (window-start
8480 (get-buffer-window gnus-article-buffer)))
8482 (and gnus-refer-article-method
8483 (gnus-check-server gnus-refer-article-method))
8484 ;; Save the old article buffer.
8486 (set-buffer (gnus-article-setup-buffer))
8487 (gnus-kill-buffer " *temp Article*")
8488 (setq tmp-buf (rename-buffer " *temp Article*")))
8490 (if (gnus-article-prepare
8491 message-id nil (gnus-read-header message-id))
8493 (setq number (mail-header-number gnus-current-headers))
8494 (gnus-rebuild-thread message-id)
8495 (gnus-summary-goto-subject number)
8496 (if (null gnus-use-full-window)
8498 (delete-windows-on tmp-buf)
8499 (gnus-configure-windows 'article 'force)))
8500 (gnus-summary-recenter)
8501 (gnus-article-set-window-start
8502 (cdr (assq number gnus-newsgroup-bookmarks)))
8504 ;; We restore the old article buffer.
8506 (kill-buffer gnus-article-buffer)
8507 (set-buffer tmp-buf)
8508 (rename-buffer gnus-article-buffer)
8509 (let ((buffer-read-only nil))
8511 (set-window-start (get-buffer-window (current-buffer))
8512 tmp-point)))))))))))
8514 (defun gnus-summary-enter-digest-group ()
8515 "Enter a digest group based on the current article."
8517 (gnus-set-global-variables)
8518 (gnus-summary-select-article)
8519 ;; We do not want a narrowed article.
8520 (gnus-summary-stop-page-breaking)
8521 (let ((name (format "%s-%d"
8522 (gnus-group-prefixed-name
8523 gnus-newsgroup-name (list 'nndoc ""))
8524 gnus-current-article))
8525 (ogroup gnus-newsgroup-name)
8526 (buf (current-buffer)))
8527 (if (gnus-group-read-ephemeral-group
8528 name (list 'nndoc name
8529 (list 'nndoc-address (get-buffer gnus-article-buffer))
8530 '(nndoc-article-type digest))
8532 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8533 (list (list (cons 'to-group ogroup))))
8534 (switch-to-buffer buf)
8535 (gnus-set-global-variables)
8536 (gnus-configure-windows 'summary)
8537 (gnus-message 3 "Article not a digest?"))))
8539 (defun gnus-summary-isearch-article ()
8540 "Do incremental search forward on current article."
8542 (gnus-set-global-variables)
8543 (gnus-summary-select-article)
8544 (gnus-eval-in-buffer-window
8545 gnus-article-buffer (isearch-forward)))
8547 (defun gnus-summary-search-article-forward (regexp &optional backward)
8548 "Search for an article containing REGEXP forward.
8549 If BACKWARD, search backward instead."
8552 (format "Search article %s (regexp%s): "
8553 (if current-prefix-arg "backward" "forward")
8554 (if gnus-last-search-regexp
8555 (concat ", default " gnus-last-search-regexp)
8557 current-prefix-arg))
8558 (gnus-set-global-variables)
8559 (if (string-equal regexp "")
8560 (setq regexp (or gnus-last-search-regexp ""))
8561 (setq gnus-last-search-regexp regexp))
8562 (if (gnus-summary-search-article regexp backward)
8563 (gnus-article-set-window-start
8564 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8565 (error "Search failed: \"%s\"" regexp)))
8567 (defun gnus-summary-search-article-backward (regexp)
8568 "Search for an article containing REGEXP backward."
8571 (format "Search article backward (regexp%s): "
8572 (if gnus-last-search-regexp
8573 (concat ", default " gnus-last-search-regexp)
8575 (gnus-summary-search-article-forward regexp 'backward))
8577 (defun gnus-summary-search-article (regexp &optional backward)
8578 "Search for an article containing REGEXP.
8579 Optional argument BACKWARD means do search for backward.
8580 gnus-select-article-hook is not called during the search."
8581 (let ((gnus-select-article-hook nil) ;Disable hook.
8582 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8585 (function re-search-backward) (function re-search-forward)))
8588 ;; Hidden thread subtrees must be searched for ,too.
8589 (gnus-summary-show-all-threads)
8590 (if (eobp) (forward-line -1))
8591 ;; First of all, search current article.
8592 ;; We don't want to read article again from NNTP server nor reset
8594 (gnus-summary-select-article)
8595 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8596 (setq last gnus-current-article)
8597 (gnus-eval-in-buffer-window
8601 ;; Begin search from current point.
8602 (setq found (funcall re-search regexp nil t))))
8603 ;; Then search next articles.
8604 (while (and (not found)
8605 (gnus-summary-display-article
8606 (gnus-summary-search-subject backward nil nil)))
8607 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8608 (gnus-eval-in-buffer-window
8612 (goto-char (if backward (point-max) (point-min)))
8613 (setq found (funcall re-search regexp nil t)))))
8615 ;; Adjust article pointer.
8616 (or (eq last gnus-current-article)
8617 (setq gnus-last-article last))
8618 ;; Return T if found such article.
8621 (defun gnus-summary-execute-command (header regexp command &optional backward)
8622 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8623 If HEADER is an empty string (or nil), the match is done on the entire
8624 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8626 (list (let ((completion-ignore-case t))
8629 (mapcar (lambda (string) (list string))
8630 '("Number" "Subject" "From" "Lines" "Date"
8631 "Message-ID" "Xref" "References"))
8632 nil 'require-match))
8633 (read-string "Regexp: ")
8634 (read-key-sequence "Command: ")
8635 current-prefix-arg))
8636 (gnus-set-global-variables)
8637 ;; Hidden thread subtrees must be searched as well.
8638 (gnus-summary-show-all-threads)
8639 ;; We don't want to change current point nor window configuration.
8641 (save-window-excursion
8642 (gnus-message 6 "Executing %s..." (key-description command))
8643 ;; We'd like to execute COMMAND interactively so as to give arguments.
8644 (gnus-execute header regexp
8646 (call-interactively '(, (key-binding command)))))
8648 (gnus-message 6 "Executing %s...done" (key-description command)))))
8650 (defun gnus-summary-beginning-of-article ()
8651 "Scroll the article back to the beginning."
8653 (gnus-set-global-variables)
8654 (gnus-summary-select-article)
8655 (gnus-configure-windows 'article)
8656 (gnus-eval-in-buffer-window
8659 (goto-char (point-min))
8660 (and gnus-break-pages (gnus-narrow-to-page))))
8662 (defun gnus-summary-end-of-article ()
8663 "Scroll to the end of the article."
8665 (gnus-set-global-variables)
8666 (gnus-summary-select-article)
8667 (gnus-configure-windows 'article)
8668 (gnus-eval-in-buffer-window
8671 (goto-char (point-max))
8673 (and gnus-break-pages (gnus-narrow-to-page))))
8675 (defun gnus-summary-show-article ()
8676 "Force re-fetching of the current article."
8678 (gnus-set-global-variables)
8679 (gnus-summary-select-article nil 'force)
8680 (gnus-configure-windows 'article)
8681 (gnus-summary-position-cursor))
8683 (defun gnus-summary-verbose-headers (&optional arg)
8684 "Toggle permanent full header display.
8685 If ARG is a positive number, turn header display on.
8686 If ARG is a negative number, turn header display off."
8688 (gnus-set-global-variables)
8689 (gnus-summary-toggle-header arg)
8690 (setq gnus-show-all-headers
8691 (cond ((or (not (numberp arg))
8693 (not gnus-show-all-headers))
8697 (defun gnus-summary-toggle-header (&optional arg)
8698 "Show the headers if they are hidden, or hide them if they are shown.
8699 If ARG is a positive number, show the entire header.
8700 If ARG is a negative number, hide the unwanted header lines."
8702 (gnus-set-global-variables)
8704 (set-buffer gnus-article-buffer)
8705 (let ((buffer-read-only nil))
8707 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8708 gnus-hidden-properties)
8709 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8710 (if (text-property-any (point-min) (point-max) 'invisible t)
8711 (remove-text-properties
8712 (point-min) (point-max) gnus-hidden-properties)
8713 ;; We hide the headers. This song and dance act below is
8714 ;; done because `gnus-have-all-headers' is buffer-local to
8715 ;; the summary buffer, and we only want to temporarily
8716 ;; change it in that buffer. Ugh.
8717 (let ((have gnus-have-all-headers))
8719 (set-buffer gnus-summary-buffer)
8720 (setq gnus-have-all-headers nil)
8722 (set-buffer gnus-article-buffer)
8723 (run-hooks 'gnus-article-display-hook))
8724 (setq gnus-have-all-headers have)))))
8725 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8727 (defun gnus-summary-show-all-headers ()
8728 "Make all header lines visible."
8730 (gnus-set-global-variables)
8731 (gnus-article-show-all-headers))
8733 (defun gnus-summary-toggle-mime (&optional arg)
8734 "Toggle MIME processing.
8735 If ARG is a positive number, turn MIME processing on."
8737 (gnus-set-global-variables)
8738 (setq gnus-show-mime
8739 (if (null arg) (not gnus-show-mime)
8740 (> (prefix-numeric-value arg) 0)))
8741 (gnus-summary-select-article t 'force))
8743 (defun gnus-summary-caesar-message (&optional arg)
8744 "Caesar rotate the current article by 13.
8745 The numerical prefix specifies how manu places to rotate each letter
8748 (gnus-set-global-variables)
8749 (gnus-summary-select-article)
8750 (let ((mail-header-separator ""))
8751 (gnus-eval-in-buffer-window
8755 (let ((start (window-start)))
8756 (news-caesar-buffer-body arg)
8757 (set-window-start (get-buffer-window (current-buffer)) start))))))
8759 (defun gnus-summary-stop-page-breaking ()
8760 "Stop page breaking in the current article."
8762 (gnus-set-global-variables)
8763 (gnus-summary-select-article)
8764 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8766 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8768 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8769 "Move the current article to a different newsgroup.
8770 If N is a positive number, move the N next articles.
8771 If N is a negative number, move the N previous articles.
8772 If N is nil and any articles have been marked with the process mark,
8773 move those articles instead.
8774 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8775 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8776 re-spool using this method.
8777 For this function to work, both the current newsgroup and the
8778 newsgroup that you want to move to have to support the `request-move'
8779 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8781 (gnus-set-global-variables)
8782 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8783 (error "The current newsgroup does not support article moving"))
8784 (let ((articles (gnus-summary-work-articles n))
8785 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8786 art-group to-method sel-met)
8787 (if (and (not to-newsgroup) (not select-method))
8790 (format "Where do you want to move %s? %s"
8791 (if (> (length articles) 1)
8792 (format "these %d articles" (length articles))
8794 (if gnus-current-move-group
8795 (format "(%s default) " gnus-current-move-group)
8797 gnus-active-hashtb nil nil prefix)))
8800 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8801 (setq to-newsgroup (or gnus-current-move-group "")))
8802 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8803 (gnus-activate-group to-newsgroup)
8804 (error "No such group: %s" to-newsgroup))
8805 (setq gnus-current-move-group to-newsgroup)))
8806 (setq to-method (if select-method (list select-method "")
8807 (gnus-find-method-for-group to-newsgroup)))
8808 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8809 (error "%s does not support article copying" (car to-method)))
8810 (or (gnus-check-server to-method)
8811 (error "Can't open server %s" (car to-method)))
8812 (gnus-message 6 "Moving to %s: %s..."
8813 (or select-method to-newsgroup) articles)
8816 (gnus-request-move-article
8817 (car articles) ; Article to move
8818 gnus-newsgroup-name ; From newsgrouo
8819 (nth 1 (gnus-find-method-for-group
8820 gnus-newsgroup-name)) ; Server
8821 (list 'gnus-request-accept-article
8823 (list 'quote select-method)
8825 (not (cdr articles))) ; Accept form
8826 (not (cdr articles)))) ; Only save nov last time
8827 (let* ((buffer-read-only nil)
8830 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8832 (gnus-group-prefixed-name
8834 (if select-method (list select-method "")
8835 (gnus-find-method-for-group to-newsgroup)))
8836 gnus-newsrc-hashtb)))
8837 (info (nth 2 entry))
8838 (article (car articles)))
8839 (gnus-summary-goto-subject article)
8841 (delete-region (point) (progn (forward-line 1) (point)))
8842 ;; Update the group that has been moved to.
8844 () ; This group does not exist yet.
8845 (if (not (memq article gnus-newsgroup-unreads))
8846 (setcar (cdr (cdr info))
8847 (gnus-add-to-range (nth 2 info)
8848 (list (cdr art-group)))))
8849 ;; Copy any marks over to the new group.
8850 (let ((marks '((tick . gnus-newsgroup-marked)
8851 (dormant . gnus-newsgroup-dormant)
8852 (expire . gnus-newsgroup-expirable)
8853 (bookmark . gnus-newsgroup-bookmarks)
8854 (reply . gnus-newsgroup-replied)))
8855 (to-article (cdr art-group)))
8857 (if (memq article (symbol-value (cdr (car marks))))
8858 (gnus-add-marked-articles
8859 (car info) (car (car marks)) (list to-article) info))
8860 (setq marks (cdr marks)))))
8862 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8863 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8864 (setq gnus-newsgroup-dormant
8865 (delq article gnus-newsgroup-dormant))
8866 (setq gnus-newsgroup-reads
8867 (cons (cons article gnus-canceled-mark)
8868 gnus-newsgroup-reads)))
8869 (gnus-message 1 "Couldn't move article %s" (car articles)))
8870 (gnus-summary-remove-process-mark (car articles))
8871 (setq articles (cdr articles)))))
8873 (defun gnus-summary-respool-article (&optional n respool-method)
8874 "Respool the current article.
8875 The article will be squeezed through the mail spooling process again,
8876 which means that it will be put in some mail newsgroup or other
8877 depending on `nnmail-split-methods'.
8878 If N is a positive number, respool the N next articles.
8879 If N is a negative number, respool the N previous articles.
8880 If N is nil and any articles have been marked with the process mark,
8881 respool those articles instead.
8883 Respooling can be done both from mail groups and \"real\" newsgroups.
8884 In the former case, the articles in question will be moved from the
8885 current group into whatever groups they are destined to. In the
8886 latter case, they will be copied into the relevant groups."
8888 (gnus-set-global-variables)
8889 (let ((respool-methods (gnus-methods-using 'respool))
8891 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8893 (setq respool-method
8895 "What method do you want to use when respooling? "
8896 respool-methods nil t methname)))
8897 (or (string= respool-method "")
8898 (if (assoc (symbol-name
8899 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8901 (gnus-summary-move-article n nil (intern respool-method))
8902 (gnus-summary-copy-article n nil (intern respool-method))))))
8904 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8905 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8906 "Move the current article to a different newsgroup.
8907 If N is a positive number, move the N next articles.
8908 If N is a negative number, move the N previous articles.
8909 If N is nil and any articles have been marked with the process mark,
8910 move those articles instead.
8911 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8912 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8913 re-spool using this method.
8914 For this function to work, the newsgroup that you want to move to have
8915 to support the `request-move' and `request-accept'
8916 functions. (Ie. mail newsgroups at present.)"
8918 (gnus-set-global-variables)
8919 (let ((articles (gnus-summary-work-articles n))
8920 (copy-buf (get-buffer-create "*copy work*"))
8921 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8922 art-group to-method)
8923 (buffer-disable-undo copy-buf)
8924 (if (and (not to-newsgroup) (not select-method))
8927 (format "Where do you want to copy %s? %s"
8928 (if (> (length articles) 1)
8929 (format "these %d articles" (length articles))
8931 (if gnus-current-move-group
8932 (format "(%s default) " gnus-current-move-group)
8934 gnus-active-hashtb nil nil prefix)))
8937 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8938 (setq to-newsgroup (or gnus-current-move-group "")))
8939 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8940 (gnus-activate-group to-newsgroup)
8941 (error "No such group: %s" to-newsgroup))
8942 (setq gnus-current-move-group to-newsgroup)))
8943 (setq to-method (if select-method (list select-method "")
8944 (gnus-find-method-for-group to-newsgroup)))
8945 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8946 (error "%s does not support article copying" (car to-method)))
8947 (or (gnus-check-server to-method)
8948 (error "Can't open server %s" (car to-method)))
8950 (gnus-message 6 "Copying to %s: %s..."
8951 (or select-method to-newsgroup) articles)
8954 (set-buffer copy-buf)
8955 (gnus-request-article-this-buffer
8956 (car articles) gnus-newsgroup-name)
8957 (gnus-request-accept-article
8958 (if select-method (quote select-method) to-newsgroup)
8959 (not (cdr articles)))))
8962 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8964 (gnus-group-prefixed-name
8966 (if select-method (list select-method "")
8967 (gnus-find-method-for-group to-newsgroup)))
8968 gnus-newsrc-hashtb)))
8969 (info (nth 2 entry))
8970 (article (car articles)))
8971 ;; We copy the info over to the new group.
8973 () ; This group does not exist (yet).
8974 (if (not (memq article gnus-newsgroup-unreads))
8975 (setcar (cdr (cdr info))
8976 (gnus-add-to-range (nth 2 info)
8977 (list (cdr art-group)))))
8978 ;; Copy any marks over to the new group.
8979 (let ((marks '((tick . gnus-newsgroup-marked)
8980 (dormant . gnus-newsgroup-dormant)
8981 (expire . gnus-newsgroup-expirable)
8982 (bookmark . gnus-newsgroup-bookmarks)
8983 (reply . gnus-newsgroup-replied)))
8984 (to-article (cdr art-group)))
8986 (if (memq article (symbol-value (cdr (car marks))))
8987 (gnus-add-marked-articles
8988 (car info) (car (car marks)) (list to-article) info))
8989 (setq marks (cdr marks))))))
8990 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8991 (gnus-summary-remove-process-mark (car articles))
8992 (setq articles (cdr articles)))
8993 (kill-buffer copy-buf)))
8995 (defun gnus-summary-import-article (file)
8996 "Import a random file into a mail newsgroup."
8997 (interactive "fImport file: ")
8998 (let ((group gnus-newsgroup-name)
9000 (or (gnus-check-backend-function 'request-accept-article group)
9001 (error "%s does not support article importing" group))
9002 (or (file-readable-p file)
9003 (not (file-regular-p file))
9004 (error "Can't read %s" file))
9006 (set-buffer (get-buffer-create " *import file*"))
9007 (buffer-disable-undo (current-buffer))
9009 (insert-file-contents file)
9010 (goto-char (point-min))
9011 (if (nnheader-article-p)
9013 (setq atts (file-attributes file))
9014 (insert "From: " (read-string "From: ") "\n"
9015 "Subject: " (read-string "Subject: ") "\n"
9016 "Date: " (current-time-string (nth 5 atts)) "\n"
9017 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9018 (gnus-request-accept-article group t)
9019 (kill-buffer (current-buffer)))))
9021 (defun gnus-summary-expire-articles ()
9022 "Expire all articles that are marked as expirable in the current group."
9024 (if (not (gnus-check-backend-function
9025 'request-expire-articles gnus-newsgroup-name))
9027 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
9028 gnus-newsrc-hashtb)))
9029 (total (memq 'total-expire (nth 5 info)))
9030 (expirable (if total
9031 (gnus-list-of-read-articles gnus-newsgroup-name)
9032 (setq gnus-newsgroup-expirable
9033 (sort gnus-newsgroup-expirable '<))))
9037 (gnus-message 6 "Expiring articles...")
9038 ;; The list of articles that weren't expired is returned.
9039 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
9040 (or total (setq gnus-newsgroup-expirable es))
9041 ;; We go through the old list of expirable, and mark all
9042 ;; really expired articles as non-existant.
9043 (or (eq es expirable) ;If nothing was expired, we don't mark.
9044 (let ((gnus-use-cache nil))
9046 (or (memq (car expirable) es)
9047 (gnus-summary-mark-article
9048 (car expirable) gnus-canceled-mark))
9049 (setq expirable (cdr expirable)))))
9050 (gnus-message 6 "Expiring articles...done")))))
9052 (defun gnus-summary-expire-articles-now ()
9053 "Expunge all expirable articles in the current group.
9054 This means that *all* articles that are marked as expirable will be
9055 deleted forever, right now."
9057 (or gnus-expert-user
9059 "Are you really, really, really sure you want to expunge? ")
9061 (let ((nnmail-expiry-wait -1)
9062 (nnmail-expiry-wait-function nil))
9063 (gnus-summary-expire-articles)))
9065 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9066 (defun gnus-summary-delete-article (&optional n)
9067 "Delete the N next (mail) articles.
9068 This command actually deletes articles. This is not a marking
9069 command. The article will disappear forever from you life, never to
9071 If N is negative, delete backwards.
9072 If N is nil and articles have been marked with the process mark,
9073 delete these instead."
9075 (or (gnus-check-backend-function 'request-expire-articles
9076 gnus-newsgroup-name)
9077 (error "The current newsgroup does not support article deletion."))
9078 ;; Compute the list of articles to delete.
9079 (let ((articles (gnus-summary-work-articles n))
9081 (if (and gnus-novice-user
9083 (format "Do you really want to delete %s forever? "
9084 (if (> (length articles) 1) "these articles"
9087 ;; Delete the articles.
9088 (setq not-deleted (gnus-request-expire-articles
9089 articles gnus-newsgroup-name 'force))
9091 (gnus-summary-remove-process-mark (car articles))
9092 ;; The backend might not have been able to delete the article
9094 (or (memq (car articles) not-deleted)
9095 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9096 (setq articles (cdr articles))))
9097 (gnus-summary-position-cursor)
9100 (defun gnus-summary-edit-article ()
9101 "Enter into a buffer and edit the current article.
9102 This will have permanent effect only in mail groups."
9104 (or (gnus-check-backend-function
9105 'request-replace-article gnus-newsgroup-name)
9106 (error "The current newsgroup does not support article editing."))
9107 (gnus-summary-select-article t)
9108 (gnus-configure-windows 'article)
9109 (select-window (get-buffer-window gnus-article-buffer))
9110 (gnus-message 6 "C-c C-c to end edits")
9111 (setq buffer-read-only nil)
9113 (use-local-map (copy-keymap (current-local-map)))
9114 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9115 (buffer-enable-undo)
9117 (goto-char (point-min))
9118 (search-forward "\n\n" nil t))
9120 (defun gnus-summary-edit-article-done ()
9121 "Make edits to the current article permanent."
9123 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9126 (if (not (gnus-request-replace-article
9127 (cdr gnus-article-current) (car gnus-article-current)
9129 (error "Couldn't replace article.")
9131 (use-local-map gnus-article-mode-map)
9132 (setq buffer-read-only t)
9133 (buffer-disable-undo (current-buffer))
9134 (gnus-configure-windows 'summary))
9135 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook))))
9137 (defun gnus-summary-edit-article-postpone ()
9138 "Postpone changes to the current article."
9141 (use-local-map gnus-article-mode-map)
9142 (setq buffer-read-only t)
9143 (buffer-disable-undo (current-buffer))
9144 (gnus-configure-windows 'summary)
9145 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9147 (defun gnus-summary-fancy-query ()
9148 "Query where the fancy respool algorithm would put this article."
9150 (gnus-summary-select-article)
9152 (set-buffer gnus-article-buffer)
9154 (goto-char (point-min))
9155 (search-forward "\n\n")
9156 (narrow-to-region (point-min) (point))
9157 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9159 ;; Summary score commands.
9161 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9163 (defun gnus-summary-raise-score (n)
9164 "Raise the score of the current article by N."
9166 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9168 (defun gnus-summary-set-score (n)
9169 "Set the score of the current article to N."
9171 ;; Skip dummy header line.
9173 (gnus-summary-show-thread)
9174 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9176 (let ((buffer-read-only nil))
9178 (gnus-summary-update-mark
9179 (if (= n (or gnus-summary-default-score 0)) ?
9180 (if (< n (or gnus-summary-default-score 0))
9181 gnus-score-below-mark gnus-score-over-mark)) 'score))
9182 (let* ((article (gnus-summary-article-number))
9183 (score (assq article gnus-newsgroup-scored)))
9184 (if score (setcdr score n)
9185 (setq gnus-newsgroup-scored
9186 (cons (cons article n) gnus-newsgroup-scored))))
9187 (gnus-summary-update-line)))
9189 (defun gnus-summary-current-score ()
9190 "Return the score of the current article."
9192 (message "%s" (gnus-summary-article-score)))
9194 ;; Summary marking commands.
9196 (defun gnus-summary-raise-same-subject-and-select (score)
9197 "Raise articles which has the same subject with SCORE and select the next."
9199 (let ((subject (gnus-summary-subject-string)))
9200 (gnus-summary-raise-score score)
9201 (while (gnus-summary-search-subject nil nil subject)
9202 (gnus-summary-raise-score score))
9203 (gnus-summary-next-article t)))
9205 (defun gnus-summary-raise-same-subject (score)
9206 "Raise articles which has the same subject with SCORE."
9208 (let ((subject (gnus-summary-subject-string)))
9209 (gnus-summary-raise-score score)
9210 (while (gnus-summary-search-subject nil nil subject)
9211 (gnus-summary-raise-score score))
9212 (gnus-summary-next-subject 1 t)))
9214 (defun gnus-score-default (level)
9215 (if level (prefix-numeric-value level)
9216 gnus-score-interactive-default-score))
9218 (defun gnus-summary-raise-thread (&optional score)
9219 "Raise the score of the articles in the current thread with SCORE."
9221 (setq score (gnus-score-default score))
9224 (let ((level (gnus-summary-thread-level)))
9225 (gnus-summary-raise-score score)
9226 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9227 (> (gnus-summary-thread-level) level))
9228 (gnus-summary-raise-score score))
9230 (let ((gnus-summary-check-current t))
9231 (or (zerop (gnus-summary-next-subject 1 t))
9233 (gnus-summary-recenter)
9234 (gnus-summary-position-cursor)
9235 (gnus-set-mode-line 'summary))
9237 (defun gnus-summary-lower-same-subject-and-select (score)
9238 "Raise articles which has the same subject with SCORE and select the next."
9240 (gnus-summary-raise-same-subject-and-select (- score)))
9242 (defun gnus-summary-lower-same-subject (score)
9243 "Raise articles which has the same subject with SCORE."
9245 (gnus-summary-raise-same-subject (- score)))
9247 (defun gnus-summary-lower-thread (&optional score)
9248 "Lower score of articles in the current thread with SCORE."
9250 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9252 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9253 "Mark articles which has the same subject as read, and then select the next.
9254 If UNMARK is positive, remove any kind of mark.
9255 If UNMARK is negative, tick articles."
9258 (setq unmark (prefix-numeric-value unmark)))
9260 (gnus-summary-mark-same-subject
9261 (gnus-summary-subject-string) unmark)))
9262 ;; Select next unread article. If auto-select-same mode, should
9263 ;; select the first unread article.
9264 (gnus-summary-next-article t (and gnus-auto-select-same
9265 (gnus-summary-subject-string)))
9266 (gnus-message 7 "%d article%s marked as %s"
9267 count (if (= count 1) " is" "s are")
9268 (if unmark "unread" "read"))))
9270 (defun gnus-summary-kill-same-subject (&optional unmark)
9271 "Mark articles which has the same subject as read.
9272 If UNMARK is positive, remove any kind of mark.
9273 If UNMARK is negative, tick articles."
9276 (setq unmark (prefix-numeric-value unmark)))
9278 (gnus-summary-mark-same-subject
9279 (gnus-summary-subject-string) unmark)))
9280 ;; If marked as read, go to next unread subject.
9282 ;; Go to next unread subject.
9283 (gnus-summary-next-subject 1 t))
9284 (gnus-message 7 "%d articles are marked as %s"
9285 count (if unmark "unread" "read"))))
9287 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9288 "Mark articles with same SUBJECT as read, and return marked number.
9289 If optional argument UNMARK is positive, remove any kinds of marks.
9290 If optional argument UNMARK is negative, mark articles as unread instead."
9294 ((null unmark) ; Mark as read.
9297 (gnus-summary-mark-article-as-read gnus-killed-mark)
9298 (gnus-summary-show-thread) t)
9299 (gnus-summary-search-forward nil subject))
9300 (setq count (1+ count))))
9301 ((> unmark 0) ; Tick.
9304 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9305 (gnus-summary-show-thread) t)
9306 (gnus-summary-search-forward nil subject))
9307 (setq count (1+ count))))
9308 (t ; Mark as unread.
9311 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9312 (gnus-summary-show-thread) t)
9313 (gnus-summary-search-forward nil subject))
9314 (setq count (1+ count)))))
9315 (gnus-set-mode-line 'summary)
9316 ;; Return the number of marked articles.
9319 (defun gnus-summary-mark-as-processable (n &optional unmark)
9320 "Set the process mark on the next N articles.
9321 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9322 the process mark instead. The difference between N and the actual
9323 number of articles marked is returned."
9325 (let ((backward (< n 0))
9330 (gnus-summary-remove-process-mark
9331 (gnus-summary-article-number))
9332 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9333 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9335 (if (/= 0 n) (gnus-message 7 "No more articles"))
9336 (gnus-summary-recenter)
9337 (gnus-summary-position-cursor)
9340 (defun gnus-summary-unmark-as-processable (n)
9341 "Remove the process mark from the next N articles.
9342 If N is negative, mark backward instead. The difference between N and
9343 the actual number of articles marked is returned."
9345 (gnus-summary-mark-as-processable n t))
9347 (defun gnus-summary-unmark-all-processable ()
9348 "Remove the process mark from all articles."
9351 (while gnus-newsgroup-processable
9352 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9353 (gnus-summary-position-cursor))
9355 (defun gnus-summary-mark-as-expirable (n)
9356 "Mark N articles forward as expirable.
9357 If N is negative, mark backward instead. The difference between N and
9358 the actual number of articles marked is returned."
9360 (gnus-summary-mark-forward n gnus-expirable-mark))
9362 (defun gnus-summary-mark-article-as-replied (article)
9363 "Mark ARTICLE replied and update the summary line."
9364 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9365 (let ((buffer-read-only nil))
9366 (if (gnus-summary-goto-subject article)
9368 (gnus-summary-update-mark gnus-replied-mark 'replied)
9371 (defun gnus-summary-set-bookmark (article)
9372 "Set a bookmark in current article."
9373 (interactive (list (gnus-summary-article-number)))
9374 (if (or (not (get-buffer gnus-article-buffer))
9375 (not gnus-current-article)
9376 (not gnus-article-current)
9377 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9378 (error "No current article selected"))
9379 ;; Remove old bookmark, if one exists.
9380 (let ((old (assq article gnus-newsgroup-bookmarks)))
9381 (if old (setq gnus-newsgroup-bookmarks
9382 (delq old gnus-newsgroup-bookmarks))))
9383 ;; Set the new bookmark, which is on the form
9384 ;; (article-number . line-number-in-body).
9385 (setq gnus-newsgroup-bookmarks
9389 (set-buffer gnus-article-buffer)
9393 (goto-char (point-min))
9394 (search-forward "\n\n" nil t)
9397 gnus-newsgroup-bookmarks))
9398 (gnus-message 6 "A bookmark has been added to the current article."))
9400 (defun gnus-summary-remove-bookmark (article)
9401 "Remove the bookmark from the current article."
9402 (interactive (list (gnus-summary-article-number)))
9403 ;; Remove old bookmark, if one exists.
9404 (let ((old (assq article gnus-newsgroup-bookmarks)))
9407 (setq gnus-newsgroup-bookmarks
9408 (delq old gnus-newsgroup-bookmarks))
9409 (gnus-message 6 "Removed bookmark."))
9410 (gnus-message 6 "No bookmark in current article."))))
9412 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9413 (defun gnus-summary-mark-as-dormant (n)
9414 "Mark N articles forward as dormant.
9415 If N is negative, mark backward instead. The difference between N and
9416 the actual number of articles marked is returned."
9418 (gnus-summary-mark-forward n gnus-dormant-mark))
9420 (defun gnus-summary-set-process-mark (article)
9421 "Set the process mark on ARTICLE and update the summary line."
9422 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9423 (let ((buffer-read-only nil))
9424 (if (gnus-summary-goto-subject article)
9426 (gnus-summary-show-thread)
9427 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9429 (gnus-summary-update-mark gnus-process-mark 'replied)
9432 (defun gnus-summary-remove-process-mark (article)
9433 "Remove the process mark from ARTICLE and update the summary line."
9434 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9435 (let ((buffer-read-only nil))
9436 (if (gnus-summary-goto-subject article)
9438 (gnus-summary-show-thread)
9439 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9441 (gnus-summary-update-mark ? 'replied)
9442 (if (memq article gnus-newsgroup-replied)
9443 (gnus-summary-update-mark gnus-replied-mark 'replied))
9446 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9447 "Mark N articles as read forwards.
9448 If N is negative, mark backwards instead.
9449 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9451 The difference between N and the actual number of articles marked is
9454 (gnus-set-global-variables)
9455 (let ((backward (< n 0))
9456 (gnus-summary-goto-unread
9457 (and gnus-summary-goto-unread
9458 (not (memq mark (list gnus-unread-mark
9459 gnus-ticked-mark gnus-dormant-mark)))))
9461 (mark (or mark gnus-del-mark)))
9463 (gnus-summary-mark-article nil mark no-expire)
9464 (zerop (gnus-summary-next-subject
9465 (if backward -1 1) gnus-summary-goto-unread t)))
9467 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9468 (gnus-summary-recenter)
9469 (gnus-summary-position-cursor)
9470 (gnus-set-mode-line 'summary)
9473 (defun gnus-summary-mark-article-as-read (mark)
9474 "Mark the current article quickly as read with MARK."
9475 (let ((article (gnus-summary-article-number)))
9476 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9477 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9478 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9479 (setq gnus-newsgroup-reads
9480 (cons (cons article mark) gnus-newsgroup-reads))
9481 ;; Possibly remove from cache, if that is used.
9482 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9483 (and gnus-newsgroup-auto-expire
9484 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9485 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9486 (= mark gnus-read-mark))
9488 (setq mark gnus-expirable-mark)
9489 (setq gnus-newsgroup-expirable
9490 (cons article gnus-newsgroup-expirable))))
9491 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9494 (gnus-summary-update-mark mark 'unread)
9497 (defun gnus-summary-mark-article-as-unread (mark)
9498 "Mark the current article quickly as unread with MARK."
9499 (let ((article (gnus-summary-article-number)))
9500 (or (memq article gnus-newsgroup-unreads)
9501 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9502 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9503 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9504 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9505 (setq gnus-newsgroup-reads
9506 (delq (assq article gnus-newsgroup-reads)
9507 gnus-newsgroup-reads))
9508 (if (= mark gnus-ticked-mark)
9509 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9510 (if (= mark gnus-dormant-mark)
9511 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9513 ;; See whether the article is to be put in the cache.
9515 (vectorp (gnus-get-header-by-num article))
9517 (gnus-cache-possibly-enter-article
9518 gnus-newsgroup-name article
9519 (gnus-get-header-by-num article)
9520 (= mark gnus-ticked-mark)
9521 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9523 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9526 (gnus-summary-update-mark mark 'unread)
9529 (defun gnus-summary-mark-article (&optional article mark no-expire)
9530 "Mark ARTICLE with MARK. MARK can be any character.
9531 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9532 (dormant) and `?E' (expirable).
9533 If MARK is nil, then the default character `?D' is used.
9534 If ARTICLE is nil, then the article on the current line will be
9537 (setq mark (aref mark 0)))
9538 ;; If no mark is given, then we check auto-expiring.
9539 (and (not no-expire)
9540 gnus-newsgroup-auto-expire
9543 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9544 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9545 (= mark gnus-read-mark))))
9546 (setq mark gnus-expirable-mark))
9547 (let* ((mark (or mark gnus-del-mark))
9548 (article (or article (gnus-summary-article-number))))
9549 (or article (error "No article on current line"))
9550 (if (or (= mark gnus-unread-mark)
9551 (= mark gnus-ticked-mark)
9552 (= mark gnus-dormant-mark))
9553 (gnus-mark-article-as-unread article mark)
9554 (gnus-mark-article-as-read article mark))
9556 ;; See whether the article is to be put in the cache.
9558 (not (= mark gnus-canceled-mark))
9559 (vectorp (gnus-get-header-by-num article))
9561 (gnus-cache-possibly-enter-article
9562 gnus-newsgroup-name article
9563 (gnus-get-header-by-num article)
9564 (= mark gnus-ticked-mark)
9565 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9567 (if (gnus-summary-goto-subject article)
9568 (let ((buffer-read-only nil))
9569 (gnus-summary-show-thread)
9570 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9573 (gnus-summary-update-mark mark 'unread)
9576 (defun gnus-summary-update-mark (mark type)
9578 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9579 (buffer-read-only nil)
9583 (forward-char forward)
9584 (setq plist (text-properties-at (point)))
9587 (and plist (add-text-properties (1- (point)) (point) plist))
9588 (and (eq type 'unread)
9590 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark))
9591 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9593 (defun gnus-mark-article-as-read (article &optional mark)
9594 "Enter ARTICLE in the pertinent lists and remove it from others."
9595 ;; Make the article expirable.
9596 (let ((mark (or mark gnus-del-mark)))
9597 (if (= mark gnus-expirable-mark)
9598 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9599 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9600 ;; Remove from unread and marked lists.
9601 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9602 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9603 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9604 (setq gnus-newsgroup-reads
9605 (cons (cons article mark) gnus-newsgroup-reads))
9606 ;; Possibly remove from cache, if that is used.
9607 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9609 (defun gnus-mark-article-as-unread (article &optional mark)
9610 "Enter ARTICLE in the pertinent lists and remove it from others."
9611 (let ((mark (or mark gnus-ticked-mark)))
9612 ;; Add to unread list.
9613 (or (memq article gnus-newsgroup-unreads)
9614 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9615 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9616 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9617 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9618 (setq gnus-newsgroup-reads
9619 (delq (assq article gnus-newsgroup-reads)
9620 gnus-newsgroup-reads))
9621 (if (= mark gnus-ticked-mark)
9622 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9623 (if (= mark gnus-dormant-mark)
9624 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9626 (defalias 'gnus-summary-mark-as-unread-forward
9627 'gnus-summary-tick-article-forward)
9628 (make-obsolete 'gnus-summary-mark-as-unread-forward
9629 'gnus-summary-tick-article-forward)
9630 (defun gnus-summary-tick-article-forward (n)
9631 "Tick N articles forwards.
9632 If N is negative, tick backwards instead.
9633 The difference between N and the number of articles ticked is returned."
9635 (gnus-summary-mark-forward n gnus-ticked-mark))
9637 (defalias 'gnus-summary-mark-as-unread-backward
9638 'gnus-summary-tick-article-backward)
9639 (make-obsolete 'gnus-summary-mark-as-unread-backward
9640 'gnus-summary-tick-article-backward)
9641 (defun gnus-summary-tick-article-backward (n)
9642 "Tick N articles backwards.
9643 The difference between N and the number of articles ticked is returned."
9645 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9647 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9648 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9649 (defun gnus-summary-tick-article (&optional article clear-mark)
9650 "Mark current article as unread.
9651 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9652 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9653 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9656 (defun gnus-summary-mark-as-read-forward (n)
9657 "Mark N articles as read forwards.
9658 If N is negative, mark backwards instead.
9659 The difference between N and the actual number of articles marked is
9662 (gnus-summary-mark-forward n gnus-del-mark t))
9664 (defun gnus-summary-mark-as-read-backward (n)
9665 "Mark the N articles as read backwards.
9666 The difference between N and the actual number of articles marked is
9669 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9671 (defun gnus-summary-mark-as-read (&optional article mark)
9672 "Mark current article as read.
9673 ARTICLE specifies the article to be marked as read.
9674 MARK specifies a string to be inserted at the beginning of the line."
9675 (gnus-summary-mark-article article mark))
9677 (defun gnus-summary-clear-mark-forward (n)
9678 "Clear marks from N articles forward.
9679 If N is negative, clear backward instead.
9680 The difference between N and the number of marks cleared is returned."
9682 (gnus-summary-mark-forward n gnus-unread-mark))
9684 (defun gnus-summary-clear-mark-backward (n)
9685 "Clear marks from N articles backward.
9686 The difference between N and the number of marks cleared is returned."
9688 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9690 (defun gnus-summary-mark-unread-as-read ()
9691 "Intended to be used by `gnus-summary-mark-article-hook'."
9692 (or (memq gnus-current-article gnus-newsgroup-marked)
9693 (memq gnus-current-article gnus-newsgroup-dormant)
9694 (memq gnus-current-article gnus-newsgroup-expirable)
9695 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9697 (defun gnus-summary-mark-region-as-read (point mark all)
9698 "Mark all unread articles between point and mark as read.
9699 If given a prefix, mark all articles between point and mark as read,
9700 even ticked and dormant ones."
9701 (interactive "r\nP")
9711 (not (memq (gnus-summary-article-number)
9712 gnus-newsgroup-marked))
9713 (not (memq (gnus-summary-article-number)
9714 gnus-newsgroup-dormant))))
9715 (gnus-summary-mark-article
9716 (gnus-summary-article-number) gnus-del-mark))
9718 (zerop (forward-line 1))))))
9720 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9721 (defalias 'gnus-summary-delete-marked-as-read
9722 'gnus-summary-remove-lines-marked-as-read)
9723 (make-obsolete 'gnus-summary-delete-marked-as-read
9724 'gnus-summary-remove-lines-marked-as-read)
9725 (defun gnus-summary-remove-lines-marked-as-read ()
9726 "Remove lines that are marked as read."
9728 (gnus-summary-remove-lines-marked-with
9730 (lambda (char) (char-to-string (symbol-value char)))
9731 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9732 gnus-killed-mark gnus-kill-file-mark
9733 gnus-low-score-mark gnus-expirable-mark
9734 gnus-canceled-mark gnus-catchup-mark)
9737 (defalias 'gnus-summary-delete-marked-with
9738 'gnus-summary-remove-lines-marked-with)
9739 (make-obsolete 'gnus-summary-delete-marked-with
9740 'gnus-summary-remove-lines-marked-with)
9741 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9742 (defun gnus-summary-remove-lines-marked-with (marks)
9743 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9744 (interactive "sMarks: ")
9745 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9746 (gnus-set-global-variables)
9747 (let ((buffer-read-only nil)
9748 (marks (concat "^[" marks "]")))
9749 (goto-char (point-min))
9750 (if gnus-newsgroup-adaptive
9751 (gnus-score-remove-lines-adaptive marks)
9752 (while (re-search-forward marks nil t)
9753 (gnus-delete-line)))
9754 ;; If we use dummy roots, we have to do an additional sweep over
9756 (if (not (eq gnus-summary-make-false-root 'dummy))
9758 (goto-char (point-min))
9759 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9760 (while (re-search-forward marks nil t)
9761 (if (gnus-subject-equal
9762 (gnus-summary-subject-string)
9765 (gnus-summary-subject-string)))
9768 (gnus-delete-line)))))
9769 (or (zerop (buffer-size))
9771 (gnus-summary-prev-subject 1)
9772 (gnus-summary-position-cursor))))
9774 (defun gnus-summary-expunge-below (&optional score)
9775 "Remove articles with score less than SCORE."
9777 (gnus-set-global-variables)
9778 (setq score (if score
9779 (prefix-numeric-value score)
9780 (or gnus-summary-default-score 0)))
9782 (set-buffer gnus-summary-buffer)
9783 (goto-char (point-min))
9784 (let ((buffer-read-only nil)
9787 (if (< (gnus-summary-article-score) score)
9791 (delete-region beg (point)))
9794 (or (zerop (buffer-size))
9796 (gnus-summary-prev-subject 1)
9797 (gnus-summary-position-cursor))))))
9799 (defun gnus-summary-mark-below (score mark)
9800 "Mark articles with score less than SCORE with MARK."
9801 (interactive "P\ncMark: ")
9802 (gnus-set-global-variables)
9803 (setq score (if score
9804 (prefix-numeric-value score)
9805 (or gnus-summary-default-score 0)))
9807 (set-buffer gnus-summary-buffer)
9808 (goto-char (point-min))
9810 (and (< (gnus-summary-article-score) score)
9811 (gnus-summary-mark-article nil mark))
9814 (defun gnus-summary-kill-below (&optional score)
9815 "Mark articles with score below SCORE as read."
9817 (gnus-set-global-variables)
9818 (gnus-summary-mark-below score gnus-killed-mark))
9820 (defun gnus-summary-clear-above (&optional score)
9821 "Clear all marks from articles with score above SCORE."
9823 (gnus-set-global-variables)
9824 (gnus-summary-mark-above score gnus-unread-mark))
9826 (defun gnus-summary-tick-above (&optional score)
9827 "Tick all articles with score above SCORE."
9829 (gnus-set-global-variables)
9830 (gnus-summary-mark-above score gnus-ticked-mark))
9832 (defun gnus-summary-mark-above (score mark)
9833 "Mark articles with score over SCORE with MARK."
9834 (interactive "P\ncMark: ")
9835 (gnus-set-global-variables)
9836 (setq score (if score
9837 (prefix-numeric-value score)
9838 (or gnus-summary-default-score 0)))
9840 (set-buffer gnus-summary-buffer)
9841 (goto-char (point-min))
9843 (if (> (gnus-summary-article-score) score)
9845 (gnus-summary-mark-article nil mark)
9847 (forward-line 1)))))
9849 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9850 (defun gnus-summary-show-all-expunged ()
9851 "Display all the hidden articles that were expunged for low scores."
9853 (gnus-set-global-variables)
9854 (let ((buffer-read-only nil))
9855 (let ((scored gnus-newsgroup-scored)
9858 (or (gnus-summary-goto-subject (car (car scored)))
9859 (and (setq h (gnus-get-header-by-num (car (car scored))))
9860 (< (cdr (car scored)) gnus-summary-expunge-below)
9861 (setq headers (cons h headers))))
9862 (setq scored (cdr scored)))
9863 (or headers (error "No expunged articles hidden."))
9864 (goto-char (point-min))
9866 (gnus-summary-update-lines
9869 (gnus-summary-prepare-unthreaded (nreverse headers))
9871 (goto-char (point-min))
9872 (gnus-summary-position-cursor)))
9874 (defun gnus-summary-show-all-dormant ()
9875 "Display all the hidden articles that are marked as dormant."
9877 (gnus-set-global-variables)
9878 (let ((buffer-read-only nil))
9879 (let ((dormant gnus-newsgroup-dormant)
9882 (or (gnus-summary-goto-subject (car dormant))
9883 (and (setq h (gnus-get-header-by-num (car dormant)))
9884 (setq headers (cons h headers))))
9885 (setq dormant (cdr dormant)))
9886 (or headers (error "No dormant articles hidden."))
9887 (goto-char (point-min))
9889 (gnus-summary-update-lines
9892 (gnus-summary-prepare-unthreaded (nreverse headers))
9894 (goto-char (point-min))
9895 (gnus-summary-position-cursor)))
9897 (defun gnus-summary-hide-all-dormant ()
9898 "Hide all dormant articles."
9900 (gnus-set-global-variables)
9901 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9902 (gnus-summary-position-cursor))
9904 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9905 "Mark all articles not marked as unread in this newsgroup as read.
9906 If prefix argument ALL is non-nil, all articles are marked as read.
9907 If QUIETLY is non-nil, no questions will be asked.
9908 If TO-HERE is non-nil, it should be a point in the buffer. All
9909 articles before this point will be marked as read.
9910 The number of articles marked as read is returned."
9912 (gnus-set-global-variables)
9915 (not gnus-interactive-catchup) ;Without confirmation?
9919 "Mark absolutely all articles as read? "
9920 "Mark all unread articles as read? ")))
9922 (not gnus-newsgroup-adaptive)
9923 (not gnus-newsgroup-auto-expire))
9925 (and all (setq gnus-newsgroup-marked nil
9926 gnus-newsgroup-dormant nil))
9927 (setq gnus-newsgroup-unreads
9928 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9929 ;; We actually mark all articles as canceled, which we
9930 ;; have to do when using auto-expiry or adaptive scoring.
9931 (let ((unreads (length gnus-newsgroup-unreads)))
9932 (gnus-summary-show-all-threads)
9933 (if (gnus-summary-first-subject (not all))
9935 (if to-here (< (point) to-here) t)
9936 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9937 (gnus-summary-search-subject nil (not all)))))
9938 (- unreads (length gnus-newsgroup-unreads))
9940 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9941 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9942 (if (and (not to-here) (eq 'nnvirtual (car method)))
9943 (nnvirtual-catchup-group
9944 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9945 (gnus-summary-position-cursor)))
9947 (defun gnus-summary-catchup-to-here (&optional all)
9948 "Mark all unticked articles before the current one as read.
9949 If ALL is non-nil, also mark ticked and dormant articles as read."
9951 (gnus-set-global-variables)
9953 (and (zerop (forward-line -1))
9956 (gnus-summary-catchup all t (point))
9957 (gnus-set-mode-line 'summary))))
9958 (gnus-summary-position-cursor))
9960 (defun gnus-summary-catchup-all (&optional quietly)
9961 "Mark all articles in this newsgroup as read."
9963 (gnus-set-global-variables)
9964 (gnus-summary-catchup t quietly))
9966 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9967 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9968 If prefix argument ALL is non-nil, all articles are marked as read."
9970 (gnus-set-global-variables)
9971 (gnus-summary-catchup all quietly nil 'fast)
9972 ;; Select next newsgroup or exit.
9973 (if (eq gnus-auto-select-next 'quietly)
9974 (gnus-summary-next-group nil)
9975 (gnus-summary-exit)))
9977 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9978 "Mark all articles in this newsgroup as read, and then exit."
9980 (gnus-set-global-variables)
9981 (gnus-summary-catchup-and-exit t quietly))
9983 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9984 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9985 "Mark all articles in this group as read and select the next group.
9986 If given a prefix, mark all articles, unread as well as ticked, as
9989 (gnus-set-global-variables)
9990 (gnus-summary-catchup all)
9991 (gnus-summary-next-group))
9993 ;; Thread-based commands.
9995 (defun gnus-summary-toggle-threads (&optional arg)
9996 "Toggle showing conversation threads.
9997 If ARG is positive number, turn showing conversation threads on."
9999 (gnus-set-global-variables)
10000 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10001 (setq gnus-show-threads
10002 (if (null arg) (not gnus-show-threads)
10003 (> (prefix-numeric-value arg) 0)))
10004 (gnus-summary-prepare)
10005 (gnus-summary-goto-subject current)
10006 (gnus-summary-position-cursor)))
10008 (defun gnus-summary-show-all-threads ()
10009 "Show all threads."
10011 (gnus-set-global-variables)
10013 (let ((buffer-read-only nil))
10014 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10015 (gnus-summary-position-cursor))
10017 (defun gnus-summary-show-thread ()
10018 "Show thread subtrees.
10019 Returns nil if no thread was there to be shown."
10021 (gnus-set-global-variables)
10022 (let ((buffer-read-only nil)
10023 (orig (prog1 (point) (gnus-summary-hide-thread)))
10024 ;; first goto end then to beg, to have point at beg after let
10025 (end (progn (end-of-line) (point)))
10026 (beg (progn (beginning-of-line) (point))))
10028 ;; Any hidden lines here?
10029 (search-forward "\r" end t)
10030 (subst-char-in-region beg end ?\^M ?\n t)
10032 (gnus-summary-position-cursor))))
10034 (defun gnus-summary-hide-all-threads ()
10035 "Hide all thread subtrees."
10037 (gnus-set-global-variables)
10039 (goto-char (point-min))
10040 (gnus-summary-hide-thread)
10041 (while (and (not (eobp)) (zerop (forward-line 1)))
10042 (gnus-summary-hide-thread)))
10043 (gnus-summary-position-cursor))
10045 (defun gnus-summary-hide-thread ()
10046 "Hide thread subtrees.
10047 Returns nil if no threads were there to be hidden."
10049 (gnus-set-global-variables)
10050 (let ((buffer-read-only nil)
10052 (level (gnus-summary-thread-level))
10054 ;; Go forward until either the buffer ends or the subthread
10058 (while (and (zerop (forward-line 1))
10059 (> (gnus-summary-thread-level) level))
10060 (setq end (point)))
10064 (search-backward "\n" start t))
10065 (subst-char-in-region start end ?\n ?\^M t)
10067 (gnus-summary-position-cursor)))))
10069 (defun gnus-summary-go-to-next-thread (&optional previous)
10070 "Go to the same level (or less) next thread.
10071 If PREVIOUS is non-nil, go to previous thread instead.
10072 Return the article number moved to, or nil if moving was impossible."
10073 (let ((level (gnus-summary-thread-level))
10074 (article (gnus-summary-article-number)))
10076 (while (and (zerop (forward-line -1))
10077 (> (gnus-summary-thread-level) level)))
10078 (while (and (save-excursion
10081 (zerop (forward-line 1))
10082 (> (gnus-summary-thread-level) level))))
10083 (gnus-summary-recenter)
10084 (gnus-summary-position-cursor)
10085 (let ((oart (gnus-summary-article-number)))
10086 (and (/= oart article) oart))))
10088 (defun gnus-summary-next-thread (n)
10089 "Go to the same level next N'th thread.
10090 If N is negative, search backward instead.
10091 Returns the difference between N and the number of skips actually
10094 (gnus-set-global-variables)
10095 (let ((backward (< n 0))
10097 (while (and (> n 0)
10098 (gnus-summary-go-to-next-thread backward))
10100 (gnus-summary-position-cursor)
10101 (if (/= 0 n) (gnus-message 7 "No more threads"))
10104 (defun gnus-summary-prev-thread (n)
10105 "Go to the same level previous N'th thread.
10106 Returns the difference between N and the number of skips actually
10109 (gnus-set-global-variables)
10110 (gnus-summary-next-thread (- n)))
10112 (defun gnus-summary-go-down-thread (&optional same)
10113 "Go down one level in the current thread.
10114 If SAME is non-nil, also move to articles of the same level."
10115 (let ((level (gnus-summary-thread-level))
10117 (if (and (zerop (forward-line 1))
10118 (> (gnus-summary-thread-level) level))
10123 (defun gnus-summary-go-up-thread ()
10124 "Go up one level in the current thread."
10125 (let ((level (gnus-summary-thread-level))
10127 (while (and (zerop (forward-line -1))
10128 (>= (gnus-summary-thread-level) level)))
10129 (if (>= (gnus-summary-thread-level) level)
10135 (defun gnus-summary-down-thread (n)
10136 "Go down thread N steps.
10137 If N is negative, go up instead.
10138 Returns the difference between N and how many steps down that were
10141 (gnus-set-global-variables)
10144 (while (and (> n 0)
10145 (if up (gnus-summary-go-up-thread)
10146 (gnus-summary-go-down-thread)))
10148 (gnus-summary-position-cursor)
10149 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10152 (defun gnus-summary-up-thread (n)
10153 "Go up thread N steps.
10154 If N is negative, go up instead.
10155 Returns the difference between N and how many steps down that were
10158 (gnus-set-global-variables)
10159 (gnus-summary-down-thread (- n)))
10161 (defun gnus-summary-kill-thread (&optional unmark)
10162 "Mark articles under current thread as read.
10163 If the prefix argument is positive, remove any kinds of marks.
10164 If the prefix argument is negative, tick articles instead."
10166 (gnus-set-global-variables)
10168 (setq unmark (prefix-numeric-value unmark)))
10170 (level (gnus-summary-thread-level)))
10172 ;; Expand the thread.
10173 (gnus-summary-show-thread)
10175 ;; Mark the article...
10176 (cond ((null unmark) (gnus-summary-mark-article-as-read
10178 ((> unmark 0) (gnus-summary-mark-article-as-unread
10180 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10181 ;; ...and go forward until either the buffer ends or the subtree
10183 (if (not (and (zerop (forward-line 1))
10184 (> (gnus-summary-thread-level) level)))
10185 (setq killing nil))))
10186 ;; Hide killed subtrees.
10188 gnus-thread-hide-killed
10189 (gnus-summary-hide-thread))
10190 ;; If marked as read, go to next unread subject.
10192 ;; Go to next unread subject.
10193 (gnus-summary-next-subject 1 t)))
10194 (gnus-set-mode-line 'summary))
10196 ;; Summary sorting commands
10198 (defun gnus-summary-sort-by-number (&optional reverse)
10199 "Sort summary buffer by article number.
10200 Argument REVERSE means reverse order."
10202 (gnus-set-global-variables)
10204 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10205 ;; a function, so we wrap it.
10206 (cons (lambda () (gnus-summary-article-number))
10207 'gnus-thread-sort-by-number) reverse))
10209 (defun gnus-summary-sort-by-author (&optional reverse)
10210 "Sort summary buffer by author name alphabetically.
10211 If case-fold-search is non-nil, case of letters is ignored.
10212 Argument REVERSE means reverse order."
10214 (gnus-set-global-variables)
10218 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10220 gnus-extract-address-components
10221 (mail-header-from header))))
10222 (concat (or (car extract) (cdr extract))
10223 "\r" (mail-header-subject header))))
10224 'gnus-thread-sort-by-author)
10227 (defun gnus-summary-sort-by-subject (&optional reverse)
10228 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10229 If case-fold-search is non-nil, case of letters is ignored.
10230 Argument REVERSE means reverse order."
10232 (gnus-set-global-variables)
10236 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10238 gnus-extract-address-components
10239 (mail-header-from header))))
10241 (downcase (gnus-simplify-subject (gnus-summary-subject-string) t))
10242 "\r" (or (car extract) (cdr extract)))))
10243 'gnus-thread-sort-by-subject)
10246 (defun gnus-summary-sort-by-date (&optional reverse)
10247 "Sort summary buffer by date.
10248 Argument REVERSE means reverse order."
10250 (gnus-set-global-variables)
10254 (gnus-sortable-date
10256 (gnus-get-header-by-num (gnus-summary-article-number)))))
10257 'gnus-thread-sort-by-date)
10260 (defun gnus-summary-sort-by-score (&optional reverse)
10261 "Sort summary buffer by score.
10262 Argument REVERSE means reverse order."
10264 (gnus-set-global-variables)
10266 (cons (lambda () (gnus-summary-article-score))
10267 'gnus-thread-sort-by-score)
10270 (defvar gnus-summary-already-sorted nil)
10271 (defun gnus-summary-sort (predicate reverse)
10272 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10273 (if gnus-summary-already-sorted
10275 (let (buffer-read-only)
10276 (if (not gnus-show-threads)
10277 ;; We do untreaded sorting...
10279 (goto-char (point-min))
10280 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10281 ;; ... or we do threaded sorting.
10282 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10283 (gnus-summary-prepare-hook nil)
10284 (gnus-summary-already-sorted nil))
10285 ;; We do that by simply regenerating the threads.
10286 (gnus-summary-prepare)
10287 (and gnus-show-threads
10288 gnus-thread-hide-subtree
10289 (gnus-summary-hide-all-threads))
10290 ;; If in async mode, we send some info to the backend.
10291 (and gnus-newsgroup-async
10292 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10293 (gnus-request-asynchronous
10294 gnus-newsgroup-name
10295 (if (and gnus-asynchronous-article-function
10296 (fboundp gnus-asynchronous-article-function))
10297 (funcall gnus-asynchronous-article-function
10298 gnus-newsgroup-threads)))))))))
10301 (defun gnus-sortable-date (date)
10302 "Make sortable string by string-lessp from DATE.
10303 Timezone package is used."
10304 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10305 (year (aref date 0))
10306 (month (aref date 1))
10307 (day (aref date 2)))
10308 (timezone-make-sortable-date
10310 (timezone-make-time-string
10311 (aref date 3) (aref date 4) (aref date 5)))))
10314 ;; Summary saving commands.
10316 (defun gnus-summary-save-article (&optional n)
10317 "Save the current article using the default saver function.
10318 If N is a positive number, save the N next articles.
10319 If N is a negative number, save the N previous articles.
10320 If N is nil and any articles have been marked with the process mark,
10321 save those articles instead.
10322 The variable `gnus-default-article-saver' specifies the saver function."
10324 (gnus-set-global-variables)
10325 (let ((articles (gnus-summary-work-articles n)))
10327 (let ((header (gnus-get-header-by-num (car articles))))
10328 (if (vectorp header)
10330 (save-window-excursion
10331 (gnus-summary-select-article t nil nil (car articles)))
10332 (or gnus-save-all-headers
10333 (gnus-article-hide-headers t))
10334 ;; Remove any X-Gnus lines.
10337 (set-buffer gnus-article-buffer)
10338 (let ((buffer-read-only nil))
10339 (goto-char (point-min))
10340 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10342 (while (re-search-forward "^X-Gnus" nil t)
10343 (beginning-of-line)
10344 (delete-region (point)
10345 (progn (forward-line 1) (point))))
10347 (save-window-excursion
10348 (if gnus-default-article-saver
10349 (funcall gnus-default-article-saver)
10350 (error "No default saver is defined."))))
10351 (if (assq 'name header)
10352 (gnus-copy-file (cdr (assq 'name header)))
10353 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10354 (gnus-summary-remove-process-mark (car articles))
10355 (setq articles (cdr articles)))
10356 (gnus-summary-position-cursor)
10359 (defun gnus-summary-pipe-output (&optional arg)
10360 "Pipe the current article to a subprocess.
10361 If N is a positive number, pipe the N next articles.
10362 If N is a negative number, pipe the N previous articles.
10363 If N is nil and any articles have been marked with the process mark,
10364 pipe those articles instead."
10366 (gnus-set-global-variables)
10367 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10368 (gnus-summary-save-article arg)))
10370 (defun gnus-summary-save-article-mail (&optional arg)
10371 "Append the current article to an mail file.
10372 If N is a positive number, save the N next articles.
10373 If N is a negative number, save the N previous articles.
10374 If N is nil and any articles have been marked with the process mark,
10375 save those articles instead."
10377 (gnus-set-global-variables)
10378 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10379 (gnus-summary-save-article arg)))
10381 (defun gnus-summary-save-article-rmail (&optional arg)
10382 "Append the current article to an rmail file.
10383 If N is a positive number, save the N next articles.
10384 If N is a negative number, save the N previous articles.
10385 If N is nil and any articles have been marked with the process mark,
10386 save those articles instead."
10388 (gnus-set-global-variables)
10389 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10390 (gnus-summary-save-article arg)))
10392 (defun gnus-summary-save-article-file (&optional arg)
10393 "Append the current article to a file.
10394 If N is a positive number, save the N next articles.
10395 If N is a negative number, save the N previous articles.
10396 If N is nil and any articles have been marked with the process mark,
10397 save those articles instead."
10399 (gnus-set-global-variables)
10400 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10401 (gnus-summary-save-article arg)))
10403 (defun gnus-read-save-file-name (prompt default-name)
10404 (let ((methods gnus-split-methods)
10406 (if (not gnus-split-methods)
10409 (set-buffer gnus-article-buffer)
10410 (gnus-narrow-to-headers)
10412 (goto-char (point-min))
10413 (and (condition-case ()
10414 (re-search-forward (car (car methods)) nil t)
10416 (setq split-name (cons (nth 1 (car methods)) split-name)))
10417 (setq methods (cdr methods)))
10419 (cond ((null split-name)
10421 (concat prompt " (default "
10422 (file-name-nondirectory default-name) ") ")
10423 (file-name-directory default-name)
10425 ((= 1 (length split-name))
10427 (concat prompt " (default " (car split-name) ") ")
10428 gnus-article-save-directory
10429 (concat gnus-article-save-directory (car split-name))))
10431 (setq split-name (mapcar (lambda (el) (list el))
10432 (nreverse split-name)))
10433 (let ((result (completing-read
10434 (concat prompt " ")
10435 split-name nil nil)))
10436 (concat gnus-article-save-directory
10437 (if (string= result "")
10438 (car (car split-name))
10441 (defun gnus-summary-save-in-rmail (&optional filename)
10442 "Append this article to Rmail file.
10443 Optional argument FILENAME specifies file name.
10444 Directory to save to is default to `gnus-article-save-directory' which
10445 is initialized from the SAVEDIR environment variable."
10447 (gnus-set-global-variables)
10448 (let ((default-name
10449 (funcall gnus-rmail-save-name gnus-newsgroup-name
10450 gnus-current-headers gnus-newsgroup-last-rmail)))
10452 (setq filename (gnus-read-save-file-name
10453 "Save in rmail file:" default-name)))
10454 (gnus-make-directory (file-name-directory filename))
10455 (gnus-eval-in-buffer-window
10456 gnus-article-buffer
10460 (gnus-output-to-rmail filename))))
10461 ;; Remember the directory name to save articles
10462 (setq gnus-newsgroup-last-rmail filename)))
10464 (defun gnus-summary-save-in-mail (&optional filename)
10465 "Append this article to Unix mail file.
10466 Optional argument FILENAME specifies file name.
10467 Directory to save to is default to `gnus-article-save-directory' which
10468 is initialized from the SAVEDIR environment variable."
10470 (gnus-set-global-variables)
10471 (let ((default-name
10472 (funcall gnus-mail-save-name gnus-newsgroup-name
10473 gnus-current-headers gnus-newsgroup-last-mail)))
10475 (setq filename (gnus-read-save-file-name
10476 "Save in Unix mail file:" default-name)))
10478 (expand-file-name filename
10480 (file-name-directory default-name))))
10481 (gnus-make-directory (file-name-directory filename))
10482 (gnus-eval-in-buffer-window
10483 gnus-article-buffer
10487 (if (and (file-readable-p filename) (rmail-file-p filename))
10488 (gnus-output-to-rmail filename)
10489 (rmail-output filename 1 t t)))))
10490 ;; Remember the directory name to save articles.
10491 (setq gnus-newsgroup-last-mail filename)))
10493 (defun gnus-summary-save-in-file (&optional filename)
10494 "Append this article to file.
10495 Optional argument FILENAME specifies file name.
10496 Directory to save to is default to `gnus-article-save-directory' which
10497 is initialized from the SAVEDIR environment variable."
10499 (gnus-set-global-variables)
10500 (let ((default-name
10501 (funcall gnus-file-save-name gnus-newsgroup-name
10502 gnus-current-headers gnus-newsgroup-last-file)))
10504 (setq filename (gnus-read-save-file-name
10505 "Save in file:" default-name)))
10506 (gnus-make-directory (file-name-directory filename))
10507 (gnus-eval-in-buffer-window
10508 gnus-article-buffer
10512 (gnus-output-to-file filename))))
10513 ;; Remember the directory name to save articles.
10514 (setq gnus-newsgroup-last-file filename)))
10516 (defun gnus-summary-save-in-pipe (&optional command)
10517 "Pipe this article to subprocess."
10519 (gnus-set-global-variables)
10520 (let ((command (read-string "Shell command on article: "
10521 gnus-last-shell-command)))
10522 (if (string-equal command "")
10523 (setq command gnus-last-shell-command))
10524 (gnus-eval-in-buffer-window
10525 gnus-article-buffer
10528 (shell-command-on-region (point-min) (point-max) command nil)))
10529 (setq gnus-last-shell-command command)))
10531 ;; Summary extract commands
10533 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10534 (let ((buffer-read-only nil)
10535 (article (gnus-summary-article-number))
10537 (or (gnus-summary-goto-subject article)
10538 (error (format "No such article: %d" article)))
10539 (gnus-summary-position-cursor)
10540 ;; If all commands are to be bunched up on one line, we collect
10542 (if gnus-view-pseudos-separately
10544 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10547 (setq action (cdr (assq 'action (car ps))))
10548 (setq files (list (cdr (assq 'name (car ps)))))
10549 (while (and ps (cdr ps)
10550 (string= (or action "1")
10551 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10552 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10553 (setcdr ps (cdr (cdr ps))))
10556 (if (not (string-match "%s" action))
10557 (setq files (cons " " files)))
10558 (setq files (cons " " files))
10559 (and (assq 'execute (car ps))
10560 (setcdr (assq 'execute (car ps))
10561 (funcall (if (string-match "%s" action)
10564 (mapconcat (lambda (f) f) files " ")))))
10565 (setq ps (cdr ps)))))
10566 (if (and gnus-view-pseudos (not not-view))
10568 (and (assq 'execute (car pslist))
10569 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10570 (eq gnus-view-pseudos 'not-confirm)))
10571 (setq pslist (cdr pslist)))
10574 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10575 (gnus-summary-article-number)))
10578 (insert " " (file-name-nondirectory
10579 (cdr (assq 'name (car pslist))))
10580 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10581 (add-text-properties
10582 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10583 'gnus-mark gnus-unread-mark
10585 'gnus-pseudo (car pslist)))
10587 (gnus-sethash (int-to-string gnus-reffed-article-number)
10588 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10589 (setq gnus-newsgroup-unreads
10590 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10591 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10592 (setq pslist (cdr pslist)))))))
10594 (defun gnus-pseudos< (p1 p2)
10595 (let ((c1 (cdr (assq 'action p1)))
10596 (c2 (cdr (assq 'action p2))))
10597 (and c1 c2 (string< c1 c2))))
10599 (defun gnus-request-pseudo-article (props)
10600 (cond ((assq 'execute props)
10601 (gnus-execute-command (cdr (assq 'execute props)))))
10602 (let ((gnus-current-article (gnus-summary-article-number)))
10603 (run-hooks 'gnus-mark-article-hook)))
10605 (defun gnus-execute-command (command &optional automatic)
10607 (gnus-article-setup-buffer)
10608 (set-buffer gnus-article-buffer)
10609 (let ((command (if automatic command (read-string "Command: " command)))
10610 (buffer-read-only nil))
10612 (insert "$ " command "\n\n")
10613 (if gnus-view-pseudo-asynchronously
10614 (start-process "gnus-execute" nil "sh" "-c" command)
10615 (call-process "sh" nil t nil "-c" command)))))
10617 (defun gnus-copy-file (file &optional to)
10620 (list (read-file-name "Copy file: " default-directory)
10621 (read-file-name "Copy file to: " default-directory)))
10622 (gnus-set-global-variables)
10623 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10624 (and (file-directory-p to)
10625 (setq to (concat (file-name-as-directory to)
10626 (file-name-nondirectory file))))
10627 (copy-file file to))
10629 ;; Summary kill commands.
10631 (defun gnus-summary-edit-global-kill (article)
10632 "Edit the \"global\" kill file."
10633 (interactive (list (gnus-summary-article-number)))
10634 (gnus-set-global-variables)
10635 (gnus-group-edit-global-kill article))
10637 (defun gnus-summary-edit-local-kill ()
10638 "Edit a local kill file applied to the current newsgroup."
10640 (gnus-set-global-variables)
10641 (setq gnus-current-headers
10643 (int-to-string (gnus-summary-article-number))
10644 gnus-newsgroup-headers-hashtb-by-number))
10645 (gnus-set-global-variables)
10646 (gnus-group-edit-local-kill
10647 (gnus-summary-article-number) gnus-newsgroup-name))
10651 ;;; Gnus article mode
10654 (put 'gnus-article-mode 'mode-class 'special)
10656 (defvar gnus-boogaboo nil)
10658 (if gnus-article-mode-map
10660 (setq gnus-article-mode-map (make-keymap))
10661 (suppress-keymap gnus-article-mode-map)
10662 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10663 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10664 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10665 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10666 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10667 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10668 (define-key gnus-article-mode-map
10669 "\C-c\C-M" 'gnus-article-mail-with-original)
10670 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10671 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10672 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10673 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10674 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10676 ;; Duplicate almost all summary keystrokes in the article mode map.
10679 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10680 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10681 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10682 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10683 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10684 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10685 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10686 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10687 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10688 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10689 "\C-c\C-v\C-v" "\C-d" "v"
10690 ;; "Mt" "M!" "Md" "Mr"
10691 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10692 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10693 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10694 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10695 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10696 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10697 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10698 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10699 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10700 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10701 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10703 (while (and gnus-boogaboo commands) ; disabled
10704 (define-key gnus-article-mode-map (car commands)
10705 'gnus-article-summary-command)
10706 (setq commands (cdr commands))))
10708 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10709 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10710 "=" "n" "^" "\M-^")))
10711 (while (and gnus-boogaboo commands) ; disabled
10712 (define-key gnus-article-mode-map (car commands)
10713 'gnus-article-summary-command-nosave)
10714 (setq commands (cdr commands)))))
10717 (defun gnus-article-mode ()
10718 "Major mode for displaying an article.
10720 All normal editing commands are switched off.
10722 The following commands are available:
10724 \\<gnus-article-mode-map>
10725 \\[gnus-article-next-page]\t Scroll the article one page forwards
10726 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10727 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10728 \\[gnus-article-show-summary]\t Display the summary buffer
10729 \\[gnus-article-mail]\t Send a reply to the address near point
10730 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10731 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10732 \\[gnus-info-find-node]\t Go to the Gnus info node"
10734 (if gnus-visual (gnus-article-make-menu-bar))
10735 (kill-all-local-variables)
10736 (setq mode-line-modified "-- ")
10737 (make-local-variable 'mode-line-format)
10738 (setq mode-line-format (copy-sequence mode-line-format))
10739 (and (equal (nth 3 mode-line-format) " ")
10740 (setcar (nthcdr 3 mode-line-format) ""))
10741 (setq mode-name "Article")
10742 (setq major-mode 'gnus-article-mode)
10743 (make-local-variable 'minor-mode-alist)
10744 (or (assq 'gnus-show-mime minor-mode-alist)
10745 (setq minor-mode-alist
10746 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10747 (use-local-map gnus-article-mode-map)
10748 (make-local-variable 'page-delimiter)
10749 (setq page-delimiter gnus-page-delimiter)
10750 (buffer-disable-undo (current-buffer))
10751 (setq buffer-read-only t) ;Disable modification
10752 (run-hooks 'gnus-article-mode-hook))
10754 (defun gnus-article-setup-buffer ()
10755 "Initialize article mode buffer."
10756 ;; Returns the article buffer.
10757 (if (get-buffer gnus-article-buffer)
10759 (set-buffer gnus-article-buffer)
10760 (buffer-disable-undo (current-buffer))
10761 (setq buffer-read-only t)
10762 (gnus-add-current-to-buffer-list)
10763 (or (eq major-mode 'gnus-article-mode)
10764 (gnus-article-mode))
10767 (set-buffer (get-buffer-create gnus-article-buffer))
10768 (gnus-add-current-to-buffer-list)
10769 (gnus-article-mode)
10770 (current-buffer))))
10772 ;; Set article window start at LINE, where LINE is the number of lines
10773 ;; from the head of the article.
10774 (defun gnus-article-set-window-start (&optional line)
10776 (get-buffer-window gnus-article-buffer)
10778 (set-buffer gnus-article-buffer)
10779 (goto-char (point-min))
10782 (gnus-message 6 "Moved to bookmark")
10783 (search-forward "\n\n" nil t)
10784 (forward-line line)
10787 (defun gnus-request-article-this-buffer (article group)
10788 "Get an article and insert it into this buffer."
10789 (setq group (or group gnus-newsgroup-name))
10791 ;; Open server if it has closed.
10792 (gnus-check-server (gnus-find-method-for-group group))
10794 ;; Using `gnus-request-article' directly will insert the article into
10795 ;; `nntp-server-buffer' - so we'll save some time by not having to
10796 ;; copy it from the server buffer into the article buffer.
10798 ;; We only request an article by message-id when we do not have the
10799 ;; headers for it, so we'll have to get those.
10800 (and (stringp article)
10801 (let ((gnus-override-method gnus-refer-article-method))
10802 (gnus-read-header article)))
10804 ;; If the article number is negative, that means that this article
10805 ;; doesn't belong in this newsgroup (possibly), so we find its
10806 ;; message-id and request it by id instead of number.
10807 (if (not (numberp article))
10810 (set-buffer gnus-summary-buffer)
10811 (let ((header (gnus-get-header-by-num article)))
10813 (if (vectorp header)
10814 ;; It's a real article.
10815 (setq article (mail-header-id header))
10816 ;; It is an extracted pseudo-article.
10817 (setq article 'pseudo)
10818 (gnus-request-pseudo-article header)))
10820 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10821 (if (not (eq (car method) 'nneething))
10823 (let ((dir (concat (file-name-as-directory (nth 1 method))
10824 (mail-header-subject header))))
10825 (if (file-directory-p dir)
10827 (setq article 'nneething)
10828 (gnus-group-enter-directory dir)))))))))
10830 ;; Check the cache.
10831 (if (and gnus-use-cache
10833 (gnus-cache-request-article article group))
10835 ;; Get the article and into the article buffer.
10836 (if (or (stringp article) (numberp article))
10839 (let ((gnus-override-method
10840 (and (stringp article) gnus-refer-article-method)))
10841 (and (gnus-request-article article group (current-buffer))
10845 (defun gnus-read-header (id)
10846 "Read the headers of article ID and enter them into the Gnus system."
10848 (if (not (setq header
10849 (car (if (let ((gnus-nov-is-evil t))
10850 (gnus-retrieve-headers
10851 (list id) gnus-newsgroup-name))
10852 (gnus-get-newsgroup-headers)))))
10855 (mail-header-set-number header gnus-reffed-article-number))
10856 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10857 (gnus-sethash (int-to-string (mail-header-number header)) header
10858 gnus-newsgroup-headers-hashtb-by-number)
10860 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10861 (setq gnus-current-headers header)
10864 (defun gnus-article-prepare (article &optional all-headers header)
10865 "Prepare ARTICLE in article mode buffer.
10866 ARTICLE should either be an article number or a Message-ID.
10867 If ARTICLE is an id, HEADER should be the article headers.
10868 If ALL-HEADERS is non-nil, no headers are hidden."
10870 ;; Make sure we start in a summary buffer.
10871 (or (eq major-mode 'gnus-summary-mode)
10872 (set-buffer gnus-summary-buffer))
10873 (setq gnus-summary-buffer (current-buffer))
10874 ;; Make sure the connection to the server is alive.
10875 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10878 (gnus-find-method-for-group gnus-newsgroup-name))
10879 (gnus-request-group gnus-newsgroup-name t)))
10880 (let* ((article (if header (mail-header-number header) article))
10881 (summary-buffer (current-buffer))
10882 (internal-hook gnus-article-internal-prepare-hook)
10883 (group gnus-newsgroup-name)
10886 (gnus-article-setup-buffer)
10887 (set-buffer gnus-article-buffer)
10888 (if (not (setq result (let ((buffer-read-only nil))
10889 (gnus-request-article-this-buffer
10891 ;; There is no such article.
10893 (if (not (numberp article))
10895 (setq gnus-article-current
10896 (cons gnus-newsgroup-name article))
10897 (set-buffer gnus-summary-buffer)
10898 (setq gnus-current-article article)
10899 (gnus-summary-mark-article article gnus-canceled-mark))
10900 (gnus-message 1 "No such article (may be canceled)")
10903 (if (or (eq result 'pseudo) (eq result 'nneething))
10906 (set-buffer summary-buffer)
10907 (setq gnus-last-article gnus-current-article
10908 gnus-newsgroup-history (cons gnus-current-article
10909 gnus-newsgroup-history)
10910 gnus-current-article 0
10911 gnus-current-headers nil
10912 gnus-article-current nil)
10913 (if (eq result 'nneething)
10914 (gnus-configure-windows 'summary)
10915 (gnus-configure-windows 'article))
10916 (gnus-set-global-variables))
10917 (gnus-set-mode-line 'article))
10918 ;; The result from the `request' was an actual article -
10919 ;; or at least some text that is now displayed in the
10921 (if (and (numberp article)
10922 (not (eq article gnus-current-article)))
10923 ;; Seems like a new article has been selected.
10924 ;; `gnus-current-article' must be an article number.
10926 (set-buffer summary-buffer)
10927 (setq gnus-last-article gnus-current-article
10928 gnus-newsgroup-history (cons gnus-current-article
10929 gnus-newsgroup-history)
10930 gnus-current-article article
10931 gnus-current-headers
10932 (gnus-get-header-by-num gnus-current-article)
10933 gnus-article-current
10934 (cons gnus-newsgroup-name gnus-current-article))
10935 (gnus-summary-show-thread)
10936 (run-hooks 'gnus-mark-article-hook)
10937 (gnus-set-mode-line 'summary)
10939 (run-hooks 'gnus-visual-mark-article-hook))
10940 ;; Set the global newsgroup variables here.
10941 ;; Suggested by Jim Sisolak
10942 ;; <sisolak@trans4.neep.wisc.edu>.
10943 (gnus-set-global-variables)
10944 (setq gnus-have-all-headers
10945 (or all-headers gnus-show-all-headers))
10946 (and gnus-use-cache
10947 (vectorp (gnus-get-header-by-number article))
10948 (gnus-cache-possibly-enter-article
10950 (gnus-get-header-by-number article)
10951 (memq article gnus-newsgroup-marked)
10952 (memq article gnus-newsgroup-dormant)
10953 (memq article gnus-newsgroup-unreads)))))
10954 ;; Hooks for getting information from the article.
10955 ;; This hook must be called before being narrowed.
10956 (let (buffer-read-only)
10957 (run-hooks 'internal-hook)
10958 (run-hooks 'gnus-article-prepare-hook)
10959 ;; Decode MIME message.
10960 (if (and gnus-show-mime
10961 (or (not gnus-strict-mime)
10962 (gnus-fetch-field "Mime-Version")))
10963 (funcall gnus-show-mime-method))
10964 ;; Perform the article display hooks.
10965 (run-hooks 'gnus-article-display-hook))
10967 (goto-char (point-min))
10968 (and gnus-break-pages (gnus-narrow-to-page))
10969 (gnus-set-mode-line 'article)
10970 (gnus-configure-windows 'article)
10971 (goto-char (point-min))
10974 (defun gnus-article-show-all-headers ()
10975 "Show all article headers in article mode buffer."
10977 (gnus-article-setup-buffer)
10978 (set-buffer gnus-article-buffer)
10979 (let ((buffer-read-only nil))
10980 (remove-text-properties (point-min) (point-max)
10981 gnus-hidden-properties))))
10983 (defun gnus-article-hide-headers-if-wanted ()
10984 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10985 Provided for backwards compatability."
10986 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10987 (gnus-article-hide-headers)))
10989 (defun gnus-article-hide-headers (&optional delete)
10990 "Hide unwanted headers and possibly sort them as well."
10993 (set-buffer gnus-article-buffer)
10995 (let ((sorted gnus-sorted-header-list)
10996 (buffer-read-only nil)
10997 want-list beg want-l)
10998 ;; First we narrow to just the headers.
11000 (goto-char (point-min))
11001 ;; Hide any "From " lines at the beginning of (mail) articles.
11002 (while (looking-at "From ")
11005 (add-text-properties (point-min) (point) gnus-hidden-properties))
11006 ;; Then treat the rest of the header lines.
11009 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
11010 ;; Then we use the two regular expressions
11011 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11012 ;; select which header lines is to remain visible in the
11014 (goto-char (point-min))
11015 (while (re-search-forward "^[^ \t]*:" nil t)
11016 (beginning-of-line)
11017 ;; We add the headers we want to keep to a list and delete
11018 ;; them from the buffer.
11019 (if (or (and (stringp gnus-visible-headers)
11020 (looking-at gnus-visible-headers))
11021 (and (not (stringp gnus-visible-headers))
11022 (stringp gnus-ignored-headers)
11023 (not (looking-at gnus-ignored-headers))))
11027 ;; Be sure to get multi-line headers...
11028 (re-search-forward "^[^ \t]*:" nil t)
11029 (beginning-of-line)
11031 (cons (buffer-substring beg (point)) want-list))
11032 (delete-region beg (point))
11035 ;; Next we perform the sorting by looking at
11036 ;; `gnus-sorted-header-list'.
11037 (goto-char (point-min))
11038 (while (and sorted want-list)
11039 (setq want-l want-list)
11041 (not (string-match (car sorted) (car want-l))))
11042 (setq want-l (cdr want-l)))
11045 (insert (car want-l))
11046 (setq want-list (delq (car want-l) want-list))))
11047 (setq sorted (cdr sorted)))
11048 ;; Any headers that were not matched by the sorted list we
11049 ;; just tack on the end of the visible header list.
11051 (insert (car want-list))
11052 (setq want-list (cdr want-list)))
11053 ;; And finally we make the unwanted headers invisible.
11055 (delete-region (point) (point-max))
11056 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11057 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11059 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11060 (defun gnus-article-treat-overstrike ()
11061 "Translate overstrikes into bold text."
11064 (set-buffer gnus-article-buffer)
11065 (let ((buffer-read-only nil))
11066 (while (search-forward "\b" nil t)
11067 (let ((next (following-char))
11068 (previous (char-after (- (point) 2))))
11069 (cond ((eq next previous)
11070 (put-text-property (- (point) 2) (point)
11072 (put-text-property (point) (1+ (point))
11075 (put-text-property (1- (point)) (1+ (point))
11077 (put-text-property (1- (point)) (point)
11080 (put-text-property (- (point) 2) (point)
11082 (put-text-property (point) (1+ (point))
11083 'face 'underline))))))))
11085 (defun gnus-article-word-wrap ()
11086 "Format too long lines."
11089 (set-buffer gnus-article-buffer)
11090 (let ((buffer-read-only nil))
11091 (goto-char (point-min))
11092 (search-forward "\n\n" nil t)
11094 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11095 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11096 (adaptive-fill-mode t))
11097 (while (not (eobp))
11098 (and (>= (current-column) (min fill-column (window-width)))
11099 (/= (preceding-char) ?:)
11100 (fill-paragraph nil))
11101 (end-of-line 2))))))
11103 (defun gnus-article-remove-cr ()
11104 "Remove carriage returns from an article."
11107 (set-buffer gnus-article-buffer)
11108 (let ((buffer-read-only nil))
11109 (goto-char (point-min))
11110 (while (search-forward "\r" nil t)
11111 (replace-match "" t t)))))
11113 (defun gnus-article-display-x-face (&optional force)
11114 "Look for an X-Face header and display it if present."
11115 (interactive (list 'force))
11117 (set-buffer gnus-article-buffer)
11118 (let ((inhibit-point-motion-hooks t)
11119 (case-fold-search nil))
11121 (goto-char (point-min))
11122 (search-forward "\n\n")
11123 (narrow-to-region (point-min) (point))
11124 (goto-char (point-min))
11125 (if (not (and gnus-article-x-face-command
11127 (not gnus-article-x-face-too-ugly)
11128 (and gnus-article-x-face-too-ugly
11129 (not (string-match gnus-article-x-face-too-ugly
11130 (mail-fetch-field "from")))))
11132 (goto-char (point-min))
11133 (re-search-forward "^X-Face: " nil t))))
11135 (let ((beg (point))
11136 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11137 (if (symbolp gnus-article-x-face-command)
11138 (and (or (fboundp gnus-article-x-face-command)
11139 (error "%s is not a function"
11140 gnus-article-x-face-command))
11141 (funcall gnus-article-x-face-command beg end))
11142 (call-process-region beg end "sh" nil 0 nil
11143 "-c" gnus-article-x-face-command))))))))
11145 (defun gnus-article-de-quoted-unreadable (&optional force)
11146 "Do a naïve translation of a quoted-printable-encoded article.
11147 This is in no way, shape or form meant as a replacement for real MIME
11148 processing, but is simply a stop-gap measure until MIME support is
11150 If FORCE, decode the article whether it is marked as quoted-printable
11152 (interactive (list 'force))
11154 (set-buffer gnus-article-buffer)
11155 (let ((case-fold-search t)
11156 (buffer-read-only nil)
11157 (type (gnus-fetch-field "content-transfer-encoding")))
11158 (if (or force (and type (string-match "quoted-printable" type)))
11160 (goto-char (point-min))
11161 (search-forward "\n\n" nil 'move)
11162 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11164 (defun gnus-mime-decode-quoted-printable (from to)
11165 ;; Decode quoted-printable from region between FROM and TO.
11168 (while (search-forward "=" to t)
11169 (cond ((eq (following-char) ?\n)
11172 ((looking-at "[0-9A-F][0-9A-F]")
11174 (insert (hexl-hex-string-to-integer
11175 (buffer-substring (point) (+ 2 (point)))))
11179 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11181 (defvar gnus-article-time-units
11182 (list (cons 'year (* 365.25 24 60 60))
11183 (cons 'week (* 7 24 60 60))
11184 (cons 'day (* 24 60 60))
11185 (cons 'hour (* 60 60))
11189 (defun gnus-article-date-ut (&optional type)
11190 "Convert DATE date to universal time in the current article.
11191 If TYPE is `local', convert to local time; if it is `lapsed', output
11192 how much time has lapsed since DATE."
11193 (interactive (list 'ut))
11194 (let ((date (mail-header-date (or gnus-current-headers
11195 (gnus-get-header-by-number
11196 (gnus-summary-article-number))"")))
11197 (date-regexp "^Date: \\|^X-Sent: "))
11202 (set-buffer gnus-article-buffer)
11203 (let ((buffer-read-only nil))
11204 (goto-char (point-min))
11205 (if (and (re-search-forward date-regexp nil t)
11207 (beginning-of-line)
11208 (looking-at date-regexp)))
11209 (delete-region (gnus-point-at-bol)
11210 (progn (end-of-line) (1+ (point))))
11211 (goto-char (point-min))
11212 (goto-char (- (search-forward "\n\n") 2)))
11216 (concat "Date: " (condition-case ()
11217 (timezone-make-date-arpa-standard date)
11223 (timezone-make-date-arpa-standard date nil "UT")
11227 ;; If the date is seriously mangled, the timezone
11228 ;; functions are liable to bug out, so we condition-case
11229 ;; the entire thing.
11230 (let* ((real-sec (condition-case ()
11231 (- (gnus-seconds-since-epoch
11232 (timezone-make-date-arpa-standard
11233 (current-time-string)
11234 (current-time-zone) "UT"))
11235 (gnus-seconds-since-epoch
11236 (timezone-make-date-arpa-standard
11239 (sec (abs real-sec))
11247 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11249 (setq sec (- sec (* num (cdr unit))))
11251 (concat (if prev ", " "") (int-to-string
11253 " " (symbol-name (car unit))
11254 (if (> num 1) "s" ""))
11256 gnus-article-time-units "")
11259 " in the future\n")))))
11261 (error "Unknown conversion type: %s" type)))))))))
11263 (defun gnus-article-date-local ()
11264 "Convert the current article date to the local timezone."
11266 (gnus-article-date-ut 'local))
11268 (defun gnus-article-date-lapsed ()
11269 "Convert the current article date to time lapsed since it was sent."
11271 (gnus-article-date-ut 'lapsed))
11273 (defun gnus-article-maybe-highlight ()
11274 "Do some article highlighting if `gnus-visual' is non-nil."
11275 (if gnus-visual (gnus-article-highlight-some)))
11279 (defun gnus-output-to-rmail (file-name)
11280 "Append the current article to an Rmail file named FILE-NAME."
11282 ;; Most of these codes are borrowed from rmailout.el.
11283 (setq file-name (expand-file-name file-name))
11284 (setq rmail-default-rmail-file file-name)
11285 (let ((artbuf (current-buffer))
11286 (tmpbuf (get-buffer-create " *Gnus-output*")))
11288 (or (get-file-buffer file-name)
11289 (file-exists-p file-name)
11290 (if (gnus-yes-or-no-p
11291 (concat "\"" file-name "\" does not exist, create it? "))
11292 (let ((file-buffer (create-file-buffer file-name)))
11294 (set-buffer file-buffer)
11295 (rmail-insert-rmail-file-header)
11296 (let ((require-final-newline nil))
11297 (write-region (point-min) (point-max) file-name t 1)))
11298 (kill-buffer file-buffer))
11299 (error "Output file does not exist")))
11300 (set-buffer tmpbuf)
11301 (buffer-disable-undo (current-buffer))
11303 (insert-buffer-substring artbuf)
11304 (gnus-convert-article-to-rmail)
11305 ;; Decide whether to append to a file or to an Emacs buffer.
11306 (let ((outbuf (get-file-buffer file-name)))
11308 (append-to-file (point-min) (point-max) file-name)
11309 ;; File has been visited, in buffer OUTBUF.
11310 (set-buffer outbuf)
11311 (let ((buffer-read-only nil)
11312 (msg (and (boundp 'rmail-current-message)
11313 (symbol-value 'rmail-current-message))))
11314 ;; If MSG is non-nil, buffer is in RMAIL mode.
11317 (narrow-to-region (point-max) (point-max))))
11318 (insert-buffer-substring tmpbuf)
11321 (goto-char (point-min))
11323 (search-backward "\^_")
11324 (narrow-to-region (point) (point-max))
11325 (goto-char (1+ (point-min)))
11326 (rmail-count-new-messages t)
11327 (rmail-show-message msg)))))))
11328 (kill-buffer tmpbuf)))
11330 (defun gnus-output-to-file (file-name)
11331 "Append the current article to a file named FILE-NAME."
11332 (setq file-name (expand-file-name file-name))
11333 (let ((artbuf (current-buffer))
11334 (tmpbuf (get-buffer-create " *Gnus-output*")))
11336 (set-buffer tmpbuf)
11337 (buffer-disable-undo (current-buffer))
11339 (insert-buffer-substring artbuf)
11340 ;; Append newline at end of the buffer as separator, and then
11341 ;; save it to file.
11342 (goto-char (point-max))
11344 (append-to-file (point-min) (point-max) file-name))
11345 (kill-buffer tmpbuf)))
11347 (defun gnus-convert-article-to-rmail ()
11348 "Convert article in current buffer to Rmail message format."
11349 (let ((buffer-read-only nil))
11350 ;; Convert article directly into Babyl format.
11351 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11352 (goto-char (point-min))
11353 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11354 (while (search-forward "\n\^_" nil t) ;single char
11355 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11356 (goto-char (point-max))
11359 (defun gnus-narrow-to-page (&optional arg)
11360 "Make text outside current page invisible except for page delimiter.
11361 A numeric arg specifies to move forward or backward by that many pages,
11362 thus showing a page other than the one point was originally in."
11364 (setq arg (if arg (prefix-numeric-value arg) 0))
11366 (forward-page -1) ;Beginning of current page.
11371 (forward-page (1- arg))))
11372 ;; Find the end of the page.
11374 ;; If we stopped due to end of buffer, stay there.
11375 ;; If we stopped after a page delimiter, put end of restriction
11376 ;; at the beginning of that line.
11377 ;; These are commented out.
11378 ;; (if (save-excursion (beginning-of-line)
11379 ;; (looking-at page-delimiter))
11380 ;; (beginning-of-line))
11381 (narrow-to-region (point)
11383 ;; Find the top of the page.
11385 ;; If we found beginning of buffer, stay there.
11386 ;; If extra text follows page delimiter on same line,
11388 ;; Otherwise, show text starting with following line.
11389 (if (and (eolp) (not (bobp)))
11393 (defun gnus-gmt-to-local ()
11394 "Rewrite Date header described in GMT to local in current buffer.
11395 Intended to be used with gnus-article-prepare-hook."
11399 (goto-char (point-min))
11400 (narrow-to-region (point-min)
11401 (progn (search-forward "\n\n" nil 'move) (point)))
11402 (goto-char (point-min))
11403 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11404 (let ((buffer-read-only nil)
11405 (date (buffer-substring-no-properties
11406 (match-beginning 1) (match-end 1))))
11407 (delete-region (match-beginning 1) (match-end 1))
11409 (timezone-make-date-arpa-standard
11410 date nil (current-time-zone))))))))
11413 ;; Article mode commands
11415 (defun gnus-article-next-page (&optional lines)
11416 "Show next page of current article.
11417 If end of article, return non-nil. Otherwise return nil.
11418 Argument LINES specifies lines to be scrolled up."
11420 (move-to-window-line -1)
11421 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11422 (if (save-excursion
11424 (and (pos-visible-in-window-p) ;Not continuation line.
11426 ;; Nothing in this page.
11427 (if (or (not gnus-break-pages)
11430 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11432 (gnus-narrow-to-page 1) ;Go to next page.
11434 ;; More in this page.
11438 ;; Long lines may cause an end-of-buffer error.
11439 (goto-char (point-max))))
11442 (defun gnus-article-prev-page (&optional lines)
11443 "Show previous page of current article.
11444 Argument LINES specifies lines to be scrolled down."
11446 (move-to-window-line 0)
11447 (if (and gnus-break-pages
11449 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11451 (gnus-narrow-to-page -1) ;Go to previous page.
11452 (goto-char (point-max))
11454 (scroll-down lines)))
11456 (defun gnus-article-refer-article ()
11457 "Read article specified by message-id around point."
11459 (search-forward ">" nil t) ;Move point to end of "<....>".
11460 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11462 (buffer-substring (match-beginning 1) (match-end 1))))
11463 (set-buffer gnus-summary-buffer)
11464 (gnus-summary-refer-article message-id))
11465 (error "No references around point")))
11467 (defun gnus-article-show-summary ()
11468 "Reconfigure windows to show summary buffer."
11470 (gnus-configure-windows 'article)
11471 (gnus-summary-goto-subject gnus-current-article))
11473 (defun gnus-article-describe-briefly ()
11474 "Describe article mode commands briefly."
11477 (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")))
11479 (defun gnus-article-summary-command ()
11480 "Execute the last keystroke in the summary buffer."
11482 (let ((obuf (current-buffer))
11483 (owin (current-window-configuration))
11485 (switch-to-buffer gnus-summary-buffer 'norecord)
11486 (setq func (lookup-key (current-local-map) (this-command-keys)))
11487 (call-interactively func)
11489 (set-window-configuration owin)
11490 (set-window-point (get-buffer-window (current-buffer)) (point))))
11492 (defun gnus-article-summary-command-nosave ()
11493 "Execute the last keystroke in the summary buffer."
11496 (pop-to-buffer gnus-summary-buffer 'norecord)
11497 (setq func (lookup-key (current-local-map) (this-command-keys)))
11498 (call-interactively func)))
11501 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11504 (defalias 'gnus-batch-kill 'gnus-batch-score)
11506 (defun gnus-batch-score ()
11507 "Run batched scoring.
11508 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11509 Newsgroups is a list of strings in Bnews format. If you want to score
11510 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11511 score the alt hierarchy, you'd say \"!alt.all\"."
11514 (gnus-newsrc-parse-options
11515 (apply (function concat)
11516 (mapcar (lambda (g) (concat g " "))
11517 command-line-args-left))))
11518 (gnus-expert-user t)
11519 (nnmail-spool-file nil)
11520 (gnus-use-dribble-file nil)
11521 (yes (car yes-and-no))
11522 (no (cdr yes-and-no))
11524 ;; Disable verbose message.
11525 gnus-novice-user gnus-large-newsgroup)
11526 ;; Eat all arguments.
11527 (setq command-line-args-left nil)
11530 ;; Apply kills to specified newsgroups in command line arguments.
11531 (setq newsrc (cdr gnus-newsrc-alist))
11533 (setq group (car (car newsrc)))
11534 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11535 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11537 (or (eq (car entry) t)
11538 (not (zerop (car entry)))))
11539 (if yes (string-match yes group) t)
11540 (or (null no) (not (string-match no group))))
11542 (gnus-summary-read-group group nil t)
11543 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11544 (gnus-summary-exit))))
11545 (setq newsrc (cdr newsrc)))
11547 (switch-to-buffer gnus-group-buffer)
11548 (gnus-group-save-newsrc)))
11550 (defun gnus-apply-kill-file ()
11551 "Apply a kill file to the current newsgroup.
11552 Returns the number of articles marked as read."
11553 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11554 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11555 (gnus-apply-kill-file-internal)
11558 (defun gnus-kill-save-kill-buffer ()
11560 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11561 (if (get-file-buffer file)
11563 (set-buffer (get-file-buffer file))
11564 (and (buffer-modified-p) (save-buffer))
11565 (kill-buffer (current-buffer)))))))
11567 (defvar gnus-kill-file-name "KILL"
11568 "Suffix of the kill files.")
11570 (defun gnus-newsgroup-kill-file (newsgroup)
11571 "Return the name of a kill file name for NEWSGROUP.
11572 If NEWSGROUP is nil, return the global kill file name instead."
11573 (cond ((or (null newsgroup)
11574 (string-equal newsgroup ""))
11575 ;; The global KILL file is placed at top of the directory.
11576 (expand-file-name gnus-kill-file-name
11577 (or gnus-kill-files-directory "~/News")))
11578 ((gnus-use-long-file-name 'not-kill)
11579 ;; Append ".KILL" to newsgroup name.
11580 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
11581 "." gnus-kill-file-name)
11582 (or gnus-kill-files-directory "~/News")))
11584 ;; Place "KILL" under the hierarchical directory.
11585 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11586 "/" gnus-kill-file-name)
11587 (or gnus-kill-files-directory "~/News")))))
11594 (defvar gnus-dribble-ignore nil)
11595 (defvar gnus-dribble-eval-file nil)
11597 (defun gnus-dribble-file-name ()
11598 (concat gnus-current-startup-file "-dribble"))
11600 (defun gnus-dribble-enter (string)
11601 (if (and (not gnus-dribble-ignore)
11602 gnus-dribble-buffer
11603 (buffer-name gnus-dribble-buffer))
11604 (let ((obuf (current-buffer)))
11605 (set-buffer gnus-dribble-buffer)
11606 (insert string "\n")
11607 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11608 (set-buffer obuf))))
11610 (defun gnus-dribble-read-file ()
11611 (let ((dribble-file (gnus-dribble-file-name)))
11613 (set-buffer (setq gnus-dribble-buffer
11615 (file-name-nondirectory dribble-file))))
11616 (gnus-add-current-to-buffer-list)
11618 (set-visited-file-name dribble-file)
11619 (buffer-disable-undo (current-buffer))
11620 (bury-buffer (current-buffer))
11621 (set-buffer-modified-p nil)
11622 (let ((auto (make-auto-save-file-name))
11623 (gnus-dribble-ignore t))
11624 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11626 (if (file-newer-than-file-p auto dribble-file)
11627 (setq dribble-file auto))
11628 (insert-file-contents dribble-file)
11629 (if (not (zerop (buffer-size)))
11630 (set-buffer-modified-p t))
11632 "Auto-save file exists. Do you want to read it? ")
11633 (setq gnus-dribble-eval-file t))))))))
11635 (defun gnus-dribble-eval-file ()
11636 (if (not gnus-dribble-eval-file)
11638 (setq gnus-dribble-eval-file nil)
11640 (let ((gnus-dribble-ignore t))
11641 (set-buffer gnus-dribble-buffer)
11642 (eval-buffer (current-buffer))))))
11644 (defun gnus-dribble-delete-file ()
11645 (if (file-exists-p (gnus-dribble-file-name))
11646 (delete-file (gnus-dribble-file-name)))
11647 (if gnus-dribble-buffer
11649 (set-buffer gnus-dribble-buffer)
11650 (let ((auto (make-auto-save-file-name)))
11651 (if (file-exists-p auto)
11652 (delete-file auto))
11654 (set-buffer-modified-p nil)))))
11656 (defun gnus-dribble-save ()
11657 (if (and gnus-dribble-buffer
11658 (buffer-name gnus-dribble-buffer))
11660 (set-buffer gnus-dribble-buffer)
11663 (defun gnus-dribble-clear ()
11665 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11667 (set-buffer gnus-dribble-buffer)
11669 (set-buffer-modified-p nil)
11670 (setq buffer-saved-size (buffer-size))))))
11673 ;;; Server Communication
11676 (defun gnus-start-news-server (&optional confirm)
11677 "Open a method for getting news.
11678 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11680 (if gnus-current-select-method
11681 ;; Stream is already opened.
11683 ;; Open NNTP server.
11684 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11687 ;; Read server name with completion.
11688 (setq gnus-nntp-server
11689 (completing-read "NNTP server: "
11690 (mapcar (lambda (server) (list server))
11691 (cons (list gnus-nntp-server)
11692 gnus-secondary-servers))
11693 nil nil gnus-nntp-server))))
11695 (if (and gnus-nntp-server
11696 (stringp gnus-nntp-server)
11697 (not (string= gnus-nntp-server "")))
11698 (setq gnus-select-method
11699 (cond ((or (string= gnus-nntp-server "")
11700 (string= gnus-nntp-server "::"))
11701 (list 'nnspool (system-name)))
11702 ((string-match "^:" gnus-nntp-server)
11703 (list 'nnmh gnus-nntp-server
11704 (list 'nnmh-directory
11705 (file-name-as-directory
11707 (concat "~/" (substring
11708 gnus-nntp-server 1)))))
11709 (list 'nnmh-get-new-mail nil)))
11711 (list 'nntp gnus-nntp-server)))))
11713 (setq how (car gnus-select-method))
11714 (cond ((eq how 'nnspool)
11716 (gnus-message 5 "Looking up local news spool..."))
11719 (gnus-message 5 "Looking up mh spool..."))
11722 (setq gnus-current-select-method gnus-select-method)
11723 (run-hooks 'gnus-open-server-hook)
11725 ;; gnus-open-server-hook might have opened it
11726 (gnus-server-opened gnus-select-method)
11727 (gnus-open-server gnus-select-method)
11730 "%s open error: '%s'. Continue? "
11731 (nth 1 gnus-select-method)
11732 (gnus-status-message gnus-select-method)))
11734 (gnus-message 1 "Couldn't open server on %s"
11735 (nth 1 gnus-select-method))
11739 (defun gnus-check-server (&optional method)
11740 "If the news server is down, start it up again."
11741 (let ((method (if method method gnus-select-method)))
11742 (and (stringp method)
11743 (setq method (gnus-server-to-method method)))
11744 (if (gnus-server-opened method)
11745 ;; Stream is already opened.
11748 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11749 (run-hooks 'gnus-open-server-hook)
11751 (gnus-open-server method)
11754 (defun gnus-nntp-message (&optional message)
11755 "Check the status of the NNTP server.
11756 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11757 is returned insted of the status string."
11758 (let ((status (gnus-status-message (gnus-find-method-for-group
11759 gnus-newsgroup-name)))
11760 (message (or message "")))
11761 (if (and (stringp status) (> (length status) 0))
11764 (defun gnus-get-function (method function)
11765 (and (stringp method)
11766 (setq method (gnus-server-to-method method)))
11767 (let ((func (intern (format "%s-%s" (car method) function))))
11768 (if (not (fboundp func))
11770 (require (car method))
11771 (if (not (fboundp func))
11772 (error "No such function: %s" func))))
11775 ;;; Interface functions to the backends.
11777 (defun gnus-open-server (method)
11778 (funcall (gnus-get-function method 'open-server)
11779 (nth 1 method) (nthcdr 2 method)))
11781 (defun gnus-close-server (method)
11782 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11784 (defun gnus-request-list (method)
11785 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11787 (defun gnus-request-list-newsgroups (method)
11788 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11790 (defun gnus-request-newgroups (date method)
11791 (funcall (gnus-get-function method 'request-newgroups)
11792 date (nth 1 method)))
11794 (defun gnus-server-opened (method)
11795 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11797 (defun gnus-status-message (method)
11798 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11800 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11802 (defun gnus-request-group (group &optional dont-check)
11803 (let ((method (gnus-find-method-for-group group)))
11804 (funcall (gnus-get-function method 'request-group)
11805 (gnus-group-real-name group) (nth 1 method) dont-check)))
11807 (defun gnus-request-asynchronous (group &optional articles)
11808 (let ((method (gnus-find-method-for-group group)))
11809 (funcall (gnus-get-function method 'request-asynchronous)
11810 (gnus-group-real-name group) (nth 1 method) articles)))
11812 (defun gnus-list-active-group (group)
11813 (let ((method (gnus-find-method-for-group group))
11814 (func 'list-active-group))
11815 (and (gnus-check-backend-function func group)
11816 (funcall (gnus-get-function method func)
11817 (gnus-group-real-name group) (nth 1 method)))))
11819 (defun gnus-request-group-description (group)
11820 (let ((method (gnus-find-method-for-group group))
11821 (func 'request-group-description))
11822 (and (gnus-check-backend-function func group)
11823 (funcall (gnus-get-function method func)
11824 (gnus-group-real-name group) (nth 1 method)))))
11826 (defun gnus-close-group (group)
11827 (let ((method (gnus-find-method-for-group group)))
11828 (funcall (gnus-get-function method 'close-group)
11829 (gnus-group-real-name group) (nth 1 method))))
11831 (defun gnus-retrieve-headers (articles group)
11832 (let ((method (gnus-find-method-for-group group)))
11833 (if (and gnus-use-cache (numberp (car articles)))
11834 (gnus-cache-retrieve-headers articles group)
11835 (funcall (gnus-get-function method 'retrieve-headers)
11836 articles (gnus-group-real-name group) (nth 1 method)))))
11838 (defun gnus-retrieve-groups (groups method)
11839 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11841 (defun gnus-request-article (article group &optional buffer)
11842 (let ((method (gnus-find-method-for-group group)))
11843 (funcall (gnus-get-function method 'request-article)
11844 article (gnus-group-real-name group) (nth 1 method) buffer)))
11846 (defun gnus-request-head (article group)
11847 (let ((method (gnus-find-method-for-group group)))
11848 (funcall (gnus-get-function method 'request-head)
11849 article (gnus-group-real-name group) (nth 1 method))))
11851 (defun gnus-request-body (article group)
11852 (let ((method (gnus-find-method-for-group group)))
11853 (funcall (gnus-get-function method 'request-body)
11854 article (gnus-group-real-name group) (nth 1 method))))
11856 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11857 (defun gnus-request-post-buffer (post group subject header artbuf
11858 info follow-to respect-poster)
11859 (let* ((info (or info (and group (nth 2 (gnus-gethash
11860 group gnus-newsrc-hashtb)))))
11862 (if (and gnus-post-method
11863 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11865 (format "%s" (car (gnus-find-method-for-group
11866 gnus-newsgroup-name)))
11867 gnus-valid-select-methods)))
11869 (gnus-find-method-for-group gnus-newsgroup-name))))
11870 (or (gnus-check-server method)
11871 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11872 (let ((mail-self-blind nil)
11873 (mail-archive-file-name nil))
11874 (funcall (gnus-get-function method 'request-post-buffer)
11875 post group subject header artbuf info follow-to
11878 (defun gnus-request-post (method &optional force)
11879 (and (stringp method)
11880 (setq method (gnus-server-to-method method)))
11881 (and (not force) gnus-post-method
11882 (memq 'post (assoc (format "%s" (car method))
11883 gnus-valid-select-methods))
11884 (setq method gnus-post-method))
11885 (funcall (gnus-get-function method 'request-post)
11888 (defun gnus-request-expire-articles (articles group &optional force)
11889 (let ((method (gnus-find-method-for-group group)))
11890 (funcall (gnus-get-function method 'request-expire-articles)
11891 articles (gnus-group-real-name group) (nth 1 method)
11894 (defun gnus-request-move-article
11895 (article group server accept-function &optional last)
11896 (let ((method (gnus-find-method-for-group group)))
11897 (funcall (gnus-get-function method 'request-move-article)
11898 article (gnus-group-real-name group)
11899 (nth 1 method) accept-function last)))
11901 (defun gnus-request-accept-article (group &optional last)
11902 (let ((func (if (symbolp group) group
11903 (car (gnus-find-method-for-group group)))))
11904 (funcall (intern (format "%s-request-accept-article" func))
11905 (if (stringp group) (gnus-group-real-name group) group)
11908 (defun gnus-request-replace-article (article group buffer)
11909 (let ((func (car (gnus-find-method-for-group group))))
11910 (funcall (intern (format "%s-request-replace-article" func))
11911 article (gnus-group-real-name group) buffer)))
11913 (defun gnus-request-create-group (group)
11914 (let ((method (gnus-find-method-for-group group)))
11915 (funcall (gnus-get-function method 'request-create-group)
11916 (gnus-group-real-name group) (nth 1 method))))
11918 (defun gnus-member-of-valid (symbol group)
11919 (memq symbol (assoc
11920 (format "%s" (car (gnus-find-method-for-group group)))
11921 gnus-valid-select-methods)))
11923 (defun gnus-secondary-method-p (method)
11924 (let ((methods gnus-secondary-select-methods)
11925 (gmethod (gnus-server-get-method nil method)))
11926 (while (and methods
11927 (not (equal (gnus-server-get-method nil (car methods))
11929 (setq methods (cdr methods)))
11932 (defun gnus-find-method-for-group (group &optional info)
11933 (or gnus-override-method
11935 gnus-select-method)
11936 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11939 (not (setq method (nth 4 info))))
11940 (setq method gnus-select-method)
11942 (cond ((stringp method)
11943 (gnus-server-to-method method))
11944 ((stringp (car method))
11945 (gnus-server-extend-method group method))
11948 (gnus-server-add-address method))))
11950 (defun gnus-check-backend-function (func group)
11951 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11953 (fboundp (intern (format "%s-%s" method func)))))
11955 (defun gnus-methods-using (method)
11956 (let ((valids gnus-valid-select-methods)
11959 (if (memq method (car valids))
11960 (setq outs (cons (car valids) outs)))
11961 (setq valids (cdr valids)))
11965 ;;; Active & Newsrc File Handling
11968 ;; Newsrc related functions.
11969 ;; Gnus internal format of gnus-newsrc-alist:
11970 ;; (("alt.general" 3 (1 . 1))
11971 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11972 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11973 ;; The first item is the group name; the second is the subscription
11974 ;; level; the third is either a range of a list of ranges of read
11975 ;; articles, the optional fourth element is a list of marked articles,
11976 ;; the optional fifth element is the select method.
11978 ;; Gnus internal format of gnus-newsrc-hashtb:
11979 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11980 ;; This is the entry for "alt.misc". The first element is the number
11981 ;; of unread articles in "alt.misc". The cdr of this entry is the
11982 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11983 ;; trivial to remove or add new elements into gnus-newsrc-alist
11984 ;; without scanning the entire list. So, to get the actual information
11985 ;; of "alt.misc", you'd say something like
11986 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11988 ;; Gnus internal format of gnus-active-hashtb:
11992 ;; The only element in each entry in this hash table is a range of
11993 ;; (possibly) available articles. (Articles in this range may have
11994 ;; been expired or canceled.)
11996 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11997 ;; ("alt.misc" "alt.test" "alt.general" ...)
11999 (defun gnus-setup-news (&optional rawfile level)
12000 "Setup news information.
12001 If RAWFILE is non-nil, the .newsrc file will also be read.
12002 If LEVEL is non-nil, the news will be set up at level LEVEL."
12003 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12004 ;; Clear some variables to re-initialize news information.
12005 (if init (setq gnus-newsrc-alist nil
12006 gnus-active-hashtb nil))
12008 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12009 (if init (gnus-read-newsrc-file rawfile))
12011 ;; If we don't read the complete active file, we fill in the
12013 (if (or (null gnus-read-active-file)
12014 (eq gnus-read-active-file 'some))
12015 (gnus-update-active-hashtb-from-killed))
12017 ;; Read the active file and create `gnus-active-hashtb'.
12018 ;; If `gnus-read-active-file' is nil, then we just create an empty
12019 ;; hash table. The partial filling out of the hash table will be
12020 ;; done in `gnus-get-unread-articles'.
12021 (and gnus-read-active-file
12023 (gnus-read-active-file))
12025 (or gnus-active-hashtb
12026 (setq gnus-active-hashtb (make-vector 4095 0)))
12028 ;; Possibly eval the dribble file.
12029 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12031 (gnus-update-format-specifications)
12033 ;; Find new newsgroups and treat them.
12034 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12035 (gnus-server-opened gnus-select-method))
12036 (gnus-find-new-newsgroups))
12038 ;; Find the number of unread articles in each non-dead group.
12039 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12040 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12042 (if (and init gnus-check-bogus-newsgroups
12043 gnus-read-active-file (not level)
12044 (gnus-server-opened gnus-select-method))
12045 (gnus-check-bogus-newsgroups))))
12047 (defun gnus-find-new-newsgroups ()
12048 "Search for new newsgroups and add them.
12049 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12050 The `-n' option line from .newsrc is respected."
12052 (or (gnus-check-first-time-used)
12053 (if (or (consp gnus-check-new-newsgroups)
12054 (eq gnus-check-new-newsgroups 'ask-server))
12055 (gnus-ask-server-for-new-groups)
12057 group new-newsgroups)
12058 (gnus-message 5 "Looking for new newsgroups...")
12059 (or gnus-have-read-active-file (gnus-read-active-file))
12060 (setq gnus-newsrc-last-checked-date (current-time-string))
12061 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12062 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12063 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12066 (if (or (null (setq group (symbol-name sym)))
12067 (null (symbol-value sym))
12068 (gnus-gethash group gnus-killed-hashtb)
12069 (gnus-gethash group gnus-newsrc-hashtb))
12071 (let ((do-sub (gnus-matches-options-n group)))
12073 ((eq do-sub 'subscribe)
12074 (setq groups (1+ groups))
12075 (gnus-sethash group group gnus-killed-hashtb)
12076 (funcall gnus-subscribe-options-newsgroup-method group))
12077 ((eq do-sub 'ignore)
12080 (setq groups (1+ groups))
12081 (gnus-sethash group group gnus-killed-hashtb)
12082 (if gnus-subscribe-hierarchical-interactive
12083 (setq new-newsgroups (cons group new-newsgroups))
12084 (funcall gnus-subscribe-newsgroup-method group)))))))
12085 gnus-active-hashtb)
12087 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12088 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12090 (gnus-message 6 "%d new newsgroup%s arrived."
12091 groups (if (> groups 1) "s have" " has"))
12092 (gnus-message 6 "No new newsgroups."))))))
12094 (defun gnus-matches-options-n (group)
12095 ;; Returns `subscribe' if the group is to be uncoditionally
12096 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12097 ;; no match for the group.
12099 ;; First we check the two user variables.
12101 ((and gnus-options-subscribe
12102 (string-match gnus-options-subscribe group))
12104 ((and gnus-options-not-subscribe
12105 (string-match gnus-options-not-subscribe group))
12107 ;; Then we go through the list that was retrieved from the .newsrc
12108 ;; file. This list has elements on the form
12109 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12110 ;; is in the reverse order of the options line) is returned.
12112 (let ((regs gnus-newsrc-options-n))
12114 (not (string-match (car (car regs)) group)))
12115 (setq regs (cdr regs)))
12116 (and regs (cdr (car regs)))))))
12118 (defun gnus-ask-server-for-new-groups ()
12119 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12120 (methods (cons gnus-select-method
12122 (and (consp gnus-check-new-newsgroups)
12123 gnus-check-new-newsgroups)
12124 gnus-secondary-select-methods)))
12126 (new-date (current-time-string))
12127 (hashtb (gnus-make-hashtable 100))
12128 group new-newsgroups got-new method)
12129 ;; Go through both primary and secondary select methods and
12130 ;; request new newsgroups.
12132 (setq method (gnus-server-get-method nil (car methods)))
12133 (and (gnus-check-server method)
12134 (gnus-request-newgroups date method)
12137 (set-buffer nntp-server-buffer)
12138 ;; Enter all the new groups in a hashtable.
12139 (gnus-active-to-gnus-format method hashtb 'ignore)))
12140 (setq methods (cdr methods)))
12141 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12142 ;; Now all new groups from all select methods are in `hashtb'.
12144 (lambda (group-sym)
12145 (setq group (symbol-name group-sym))
12146 (if (or (null group)
12147 (null (symbol-value group-sym))
12148 (gnus-gethash group gnus-newsrc-hashtb)
12149 (member group gnus-zombie-list)
12150 (member group gnus-killed-list))
12151 ;; The group is already known.
12153 (and (symbol-value group-sym)
12154 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12155 (let ((do-sub (gnus-matches-options-n group)))
12156 (cond ((eq do-sub 'subscribe)
12157 (setq groups (1+ groups))
12158 (gnus-sethash group group gnus-killed-hashtb)
12160 gnus-subscribe-options-newsgroup-method group))
12161 ((eq do-sub 'ignore)
12164 (setq groups (1+ groups))
12165 (gnus-sethash group group gnus-killed-hashtb)
12166 (if gnus-subscribe-hierarchical-interactive
12167 (setq new-newsgroups (cons group new-newsgroups))
12168 (funcall gnus-subscribe-newsgroup-method group)))))))
12171 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12172 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12174 (gnus-message 6 "%d new newsgroup%s arrived."
12175 groups (if (> groups 1) "s have" " has")))
12178 (defun gnus-check-first-time-used ()
12179 (if (or (> (length gnus-newsrc-alist) 1)
12180 (file-exists-p gnus-startup-file)
12181 (file-exists-p (concat gnus-startup-file ".el"))
12182 (file-exists-p (concat gnus-startup-file ".eld")))
12184 (gnus-message 6 "First time user; subscribing you to default groups")
12185 (or gnus-have-read-active-file (gnus-read-active-file))
12186 (setq gnus-newsrc-last-checked-date (current-time-string))
12187 (let ((groups gnus-default-subscribed-newsgroups)
12191 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12194 (if (null (setq group (symbol-name sym)))
12196 (let ((do-sub (gnus-matches-options-n group)))
12198 ((eq do-sub 'subscribe)
12199 (gnus-sethash group group gnus-killed-hashtb)
12200 (funcall gnus-subscribe-options-newsgroup-method group))
12201 ((eq do-sub 'ignore)
12204 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12205 gnus-active-hashtb)
12207 (if (gnus-gethash (car groups) gnus-active-hashtb)
12208 (gnus-group-change-level
12209 (car groups) gnus-level-default-subscribed gnus-level-killed))
12210 (setq groups (cdr groups)))
12211 (gnus-group-make-help-group)
12212 (and gnus-novice-user
12213 (gnus-message 7 "`A k' to list killed groups"))))))
12215 (defun gnus-subscribe-group (group previous &optional method)
12216 (gnus-group-change-level
12218 (list t group gnus-level-default-subscribed nil nil method)
12220 gnus-level-default-subscribed gnus-level-killed previous t))
12222 ;; `gnus-group-change-level' is the fundamental function for changing
12223 ;; subscription levels of newsgroups. This might mean just changing
12224 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12225 ;; again, which subscribes/unsubscribes a group, which is equally
12226 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12227 ;; from 8-9 to 1-7 means that you remove the group from the list of
12228 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12229 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12230 ;; which is trivial.
12231 ;; ENTRY can either be a string (newsgroup name) or a list (if
12232 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12233 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12235 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12236 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12238 (defun gnus-group-change-level (entry level &optional oldlevel
12239 previous fromkilled)
12240 (let (group info active num)
12241 ;; Glean what info we can from the arguments
12243 (if fromkilled (setq group (nth 1 entry))
12244 (setq group (car (nth 2 entry))))
12245 (setq group entry))
12246 (if (and (stringp entry)
12248 (< oldlevel gnus-level-zombie))
12249 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12250 (if (and (not oldlevel)
12252 (setq oldlevel (car (cdr (nth 2 entry)))))
12253 (if (stringp previous)
12254 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12256 (if (and (>= oldlevel gnus-level-zombie)
12257 (gnus-gethash group gnus-newsrc-hashtb))
12258 ;; We are trying to subscribe a group that is already
12262 (gnus-dribble-enter
12263 (format "(gnus-group-change-level %S %S %S %S %S)"
12264 group level oldlevel (car (nth 2 previous)) fromkilled))
12266 ;; Then we remove the newgroup from any old structures, if needed.
12267 ;; If the group was killed, we remove it from the killed or zombie
12268 ;; list. If not, and it is in fact going to be killed, we remove
12269 ;; it from the newsrc hash table and assoc.
12270 (cond ((>= oldlevel gnus-level-zombie)
12271 (if (= oldlevel gnus-level-zombie)
12272 (setq gnus-zombie-list (delete group gnus-zombie-list))
12273 (setq gnus-killed-list (delete group gnus-killed-list))))
12275 (if (and (>= level gnus-level-zombie)
12278 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12280 (setcdr (gnus-gethash (car (nth 3 entry))
12281 gnus-newsrc-hashtb)
12283 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12285 ;; Finally we enter (if needed) the list where it is supposed to
12286 ;; go, and change the subscription level. If it is to be killed,
12287 ;; we enter it into the killed or zombie list.
12288 (cond ((>= level gnus-level-zombie)
12289 ;; Remove from the hash table.
12290 (gnus-sethash group nil gnus-newsrc-hashtb)
12291 (or (gnus-group-foreign-p group)
12292 ;; We do not enter foreign groups into the list of dead
12294 (if (= level gnus-level-zombie)
12295 (setq gnus-zombie-list (cons group gnus-zombie-list))
12296 (setq gnus-killed-list (cons group gnus-killed-list)))))
12298 ;; If the list is to be entered into the newsrc assoc, and
12299 ;; it was killed, we have to create an entry in the newsrc
12300 ;; hashtb format and fix the pointers in the newsrc assoc.
12301 (if (>= oldlevel gnus-level-zombie)
12305 (setq info (cdr entry))
12306 (setq num (car entry)))
12307 (setq active (gnus-gethash group gnus-active-hashtb))
12309 (if active (- (1+ (cdr active)) (car active)) t))
12310 ;; Check whether the group is foreign. If so, the
12311 ;; foreign select method has to be entered into the
12313 (let ((method (gnus-group-method-name group)))
12314 (if (eq method gnus-select-method)
12315 (setq info (list group level nil))
12316 (setq info (list group level nil nil method)))))
12319 (let ((p gnus-newsrc-alist))
12320 (while (cdr (cdr p))
12323 (setq entry (cons info (cdr (cdr previous))))
12326 (setcdr (cdr previous) entry)
12327 (gnus-sethash group (cons num (cdr previous))
12328 gnus-newsrc-hashtb))
12329 (setcdr previous entry)
12330 (gnus-sethash group (cons num previous)
12331 gnus-newsrc-hashtb))
12333 (setcdr (gnus-gethash (car (car (cdr entry)))
12334 gnus-newsrc-hashtb)
12336 ;; It was alive, and it is going to stay alive, so we
12337 ;; just change the level and don't change any pointers or
12338 ;; hash table entries.
12339 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12341 (defun gnus-kill-newsgroup (newsgroup)
12342 "Obsolete function. Kills a newsgroup."
12343 (gnus-group-change-level
12344 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12346 (defun gnus-check-bogus-newsgroups (&optional confirm)
12347 "Remove bogus newsgroups.
12348 If CONFIRM is non-nil, the user has to confirm the deletion of every
12350 (let ((newsrc (cdr gnus-newsrc-alist))
12352 (gnus-message 5 "Checking bogus newsgroups...")
12353 (or gnus-have-read-active-file (gnus-read-active-file))
12354 ;; Find all bogus newsgroup that are subscribed.
12356 (setq group (car (car newsrc)))
12357 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12358 (nth 4 (car newsrc)) ; Foreign
12360 (not (gnus-y-or-n-p
12361 (format "Remove bogus newsgroup: %s " group)))))
12364 ;; Found a bogus newsgroup.
12365 (setq bogus (cons group bogus)))
12366 (setq newsrc (cdr newsrc)))
12367 ;; Remove all bogus subscribed groups by first killing them, and
12368 ;; then removing them from the list of killed groups.
12370 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12372 (gnus-group-change-level entry gnus-level-killed)
12373 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12374 (setq bogus (cdr bogus)))
12375 ;; Then we remove all bogus groups from the list of killed and
12376 ;; zombie groups. They are are removed without confirmation.
12377 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12380 (setq killed (symbol-value (car dead-lists)))
12382 (setq group (car killed))
12383 (or (gnus-gethash group gnus-active-hashtb)
12384 ;; The group is bogus.
12385 (set (car dead-lists)
12386 (delete group (symbol-value (car dead-lists)))))
12387 (setq killed (cdr killed)))
12388 (setq dead-lists (cdr dead-lists))))
12389 (gnus-message 5 "Checking bogus newsgroups...done")))
12391 (defun gnus-check-duplicate-killed-groups ()
12392 "Remove duplicates from the list of killed groups."
12394 (let ((killed gnus-killed-list))
12396 (gnus-message 9 "%d" (length killed))
12397 (setcdr killed (delete (car killed) (cdr killed)))
12398 (setq killed (cdr killed)))))
12400 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12401 ;; and compute how many unread articles there are in each group.
12402 (defun gnus-get-unread-articles (&optional level)
12403 (let* ((newsrc (cdr gnus-newsrc-alist))
12404 (level (or level (1+ gnus-level-subscribed)))
12407 (cond ((and gnus-activate-foreign-newsgroups
12408 (not (numberp gnus-activate-foreign-newsgroups)))
12409 (1+ gnus-level-subscribed))
12410 ((numberp gnus-activate-foreign-newsgroups)
12411 gnus-activate-foreign-newsgroups)
12414 info group active virtuals method)
12415 (gnus-message 5 "Checking new news...")
12418 (setq info (car newsrc)
12420 active (gnus-gethash group gnus-active-hashtb))
12422 ;; Check newsgroups. If the user doesn't want to check them, or
12423 ;; they can't be checked (for instance, if the news server can't
12424 ;; be reached) we just set the number of unread articles in this
12425 ;; newsgroup to t. This means that Gnus thinks that there are
12426 ;; unread articles, but it has no idea how many.
12427 (if (and (setq method (nth 4 info))
12428 (not (gnus-server-equal gnus-select-method
12429 (gnus-server-get-method nil method)))
12430 (not (gnus-secondary-method-p method)))
12431 ;; These groups are foreign. Check the level.
12432 (if (<= (nth 1 info) foreign-level)
12433 (if (eq (car (if (stringp method)
12434 (gnus-server-to-method method)
12435 (nth 4 info))) 'nnvirtual)
12436 ;; We have to activate the virtual groups after all
12437 ;; the others, so we just pop them on a list for
12439 (setq virtuals (cons info virtuals))
12440 (and (setq active (gnus-activate-group (car info)))
12441 ;; Close the groups as we look at them!
12442 (gnus-close-group group))))
12444 ;; These groups are native or secondary.
12445 (if (and (not gnus-read-active-file)
12446 (<= (nth 1 info) level))
12448 (or gnus-read-active-file (gnus-check-server method))
12449 (setq active (gnus-activate-group (car info))))))
12452 (gnus-get-unread-articles-in-group info active)
12453 ;; The group couldn't be reached, so we nix out the number of
12454 ;; unread articles and stuff.
12455 (gnus-sethash group nil gnus-active-hashtb)
12456 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12458 (setq newsrc (cdr newsrc)))
12460 ;; Activate the virtual groups. This has to be done after all the
12462 ;; !!! If one virtual group contains another virtual group, even
12463 ;; doing it this way might cause problems.
12465 (and (setq active (gnus-activate-group (car (car virtuals))))
12466 (gnus-get-unread-articles-in-group (car virtuals) active))
12467 (setq virtuals (cdr virtuals)))
12469 (gnus-message 5 "Checking new news...done")))
12471 ;; Create a hash table out of the newsrc alist. The `car's of the
12472 ;; alist elements are used as keys.
12473 (defun gnus-make-hashtable-from-newsrc-alist ()
12474 (let ((alist gnus-newsrc-alist)
12475 (ohashtb gnus-newsrc-hashtb)
12477 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12479 (setq prev (setq gnus-newsrc-alist
12480 (if (equal (car (car gnus-newsrc-alist))
12483 (cons (list "dummy.group" 0 nil) alist)))))
12485 (gnus-sethash (car (car alist))
12486 (cons (and ohashtb (car (gnus-gethash
12487 (car (car alist)) ohashtb)))
12488 prev) gnus-newsrc-hashtb)
12490 alist (cdr alist)))))
12492 (defun gnus-make-hashtable-from-killed ()
12493 "Create a hash table from the killed and zombie lists."
12494 (let ((lists '(gnus-killed-list gnus-zombie-list))
12496 (setq gnus-killed-hashtb
12497 (gnus-make-hashtable
12498 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12500 (setq list (symbol-value (car lists)))
12501 (setq lists (cdr lists))
12503 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12504 (setq list (cdr list))))))
12506 (defun gnus-get-unread-articles-in-group (info active)
12507 (let* ((range (nth 2 info))
12509 (marked (nth 3 info)))
12510 ;; If a cache is present, we may have to alter the active info.
12511 (and gnus-use-cache
12512 (gnus-cache-possibly-alter-active (car info) active))
12513 ;; Modify the list of read articles according to what articles
12514 ;; are available; then tally the unread articles and add the
12515 ;; number to the group hash table entry.
12517 ((zerop (cdr active))
12520 (setq num (- (1+ (cdr active)) (car active))))
12521 ((not (listp (cdr range)))
12522 ;; Fix a single (num . num) range according to the
12523 ;; active hash table.
12524 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12525 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12526 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12527 ;; Compute number of unread articles.
12528 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12530 ;; The read list is a list of ranges. Fix them according to
12531 ;; the active hash table.
12532 ;; First peel off any elements that are below the lower
12534 (while (and (cdr range)
12536 (or (and (atom (car (cdr range))) (car (cdr range)))
12537 (car (car (cdr range))))))
12538 (if (numberp (car range))
12541 (or (and (numberp (car (cdr range)))
12543 (cdr (car (cdr range))))))
12544 (setcdr (car range)
12545 (or (and (numberp (nth 1 range)) (nth 1 range))
12546 (cdr (car (cdr range))))))
12547 (setcdr range (cdr (cdr range))))
12548 ;; Adjust the first element to be the same as the lower limit.
12549 (if (and (not (atom (car range)))
12550 (< (cdr (car range)) (car active)))
12551 (setcdr (car range) (1- (car active))))
12552 ;; Then we want to peel off any elements that are higher
12553 ;; than the upper active limit.
12554 (let ((srange range))
12555 ;; Go past all legal elements.
12556 (while (and (cdr srange)
12557 (<= (or (and (atom (car (cdr srange)))
12558 (car (cdr srange)))
12559 (car (car (cdr srange)))) (cdr active)))
12560 (setq srange (cdr srange)))
12562 ;; Nuke all remaining illegal elements.
12563 (setcdr srange nil))
12565 ;; Adjust the final element.
12566 (if (and (not (atom (car srange)))
12567 (> (cdr (car srange)) (cdr active)))
12568 (setcdr (car srange) (cdr active))))
12569 ;; Compute the number of unread articles.
12571 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12572 (cdr (car range))))
12573 (or (and (atom (car range)) (car range))
12574 (car (car range))))))
12575 (setq range (cdr range)))
12576 (setq num (max 0 (- (cdr active) num)))))
12579 (and (assq 'tick marked)
12580 (inline (gnus-remove-illegal-marked-articles
12581 (assq 'tick marked) (nth 2 info))))
12582 (and (assq 'dormant marked)
12583 (inline (gnus-remove-illegal-marked-articles
12584 (assq 'dormant marked) (nth 2 info))))
12586 (gnus-gethash (car info) gnus-newsrc-hashtb)
12587 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12588 (length (cdr (assq 'dormant marked)))))))))
12591 (defun gnus-remove-illegal-marked-articles (marked ranges)
12592 (let ((m (cdr marked)))
12593 ;; Make sure that all ticked articles are a subset of the unread
12596 (if (gnus-member-of-range (car m) ranges)
12597 (setcdr marked (cdr m))
12599 (setq m (cdr m)))))
12601 (defun gnus-activate-group (group)
12602 ;; Check whether a group has been activated or not.
12603 (let ((method (gnus-find-method-for-group group))
12605 (and (gnus-check-server method)
12606 ;; We escape all bugs and quit here to make it possible to
12607 ;; continue if a group is so out-there that it reports bugs
12610 (gnus-request-group group)
12614 (set-buffer nntp-server-buffer)
12615 (goto-char (point-min))
12616 ;; Parse the result we got from `gnus-request-group'.
12617 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12619 (goto-char (match-beginning 1))
12621 group (setq active (cons (read (current-buffer))
12622 (read (current-buffer))))
12623 gnus-active-hashtb))
12624 ;; Return the new active info.
12627 (defun gnus-update-read-articles
12628 (group unread unselected ticked &optional domarks replied expirable killed
12629 dormant bookmark score)
12630 "Update the list of read and ticked articles in GROUP using the
12631 UNREAD and TICKED lists.
12632 Note: UNSELECTED has to be sorted over `<'.
12633 Returns whether the updating was successful."
12634 (let* ((active (or gnus-newsgroup-active
12635 (gnus-gethash group gnus-active-hashtb)))
12636 (entry (gnus-gethash group gnus-newsrc-hashtb))
12637 (info (nth 2 entry))
12638 (marked (nth 3 info))
12640 (unread (sort (copy-sequence unread) (function <)))
12642 (if (or (not info) (not active))
12643 ;; There is no info on this group if it was, in fact,
12644 ;; killed. Gnus stores no information on killed groups, so
12645 ;; there's nothing to be done.
12646 ;; One could store the information somewhere temporarily,
12647 ;; perhaps... Hmmm...
12649 ;; Remove any negative articles numbers.
12650 (while (and unread (< (car unread) 0))
12651 (setq unread (cdr unread)))
12652 ;; Remove any expired article numbers
12653 (while (and unread (< (car unread) (car active)))
12654 (setq unread (cdr unread)))
12655 (while (and ticked (< (car ticked) (car active)))
12656 (setq ticked (cdr ticked)))
12657 (while (and dormant (< (car dormant) (car active)))
12658 (setq dormant (cdr dormant)))
12659 (setq unread (sort (append unselected unread) '<))
12660 ;; Compute the ranges of read articles by looking at the list of
12661 ;; unread articles.
12663 (if (/= (car unread) prev)
12664 (setq read (cons (if (= prev (1- (car unread))) prev
12665 (cons prev (1- (car unread)))) read)))
12666 (setq prev (1+ (car unread)))
12667 (setq unread (cdr unread)))
12668 (if (<= prev (cdr active))
12669 (setq read (cons (cons prev (cdr active)) read)))
12670 ;; Enter this list into the group info.
12671 (setcar (cdr (cdr info))
12672 (if (> (length read) 1) (nreverse read) read))
12673 ;; Enter the list of ticked articles.
12674 (gnus-set-marked-articles
12676 (if domarks replied (cdr (assq 'reply marked)))
12677 (if domarks expirable (cdr (assq 'expire marked)))
12678 (if domarks killed (cdr (assq 'killed marked)))
12679 (if domarks dormant (cdr (assq 'dormant marked)))
12680 (if domarks bookmark (cdr (assq 'bookmark marked)))
12681 (if domarks score (cdr (assq 'score marked))))
12682 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12683 (gnus-get-unread-articles-in-group
12684 info (gnus-gethash group gnus-active-hashtb))
12687 (defun gnus-make-articles-unread (group articles)
12688 "Mark ARTICLES in GROUP as unread."
12689 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12690 (gnus-gethash (gnus-group-real-name group)
12691 gnus-newsrc-hashtb))))
12692 (ranges (nth 2 info))
12695 (and (gnus-member-of-range (car articles) ranges)
12696 (setq news (cons (car articles) news)))
12697 (setq articles (cdr articles)))
12700 (setcar (nthcdr 2 info)
12701 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12702 (gnus-group-update-group group t))))
12704 ;; Enter all dead groups into the hashtb.
12705 (defun gnus-update-active-hashtb-from-killed ()
12706 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12707 (lists (list gnus-killed-list gnus-zombie-list))
12710 (setq killed (car lists))
12712 (gnus-sethash (car killed) nil hashtb)
12713 (setq killed (cdr killed)))
12714 (setq lists (cdr lists)))))
12716 ;; Get the active file(s) from the backend(s).
12717 (defun gnus-read-active-file ()
12718 (gnus-group-set-mode-line)
12719 (let ((methods (if (gnus-check-server gnus-select-method)
12720 ;; The native server is available.
12721 (cons gnus-select-method gnus-secondary-select-methods)
12722 ;; The native server is down, so we just do the
12724 gnus-secondary-select-methods))
12726 (setq gnus-have-read-active-file nil)
12728 (set-buffer nntp-server-buffer)
12730 (let* ((method (gnus-server-get-method nil (car methods)))
12731 (where (nth 1 method))
12732 (mesg (format "Reading active file%s via %s..."
12733 (if (and where (not (zerop (length where))))
12734 (concat " from " where) "")
12736 (gnus-message 5 mesg)
12737 (if (not (gnus-check-server method))
12740 ((and (eq gnus-read-active-file 'some)
12741 (gnus-check-backend-function 'retrieve-groups (car method)))
12742 (let ((newsrc (cdr gnus-newsrc-alist))
12743 (gmethod (gnus-server-get-method nil method))
12746 (and (gnus-server-equal
12747 (gnus-find-method-for-group
12748 (car (car newsrc)) (car newsrc))
12750 (setq groups (cons (gnus-group-real-name
12751 (car (car newsrc))) groups)))
12752 (setq newsrc (cdr newsrc)))
12753 (gnus-check-server method)
12754 (setq list-type (gnus-retrieve-groups groups method))
12758 1 "Cannot read partial active file from %s server."
12762 ((eq list-type 'active)
12763 (gnus-active-to-gnus-format method gnus-active-hashtb))
12765 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12767 (if (not (gnus-request-list method))
12769 (gnus-message 1 "Cannot read active file from %s server."
12772 (gnus-active-to-gnus-format method)
12773 ;; We mark this active file as read.
12774 (setq gnus-have-read-active-file
12775 (cons method gnus-have-read-active-file))
12776 (gnus-message 5 "%sdone" mesg))))))
12777 (setq methods (cdr methods))))))
12779 ;; Read an active file and place the results in `gnus-active-hashtb'.
12780 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12781 (let ((cur (current-buffer))
12783 (if (and gnus-active-hashtb
12784 (not (equal method gnus-select-method)))
12786 (setq gnus-active-hashtb
12787 (if (equal method gnus-select-method)
12788 (gnus-make-hashtable
12789 (count-lines (point-min) (point-max)))
12790 (gnus-make-hashtable 4096))))))
12791 (flag-hashtb (gnus-make-hashtable 60)))
12792 ;; Delete unnecessary lines.
12793 (goto-char (point-min))
12794 (while (search-forward "\nto." nil t)
12795 (delete-region (1+ (match-beginning 0))
12796 (progn (forward-line 1) (point))))
12797 (or (string= gnus-ignored-newsgroups "")
12799 (goto-char (point-min))
12800 (delete-matching-lines gnus-ignored-newsgroups)))
12801 ;; Make the group names readable as a lisp expression even if they
12802 ;; contain special characters.
12803 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12804 (goto-char (point-max))
12805 (while (re-search-backward "[][';?()#]" nil t)
12807 ;; If these are groups from a foreign select method, we insert the
12808 ;; group prefix in front of the group names.
12809 (and method (not (gnus-server-equal
12810 (gnus-server-get-method nil method)
12811 (gnus-server-get-method nil gnus-select-method)))
12812 (let ((prefix (gnus-group-prefixed-name "" method)))
12813 (goto-char (point-min))
12814 (while (and (not (eobp))
12815 (progn (insert prefix)
12816 (zerop (forward-line 1)))))))
12817 ;; Store the active file in a hash table.
12818 (goto-char (point-min))
12819 (if (string-match "%[oO]" gnus-group-line-format)
12820 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12821 ;; If we want information on moderated groups, we use this
12823 (let* ((mod-hashtb (make-vector 7 0))
12824 (m (intern "m" mod-hashtb))
12826 (while (not (eobp))
12827 (condition-case nil
12829 (narrow-to-region (point) (gnus-point-at-eol))
12830 (setq group (let ((obarray hashtb)) (read cur)))
12831 (if (and (numberp (setq max (read cur)))
12832 (numberp (setq min (read cur)))
12834 (skip-chars-forward " \t")
12836 (or (= (following-char) ?=)
12837 (= (following-char) ?x)
12838 (= (following-char) ?j)))))
12839 (set group (cons min max))
12841 ;; Enter moderated groups into a list.
12842 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12843 (setq gnus-moderated-list
12844 (cons (symbol-name group) gnus-moderated-list))))
12851 ;; And if we do not care about moderation, we use this loop,
12852 ;; which is faster.
12853 (let (group max min)
12854 (while (not (eobp))
12857 (narrow-to-region (point) (gnus-point-at-eol))
12858 ;; group gets set to a symbol interned in the hash table
12859 ;; (what a hack!!) - jwz
12860 (setq group (let ((obarray hashtb)) (read cur)))
12861 (if (and (numberp (setq max (read cur)))
12862 (numberp (setq min (read cur)))
12864 (skip-chars-forward " \t")
12866 (or (= (following-char) ?=)
12867 (= (following-char) ?x)
12868 (= (following-char) ?j)))))
12869 (set group (cons min max))
12877 (gnus-message 3 "Warning - illegal active: %s"
12879 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12881 (forward-line 1))))))
12883 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12884 ;; Parse a "groups" active file.
12885 (let ((cur (current-buffer))
12887 (if (and method gnus-active-hashtb)
12889 (setq gnus-active-hashtb
12890 (gnus-make-hashtable
12891 (count-lines (point-min) (point-max)))))))
12892 (prefix (and method
12893 (not (gnus-server-equal
12894 (gnus-server-get-method nil method)
12895 (gnus-server-get-method nil gnus-select-method)))
12896 (gnus-group-prefixed-name "" method))))
12898 (goto-char (point-min))
12899 ;; We split this into to separate loops, one with the prefix
12900 ;; and one without to speed the reading up somewhat.
12902 (let (min max opoint group)
12903 (while (not (eobp))
12906 (read cur) (read cur)
12907 (setq min (read cur)
12910 (skip-chars-forward " \t")
12913 (set (let ((obarray hashtb)) (read cur))
12915 (error (and group (symbolp group) (set group nil))))
12917 (let (min max group)
12918 (while (not (eobp))
12920 (if (= (following-char) ?2)
12922 (read cur) (read cur)
12923 (setq min (read cur)
12925 (set (setq group (let ((obarray hashtb)) (read cur)))
12927 (error (and group (symbolp group) (set group nil))))
12928 (forward-line 1))))))
12930 (defun gnus-read-newsrc-file (&optional force)
12931 "Read startup file.
12932 If FORCE is non-nil, the .newsrc file is read."
12933 ;; Reset variables that might be defined in the .newsrc.eld file.
12934 (let ((variables gnus-variable-list))
12936 (set (car variables) nil)
12937 (setq variables (cdr variables))))
12938 (let* ((newsrc-file gnus-current-startup-file)
12939 (quick-file (concat newsrc-file ".el")))
12941 ;; We always load the .newsrc.eld file. If always contains
12942 ;; much information that can not be gotten from the .newsrc
12943 ;; file (ticked articles, killed groups, foreign methods, etc.)
12944 (gnus-read-newsrc-el-file quick-file)
12947 (and (file-newer-than-file-p newsrc-file quick-file)
12948 (file-newer-than-file-p newsrc-file
12949 (concat quick-file "d")))
12950 (not gnus-newsrc-alist))
12951 ;; We read the .newsrc file. Note that if there if a
12952 ;; .newsrc.eld file exists, it has already been read, and
12953 ;; the `gnus-newsrc-hashtb' has been created. While reading
12954 ;; the .newsrc file, Gnus will only use the information it
12955 ;; can find there for changing the data already read -
12956 ;; ie. reading the .newsrc file will not trash the data
12957 ;; already read (except for read articles).
12959 (gnus-message 5 "Reading %s..." newsrc-file)
12960 (set-buffer (find-file-noselect newsrc-file))
12961 (buffer-disable-undo (current-buffer))
12962 (gnus-newsrc-to-gnus-format)
12963 (kill-buffer (current-buffer))
12964 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12966 (defun gnus-read-newsrc-el-file (file)
12967 (let ((ding-file (concat file "d")))
12968 ;; We always, always read the .eld file.
12969 (gnus-message 5 "Reading %s..." ding-file)
12970 (let (gnus-newsrc-assoc)
12971 (condition-case nil
12972 (load ding-file t t t)
12974 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12975 (let ((inhibit-quit t))
12976 (gnus-uncompress-newsrc-alist))
12977 (gnus-make-hashtable-from-newsrc-alist)
12978 (if (not (file-newer-than-file-p file ding-file))
12980 ;; Old format quick file
12981 (gnus-message 5 "Reading %s..." file)
12982 ;; The .el file is newer than the .eld file, so we read that one
12984 (gnus-read-old-newsrc-el-file file))))
12986 ;; Parse the old-style quick startup file
12987 (defun gnus-read-old-newsrc-el-file (file)
12988 (let (newsrc killed marked group m)
12990 (let ((gnus-killed-assoc nil)
12991 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12993 (condition-case nil
12996 (setq newsrc gnus-newsrc-assoc
12997 killed gnus-killed-assoc
12998 marked gnus-marked-assoc)))
12999 (setq gnus-newsrc-alist nil)
13001 (setq group (car newsrc))
13002 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13005 (setcar (nthcdr 2 info) (cdr (cdr group)))
13007 (if (nth 1 group) gnus-level-default-subscribed
13008 gnus-level-default-unsubscribed))
13009 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13010 (setq gnus-newsrc-alist
13014 (if (nth 1 group) gnus-level-default-subscribed
13015 gnus-level-default-unsubscribed)
13016 (cdr (cdr group))))
13017 gnus-newsrc-alist)))
13018 (if (setq m (assoc (car group) marked))
13019 (setcdr (cdr (cdr info))
13020 (cons (list (cons 'tick (cdr m))) nil))))
13021 (setq newsrc (cdr newsrc)))
13022 (setq newsrc killed)
13024 (setcar newsrc (car (car newsrc)))
13025 (setq newsrc (cdr newsrc)))
13026 (setq gnus-killed-list killed))
13027 ;; The .el file version of this variable does not begin with
13028 ;; "options", while the .eld version does, so we just add it if it
13031 gnus-newsrc-options
13033 (and (not (string-match "^ *options" gnus-newsrc-options))
13034 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13035 (and (not (string-match "\n$" gnus-newsrc-options))
13036 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
13037 ;; Finally, if we read some options lines, we parse them.
13038 (or (string= gnus-newsrc-options "")
13039 (gnus-newsrc-parse-options gnus-newsrc-options))))
13041 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13042 (gnus-make-hashtable-from-newsrc-alist)))
13044 (defun gnus-make-newsrc-file (file)
13045 "Make server dependent file name by catenating FILE and server host name."
13046 (let* ((file (expand-file-name file nil))
13047 (real-file (concat file "-" (nth 1 gnus-select-method))))
13048 (if (or (file-exists-p real-file)
13049 (file-exists-p (concat real-file ".el"))
13050 (file-exists-p (concat real-file ".eld")))
13053 (defun gnus-uncompress-newsrc-alist ()
13054 ;; Uncompress all lists of marked articles in the newsrc assoc.
13055 (let ((newsrc gnus-newsrc-alist)
13058 (if (not (setq marked (nth 3 (car newsrc))))
13061 (or (eq 'score (car (car marked)))
13062 (eq 'bookmark (car (car marked)))
13063 (eq 'killed (car (car marked)))
13064 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13065 (setq marked (cdr marked))))
13066 (setq newsrc (cdr newsrc)))))
13068 (defun gnus-compress-newsrc-alist ()
13069 ;; Compress all lists of marked articles in the newsrc assoc.
13070 (let ((newsrc gnus-newsrc-alist)
13073 (if (not (setq marked (nth 3 (car newsrc))))
13076 (or (eq 'score (car (car marked)))
13077 (eq 'bookmark (car (car marked)))
13078 (eq 'killed (car (car marked)))
13079 (setcdr (car marked)
13081 (gnus-compress-sequence
13082 (sort (cdr (car marked)) '<) t)
13083 (error (cdr (car marked))))))
13084 (setq marked (cdr marked))))
13085 (setq newsrc (cdr newsrc)))))
13087 (defun gnus-newsrc-to-gnus-format ()
13088 (setq gnus-newsrc-options "")
13089 (setq gnus-newsrc-options-n nil)
13091 (or gnus-active-hashtb
13092 (setq gnus-active-hashtb (make-vector 4095 0)))
13093 (let ((buf (current-buffer))
13094 (already-read (> (length gnus-newsrc-alist) 1))
13095 group subscribed options-symbol newsrc Options-symbol
13097 (goto-char (point-min))
13098 ;; We intern the symbol `options' in the active hashtb so that we
13099 ;; can `eq' against it later.
13100 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13101 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13103 (while (not (eobp))
13104 ;; We first read the first word on the line by narrowing and
13105 ;; then reading into `gnus-active-hashtb'. Most groups will
13106 ;; already exist in that hashtb, so this will save some string
13110 (progn (skip-chars-forward "^ \t!:\n") (point)))
13111 (goto-char (point-min))
13113 (and (/= (point-min) (point-max))
13114 (let ((obarray gnus-active-hashtb)) (read buf))))
13116 ;; Now, the symbol we have read is either `options' or a group
13117 ;; name. If it is an options line, we just add it to a string.
13119 ((or (eq symbol options-symbol)
13120 (eq symbol Options-symbol))
13121 (setq gnus-newsrc-options
13122 ;; This concatting is quite inefficient, but since our
13123 ;; thorough studies show that approx 99.37% of all
13124 ;; .newsrc files only contain a single options line, we
13125 ;; don't give a damn, frankly, my dear.
13126 (concat gnus-newsrc-options
13128 (gnus-point-at-bol)
13129 ;; Options may continue on the next line.
13130 (or (and (re-search-forward "^[^ \t]" nil 'move)
13131 (progn (beginning-of-line) (point)))
13134 (or (boundp symbol) (set symbol nil))
13135 ;; It was a group name.
13136 (setq subscribed (= (following-char) ?:)
13137 group (symbol-name symbol)
13140 ;; If the line ends here, this is clearly a buggy line, so
13141 ;; we put point a the beginning of line and let the cond
13142 ;; below do the error handling.
13143 (beginning-of-line)
13144 ;; We skip to the beginning of the ranges.
13145 (skip-chars-forward "!: \t"))
13146 ;; We are now at the beginning of the list of read articles.
13147 ;; We read them range by range.
13150 ((looking-at "[0-9]+")
13151 ;; We narrow and read a number instead of buffer-substring/
13152 ;; string-to-int because it's faster. narrow/widen is
13153 ;; faster than save-restriction/narrow, and save-restriction
13154 ;; produces a garbage object.
13156 (narrow-to-region (match-beginning 0) (match-end 0))
13159 ;; If the next character is a dash, then this is a range.
13160 (if (= (following-char) ?-)
13162 ;; We read the upper bound of the range.
13164 (if (not (looking-at "[0-9]+"))
13165 ;; This is a buggy line, by we pretend that
13166 ;; it's kinda OK. Perhaps the user should be
13168 (setq reads (cons num1 reads))
13173 (narrow-to-region (match-beginning 0)
13178 ;; It was just a simple number, so we add it to the
13180 (setq reads (cons num1 reads)))
13181 ;; If the next char in ?\n, then we have reached the end
13182 ;; of the line and return nil.
13183 (/= (following-char) ?\n))
13184 ((= (following-char) ?\n)
13185 ;; End of line, so we end.
13188 ;; Not numbers and not eol, so this might be a buggy
13191 ;; If it was eob instead of ?\n, we allow it.
13193 ;; The line was buggy.
13195 (gnus-message 3 "Mangled line: %s"
13196 (buffer-substring (gnus-point-at-bol)
13197 (gnus-point-at-eol)))
13201 ;; Skip past ", ". Spaces are illegal in these ranges, but
13202 ;; we allow them, because it's a common mistake to put a
13203 ;; space after the comma.
13204 (skip-chars-forward ", "))
13206 ;; We have already read .newsrc.eld, so we gently update the
13207 ;; data in the hash table with the information we have just
13211 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13214 ;; There is an entry for this file in the alist.
13216 (setcar (nthcdr 2 info) (nreverse reads))
13217 ;; We update the level very gently. In fact, we
13218 ;; only change it if there's been a status change
13219 ;; from subscribed to unsubscribed, or vice versa.
13220 (setq level (nth 1 info))
13221 (cond ((and (<= level gnus-level-subscribed)
13223 (setq level (if reads
13224 gnus-level-default-unsubscribed
13225 (1+ gnus-level-default-unsubscribed))))
13226 ((and (> level gnus-level-subscribed) subscribed)
13227 (setq level gnus-level-default-subscribed)))
13228 (setcar (cdr info) level))
13229 ;; This is a new group.
13230 (setq info (list group
13232 gnus-level-default-subscribed
13234 (1+ gnus-level-subscribed)
13235 gnus-level-default-unsubscribed))
13236 (nreverse reads))))
13237 (setq newsrc (cons info newsrc))))))
13240 (setq newsrc (nreverse newsrc))
13242 (if (not already-read)
13244 ;; We now have two newsrc lists - `newsrc', which is what we
13245 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13246 ;; what we've read from .newsrc.eld. We have to merge these
13247 ;; lists. We do this by "attaching" any (foreign) groups in the
13248 ;; gnus-newsrc-alist to the (native) group that precedes them.
13249 (let ((rc (cdr gnus-newsrc-alist))
13250 (prev gnus-newsrc-alist)
13253 (or (null (nth 4 (car rc))) ; It's a native group.
13254 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13255 (if (setq entry (assoc (car (car prev)) newsrc))
13256 (setcdr (setq mentry (memq entry newsrc))
13257 (cons (car rc) (cdr mentry)))
13258 (setq newsrc (cons (car rc) newsrc))))
13262 (setq gnus-newsrc-alist newsrc)
13263 ;; We make the newsrc hashtb.
13264 (gnus-make-hashtable-from-newsrc-alist)
13266 ;; Finally, if we read some options lines, we parse them.
13267 (or (string= gnus-newsrc-options "")
13268 (gnus-newsrc-parse-options gnus-newsrc-options))))
13270 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13271 ;; The return value will be a list on the form
13272 ;; ((regexp1 . ignore)
13273 ;; (regexp2 . subscribe)...)
13274 ;; When handling new newsgroups, groups that match a `ignore' regexp
13275 ;; will be ignored, and groups that match a `subscribe' regexp will be
13276 ;; subscribed. A line like
13277 ;; options -n !all rec.all
13278 ;; will lead to a list that looks like
13279 ;; (("^rec\\..+" . subscribe)
13280 ;; ("^.+" . ignore))
13281 ;; So all "rec.*" groups will be subscribed, while all the other
13282 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13283 ;; different from "options -n rec.all !all".
13284 (defun gnus-newsrc-parse-options (options)
13287 (gnus-set-work-buffer)
13288 (insert (regexp-quote options))
13289 ;; First we treat all continuation lines.
13290 (goto-char (point-min))
13291 (while (re-search-forward "\n[ \t]+" nil t)
13292 (replace-match " " t t))
13293 ;; Then we transform all "all"s into ".+"s.
13294 (goto-char (point-min))
13295 (while (re-search-forward "\\ball\\b" nil t)
13296 (replace-match ".+" t t))
13297 (goto-char (point-min))
13298 ;; We remove all other options than the "-n" ones.
13299 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13300 (replace-match " ")
13302 (goto-char (point-min))
13304 ;; We are only interested in "options -n" lines - we
13305 ;; ignore the other option lines.
13306 (while (re-search-forward "[ \t]-n" nil t)
13308 (or (save-excursion
13309 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13311 (gnus-point-at-eol)))
13312 ;; Search for all "words"...
13313 (while (re-search-forward "[^ \t,\n]+" eol t)
13314 (if (= (char-after (match-beginning 0)) ?!)
13315 ;; If the word begins with a bang (!), this is a "not"
13316 ;; spec. We put this spec (minus the bang) and the
13317 ;; symbol `ignore' into the list.
13318 (setq out (cons (cons (concat
13319 "^" (buffer-substring
13320 (1+ (match-beginning 0))
13323 ;; There was no bang, so this is a "yes" spec.
13324 (setq out (cons (cons (concat
13325 "^" (buffer-substring (match-beginning 0)
13327 'subscribe) out)))))
13329 (setq gnus-newsrc-options-n out))))
13332 (defun gnus-save-newsrc-file ()
13333 "Save .newsrc file."
13334 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13335 ;; from the variable gnus-newsrc-alist.
13336 (and (or gnus-newsrc-alist gnus-killed-list)
13337 gnus-current-startup-file
13339 (run-hooks 'gnus-save-newsrc-hook)
13341 (if (and gnus-use-dribble-file
13342 (or (not gnus-dribble-buffer)
13343 (not (buffer-name gnus-dribble-buffer))
13344 (zerop (save-excursion
13345 (set-buffer gnus-dribble-buffer)
13347 (gnus-message 4 "(No changes need to be saved)")
13348 (if gnus-save-newsrc-file
13350 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13351 ;; Make backup file of master newsrc.
13352 (gnus-gnus-to-newsrc-format)
13353 (gnus-message 5 "Saving %s...done"
13354 gnus-current-startup-file)))
13355 ;; Quickly loadable .newsrc.
13356 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13357 (setq buffer-file-name (concat gnus-current-startup-file ".eld"))
13358 (gnus-add-current-to-buffer-list)
13359 (buffer-disable-undo (current-buffer))
13361 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13362 (gnus-gnus-to-quick-newsrc-format)
13364 (kill-buffer (current-buffer))
13365 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13366 (gnus-dribble-delete-file))))))
13368 (defun gnus-gnus-to-quick-newsrc-format ()
13369 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13370 (insert ";; Gnus startup file.\n")
13371 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13372 (insert ";; to read .newsrc.\n")
13373 (insert "(setq gnus-newsrc-file-version "
13374 (prin1-to-string gnus-version) ")\n")
13375 (let ((variables gnus-variable-list)
13377 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13379 ;; insert lisp expressions.
13380 (gnus-compress-newsrc-alist)
13382 (setq variable (car variables))
13383 (and (boundp variable)
13384 (symbol-value variable)
13385 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13386 (insert "(setq " (symbol-name variable) " '"
13387 (prin1-to-string (symbol-value variable))
13389 (setq variables (cdr variables)))
13390 (gnus-uncompress-newsrc-alist)))
13393 (defun gnus-gnus-to-newsrc-format ()
13394 ;; Generate and save the .newsrc file.
13395 (let ((newsrc (cdr gnus-newsrc-alist))
13398 (set-buffer (create-file-buffer gnus-current-startup-file))
13399 (setq buffer-file-name gnus-current-startup-file)
13400 (buffer-disable-undo (current-buffer))
13403 (if gnus-newsrc-options (insert gnus-newsrc-options))
13404 ;; Write subscribed and unsubscribed.
13406 (setq info (car newsrc))
13407 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13409 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13411 (if (setq ranges (nth 2 info))
13414 (if (not (listp (cdr ranges)))
13415 (if (= (car ranges) (cdr ranges))
13416 (insert (int-to-string (car ranges)))
13417 (insert (int-to-string (car ranges)) "-"
13418 (int-to-string (cdr ranges))))
13420 (setq range (car ranges)
13421 ranges (cdr ranges))
13422 (if (or (atom range) (= (car range) (cdr range)))
13423 (insert (int-to-string
13424 (or (and (atom range) range)
13426 (insert (int-to-string (car range)) "-"
13427 (int-to-string (cdr range))))
13428 (if ranges (insert ","))))))
13430 (setq newsrc (cdr newsrc)))
13431 ;; It has been reported that sometime the modtime on the .newsrc
13432 ;; file seems to be off. We really do want to overwrite it, so
13433 ;; we clear the modtime here before saving. It's a bit odd,
13435 ;; sometimes the modtime clear isn't sufficient. most brute force:
13436 ;; delete the silly thing entirely first. but this fails to provide
13437 ;; such niceties as .newsrc~ creation.
13438 (if gnus-modtime-botch
13439 (delete-file gnus-startup-file)
13440 (clear-visited-file-modtime))
13442 (kill-buffer (current-buffer)))))
13444 (defun gnus-read-all-descriptions-files ()
13445 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13447 (gnus-read-descriptions-file (car methods))
13448 (setq methods (cdr methods)))
13451 (defun gnus-read-descriptions-file (&optional method)
13452 (let ((method (or method gnus-select-method)))
13453 ;; We create the hashtable whether we manage to read the desc file
13454 ;; to avoid trying to re-read after a failed read.
13455 (or gnus-description-hashtb
13456 (setq gnus-description-hashtb
13457 (gnus-make-hashtable (length gnus-active-hashtb))))
13458 ;; Mark this method's desc file as read.
13459 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13460 gnus-description-hashtb)
13462 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13464 ((not (gnus-check-server method))
13465 (gnus-message 1 "Couldn't open server")
13467 ((not (gnus-request-list-newsgroups method))
13468 (gnus-message 1 "Couldn't read newsgroups descriptions")
13474 (set-buffer nntp-server-buffer)
13475 (goto-char (point-min))
13476 (if (or (search-forward "\n.\n" nil t)
13477 (goto-char (point-max)))
13479 (beginning-of-line)
13480 (narrow-to-region (point-min) (point))))
13481 (goto-char (point-min))
13482 (while (not (eobp))
13483 ;; If we get an error, we set group to 0, which is not a
13487 (let ((obarray gnus-description-hashtb))
13488 ;; Group is set to a symbol interned in this
13490 (read nntp-server-buffer))
13492 (skip-chars-forward " \t")
13493 ;; ... which leads to this line being effectively ignored.
13494 (and (symbolp group)
13495 (set group (buffer-substring
13496 (point) (progn (end-of-line) (point)))))
13497 (forward-line 1))))
13498 (gnus-message 5 "Reading descriptions file...done")
13501 (defun gnus-group-get-description (group)
13502 ;; Get the description of a group by sending XGTITLE to the server.
13503 (and (gnus-request-group-description group)
13505 (set-buffer nntp-server-buffer)
13506 (goto-char (point-min))
13507 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13508 (buffer-substring (match-beginning 1) (match-end 1))))))
13514 (defvar gnus-server-mode-hook nil
13515 "Hook run in `gnus-server-mode' buffers.")
13517 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13518 "Format of server lines.
13519 It works along the same lines as a normal formatting string,
13520 with some simple extensions.")
13522 (defvar gnus-server-mode-line-format "Gnus List of servers"
13523 "The format specification for the server mode line.")
13525 (defconst gnus-server-line-format-alist
13526 (list (list ?h 'how ?s)
13528 (list ?w 'where ?s)
13531 (defconst gnus-server-mode-line-format-alist
13532 (list (list ?S 'news-server ?s)
13533 (list ?M 'news-method ?s)
13534 (list ?u 'user-defined ?s)))
13536 (defvar gnus-server-line-format-spec nil)
13537 (defvar gnus-server-mode-line-format-spec nil)
13538 (defvar gnus-server-killed-servers nil)
13540 (defvar gnus-server-mode-map nil)
13541 (put 'gnus-server-mode 'mode-class 'special)
13543 (if gnus-server-mode-map
13545 (setq gnus-server-mode-map (make-sparse-keymap))
13546 (suppress-keymap gnus-server-mode-map)
13547 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13548 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13549 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13550 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13551 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13552 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13553 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13554 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13555 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13556 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13558 (defun gnus-server-mode ()
13559 "Major mode for listing and editing servers.
13561 All normal editing commands are switched off.
13562 \\<gnus-server-mode-map>
13564 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13566 The following commands are available:
13568 \\{gnus-server-mode-map}"
13570 (if gnus-visual (gnus-server-make-menu-bar))
13571 (kill-all-local-variables)
13572 (setq mode-line-modified "-- ")
13573 (make-local-variable 'mode-line-format)
13574 (setq mode-line-format (copy-sequence mode-line-format))
13575 (and (equal (nth 3 mode-line-format) " ")
13576 (setcar (nthcdr 3 mode-line-format) ""))
13577 (setq major-mode 'gnus-server-mode)
13578 (setq mode-name "Server")
13579 ; (gnus-group-set-mode-line)
13580 (setq mode-line-process nil)
13581 (use-local-map gnus-server-mode-map)
13582 (buffer-disable-undo (current-buffer))
13583 (setq truncate-lines t)
13584 (setq buffer-read-only t)
13585 (run-hooks 'gnus-server-mode-hook))
13587 (defun gnus-server-insert-server-line (sformat name method)
13588 (let* ((sformat (or sformat gnus-server-line-format-spec))
13590 (where (nth 1 method))
13592 (beginning-of-line)
13594 ;; Insert the text.
13595 (insert (eval sformat))
13596 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13598 (defun gnus-server-setup-buffer ()
13599 (if (get-buffer gnus-server-buffer)
13602 (set-buffer (get-buffer-create gnus-server-buffer))
13604 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13606 (defun gnus-server-prepare ()
13607 (setq gnus-server-mode-line-format-spec
13608 (gnus-parse-format gnus-server-mode-line-format
13609 gnus-server-mode-line-format-alist))
13610 (setq gnus-server-line-format-spec
13611 (gnus-parse-format gnus-server-line-format
13612 gnus-server-line-format-alist))
13613 (let ((alist gnus-server-alist)
13614 (buffer-read-only nil))
13617 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13618 (setq alist (cdr alist))))
13619 (goto-char (point-min))
13620 (gnus-server-position-cursor))
13622 (defun gnus-server-server-name ()
13623 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13624 (and server (symbol-name server))))
13626 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13628 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13630 (defun gnus-server-update-server (server)
13632 (set-buffer gnus-server-buffer)
13633 (let ((buffer-read-only nil)
13634 (info (cdr (assoc server gnus-server-alist))))
13635 (gnus-dribble-enter
13636 (concat "(gnus-server-set-info \"" server "\" '"
13637 (prin1-to-string info) ")"))
13638 ;; Buffer may be narrowed.
13641 (if (gnus-server-goto-server server)
13642 (delete-region (progn (beginning-of-line) (point))
13643 (progn (forward-line 1) (point))))
13644 (let ((entry (assoc server gnus-server-alist)))
13645 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13646 (gnus-server-position-cursor))))))
13648 (defun gnus-server-set-info (server info)
13649 ;; Enter a select method into the virtual server alist.
13650 (gnus-dribble-enter
13651 (concat "(gnus-server-set-info \"" server "\" '"
13652 (prin1-to-string info) ")"))
13653 (let* ((server (nth 1 info))
13654 (entry (assoc server gnus-server-alist)))
13655 (if entry (setcdr entry info)
13656 (setq gnus-server-alist
13657 (nconc gnus-server-alist (list (cons server info)))))))
13659 (defun gnus-server-to-method (server)
13660 ;; Map virtual server names to select methods.
13661 (or (and (equal server "native") gnus-select-method)
13662 (cdr (assoc server gnus-server-alist))))
13664 (defun gnus-server-extend-method (group method)
13665 ;; This function "extends" a virtual server. If the server is
13666 ;; "hello", and the select method is ("hello" (my-var "something"))
13667 ;; in the group "alt.alt", this will result in a new virtual server
13668 ;; called "helly+alt.alt".
13670 (gnus-copy-sequence
13671 (if (equal (car method) "native") gnus-select-method
13672 (cdr (assoc (car method) gnus-server-alist))))))
13673 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13674 (nconc entry (cdr method))))
13676 (defun gnus-server-get-method (group method)
13677 ;; Input either a server name, and extended server name, or a
13678 ;; select method, and return a select method.
13679 (cond ((stringp method)
13680 (gnus-server-to-method method))
13681 ((and (stringp (car method)) group)
13682 (gnus-server-extend-method group method))
13684 (gnus-server-add-address method))))
13686 (defun gnus-server-add-address (method)
13687 (let ((method-name (symbol-name (car method))))
13688 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13689 (not (assq (intern (concat method-name "-address")) method)))
13690 (append method (list (list (intern (concat method-name "-address"))
13694 (defun gnus-server-equal (s1 s2)
13696 (and (= (length s1) (length s2))
13698 (while (and s1 (member (car s1) s2))
13699 (setq s1 (cdr s1)))
13702 ;;; Interactive server functions.
13704 (defun gnus-server-kill-server (server)
13705 "Kill the server on the current line."
13706 (interactive (list (gnus-server-server-name)))
13707 (or (gnus-server-goto-server server)
13708 (if server (error "No such server: %s" server)
13709 (error "No server on the current line")))
13710 (gnus-dribble-enter "")
13711 (let ((buffer-read-only nil))
13712 (delete-region (progn (beginning-of-line) (point))
13713 (progn (forward-line 1) (point))))
13714 (setq gnus-server-killed-servers
13715 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13716 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13717 gnus-server-alist))
13718 (gnus-server-position-cursor))
13720 (defun gnus-server-yank-server ()
13721 "Yank the previously killed server."
13723 (or gnus-server-killed-servers
13724 (error "No killed servers to be yanked"))
13725 (let ((alist gnus-server-alist)
13726 (server (gnus-server-server-name))
13727 (killed (car gnus-server-killed-servers)))
13729 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13730 (if (string= server (car (car gnus-server-alist)))
13731 (setq gnus-server-alist (cons killed gnus-server-alist))
13732 (while (and (cdr alist)
13733 (not (string= server (car (car (cdr alist))))))
13734 (setq alist (cdr alist)))
13735 (setcdr alist (cons killed (cdr alist)))))
13736 (gnus-server-update-server (car killed))
13737 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13738 (gnus-server-position-cursor)))
13740 (defun gnus-server-exit ()
13741 "Return to the group buffer."
13743 (kill-buffer (current-buffer))
13744 (switch-to-buffer gnus-group-buffer))
13746 (defun gnus-server-list-servers ()
13747 "List all available servers."
13749 (let ((cur (gnus-server-server-name)))
13750 (gnus-server-prepare)
13751 (if cur (gnus-server-goto-server cur)
13752 (goto-char (point-max))
13754 (gnus-server-position-cursor)))
13756 (defun gnus-server-copy-server (from to)
13759 (or (gnus-server-server-name)
13760 (error "No server on the current line"))
13761 (read-string "Copy to: ")))
13762 (or from (error "No server on current line"))
13763 (or (and to (not (string= to ""))) (error "No name to copy to"))
13764 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13765 (or (assoc from gnus-server-alist)
13766 (error "%s: no such server" from))
13767 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13768 (setcar to-entry to)
13769 (setcar (nthcdr 2 to-entry) to)
13770 (setq gnus-server-killed-servers
13771 (cons to-entry gnus-server-killed-servers))
13772 (gnus-server-yank-server)))
13774 (defun gnus-server-add-server (how where)
13776 (list (intern (completing-read "Server method: "
13777 gnus-valid-select-methods nil t))
13778 (read-string "Server name: ")))
13779 (setq gnus-server-killed-servers
13780 (cons (list where how where) gnus-server-killed-servers))
13781 (gnus-server-yank-server))
13783 (defun gnus-server-goto-server (server)
13784 "Jump to a server line."
13786 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13787 (let ((to (text-property-any (point-min) (point-max)
13788 'gnus-server (intern server))))
13792 (gnus-server-position-cursor)))))
13794 (defun gnus-server-edit-server (server)
13795 "Edit the server on the current line."
13796 (interactive (list (gnus-server-server-name)))
13798 (error "No server on current line"))
13799 (let ((winconf (current-window-configuration)))
13800 (get-buffer-create gnus-server-edit-buffer)
13801 (gnus-configure-windows 'edit-server)
13802 (gnus-add-current-to-buffer-list)
13804 (make-local-variable 'gnus-prev-winconf)
13805 (setq gnus-prev-winconf winconf)
13806 (use-local-map (copy-keymap (current-local-map)))
13807 (let ((done-func '(lambda ()
13808 "Exit editing mode and update the information."
13810 (gnus-server-edit-server-done 'group))))
13811 (setcar (cdr (nth 4 done-func)) server)
13812 (local-set-key "\C-c\C-c" done-func))
13814 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13815 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13817 (defun gnus-server-edit-server-done (server)
13819 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13820 (goto-char (point-min))
13821 (let ((form (read (current-buffer)))
13822 (winconf gnus-prev-winconf))
13823 (gnus-server-set-info server form)
13824 (kill-buffer (current-buffer))
13825 (and winconf (set-window-configuration winconf))
13826 (set-buffer gnus-server-buffer)
13827 (gnus-server-update-server (gnus-server-server-name))
13828 (gnus-server-list-servers)
13829 (gnus-server-position-cursor)))
13831 (defun gnus-server-read-server (server)
13833 (interactive (list (gnus-server-server-name)))
13834 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13836 (defun gnus-mouse-pick-server (e)
13838 (mouse-set-point e)
13839 (gnus-server-read-server (gnus-server-server-name)))
13842 ;;; entry points into gnus-score.el
13845 ;;; Finding score files.
13847 (defvar gnus-global-score-files nil
13848 "*List of global score files and directories.
13849 Set this variable if you want to use people's score files. One entry
13850 for each score file or each score file directory. Gnus will decide
13851 by itself what score files are applicable to which group.
13853 Say you want to use the single score file
13854 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13855 score files in the \"/ftp.some-where:/pub/score\" directory.
13857 (setq gnus-global-score-files
13858 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13859 \"/ftp.some-where:/pub/score\"))")
13861 (defun gnus-score-score-files (group)
13862 "Return a list of all possible score files."
13863 ;; Search and set any global score files.
13864 (and gnus-global-score-files
13865 (or gnus-internal-global-score-files
13866 (gnus-score-search-global-directories gnus-global-score-files)))
13867 ;; Fix the kill-file dir variable.
13868 (setq gnus-kill-files-directory
13869 (file-name-as-directory
13870 (or gnus-kill-files-directory "~/News/")))
13871 ;; If we can't read it, there are no score files.
13872 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13873 (setq gnus-score-file-list nil)
13874 (if (gnus-use-long-file-name 'not-score)
13875 ;; We want long file names.
13876 (if (or (not gnus-score-file-list)
13877 (not (car gnus-score-file-list))
13878 (gnus-file-newer-than gnus-kill-files-directory
13879 (car gnus-score-file-list)))
13880 (setq gnus-score-file-list
13881 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13884 gnus-kill-files-directory t
13885 (gnus-score-file-regexp))))))
13886 ;; We do not use long file names, so we have to do some
13887 ;; directory traversing.
13888 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13889 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13892 (setq dir (expand-file-name
13893 (concat gnus-kill-files-directory
13894 (gnus-replace-chars-in-string group ?. ?/))))
13895 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13896 (setq suffix (car suffixes)
13897 suffixes (cdr suffixes))
13898 (if (file-exists-p (concat dir "/" suffix))
13899 (setq files (cons (concat dir "/" suffix) files)))
13900 (while (>= (1+ (length dir)) mdir)
13901 (and (file-exists-p (concat dir "/all/" suffix))
13902 (setq files (cons (concat dir "/all/" suffix) files)))
13903 (string-match "/[^/]*$" dir)
13904 (setq dir (substring dir 0 (match-beginning 0)))))
13905 (setq gnus-score-file-list
13906 (cons nil (nreverse files)))))
13907 (cdr gnus-score-file-list)))
13909 (defun gnus-score-file-regexp ()
13910 (concat "\\(" gnus-score-file-suffix
13911 "\\|" gnus-adaptive-file-suffix "\\)$"))
13913 (defun gnus-score-find-bnews (group)
13914 "Return a list of score files for GROUP.
13915 The score files are those files in the ~/News directory which matches
13916 GROUP using BNews sys file syntax."
13917 (let* ((sfiles (append (gnus-score-score-files group)
13918 gnus-internal-global-score-files))
13919 (kill-dir (file-name-as-directory
13920 (expand-file-name gnus-kill-files-directory)))
13921 (klen (length kill-dir))
13922 ofiles not-match regexp)
13924 (set-buffer (get-buffer-create "*gnus score files*"))
13925 (buffer-disable-undo (current-buffer))
13926 ;; Go through all score file names and create regexp with them
13930 (insert (car sfiles))
13931 (goto-char (point-min))
13932 ;; First remove the suffix itself.
13933 (re-search-forward (concat "." (gnus-score-file-regexp)))
13934 (replace-match "" t t)
13935 (goto-char (point-min))
13936 (if (looking-at (regexp-quote kill-dir))
13937 ;; If the file name was just "SCORE", `klen' is one character
13939 (delete-char (min (1- (point-max)) klen))
13940 (goto-char (point-max))
13941 (search-backward "/")
13942 (delete-region (1+ (point)) (point-min)))
13943 ;; If short file names were used, we have to translate slashes.
13944 (goto-char (point-min))
13945 (while (re-search-forward "[/:]" nil t)
13946 (replace-match "." t t))
13947 ;; Translate "all" to ".*".
13948 (while (search-forward "all" nil t)
13949 (replace-match ".*" t t))
13950 (goto-char (point-min))
13951 ;; Deal with "not."s.
13952 (if (looking-at "not.")
13955 (setq regexp (buffer-substring 5 (point-max))))
13956 (setq regexp (buffer-substring 1 (point-max)))
13957 (setq not-match nil))
13958 ;; Finally - if this resulting regexp matches the group name,
13959 ;; we add this score file to the list of score files
13960 ;; applicable to this group.
13961 (if (or (and not-match
13962 (not (string-match regexp group)))
13963 (and (not not-match)
13964 (string-match regexp group)))
13965 (setq ofiles (cons (car sfiles) ofiles)))
13966 (setq sfiles (cdr sfiles)))
13967 (kill-buffer (current-buffer))
13968 ;; Slight kludge here - the last score file returned should be
13969 ;; the local score file, whether it exists or not. This is so
13970 ;; that any score commands the user enters will go to the right
13971 ;; file, and not end up in some global score file.
13974 (if (gnus-use-long-file-name 'not-score)
13975 (concat gnus-kill-files-directory group "."
13976 gnus-score-file-suffix)
13977 (concat gnus-kill-files-directory
13978 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
13979 "/" gnus-score-file-suffix)))))
13980 (and (member localscore ofiles)
13981 (delete localscore ofiles))
13982 (setq ofiles (cons localscore ofiles)))
13983 (nreverse ofiles))))
13985 (defun gnus-score-find-single (group)
13986 "Return list containing the score file for GROUP."
13987 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13988 (gnus-score-file-name group)))
13990 (defun gnus-score-find-hierarchical (group)
13991 "Return list of score files for GROUP.
13992 This includes the score file for the group and all its parents."
13993 (let ((all (copy-sequence '(nil)))
13995 (while (string-match "\\." group (1+ start))
13996 (setq start (match-beginning 0))
13997 (setq all (cons (substring group 0 start) all)))
13998 (setq all (cons group all))
14000 (mapcar (lambda (newsgroup)
14001 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14002 (setq all (nreverse all)))
14003 (mapcar 'gnus-score-file-name all))))
14005 (defvar gnus-score-file-alist-cache nil)
14007 (defun gnus-score-find-alist (group)
14008 "Return list of score files for GROUP.
14009 The list is determined from the variable gnus-score-file-alist."
14010 (let ((alist gnus-score-file-multiple-match-alist)
14012 ;; if this group has been seen before, return the cached entry
14013 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14014 (cdr score-files) ;ensures caching groups with no matches
14015 ;; handle the multiple match alist
14017 (and (string-match (car (car alist)) group)
14019 (nconc score-files (copy-sequence (cdr (car alist))))))
14020 (setq alist (cdr alist)))
14021 (setq alist gnus-score-file-single-match-alist)
14022 ;; handle the single match alist
14024 (and (string-match (car (car alist)) group)
14025 ;; progn used just in case ("regexp") has no files
14026 ;; and score-files is still nil. -sj
14027 ;; this can be construed as a "stop searching here" feature :>
14028 ;; and used to simplify regexps in the single-alist
14031 (nconc score-files (copy-sequence (cdr (car alist)))))
14033 (setq alist (cdr alist)))
14034 ;; cache the score files
14035 (setq gnus-score-file-alist-cache
14036 (cons (cons group score-files) gnus-score-file-alist-cache))
14040 (defun gnus-possibly-score-headers (&optional trace)
14041 (let ((func gnus-score-find-score-files-function)
14043 (and func (not (listp func))
14044 (setq func (list func)))
14045 ;; Go through all the functions for finding score files (or actual
14046 ;; scores) and add them to a list.
14047 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14049 (and (symbolp (car func))
14050 (fboundp (car func))
14052 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14053 (setq func (cdr func)))
14054 (if score-files (gnus-score-headers score-files trace))))
14056 (defun gnus-score-file-name (newsgroup &optional suffix)
14057 "Return the name of a score file for NEWSGROUP."
14058 (let ((suffix (or suffix gnus-score-file-suffix)))
14060 ((or (null newsgroup)
14061 (string-equal newsgroup ""))
14062 ;; The global score file is placed at top of the directory.
14064 suffix (or gnus-kill-files-directory "~/News")))
14065 ((gnus-use-long-file-name 'not-score)
14066 ;; Append ".SCORE" to newsgroup name.
14067 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14069 (or gnus-kill-files-directory "~/News")))
14071 ;; Place "SCORE" under the hierarchical directory.
14072 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14074 (or gnus-kill-files-directory "~/News"))))))
14076 (defun gnus-score-search-global-directories (files)
14077 "Scan all global score directories for score files."
14078 ;; Set the variable `gnus-internal-global-score-files' to all
14079 ;; available global score files.
14080 (interactive (list gnus-global-score-files))
14083 (if (string-match "/$" (car files))
14084 (setq out (nconc (directory-files
14086 (concat (gnus-score-file-regexp) "$"))))
14087 (setq out (cons (car files) out)))
14088 (setq files (cdr files)))
14089 (setq gnus-internal-global-score-files out)))
14091 ;; Allow redefinition of Gnus functions.
14093 (gnus-ems-redefine)
14097 ;;; gnus.el ends here