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 (or (null gnus-nntp-service)
104 (equal gnus-nntp-service "nntp"))
106 (list gnus-nntp-service)))
107 "*Default method for selecting a newsgroup.
108 This variable should be a list, where the first element is how the
109 news is to be fetched, the second is the address.
111 For instance, if you want to get your news via NNTP from
112 \"flab.flab.edu\", you could say:
114 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
116 If you want to use your local spool, say:
118 (setq gnus-select-method (list 'nnspool (system-name)))
120 If you use this variable, you must set `gnus-nntp-server' to nil.
122 There is a lot more to know about select methods and virtual servers -
123 see the manual for details.")
125 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
126 (defvar gnus-post-method nil
127 "*Preferred method for posting USENET news.
128 If this variable is nil, Gnus will use the current method to decide
129 which method to use when posting. If it is non-nil, it will override
130 the current method. This method will not be used in mail groups and
131 the like, only in \"real\" newsgroups.
133 The value must be a valid method as discussed in the documentation of
134 `gnus-select-method'.")
136 (defvar gnus-refer-article-method nil
137 "*Preferred method for fetching an article by Message-ID.
138 If you are reading news from the local spool (with nnspool), fetching
139 articles by Message-ID is painfully slow. By setting this method to an
140 nntp method, you might get acceptable results.
142 The value of this variable must be a valid select method as discussed
143 in the documentation of `gnus-select-method'")
145 (defvar gnus-secondary-select-methods nil
146 "*A list of secondary methods that will be used for reading news.
147 This is a list where each element is a complete select method (see
148 `gnus-select-method').
150 If, for instance, you want to read your mail with the nnml backend,
151 you could set this variable:
153 (setq gnus-secondary-select-methods '((nnml \"\")))")
155 (defvar gnus-secondary-servers nil
156 "*List of NNTP servers that the user can choose between interactively.
157 To make Gnus query you for a server, you have to give `gnus' a
158 non-numeric prefix - `C-u M-x gnus', in short.")
160 (defvar gnus-nntp-server nil
161 "*The name of the host running the NNTP server.
162 This variable is semi-obsolete. Use the `gnus-select-method'
165 (defvar gnus-startup-file "~/.newsrc"
166 "*Your `.newsrc' file.
167 `.newsrc-SERVER' will be used instead if that exists.")
169 (defvar gnus-init-file "~/.gnus"
170 "*Your Gnus elisp startup file.
171 If a file with the .el or .elc suffixes exist, it will be read
174 (defvar gnus-group-faq-directory
175 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
176 "*Directory where the group FAQs are stored.
177 This will most commonly be on a remote machine, and the file will be
180 Note that Gnus uses an aol machine as the default directory. If this
181 feels fundamentally unclean, just think of it as a way to finally get
182 something of value back from them.
184 If the default site is too slow, try one of these:
186 North America: ftp.uu.net /usenet/news.answers
187 mirrors.aol.com /pub/rtfm/usenet
188 ftp.seas.gwu.edu /pub/rtfm
189 rtfm.mit.edu /pub/usenet/news.answers
190 Europe: ftp.uni-paderborn.de /pub/FAQ
191 ftp.Germany.EU.net /pub/newsarchive/news.answers
192 ftp.sunet.se /pub/usenet
193 Asia: nctuccca.edu.tw /USENET/FAQ
194 hwarang.postech.ac.kr /pub/usenet/news.answers
195 ftp.hk.super.net /mirror/faqs")
197 (defvar gnus-group-archive-directory
198 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
199 "*The address of the (ding) archives.")
201 (defvar gnus-group-recent-archive-directory
202 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
203 "*The address of the most recent (ding) articles.")
205 (defvar gnus-default-subscribed-newsgroups nil
206 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
207 It should be a list of strings.
208 If it is `t', Gnus will not do anything special the first time it is
209 started; it'll just use the normal newsgroups subscription methods.")
211 (defvar gnus-use-cross-reference t
212 "*Non-nil means that cross referenced articles will be marked as read.
213 If nil, ignore cross references. If t, mark articles as read in
214 subscribed newsgroups. If neither t nor nil, mark as read in all
217 (defvar gnus-use-dribble-file t
218 "*Non-nil means that Gnus will use a dribble file to store user updates.
219 If Emacs should crash without saving the .newsrc files, complete
220 information can be restored from the dribble file.")
222 (defvar gnus-asynchronous nil
223 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
225 (defvar gnus-asynchronous-article-function nil
226 "*Function for picking articles to pre-fetch, possibly.")
228 (defvar gnus-score-file-single-match-alist nil
229 "*Alist mapping regexps to lists of score files.
230 Each element of this alist should be of the form
231 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
233 If the name of a group is matched by REGEXP, the corresponding scorefiles
234 will be used for that group.
235 The first match found is used, subsequent matching entries are ignored (to
236 use multiple matches, see gnus-score-file-multiple-match-alist).
238 These score files are loaded in addition to any files returned by
239 gnus-score-find-score-files-function (which see).")
241 (defvar gnus-score-file-multiple-match-alist nil
242 "*Alist mapping regexps to lists of score files.
243 Each element of this alist should be of the form
244 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
246 If the name of a group is matched by REGEXP, the corresponding scorefiles
247 will be used for that group.
248 If multiple REGEXPs match a group, the score files corresponding to each
249 match will be used (for only one match to be used, see
250 gnus-score-file-single-match-alist).
252 These score files are loaded in addition to any files returned by
253 gnus-score-find-score-files-function (which see).")
256 (defvar gnus-score-file-suffix "SCORE"
257 "*Suffix of the score files.")
259 (defvar gnus-adaptive-file-suffix "ADAPT"
260 "*Suffix of the adaptive score files.")
262 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
263 "*Function used to find score files.
264 The function will be called with the group name as the argument, and
265 should return a list of score files to apply to that group. The score
266 files do not actually have to exist.
268 Predefined values are:
270 gnus-score-find-single: Only apply the group's own score file.
271 gnus-score-find-hierarchical: Also apply score files from parent groups.
272 gnus-score-find-bnews: Apply score files whose names matches.
274 See the documentation to these functions for more information.
276 This variable can also be a list of functions to be called. Each
277 function should either return a list of score files, or a list of
280 (defvar gnus-score-interactive-default-score 1000
281 "*Scoring commands will raise/lower the score with this number as the default.")
283 (defvar gnus-large-newsgroup 200
284 "*The number of articles which indicates a large newsgroup.
285 If the number of articles in a newsgroup is greater than this value,
286 confirmation is required for selecting the newsgroup.")
288 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
289 (defvar gnus-no-groups-message "No news is horrible news"
290 "*Message displayed by Gnus when no groups are available.")
292 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
293 "*Non-nil means that the default name of a file to save articles in is the group name.
294 If it's nil, the directory form of the group name is used instead.
296 If this variable is a list, and the list contains the element
297 `not-score', long file names will not be used for score files; if it
298 contains the element `not-save', long file names will not be used for
299 saving; and if it contains the element `not-kill', long file names
300 will not be used for kill files.")
302 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
303 "*Name of the directory articles will be saved in (default \"~/News\").
304 Initialized from the SAVEDIR environment variable.")
306 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
307 "*Name of the directory where kill files will be stored (default \"~/News\").
308 Initialized from the SAVEDIR environment variable.")
310 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
311 "*A function to save articles in your favorite format.
312 The function must be interactively callable (in other words, it must
313 be an Emacs command).
315 Gnus provides the following functions:
317 * gnus-summary-save-in-rmail (Rmail format)
318 * gnus-summary-save-in-mail (Unix mail format)
319 * gnus-summary-save-in-folder (MH folder)
320 * gnus-summary-save-in-file (article format).
321 * gnus-summary-save-in-vm (use VM's folder format).")
323 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
324 "*A function generating a file name to save articles in Rmail format.
325 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
327 (defvar gnus-mail-save-name (function gnus-plain-save-name)
328 "*A function generating a file name to save articles in Unix mail format.
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
331 (defvar gnus-folder-save-name (function gnus-folder-save-name)
332 "*A function generating a file name to save articles in MH folder.
333 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
335 (defvar gnus-file-save-name (function gnus-numeric-save-name)
336 "*A function generating a file name to save articles in article format.
337 The function is called with NEWSGROUP, HEADERS, and optional
340 (defvar gnus-split-methods nil
341 "*Variable used to suggest where articles are to be saved.
342 The syntax of this variable is the same as `nnmail-split-methods'.
344 For instance, if you would like to save articles related to Gnus in
345 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
346 you could set this variable to something like:
348 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
349 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
351 (defvar gnus-save-score nil
352 "*If non-nil, save group scoring info.")
354 (defvar gnus-use-adaptive-scoring nil
355 "*If non-nil, use some adaptive scoring scheme.")
357 (defvar gnus-use-cache nil
358 "*If non-nil, Gnus will cache (some) articles locally.")
360 (defvar gnus-use-scoring t
361 "*If non-nil, enable scoring.")
363 (defvar gnus-fetch-old-headers nil
364 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
365 If an unread article in the group refers to an older, already read (or
366 just marked as read) article, the old article will not normally be
367 displayed in the Summary buffer. If this variable is non-nil, Gnus
368 will attempt to grab the headers to the old articles, and thereby
369 build complete threads. If it has the value `some', only enough
370 headers to connect otherwise loose threads will be displayed.
372 The server has to support XOVER for any of this to work.")
375 ;(defvar gnus-visual t
376 ; "*If non-nil, will do various highlighting.
377 ;If nil, no mouse highlights (or any other highlights) will be
378 ;performed. This might speed up Gnus some when generating large group
379 ;and summary buffers.")
381 (defvar gnus-novice-user t
382 "*Non-nil means that you are a usenet novice.
383 If non-nil, verbose messages may be displayed and confirmations may be
386 (defvar gnus-expert-user nil
387 "*Non-nil means that you will never be asked for confirmation about anything.
388 And that means *anything*.")
390 (defvar gnus-verbose 7
391 "*Integer that says how verbose Gnus should be.
392 The higher the number, the more messages Gnus will flash to say what
393 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
394 display most important messages; and at ten, Gnus will keep on
395 jabbering all the time.")
397 (defvar gnus-keep-same-level nil
398 "*Non-nil means that the next newsgroup after the current will be on the same level.
399 When you type, for instance, `n' after reading the last article in the
400 current newsgroup, you will go to the next newsgroup. If this variable
401 is nil, the next newsgroup will be the next from the group
403 If this variable is non-nil, Gnus will either put you in the
404 next newsgroup with the same level, or, if no such newsgroup is
405 available, the next newsgroup with the lowest possible level higher
406 than the current level.
407 If this variable is `best', Gnus will make the next newsgroup the one
408 with the best level.")
410 (defvar gnus-summary-make-false-root 'adopt
411 "*nil means that Gnus won't gather loose threads.
412 If the root of a thread has expired or been read in a previous
413 session, the information necessary to build a complete thread has been
414 lost. Instead of having many small sub-threads from this original thread
415 scattered all over the summary buffer, Gnus can gather them.
417 If non-nil, Gnus will try to gather all loose sub-threads from an
418 original thread into one large thread.
420 If this variable is non-nil, it should be one of `none', `adopt',
423 If this variable is `none', Gnus will not make a false root, but just
424 present the sub-threads after another.
425 If this variable is `dummy', Gnus will create a dummy root that will
426 have all the sub-threads as children.
427 If this variable is `adopt', Gnus will make one of the \"children\"
428 the parent and mark all the step-children as such.
429 If this variable is `empty', the \"children\" are printed with empty
430 subject fields. (Or rather, they will be printed with a string
431 given by the `gnus-summary-same-subject' variable.)")
433 (defvar gnus-summary-gather-subject-limit nil
434 "*Maximum length of subject comparisons when gathering loose threads.
435 Use nil to compare full subjects. Setting this variable to a low
436 number will help gather threads that have been corrupted by
437 newsreaders chopping off subject lines, but it might also mean that
438 unrelated articles that have subject that happen to begin with the
439 same few characters will be incorrectly gathered.
441 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
442 comparing subjects.")
444 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
445 (defvar gnus-summary-same-subject ""
446 "*String indicating that the current article has the same subject as the previous.
447 This variable will only be used if the value of
448 `gnus-summary-make-false-root' is `empty'.")
450 (defvar gnus-summary-goto-unread t
451 "*If non-nil, marking commands will go to the next unread article.")
453 (defvar gnus-group-goto-unread t
454 "*If non-nil, movement commands will go to the next unread and subscribed group.")
456 (defvar gnus-check-new-newsgroups t
457 "*Non-nil means that Gnus will add new newsgroups at startup.
458 If this variable is `ask-server', Gnus will ask the server for new
459 groups since the last time it checked. This means that the killed list
460 is no longer necessary, so you could set `gnus-save-killed-list' to
463 A variant is to have this variable be a list of select methods. Gnus
464 will then use the `ask-server' method on all these select methods to
465 query for new groups from all those servers.
468 (setq gnus-check-new-newsgroups
469 '((nntp \"some.server\") (nntp \"other.server\")))
471 If this variable is nil, then you have to tell Gnus explicitly to
472 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
474 (defvar gnus-check-bogus-newsgroups nil
475 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
476 If this variable is nil, then you have to tell Gnus explicitly to
477 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
479 (defvar gnus-read-active-file t
480 "*Non-nil means that Gnus will read the entire active file at startup.
481 If this variable is nil, Gnus will only know about the groups in your
484 If this variable is `some', Gnus will try to only read the relevant
485 parts of the active file from the server. Not all servers support
486 this, and it might be quite slow with other servers, but this should
487 generally be faster than both the t and nil value.
489 If you set this variable to nil or `some', you probably still want to
490 be told about new newsgroups that arrive. To do that, set
491 `gnus-check-new-newsgroups' to `ask-server'. This may not work
492 properly with all servers.")
494 (defvar gnus-level-subscribed 5
495 "*Groups with levels less than or equal to this variable are subscribed.")
497 (defvar gnus-level-unsubscribed 7
498 "*Groups with levels less than or equal to this variable are unsubscribed.
499 Groups with levels less than `gnus-level-subscribed', which should be
500 less than this variable, are subscribed.")
502 (defvar gnus-level-zombie 8
503 "*Groups with this level are zombie groups.")
505 (defvar gnus-level-killed 9
506 "*Groups with this level are killed.")
508 (defvar gnus-level-default-subscribed 3
509 "*New subscribed groups will be subscribed at this level.")
511 (defvar gnus-level-default-unsubscribed 6
512 "*New unsubscribed groups will be unsubscribed at this level.")
514 (defvar gnus-activate-foreign-newsgroups 4
515 "*If nil, Gnus will not check foreign newsgroups at startup.
516 If it is non-nil, it should be a number between one and nine. Foreign
517 newsgroups that have a level lower or equal to this number will be
518 activated on startup. For instance, if you want to active all
519 subscribed newsgroups, but not the rest, you'd set this variable to
520 `gnus-level-subscribed'.
522 If you subscribe to lots of newsgroups from different servers, startup
523 might take a while. By setting this variable to nil, you'll save time,
524 but you won't be told how many unread articles there are in the
527 (defvar gnus-save-newsrc-file t
528 "*Non-nil means that Gnus will save the `.newsrc' file.
529 Gnus always saves its own startup file, which is called
530 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
531 be readily understood by other newsreaders. If you don't plan on
532 using other newsreaders, set this variable to nil to save some time on
535 (defvar gnus-save-killed-list t
536 "*If non-nil, save the list of killed groups to the startup file.
537 This will save both time (when starting and quitting) and space (both
538 memory and disk), but it will also mean that Gnus has no record of
539 which groups are new and which are old, so the automatic new
540 newsgroups subscription methods become meaningless. You should always
541 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
544 (defvar gnus-interactive-catchup t
545 "*If non-nil, require your confirmation when catching up a group.")
547 (defvar gnus-interactive-post t
548 "*If non-nil, group name will be asked for when posting.")
550 (defvar gnus-interactive-exit t
551 "*If non-nil, require your confirmation when exiting Gnus.")
553 (defvar gnus-kill-killed t
554 "*If non-nil, Gnus will apply kill files to already killed articles.
555 If it is nil, Gnus will never apply kill files to articles that have
556 already been through the scoring process, which might very well save lots
559 (defvar gnus-extract-address-components 'gnus-extract-address-components
560 "*Function for extracting address components from a From header.
561 Two pre-defined function exist: `gnus-extract-address-components',
562 which is the default, quite fast, and too simplistic solution, and
563 `mail-extract-address-components', which works much better, but is
566 (defvar gnus-summary-default-score 0
567 "*Default article score level.
568 If this variable is nil, scoring will be disabled.")
570 (defvar gnus-summary-zcore-fuzz 0
571 "*Fuzziness factor for the zcore in the summary buffer.
572 Articles with scores closer than this to `gnus-summary-default-score'
573 will not be marked.")
575 (defvar gnus-simplify-subject-fuzzy-regexp nil
576 "*Regular expression that will be removed from subject strings if
577 fuzzy subject simplification is selected.")
579 (defvar gnus-group-default-list-level gnus-level-subscribed
580 "*Default listing level.
581 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
583 (defvar gnus-group-use-permanent-levels nil
584 "*If non-nil, once you set a level, Gnus will use this level.")
586 (defvar gnus-show-mime nil
587 "*If non-nil, do mime processing of articles.
588 The articles will simply be fed to the function given by
589 `gnus-show-mime-method'.")
591 (defvar gnus-strict-mime t
592 "*If nil, decode MIME header even if there is not Mime-Version field.")
594 (defvar gnus-show-mime-method (function metamail-buffer)
595 "*Function to process a MIME message.
596 The function is called from the article buffer.")
598 (defvar gnus-show-threads t
599 "*If non-nil, display threads in summary mode.")
601 (defvar gnus-thread-hide-subtree nil
602 "*If non-nil, hide all threads initially.
603 If threads are hidden, you have to run the command
604 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
605 to expose hidden threads.")
607 (defvar gnus-thread-hide-killed t
608 "*If non-nil, hide killed threads automatically.")
610 (defvar gnus-thread-ignore-subject nil
611 "*If non-nil, ignore subjects and do all threading based on the Reference header.
612 If nil, which is the default, articles that have different subjects
613 from their parents will start separate threads.")
615 (defvar gnus-thread-indent-level 4
616 "*Number that says how much each sub-thread should be indented.")
618 (defvar gnus-ignored-newsgroups
619 (purecopy (mapconcat 'identity
620 '("^to\\." ; not "real" groups
621 "^[0-9. \t]+ " ; all digits in name
622 "[][\"#'()]" ; bogus characters
625 "*A regexp to match uninteresting newsgroups in the active file.
626 Any lines in the active file matching this regular expression are
627 removed from the newsgroup list before anything else is done to it,
628 thus making them effectively non-existent.")
630 (defvar gnus-ignored-headers
631 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
632 "*All headers that match this regexp will be hidden.
633 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
635 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
636 "*All headers that do not match this regexp will be hidden.
637 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
639 (defvar gnus-sorted-header-list
640 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
641 "^Cc:" "^Date:" "^Organization:")
642 "*This variable is a list of regular expressions.
643 If it is non-nil, headers that match the regular expressions will
644 be placed first in the article buffer in the sequence specified by
647 (defvar gnus-show-all-headers nil
648 "*If non-nil, don't hide any headers.")
650 (defvar gnus-save-all-headers t
651 "*If non-nil, don't remove any headers before saving.")
653 (defvar gnus-inhibit-startup-message nil
654 "*If non-nil, the startup message will not be displayed.")
656 (defvar gnus-signature-separator "^-- *$"
657 "Regexp matching signature separator.")
659 (defvar gnus-auto-extend-newsgroup t
660 "*If non-nil, extend newsgroup forward and backward when requested.")
662 (defvar gnus-auto-select-first t
663 "*If non-nil, select the first unread article when entering a group.
664 If you want to prevent automatic selection of the first unread article
665 in some newsgroups, set the variable to nil in
666 `gnus-select-group-hook'.")
668 (defvar gnus-auto-select-next t
669 "*If non-nil, offer to go to the next group from the end of the previous.
670 If the value is t and the next newsgroup is empty, Gnus will exit
671 summary mode and go back to group mode. If the value is neither nil
672 nor t, Gnus will select the following unread newsgroup. In
673 particular, if the value is the symbol `quietly', the next unread
674 newsgroup will be selected without any confirmations.")
676 (defvar gnus-auto-select-same nil
677 "*If non-nil, select the next article with the same subject.")
679 (defvar gnus-summary-check-current nil
680 "*If non-nil, consider the current article when moving.
681 The \"unread\" movement commands will stay on the same line if the
682 current article is unread.")
684 (defvar gnus-auto-center-summary t
685 "*If non-nil, always center the current summary buffer.")
687 (defvar gnus-break-pages t
688 "*If non-nil, do page breaking on articles.
689 The page delimiter is specified by the `gnus-page-delimiter'
692 (defvar gnus-page-delimiter "^\^L"
693 "*Regexp describing what to use as article page delimiters.
694 The default value is \"^\^L\", which is a form linefeed at the
695 beginning of a line.")
697 (defvar gnus-use-full-window t
698 "*If non-nil, use the entire Emacs screen.")
700 (defvar gnus-window-configuration nil
701 "Obsolete variable. See `gnus-buffer-configuration'.")
703 (defvar gnus-buffer-configuration
704 '((group ([group 1.0 point]
705 (if gnus-carpal [group-carpal 4])))
706 (summary ([summary 1.0 point]
707 (if gnus-carpal [summary-carpal 4])))
708 (article ([summary 0.25 point]
709 (if gnus-carpal [summary-carpal 4])
711 (server ([server 1.0 point]
712 (if gnus-carpal [server-carpal 2])))
713 (browse ([browse 1.0 point]
714 (if gnus-carpal [browse-carpal 2])))
715 (group-mail ([mail 1.0 point]))
716 (summary-mail ([mail 1.0 point]))
717 (summary-reply ([article 0.5]
719 (info ([nil 1.0 point]))
720 (summary-faq ([summary 0.25]
722 (edit-group ([group 0.5]
723 [edit-group 1.0 point]))
724 (edit-server ([server 0.5]
725 [edit-server 1.0 point]))
726 (edit-score ([summary 0.25]
727 [edit-score 1.0 point]))
728 (post ([post 1.0 point]))
729 (reply ([article 0.5]
731 (mail-forward ([mail 1.0 point]))
732 (post-forward ([post 1.0 point]))
733 (reply-yank ([mail 1.0 point]))
734 (followup ([article 0.5]
736 (followup-yank ([post 1.0 point])))
737 "Window configuration for all possible Gnus buffers.
738 This variable is a list of lists. Each of these lists has a NAME and
739 a RULE. The NAMEs are commonsense names like `group', which names a
740 rule used when displaying the group buffer; `summary', which names a
741 rule for what happens when you enter a group and do not display an
742 article buffer; and so on. See the value of this variable for a
743 complete list of NAMEs.
745 Each RULE is a list of vectors. The first element in this vector is
746 the name of the buffer to be displayed; the second element is the
747 percentage of the screen this buffer is to occupy (a number in the
748 0.0-0.99 range); the optional third element is `point', which should
749 be present to denote which buffer point is to go to after making this
750 buffer configuration.")
752 (defvar gnus-window-to-buffer
753 '((group . gnus-group-buffer)
754 (summary . gnus-summary-buffer)
755 (article . gnus-article-buffer)
756 (server . gnus-server-buffer)
757 (browse . "*Gnus Browse Server*")
758 (edit-group . gnus-group-edit-buffer)
759 (edit-server . gnus-server-edit-buffer)
760 (group-carpal . gnus-carpal-group-buffer)
761 (summary-carpal . gnus-carpal-summary-buffer)
762 (server-carpal . gnus-carpal-server-buffer)
763 (browse-carpal . gnus-carpal-browse-buffer)
764 (edit-score . gnus-score-edit-buffer)
765 (mail . gnus-mail-buffer)
766 (post . gnus-post-news-buffer)
767 (faq . gnus-faq-buffer))
768 "Mapping from short symbols to buffer names or buffer variables.")
770 (defvar gnus-carpal nil
771 "*If non-nil, display clickable icons.")
773 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
774 "*Function called with a group name when new group is detected.
775 A few pre-made functions are supplied: `gnus-subscribe-randomly'
776 inserts new groups at the beginning of the list of groups;
777 `gnus-subscribe-alphabetically' inserts new groups in strict
778 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
779 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
782 ;; Suggested by a bug report by Hallvard B Furuseth.
783 ;; <h.b.furuseth@usit.uio.no>.
784 (defvar gnus-subscribe-options-newsgroup-method
785 (function gnus-subscribe-alphabetically)
786 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
787 If, for instance, you want to subscribe to all newsgroups in the
788 \"no\" and \"alt\" hierarchies, you'd put the following in your
791 options -n no.all alt.all
793 Gnus will the subscribe all new newsgroups in these hierarchies with
794 the subscription method in this variable.")
796 (defvar gnus-subscribe-hierarchical-interactive nil
797 "*If non-nil, Gnus will offer to subscribe hierarchically.
798 When a new hierarchy appears, Gnus will ask the user:
800 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
802 If the user pressed `d', Gnus will descend the hierarchy, `y' will
803 subscribe to all newsgroups in the hierarchy and `s' will skip this
804 hierarchy in its entirety.")
806 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
807 "*Function used for sorting the group buffer.
808 This function will be called with group info entries as the arguments
809 for the groups to be sorted. Pre-made functions include
810 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
811 `gnus-group-sort-by-level'")
813 ;; Mark variables suggested by Thomas Michanek
814 ;; <Thomas.Michanek@telelogic.se>.
815 (defvar gnus-unread-mark ?
816 "*Mark used for unread articles.")
817 (defvar gnus-ticked-mark ?!
818 "*Mark used for ticked articles.")
819 (defvar gnus-dormant-mark ??
820 "*Mark used for dormant articles.")
821 (defvar gnus-del-mark ?r
822 "*Mark used for del'd articles.")
823 (defvar gnus-read-mark ?R
824 "*Mark used for read articles.")
825 (defvar gnus-expirable-mark ?E
826 "*Mark used for expirable articles.")
827 (defvar gnus-killed-mark ?K
828 "*Mark used for killed articles.")
829 (defvar gnus-kill-file-mark ?X
830 "*Mark used for articles killed by kill files.")
831 (defvar gnus-low-score-mark ?Y
832 "*Mark used for articles with a low score.")
833 (defvar gnus-catchup-mark ?C
834 "*Mark used for articles that are caught up.")
835 (defvar gnus-replied-mark ?A
836 "*Mark used for articles that have been replied to.")
837 (defvar gnus-process-mark ?#
839 (defvar gnus-ancient-mark ?O
840 "*Mark used for ancient articles.")
841 (defvar gnus-canceled-mark ?G
842 "*Mark used for canceled articles.")
843 (defvar gnus-score-over-mark ?+
844 "*Score mark used for articles with high scores.")
845 (defvar gnus-score-below-mark ?-
846 "*Score mark used for articles with low scores.")
847 (defvar gnus-empty-thread-mark ?
848 "*There is no thread under the article.")
849 (defvar gnus-not-empty-thread-mark ?=
850 "*There is a thread under the article.")
851 (defvar gnus-dummy-mark ?Z
852 "*This is a dummy article.")
854 (defvar gnus-view-pseudo-asynchronously nil
855 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
857 (defvar gnus-view-pseudos nil
858 "*If `automatic', pseudo-articles will be viewed automatically.
859 If `not-confirm', pseudos will be viewed automatically, and the user
860 will not be asked to confirm the command.")
862 (defvar gnus-view-pseudos-separately t
863 "*If non-nil, one pseudo-article will be created for each file to be viewed.
864 If nil, all files that use the same viewing command will be given as a
865 list of parameters to that command.")
867 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
868 "*Format of group lines.
869 It works along the same lines as a normal formatting string,
870 with some simple extensions.
872 %M Only marked articles (character, \"*\" or \" \")
873 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
874 %L Level of subscribedness (integer)
875 %N Number of unread articles (integer)
876 %I Number of dormant articles (integer)
877 %i Number of ticked and dormant (integer)
878 %T Number of ticked articles (integer)
879 %R Number of read articles (integer)
880 %t Total number of articles (integer)
881 %y Number of unread, unticked articles (integer)
882 %G Group name (string)
883 %g Qualified group name (string)
884 %D Group description (string)
885 %s Select method (string)
886 %o Moderated group (char, \"m\")
887 %p Process mark (char)
888 %O Moderated group (string, \"(m)\" or \"\")
889 %n Select from where (string)
890 %z A string that look like `<%s:%n>' if a foreign select method is used
891 %u User defined specifier. The next character in the format string should
892 be a letter. Gnus will call the function gnus-user-format-function-X,
893 where X is the letter following %u. The function will be passed the
894 current header as argument. The function should return a string, which
895 will be inserted into the buffer just like information from any other
898 Text between %( and %) will be highlighted with `gnus-mouse-face' when
899 the mouse point move inside the area. There can only be one such area.
901 Note that this format specification is not always respected. For
902 reasons of efficiency, when listing killed groups, this specification
903 is ignored altogether. If the spec is changed considerably, your
904 output may end up looking strange when listing both alive and killed
907 If you use %o or %O, reading the active file will be slower and quite
908 a bit of extra memory will be used. %D will also worsen performance.
909 Also note that if you change the format specification to include any
910 of these specs, you must probably re-start Gnus to see them go into
913 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
914 "*The format specification of the lines in the summary buffer.
916 It works along the same lines as a normal formatting string,
917 with some simple extensions.
919 %N Article number, left padded with spaces (string)
921 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
922 %n Name of the poster (string)
923 %a Extracted name of the poster (string)
924 %A Extracted address of the poster (string)
925 %F Contents of the From: header (string)
926 %x Contents of the Xref: header (string)
927 %D Date of the article (string)
928 %d Date of the article (string) in DD-MMM format
929 %M Message-id of the article (string)
930 %r References of the article (string)
931 %c Number of characters in the article (integer)
932 %L Number of lines in the article (integer)
933 %I Indentation based on thread level (a string of spaces)
934 %T A string with two possible values: 80 spaces if the article
935 is on thread level two or larger and 0 spaces on level one
936 %R \"R\" if this article has been replied to, \" \" otherwise (character)
937 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
938 %[ Opening bracket (character, \"[\" or \"<\")
939 %] Closing bracket (character, \"]\" or \">\")
940 %> Spaces of length thread-level (string)
941 %< Spaces of length (- 20 thread-level) (string)
942 %i Article score (number)
943 %z Article zcore (character)
944 %t Number of articles under the current thread (number).
945 %e Whether the thread is empty or not (character).
946 %u User defined specifier. The next character in the format string should
947 be a letter. Gnus will call the function gnus-user-format-function-X,
948 where X is the letter following %u. The function will be passed the
949 current header as argument. The function should return a string, which
950 will be inserted into the summary just like information from any other
953 Text between %( and %) will be highlighted with `gnus-mouse-face'
954 when the mouse point is placed inside the area. There can only be one
957 The %U (status), %R (replied) and %z (zcore) specs have to be handled
958 with care. For reasons of efficiency, Gnus will compute what column
959 these characters will end up in, and \"hard-code\" that. This means that
960 it is illegal to have these specs after a variable-length spec. Well,
961 you might not be arrested, but your summary buffer will look strange,
964 The smart choice is to have these specs as for to the left as
967 This restriction may disappear in later versions of Gnus.")
969 (defvar gnus-summary-dummy-line-format "* : : %S\n"
970 "*The format specification for the dummy roots in the summary buffer.
971 It works along the same lines as a normal formatting string,
972 with some simple extensions.
976 (defvar gnus-summary-mode-line-format "Gnus %G/%A %Z"
977 "*The format specification for the summary mode line.")
979 (defvar gnus-article-mode-line-format "Gnus %G/%A %S"
980 "*The format specification for the article mode line.")
982 (defvar gnus-group-mode-line-format "Gnus List of groups {%M:%S} "
983 "*The format specification for the group mode line.")
985 (defvar gnus-valid-select-methods
986 '(("nntp" post address prompt-address)
988 ("nnvirtual" none virtual prompt-address)
989 ("nnmbox" mail respool)
990 ("nnml" mail respool)
991 ("nnmh" mail respool)
992 ("nndir" none prompt-address address)
993 ("nneething" none prompt-address)
995 ("nndoc" none prompt-address)
996 ("nnbabyl" mail respool)
997 ("nnkiboze" post virtual)
999 ("nnfolder" mail respool))
1000 "An alist of valid select methods.
1001 The first element of each list lists should be a string with the name
1002 of the select method. The other elements may be be the category of
1003 this method (ie. `post', `mail', `none' or whatever) or other
1004 properties that this method has (like being respoolable).
1005 If you implement a new select method, all you should have to change is
1006 this variable. I think.")
1008 (defvar gnus-updated-mode-lines '(group article summary)
1009 "*List of buffers that should update their mode lines.
1010 The list may contain the symbols `group', `article' and `summary'. If
1011 the corresponding symbol is present, Gnus will keep that mode line
1012 updated with information that may be pertinent.
1013 If this variable is nil, screen refresh may be quicker.")
1015 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1016 (defvar gnus-mode-non-string-length 21
1017 "*Max length of mode-line non-string contents.
1018 If this is nil, Gnus will take space as is needed, leaving the rest
1019 of the modeline intact.")
1022 ;(defvar gnus-mouse-face 'highlight
1023 ; "*Face used for mouse highlighting in Gnus.
1024 ;No mouse highlights will be done if `gnus-visual' is nil.")
1026 (defvar gnus-summary-mark-below nil
1027 "*Mark all articles with a score below this variable as read.
1028 This variable is local to each summary buffer and usually set by the
1031 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1032 "*List of functions used for sorting threads in the summary buffer.
1033 By default, threads are sorted by article number.
1035 Each function takes two threads and return non-nil if the first thread
1036 should be sorted before the other. If you use more than one function,
1037 the primary sort function should be the last.
1039 Ready-mady functions include `gnus-thread-sort-by-number',
1040 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1041 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1042 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1044 (defvar gnus-thread-score-function '+
1045 "*Function used for calculating the total score of a thread.
1047 The function is called with the scores of the article and each
1048 subthread and should then return the score of the thread.
1050 Some functions you can use are `+', `max', or `min'.")
1052 (defvar gnus-options-subscribe nil
1053 "*All new groups matching this regexp will be subscribed unconditionally.
1054 Note that this variable deals only with new newsgroups. This variable
1055 does not affect old newsgroups.")
1057 (defvar gnus-options-not-subscribe nil
1058 "*All new groups matching this regexp will be ignored.
1059 Note that this variable deals only with new newsgroups. This variable
1060 does not affect old (already subscribed) newsgroups.")
1062 (defvar gnus-auto-expirable-newsgroups nil
1063 "*Groups in which to automatically mark read articles as expirable.
1064 If non-nil, this should be a regexp that should match all groups in
1065 which to perform auto-expiry. This only makes sense for mail groups.")
1067 (defvar gnus-hidden-properties '(invisible t intangible t)
1068 "Property list to use for hiding text.")
1070 (defvar gnus-modtime-botch nil
1071 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1072 due to the bogus appearance that .newsrc was modified on disc.")
1076 (defvar gnus-group-mode-hook nil
1077 "*A hook for Gnus group mode.")
1079 (defvar gnus-summary-mode-hook nil
1080 "*A hook for Gnus summary mode.
1081 This hook is run before any variables are set in the summary buffer.")
1083 (defvar gnus-article-mode-hook nil
1084 "*A hook for Gnus article mode.")
1086 (defun gnus-summary-prepare-exit-hook nil
1087 "*A hook called when preparing to exit from the summary buffer.
1088 It calls `gnus-summary-expire-articles' by default.")
1089 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1091 (defun gnus-summary-exit-hook nil
1092 "*A hook called on exit from the summary buffer.")
1094 (defvar gnus-open-server-hook nil
1095 "*A hook called just before opening connection to the news server.")
1097 (defvar gnus-load-hook nil
1098 "*A hook run while Gnus is loaded.")
1100 (defvar gnus-startup-hook nil
1101 "*A hook called at startup.
1102 This hook is called after Gnus is connected to the NNTP server.")
1104 (defvar gnus-get-new-news-hook nil
1105 "*A hook run just before Gnus checks for new news.")
1107 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1108 "*A function that is called to generate the group buffer.
1109 The function is called with three arguments: The first is a number;
1110 all group with a level less or equal to that number should be listed,
1111 if the second is non-nil, empty groups should also be displayed. If
1112 the third is non-nil, it is a number. No groups with a level lower
1113 than this number should be displayed.
1115 The only current function implemented is `gnus-group-prepare-flat'.")
1117 (defvar gnus-group-prepare-hook nil
1118 "*A hook called after the group buffer has been generated.
1119 If you want to modify the group buffer, you can use this hook.")
1121 (defvar gnus-summary-prepare-hook nil
1122 "*A hook called after the summary buffer has been generated.
1123 If you want to modify the summary buffer, you can use this hook.")
1125 (defvar gnus-article-prepare-hook nil
1126 "*A hook called after an article has been prepared in the article buffer.
1127 If you want to run a special decoding program like nkf, use this hook.")
1129 ;(defvar gnus-article-display-hook nil
1130 ; "*A hook called after the article is displayed in the article buffer.
1131 ;The hook is designed to change the contents of the article
1132 ;buffer. Typical functions that this hook may contain are
1133 ;`gnus-article-hide-headers' (hide selected headers),
1134 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1135 ;`gnus-article-hide-signature' (hide signature) and
1136 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1137 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1138 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1139 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1141 (defvar gnus-article-x-face-command
1142 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1143 "String or function to be executed to display an X-Face header.
1144 If it is a string, the command will be executed in a sub-shell
1145 asynchronously. The compressed face will be piped to this command.")
1147 (defvar gnus-article-x-face-too-ugly nil
1148 "Regexp matching posters whose face shouldn't be shown automatically.")
1150 (defvar gnus-select-group-hook nil
1151 "*A hook called when a newsgroup is selected.
1153 If you'd like to simplify subjects like the
1154 `gnus-summary-next-same-subject' command does, you can use the
1157 (setq gnus-select-group-hook
1160 (mapcar (lambda (header)
1161 (mail-header-set-subject
1163 (gnus-simplify-subject
1164 (mail-header-subject header) 're-only)))
1165 gnus-newsgroup-headers))))")
1167 (defvar gnus-select-article-hook
1168 '(gnus-summary-show-thread)
1169 "*A hook called when an article is selected.
1170 The default hook shows conversation thread subtrees of the selected
1171 article automatically using `gnus-summary-show-thread'.")
1173 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1174 "*A hook called to apply kill files to a group.
1175 This hook is intended to apply a kill file to the selected newsgroup.
1176 The function `gnus-apply-kill-file' is called by default.
1178 Since a general kill file is too heavy to use only for a few
1179 newsgroups, I recommend you to use a lighter hook function. For
1180 example, if you'd like to apply a kill file to articles which contains
1181 a string `rmgroup' in subject in newsgroup `control', you can use the
1184 (setq gnus-apply-kill-hook
1187 (cond ((string-match \"control\" gnus-newsgroup-name)
1188 (gnus-kill \"Subject\" \"rmgroup\")
1189 (gnus-expunge \"X\"))))))")
1191 (defvar gnus-visual-mark-article-hook
1192 (list 'gnus-highlight-selected-summary)
1193 "*Hook run after selecting an article in the summary buffer.
1194 It is meant to be used for highlighting the article in some way. It
1195 is not run if `gnus-visual' is nil.")
1197 (defvar gnus-exit-group-hook nil
1198 "*A hook called when exiting (not quitting) summary mode.")
1200 (defvar gnus-suspend-gnus-hook nil
1201 "*A hook called when suspending (not exiting) Gnus.")
1203 (defvar gnus-exit-gnus-hook nil
1204 "*A hook called when exiting Gnus.")
1206 (defvar gnus-save-newsrc-hook nil
1207 "*A hook called when saving the newsrc file.")
1209 (defvar gnus-summary-update-hook
1210 (list 'gnus-summary-highlight-line)
1211 "*A hook called when a summary line is changed.
1212 The hook will not be called if `gnus-visual' is nil.
1214 The default function `gnus-summary-highlight-line' will
1215 highlight the line according to the `gnus-summary-highlight'
1218 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1219 "*A hook called when an article is selected for the first time.
1220 The hook is intended to mark an article as read (or unread)
1221 automatically when it is selected.")
1223 ;; Remove any hilit infestation.
1224 (add-hook 'gnus-startup-hook
1226 (remove-hook 'gnus-summary-prepare-hook
1227 'hilit-rehighlight-buffer-quietly)
1228 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1229 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1230 (remove-hook 'gnus-article-prepare-hook
1231 'hilit-rehighlight-buffer-quietly)))
1235 ;; Internal variables
1237 ;; Avoid highlighting in kill files.
1238 (defvar gnus-summary-inhibit-highlight nil)
1239 (defvar gnus-newsgroup-selected-overlay nil)
1241 (defvar gnus-article-mode-map nil)
1242 (defvar gnus-dribble-buffer nil)
1243 (defvar gnus-headers-retrieved-by nil)
1244 (defvar gnus-article-reply nil)
1245 (defvar gnus-override-method nil)
1246 (defvar gnus-article-check-size nil)
1248 (defvar gnus-current-score-file nil)
1249 (defvar gnus-internal-global-score-files nil)
1250 (defvar gnus-score-file-list nil)
1253 (defvar gnus-current-move-group nil)
1255 (defvar gnus-newsgroup-dependencies nil)
1256 (defvar gnus-newsgroup-threads nil)
1257 (defvar gnus-newsgroup-async nil)
1258 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1260 (defvar gnus-newsgroup-adaptive nil)
1262 (defvar gnus-summary-display-table nil)
1264 (defconst gnus-group-line-format-alist
1265 (list (list ?M 'marked ?c)
1266 (list ?S 'subscribed ?c)
1268 (list ?N 'number ?s)
1269 (list ?I 'number-of-dormant ?d)
1270 (list ?T 'number-of-ticked ?d)
1271 (list ?R 'number-of-read ?s)
1272 (list ?t 'number-total ?d)
1273 (list ?y 'number-of-unread-unticked ?s)
1274 (list ?i 'number-of-ticked-and-dormant ?d)
1276 (list ?G 'qualified-group ?s)
1277 (list ?D 'newsgroup-description ?s)
1278 (list ?o 'moderated ?c)
1279 (list ?O 'moderated-string ?s)
1280 (list ?p 'process-marked ?c)
1281 (list ?s 'news-server ?s)
1282 (list ?n 'news-method ?s)
1283 (list ?z 'news-method-string ?s)
1284 (list ?u 'user-defined ?s)))
1286 (defconst gnus-summary-line-format-alist
1287 (list (list ?N 'number ?d)
1288 (list ?S 'subject ?s)
1289 (list ?s 'subject-or-nil ?s)
1291 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1293 (list ?a '(or (car (funcall gnus-extract-address-components from))
1296 (list ?x (macroexpand '(mail-header-xref header)) ?s)
1297 (list ?D (macroexpand '(mail-header-date header)) ?s)
1298 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s)
1299 (list ?M (macroexpand '(mail-header-id header)) ?s)
1300 (list ?r (macroexpand '(mail-header-references header)) ?s)
1301 (list ?c '(or (mail-header-chars header) 0) ?d)
1303 (list ?I 'indentation ?s)
1304 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1305 (list ?R 'replied ?c)
1306 (list ?\[ 'opening-bracket ?c)
1307 (list ?\] 'closing-bracket ?c)
1308 (list ?\> '(make-string level ? ) ?s)
1309 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1311 (list ?z 'score-char ?c)
1312 (list ?U 'unread ?c)
1313 (list ?t '(gnus-summary-number-of-articles-in-thread
1314 (and (boundp 'thread) (car thread)))
1316 (list ?e '(gnus-summary-number-of-articles-in-thread
1317 (and (boundp 'thread) (car thread)) t)
1319 (list ?u 'user-defined ?s))
1320 "An alist of format specifications that can appear in summary lines,
1321 and what variables they correspond with, along with the type of the
1322 variable (string, integer, character, etc).")
1324 (defconst gnus-summary-dummy-line-format-alist
1325 (list (list ?S 'subject ?s)
1326 (list ?N 'number ?d)
1327 (list ?u 'user-defined ?s)))
1329 (defconst gnus-summary-mode-line-format-alist
1330 (list (list ?G 'group-name ?s)
1331 (list ?g '(gnus-short-group-name group-name) ?s)
1332 (list ?A 'article-number ?d)
1333 (list ?Z 'unread-and-unselected ?s)
1334 (list ?V 'gnus-version ?s)
1335 (list ?U 'unread ?d)
1336 (list ?S 'subject ?s)
1337 (list ?e 'unselected ?d)
1338 (list ?u 'user-defined ?s)
1339 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1341 (defconst gnus-group-mode-line-format-alist
1342 (list (list ?S 'news-server ?s)
1343 (list ?M 'news-method ?s)
1344 (list ?u 'user-defined ?s)))
1346 (defvar gnus-have-read-active-file nil)
1348 (defconst gnus-maintainer
1349 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1350 "The mail address of the Gnus maintainers.")
1352 (defconst gnus-version "Gnus v5.0.8"
1353 "Version number for this version of Gnus.")
1355 (defvar gnus-info-nodes
1356 '((gnus-group-mode "(gnus)The Group Buffer")
1357 (gnus-summary-mode "(gnus)The Summary Buffer")
1358 (gnus-article-mode "(gnus)The Article Buffer"))
1359 "Assoc list of major modes and related Info nodes.")
1361 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1362 "The location of the Gnus documentation group.")
1364 (defvar gnus-group-buffer "*Group*")
1365 (defvar gnus-summary-buffer "*Summary*")
1366 (defvar gnus-article-buffer "*Article*")
1367 (defvar gnus-server-buffer "*Server*")
1369 (defvar gnus-work-buffer " *gnus work*")
1371 (defvar gnus-buffer-list nil
1372 "Gnus buffers that should be killed on exit.")
1374 (defvar gnus-server-alist nil
1375 "List of available servers.")
1377 (defvar gnus-variable-list
1378 '(gnus-newsrc-options gnus-newsrc-options-n
1379 gnus-newsrc-last-checked-date
1380 gnus-newsrc-alist gnus-server-alist
1381 gnus-killed-list gnus-zombie-list)
1382 "Gnus variables saved in the quick startup file.")
1384 (defvar gnus-overload-functions
1385 '((news-inews gnus-inews-news "rnewspost"))
1386 "Functions overloaded by gnus.
1387 It is a list of `(original overload &optional file)'.")
1389 (defvar gnus-newsrc-options nil
1390 "Options line in the .newsrc file.")
1392 (defvar gnus-newsrc-options-n nil
1393 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1395 (defvar gnus-newsrc-last-checked-date nil
1396 "Date Gnus last asked server for new newsgroups.")
1398 (defvar gnus-newsrc-alist nil
1399 "Assoc list of read articles.
1400 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1402 (defvar gnus-newsrc-hashtb nil
1403 "Hashtable of gnus-newsrc-alist.")
1405 (defvar gnus-killed-list nil
1406 "List of killed newsgroups.")
1408 (defvar gnus-killed-hashtb nil
1409 "Hash table equivalent of gnus-killed-list.")
1411 (defvar gnus-zombie-list nil
1412 "List of almost dead newsgroups.")
1414 (defvar gnus-description-hashtb nil
1415 "Descriptions of newsgroups.")
1417 (defvar gnus-list-of-killed-groups nil
1418 "List of newsgroups that have recently been killed by the user.")
1420 (defvar gnus-active-hashtb nil
1421 "Hashtable of active articles.")
1423 (defvar gnus-moderated-list nil
1424 "List of moderated newsgroups.")
1426 (defvar gnus-group-marked nil)
1428 (defvar gnus-current-startup-file nil
1429 "Startup file for the current host.")
1431 (defvar gnus-last-search-regexp nil
1432 "Default regexp for article search command.")
1434 (defvar gnus-last-shell-command nil
1435 "Default shell command on article.")
1437 (defvar gnus-current-select-method nil
1438 "The current method for selecting a newsgroup.")
1440 (defvar gnus-group-list-mode nil)
1442 (defvar gnus-article-internal-prepare-hook nil)
1444 (defvar gnus-newsgroup-name nil)
1445 (defvar gnus-newsgroup-begin nil)
1446 (defvar gnus-newsgroup-end nil)
1447 (defvar gnus-newsgroup-last-rmail nil)
1448 (defvar gnus-newsgroup-last-mail nil)
1449 (defvar gnus-newsgroup-last-folder nil)
1450 (defvar gnus-newsgroup-last-file nil)
1451 (defvar gnus-newsgroup-auto-expire nil)
1452 (defvar gnus-newsgroup-active nil)
1454 (defvar gnus-newsgroup-unreads nil
1455 "List of unread articles in the current newsgroup.")
1457 (defvar gnus-newsgroup-unselected nil
1458 "List of unselected unread articles in the current newsgroup.")
1460 (defvar gnus-newsgroup-reads nil
1461 "Alist of read articles and article marks in the current newsgroup.")
1463 (defvar gnus-newsgroup-marked nil
1464 "List of ticked articles in the current newsgroup (a subset of unread art).")
1466 (defvar gnus-newsgroup-killed nil
1467 "List of ranges of articles that have been through the scoring process.")
1469 (defvar gnus-newsgroup-kill-headers nil)
1471 (defvar gnus-newsgroup-replied nil
1472 "List of articles that have been replied to in the current newsgroup.")
1474 (defvar gnus-newsgroup-expirable nil
1475 "List of articles in the current newsgroup that can be expired.")
1477 (defvar gnus-newsgroup-processable nil
1478 "List of articles in the current newsgroup that can be processed.")
1480 (defvar gnus-newsgroup-bookmarks nil
1481 "List of articles in the current newsgroup that have bookmarks.")
1483 (defvar gnus-newsgroup-dormant nil
1484 "List of dormant articles in the current newsgroup.")
1486 (defvar gnus-newsgroup-scored nil
1487 "List of scored articles in the current newsgroup.")
1489 (defvar gnus-newsgroup-headers nil
1490 "List of article headers in the current newsgroup.")
1491 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1493 (defvar gnus-newsgroup-ancient nil
1494 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1496 (defvar gnus-current-article nil)
1497 (defvar gnus-article-current nil)
1498 (defvar gnus-current-headers nil)
1499 (defvar gnus-have-all-headers nil)
1500 (defvar gnus-last-article nil)
1501 (defvar gnus-newsgroup-history nil)
1502 (defvar gnus-current-kill-article nil)
1504 ;; Save window configuration.
1505 (defvar gnus-prev-winconf nil)
1508 (defvar gnus-summary-line-format-spec nil)
1509 (defvar gnus-summary-dummy-line-format-spec nil)
1510 (defvar gnus-group-line-format-spec nil)
1511 (defvar gnus-summary-mode-line-format-spec nil)
1512 (defvar gnus-article-mode-line-format-spec nil)
1513 (defvar gnus-group-mode-line-format-spec nil)
1514 (defvar gnus-summary-mark-positions nil)
1515 (defvar gnus-group-mark-positions nil)
1517 (defvar gnus-summary-expunge-below nil)
1518 (defvar gnus-reffed-article-number nil)
1520 ; Let the byte-compiler know that we know about this variable.
1521 (defvar rmail-default-rmail-file)
1523 (defvar gnus-cache-removeable-articles nil)
1525 (defconst gnus-summary-local-variables
1526 '(gnus-newsgroup-name
1527 gnus-newsgroup-begin gnus-newsgroup-end
1528 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1529 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1530 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1531 gnus-newsgroup-unselected gnus-newsgroup-marked
1532 gnus-newsgroup-reads
1533 gnus-newsgroup-replied gnus-newsgroup-expirable
1534 gnus-newsgroup-processable gnus-newsgroup-killed
1535 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1536 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1537 gnus-current-article gnus-current-headers gnus-have-all-headers
1538 gnus-last-article gnus-article-internal-prepare-hook
1539 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1540 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1541 gnus-newsgroup-threads gnus-newsgroup-async
1542 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1543 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1544 gnus-newsgroup-history gnus-newsgroup-ancient
1545 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1546 gnus-cache-removeable-articles)
1547 "Variables that are buffer-local to the summary buffers.")
1549 (defconst gnus-bug-message
1550 "Sending a bug report to the Gnus Towers.
1551 ========================================
1553 The buffer below is a mail buffer. When you press `C-c C-c', it will
1554 be sent to the Gnus Bug Exterminators.
1556 At the bottom of the buffer you'll see lots of variable settings.
1557 Please do not delete those. They will tell the Bug People what your
1558 environment is, so that it will be easier to locate the bugs.
1560 If you have found a bug that makes Emacs go \"beep\", set
1561 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1562 and include the backtrace in your bug report.
1564 Please describe the bug in annoying, painstaking detail.
1566 Thank you for your help in stamping out bugs.
1569 ;;; End of variables.
1571 ;; Define some autoload functions Gnus might use.
1575 (autoload 'metamail-buffer "metamail")
1576 (autoload 'Info-goto-node "info")
1577 (autoload 'hexl-hex-string-to-integer "hexl")
1579 (autoload 'pp-to-string "pp")
1580 (autoload 'pp-eval-expression "pp")
1581 (autoload 'mail-extract-address-components "mail-extr")
1583 (autoload 'nnmail-split-fancy "nnmail")
1584 (autoload 'nnvirtual-catchup-group "nnvirtual")
1587 (autoload 'timezone-make-date-arpa-standard "timezone")
1588 (autoload 'timezone-fix-time "timezone")
1589 (autoload 'timezone-make-sortable-date "timezone")
1590 (autoload 'timezone-make-time-string "timezone")
1593 (autoload 'mail-position-on-field "sendmail")
1594 (autoload 'mail-setup "sendmail")
1595 (autoload 'rmail-output "rmailout")
1596 (autoload 'news-mail-other-window "rnewspost")
1597 (autoload 'news-reply-yank-original "rnewspost")
1598 (autoload 'news-caesar-buffer-body "rnewspost")
1599 (autoload 'rmail-insert-rmail-file-header "rmail")
1600 (autoload 'rmail-count-new-messages "rmail")
1601 (autoload 'rmail-show-message "rmail")
1604 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1605 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1606 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1607 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1608 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1609 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1610 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1613 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1614 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1615 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1616 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1617 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1618 (autoload 'gnus-Folder-save-name "gnus-mh")
1619 (autoload 'gnus-folder-save-name "gnus-mh")
1622 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1623 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1624 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1625 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1626 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1627 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1628 (autoload 'gnus-summary-highlight-line "gnus-vis")
1629 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1632 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1633 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1634 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1635 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1636 (autoload 'gnus-article-hide "gnus-vis" nil t)
1637 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1638 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1639 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1640 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1641 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1642 (autoload 'gnus-article-add-button "gnus-vis")
1645 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1646 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1647 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1650 (autoload 'gnus-kill "gnus-kill")
1651 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1652 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1653 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1654 (autoload 'gnus-execute "gnus-kill")
1655 (autoload 'gnus-expunge "gnus-kill")
1658 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1659 (autoload 'gnus-cache-save-buffers "gnus-cache")
1660 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1661 (autoload 'gnus-cache-request-article "gnus-cache")
1662 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1663 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1664 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1665 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1668 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1669 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1670 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1671 (autoload 'gnus-score-save "gnus-score")
1672 (autoload 'gnus-score-headers "gnus-score")
1673 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1674 (autoload 'gnus-score-adaptive "gnus-score")
1675 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1676 (autoload 'gnus-score-find-trace "gnus-score")
1679 (autoload 'gnus-score-customize "gnus-edit" nil t)
1682 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1683 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1684 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1685 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1686 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1687 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1688 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1689 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1690 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1691 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1692 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1693 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1694 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1695 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1696 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1697 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1698 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1699 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1700 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1701 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1702 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1703 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1706 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1707 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1708 (autoload 'gnus-group-mail "gnus-msg" nil t)
1709 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1710 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1711 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1712 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1713 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1714 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1715 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1716 (autoload 'gnus-post-news "gnus-msg" nil t)
1717 (autoload 'gnus-inews-news "gnus-msg" nil t)
1718 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1719 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1720 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1721 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1722 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1723 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1724 (autoload 'gnus-mail-yank-original "gnus-msg")
1725 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1726 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1727 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1728 (autoload 'gnus-article-mail "gnus-msg")
1729 (autoload 'gnus-bug "gnus-msg" nil t)
1732 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1733 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1734 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1735 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1736 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1737 (autoload 'gnus-yank-article "gnus-vm" nil t)
1743 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1744 ;; If you want the cursor to go somewhere else, set these two
1745 ;; functions in some startup hook to whatever you want.
1746 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1747 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1749 ;;; Various macros and substs.
1751 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1752 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1753 (` (let ((GnusStartBufferWindow (selected-window)))
1756 (pop-to-buffer (, buffer))
1758 (select-window GnusStartBufferWindow)))))
1760 (defmacro gnus-gethash (string hashtable)
1761 "Get hash value of STRING in HASHTABLE."
1762 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1763 ;;(` (abbrev-expansion (, string) (, hashtable)))
1764 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1766 (defmacro gnus-sethash (string value hashtable)
1767 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1768 ;; We cannot use define-abbrev since it only accepts string as value.
1769 ;; (set (intern string hashtable) value))
1770 (` (set (intern (, string) (, hashtable)) (, value))))
1772 (defsubst gnus-buffer-substring (beg end)
1773 (buffer-substring (match-beginning beg) (match-end end)))
1775 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1776 ;; function `substring' might cut on a middle of multi-octet
1778 (defun gnus-truncate-string (str width)
1779 (substring str 0 width))
1781 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1782 ;; to limit the length of a string. This function is necessary since
1783 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1784 (defsubst gnus-limit-string (str width)
1785 (if (> (length str) width)
1786 (substring str 0 width)
1789 (defsubst gnus-simplify-subject-re (subject)
1790 "Remove \"Re:\" from subject lines."
1791 (let ((case-fold-search t))
1792 (if (string-match "^re: *" subject)
1793 (substring subject (match-end 0))
1796 (defsubst gnus-goto-char (point)
1797 (and point (goto-char point)))
1799 (defmacro gnus-buffer-exists-p (buffer)
1801 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1804 (defmacro gnus-kill-buffer (buffer)
1805 (` (if (gnus-buffer-exists-p (, buffer))
1806 (kill-buffer (, buffer)))))
1808 (defsubst gnus-point-at-bol ()
1809 "Return point at the beginning of line."
1816 (defsubst gnus-point-at-eol ()
1817 "Return point at the beginning of line."
1824 ;; Delete the current line (and the next N lines.);
1825 (defmacro gnus-delete-line (&optional n)
1826 (` (delete-region (progn (beginning-of-line) (point))
1827 (progn (forward-line (, (or n 1))) (point)))))
1829 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1830 (defvar gnus-init-inhibit nil)
1831 (defun gnus-read-init-file (&optional inhibit-next)
1832 (if gnus-init-inhibit
1833 (setq gnus-init-inhibit nil)
1834 (setq gnus-init-inhibit inhibit-next)
1836 (or (and (file-exists-p gnus-init-file)
1837 ;; Don't try to load a directory.
1838 (not (file-directory-p gnus-init-file)))
1839 (file-exists-p (concat gnus-init-file ".el"))
1840 (file-exists-p (concat gnus-init-file ".elc")))
1841 (load gnus-init-file nil t))))
1843 ;;; Load the user startup file.
1844 ;; (eval '(gnus-read-init-file 'inhibit))
1846 ;;; Load the compatability functions.
1853 ;;; Gnus Utility Functions
1856 (defun gnus-extract-address-components (from)
1858 ;; First find the address - the thing with the @ in it. This may
1859 ;; not be accurate in mail addresses, but does the trick most of
1860 ;; the time in news messages.
1861 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1862 (setq address (substring from (match-beginning 0) (match-end 0))))
1863 ;; Then we check whether the "name <address>" format is used.
1865 (string-match (concat "<" (regexp-quote address) ">") from)
1866 (and (setq name (substring from 0 (1- (match-beginning 0))))
1867 ;; Strip any quotes from the name.
1868 (string-match "\".*\"" name)
1869 (setq name (substring name 1 (1- (match-end 0))))))
1870 ;; If not, then "address (name)" is used.
1872 (and (string-match "(.+)" from)
1873 (setq name (substring from (1+ (match-beginning 0))
1874 (1- (match-end 0)))))
1875 (and (string-match "()" from)
1876 (setq name address))
1877 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1878 ;; XOVER might not support folded From headers.
1879 (and (string-match "(.*" from)
1880 (setq name (substring from (1+ (match-beginning 0))
1882 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1883 (list (or name from) (or address from))))
1885 (defun gnus-fetch-field (field)
1886 "Return the value of the header FIELD of current article."
1889 (let ((case-fold-search t))
1890 (gnus-narrow-to-headers)
1891 (mail-fetch-field field)))))
1893 (defun gnus-goto-colon ()
1895 (search-forward ":" (gnus-point-at-eol) t))
1897 (defun gnus-narrow-to-headers ()
1901 (goto-char (point-min))
1902 (if (search-forward "\n\n" nil t)
1906 (defvar gnus-old-specs nil)
1908 (defun gnus-update-format-specifications ()
1909 (gnus-make-thread-indent-array)
1911 (let ((formats '(summary summary-dummy group
1912 summary-mode group-mode article-mode))
1913 old-format new-format)
1915 (setq new-format (symbol-value
1916 (intern (format "gnus-%s-line-format" (car formats)))))
1917 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1918 (equal old-format new-format))
1919 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1923 (intern (format "gnus-%s-line-format-alist"
1924 (if (eq (car formats) 'article-mode)
1925 'summary-mode (car formats))))))))
1926 (setq gnus-old-specs (cons (cons (car formats) new-format)
1927 (delq (car formats) gnus-old-specs)))
1928 (setq formats (cdr formats))))
1930 (gnus-update-group-mark-positions)
1931 (gnus-update-summary-mark-positions)
1933 (if (and (string-match "%D" gnus-group-line-format)
1934 (not gnus-description-hashtb)
1935 gnus-read-active-file)
1936 (gnus-read-all-descriptions-files)))
1938 (defun gnus-update-summary-mark-positions ()
1940 (let ((gnus-replied-mark 129)
1941 (gnus-score-below-mark 130)
1942 (gnus-score-over-mark 130)
1945 (gnus-set-work-buffer)
1946 (gnus-summary-insert-line
1947 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1948 (goto-char (point-min))
1949 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1951 (goto-char (point-min))
1952 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1953 (- (point) 2))) pos))
1954 (goto-char (point-min))
1955 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1956 (- (point) 2))) pos))
1957 (setq gnus-summary-mark-positions pos))))
1959 (defun gnus-update-group-mark-positions ()
1961 (let ((gnus-process-mark 128)
1962 (gnus-group-marked '("dummy.group")))
1963 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
1964 (gnus-set-work-buffer)
1965 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1966 (goto-char (point-min))
1967 (setq gnus-group-mark-positions
1968 (list (cons 'process (and (search-forward "\200" nil t)
1969 (- (point) 2))))))))
1971 (defun gnus-mouse-face-function (form)
1972 (` (let ((string (, form)))
1973 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1976 (defun gnus-max-width-function (el max-width)
1977 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1978 (` (let* ((val (eval (, el)))
1979 (valstr (if (numberp val)
1980 (int-to-string val) val)))
1981 (if (> (length valstr) (, max-width))
1982 (substring valstr 0 (, max-width))
1985 (defun gnus-parse-format (format spec-alist)
1986 ;; This function parses the FORMAT string with the help of the
1987 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1988 ;; string. If the FORMAT string contains the specifiers %( and %)
1989 ;; the text between them will have the mouse-face text property.
1990 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1991 (if (and gnus-visual gnus-mouse-face)
1992 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1993 (button (substring format (match-beginning 2) (match-end 2)))
1994 (post (substring format (match-beginning 3) (match-end 3))))
1996 (gnus-parse-simple-format pre spec-alist)
1997 (gnus-mouse-face-function
1998 (gnus-parse-simple-format button spec-alist))
1999 (gnus-parse-simple-format post spec-alist)))
2000 (gnus-parse-simple-format
2001 (concat (substring format (match-beginning 1) (match-end 1))
2002 (substring format (match-beginning 2) (match-end 2))
2003 (substring format (match-beginning 3) (match-end 3)))
2005 (gnus-parse-simple-format format spec-alist)))
2007 (defun gnus-parse-simple-format (format spec-alist)
2008 ;; This function parses the FORMAT string with the help of the
2009 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2010 ;; string. The list will consist of the symbol `format', a format
2011 ;; specification string, and a list of forms depending on the
2014 spec flist fstring newspec elem beg)
2016 (gnus-set-work-buffer)
2018 (goto-char (point-min))
2019 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
2020 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2022 ;; First check if there are any specs that look anything like
2023 ;; "%12,12A", ie. with a "max width specification". These have
2024 ;; to be treated specially.
2025 (if (setq beg (match-beginning 1))
2028 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2030 (setq beg (match-beginning 2)))
2031 ;; Find the specification from `spec-alist'.
2032 (if (not (setq elem (cdr (assq spec spec-alist))))
2033 (setq elem '("*" ?s)))
2034 ;; Treat user defined format specifiers specially
2035 (and (eq (car elem) 'user-defined)
2038 (list (intern (concat "gnus-user-format-function-"
2044 (delete-region (match-beginning 3) (match-end 3)))
2045 (if (not (zerop max-width))
2046 (let ((el (car elem)))
2047 (cond ((= (car (cdr elem)) ?c)
2048 (setq el (list 'char-to-string el)))
2049 ((= (car (cdr elem)) ?d)
2050 (numberp el) (setq el (list 'int-to-string el))))
2051 (setq flist (cons (gnus-max-width-function el max-width)
2054 (setq flist (cons (car elem) flist))
2055 (setq newspec (car (cdr elem))))
2056 ;; Remove the old specification (and possibly a ",12" string).
2057 (delete-region beg (match-end 2))
2058 ;; Insert the new specification.
2061 (setq fstring (buffer-substring 1 (point-max))))
2062 (cons 'format (cons fstring (nreverse flist)))))
2064 (defun gnus-set-work-buffer ()
2065 (if (get-buffer gnus-work-buffer)
2067 (set-buffer gnus-work-buffer)
2069 (set-buffer (get-buffer-create gnus-work-buffer))
2070 (kill-all-local-variables)
2071 (buffer-disable-undo (current-buffer))
2072 (gnus-add-current-to-buffer-list)))
2074 ;; Article file names when saving.
2076 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2077 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2078 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2079 Otherwise, it is like ~/News/news/group/num."
2082 (concat (if (gnus-use-long-file-name 'not-save)
2083 (gnus-capitalize-newsgroup newsgroup)
2084 (gnus-newsgroup-directory-form newsgroup))
2085 "/" (int-to-string (mail-header-number headers)))
2086 (or gnus-article-save-directory "~/News"))))
2088 (string-equal (file-name-directory default)
2089 (file-name-directory last-file))
2090 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2092 (or last-file default))))
2094 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2095 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2096 If variable `gnus-use-long-file-name' is non-nil, it is
2097 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2100 (concat (if (gnus-use-long-file-name 'not-save)
2102 (gnus-newsgroup-directory-form newsgroup))
2103 "/" (int-to-string (mail-header-number headers)))
2104 (or gnus-article-save-directory "~/News"))))
2106 (string-equal (file-name-directory default)
2107 (file-name-directory last-file))
2108 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2110 (or last-file default))))
2112 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2113 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2114 If variable `gnus-use-long-file-name' is non-nil, it is
2115 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2118 (if (gnus-use-long-file-name 'not-save)
2119 (gnus-capitalize-newsgroup newsgroup)
2120 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2121 (or gnus-article-save-directory "~/News"))))
2123 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2124 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2125 If variable `gnus-use-long-file-name' is non-nil, it is
2126 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2129 (if (gnus-use-long-file-name 'not-save)
2131 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2132 (or gnus-article-save-directory "~/News"))))
2134 ;; For subscribing new newsgroup
2136 (defun gnus-subscribe-hierarchical-interactive (groups)
2137 (let ((groups (sort groups 'string<))
2138 prefixes prefix start ans group starts)
2140 (setq prefixes (list "^"))
2141 (while (and groups prefixes)
2142 (while (not (string-match (car prefixes) (car groups)))
2143 (setq prefixes (cdr prefixes)))
2144 (setq prefix (car prefixes))
2145 (setq start (1- (length prefix)))
2146 (if (and (string-match "[^\\.]\\." (car groups) start)
2149 (concat "^" (substring (car groups) 0 (match-end 0))))
2150 (string-match prefix (car (cdr groups))))
2152 (setq prefixes (cons prefix prefixes))
2153 (message "Descend hierarchy %s? ([y]nsq): "
2154 (substring prefix 1 (1- (length prefix))))
2155 (setq ans (read-char))
2158 (string-match prefix
2159 (setq group (car groups))))
2160 (setq gnus-killed-list
2161 (cons group gnus-killed-list))
2162 (gnus-sethash group group gnus-killed-hashtb)
2163 (setq groups (cdr groups)))
2164 (setq starts (cdr starts)))
2167 (string-match prefix
2168 (setq group (car groups))))
2169 (gnus-sethash group group gnus-killed-hashtb)
2170 (gnus-subscribe-alphabetically (car groups))
2171 (setq groups (cdr groups)))
2172 (setq starts (cdr starts)))
2175 (setq group (car groups))
2176 (setq gnus-killed-list (cons group gnus-killed-list))
2177 (gnus-sethash group group gnus-killed-hashtb)
2178 (setq groups (cdr groups))))
2180 (message "Subscribe %s? ([n]yq)" (car groups))
2181 (setq ans (read-char))
2182 (setq group (car groups))
2184 (gnus-subscribe-alphabetically (car groups))
2185 (gnus-sethash group group gnus-killed-hashtb))
2188 (setq group (car groups))
2189 (setq gnus-killed-list (cons group gnus-killed-list))
2190 (gnus-sethash group group gnus-killed-hashtb)
2191 (setq groups (cdr groups))))
2193 (setq gnus-killed-list (cons group gnus-killed-list))
2194 (gnus-sethash group group gnus-killed-hashtb)))
2195 (setq groups (cdr groups)))))))
2197 (defun gnus-subscribe-randomly (newsgroup)
2198 "Subscribe new NEWSGROUP by making it the first newsgroup."
2199 (gnus-subscribe-newsgroup newsgroup))
2201 (defun gnus-subscribe-alphabetically (newgroup)
2202 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2203 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2204 (let ((groups (cdr gnus-newsrc-alist))
2206 (while (and (not before) groups)
2207 (if (string< newgroup (car (car groups)))
2208 (setq before (car (car groups)))
2209 (setq groups (cdr groups))))
2210 (gnus-subscribe-newsgroup newgroup before)))
2212 (defun gnus-subscribe-hierarchically (newgroup)
2213 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2214 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2216 (set-buffer (find-file-noselect gnus-current-startup-file))
2217 (let ((groupkey newgroup)
2219 (while (and (not before) groupkey)
2220 (goto-char (point-min))
2222 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2223 (while (and (re-search-forward groupkey-re nil t)
2225 (setq before (buffer-substring
2226 (match-beginning 1) (match-end 1)))
2227 (string< before newgroup)))))
2228 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2230 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2231 (substring groupkey (match-beginning 1) (match-end 1)))))
2232 (gnus-subscribe-newsgroup newgroup before))))
2234 (defun gnus-subscribe-interactively (newsgroup)
2235 "Subscribe new NEWSGROUP interactively.
2236 It is inserted in hierarchical newsgroup order if subscribed. If not,
2238 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2239 (gnus-subscribe-hierarchically newsgroup)
2240 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2242 (defun gnus-subscribe-zombies (newsgroup)
2243 "Make new NEWSGROUP a zombie group."
2244 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2246 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2247 "Subscribe new NEWSGROUP.
2248 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2249 the first newsgroup."
2250 ;; We subscribe the group by changing its level to `subscribed'.
2251 (gnus-group-change-level
2252 newsgroup gnus-level-default-subscribed
2253 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2254 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2258 (defun gnus-newsgroup-directory-form (newsgroup)
2259 "Make hierarchical directory name from NEWSGROUP name."
2260 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2261 (len (length newsgroup))
2263 ;; If this is a foreign group, we don't want to translate the
2265 (if (setq idx (string-match ":" newsgroup))
2266 (aset newsgroup idx ?/)
2268 ;; Replace all occurrences of `.' with `/'.
2270 (if (= (aref newsgroup idx) ?.)
2271 (aset newsgroup idx ?/))
2272 (setq idx (1+ idx)))
2275 (defun gnus-newsgroup-saveable-name (group)
2276 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2278 (gnus-replace-chars-in-string group ?/ ?.))
2280 (defun gnus-make-directory (dir)
2281 "Make DIRECTORY recursively."
2282 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2283 ;; of the many mysteries of the universe.
2284 (let* ((dir (expand-file-name dir default-directory))
2286 (if (string-match "/$" dir)
2287 (setq dir (substring dir 0 (match-beginning 0))))
2288 ;; First go down the path until we find a directory that exists.
2289 (while (not (file-exists-p dir))
2290 (setq dirs (cons dir dirs))
2291 (string-match "/[^/]+$" dir)
2292 (setq dir (substring dir 0 (match-beginning 0))))
2293 ;; Then create all the subdirs.
2294 (while (and dirs (not err))
2296 (make-directory (car dirs))
2297 (error (setq err t)))
2298 (setq dirs (cdr dirs)))
2299 ;; We return whether we were successful or not.
2302 (defun gnus-capitalize-newsgroup (newsgroup)
2303 "Capitalize NEWSGROUP name."
2304 (and (not (zerop (length newsgroup)))
2305 (concat (char-to-string (upcase (aref newsgroup 0)))
2306 (substring newsgroup 1))))
2310 (defun gnus-simplify-subject (subject &optional re-only)
2311 "Remove `Re:' and words in parentheses.
2312 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2313 (let ((case-fold-search t)) ;Ignore case.
2314 ;; Remove `Re:' and `Re^N:'.
2315 (if (string-match "^re:[ \t]*" subject)
2316 (setq subject (substring subject (match-end 0))))
2317 ;; Remove words in parentheses from end.
2319 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2320 (setq subject (substring subject 0 (match-beginning 0)))))
2321 ;; Return subject string.
2324 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2326 (defun gnus-simplify-subject-fuzzy (subject)
2327 (let ((case-fold-search t))
2329 (gnus-set-work-buffer)
2331 (inline (gnus-simplify-buffer-fuzzy))
2334 (defun gnus-simplify-buffer-fuzzy ()
2335 (goto-char (point-min))
2336 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2337 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2339 (replace-match "" t t))
2340 (goto-char (point-min))
2341 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2342 (replace-match "" t t))
2343 (goto-char (point-min))
2344 (while (re-search-forward "[ \t]+" 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 (if gnus-simplify-subject-fuzzy-regexp
2353 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2354 (replace-match "" t t))))
2356 ;; Add the current buffer to the list of buffers to be killed on exit.
2357 (defun gnus-add-current-to-buffer-list ()
2358 (or (memq (current-buffer) gnus-buffer-list)
2359 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2361 (defun gnus-string> (s1 s2)
2362 (not (or (string< s1 s2)
2365 ;; Functions accessing headers.
2366 ;; Functions are more convenient than macros in some cases.
2368 (defun gnus-header-number (header)
2369 (mail-header-number header))
2371 (defun gnus-header-subject (header)
2372 (mail-header-subject header))
2374 (defun gnus-header-from (header)
2375 (mail-header-from header))
2377 (defun gnus-header-xref (header)
2378 (mail-header-xref header))
2380 (defun gnus-header-lines (header)
2381 (mail-header-lines header))
2383 (defun gnus-header-date (header)
2384 (mail-header-date header))
2386 (defun gnus-header-id (header)
2387 (mail-header-id header))
2389 (defun gnus-header-message-id (header)
2390 (mail-header-id header))
2392 (defun gnus-header-chars (header)
2393 (mail-header-chars header))
2395 (defun gnus-header-references (header)
2396 (mail-header-references header))
2398 ;;; General various misc type functions.
2400 (defun gnus-clear-system ()
2401 "Clear all variables and buffers."
2402 ;; Clear Gnus variables.
2403 (let ((variables gnus-variable-list))
2405 (set (car variables) nil)
2406 (setq variables (cdr variables))))
2407 ;; Clear other internal variables.
2408 (setq gnus-list-of-killed-groups nil
2409 gnus-have-read-active-file nil
2410 gnus-newsrc-alist nil
2411 gnus-newsrc-hashtb nil
2412 gnus-killed-list nil
2413 gnus-zombie-list nil
2414 gnus-killed-hashtb nil
2415 gnus-active-hashtb nil
2416 gnus-moderated-list nil
2417 gnus-description-hashtb nil
2418 gnus-newsgroup-headers nil
2419 gnus-newsgroup-headers-hashtb-by-number nil
2420 gnus-newsgroup-name nil
2421 gnus-server-alist nil
2422 gnus-current-select-method nil)
2423 ;; Reset any score variables.
2424 (and (boundp 'gnus-score-cache)
2425 (set 'gnus-score-cache nil))
2426 (and (boundp 'gnus-internal-global-score-files)
2427 (set 'gnus-internal-global-score-files nil))
2428 ;; Kill the startup file.
2429 (and gnus-current-startup-file
2430 (get-file-buffer gnus-current-startup-file)
2431 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2432 ;; Save any cache buffers.
2433 (and gnus-use-cache (gnus-cache-save-buffers))
2434 ;; Clear the dribble buffer.
2435 (gnus-dribble-clear)
2436 ;; Kill global KILL file buffer.
2437 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2438 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2439 (gnus-kill-buffer nntp-server-buffer)
2440 ;; Kill Gnus buffers.
2441 (while gnus-buffer-list
2442 (gnus-kill-buffer (car gnus-buffer-list))
2443 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2445 (defun gnus-windows-old-to-new (setting)
2446 (if (symbolp setting)
2448 (cond ((eq setting 'SelectArticle)
2450 ((eq setting 'SelectSubject)
2452 ((eq setting 'SelectNewsgroup)
2455 (if (or (listp setting)
2456 (not (and gnus-window-configuration
2457 (memq setting '(group summary article)))))
2459 (let* ((setting (if (eq setting 'group)
2460 (if (assq 'newsgroup gnus-window-configuration)
2462 'newsgroups) setting))
2463 (elem (car (cdr (assq setting gnus-window-configuration))))
2464 (total (apply '+ elem))
2465 (types '(group summary article))
2466 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2471 (or (zerop (nth i elem))
2473 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2474 (setq out (cons (if (eq pbuf (nth i types))
2475 (vector (nth i types) perc 'point)
2476 (vector (nth i types) perc))
2479 (list (nreverse out)))))
2481 (defun gnus-add-configuration (conf)
2482 (setq gnus-buffer-configuration
2483 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2484 gnus-buffer-configuration))))
2486 (defun gnus-configure-windows (setting &optional force)
2487 (setq setting (gnus-windows-old-to-new setting))
2488 (let ((r (if (symbolp setting)
2489 (cdr (assq setting gnus-buffer-configuration))
2491 (in-buf (current-buffer))
2492 rule val w height hor ohor heights sub jump-buffer
2493 rel total to-buf all-visible)
2494 (or r (error "No such setting: %s" setting))
2496 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2497 ;; All the windows mentioned are already visible, so we just
2498 ;; put point in the assigned buffer, and do not touch the
2500 (select-window (get-buffer-window all-visible t))
2503 ;; Either remove all windows or just remove all Gnus windows.
2504 (if gnus-use-full-window
2505 (delete-other-windows)
2506 (gnus-remove-some-windows)
2507 (switch-to-buffer nntp-server-buffer))
2513 ;; We have to do the (possible) horizontal splitting before the
2515 (if (and (listp (car hor))
2516 (eq (car (car hor)) 'horizontal))
2520 (if (integerp (nth 1 (car hor)))
2522 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2524 (setq hor (cdr hor))))
2526 ;; Go through the rules and eval the elements that are to be
2529 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2531 ;; Expand short buffer name.
2532 (setq w (aref val 0))
2533 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2535 (setq val (apply 'vector (mapcar 'identity val)))
2537 (setq ohor (cons val ohor))))
2538 (setq hor (cdr hor)))
2539 (setq rule (cons (nreverse ohor) rule))
2541 (setq rule (nreverse rule))
2543 ;; We tally the window sizes.
2544 (setq total (window-height))
2546 (setq hor (car rule))
2547 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2548 (setq hor (cdr hor)))
2551 (setq rel (aref (car hor) 1)
2553 (cond ((and (floatp rel) (= 1.0 rel))
2558 (max (floor (* total rel)) 4)))
2560 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2562 (setq heights (nreverse heights)
2565 ;; We then go through these heighs and create windows for them.
2567 (setq height (car heights)
2568 heights (cdr heights))
2570 (setq height (- total sub)))
2572 (split-window nil height))
2573 (setq to-buf (aref (car hor) 0))
2578 (symbol-value (aref (car hor) 0)))
2580 (aref (car hor) 0))))
2581 (and (> (length (car hor)) 2)
2582 (eq (aref (car hor) 2) 'point)
2583 (setq jump-buffer (current-buffer)))
2585 (setq hor (cdr hor)))
2587 (setq rule (cdr rule)))
2589 ;; Finally, we pop to the buffer that's supposed to have point.
2590 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2592 (select-window (get-buffer-window jump-buffer t))
2593 (set-buffer jump-buffer))))
2595 (defun gnus-all-windows-visible-p (rule)
2596 (let (invisible hor jump-buffer val buffer)
2597 ;; Go through the rules and eval the elements that are to be
2599 (while (and rule (not invisible))
2600 (setq hor (car rule)
2602 (while (and hor (not invisible))
2603 (if (setq val (if (vectorp (car hor))
2605 (if (not (eq (car (car hor)) 'horizontal))
2608 ;; Expand short buffer name.
2609 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2611 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2613 (and (> (length val) 2) (eq 'point (aref val 2))
2614 (setq jump-buffer buffer))
2615 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2616 (setq hor (cdr hor))))
2617 (and (not invisible) jump-buffer)))
2619 (defun gnus-window-top-edge (&optional window)
2620 (nth 1 (window-edges window)))
2622 (defun gnus-remove-some-windows ()
2623 (let ((buffers gnus-window-to-buffer)
2624 buf bufs lowest-buf lowest)
2626 ;; Remove windows on all known Gnus buffers.
2628 (setq buf (cdr (car buffers)))
2630 (setq buf (and (boundp buf) (symbol-value buf))))
2632 (get-buffer-window buf)
2634 (setq bufs (cons buf bufs))
2636 (if (or (not lowest)
2637 (< (gnus-window-top-edge) lowest))
2639 (setq lowest (gnus-window-top-edge))
2640 (setq lowest-buf buf)))))
2641 (setq buffers (cdr buffers)))
2642 ;; Remove windows on *all* summary buffers.
2646 (let ((buf (window-buffer win)))
2647 (if (string-match "^\\*Summary" (buffer-name buf))
2649 (setq bufs (cons buf bufs))
2651 (if (or (not lowest)
2652 (< (gnus-window-top-edge) lowest))
2654 (setq lowest-buf buf)
2655 (setq lowest (gnus-window-top-edge))))))))))
2658 (pop-to-buffer lowest-buf)
2659 (switch-to-buffer nntp-server-buffer)))
2661 (and (not (eq (car bufs) lowest-buf))
2662 (delete-windows-on (car bufs)))
2663 (setq bufs (cdr bufs))))))
2665 (defun gnus-version ()
2666 "Version numbers of this version of Gnus."
2668 (let ((methods gnus-valid-select-methods)
2671 ;; Go through all the legal select methods and add their version
2672 ;; numbers to the total version string. Only the backends that are
2673 ;; currently in use will have their message numbers taken into
2676 (setq meth (intern (concat (car (car methods)) "-version")))
2678 (stringp (symbol-value meth))
2679 (setq mess (concat mess "; " (symbol-value meth))))
2680 (setq methods (cdr methods)))
2681 (gnus-message 2 mess)))
2683 (defun gnus-info-find-node ()
2684 "Find Info documentation of Gnus."
2686 ;; Enlarge info window if needed.
2687 (let ((mode major-mode))
2688 (gnus-configure-windows 'info)
2689 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2691 (defun gnus-overload-functions (&optional overloads)
2692 "Overload functions specified by optional argument OVERLOADS.
2693 If nothing is specified, use the variable gnus-overload-functions."
2695 (overloads (or overloads gnus-overload-functions)))
2697 (setq defs (car overloads))
2698 (setq overloads (cdr overloads))
2699 ;; Load file before overloading function if necessary. Make
2700 ;; sure we cannot use `require' always.
2701 (and (not (fboundp (car defs)))
2702 (car (cdr (cdr defs)))
2703 (load (car (cdr (cdr defs))) nil 'nomessage))
2704 (fset (car defs) (car (cdr defs))))))
2706 (defun gnus-replace-chars-in-string (string &rest pairs)
2707 "Replace characters in STRING from FROM to TO."
2708 (let ((string (substring string 0)) ;Copy string.
2709 (len (length string))
2712 (or (zerop (% (length pairs) 2))
2713 (error "Odd number of translation pairs"))
2714 (setplist 'sym pairs)
2715 ;; Replace all occurrences of FROM with TO.
2717 (if (setq to (get 'sym (aref string idx)))
2718 (aset string idx to))
2719 (setq idx (1+ idx)))
2722 (defun gnus-days-between (date1 date2)
2723 ;; Return the number of days between date1 and date2.
2724 (- (gnus-day-number date1) (gnus-day-number date2)))
2726 (defun gnus-day-number (date)
2727 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2728 (timezone-parse-date date))))
2729 (timezone-absolute-from-gregorian
2730 (nth 1 dat) (nth 2 dat) (car dat))))
2732 ;; Returns a floating point number that says how many seconds have
2733 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2734 (defun gnus-seconds-since-epoch (date)
2735 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2736 (timezone-parse-date date)))
2737 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2738 (timezone-parse-time
2739 (aref (timezone-parse-date date) 3))))
2740 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2741 (timezone-parse-date "Jan 1 12:00:00 1970")))
2742 (tday (- (timezone-absolute-from-gregorian
2743 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2744 (timezone-absolute-from-gregorian
2745 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2747 (* (nth 1 ttime) 60)
2748 (* 1.0 (nth 0 ttime) 60 60)
2749 (* 1.0 tday 60 60 24))))
2751 (defun gnus-file-newer-than (file date)
2752 (let ((fdate (nth 5 (file-attributes file))))
2753 (or (> (car fdate) (car date))
2754 (and (= (car fdate) (car date))
2755 (> (nth 1 fdate) (nth 1 date))))))
2757 (defun gnus-group-read-only-p (&optional group)
2758 "Check whether GROUP supports editing or not.
2759 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
2760 that that variable is buffer-local to the summary buffers."
2761 (let ((group (or group gnus-newsgroup-name)))
2762 (not (gnus-check-backend-function 'request-replace-article group))))
2764 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2766 (defun gnus-y-or-n-p (prompt)
2771 (defun gnus-yes-or-no-p (prompt)
2773 (yes-or-no-p prompt)
2776 ;; Check whether to use long file names.
2777 (defun gnus-use-long-file-name (symbol)
2778 ;; The variable has to be set...
2779 (and gnus-use-long-file-name
2780 ;; If it isn't a list, then we return t.
2781 (or (not (listp gnus-use-long-file-name))
2782 ;; If it is a list, and the list contains `symbol', we
2784 (not (memq symbol gnus-use-long-file-name)))))
2786 ;; I suspect there's a better way, but I haven't taken the time to do
2787 ;; it yet. -erik selberg@cs.washington.edu
2788 (defun gnus-dd-mmm (messy-date)
2789 "Return a string like DD-MMM from a big messy string"
2790 (let ((datevec (timezone-parse-date messy-date)))
2792 (or (aref datevec 2) "??")
2795 (nth (1- (string-to-number (aref datevec 1)))
2796 timezone-months-assoc))
2799 ;; Make a hash table (default and minimum size is 255).
2800 ;; Optional argument HASHSIZE specifies the table size.
2801 (defun gnus-make-hashtable (&optional hashsize)
2802 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2804 ;; Make a number that is suitable for hashing; bigger than MIN and one
2806 (defun gnus-create-hash-size (min)
2812 ;; Show message if message has a lower level than `gnus-verbose'.
2813 ;; Guide-line for numbers:
2814 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2815 ;; for things that take a long time, 7 - not very important messages
2816 ;; on stuff, 9 - messages inside loops.
2817 (defun gnus-message (level &rest args)
2818 (if (<= level gnus-verbose)
2819 (apply 'message args)
2820 ;; We have to do this format thingie here even if the result isn't
2821 ;; shown - the return value has to be the same as the return value
2823 (apply 'format args)))
2825 ;; Generate a unique new group name.
2826 (defun gnus-generate-new-group-name (leaf)
2829 (while (gnus-gethash name gnus-newsrc-hashtb)
2830 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2833 ;;; List and range functions
2835 (defun gnus-last-element (list)
2836 "Return last element of LIST."
2838 (setq list (cdr list)))
2841 (defun gnus-copy-sequence (list)
2842 "Do a complete, total copy of a list."
2843 (if (and (consp list) (not (consp (cdr list))))
2844 (cons (car list) (cdr list))
2845 (mapcar (lambda (elem) (if (consp elem)
2846 (if (consp (cdr elem))
2847 (gnus-copy-sequence elem)
2848 (cons (car elem) (cdr elem)))
2852 (defun gnus-set-difference (list1 list2)
2853 "Return a list of elements of LIST1 that do not appear in LIST2."
2854 (let ((list1 (copy-sequence list1)))
2856 (setq list1 (delq (car list2) list1))
2857 (setq list2 (cdr list2)))
2860 (defun gnus-sorted-complement (list1 list2)
2861 "Return a list of elements of LIST1 that do not appear in LIST2.
2862 Both lists have to be sorted over <."
2864 (if (or (null list1) (null list2))
2866 (while (and list1 list2)
2867 (cond ((= (car list1) (car list2))
2868 (setq list1 (cdr list1)
2870 ((< (car list1) (car list2))
2871 (setq out (cons (car list1) out))
2872 (setq list1 (cdr list1)))
2874 (setq out (cons (car list2) out))
2875 (setq list2 (cdr list2)))))
2876 (nconc (nreverse out) (or list1 list2)))))
2878 (defun gnus-intersection (list1 list2)
2881 (if (memq (car list2) list1)
2882 (setq result (cons (car list2) result)))
2883 (setq list2 (cdr list2)))
2886 (defun gnus-sorted-intersection (list1 list2)
2887 ;; LIST1 and LIST2 have to be sorted over <.
2889 (while (and list1 list2)
2890 (cond ((= (car list1) (car list2))
2891 (setq out (cons (car list1) out)
2894 ((< (car list1) (car list2))
2895 (setq list1 (cdr list1)))
2897 (setq list2 (cdr list2)))))
2900 (defun gnus-set-sorted-intersection (list1 list2)
2901 ;; LIST1 and LIST2 have to be sorted over <.
2902 ;; This function modifies LIST1.
2903 (let* ((top (cons nil list1))
2905 (while (and list1 list2)
2906 (cond ((= (car list1) (car list2))
2910 ((< (car list1) (car list2))
2911 (setcdr prev (cdr list1))
2912 (setq list1 (cdr list1)))
2914 (setq list2 (cdr list2)))))
2918 (defun gnus-compress-sequence (numbers &optional always-list)
2919 "Convert list of numbers to a list of ranges or a single range.
2920 If ALWAYS-LIST is non-nil, this function will always release a list of
2922 (let* ((first (car numbers))
2923 (last (car numbers))
2927 (if (not (listp (cdr numbers)))
2930 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2931 ((= (1+ last) (car numbers)) ;Still in sequence
2932 (setq last (car numbers)))
2933 (t ;End of one sequence
2935 (cons (if (= first last) first
2936 (cons first last)) result))
2937 (setq first (car numbers))
2938 (setq last (car numbers))))
2939 (setq numbers (cdr numbers)))
2940 (if (and (not always-list) (null result))
2941 (if (= first last) (list first) (cons first last))
2942 (nreverse (cons (if (= first last) first (cons first last))
2945 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2946 (defun gnus-uncompress-range (ranges)
2947 "Expand a list of ranges into a list of numbers.
2948 RANGES is either a single range on the form `(num . num)' or a list of
2950 (let (first last result)
2954 ((not (listp (cdr ranges)))
2955 (setq first (car ranges))
2956 (setq last (cdr ranges))
2957 (while (<= first last)
2958 (setq result (cons first result))
2959 (setq first (1+ first)))
2963 (if (atom (car ranges))
2964 (if (numberp (car ranges))
2965 (setq result (cons (car ranges) result)))
2966 (setq first (car (car ranges)))
2967 (setq last (cdr (car ranges)))
2968 (while (<= first last)
2969 (setq result (cons first result))
2970 (setq first (1+ first))))
2971 (setq ranges (cdr ranges)))
2972 (nreverse result)))))
2974 (defun gnus-add-to-range (ranges list)
2975 "Return a list of ranges that has all articles from both RANGES and LIST.
2976 Note: LIST has to be sorted over `<'."
2978 (gnus-compress-sequence list t)
2979 (setq list (copy-sequence list))
2980 (or (listp (cdr ranges))
2981 (setq ranges (list ranges)))
2983 ilist lowest highest temp)
2984 (while (and ranges list)
2986 (setq lowest (or (and (atom (car ranges)) (car ranges))
2987 (car (car ranges))))
2988 (while (and list (cdr list) (< (car (cdr list)) lowest))
2989 (setq list (cdr list)))
2990 (if (< (car ilist) lowest)
2993 (setq list (cdr list))
2995 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2996 (setq highest (or (and (atom (car ranges)) (car ranges))
2997 (cdr (car ranges))))
2998 (while (and list (<= (car list) highest))
2999 (setq list (cdr list)))
3000 (setq ranges (cdr ranges)))
3002 (setq out (nconc (gnus-compress-sequence list t) out)))
3003 (setq out (sort out (lambda (r1 r2)
3004 (< (or (and (atom r1) r1) (car r1))
3005 (or (and (atom r2) r2) (car r2))))))
3008 (if (atom (car ranges))
3010 (if (atom (car (cdr ranges)))
3011 (if (= (1+ (car ranges)) (car (cdr ranges)))
3013 (setcar ranges (cons (car ranges)
3014 (car (cdr ranges))))
3015 (setcdr ranges (cdr (cdr ranges)))))
3016 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3018 (setcar (car (cdr ranges)) (car ranges))
3019 (setcar ranges (car (cdr ranges)))
3020 (setcdr ranges (cdr (cdr ranges)))))))
3022 (if (atom (car (cdr ranges)))
3023 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3025 (setcdr (car ranges) (car (cdr ranges)))
3026 (setcdr ranges (cdr (cdr ranges)))))
3027 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3029 (setcdr (car ranges) (cdr (car (cdr ranges))))
3030 (setcdr ranges (cdr (cdr ranges))))))))
3031 (setq ranges (cdr ranges)))
3034 (defun gnus-remove-from-range (ranges list)
3035 "Return a list of ranges that has all articles from LIST removed from RANGES.
3036 Note: LIST has to be sorted over `<'."
3037 ;; !!! This function shouldn't look like this, but I've got a headache.
3038 (gnus-compress-sequence
3039 (gnus-sorted-complement
3040 (gnus-uncompress-range ranges) list)))
3042 (defun gnus-member-of-range (number ranges)
3043 (if (not (listp (cdr ranges)))
3044 (and (>= number (car ranges))
3045 (<= number (cdr ranges)))
3048 (if (numberp (car ranges))
3049 (>= number (car ranges))
3050 (>= number (car (car ranges))))
3052 (if (if (numberp (car ranges))
3053 (= number (car ranges))
3054 (and (>= number (car (car ranges)))
3055 (<= number (cdr (car ranges)))))
3056 (setq not-stop nil))
3057 (setq ranges (cdr ranges)))
3065 (defvar gnus-group-mode-map nil)
3066 (defvar gnus-group-group-map nil)
3067 (defvar gnus-group-mark-map nil)
3068 (defvar gnus-group-list-map nil)
3069 (defvar gnus-group-sub-map nil)
3070 (put 'gnus-group-mode 'mode-class 'special)
3072 (if gnus-group-mode-map
3074 (setq gnus-group-mode-map (make-keymap))
3075 (suppress-keymap gnus-group-mode-map)
3076 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3077 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3078 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3079 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3080 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3081 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3082 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3083 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3084 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3085 (define-key gnus-group-mode-map
3086 "\M-n" 'gnus-group-next-unread-group-same-level)
3087 (define-key gnus-group-mode-map
3088 "\M-p" 'gnus-group-prev-unread-group-same-level)
3089 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3090 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3091 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3092 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3093 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3094 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3095 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3096 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3097 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3098 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3099 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3100 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3101 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3102 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3103 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3104 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3105 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3106 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3107 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3108 (define-key gnus-group-mode-map "\C-c\M-\C-a" 'gnus-group-description-apropos)
3109 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3110 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3111 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3112 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3113 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3114 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3115 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3116 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3117 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3118 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3119 (define-key gnus-group-mode-map "V" 'gnus-version)
3120 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3121 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3122 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3123 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3124 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3125 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3126 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3127 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3128 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3129 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3130 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3131 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3132 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3133 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3134 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3136 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3137 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3138 (define-prefix-command 'gnus-group-mark-map)
3139 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3140 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3141 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3142 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3144 (define-prefix-command 'gnus-group-group-map)
3145 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3146 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3147 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3148 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3149 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3150 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3151 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3152 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3153 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3154 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3155 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3156 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3157 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3158 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3159 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3160 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3161 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3162 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3164 (define-prefix-command 'gnus-group-list-map)
3165 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3166 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3167 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3168 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3169 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3170 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3171 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3172 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3173 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3175 (define-prefix-command 'gnus-group-sub-map)
3176 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3177 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3178 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3179 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3180 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3181 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3182 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3183 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3185 (defun gnus-group-mode ()
3186 "Major mode for reading news.
3188 All normal editing commands are switched off.
3189 \\<gnus-group-mode-map>
3190 The group buffer lists (some of) the groups available. For instance,
3191 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3192 lists all zombie groups.
3194 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3195 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3197 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3199 The following commands are available:
3201 \\{gnus-group-mode-map}"
3203 (if gnus-visual (gnus-group-make-menu-bar))
3204 (kill-all-local-variables)
3205 (setq mode-line-modified "-- ")
3206 (make-local-variable 'mode-line-format)
3207 (setq mode-line-format (copy-sequence mode-line-format))
3208 (and (equal (nth 3 mode-line-format) " ")
3209 (setcar (nthcdr 3 mode-line-format) ""))
3210 (setq major-mode 'gnus-group-mode)
3211 (setq mode-name "Group")
3212 (gnus-group-set-mode-line)
3213 (setq mode-line-process nil)
3214 (use-local-map gnus-group-mode-map)
3215 (buffer-disable-undo (current-buffer))
3216 (setq truncate-lines t)
3217 (setq buffer-read-only t)
3218 (run-hooks 'gnus-group-mode-hook))
3220 (defun gnus-mouse-pick-group (e)
3223 (gnus-group-read-group nil))
3225 ;; Look at LEVEL and find out what the level is really supposed to be.
3226 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3227 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3228 (defun gnus-group-default-level (&optional level number-or-nil)
3230 (gnus-group-use-permanent-levels
3231 (setq gnus-group-default-list-level
3232 (or level gnus-group-default-list-level))
3233 (or gnus-group-default-list-level gnus-level-subscribed))
3237 (or level gnus-group-default-list-level gnus-level-subscribed))))
3240 (defvar gnus-tmp-prev-perm nil)
3243 (defun gnus-no-server (&optional arg)
3245 If ARG is a positive number, Gnus will use that as the
3246 startup level. If ARG is nil, Gnus will be started at level 2.
3247 If ARG is non-nil and not a positive number, Gnus will
3248 prompt the user for the name of an NNTP server to use.
3249 As opposed to `gnus', this command will not connect to the local server."
3252 (cons gnus-group-use-permanent-levels gnus-group-default-list-level)))
3253 (setq gnus-tmp-prev-perm nil)
3254 (setq gnus-group-use-permanent-levels t)
3255 (gnus (or arg (1- gnus-level-default-subscribed)) t)
3256 (setq gnus-tmp-prev-perm perm)))
3259 (defun gnus (&optional arg dont-connect)
3261 If ARG is non-nil and a positive number, Gnus will use that as the
3262 startup level. If ARG is non-nil and not a positive number, Gnus will
3263 prompt the user for the name of an NNTP server to use."
3265 (if (get-buffer gnus-group-buffer)
3267 (switch-to-buffer gnus-group-buffer)
3268 (gnus-group-get-new-news))
3272 (nnheader-init-server-buffer)
3273 ;; We do this if `gnus-no-server' has been run.
3274 (if gnus-tmp-prev-perm
3275 (setq gnus-group-use-permanent-levels (car gnus-tmp-prev-perm)
3276 gnus-group-default-list-level (cdr gnus-tmp-prev-perm)
3277 gnus-tmp-prev-perm nil))
3278 (gnus-read-init-file)
3280 (gnus-group-setup-buffer)
3281 (let ((buffer-read-only nil))
3283 (if (not gnus-inhibit-startup-message)
3285 (gnus-group-startup-message)
3288 (let ((level (and arg (numberp arg) (> arg 0) arg))
3294 (gnus-start-news-server (and arg (not level))))))
3295 (if (and (not dont-connect)
3298 (run-hooks 'gnus-startup-hook)
3299 ;; NNTP server is successfully open.
3301 ;; Find the current startup file name.
3302 (setq gnus-current-startup-file
3303 (gnus-make-newsrc-file gnus-startup-file))
3305 ;; Read the dribble file.
3306 (and gnus-use-dribble-file (gnus-dribble-read-file))
3308 (gnus-summary-make-display-table)
3309 (gnus-setup-news nil level)
3310 (gnus-group-list-groups level)
3311 (gnus-configure-windows 'group))))))
3313 (defun gnus-unload ()
3314 "Unload all Gnus features."
3316 (or (boundp 'load-history)
3317 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3318 (let ((history load-history)
3321 (and (string-match "^gnus" (car (car history)))
3322 (setq feature (cdr (assq 'provide (car history))))
3323 (unload-feature feature 'force))
3324 (setq history (cdr history)))))
3326 (defun gnus-group-startup-message (&optional x y)
3327 "Insert startup message in current buffer."
3328 ;; Insert the message.
3333 _ ___ __ ___ __ _ ___
3351 Gnus * A newsreader for Emacsen
3352 A Praxis release * larsi@ifi.uio.no
3355 ;; And then hack it.
3356 ;; 18 is the longest line.
3357 (indent-rigidly (point-min) (point-max)
3358 (/ (max (- (window-width) (or x 46)) 0) 2))
3359 (goto-char (point-min))
3360 (let* ((pheight (count-lines (point-min) (point-max)))
3361 (wheight (window-height))
3362 (rest (- wheight pheight)))
3363 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3368 (goto-char (point-min))
3369 (search-forward "Praxis")
3370 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3371 (goto-char (point-min)))
3373 (defun gnus-group-startup-message-old (&optional x y)
3374 "Insert startup message in current buffer."
3375 ;; Insert the message.
3391 ;; And then hack it.
3392 ;; 18 is the longest line.
3393 (indent-rigidly (point-min) (point-max)
3394 (/ (max (- (window-width) (or x 28)) 0) 2))
3395 (goto-char (point-min))
3396 ;; +4 is fuzzy factor.
3397 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3400 (goto-char (point-min))
3401 (search-forward "Praxis")
3402 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3403 (goto-char (point-min)))
3405 (defun gnus-group-setup-buffer ()
3406 (or (get-buffer gnus-group-buffer)
3408 (switch-to-buffer gnus-group-buffer)
3409 (gnus-add-current-to-buffer-list)
3411 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3413 (defun gnus-group-list-groups (&optional level unread)
3414 "List newsgroups with level LEVEL or lower that have unread articles.
3415 Default is all subscribed groups.
3416 If argument UNREAD is non-nil, groups with no unread articles are also
3418 (interactive (list (if current-prefix-arg
3419 (prefix-numeric-value current-prefix-arg)
3421 (gnus-group-default-level nil t)
3422 gnus-group-default-list-level
3423 gnus-level-subscribed))))
3425 (setq level (car gnus-group-list-mode)
3426 unread (cdr gnus-group-list-mode)))
3427 (setq level (gnus-group-default-level level))
3428 (gnus-group-setup-buffer) ;May call from out of group buffer
3429 (let ((case-fold-search nil)
3430 (group (gnus-group-group-name)))
3431 (funcall gnus-group-prepare-function level unread nil)
3432 (if (zerop (buffer-size))
3433 (gnus-message 5 gnus-no-groups-message)
3434 (goto-char (point-min))
3436 ;; Go to the first group with unread articles.
3437 (gnus-group-search-forward nil nil nil t)
3438 ;; Find the right group to put point on. If the current group
3439 ;; has disapeared in the new listing, try to find the next
3440 ;; one. If no next one can be found, just leave point at the
3441 ;; first newsgroup in the buffer.
3442 (if (not (gnus-goto-char
3443 (text-property-any (point-min) (point-max)
3444 'gnus-group (intern group))))
3445 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3447 (not (gnus-goto-char
3449 (point-min) (point-max) 'gnus-group
3450 (intern (car (car newsrc)))))))
3451 (setq newsrc (cdr newsrc)))
3452 (or newsrc (progn (goto-char (point-max))
3453 (forward-line -1))))))
3454 ;; Adjust cursor point.
3455 (gnus-group-position-cursor))))
3457 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3458 "List all newsgroups with unread articles of level LEVEL or lower.
3459 If ALL is non-nil, list groups that have no unread articles.
3460 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3461 If REGEXP, only list groups matching REGEXP."
3462 (set-buffer gnus-group-buffer)
3463 (let ((buffer-read-only nil)
3464 (newsrc (cdr gnus-newsrc-alist))
3465 (lowest (or lowest 1))
3466 info clevel unread group)
3468 (if (< lowest gnus-level-zombie)
3469 ;; List living groups.
3471 (setq info (car newsrc)
3474 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3475 (and unread ; This group might be bogus
3477 (string-match regexp group))
3478 (<= (setq clevel (car (cdr info))) level)
3480 (or all ; We list all groups?
3481 (eq unread t) ; We list unactivated groups
3482 (> unread 0) ; We list groups with unread articles
3483 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3484 (gnus-group-insert-group-line
3485 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3487 ;; List dead groups.
3488 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3489 (gnus-group-prepare-flat-list-dead
3490 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3491 gnus-level-zombie ?Z
3493 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3494 (gnus-group-prepare-flat-list-dead
3495 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3496 gnus-level-killed ?K regexp))
3498 (gnus-group-set-mode-line)
3499 (setq gnus-group-list-mode (cons level all))
3500 (run-hooks 'gnus-group-prepare-hook)))
3502 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3503 ;; List zombies and killed lists somehwat faster, which was
3504 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3505 ;; this by ignoring the group format specification altogether.
3508 (setq group (car groups)
3509 groups (cdr groups))
3510 (if (or (not regexp)
3511 (string-match regexp group))
3514 (insert (format " %c *: %s\n" mark group))
3515 (add-text-properties
3517 (list 'gnus-group (intern group)
3519 'gnus-level level)))))))
3521 (defun gnus-group-real-name (group)
3522 "Find the real name of a foreign newsgroup."
3523 (if (string-match ":[^:]+$" group)
3524 (substring group (1+ (match-beginning 0)))
3527 (defun gnus-group-prefixed-name (group method)
3528 "Return the whole name from GROUP and METHOD."
3529 (and (stringp method) (setq method (gnus-server-to-method method)))
3530 (concat (format "%s" (car method))
3532 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3533 (not (string= (nth 1 method) "")))
3534 (concat "+" (nth 1 method)))
3537 (defun gnus-group-real-prefix (group)
3538 "Return the prefix of the current group name."
3539 (if (string-match "^[^:]+:" group)
3540 (substring group 0 (match-end 0))
3543 (defun gnus-group-method-name (group)
3544 "Return the method used for selecting GROUP."
3545 (let ((prefix (gnus-group-real-prefix group)))
3546 (if (equal prefix "")
3548 (if (string-match "^[^\\+]+\\+" prefix)
3549 (list (intern (substring prefix 0 (1- (match-end 0))))
3550 (substring prefix (match-end 0) (1- (length prefix))))
3551 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3553 (defun gnus-group-foreign-p (group)
3554 "Return nil if GROUP is native, non-nil if it is foreign."
3555 (string-match ":" group))
3557 (defun gnus-group-set-info (info &optional method-only-group part)
3558 (let* ((entry (gnus-gethash
3559 (or method-only-group (car info)) gnus-newsrc-hashtb))
3561 (info (if method-only-group (nth 2 entry) info)))
3562 (if (not method-only-group)
3565 (error "Trying to change non-existent group %s" method-only-group))
3566 ;; We have recevied parts of the actual group info - either the
3567 ;; select method or the group parameters. We first check
3568 ;; whether we have to extend the info, and if so, do that.
3569 (let ((len (length info))
3570 (total (if (eq part 'method) 5 6)))
3572 (setcdr (nthcdr (1- len) info)
3573 (make-list (- total len) nil)))
3574 ;; Then we enter the new info.
3575 (setcar (nthcdr (1- total) info) part-info)))
3576 ;; We uncompress some lists of marked articles.
3578 (if (not (setq marked (nth 3 info)))
3581 (or (eq 'score (car (car marked)))
3582 (eq 'bookmark (car (car marked)))
3583 (eq 'killed (car (car marked)))
3584 (setcdr (car marked)
3585 (gnus-uncompress-range (cdr (car marked)))))
3586 (setq marked (cdr marked)))))
3589 ;; This is a new group, so we just create it.
3591 (set-buffer gnus-group-buffer)
3593 ;; It's a foreign group...
3594 (gnus-group-make-group
3595 (gnus-group-real-name (car info))
3596 (prin1-to-string (car (nth 4 info)))
3597 (nth 1 (nth 4 info)))
3598 ;; It's a native group.
3599 (gnus-group-make-group (car info)))
3600 (gnus-message 6 "Note: New group created")
3602 (gnus-gethash (gnus-group-prefixed-name
3603 (gnus-group-real-name (car info))
3604 (or (nth 4 info) gnus-select-method))
3605 gnus-newsrc-hashtb))))
3606 ;; Whether it was a new group or not, we now have the entry, so we
3607 ;; can do the update.
3610 (setcar (nthcdr 2 entry) info)
3611 (if (and (not (eq (car entry) t))
3612 (gnus-gethash (car info) gnus-active-hashtb))
3613 (let ((marked (nth 3 info)))
3615 (max 0 (- (length (gnus-list-of-unread-articles
3617 (length (cdr (assq 'tick marked)))
3618 (length (cdr (assq 'dormant marked)))))))))
3619 (error "No such group: %s" (car info)))))
3621 (defun gnus-group-set-method-info (group select-method)
3622 (gnus-group-set-info select-method group 'method))
3624 (defun gnus-group-set-params-info (group params)
3625 (gnus-group-set-info params group 'params))
3627 (defun gnus-group-update-group-line ()
3628 "This function updates the current line in the newsgroup buffer and
3629 moves the point to the colon."
3630 (let* ((buffer-read-only nil)
3631 (group (gnus-group-group-name))
3632 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3635 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3638 (delete-region (point) (progn (forward-line 1) (point)))
3639 (gnus-group-insert-group-line-info group)
3641 (gnus-group-position-cursor)))
3643 (defun gnus-group-insert-group-line-info (group)
3644 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3648 (setq info (nth 2 entry))
3649 (gnus-group-insert-group-line
3650 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3651 (setq active (gnus-gethash group gnus-active-hashtb))
3652 (gnus-group-insert-group-line
3654 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3655 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3657 (defun gnus-group-insert-group-line (gformat group level marked number method)
3658 (let* ((gformat (or gformat gnus-group-line-format-spec))
3659 (active (gnus-gethash group gnus-active-hashtb))
3660 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3661 (number-of-dormant (length (cdr (assq 'dormant marked))))
3662 (number-of-ticked (length (cdr (assq 'tick marked))))
3663 (number-of-ticked-and-dormant
3664 (+ number-of-ticked number-of-dormant))
3665 (number-of-unread-unticked
3666 (if (numberp number) (int-to-string (max 0 number))
3669 (if (numberp number)
3670 (max 0 (- number-total number))
3672 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3673 ((<= level gnus-level-unsubscribed) ?U)
3674 ((= level gnus-level-zombie) ?Z)
3676 (qualified-group (gnus-group-real-name group))
3677 (newsgroup-description
3678 (if gnus-description-hashtb
3679 (or (gnus-gethash group gnus-description-hashtb) "")
3681 (moderated (if (member group gnus-moderated-list) ?m ? ))
3682 (moderated-string (if (eq moderated ?m) "(m)" ""))
3683 (method (gnus-server-get-method group method))
3684 (news-server (or (car (cdr method)) ""))
3685 (news-method (or (car method) ""))
3687 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3691 (> number-of-ticked 0))
3693 (number (if (eq number t) "*" (+ number number-of-dormant
3695 (process-marked (if (member group gnus-group-marked)
3696 gnus-process-mark ? ))
3697 (buffer-read-only nil)
3698 header ; passed as parameter to user-funcs.
3703 (insert (eval gformat))
3705 (add-text-properties
3706 b (1+ b) (list 'gnus-group (intern group)
3707 'gnus-unread (if (numberp number)
3708 (string-to-int number-of-unread-unticked)
3711 'gnus-level level))))
3713 (defun gnus-group-update-group (group &optional visible-only)
3714 "Update newsgroup info of GROUP.
3715 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3717 (set-buffer gnus-group-buffer)
3718 (let ((buffer-read-only nil)
3720 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3723 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3725 ;; Buffer may be narrowed.
3728 ;; Search a line to modify. If the buffer is large, the search
3729 ;; takes long time. In most cases, current point is on the line
3730 ;; we are looking for. So, first of all, check current line.
3733 (eq (get-text-property (point) 'gnus-group)
3738 (point-min) (point-max) 'gnus-group (intern group)))))
3739 ;; GROUP is listed in current buffer. So, delete old line.
3743 (delete-region (point) (progn (forward-line 1) (point))))
3744 ;; No such line in the buffer, find out where it's supposed to
3745 ;; go, and insert it there (or at the end of the buffer).
3746 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3749 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3755 (point-min) (point-max)
3756 'gnus-group (intern (car (car entry)))))))
3757 (setq entry (cdr entry)))
3758 (or entry (goto-char (point-max)))))))
3759 (if (or visible (not visible-only))
3760 (gnus-group-insert-group-line-info group))
3761 (gnus-group-set-mode-line))))
3763 (defun gnus-group-set-mode-line ()
3764 (if (memq 'group gnus-updated-mode-lines)
3765 (let* ((gformat (or gnus-group-mode-line-format-spec
3766 (setq gnus-group-mode-line-format-spec
3768 gnus-group-mode-line-format
3769 gnus-group-mode-line-format-alist))))
3770 (news-server (car (cdr gnus-select-method)))
3771 (news-method (car gnus-select-method))
3773 (mode-string (eval gformat)))
3774 (setq mode-string (eval gformat))
3775 (if (> (length mode-string) max-len)
3776 (setq mode-string (substring mode-string 0 (- max-len 4))))
3777 (setq mode-line-buffer-identification mode-string)
3778 (set-buffer-modified-p t))))
3780 (defun gnus-group-group-name ()
3781 "Get the name of the newsgroup on the current line."
3782 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3783 (and group (symbol-name group))))
3785 (defun gnus-group-group-level ()
3786 "Get the level of the newsgroup on the current line."
3787 (get-text-property (gnus-point-at-bol) 'gnus-level))
3789 (defun gnus-group-group-unread ()
3790 "Get the number of unread articles of the newsgroup on the current line."
3791 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3793 (defun gnus-group-search-forward (&optional backward all level first-too)
3794 "Find the next newsgroup with unread articles.
3795 If BACKWARD is non-nil, find the previous newsgroup instead.
3796 If ALL is non-nil, just find any newsgroup.
3797 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3799 If FIRST-TOO, the current line is also eligible as a target."
3800 (let ((way (if backward -1 1))
3801 (low gnus-level-killed)
3804 (if (and backward (progn (beginning-of-line)) (bobp))
3806 (or first-too (forward-line way))
3814 (get-text-property (point) 'gnus-unread)))
3815 (or (eq unread t) (and unread (> unread 0))))
3816 (setq lev (get-text-property (point)
3818 (<= lev gnus-level-subscribed)))
3820 (and (setq lev (get-text-property (point)
3829 (zerop (forward-line way)))))
3831 (progn (gnus-group-position-cursor) t)
3832 (goto-char (or pos beg))
3835 ;;; Gnus group mode commands
3839 (defun gnus-group-mark-group (n &optional unmark no-advance)
3840 "Mark the current group."
3842 (let ((buffer-read-only nil)
3846 (setq group (gnus-group-group-name))
3850 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3855 (setq gnus-group-marked (delete group gnus-group-marked)))
3857 (setq gnus-group-marked
3858 (cons group (delete group gnus-group-marked))))
3860 (or no-advance (zerop (gnus-group-next-group 1))))
3862 (gnus-summary-position-cursor)
3865 (defun gnus-group-unmark-group (n)
3866 "Remove the mark from the current group."
3868 (gnus-group-mark-group n 'unmark))
3870 (defun gnus-group-mark-region (unmark beg end)
3871 "Mark all groups between point and mark.
3872 If UNMARK, remove the mark instead."
3873 (interactive "P\nr")
3874 (let ((num (count-lines beg end)))
3877 (- num (gnus-group-mark-group num unmark)))))
3879 (defun gnus-group-remove-mark (group)
3880 (and (gnus-group-goto-group group)
3882 (gnus-group-mark-group 1 'unmark t))))
3884 ;; Return a list of groups to work on. Take into consideration N (the
3885 ;; prefix) and the list of marked groups.
3886 (defun gnus-group-process-prefix (n)
3888 (setq n (prefix-numeric-value n))
3889 ;; There is a prefix, so we return a list of the N next
3891 (let ((way (if (< n 0) -1 1))
3896 (setq group (gnus-group-group-name)))
3897 (setq groups (cons group groups))
3899 (forward-line way)))
3902 ;; No prefix, but a list of marked articles.
3903 (reverse gnus-group-marked))
3905 ;; Neither marked articles or a prefix, so we return the
3907 (let ((group (gnus-group-group-name)))
3908 (and group (list group))))))
3910 ;; Selecting groups.
3912 (defun gnus-group-read-group (&optional all no-article group)
3913 "Read news in this newsgroup.
3914 If the prefix argument ALL is non-nil, already read articles become
3915 readable. If the optional argument NO-ARTICLE is non-nil, no article
3916 will be auto-selected upon group entry."
3918 (let ((group (or group (gnus-group-group-name)))
3919 number active marked entry)
3920 (or group (error "No group on current line"))
3922 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3923 ;; This group might be a dead group. In that case we have to get
3924 ;; the number of unread articles from `gnus-active-hashtb'.
3926 (setq number (car entry))
3927 (if (setq active (gnus-gethash group gnus-active-hashtb))
3928 (setq number (- (1+ (cdr active)) (car active)))))
3929 (gnus-summary-read-group
3930 group (or all (and (numberp number)
3931 (zerop (+ number (length (cdr (assq 'tick marked)))
3932 (length (cdr (assq 'dormant marked)))))))
3935 (defun gnus-group-select-group (&optional all)
3936 "Select this newsgroup.
3937 No article is selected automatically.
3938 If argument ALL is non-nil, already read articles become readable."
3940 (gnus-group-read-group all t))
3942 (defun gnus-group-select-group-all ()
3943 "Select the current group and display all articles in it."
3945 (gnus-group-select-group 'all))
3947 ;; Enter a group that is not in the group buffer. Non-nil is returned
3948 ;; if selection was successful.
3949 (defun gnus-group-read-ephemeral-group
3950 (group method &optional activate quit-config)
3951 (let ((group (if (gnus-group-foreign-p group) group
3952 (gnus-group-prefixed-name group method))))
3955 (list t nil (list group gnus-level-default-subscribed nil nil
3959 (if quit-config quit-config
3960 (cons (current-buffer) 'summary)))))))
3962 (set-buffer gnus-group-buffer)
3963 (or (gnus-check-server method)
3964 (error "Unable to contact server: %s" (gnus-status-message method)))
3965 (if activate (or (gnus-request-group group)
3966 (error "Couldn't request group")))
3968 (gnus-group-read-group t t group)
3971 (not (equal major-mode 'gnus-group-mode))))
3973 (defun gnus-group-jump-to-group (group)
3974 "Jump to newsgroup GROUP."
3976 (list (completing-read
3977 "Group: " gnus-active-hashtb nil
3978 (memq gnus-select-method gnus-have-read-active-file))))
3980 (if (equal group "")
3981 (error "Empty group name"))
3983 (let ((b (text-property-any
3984 (point-min) (point-max) 'gnus-group (intern group))))
3986 ;; Either go to the line in the group buffer...
3988 ;; ... or insert the line.
3990 (gnus-gethash group gnus-active-hashtb)
3991 (gnus-activate-group group)
3992 (error "%s error: %s" group (gnus-status-message group)))
3994 (gnus-group-update-group group)
3995 (goto-char (text-property-any
3996 (point-min) (point-max) 'gnus-group (intern group)))))
3997 ;; Adjust cursor point.
3998 (gnus-group-position-cursor))
4000 (defun gnus-group-goto-group (group)
4001 "Goto to newsgroup GROUP."
4002 (let ((b (text-property-any (point-min) (point-max)
4003 'gnus-group (intern group))))
4004 (and b (goto-char b))))
4006 (defun gnus-group-next-group (n)
4007 "Go to next N'th newsgroup.
4008 If N is negative, search backward instead.
4009 Returns the difference between N and the number of skips actually
4012 (gnus-group-next-unread-group n t))
4014 (defun gnus-group-next-unread-group (n &optional all level)
4015 "Go to next N'th unread newsgroup.
4016 If N is negative, search backward instead.
4017 If ALL is non-nil, choose any newsgroup, unread or not.
4018 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4019 such group can be found, the next group with a level higher than
4021 Returns the difference between N and the number of skips actually
4024 (let ((backward (< n 0))
4027 (gnus-group-search-forward
4028 backward (or (not gnus-group-goto-unread) all) level))
4030 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4031 (if level " on this level or higher" "")))
4034 (defun gnus-group-prev-group (n)
4035 "Go to previous N'th newsgroup.
4036 Returns the difference between N and the number of skips actually
4039 (gnus-group-next-unread-group (- n) t))
4041 (defun gnus-group-prev-unread-group (n)
4042 "Go to previous N'th unread newsgroup.
4043 Returns the difference between N and the number of skips actually
4046 (gnus-group-next-unread-group (- n)))
4048 (defun gnus-group-next-unread-group-same-level (n)
4049 "Go to next N'th unread newsgroup on the same level.
4050 If N is negative, search backward instead.
4051 Returns the difference between N and the number of skips actually
4054 (gnus-group-next-unread-group n t (gnus-group-group-level))
4055 (gnus-group-position-cursor))
4057 (defun gnus-group-prev-unread-group-same-level (n)
4058 "Go to next N'th unread newsgroup on the same level.
4059 Returns the difference between N and the number of skips actually
4062 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4063 (gnus-group-position-cursor))
4065 (defun gnus-group-best-unread-group (&optional exclude-group)
4066 "Go to the group with the highest level.
4067 If EXCLUDE-GROUP, do not go to that group."
4069 (goto-char (point-min))
4072 (while (setq unread (get-text-property (point) 'gnus-unread))
4073 (if (and (numberp unread) (> unread 0))
4075 (if (and (< (get-text-property (point) 'gnus-level) best)
4076 (or (not exclude-group)
4077 (not (equal exclude-group (gnus-group-group-name)))))
4079 (setq best (get-text-property (point) 'gnus-level))
4080 (setq best-point (point))))))
4082 (if best-point (goto-char best-point))
4083 (gnus-summary-position-cursor)
4084 (and best-point (gnus-group-group-name))))
4086 (defun gnus-group-first-unread-group ()
4087 "Go to the first group with unread articles."
4090 (let ((opoint (point))
4092 (goto-char (point-min))
4093 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4094 (not (zerop unread)) ; Has unread articles.
4095 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4098 nil)) ; Not success.
4099 (gnus-group-position-cursor)))
4101 (defun gnus-group-enter-server-mode ()
4102 "Jump to the server buffer."
4104 (gnus-server-setup-buffer)
4105 (gnus-configure-windows 'server)
4106 (gnus-server-prepare))
4108 (defun gnus-group-make-group (name &optional method address)
4109 "Add a new newsgroup.
4110 The user will be prompted for a NAME, for a select METHOD, and an
4114 (read-string "Group name: ")
4117 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4119 (if (assoc method gnus-valid-select-methods)
4121 (if (memq 'prompt-address
4122 (assoc method gnus-valid-select-methods))
4123 (read-string "Address: ")
4125 (list method nil)))))
4127 (let* ((meth (and method (if address (list (intern method) address) method)))
4128 (nname (if method (gnus-group-prefixed-name name meth) name))
4130 (and (gnus-gethash nname gnus-newsrc-hashtb)
4131 (error "Group %s already exists" nname))
4132 (gnus-group-change-level
4133 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4134 gnus-level-default-subscribed gnus-level-killed
4135 (and (gnus-group-group-name)
4136 (gnus-gethash (gnus-group-group-name)
4137 gnus-newsrc-hashtb))
4139 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4141 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
4142 (gnus-group-insert-group-line-info nname)
4144 (if (assoc method gnus-valid-select-methods)
4145 (require (intern method)))
4146 (and (gnus-check-backend-function 'request-create-group nname)
4147 (gnus-request-create-group nname))))
4149 (defun gnus-group-edit-group (group &optional part)
4150 "Edit the group on the current line."
4151 (interactive (list (gnus-group-group-name)))
4152 (let ((done-func '(lambda ()
4153 "Exit editing mode and update the information."
4155 (gnus-group-edit-group-done 'part 'group)))
4156 (part (or part 'info))
4157 (winconf (current-window-configuration))
4159 (or group (error "No group on current line"))
4160 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4161 (error "Killed group; can't be edited"))
4162 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4163 (gnus-configure-windows 'edit-group)
4164 (gnus-add-current-to-buffer-list)
4166 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4167 (use-local-map (copy-keymap emacs-lisp-mode-map))
4168 (local-set-key "\C-c\C-c" done-func)
4169 (make-local-variable 'gnus-prev-winconf)
4170 (setq gnus-prev-winconf winconf)
4171 ;; We modify the func to let it know what part it is editing.
4172 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4173 (setcar (cdr (cdr (nth 4 done-func))) group)
4178 ";; Type `C-c C-c' after editing the select method.\n\n")
4180 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4182 ";; Type `C-c C-c' after editing the group info.\n\n")))
4183 (let ((cinfo (gnus-copy-sequence info))
4185 (if (not (setq marked (nth 3 cinfo)))
4188 (or (eq 'score (car (car marked)))
4189 (eq 'bookmark (car (car marked)))
4190 (eq 'killed (car (car marked)))
4191 (not (numberp (car (cdr (car marked)))))
4192 (setcdr (car marked)
4193 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4194 (setq marked (cdr marked))))
4197 (cond ((eq part 'method)
4198 (or (nth 4 info) "native"))
4205 (defun gnus-group-edit-group-method (group)
4206 "Edit the select method of GROUP."
4207 (interactive (list (gnus-group-group-name)))
4208 (gnus-group-edit-group group 'method))
4210 (defun gnus-group-edit-group-parameters (group)
4211 "Edit the group parameters of GROUP."
4212 (interactive (list (gnus-group-group-name)))
4213 (gnus-group-edit-group group 'params))
4215 (defun gnus-group-edit-group-done (part group)
4216 "Get info from buffer, update variables and jump to the group buffer."
4217 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4218 (goto-char (point-min))
4219 (let ((form (read (current-buffer)))
4220 (winconf gnus-prev-winconf))
4222 (gnus-group-set-info form)
4223 (gnus-group-set-info form group part))
4224 (kill-buffer (current-buffer))
4225 (and winconf (set-window-configuration winconf))
4226 (set-buffer gnus-group-buffer)
4227 (gnus-group-update-group (gnus-group-group-name))
4228 (gnus-group-position-cursor)))
4230 (defun gnus-group-make-help-group ()
4231 "Create the Gnus documentation group."
4233 (let ((path load-path)
4235 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4236 "gnus-help" '(nndoc "gnus-help")))
4238 (error "Documentation group already exists"))
4240 (not (file-exists-p (concat (file-name-as-directory (car path))
4242 (setq path (cdr path)))
4243 (or path (error "Couldn't find doc group"))
4244 (gnus-group-make-group
4245 (gnus-group-real-name name)
4247 (list 'nndoc-address
4248 (concat (file-name-as-directory (car path)) "doc.txt"))
4249 (list 'nndoc-article-type 'mbox))))
4250 (gnus-group-position-cursor))
4252 (defun gnus-group-make-doc-group (file type)
4253 "Create a group that uses a single file as the source."
4255 (list (read-file-name "File name: ")
4259 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4260 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4261 ((= char ?b) 'babyl)
4262 ((= char ?d) 'digest)
4263 (t (setq err (format "%c unknown. " char))
4266 (let* ((file (expand-file-name file))
4267 (name (gnus-generate-new-group-name
4268 (gnus-group-prefixed-name
4269 (file-name-nondirectory file) '(nndoc "")))))
4270 (gnus-group-make-group
4271 (gnus-group-real-name name)
4273 (list 'nndoc-address file)
4274 (list 'nndoc-article-type type)))))
4276 (defun gnus-group-make-archive-group (&optional all)
4277 "Create the (ding) Gnus archive group of the most recent articles.
4278 Given a prefix, create a full group."
4280 (let ((group (gnus-group-prefixed-name
4281 (if all "ding.archives" "ding.recent") '(nndir ""))))
4282 (and (gnus-gethash group gnus-newsrc-hashtb)
4283 (error "Archive group already exists"))
4284 (gnus-group-make-group
4285 (gnus-group-real-name group)
4287 (if all gnus-group-archive-directory
4288 gnus-group-recent-archive-directory)))
4289 (gnus-group-position-cursor))
4291 (defun gnus-group-make-directory-group (dir)
4292 "Create an nndir group.
4293 The user will be prompted for a directory. The contents of this
4294 directory will be used as a newsgroup. The directory should contain
4295 mail messages or news articles in files that have numeric names."
4297 (list (read-file-name "Create group from directory: ")))
4298 (or (file-exists-p dir) (error "No such directory"))
4299 (or (file-directory-p dir) (error "Not a directory"))
4300 (gnus-group-make-group dir "nndir" dir)
4301 (gnus-group-position-cursor))
4303 (defun gnus-group-make-kiboze-group (group address scores)
4304 "Create an nnkiboze group.
4305 The user will be prompted for a name, a regexp to match groups, and
4306 score file entries for articles to include in the group."
4309 (read-string "nnkiboze group name: ")
4310 (read-string "Source groups (regexp): ")
4311 (let ((headers (mapcar (lambda (group) (list group))
4312 '("subject" "from" "number" "date" "message-id"
4313 "references" "chars" "lines" "xref")))
4314 scores header regexp regexps)
4315 (while (not (equal "" (setq header (completing-read
4316 "Match on header: " headers nil t))))
4318 (while (not (equal "" (setq regexp (read-string
4319 (format "Match on %s (string): "
4321 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4322 (setq scores (cons (cons header regexps) scores)))
4324 (gnus-group-make-group group "nnkiboze" address)
4326 (gnus-set-work-buffer)
4327 (let (emacs-lisp-mode-hook)
4328 (pp scores (current-buffer)))
4329 (write-region (point-min) (point-max)
4330 (concat (or gnus-kill-files-directory "~/News")
4331 "nnkiboze:" group "." gnus-score-file-suffix)))
4332 (gnus-group-position-cursor))
4334 (defun gnus-group-add-to-virtual (n vgroup)
4335 "Add the current group to a virtual group."
4337 (list current-prefix-arg
4338 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4340 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4341 (error "%s is not an nnvirtual group" vgroup))
4342 (let* ((groups (gnus-group-process-prefix n))
4343 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4344 (setcar (cdr method)
4346 (nth 1 method) "\\|"
4349 (gnus-group-remove-mark s)
4350 (concat "\\(^" (regexp-quote s) "$\\)"))
4352 (gnus-group-position-cursor))
4354 (defun gnus-group-make-empty-virtual (group)
4355 "Create a new, fresh, empty virtual group."
4356 (interactive "sCreate new, empty virtual group: ")
4357 (let* ((method (list 'nnvirtual "^$"))
4358 (pgroup (gnus-group-prefixed-name group method)))
4359 ;; Check whether it exists already.
4360 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4361 (error "Group %s already exists." pgroup))
4362 ;; Subscribe the new group after the group on the current line.
4363 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4364 (gnus-group-update-group pgroup)
4366 (gnus-group-position-cursor)))
4368 (defun gnus-group-enter-directory (dir)
4369 "Enter an ephemeral nneething group."
4370 (interactive "DDirectory to read: ")
4371 (let* ((method (list 'nneething dir))
4372 (leaf (gnus-group-prefixed-name
4373 (file-name-nondirectory (directory-file-name dir))
4375 (name (gnus-generate-new-group-name leaf)))
4376 (let ((nneething-read-only t))
4377 (or (gnus-group-read-ephemeral-group
4379 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4381 (error "Couldn't enter %s" dir)))))
4383 ;; Group sorting commands
4384 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4386 (defun gnus-group-sort-groups ()
4387 "Sort the group buffer using `gnus-group-sort-function'."
4389 (setq gnus-newsrc-alist
4390 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4391 (gnus-make-hashtable-from-newsrc-alist)
4392 (gnus-group-list-groups))
4394 (defun gnus-group-sort-by-alphabet (info1 info2)
4395 (string< (car info1) (car info2)))
4397 (defun gnus-group-sort-by-unread (info1 info2)
4398 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4399 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4400 (< (or (and (numberp n1) n1) 0)
4401 (or (and (numberp n2) n2) 0))))
4403 (defun gnus-group-sort-by-level (info1 info2)
4404 (< (nth 1 info1) (nth 1 info2)))
4406 ;; Group catching up.
4408 (defun gnus-group-catchup-current (&optional n all)
4409 "Mark all articles not marked as unread in current newsgroup as read.
4410 If prefix argument N is numeric, the ARG next newsgroups will be
4411 caught up. If ALL is non-nil, marked articles will also be marked as
4412 read. Cross references (Xref: header) of articles are ignored.
4413 The difference between N and actual number of newsgroups that were
4414 caught up is returned."
4416 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4420 "Do you really want to mark all articles as read? "
4421 "Mark all unread articles as read? "))))
4423 (let ((groups (gnus-group-process-prefix n))
4426 ;; Virtual groups have to be given special treatment.
4427 (let ((method (gnus-find-method-for-group (car groups))))
4428 (if (eq 'nnvirtual (car method))
4429 (nnvirtual-catchup-group
4430 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4431 (gnus-group-remove-mark (car groups))
4433 (gnus-group-goto-group (car groups))
4434 (gnus-group-catchup (car groups) all))
4435 (gnus-group-update-group-line)
4436 (setq ret (1+ ret)))
4437 (setq groups (cdr groups)))
4438 (gnus-group-next-unread-group 1)
4441 (defun gnus-group-catchup-current-all (&optional n)
4442 "Mark all articles in current newsgroup as read.
4443 Cross references (Xref: header) of articles are ignored."
4445 (gnus-group-catchup-current n 'all))
4447 (defun gnus-group-catchup (group &optional all)
4448 "Mark all articles in GROUP as read.
4449 If ALL is non-nil, all articles are marked as read.
4450 The return value is the number of articles that were marked as read,
4451 or nil if no action could be taken."
4452 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4454 (marked (nth 3 (nth 2 entry))))
4455 (if (not (numberp (car entry)))
4456 (gnus-message 1 "Can't catch up; non-active group")
4457 ;; Do the updating only if the newsgroup isn't killed.
4460 (gnus-update-read-articles
4461 group (and (not all) (append (cdr (assq 'tick marked))
4462 (cdr (assq 'dormant marked))))
4463 nil (and (not all) (cdr (assq 'tick marked))))
4465 (setq marked (nth 3 (nth 2 entry)))
4466 (setcar (nthcdr 3 (nth 2 entry))
4467 (delq (assq 'dormant marked)
4468 (nth 3 (nth 2 entry)))))))
4471 (defun gnus-group-expire-articles (&optional n)
4472 "Expire all expirable articles in the current newsgroup."
4474 (let ((groups (gnus-group-process-prefix n))
4476 (or groups (error "No groups to expire"))
4478 (setq group (car groups)
4479 groups (cdr groups))
4480 (gnus-group-remove-mark group)
4481 (if (not (gnus-check-backend-function 'request-expire-articles group))
4483 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4484 (expirable (if (memq 'total-expire (nth 5 info))
4485 (cons nil (gnus-list-of-read-articles group))
4486 (assq 'expire (nth 3 info)))))
4489 (gnus-request-expire-articles
4490 (cdr expirable) group))))))))
4492 (defun gnus-group-expire-all-groups ()
4493 "Expire all expirable articles in all newsgroups."
4496 (gnus-message 5 "Expiring...")
4497 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4498 (cdr gnus-newsrc-alist))))
4499 (gnus-group-expire-articles nil)))
4500 (gnus-group-position-cursor)
4501 (gnus-message 5 "Expiring...done"))
4503 (defun gnus-group-set-current-level (n level)
4504 "Set the level of the next N groups to LEVEL."
4505 (interactive "P\nnLevel: ")
4506 (or (and (>= level 1) (<= level gnus-level-killed))
4507 (error "Illegal level: %d" level))
4508 (let ((groups (gnus-group-process-prefix n))
4511 (setq group (car groups)
4512 groups (cdr groups))
4513 (gnus-group-remove-mark group)
4514 (gnus-message 6 "Changed level of %s from %d to %d"
4515 group (gnus-group-group-level) level)
4516 (gnus-group-change-level group level
4517 (gnus-group-group-level))
4518 (gnus-group-update-group-line)))
4519 (gnus-group-position-cursor))
4521 (defun gnus-group-unsubscribe-current-group (&optional n)
4522 "Toggle subscription of the current group.
4523 If given numerical prefix, toggle the N next groups."
4525 (let ((groups (gnus-group-process-prefix n))
4528 (setq group (car groups)
4529 groups (cdr groups))
4530 (gnus-group-remove-mark group)
4531 (gnus-group-unsubscribe-group
4532 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4533 gnus-level-default-unsubscribed
4534 gnus-level-default-subscribed))
4535 (gnus-group-update-group-line))
4536 (gnus-group-next-group 1)))
4538 (defun gnus-group-unsubscribe-group (group &optional level)
4539 "Toggle subscribe from/to unsubscribe GROUP.
4540 New newsgroup is added to .newsrc automatically."
4542 (list (completing-read
4543 "Group: " gnus-active-hashtb nil
4544 (memq gnus-select-method gnus-have-read-active-file))))
4545 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4547 ((string-match "^[ \t]$" group)
4548 (error "Empty group name"))
4550 ;; Toggle subscription flag.
4551 (gnus-group-change-level
4552 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4553 gnus-level-subscribed)
4554 (1+ gnus-level-subscribed)
4555 gnus-level-default-subscribed)))
4556 (gnus-group-update-group group))
4557 ((and (stringp group)
4558 (or (not (memq gnus-select-method gnus-have-read-active-file))
4559 (gnus-gethash group gnus-active-hashtb)))
4560 ;; Add new newsgroup.
4561 (gnus-group-change-level
4563 (if level level gnus-level-default-subscribed)
4564 (or (and (member group gnus-zombie-list)
4567 (and (gnus-group-group-name)
4568 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4569 (gnus-group-update-group group))
4570 (t (error "No such newsgroup: %s" group)))
4571 (gnus-group-position-cursor)))
4573 (defun gnus-group-transpose-groups (n)
4574 "Move the current newsgroup up N places.
4575 If given a negative prefix, move down instead. The difference between
4576 N and the number of steps taken is returned."
4578 (or (gnus-group-group-name)
4579 (error "No group on current line"))
4580 (gnus-group-kill-group 1)
4582 (forward-line (- n))
4583 (gnus-group-yank-group)
4584 (gnus-group-position-cursor)))
4586 (defun gnus-group-kill-all-zombies ()
4587 "Kill all zombie newsgroups."
4589 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4590 (setq gnus-zombie-list nil)
4591 (gnus-group-list-groups))
4593 (defun gnus-group-kill-region (begin end)
4594 "Kill newsgroups in current region (excluding current point).
4595 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4610 (beginning-of-line) ;Important when LINES < 1
4611 (gnus-group-kill-group lines)))
4613 (defun gnus-group-kill-group (&optional n)
4614 "The the next N groups.
4615 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4616 However, only groups that were alive can be yanked; already killed
4617 groups or zombie groups can't be yanked.
4618 The return value is the name of the (last) group that was killed."
4620 (let ((buffer-read-only nil)
4621 (groups (gnus-group-process-prefix n))
4624 (setq group (car groups)
4625 groups (cdr groups))
4626 (gnus-group-remove-mark group)
4627 (setq level (gnus-group-group-level))
4629 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4630 (setq gnus-list-of-killed-groups
4631 (cons (cons (car entry) (nth 2 entry))
4632 gnus-list-of-killed-groups)))
4633 (gnus-group-change-level
4634 (if entry entry group) gnus-level-killed (if entry nil level)))
4635 (gnus-group-position-cursor)
4638 (defun gnus-group-yank-group (&optional arg)
4639 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4640 inserting it before the current newsgroup. The numeric ARG specifies
4641 how many newsgroups are to be yanked. The name of the (last)
4642 newsgroup yanked is returned."
4644 (if (not arg) (setq arg 1))
4645 (let (info group prev)
4646 (while (>= (setq arg (1- arg)) 0)
4647 (if (not (setq info (car gnus-list-of-killed-groups)))
4648 (error "No more newsgroups to yank"))
4649 (setq group (nth 2 info))
4650 ;; Find which newsgroup to insert this one before - search
4651 ;; backward until something suitable is found. If there are no
4652 ;; other newsgroups in this buffer, just make this newsgroup the
4654 (setq prev (gnus-group-group-name))
4655 (gnus-group-change-level
4656 info (nth 2 info) gnus-level-killed
4657 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4659 (gnus-group-insert-group-line-info (nth 1 info))
4660 (setq gnus-list-of-killed-groups
4661 (cdr gnus-list-of-killed-groups)))
4663 (gnus-group-position-cursor)
4666 (defun gnus-group-list-all-groups (&optional arg)
4667 "List all newsgroups with level ARG or lower.
4668 Default is gnus-level-unsubscribed, which lists all subscribed and most
4669 unsubscribed groups."
4671 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4673 (defun gnus-group-list-killed ()
4674 "List all killed newsgroups in the group buffer."
4676 (if (not gnus-killed-list)
4677 (gnus-message 6 "No killed groups")
4678 (let (gnus-group-list-mode)
4679 (funcall gnus-group-prepare-function
4680 gnus-level-killed t gnus-level-killed))
4681 (goto-char (point-min)))
4682 (gnus-group-position-cursor))
4684 (defun gnus-group-list-zombies ()
4685 "List all zombie newsgroups in the group buffer."
4687 (if (not gnus-zombie-list)
4688 (gnus-message 6 "No zombie groups")
4689 (let (gnus-group-list-mode)
4690 (funcall gnus-group-prepare-function
4691 gnus-level-zombie t gnus-level-zombie))
4692 (goto-char (point-min)))
4693 (gnus-group-position-cursor))
4695 (defun gnus-group-get-new-news (&optional arg)
4696 "Get newly arrived articles.
4697 If ARG is non-nil, it should be a number between one and nine to
4698 specify which levels you are interested in re-scanning."
4700 (run-hooks 'gnus-get-new-news-hook)
4701 (setq arg (gnus-group-default-level arg t))
4702 (if (and gnus-read-active-file (not arg))
4704 (gnus-read-active-file)
4705 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4706 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
4707 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4708 (gnus-group-list-groups))
4710 (defun gnus-group-get-new-news-this-group (&optional n)
4711 "Check for newly arrived news in the current group (and the N-1 next groups).
4712 The difference between N and the number of newsgroup checked is returned.
4713 If N is negative, this group and the N-1 previous groups will be checked."
4715 (let* ((groups (gnus-group-process-prefix n))
4716 (ret (if (numberp n) (- n (length groups)) 0))
4719 (setq group (car groups)
4720 groups (cdr groups))
4721 (gnus-group-remove-mark group)
4722 (or (gnus-get-new-news-in-group group)
4725 (message "%s error: %s" group (gnus-status-message group))
4727 (gnus-group-next-unread-group 1 t)
4728 (gnus-summary-position-cursor)
4731 (defun gnus-get-new-news-in-group (group)
4733 (gnus-activate-group group)
4735 (gnus-get-unread-articles-in-group
4736 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4737 (gnus-gethash group gnus-active-hashtb))
4738 (gnus-group-update-group-line)
4741 (defun gnus-group-fetch-faq (group)
4742 "Fetch the FAQ for the current group."
4743 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4744 (or group (error "No group name given"))
4745 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group))))
4746 (if (not (file-exists-p file))
4747 (error "No such file: %s" file)
4750 (defun gnus-group-describe-group (force &optional group)
4751 "Display a description of the current newsgroup."
4752 (interactive (list current-prefix-arg (gnus-group-group-name)))
4753 (and force (setq gnus-description-hashtb nil))
4754 (let ((method (gnus-find-method-for-group group))
4756 (or group (error "No group name given"))
4757 (and (or (and gnus-description-hashtb
4758 ;; We check whether this group's method has been
4759 ;; queried for a description file.
4761 (gnus-group-prefixed-name "" method)
4762 gnus-description-hashtb))
4763 (setq desc (gnus-group-get-description group))
4764 (gnus-read-descriptions-file method))
4766 (or desc (gnus-gethash group gnus-description-hashtb)
4767 "No description available")))))
4769 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4770 (defun gnus-group-describe-all-groups (&optional force)
4771 "Pop up a buffer with descriptions of all newsgroups."
4773 (and force (setq gnus-description-hashtb nil))
4774 (if (not (or gnus-description-hashtb
4775 (gnus-read-all-descriptions-files)))
4776 (error "Couldn't request descriptions file"))
4777 (let ((buffer-read-only nil)
4783 (insert (format " *: %-20s %s\n" (symbol-name group)
4784 (symbol-value group)))
4785 (add-text-properties
4786 b (1+ b) (list 'gnus-group group
4787 'gnus-unread t 'gnus-marked nil
4788 'gnus-level (1+ gnus-level-subscribed))))
4789 gnus-description-hashtb)
4790 (goto-char (point-min))
4791 (gnus-group-position-cursor)))
4793 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4794 (defun gnus-group-apropos (regexp &optional search-description)
4795 "List all newsgroups that have names that match a regexp."
4796 (interactive "sGnus apropos (regexp): ")
4798 (obuf (current-buffer))
4800 ;; Go through all newsgroups that are known to Gnus.
4803 (and (symbol-name group)
4804 (string-match regexp (symbol-name group))
4805 (setq groups (cons (symbol-name group) groups))))
4807 ;; Go through all descriptions that are known to Gnus.
4808 (if search-description
4811 (and (string-match regexp (symbol-value group))
4812 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4813 (setq groups (cons (symbol-name group) groups))))
4814 gnus-description-hashtb))
4816 (gnus-message 3 "No groups matched \"%s\"." regexp)
4817 ;; Print out all the groups.
4819 (pop-to-buffer "*Gnus Help*")
4820 (buffer-disable-undo (current-buffer))
4822 (setq groups (sort groups 'string<))
4824 ;; Groups may be entered twice into the list of groups.
4825 (if (not (string= (car groups) prev))
4827 (insert (setq prev (car groups)) "\n")
4828 (if (and gnus-description-hashtb
4829 (setq des (gnus-gethash (car groups)
4830 gnus-description-hashtb)))
4831 (insert " " des "\n"))))
4832 (setq groups (cdr groups)))
4833 (goto-char (point-min))))
4834 (pop-to-buffer obuf)))
4836 (defun gnus-group-description-apropos (regexp)
4837 "List all newsgroups that have names or descriptions that match a regexp."
4838 (interactive "sGnus description apropos (regexp): ")
4839 (if (not (or gnus-description-hashtb
4840 (gnus-read-all-descriptions-files)))
4841 (error "Couldn't request descriptions file"))
4842 (gnus-group-apropos regexp t))
4844 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4845 (defun gnus-group-list-matching (level regexp &optional all lowest)
4846 "List all groups with unread articles that match REGEXP.
4847 If the prefix LEVEL is non-nil, it should be a number that says which
4848 level to cut off listing groups.
4849 If ALL, also list groups with no unread articles.
4850 If LOWEST, don't list groups with level lower than LOWEST."
4851 (interactive "P\nsList newsgroups matching: ")
4852 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4853 all (or lowest 1) regexp)
4854 (goto-char (point-min))
4855 (gnus-group-position-cursor))
4857 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4858 "List all groups that match REGEXP.
4859 If the prefix LEVEL is non-nil, it should be a number that says which
4860 level to cut off listing groups.
4861 If LOWEST, don't list groups with level lower than LOWEST."
4862 (interactive "P\nsList newsgroups matching: ")
4863 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4865 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4866 (defun gnus-group-save-newsrc ()
4867 "Save the Gnus startup files."
4869 (gnus-save-newsrc-file))
4871 (defun gnus-group-restart (&optional arg)
4872 "Force Gnus to read the .newsrc file."
4874 (gnus-save-newsrc-file)
4875 (gnus-setup-news 'force)
4876 (gnus-group-list-groups arg))
4878 (defun gnus-group-read-init-file ()
4879 "Read the Gnus elisp init file."
4881 (gnus-read-init-file))
4883 (defun gnus-group-check-bogus-groups (&optional silent)
4884 "Check bogus newsgroups.
4885 If given a prefix, don't ask for confirmation before removing a bogus
4888 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4889 (gnus-group-list-groups))
4891 (defun gnus-group-edit-global-kill (&optional article group)
4892 "Edit the global kill file.
4893 If GROUP, edit that local kill file instead."
4895 (setq gnus-current-kill-article article)
4896 (gnus-kill-file-edit-file group)
4899 (substitute-command-keys
4900 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4902 (defun gnus-group-edit-local-kill (article group)
4903 "Edit a local kill file."
4904 (interactive (list nil (gnus-group-group-name)))
4905 (gnus-group-edit-global-kill article group))
4907 (defun gnus-group-force-update ()
4908 "Update `.newsrc' file."
4910 (gnus-save-newsrc-file))
4912 (defun gnus-group-suspend ()
4913 "Suspend the current Gnus session.
4914 In fact, cleanup buffers except for group mode buffer.
4915 The hook gnus-suspend-gnus-hook is called before actually suspending."
4917 (run-hooks 'gnus-suspend-gnus-hook)
4918 ;; Kill Gnus buffers except for group mode buffer.
4919 (let ((group-buf (get-buffer gnus-group-buffer)))
4920 ;; Do this on a separate list in case the user does a ^G before we finish
4921 (let ((gnus-buffer-list
4922 (delq group-buf (delq gnus-dribble-buffer
4923 (append gnus-buffer-list nil)))))
4924 (while gnus-buffer-list
4925 (gnus-kill-buffer (car gnus-buffer-list))
4926 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4929 (setq gnus-buffer-list (list group-buf))
4930 (bury-buffer group-buf)
4931 (delete-windows-on group-buf t)))))
4933 (defun gnus-group-clear-dribble ()
4934 "Clear all information from the dribble buffer."
4936 (gnus-dribble-clear))
4938 (defun gnus-group-exit ()
4939 "Quit reading news after updating .newsrc.eld and .newsrc.
4940 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4942 (if (or noninteractive ;For gnus-batch-kill
4943 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4944 (not gnus-interactive-exit) ;Without confirmation
4946 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4948 (run-hooks 'gnus-exit-gnus-hook)
4949 ;; Offer to save data from non-quitted summary buffers.
4950 (gnus-offer-save-summaries)
4951 ;; Save the newsrc file(s).
4952 (gnus-save-newsrc-file)
4954 (gnus-close-backends)
4955 ;; Reset everything.
4956 (gnus-clear-system))))
4958 (defun gnus-close-backends ()
4959 ;; Send a close request to all backends that support such a request.
4960 (let ((methods gnus-valid-select-methods)
4963 (if (fboundp (setq func (intern (concat (car (car methods))
4964 "-request-close"))))
4966 (setq methods (cdr methods)))))
4968 (defun gnus-group-quit ()
4969 "Quit reading news without updating .newsrc.eld or .newsrc.
4970 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4972 (if (or noninteractive ;For gnus-batch-kill
4973 (zerop (buffer-size))
4974 (not (gnus-server-opened gnus-select-method))
4976 (not gnus-current-startup-file)
4978 (format "Quit reading news without saving %s? "
4979 (file-name-nondirectory gnus-current-startup-file))))
4981 (run-hooks 'gnus-exit-gnus-hook)
4982 (if gnus-use-full-window
4983 (delete-other-windows)
4984 (gnus-remove-some-windows))
4986 (gnus-close-backends)
4987 (gnus-clear-system))))
4989 (defun gnus-offer-save-summaries ()
4991 (let ((buflist (buffer-list))
4994 (and (setq bufname (buffer-name (car buflist)))
4995 (string-match "Summary" bufname)
4997 (set-buffer bufname)
4998 ;; We check that this is, indeed, a summary buffer.
4999 (eq major-mode 'gnus-summary-mode))
5000 (setq buffers (cons bufname buffers)))
5001 (setq buflist (cdr buflist)))
5004 "Update summary buffer %s? "
5007 (gnus-summary-exit))
5010 (defun gnus-group-describe-briefly ()
5011 "Give a one line description of the group mode commands."
5013 (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")))
5015 (defun gnus-group-browse-foreign-server (method)
5016 "Browse a foreign news server.
5017 If called interactively, this function will ask for a select method
5018 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
5019 If not, METHOD should be a list where the first element is the method
5020 and the second element is the address."
5022 (list (let ((how (completing-read
5024 (append gnus-valid-select-methods gnus-server-alist)
5026 ;; We either got a backend name or a virtual server name.
5027 ;; If the first, we also need an address.
5028 (if (assoc how gnus-valid-select-methods)
5030 ;; Suggested by mapjph@bath.ac.uk.
5033 (mapcar (lambda (server) (list server))
5034 gnus-secondary-servers)))
5035 ;; We got a server name, so we find the method.
5036 (gnus-server-to-method how)))))
5037 (gnus-browse-foreign-server method))
5041 ;;; Browse Server Mode
5044 (defvar gnus-browse-mode-hook nil)
5045 (defvar gnus-browse-mode-map nil)
5046 (put 'gnus-browse-mode 'mode-class 'special)
5048 (if gnus-browse-mode-map
5050 (setq gnus-browse-mode-map (make-keymap))
5051 (suppress-keymap gnus-browse-mode-map)
5052 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5053 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5054 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5055 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5056 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5057 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5058 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5059 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5060 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5061 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5062 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5063 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5064 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5065 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5066 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5067 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5068 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5069 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5072 (defvar gnus-browse-current-method nil)
5073 (defvar gnus-browse-return-buffer nil)
5075 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5077 (defun gnus-browse-foreign-server (method &optional return-buffer)
5078 (setq gnus-browse-current-method method)
5079 (setq gnus-browse-return-buffer return-buffer)
5080 (let ((gnus-select-method method)
5082 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5083 (or (gnus-check-server method)
5084 (error "Unable to contact server: %s" (gnus-status-message method)))
5085 (or (gnus-request-list method)
5086 (error "Couldn't request list: %s" (gnus-status-message method)))
5087 (get-buffer-create gnus-browse-buffer)
5088 (gnus-add-current-to-buffer-list)
5089 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5090 (gnus-configure-windows 'browse)
5091 (buffer-disable-undo (current-buffer))
5092 (let ((buffer-read-only nil))
5095 (setq mode-line-buffer-identification
5097 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5099 (set-buffer nntp-server-buffer)
5100 (let ((cur (current-buffer)))
5101 (goto-char (point-min))
5102 (or (string= gnus-ignored-newsgroups "")
5103 (delete-matching-lines gnus-ignored-newsgroups))
5104 (while (re-search-forward
5105 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5106 (goto-char (match-end 1))
5107 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5109 (max 0 (- (1+ (read cur)) (read cur))))
5111 (setq groups (sort groups
5113 (string< (car l1) (car l2)))))
5114 (let ((buffer-read-only nil))
5116 (setq group (car groups))
5118 (format "K%7d: %s\n" (cdr group) (car group)))
5119 (setq groups (cdr groups))))
5120 (switch-to-buffer (current-buffer))
5121 (goto-char (point-min))
5122 (gnus-group-position-cursor)))
5124 (defun gnus-browse-mode ()
5125 "Major mode for browsing a foreign server.
5127 All normal editing commands are switched off.
5129 \\<gnus-browse-mode-map>
5130 The only things you can do in this buffer is
5132 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5133 The group will be inserted into the group buffer upon exit from this
5136 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5138 3) `\\[gnus-browse-exit]' to return to the group buffer."
5140 (kill-all-local-variables)
5141 (if gnus-visual (gnus-browse-make-menu-bar))
5142 (setq mode-line-modified "-- ")
5143 (make-local-variable 'mode-line-format)
5144 (setq mode-line-format (copy-sequence mode-line-format))
5145 (and (equal (nth 3 mode-line-format) " ")
5146 (setcar (nthcdr 3 mode-line-format) ""))
5147 (setq major-mode 'gnus-browse-mode)
5148 (setq mode-name "Browse Server")
5149 (setq mode-line-process nil)
5150 (use-local-map gnus-browse-mode-map)
5151 (buffer-disable-undo (current-buffer))
5152 (setq truncate-lines t)
5153 (setq buffer-read-only t)
5154 (run-hooks 'gnus-browse-mode-hook))
5156 (defun gnus-browse-read-group (&optional no-article)
5157 "Enter the group at the current line."
5159 (let ((group (gnus-browse-group-name)))
5160 (or (gnus-group-read-ephemeral-group
5161 group gnus-browse-current-method nil
5162 (cons (current-buffer) 'browse))
5163 (error "Couldn't enter %s" group))))
5165 (defun gnus-browse-select-group ()
5166 "Select the current group."
5168 (gnus-browse-read-group 'no))
5170 (defun gnus-browse-next-group (n)
5171 "Go to the next group."
5175 (gnus-group-position-cursor)))
5177 (defun gnus-browse-prev-group (n)
5178 "Go to the next group."
5180 (gnus-browse-next-group (- n)))
5182 (defun gnus-browse-unsubscribe-current-group (arg)
5183 "(Un)subscribe to the next ARG groups."
5186 (error "No group at current line."))
5187 (let ((ward (if (< arg 0) -1 1))
5189 (while (and (> arg 0)
5191 (gnus-browse-unsubscribe-group)
5192 (zerop (gnus-browse-next-group ward)))
5193 (setq arg (1- arg)))
5194 (gnus-group-position-cursor)
5195 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5198 (defun gnus-browse-group-name ()
5201 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5203 (gnus-group-prefixed-name
5204 (buffer-substring (match-beginning 1) (match-end 1))
5205 gnus-browse-current-method))))
5207 (defun gnus-browse-unsubscribe-group ()
5209 (buffer-read-only nil)
5213 (if (= (following-char) ?K) (setq sub t))
5214 (setq group (gnus-browse-group-name))
5219 (gnus-group-change-level
5220 (list t group gnus-level-default-subscribed
5221 nil nil gnus-browse-current-method)
5222 gnus-level-default-subscribed gnus-level-killed
5223 (and (car (nth 1 gnus-newsrc-alist))
5224 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5225 gnus-newsrc-hashtb))
5228 (gnus-group-change-level
5229 group gnus-level-killed gnus-level-default-subscribed)
5233 (defun gnus-browse-exit ()
5234 "Quit browsing and return to the group buffer."
5236 (if (eq major-mode 'gnus-browse-mode)
5237 (kill-buffer (current-buffer)))
5238 (if gnus-browse-return-buffer
5239 (gnus-configure-windows 'server 'force)
5240 (gnus-configure-windows 'group 'force)
5241 (gnus-group-list-groups nil)))
5243 (defun gnus-browse-describe-briefly ()
5244 "Give a one line description of the group mode commands."
5247 (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")))
5251 ;;; Gnus summary mode
5254 (defvar gnus-summary-mode-map nil)
5255 (defvar gnus-summary-mark-map nil)
5256 (defvar gnus-summary-mscore-map nil)
5257 (defvar gnus-summary-article-map nil)
5258 (defvar gnus-summary-thread-map nil)
5259 (defvar gnus-summary-goto-map nil)
5260 (defvar gnus-summary-exit-map nil)
5261 (defvar gnus-summary-interest-map nil)
5262 (defvar gnus-summary-sort-map nil)
5263 (defvar gnus-summary-backend-map nil)
5264 (defvar gnus-summary-save-map nil)
5265 (defvar gnus-summary-wash-map nil)
5266 (defvar gnus-summary-wash-hide-map nil)
5267 (defvar gnus-summary-wash-highlight-map nil)
5268 (defvar gnus-summary-wash-time-map nil)
5269 (defvar gnus-summary-help-map nil)
5271 (put 'gnus-summary-mode 'mode-class 'special)
5273 (if gnus-summary-mode-map
5275 (setq gnus-summary-mode-map (make-keymap))
5276 (suppress-keymap gnus-summary-mode-map)
5278 ;; Non-orthogonal keys
5280 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5281 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5282 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5283 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5284 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5285 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5286 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5287 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5288 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5289 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5290 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5291 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5292 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5293 (define-key gnus-summary-mode-map
5294 "\M-s" 'gnus-summary-search-article-forward)
5295 (define-key gnus-summary-mode-map
5296 "\M-r" 'gnus-summary-search-article-backward)
5297 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5298 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5299 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5300 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5301 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5302 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5303 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5304 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5305 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5306 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5307 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5308 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5309 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5310 (define-key gnus-summary-mode-map
5311 "k" 'gnus-summary-kill-same-subject-and-select)
5312 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5313 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5314 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5315 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5316 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5317 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5318 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5319 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5320 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5321 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5322 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5323 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5324 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5325 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5326 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5327 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5328 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5329 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5330 (define-key gnus-summary-mode-map
5331 "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5332 (define-key gnus-summary-mode-map
5333 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5334 (define-key gnus-summary-mode-map
5335 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5336 (define-key gnus-summary-mode-map
5337 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5338 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5339 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5340 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5341 (define-key gnus-summary-mode-map
5342 "\C-x\C-s" 'gnus-summary-reselect-current-group)
5343 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5344 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5345 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5346 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5347 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5348 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5349 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5350 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5351 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5352 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5353 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5354 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5355 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5356 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5357 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5358 (define-key gnus-summary-mode-map "V" 'gnus-version)
5359 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5360 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5361 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5362 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5363 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5364 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5365 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5366 (define-key gnus-summary-mode-map
5367 "x" 'gnus-summary-remove-lines-marked-as-read)
5368 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5369 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5370 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5371 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5372 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5373 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5374 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5375 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5376 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5377 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5380 ;; Sort of orthogonal keymap
5381 (define-prefix-command 'gnus-summary-mark-map)
5382 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5383 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5384 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5385 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5386 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5387 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5388 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5389 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5390 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5391 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5392 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5393 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5394 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5395 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5396 (define-key gnus-summary-mark-map
5397 "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5398 (define-key gnus-summary-mark-map
5399 "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5400 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5401 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5402 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5403 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5404 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5405 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5406 (define-key gnus-summary-mark-map
5407 "k" 'gnus-summary-kill-same-subject-and-select)
5408 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5410 (define-prefix-command 'gnus-summary-mscore-map)
5411 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5412 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5413 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5414 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5415 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5417 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5419 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5421 (define-prefix-command 'gnus-summary-goto-map)
5422 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5423 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5424 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5425 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5426 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5427 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5428 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5429 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5430 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5431 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5432 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5433 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5434 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5435 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5438 (define-prefix-command 'gnus-summary-thread-map)
5439 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5440 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5441 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5442 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5443 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5444 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5445 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5446 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5447 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5448 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5449 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5450 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5451 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5452 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5455 (define-prefix-command 'gnus-summary-exit-map)
5456 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5457 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5458 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5459 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5460 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5461 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5462 (define-key gnus-summary-exit-map
5463 "n" 'gnus-summary-catchup-and-goto-next-group)
5464 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5465 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5466 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5467 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5470 (define-prefix-command 'gnus-summary-article-map)
5471 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5472 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5473 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5474 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5475 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5476 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5477 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5478 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5479 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5480 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5481 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5482 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5483 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5484 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5488 (define-prefix-command 'gnus-summary-wash-map)
5489 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5491 (define-prefix-command 'gnus-summary-wash-hide-map)
5492 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5493 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5494 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5495 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5496 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5497 (define-key gnus-summary-wash-hide-map
5498 "\C-c" 'gnus-article-hide-citation-maybe)
5500 (define-prefix-command 'gnus-summary-wash-highlight-map)
5501 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5502 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5503 (define-key gnus-summary-wash-highlight-map
5504 "h" 'gnus-article-highlight-headers)
5505 (define-key gnus-summary-wash-highlight-map
5506 "c" 'gnus-article-highlight-citation)
5507 (define-key gnus-summary-wash-highlight-map
5508 "s" 'gnus-article-highlight-signature)
5510 (define-prefix-command 'gnus-summary-wash-time-map)
5511 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5512 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5513 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5514 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5515 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5517 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5518 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5519 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5520 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5521 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5522 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5523 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5524 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5525 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5526 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5529 (define-prefix-command 'gnus-summary-help-map)
5530 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5531 (define-key gnus-summary-help-map "v" 'gnus-version)
5532 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5533 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5534 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5535 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5538 (define-prefix-command 'gnus-summary-backend-map)
5539 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5540 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5541 (define-key gnus-summary-backend-map "\M-\C-e"
5542 'gnus-summary-expire-articles-now)
5543 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5544 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5545 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5546 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5547 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5548 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5549 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5552 (define-prefix-command 'gnus-summary-save-map)
5553 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5554 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5555 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5556 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5557 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5558 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5559 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5560 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5561 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5563 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5565 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5566 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5567 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5568 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5569 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5570 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5571 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5572 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5573 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5574 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5576 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5578 ; (define-prefix-command 'gnus-summary-sort-map)
5579 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5580 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5581 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5582 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5583 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5584 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5586 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5587 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5593 (defun gnus-summary-mode (&optional group)
5594 "Major mode for reading articles.
5596 All normal editing commands are switched off.
5597 \\<gnus-summary-mode-map>
5598 Each line in this buffer represents one article. To read an
5599 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5600 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5603 You can also post articles and send mail from this buffer. To
5604 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5605 of an article, type `\\[gnus-summary-reply]'.
5607 There are approx. one gazillion commands you can execute in this
5608 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5610 The following commands are available:
5612 \\{gnus-summary-mode-map}"
5614 (if gnus-visual (gnus-summary-make-menu-bar))
5615 (kill-all-local-variables)
5616 (let ((locals gnus-summary-local-variables))
5618 (if (consp (car locals))
5620 (make-local-variable (car (car locals)))
5621 (set (car (car locals)) (eval (cdr (car locals)))))
5622 (make-local-variable (car locals))
5623 (set (car locals) nil))
5624 (setq locals (cdr locals))))
5625 (gnus-make-thread-indent-array)
5626 (setq mode-line-modified "-- ")
5627 (make-local-variable 'mode-line-format)
5628 (setq mode-line-format (copy-sequence mode-line-format))
5629 (and (equal (nth 3 mode-line-format) " ")
5630 (setcar (nthcdr 3 mode-line-format) ""))
5631 (setq major-mode 'gnus-summary-mode)
5632 (setq mode-name "Summary")
5633 (make-local-variable 'minor-mode-alist)
5634 (use-local-map gnus-summary-mode-map)
5635 (buffer-disable-undo (current-buffer))
5636 (setq buffer-read-only t) ;Disable modification
5637 (setq truncate-lines t)
5638 (setq selective-display t)
5639 (setq selective-display-ellipses t) ;Display `...'
5640 (setq buffer-display-table gnus-summary-display-table)
5641 (setq gnus-newsgroup-name group)
5642 (run-hooks 'gnus-summary-mode-hook))
5644 (defun gnus-summary-make-display-table ()
5645 ;; Change the display table. Odd characters have a tendency to mess
5646 ;; up nicely formatted displays - we make all possible glyphs
5647 ;; display only a single character.
5649 ;; We start from the standard display table, if any.
5650 (setq gnus-summary-display-table
5651 (or (copy-sequence standard-display-table)
5652 (make-display-table)))
5653 ;; Nix out all the control chars...
5655 (while (>= (setq i (1- i)) 0)
5656 (aset gnus-summary-display-table i [??])))
5657 ;; ... but not newline and cr, of course. (cr is necessary for the
5658 ;; selective display).
5659 (aset gnus-summary-display-table ?\n nil)
5660 (aset gnus-summary-display-table ?\r nil)
5661 ;; We nix out any glyphs over 126 that are not set already.
5663 (while (>= (setq i (1- i)) 127)
5664 ;; Only modify if the entry is nil.
5665 (or (aref gnus-summary-display-table i)
5666 (aset gnus-summary-display-table i [??])))))
5668 (defun gnus-summary-clear-local-variables ()
5669 (let ((locals gnus-summary-local-variables))
5671 (if (consp (car locals))
5672 (and (vectorp (car (car locals)))
5673 (set (car (car locals)) nil))
5674 (and (vectorp (car locals))
5675 (set (car locals) nil)))
5676 (setq locals (cdr locals)))))
5678 ;; Some summary mode macros.
5680 ;; Return a header specified by a NUMBER.
5681 (defun gnus-get-header-by-number (number)
5683 (set-buffer gnus-summary-buffer)
5684 (or gnus-newsgroup-headers-hashtb-by-number
5685 (gnus-make-headers-hashtable-by-number))
5686 (gnus-gethash (int-to-string number)
5687 gnus-newsgroup-headers-hashtb-by-number)))
5689 ;; Fast version of the function above.
5690 (defmacro gnus-get-header-by-num (number)
5691 (` (gnus-gethash (int-to-string (, number))
5692 gnus-newsgroup-headers-hashtb-by-number)))
5694 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5695 "Search for article forward.
5696 If UNREAD is non-nil, only unread articles are selected.
5697 If SUBJECT is non-nil, the article which has the same subject will be
5699 If BACKWARD is non-nil, the search will be performed backwards instead."
5700 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5702 (defmacro gnus-summary-search-backward (&optional unread subject)
5703 "Search for article backward.
5704 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5705 If 2nd optional argument SUBJECT is non-nil, the article which has
5706 the same subject will be searched for."
5707 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5709 (defmacro gnus-summary-article-number (&optional number-or-nil)
5710 "The article number of the article on the current line.
5711 If there isn's an article number here, then we return the current
5714 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5715 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5716 gnus-current-article)))
5718 (defmacro gnus-summary-thread-level ()
5719 "The thread level of the article on the current line."
5720 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5723 (defmacro gnus-summary-article-mark ()
5724 "The mark on the current line."
5725 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5727 (defun gnus-summary-subject-string ()
5728 "Return current subject string or nil if nothing."
5729 (let ((article (gnus-summary-article-number))
5732 (setq header (gnus-get-header-by-num article))
5734 (mail-header-subject header))))
5736 ;; Various summary mode internalish functions.
5738 (defun gnus-mouse-pick-article (e)
5741 (gnus-summary-next-page nil t))
5743 (defun gnus-summary-setup-buffer (group)
5744 "Initialize summary buffer."
5745 (let ((buffer (concat "*Summary " group "*")))
5746 (if (get-buffer buffer)
5749 (not gnus-newsgroup-begin))
5750 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5751 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5752 (gnus-add-current-to-buffer-list)
5753 (gnus-summary-mode group)
5754 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5755 (setq gnus-newsgroup-name group)
5758 (defun gnus-set-global-variables ()
5759 ;; Set the global equivalents of the summary buffer-local variables
5760 ;; to the latest values they had. These reflect the summary buffer
5761 ;; that was in action when the last article was fetched.
5762 (if (eq major-mode 'gnus-summary-mode)
5764 (setq gnus-summary-buffer (current-buffer))
5765 (let ((name gnus-newsgroup-name)
5766 (marked gnus-newsgroup-marked)
5767 (unread gnus-newsgroup-unreads)
5768 (headers gnus-current-headers)
5769 (score-file gnus-current-score-file))
5771 (set-buffer gnus-group-buffer)
5772 (setq gnus-newsgroup-name name)
5773 (setq gnus-newsgroup-marked marked)
5774 (setq gnus-newsgroup-unreads unread)
5775 (setq gnus-current-headers headers)
5776 (setq gnus-current-score-file score-file))))))
5778 (defun gnus-summary-insert-dummy-line (sformat subject number)
5780 (setq sformat gnus-summary-dummy-line-format-spec))
5784 (insert (eval sformat))
5785 (add-text-properties
5787 (list 'gnus-number number
5788 'gnus-mark gnus-dummy-mark
5791 (defvar gnus-thread-indent-array nil)
5792 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5793 (defun gnus-make-thread-indent-array ()
5795 (if (and gnus-thread-indent-array
5796 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5798 (setq gnus-thread-indent-array (make-vector 201 "")
5799 gnus-thread-indent-array-level gnus-thread-indent-level)
5801 (aset gnus-thread-indent-array n
5802 (make-string (* n gnus-thread-indent-level) ? ))
5805 (defun gnus-summary-insert-line
5806 (sformat header level current unread replied expirable subject-or-nil
5807 &optional dummy score process)
5808 (or sformat (setq sformat gnus-summary-line-format-spec))
5809 (let* ((indentation (aref gnus-thread-indent-array level))
5810 (lines (mail-header-lines header))
5811 (score (or score gnus-summary-default-score 0))
5813 (if (or (null gnus-summary-default-score)
5814 (<= (abs (- score gnus-summary-default-score))
5815 gnus-summary-zcore-fuzz)) ?
5816 (if (< score gnus-summary-default-score)
5817 gnus-score-below-mark gnus-score-over-mark)))
5818 (replied (cond (process gnus-process-mark)
5819 (replied gnus-replied-mark)
5820 (t gnus-unread-mark)))
5821 (from (mail-header-from header))
5823 ((string-match "(.+)" from)
5824 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5825 ((string-match "<[^>]+> *$" from)
5826 (let ((beg (match-beginning 0)))
5827 (or (and (string-match "^\"[^\"]*\"" from)
5828 (substring from (1+ (match-beginning 0))
5829 (1- (match-end 0))))
5830 (substring from 0 beg))))
5832 (subject (mail-header-subject header))
5833 (number (mail-header-number header))
5834 (opening-bracket (if dummy ?\< ?\[))
5835 (closing-bracket (if dummy ?\> ?\]))
5836 (buffer-read-only nil)
5837 (b (progn (beginning-of-line) (point))))
5838 (or (numberp lines) (setq lines 0))
5839 (insert (eval sformat))
5840 (add-text-properties
5841 b (1+ b) (list 'gnus-number number
5842 'gnus-mark (or unread gnus-unread-mark)
5843 'gnus-level level))))
5845 (defun gnus-summary-update-line (&optional dont-update)
5846 ;; Update summary line after change.
5847 (or (not gnus-summary-default-score)
5848 gnus-summary-inhibit-highlight
5849 (let ((gnus-summary-inhibit-highlight t)
5850 (article (gnus-summary-article-number)))
5853 (if (and gnus-summary-mark-below
5854 (< (gnus-summary-article-score)
5855 gnus-summary-mark-below))
5856 (and (not (memq article gnus-newsgroup-marked))
5857 (not (memq article gnus-newsgroup-dormant))
5858 (memq article gnus-newsgroup-unreads)
5859 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5860 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5861 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5863 (run-hooks 'gnus-summary-update-hook))))))
5865 (defun gnus-summary-update-lines (&optional beg end)
5866 ;; Mark article as read (or not) by taking into account scores.
5867 (let ((beg (or beg (point-min)))
5868 (end (or end (point-max))))
5869 (if (or (not gnus-summary-default-score)
5870 gnus-summary-inhibit-highlight)
5872 (let ((gnus-summary-inhibit-highlight t)
5875 (set-buffer gnus-summary-buffer)
5878 (while (and (not (eobp)) (< (point) end))
5879 (if (and gnus-summary-mark-below
5881 (setq article (get-text-property
5882 (point) 'gnus-number))
5883 gnus-newsgroup-scored))
5884 gnus-summary-default-score 0)
5885 gnus-summary-mark-below))
5886 ;; We want to possibly mark it as read...
5887 (and (not (memq article gnus-newsgroup-marked))
5888 (not (memq article gnus-newsgroup-dormant))
5889 (memq article gnus-newsgroup-unreads)
5890 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5891 ;; We want to possibly mark it as unread.
5892 (and (eq (get-text-property (point) 'gnus-mark)
5893 gnus-low-score-mark)
5894 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5895 ;; Do the visual highlights at the same time.
5896 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5897 (forward-line 1)))))))
5899 (defvar gnus-tmp-gathered nil)
5901 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5902 ;; Sum up all elements (and sub-elements) in a list.
5904 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5905 (if (and (consp thread) (cdr thread))
5908 'gnus-summary-number-of-articles-in-thread
5912 (if (> number 1) gnus-not-empty-thread-mark
5913 gnus-empty-thread-mark)
5916 (defun gnus-summary-read-group
5917 (group &optional show-all no-article kill-buffer)
5918 "Start reading news in newsgroup GROUP.
5919 If SHOW-ALL is non-nil, already read articles are also listed.
5920 If NO-ARTICLE is non-nil, no article is selected initially."
5921 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5922 (let* ((new-group (gnus-summary-setup-buffer group))
5923 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5925 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5928 (gnus-set-global-variables)
5929 (gnus-kill-buffer kill-buffer)
5930 (gnus-configure-windows 'summary 'force)
5931 (gnus-set-mode-line 'summary)
5932 (gnus-summary-position-cursor)
5936 (and (eq major-mode 'gnus-summary-mode)
5937 (not (equal (current-buffer) kill-buffer))
5939 (kill-buffer (current-buffer))
5940 (if (not quit-config)
5942 (set-buffer gnus-group-buffer)
5943 (gnus-group-jump-to-group group)
5944 (gnus-group-next-unread-group 1))
5945 (if (not (buffer-name (car quit-config)))
5946 (gnus-configure-windows 'group 'force)
5947 (set-buffer (car quit-config))
5948 (and (eq major-mode 'gnus-summary-mode)
5949 (gnus-set-global-variables))
5950 (gnus-configure-windows (cdr quit-config))))))
5951 (message "Can't select group")
5953 ((eq did-select 'quit)
5954 (and (eq major-mode 'gnus-summary-mode)
5955 (not (equal (current-buffer) kill-buffer))
5956 (kill-buffer (current-buffer)))
5957 (gnus-kill-buffer kill-buffer)
5958 (if (not quit-config)
5960 (set-buffer gnus-group-buffer)
5961 (gnus-group-jump-to-group group)
5962 (gnus-group-next-unread-group 1)
5963 (gnus-configure-windows 'group 'force))
5964 (if (not (buffer-name (car quit-config)))
5965 (gnus-configure-windows 'group 'force)
5966 (set-buffer (car quit-config))
5967 (and (eq major-mode 'gnus-summary-mode)
5968 (gnus-set-global-variables))
5969 (gnus-configure-windows (cdr quit-config))))
5972 (gnus-set-global-variables)
5973 ;; Save the active value in effect when the group was entered.
5974 (setq gnus-newsgroup-active
5976 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5977 ;; You can change the subjects in this hook.
5978 (run-hooks 'gnus-select-group-hook)
5979 ;; Do score processing.
5980 (and gnus-use-scoring (gnus-possibly-score-headers))
5981 (gnus-update-format-specifications)
5982 ;; Generate the summary buffer.
5983 (gnus-summary-prepare)
5984 (if (zerop (buffer-size))
5985 (cond (gnus-newsgroup-dormant
5986 (gnus-summary-show-all-dormant))
5987 ((and gnus-newsgroup-scored show-all)
5988 (gnus-summary-show-all-expunged))))
5989 ;; Function `gnus-apply-kill-file' must be called in this hook.
5990 (run-hooks 'gnus-apply-kill-hook)
5991 (if (zerop (buffer-size))
5993 ;; This newsgroup is empty.
5994 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5995 (gnus-message 6 "No unread news")
5996 (gnus-kill-buffer kill-buffer)
6000 ;; (let ((gnus-summary-buffer kill-buffer))
6001 ;; (gnus-configure-windows 'group))))
6002 ;; Hide conversation thread subtrees. We cannot do this in
6003 ;; gnus-summary-prepare-hook since kill processing may not
6004 ;; work with hidden articles.
6005 (and gnus-show-threads
6006 gnus-thread-hide-subtree
6007 (gnus-summary-hide-all-threads))
6008 ;; Show first unread article if requested.
6009 (goto-char (point-min))
6010 (if (and (not no-article)
6011 gnus-auto-select-first
6012 (gnus-summary-first-unread-article))
6014 (gnus-configure-windows 'summary 'force))
6015 (gnus-set-mode-line 'summary)
6016 (gnus-summary-position-cursor)
6017 ;; If in async mode, we send some info to the backend.
6018 (and gnus-newsgroup-async
6019 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
6020 (gnus-request-asynchronous
6022 (if (and gnus-asynchronous-article-function
6023 (fboundp gnus-asynchronous-article-function))
6024 (funcall gnus-asynchronous-article-function
6025 gnus-newsgroup-threads)
6026 gnus-newsgroup-threads)))
6027 (gnus-kill-buffer kill-buffer)
6028 (if (not (get-buffer-window gnus-group-buffer))
6030 ;; gotta use windows, because recenter does wierd stuff if
6031 ;; the current buffer ain't the displayed window.
6032 (let ((owin (selected-window)))
6033 (select-window (get-buffer-window gnus-group-buffer))
6034 (and (gnus-group-goto-group group)
6036 (select-window owin))))
6039 (defun gnus-summary-prepare ()
6040 ;; Generate the summary buffer.
6041 (let ((buffer-read-only nil))
6043 (gnus-summary-prepare-threads
6044 (if gnus-show-threads
6045 (gnus-gather-threads
6047 (if (and gnus-summary-expunge-below
6048 (not gnus-fetch-old-headers))
6049 (gnus-make-threads-and-expunge)
6050 (gnus-make-threads))))
6051 gnus-newsgroup-headers)
6053 (gnus-summary-update-lines)
6054 ;; Create the header hashtb.
6055 (gnus-make-headers-hashtable-by-number)
6056 ;; Call hooks for modifying summary buffer.
6057 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6058 (goto-char (point-min))
6059 (run-hooks 'gnus-summary-prepare-hook)))
6061 (defun gnus-gather-threads (threads)
6062 "Gather threads that have lost their roots."
6063 (if (not gnus-summary-make-false-root)
6065 (let ((hashtb (gnus-make-hashtable 1023))
6068 subject hthread whole-subject)
6071 (setq subject (mail-header-subject (car (car threads)))))
6072 (if gnus-summary-gather-subject-limit
6073 (or (and (numberp gnus-summary-gather-subject-limit)
6074 (> (length subject) gnus-summary-gather-subject-limit)
6076 (substring subject 0
6077 gnus-summary-gather-subject-limit)))
6078 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6079 (setq subject (gnus-simplify-subject-fuzzy subject))))
6080 (setq subject (gnus-simplify-subject-re subject)))
6082 (gnus-gethash subject hashtb))
6084 (or (stringp (car (car hthread)))
6085 (setcar hthread (list whole-subject (car hthread))))
6086 (setcdr (car hthread) (nconc (cdr (car hthread))
6087 (list (car threads))))
6088 (setcdr prev (cdr threads))
6089 (setq threads prev))
6090 (gnus-sethash subject threads hashtb))
6092 (setq threads (cdr threads)))
6095 (defun gnus-make-threads ()
6096 ;; This function takes the dependencies already made by
6097 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6098 ;; through the dependecies in the hash table and finds all the
6099 ;; roots. Roots do not refer back to any valid articles.
6100 (gnus-message 6 "Threading...")
6101 (let (roots new-roots)
6102 (and gnus-fetch-old-headers
6103 (eq gnus-headers-retrieved-by 'nov)
6104 (gnus-build-old-threads))
6107 (if (not (car (symbol-value refs)))
6108 (setq roots (append (cdr (symbol-value refs)) roots))
6109 ;; Ok, these refer back to valid articles, but if
6110 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6111 ;; the root has the same subject as its children. The children
6112 ;; that do not are made into roots and removed from the list
6114 (or gnus-thread-ignore-subject
6115 (let* ((prev (symbol-value refs))
6116 (subject (gnus-simplify-subject-re
6117 (mail-header-subject (car prev))))
6118 (headers (cdr prev)))
6120 (if (not (string= subject
6121 (gnus-simplify-subject-re
6122 (mail-header-subject (car headers)))))
6124 (setq new-roots (cons (car headers) new-roots))
6125 (setcdr prev (cdr headers)))
6126 (setq prev headers))
6127 (setq headers (cdr headers)))))))
6128 gnus-newsgroup-dependencies)
6130 ;; We enter the new roots into the dependencies structure to
6131 ;; ensure that any possible later thread-regeneration will be
6133 (let ((r new-roots))
6135 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6136 (list nil (car r)) gnus-newsgroup-dependencies)
6139 (setq roots (nconc new-roots roots))
6142 (mapcar 'gnus-trim-thread
6144 (mapcar 'gnus-cut-thread
6145 (mapcar 'gnus-make-sub-thread roots))))
6146 (gnus-message 6 "Threading...done"))))
6149 (defun gnus-make-threads-and-expunge ()
6150 ;; This function takes the dependencies already made by
6151 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6152 ;; through the dependecies in the hash table and finds all the
6153 ;; roots. Roots do not refer back to any valid articles.
6154 (gnus-message 6 "Threading...")
6155 (let ((default (or gnus-summary-default-score 0))
6156 (below gnus-summary-expunge-below)
6157 roots article new-roots)
6158 (and gnus-fetch-old-headers
6159 (eq gnus-headers-retrieved-by 'nov)
6160 (gnus-build-old-threads))
6163 (if (not (car (symbol-value refs)))
6164 ;; These articles do not refer back to any other articles -
6166 (let ((headers (cdr (symbol-value refs))))
6167 ;; We weed out the low-scored articles.
6169 (if (not (< (or (cdr (assq (mail-header-number (car headers))
6170 gnus-newsgroup-scored)) default)
6173 (setq roots (cons (car headers) roots))
6174 ;; It is below, so we mark it as read.
6175 (setq gnus-newsgroup-unreads
6176 (delq (mail-header-number (car headers))
6177 gnus-newsgroup-unreads))
6178 (setq gnus-newsgroup-reads
6179 (cons (cons (mail-header-number (car headers))
6180 gnus-low-score-mark)
6181 gnus-newsgroup-reads)))
6182 (setq headers (cdr headers))))
6183 ;; Ok, these refer back to valid articles, but if
6184 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6185 ;; the root has the same subject as its children. The children
6186 ;; that do not are made into roots and removed from the list
6188 (or gnus-thread-ignore-subject
6189 (let* ((prev (symbol-value refs))
6190 (subject (gnus-simplify-subject-re
6191 (mail-header-subject (car prev))))
6192 (headers (cdr prev)))
6194 (if (not (string= subject
6195 (gnus-simplify-subject-re
6196 (mail-header-subject (car headers)))))
6198 (if (not (< (or (cdr (assq (mail-header-number
6200 gnus-newsgroup-scored))
6202 (setq new-roots (cons (car headers) new-roots))
6203 (setq gnus-newsgroup-unreads
6204 (delq (mail-header-number (car headers))
6205 gnus-newsgroup-unreads))
6206 (setq gnus-newsgroup-reads
6207 (cons (cons (mail-header-number (car headers))
6208 gnus-low-score-mark)
6209 gnus-newsgroup-reads)))
6210 (setcdr prev (cdr headers)))
6211 (setq prev headers))
6212 (setq headers (cdr headers)))))
6213 ;; If this article is expunged, some of the children might be
6215 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs)))
6216 gnus-newsgroup-scored)) default)
6218 (let* ((prev (symbol-value refs))
6219 (headers (cdr prev)))
6221 (setq article (mail-header-number (car headers)))
6222 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6224 (progn (setq new-roots (cons (car headers) new-roots))
6225 (setq prev headers))
6226 (setq gnus-newsgroup-unreads
6227 (delq article gnus-newsgroup-unreads))
6228 (setq gnus-newsgroup-reads
6229 (cons (cons article gnus-low-score-mark)
6230 gnus-newsgroup-reads))
6231 (setcdr prev (cdr headers)))
6232 (setq headers (cdr headers))))
6233 ;; It was not expunged, but we look at expunged children.
6234 (let* ((prev (symbol-value refs))
6235 (headers (cdr prev))
6238 (setq article (mail-header-number (car headers)))
6239 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6242 (setq gnus-newsgroup-unreads
6243 (delq article gnus-newsgroup-unreads))
6244 (setq gnus-newsgroup-reads
6245 (cons (cons article gnus-low-score-mark)
6246 gnus-newsgroup-reads))
6247 (setcdr prev (cdr headers)))
6248 (setq headers (cdr headers)))))))
6249 gnus-newsgroup-dependencies)
6251 ;; We enter the new roots into the dependencies structure to
6252 ;; ensure that any possible later thread-regeneration will be
6254 (let ((r new-roots))
6256 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6257 (list nil (car r)) gnus-newsgroup-dependencies)
6260 (setq roots (nconc new-roots roots))
6263 (mapcar 'gnus-trim-thread
6265 (mapcar 'gnus-cut-thread
6266 (mapcar 'gnus-make-sub-thread roots))))
6267 (gnus-message 6 "Threading...done"))))
6270 (defun gnus-cut-thread (thread)
6271 ;; Remove leaf dormant or ancient articles from THREAD.
6272 (let ((head (car thread))
6273 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6274 (if (and (null tail)
6275 (let ((number (mail-header-number head)))
6276 (or (memq number gnus-newsgroup-ancient)
6277 (memq number gnus-newsgroup-dormant)
6278 (and gnus-summary-expunge-below
6279 (eq gnus-fetch-old-headers 'some)
6280 (< (or (cdr (assq number gnus-newsgroup-scored))
6281 gnus-summary-default-score 0)
6282 gnus-summary-expunge-below)
6284 (setq gnus-newsgroup-unreads
6285 (delq number gnus-newsgroup-unreads))
6286 (setq gnus-newsgroup-reads
6287 (cons (cons number gnus-low-score-mark)
6288 gnus-newsgroup-reads))
6291 (list (cons head tail)))))
6293 (defun gnus-trim-thread (thread)
6294 ;; Remove root ancient articles with only one child from THREAD.
6295 (if (and (eq gnus-fetch-old-headers 'some)
6296 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6297 (= (length thread) 2))
6298 (gnus-trim-thread (nth 1 thread))
6301 (defun gnus-make-sub-thread (root)
6302 ;; This function makes a sub-tree for a node in the tree.
6303 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6304 gnus-newsgroup-dependencies)))))
6305 (cons root (mapcar 'gnus-make-sub-thread children))))
6307 (defun gnus-build-old-threads ()
6308 ;; Look at all the articles that refer back to old articles, and
6309 ;; fetch the headers for the articles that aren't there. This will
6310 ;; build complete threads - if the roots haven't been expired by the
6315 (if (not (car (symbol-value refs)))
6317 (setq heads (cdr (symbol-value refs)))
6319 (if (not (memq (mail-header-number (car heads))
6320 gnus-newsgroup-dormant))
6322 (setq id (symbol-name refs))
6323 (while (and (setq id (gnus-build-get-header id))
6324 (not (car (gnus-gethash
6325 id gnus-newsgroup-dependencies)))))
6327 (setq heads (cdr heads)))))))
6328 gnus-newsgroup-dependencies)))
6330 (defun gnus-build-get-header (id)
6331 ;; Look through the buffer of NOV lines and find the header to
6332 ;; ID. Enter this line into the dependencies hash table, and return
6333 ;; the id of the parent article (if any).
6334 (let ((deps gnus-newsgroup-dependencies)
6338 (set-buffer nntp-server-buffer)
6339 (goto-char (point-min))
6340 (while (and (not found) (search-forward id nil t))
6342 (setq found (looking-at
6343 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6344 (regexp-quote id))))
6345 (or found (beginning-of-line 2)))
6350 (setq header (gnus-nov-parse-line
6351 (read (current-buffer)) deps))
6352 (setq ref (mail-header-references header))
6353 (string-match "\\(<[^>]+>\\) *$" ref)
6354 (substring ref (match-beginning 1) (match-end 1))))))
6356 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6357 gnus-newsgroup-ancient (cons (mail-header-number header)
6358 gnus-newsgroup-ancient))))))
6360 ;; Re-build the thread containing ID.
6361 (defun gnus-rebuild-thread (id)
6362 (let ((dep gnus-newsgroup-dependencies)
6363 (buffer-read-only nil)
6364 parent headers refs thread art)
6365 (while (and id (setq headers
6366 (car (setq art (gnus-gethash (downcase id) dep)))))
6368 (setq id (and (setq refs (mail-header-references headers))
6369 (string-match "\\(<[^>]+>\\) *$" refs)
6370 (substring refs (match-beginning 1) (match-end 1)))))
6371 (setq thread (gnus-make-sub-thread (car parent)))
6372 (gnus-rebuild-remove-articles thread)
6373 (let ((beg (point)))
6374 (gnus-summary-prepare-threads (list thread))
6375 (gnus-summary-update-lines beg (point)))))
6377 ;; Delete all lines in the summary buffer that correspond to articles
6379 (defun gnus-rebuild-remove-articles (thread)
6380 (and (gnus-summary-goto-subject (mail-header-number (car thread)))
6382 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6384 (defun gnus-sort-threads (threads)
6385 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6386 (let ((fun gnus-thread-sort-functions))
6388 (gnus-message 6 "Sorting with %S..." fun)
6389 (setq threads (sort threads (car fun))
6391 (if gnus-thread-sort-functions
6392 (gnus-message 6 "Sorting...done"))
6395 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6396 (defmacro gnus-thread-header (thread)
6397 ;; Return header of first article in THREAD.
6398 ;; Note that THREAD must never, evr be anything else than a variable -
6399 ;; using some other form will lead to serious barfage.
6400 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6401 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6402 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6405 (defun gnus-thread-sort-by-number (h1 h2)
6406 "Sort threads by root article number."
6407 (< (mail-header-number (gnus-thread-header h1))
6408 (mail-header-number (gnus-thread-header h2))))
6410 (defun gnus-thread-sort-by-author (h1 h2)
6411 "Sort threads by root author."
6413 (let ((extract (funcall
6414 gnus-extract-address-components
6415 (mail-header-from (gnus-thread-header h1)))))
6416 (or (car extract) (cdr extract)))
6417 (let ((extract (funcall
6418 gnus-extract-address-components
6419 (mail-header-from (gnus-thread-header h2)))))
6420 (or (car extract) (cdr extract)))))
6422 (defun gnus-thread-sort-by-subject (h1 h2)
6423 "Sort threads by root subject."
6425 (downcase (gnus-simplify-subject-re
6426 (mail-header-subject (gnus-thread-header h1))))
6427 (downcase (gnus-simplify-subject-re
6428 (mail-header-subject (gnus-thread-header h2))))))
6430 (defun gnus-thread-sort-by-date (h1 h2)
6431 "Sort threads by root article date."
6433 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6434 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6436 (defun gnus-thread-sort-by-score (h1 h2)
6437 "Sort threads by root article score.
6438 Unscored articles will be counted as having a score of zero."
6439 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6440 gnus-newsgroup-scored))
6441 gnus-summary-default-score 0)
6442 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6443 gnus-newsgroup-scored))
6444 gnus-summary-default-score 0)))
6446 (defun gnus-thread-sort-by-total-score (h1 h2)
6447 "Sort threads by the sum of all scores in the thread.
6448 Unscored articles will be counted as having a score of zero."
6449 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6451 (defun gnus-thread-total-score (thread)
6452 ;; This function find the total score of THREAD.
6454 (if (stringp (car thread))
6455 (apply gnus-thread-score-function 0
6456 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6457 (gnus-thread-total-score-1 thread))
6458 (gnus-thread-total-score-1 (list thread))))
6460 (defun gnus-thread-total-score-1 (root)
6461 ;; This function find the total score of the thread below ROOT.
6462 (setq root (car root))
6463 (apply gnus-thread-score-function
6464 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6465 gnus-summary-default-score 0)
6466 (mapcar 'gnus-thread-total-score
6467 (cdr (gnus-gethash (downcase (mail-header-id root))
6468 gnus-newsgroup-dependencies)))))
6470 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6471 (defvar gnus-tmp-prev-subject "")
6473 (defun gnus-summary-prepare-threads (threads &optional cull)
6474 "Prepare summary buffer from THREADS and indentation LEVEL.
6475 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6476 or a straight list of headers."
6477 (message "Generating summary...")
6479 thread header number subject stack state gnus-tmp-gathered)
6480 (if (vectorp (car threads))
6481 ;; If this is a straight (sic) list of headers, then a
6482 ;; threaded summary display isn't required, so we just create
6483 ;; an unthreaded one.
6484 (gnus-summary-prepare-unthreaded threads cull)
6486 ;; Do the threaded display.
6488 (while (or threads stack)
6491 ;; If there are some threads, we do them before the
6492 ;; threads on the stack.
6493 (setq thread threads
6494 header (car (car thread)))
6495 ;; There were no current threads, so we pop something off
6497 (setq state (car stack)
6501 header (car (car thread))))
6503 (if (stringp header)
6505 ;; The header is a dummy root.
6507 ((eq gnus-summary-make-false-root 'adopt)
6508 ;; We let the first article adopt the rest.
6509 (let ((th (car (cdr (car thread)))))
6512 (setcdr th (cdr (cdr (car thread))))
6513 (setq gnus-tmp-gathered
6515 (lambda (h) (mail-header-number (car h)))
6516 (cdr (cdr (car thread))))
6518 (setcdr (cdr (car thread)) nil))
6520 ((eq gnus-summary-make-false-root 'empty)
6521 ;; We print adopted articles with empty subject fields.
6522 (setq gnus-tmp-gathered
6524 (lambda (h) (mail-header-number (car h)))
6525 (cdr (cdr (car thread))))
6528 ((eq gnus-summary-make-false-root 'dummy)
6529 ;; We output a dummy root.
6530 (gnus-summary-insert-dummy-line
6531 nil header (mail-header-number
6532 (car (car (cdr (car thread)))))))
6534 ;; We do not make a root for the gathered
6535 ;; sub-threads at all.
6538 (setq number (mail-header-number header)
6539 subject (mail-header-subject header))
6541 ;; Do the async thing.
6542 (and gnus-newsgroup-async
6543 (setq gnus-newsgroup-threads
6544 (cons (cons number (mail-header-lines header))
6545 gnus-newsgroup-threads)))
6547 ;; We may have to root out some bad articles...
6550 (cond ((and (memq (setq number (mail-header-number header))
6551 gnus-newsgroup-dormant)
6554 ((and gnus-summary-expunge-below
6555 (< (or (cdr (assq number gnus-newsgroup-scored))
6556 gnus-summary-default-score 0)
6557 gnus-summary-expunge-below))
6559 (setq gnus-newsgroup-unreads
6560 (delq number gnus-newsgroup-unreads))
6561 (setq gnus-newsgroup-reads
6562 (cons (cons number gnus-low-score-mark)
6563 gnus-newsgroup-reads)))))
6569 (gnus-summary-insert-line
6570 nil header level nil
6572 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6573 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6574 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6575 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6576 (t (or (cdr (assq number gnus-newsgroup-reads))
6577 gnus-ancient-mark)))
6578 (memq number gnus-newsgroup-replied)
6579 (memq number gnus-newsgroup-expirable)
6581 ((and gnus-thread-ignore-subject
6583 (gnus-simplify-subject-re gnus-tmp-prev-subject)
6584 (gnus-simplify-subject-re subject))))
6587 (if (and (eq gnus-summary-make-false-root 'empty)
6588 (memq number gnus-tmp-gathered))
6589 gnus-summary-same-subject
6591 (t gnus-summary-same-subject))
6592 (and (eq gnus-summary-make-false-root 'adopt)
6593 (memq number gnus-tmp-gathered))
6594 (cdr (assq number gnus-newsgroup-scored))
6595 (memq number gnus-newsgroup-processable))
6597 (setq gnus-tmp-prev-subject subject)))))
6600 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6601 (setq level (1+ level))
6602 (setq threads (cdr (car thread))))))
6603 (message "Generating summary...done"))
6607 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6608 (let (header number)
6610 ;; Do the async thing, if that is required.
6611 (if gnus-newsgroup-async
6612 (setq gnus-newsgroup-threads
6614 (cons (mail-header-number h) (mail-header-lines h)))
6618 (setq header (car headers)
6619 headers (cdr headers)
6620 number (mail-header-number header))
6622 ;; We may have to root out some bad articles...
6625 (memq (setq number (mail-header-number header))
6626 gnus-newsgroup-dormant)))
6627 ((and cull gnus-summary-expunge-below
6628 (< (or (cdr (assq number gnus-newsgroup-scored))
6629 gnus-summary-default-score 0)
6630 gnus-summary-expunge-below))
6631 (setq gnus-newsgroup-unreads
6632 (delq number gnus-newsgroup-unreads))
6633 (setq gnus-newsgroup-reads
6634 (cons (cons number gnus-low-score-mark)
6635 gnus-newsgroup-reads)))
6637 (gnus-summary-insert-line
6639 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6640 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6641 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6642 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6643 (t (or (cdr (assq number gnus-newsgroup-reads))
6644 gnus-ancient-mark)))
6645 (memq number gnus-newsgroup-replied)
6646 (memq number gnus-newsgroup-expirable)
6647 (mail-header-subject header) nil
6648 (cdr (assq number gnus-newsgroup-scored))
6649 (memq number gnus-newsgroup-processable)))))))
6651 (defun gnus-select-newsgroup (group &optional read-all)
6652 "Select newsgroup GROUP.
6653 If READ-ALL is non-nil, all articles in the group are selected."
6654 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6655 (info (nth 2 entry))
6658 (or (gnus-check-server
6659 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6660 (error "Couldn't open server"))
6662 (or (and entry (not (eq (car entry) t))) ; Either it's active...
6663 (gnus-activate-group group) ; Or we can activate it...
6664 (progn ; Or we bug out.
6665 (kill-buffer (current-buffer))
6666 (error "Couldn't request group %s: %s"
6667 group (gnus-status-message group))))
6669 (setq gnus-newsgroup-name group)
6670 (setq gnus-newsgroup-unselected nil)
6671 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6673 (and gnus-asynchronous
6674 (gnus-check-backend-function
6675 'request-asynchronous gnus-newsgroup-name)
6676 (setq gnus-newsgroup-async
6677 (gnus-request-asynchronous gnus-newsgroup-name)))
6679 (setq articles (gnus-articles-to-read group read-all))
6683 (gnus-message 3 "Couldn't select newsgroup")
6685 ((eq articles 0) nil)
6687 ;; Init the dependencies hash table.
6688 (setq gnus-newsgroup-dependencies
6689 (gnus-make-hashtable (length articles)))
6690 ;; Retrieve the headers and read them in.
6691 (gnus-message 5 "Fetching headers...")
6692 (setq gnus-newsgroup-headers
6693 (if (eq 'nov (setq gnus-headers-retrieved-by
6694 ;; This is a naughty hack. To get the
6695 ;; retrieval of old headers to work, we
6696 ;; set `nntp-nov-gap' to nil (locally),
6697 ;; and then just retrieve the headers.
6699 (if gnus-fetch-old-headers
6701 (gnus-retrieve-headers
6702 (if (not (eq 1 (car articles)))
6705 gnus-newsgroup-name))
6706 (gnus-retrieve-headers
6707 articles gnus-newsgroup-name))))
6709 (gnus-get-newsgroup-headers-xover articles))
6710 ;; If we were to fetch old headers, but the backend didn't
6711 ;; support XOVER, then it is possible we fetched one article
6712 ;; that we shouldn't have. If that's the case, we remove it.
6713 (if (or (not gnus-fetch-old-headers)
6714 (eq 1 (car articles)))
6717 (set-buffer nntp-server-buffer)
6718 (goto-char (point-min))
6720 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6721 (delete-region ; So we delete this head.
6723 (search-forward "\n.\n" nil t)))))
6724 (gnus-get-newsgroup-headers)))
6725 (gnus-message 5 "Fetching headers...done")
6726 ;; Remove canceled articles from the list of unread articles.
6727 (setq gnus-newsgroup-unreads
6728 (gnus-set-sorted-intersection
6729 gnus-newsgroup-unreads
6730 (mapcar (lambda (headers) (mail-header-number headers))
6731 gnus-newsgroup-headers)))
6732 ;; Adjust and set lists of article marks.
6735 (gnus-adjust-marked-articles info)
6736 (setq gnus-newsgroup-marked
6738 (cdr (assq 'tick (setq marked (nth 3 info))))))
6739 (setq gnus-newsgroup-replied
6740 (copy-sequence (cdr (assq 'reply marked))))
6741 (setq gnus-newsgroup-expirable
6742 (copy-sequence (cdr (assq 'expire marked))))
6743 (setq gnus-newsgroup-killed
6744 (copy-sequence (cdr (assq 'killed marked))))
6745 (setq gnus-newsgroup-bookmarks
6746 (copy-sequence (cdr (assq 'bookmark marked))))
6747 (setq gnus-newsgroup-dormant
6748 (copy-sequence (cdr (assq 'dormant marked))))
6749 (setq gnus-newsgroup-scored
6750 (copy-sequence (cdr (assq 'score marked))))
6751 (setq gnus-newsgroup-processable nil)))
6752 ;; Check whether auto-expire is to be done in this group.
6753 (setq gnus-newsgroup-auto-expire
6754 (or (and (stringp gnus-auto-expirable-newsgroups)
6755 (string-match gnus-auto-expirable-newsgroups group))
6756 (memq 'auto-expire (nth 5 info))))
6757 ;; First and last article in this newsgroup.
6758 (and gnus-newsgroup-headers
6759 (setq gnus-newsgroup-begin
6760 (mail-header-number (car gnus-newsgroup-headers)))
6761 (setq gnus-newsgroup-end
6763 (gnus-last-element gnus-newsgroup-headers))))
6764 (setq gnus-reffed-article-number -1)
6765 ;; GROUP is successfully selected.
6766 (or gnus-newsgroup-headers t)))))
6768 (defun gnus-articles-to-read (group read-all)
6769 ;; Find out what articles the user wants to read.
6771 ;; Select all articles if `read-all' is non-nil, or if all the
6772 ;; unread articles are dormant articles.
6773 (if (or (and read-all (not (numberp read-all)))
6774 (= (length gnus-newsgroup-unreads)
6775 (length gnus-newsgroup-dormant)))
6776 (gnus-uncompress-range
6777 (gnus-gethash group gnus-active-hashtb))
6778 gnus-newsgroup-unreads))
6779 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6780 (scored (length scored-list))
6781 (number (length articles))
6782 (marked (+ (length gnus-newsgroup-marked)
6783 (length gnus-newsgroup-dormant)))
6790 (cond ((and (or (<= scored marked)
6792 (numberp gnus-large-newsgroup)
6793 (> number gnus-large-newsgroup))
6797 "How many articles from %s (default %d): "
6798 gnus-newsgroup-name number))))
6799 (if (string-match "^[ \t]*$" input)
6801 ((and (> scored marked) (< scored number))
6805 "%s %s (%d scored, %d total): "
6806 "How many articles from"
6807 group scored number))))
6808 (if (string-match "^[ \t]*$" input)
6812 (setq select (if (stringp select) (string-to-number select) select))
6813 (if (or (null select) (zerop select))
6815 (if (and (not (zerop scored)) (<= (abs select) scored))
6817 (setq articles (sort scored-list '<))
6818 (setq number (length articles)))
6819 (setq articles (copy-sequence articles)))
6821 (if (< (abs select) number)
6823 ;; Select the N oldest articles.
6824 (setcdr (nthcdr (1- (abs select)) articles) nil)
6825 ;; Select the N most recent articles.
6826 (setq articles (nthcdr (- number select) articles))))
6827 (setq gnus-newsgroup-unselected
6828 (gnus-sorted-intersection
6829 gnus-newsgroup-unreads
6830 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6833 (defun gnus-killed-articles (killed articles)
6836 (if (inline (gnus-member-of-range (car articles) killed))
6837 (setq out (cons (car articles) out)))
6838 (setq articles (cdr articles)))
6841 (defun gnus-adjust-marked-articles (info &optional active)
6842 "Remove all marked articles that are no longer legal."
6843 (let ((marked-lists (nth 3 info))
6844 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6846 ;; There are many types of marked articles.
6848 (setq m (cdr (setq prev (car marked-lists))))
6849 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6850 ;; Make sure that all ticked articles are a subset of the
6851 ;; unread/unselected articles.
6853 (if (or (memq (car m) gnus-newsgroup-unreads)
6854 (memq (car m) gnus-newsgroup-unselected))
6856 (setcdr prev (cdr m)))
6858 ((eq 'score (car prev))
6859 ;; Scored articles should be a subset of
6860 ;; unread/unselected articles.
6862 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6863 (memq (car (car m)) gnus-newsgroup-unreads))
6865 (setcdr prev (cdr m)))
6867 ((eq 'bookmark (car prev))
6868 ;; Bookmarks should be a subset of active articles.
6870 (if (< (car (car m)) (car active))
6871 (setcdr prev (cdr m))
6874 ((eq 'killed (car prev))
6875 ;; Articles that have been through the kill process are
6876 ;; to be a subset of active articles.
6877 (while (and m (< (or (and (numberp (car m)) (car m))
6880 (setcdr prev (cdr m))
6882 (if (and m (< (or (and (numberp (car m)) (car m))
6885 (setcar (if (numberp (car m)) m (car m)) (car active))))
6886 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6887 ;; The replied and expirable articles have to be articles
6890 (if (< (car m) (car active))
6891 (setcdr prev (cdr m))
6894 (setq marked-lists (cdr marked-lists)))
6895 ;; Remove all lists that are empty.
6896 (setq marked-lists (nth 3 info))
6899 (while (= 1 (length (car marked-lists)))
6900 (setq marked-lists (cdr marked-lists)))
6901 (setq m (cdr (setq prev marked-lists)))
6903 (if (= 1 (length (car m)))
6904 (setcdr prev (cdr m))
6907 (setcar (nthcdr 3 info) marked-lists)))
6908 ;; Finally, if there are no marked lists at all left, and if there
6909 ;; are no elements after the lists in the info list, we just chop
6910 ;; the info list off before the marked lists.
6911 (and (null marked-lists)
6912 (not (nthcdr 4 info))
6913 (setcdr (nthcdr 2 info) nil)))
6916 (defun gnus-set-marked-articles
6917 (info ticked replied expirable killed dormant bookmark score)
6918 "Enter the various lists of marked articles into the newsgroup info list."
6920 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6921 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6922 (and expirable (setq newmarked (cons (cons 'expire expirable)
6924 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6925 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6926 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6928 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6931 (setcar (nthcdr 3 info) newmarked)
6932 (and (not newmarked)
6933 (not (nthcdr 4 info))
6934 (setcdr (nthcdr 2 info) nil)))
6936 (setcdr (nthcdr 2 info) (list newmarked))))))
6938 (defun gnus-add-marked-articles (group type articles &optional info force)
6939 ;; Add ARTICLES of TYPE to the info of GROUP.
6940 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6941 ;; add, but replace marked articles of TYPE with ARTICLES.
6942 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6945 (and (not (setq marked (nthcdr 3 info)))
6946 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6947 (and (not (setq m (assq type (car marked))))
6948 (setcar marked (cons (cons type articles) (car marked))))
6951 (nconc m articles)))))
6953 (defun gnus-set-mode-line (where)
6954 "This function sets the mode line of the article or summary buffers.
6955 If WHERE is `summary', the summary mode line format will be used."
6956 (if (memq where gnus-updated-mode-lines)
6959 (set-buffer gnus-summary-buffer)
6960 (let* ((mformat (if (eq where 'article)
6961 gnus-article-mode-line-format-spec
6962 gnus-summary-mode-line-format-spec))
6963 (group-name gnus-newsgroup-name)
6964 (article-number (or gnus-current-article 0))
6965 (unread (- (length gnus-newsgroup-unreads)
6966 (length gnus-newsgroup-dormant)))
6967 (unread-and-unticked
6968 (- unread (length gnus-newsgroup-marked)))
6969 (unselected (length gnus-newsgroup-unselected))
6970 (unread-and-unselected
6971 (cond ((and (zerop unread-and-unticked)
6972 (zerop unselected)) "")
6974 (format "{%d more}" unread-and-unticked))
6975 (t (format "{%d(+%d) more}"
6976 unread-and-unticked unselected))))
6978 (if gnus-current-headers
6979 (mail-header-subject gnus-current-headers) ""))
6980 (max-len (and gnus-mode-non-string-length
6981 (- (frame-width) gnus-mode-non-string-length)))
6982 header);; passed as argument to any user-format-funcs
6983 (setq mode-string (eval mformat))
6984 (or (numberp max-len)
6985 (setq max-len (length mode-string)))
6986 (if (< max-len 4) (setq max-len 4))
6987 (if (> (length mode-string) max-len)
6988 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6989 ;; function `substring' might cut on a middle
6990 ;; of multi-octet character.
6992 (concat (gnus-truncate-string mode-string (- max-len 3))
6994 (setq mode-string (format (format "%%-%ds" max-len)
6996 (setq mode-line-buffer-identification mode-string)
6997 (set-buffer-modified-p t))))
6999 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
7000 "Go through the HEADERS list and add all Xrefs to a hash table.
7001 The resulting hash table is returned, or nil if no Xrefs were found."
7002 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
7004 (gnus-group-foreign-p from-newsgroup)
7006 (assoc (symbol-name (car from-method))
7007 gnus-valid-select-methods))))
7008 (gnus-group-real-prefix from-newsgroup)))
7009 (xref-hashtb (make-vector 63 0))
7010 start group entry number xrefs header)
7012 (setq header (car headers))
7013 (if (and (setq xrefs (mail-header-xref header))
7014 (not (memq (mail-header-number header) unreads)))
7017 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
7018 (setq start (match-end 0))
7019 (setq group (concat prefix (substring xrefs (match-beginning 1)
7022 (string-to-int (substring xrefs (match-beginning 2)
7024 (if (setq entry (gnus-gethash group xref-hashtb))
7025 (setcdr entry (cons number (cdr entry)))
7026 (gnus-sethash group (cons number nil) xref-hashtb)))))
7027 (setq headers (cdr headers)))
7028 (if start xref-hashtb nil)))
7030 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
7031 "Look through all the headers and mark the Xrefs as read."
7032 (let ((virtual (memq 'virtual
7033 (assoc (symbol-name (car (gnus-find-method-for-group
7035 gnus-valid-select-methods)))
7036 name entry info xref-hashtb idlist method
7039 (set-buffer gnus-group-buffer)
7040 (if (setq xref-hashtb
7041 (gnus-create-xref-hashtb from-newsgroup headers unreads))
7044 (if (string= from-newsgroup (setq name (symbol-name group)))
7046 (setq idlist (symbol-value group))
7047 ;; Dead groups are not updated.
7049 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7051 (if (stringp (setq nth4 (nth 4 info)))
7052 (setq nth4 (gnus-server-to-method nth4))))
7053 ;; Only do the xrefs if the group has the same
7054 ;; select method as the group we have just read.
7055 (or (gnus-methods-equal-p
7056 nth4 (gnus-find-method-for-group from-newsgroup))
7059 (setq method (gnus-find-method-for-group
7061 (and (equal (car nth4) (car method))
7062 (equal (nth 1 nth4) (nth 1 method))))
7063 gnus-use-cross-reference
7064 (or (not (eq gnus-use-cross-reference t))
7066 ;; Only do cross-references on subscribed
7067 ;; groups, if that is what is wanted.
7068 (<= (nth 1 info) gnus-level-subscribed)))
7069 (gnus-group-make-articles-read name idlist expirable))))
7072 (defun gnus-group-make-articles-read (group articles expirable)
7074 (entry (gnus-gethash group gnus-newsrc-hashtb))
7075 (info (nth 2 entry))
7076 (active (gnus-gethash group gnus-active-hashtb))
7077 exps expirable range)
7078 ;; First peel off all illegal article numbers.
7080 (let ((ids articles)
7081 (ticked (cdr (assq 'tick (nth 3 info))))
7082 (dormant (cdr (assq 'dormant (nth 3 info))))
7087 (if (and first (> id (cdr active)))
7089 ;; We'll end up in this situation in one particular
7090 ;; obscure situation. If you re-scan a group and get
7091 ;; a new article that is cross-posted to a different
7092 ;; group that has not been re-scanned, you might get
7093 ;; crossposted article that has a higher number than
7094 ;; Gnus believes possible. So we re-activate this
7095 ;; group as well. This might mean doing the
7096 ;; crossposting thingie will *increase* the number
7097 ;; of articles in some groups. Tsk, tsk.
7098 (setq active (or (gnus-activate-group group) active))))
7099 (if (or (> id (cdr active))
7103 (setq articles (delq id articles)))
7104 (and (memq id expirable)
7105 (setq exps (cons id exps)))
7106 (setq ids (cdr ids)))))
7107 ;; Update expirable articles.
7108 (gnus-add-marked-articles nil 'expirable exps info)
7112 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7113 (setcar (nthcdr 2 info)
7117 (setq articles (sort articles '<)))))
7118 ;; Then we have to re-compute how many unread
7119 ;; articles there are in this group.
7124 (setq num (- (1+ (cdr active)) (car active))))
7125 ((not (listp (cdr range)))
7126 (setq num (- (cdr active) (- (1+ (cdr range))
7130 (if (numberp (car range))
7132 (setq num (+ num (- (1+ (cdr (car range)))
7133 (car (car range))))))
7134 (setq range (cdr range)))
7135 (setq num (- (cdr active) num))))
7136 ;; Update the number of unread articles.
7140 (length (cdr (assq 'tick (nth 3 info))))
7142 (cdr (assq 'dormant (nth 3 info)))))))
7143 ;; Update the group buffer.
7144 (gnus-group-update-group group t)))))
7146 (defun gnus-methods-equal-p (m1 m2)
7147 (let ((m1 (or m1 gnus-select-method))
7148 (m2 (or m2 gnus-select-method)))
7150 (and (eq (car m1) (car m2))
7151 (or (not (memq 'address (assoc (symbol-name (car m1))
7152 gnus-valid-select-methods)))
7153 (equal (nth 1 m1) (nth 1 m2)))))))
7155 (defsubst gnus-header-value ()
7156 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7158 (defvar gnus-newsgroup-none-id 0)
7160 (defun gnus-get-newsgroup-headers ()
7161 (setq gnus-article-internal-prepare-hook nil)
7162 (let ((cur nntp-server-buffer)
7163 (dependencies gnus-newsgroup-dependencies)
7164 headers id dep end ref)
7166 (set-buffer nntp-server-buffer)
7167 (goto-char (point-min))
7168 ;; Search to the beginning of the next header. Error messages
7169 ;; do not begin with 2 or 3.
7170 (while (re-search-forward "^[23][0-9]+ " nil t)
7171 (let ((header (make-vector 9 nil))
7172 (case-fold-search t)
7177 (mail-header-set-number header (read cur))
7178 ;; This implementation of this function, with nine
7179 ;; search-forwards instead of the one re-search-forward and
7180 ;; a case (which basically was the old function) is actually
7181 ;; about twice as fast, even though it looks messier. You
7182 ;; can't have everything, I guess. Speed and elegance
7183 ;; doesn't always come hand in hand.
7185 (narrow-to-region (point) (or (save-excursion
7186 (search-forward "\n.\n" nil t))
7188 (if (search-forward "\nfrom: " nil t)
7189 (mail-header-set-from header (gnus-header-value))
7190 (mail-header-set-from header "(nobody)"))
7192 (if (search-forward "\nsubject: " nil t)
7193 (mail-header-set-subject header (gnus-header-value))
7194 (mail-header-set-subject header "(none)"))
7196 (and (search-forward "\nxref: " nil t)
7197 (mail-header-set-xref header (gnus-header-value)))
7199 (or (numberp (and (search-forward "\nlines: " nil t)
7200 (mail-header-set-lines header (read cur))))
7201 (mail-header-set-lines header 0))
7203 (and (search-forward "\ndate: " nil t)
7204 (mail-header-set-date header (gnus-header-value)))
7206 (if (search-forward "\nmessage-id: " nil t)
7207 (mail-header-set-id header (setq id (gnus-header-value)))
7208 ;; If there was no message-id, we just fake one to make
7209 ;; subsequent routines simpler.
7212 (setq id (concat "none+"
7214 (setq gnus-newsgroup-none-id
7215 (1+ gnus-newsgroup-none-id)))))))
7217 (if (search-forward "\nreferences: " nil t)
7219 (mail-header-set-references header (gnus-header-value))
7220 (setq end (match-end 0))
7227 (search-backward ">" end t)
7230 (search-backward "<" end t)
7232 ;; Get the references from the in-reply-to header if there
7233 ;; ware no references and the in-reply-to header looks
7235 (if (and (search-forward "\nin-reply-to: " nil t)
7236 (setq in-reply-to (gnus-header-value))
7237 (string-match "<[^>]+>" in-reply-to))
7239 (mail-header-set-references
7241 (setq ref (substring in-reply-to (match-beginning 0)
7243 (setq ref (downcase ref)))
7245 ;; We do some threading while we read the headers. The
7246 ;; message-id and the last reference are both entered into
7247 ;; the same hash table. Some tippy-toeing around has to be
7248 ;; done in case an article has arrived before the article
7249 ;; which it refers to.
7250 (if (boundp (setq dep (intern (downcase id) dependencies)))
7251 (if (car (symbol-value dep))
7252 ;; An article with this Message-ID has already
7253 ;; been seen, so we ignore this one, except we add
7254 ;; any additional Xrefs (in case the two articles
7255 ;; came from different servers.
7257 (mail-header-set-xref
7258 (car (symbol-value dep))
7259 (concat (or (mail-header-xref
7260 (car (symbol-value dep))) "")
7261 (or (mail-header-xref header) "")))
7263 (setcar (symbol-value dep) header))
7264 (set dep (list header)))
7267 (if (boundp (setq dep (intern ref dependencies)))
7268 (setcdr (symbol-value dep)
7269 (cons header (cdr (symbol-value dep))))
7270 (set dep (list nil header)))
7271 (setq headers (cons header headers))))
7272 (goto-char (point-max))))))
7273 (nreverse headers)))
7275 ;; The following macros and functions were written by Felix Lee
7276 ;; <flee@cse.psu.edu>.
7278 (defmacro gnus-nov-read-integer ()
7280 (if (= (following-char) ?\t)
7282 (let ((num (condition-case nil (read buffer) (error nil))))
7283 (if (numberp num) num 0)))
7284 (or (eobp) (forward-char 1))))
7286 (defmacro gnus-nov-skip-field ()
7287 '(search-forward "\t" eol 'move))
7289 (defmacro gnus-nov-field ()
7290 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7292 ;; Goes through the xover lines and returns a list of vectors
7293 (defun gnus-get-newsgroup-headers-xover (sequence)
7294 "Parse the news overview data in the server buffer, and return a
7295 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7296 ;; Get the Xref when the users reads the articles since most/some
7297 ;; NNTP servers do not include Xrefs when using XOVER.
7298 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7299 (let ((cur nntp-server-buffer)
7300 (dependencies gnus-newsgroup-dependencies)
7301 number headers header)
7303 (set-buffer nntp-server-buffer)
7304 (goto-char (point-min))
7305 (while (and sequence (not (eobp)))
7306 (setq number (read cur))
7307 (while (and sequence (< (car sequence) number))
7308 (setq sequence (cdr sequence)))
7310 (eq number (car sequence))
7312 (setq sequence (cdr sequence))
7314 (inline (gnus-nov-parse-line number dependencies)))
7315 (setq headers (cons header headers)))))
7317 (setq headers (nreverse headers)))
7320 ;; This function has to be called with point after the article number
7321 ;; on the beginning of the line.
7322 (defun gnus-nov-parse-line (number dependencies)
7324 (eol (gnus-point-at-eol))
7325 (buffer (current-buffer))
7328 ;; overview: [num subject from date id refs chars lines misc]
7329 (narrow-to-region (point) eol)
7330 (or (eobp) (forward-char))
7336 (gnus-nov-field) ; subject
7337 (gnus-nov-field) ; from
7338 (gnus-nov-field) ; date
7339 (setq id (or (gnus-nov-field)
7342 (setq none (1+ none)))))) ; id
7345 (let ((beg (point)))
7346 (search-forward "\t" eol)
7347 (if (search-backward ">" beg t)
7353 (search-backward "<" beg t)
7356 (gnus-nov-field)) ; refs
7357 (gnus-nov-read-integer) ; chars
7358 (gnus-nov-read-integer) ; lines
7359 (if (= (following-char) ?\n)
7361 (gnus-nov-field)) ; misc
7365 (message "Strange nov line.")
7371 ;; We build the thread tree.
7373 (if (boundp (setq dep (intern (downcase id) dependencies)))
7374 (if (car (symbol-value dep))
7375 ;; An article with this Message-ID has already been seen,
7376 ;; so we ignore this one, except we add any additional
7377 ;; Xrefs (in case the two articles came from different
7380 (mail-header-set-xref
7381 (car (symbol-value dep))
7382 (concat (or (mail-header-xref (car (symbol-value dep))) "")
7383 (or (mail-header-xref header) "")))
7385 (setcar (symbol-value dep) header))
7386 (set dep (list header))))
7389 (if (boundp (setq dep (intern (or ref "none")
7391 (setcdr (symbol-value dep)
7392 (cons header (cdr (symbol-value dep))))
7393 (set dep (list nil header)))))
7396 (defun gnus-article-get-xrefs ()
7397 "Fill in the Xref value in `gnus-current-headers', if necessary.
7398 This is meant to be called in `gnus-article-internal-prepare-hook'."
7399 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7400 gnus-current-headers)))
7401 (or (not gnus-use-cross-reference)
7403 (and (mail-header-xref headers)
7404 (not (string= (mail-header-xref headers) "")))
7405 (let ((case-fold-search t)
7408 (gnus-narrow-to-headers)
7409 (goto-char (point-min))
7410 (if (or (and (eq (downcase (following-char)) ?x)
7411 (looking-at "Xref:"))
7412 (search-forward "\nXref:" nil t))
7414 (goto-char (1+ (match-end 0)))
7415 (setq xref (buffer-substring (point)
7416 (progn (end-of-line) (point))))
7417 (mail-header-set-xref headers xref))))))))
7419 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7420 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7422 (defun gnus-make-headers-hashtable-by-number ()
7423 "Make hashtable for the variable gnus-newsgroup-headers by number."
7425 (set-buffer gnus-summary-buffer)
7426 (let ((headers gnus-newsgroup-headers)
7428 (setq gnus-newsgroup-headers-hashtb-by-number
7429 (gnus-make-hashtable (length headers)))
7431 (setq header (car headers))
7432 (gnus-sethash (int-to-string (mail-header-number header))
7433 header gnus-newsgroup-headers-hashtb-by-number)
7434 (setq headers (cdr headers))))))
7436 (defun gnus-more-header-backward ()
7437 "Find new header backward."
7438 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7439 (artnum gnus-newsgroup-begin)
7441 (while (and (not header)
7443 (setq artnum (1- artnum))
7444 (setq header (gnus-read-header artnum)))
7447 (defun gnus-more-header-forward (&optional backward)
7448 "Find new header forward.
7449 If BACKWARD, find new header backward instead."
7451 (gnus-more-header-backward)
7452 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7453 (artnum gnus-newsgroup-end)
7455 (while (and (not header)
7457 (setq artnum (1+ artnum))
7458 (setq header (gnus-read-header artnum)))
7461 (defun gnus-extend-newsgroup (header &optional backward)
7462 "Extend newsgroup selection with HEADER.
7463 Optional argument BACKWARD means extend toward backward."
7465 (let ((artnum (mail-header-number header)))
7466 (setq gnus-newsgroup-headers
7468 (cons header gnus-newsgroup-headers)
7469 (nconc gnus-newsgroup-headers (list header))))
7470 (setq gnus-newsgroup-unselected
7471 (delq artnum gnus-newsgroup-unselected))
7472 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7473 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7475 (defun gnus-summary-work-articles (n)
7476 "Return a list of articles to be worked upon. The prefix argument,
7477 the list of process marked articles, and the current article will be
7478 taken into consideration."
7480 (if (and n (numberp n))
7481 (let ((backward (< n 0))
7485 (setq articles (cons (gnus-summary-article-number)
7487 (gnus-summary-search-forward nil nil backward))
7489 (sort articles (function <)))
7490 (or (reverse gnus-newsgroup-processable)
7491 (list (gnus-summary-article-number))))))
7493 (defun gnus-summary-search-group (&optional backward use-level)
7494 "Search for next unread newsgroup.
7495 If optional argument BACKWARD is non-nil, search backward instead."
7497 (set-buffer gnus-group-buffer)
7498 (if (gnus-group-search-forward
7499 backward nil (if use-level (gnus-group-group-level) nil))
7500 (gnus-group-group-name))))
7502 (defun gnus-summary-best-group (&optional exclude-group)
7503 "Find the name of the best unread group.
7504 If EXCLUDE-GROUP, do not go to this group."
7506 (set-buffer gnus-group-buffer)
7508 (gnus-group-best-unread-group exclude-group))))
7510 (defun gnus-subject-equal (s1 s2)
7512 ((null gnus-summary-gather-subject-limit)
7513 (equal (gnus-simplify-subject-re s1)
7514 (gnus-simplify-subject-re s2)))
7515 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7516 (equal (gnus-simplify-subject-fuzzy s1)
7517 (gnus-simplify-subject-fuzzy s2)))
7518 ((numberp gnus-summary-gather-subject-limit)
7519 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7520 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7524 (defun gnus-summary-search-subject (&optional backward unread subject)
7525 "Search for article forward.
7526 If BACKWARD is non-nil, search backward.
7527 If UNREAD is non-nil, only unread articles are selected.
7528 If SUBJECT is non-nil, the article which has the same subject will be
7530 (let ((func (if backward 'previous-single-property-change
7531 'next-single-property-change))
7536 (and gnus-summary-check-current unread
7537 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7541 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7544 (setq pos (funcall func (point) 'gnus-number))
7545 (goto-char (if backward (1- pos) pos))
7549 (eq (get-text-property (point) 'gnus-mark)
7553 (inline (gnus-summary-subject-string)))
7555 (gnus-subject-equal subject psubject)))))))
7556 (if backward (if (bobp) nil (forward-char -1) t)
7557 (if (eobp) nil (forward-char 1) t)))))
7559 (progn (goto-char beg) nil)
7561 (get-text-property (point) 'gnus-number)
7562 (gnus-summary-show-thread)
7563 (gnus-summary-position-cursor)))))
7565 (defun gnus-summary-pseudo-article ()
7566 "The thread level of the article on the current line."
7567 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7569 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7570 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7571 (defun gnus-summary-article-score ()
7572 "Return current article score."
7573 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7574 gnus-summary-default-score 0))
7576 (defun gnus-summary-recenter ()
7577 "Center point in the summary window.
7578 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7579 displayed, no centering will be performed."
7580 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7581 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7582 (let* ((top (cond ((< (window-height) 4) 0)
7583 ((< (window-height) 7) 1)
7585 (height (1- (window-height)))
7586 (bottom (save-excursion (goto-char (point-max))
7587 (forward-line (- height))
7589 (window (get-buffer-window (current-buffer))))
7591 ;; The user has to want it,
7592 gnus-auto-center-summary
7593 ;; the article buffer must be displayed,
7594 (get-buffer-window gnus-article-buffer)
7595 ;; Set the window start to either `bottom', which is the biggest
7596 ;; possible valid number, or the second line from the top,
7597 ;; whichever is the least.
7599 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7601 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7602 (defun gnus-short-group-name (group &optional levels)
7603 "Collapse GROUP name LEVELS."
7604 (let* ((name "") (foreign "") (depth -1) (skip 1)
7607 (while (string-match "\\." group skip)
7608 (setq skip (match-end 0)
7611 (if (string-match ":" group)
7612 (setq foreign (substring group 0 (match-end 0))
7613 group (substring group (match-end 0))))
7615 (if (and (string-match "\\." group) (> levels 0))
7616 (setq name (concat name (substring group 0 1))
7617 group (substring group (match-end 0))
7619 name (concat name "."))
7620 (setq name (concat foreign name group)
7624 (defun gnus-summary-jump-to-group (newsgroup)
7625 "Move point to NEWSGROUP in group mode buffer."
7626 ;; Keep update point of group mode buffer if visible.
7627 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7628 (save-window-excursion
7629 ;; Take care of tree window mode.
7630 (if (get-buffer-window gnus-group-buffer)
7631 (pop-to-buffer gnus-group-buffer))
7632 (gnus-group-jump-to-group newsgroup))
7634 ;; Take care of tree window mode.
7635 (if (get-buffer-window gnus-group-buffer)
7636 (pop-to-buffer gnus-group-buffer)
7637 (set-buffer gnus-group-buffer))
7638 (gnus-group-jump-to-group newsgroup))))
7640 ;; This function returns a list of article numbers based on the
7641 ;; difference between the ranges of read articles in this group and
7642 ;; the range of active articles.
7643 (defun gnus-list-of-unread-articles (group)
7644 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7645 (active (gnus-gethash group gnus-active-hashtb))
7648 ;; If none are read, then all are unread.
7650 (setq first (car active))
7651 ;; If the range of read articles is a single range, then the
7652 ;; first unread article is the article after the last read
7653 ;; article. Sounds logical, doesn't it?
7654 (if (not (listp (cdr read)))
7655 (setq first (1+ (cdr read)))
7656 ;; `read' is a list of ranges.
7657 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7658 (car (car read)))) 1)
7662 (while (< first nlast)
7663 (setq unread (cons first unread))
7664 (setq first (1+ first))))
7665 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7666 (setq nlast (if (atom (car (cdr read)))
7668 (car (car (cdr read)))))
7669 (setq read (cdr read)))))
7670 ;; And add the last unread articles.
7671 (while (<= first last)
7672 (setq unread (cons first unread))
7673 (setq first (1+ first)))
7674 ;; Return the list of unread articles.
7677 (defun gnus-list-of-read-articles (group)
7678 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7679 (active (gnus-gethash group gnus-active-hashtb)))
7681 (gnus-sorted-complement
7682 (gnus-uncompress-range active)
7683 (gnus-list-of-unread-articles group)))))
7685 ;; Various summary commands
7687 (defun gnus-summary-universal-argument ()
7688 "Perform any operation on all articles marked with the process mark."
7690 (gnus-set-global-variables)
7691 (let ((articles (reverse gnus-newsgroup-processable))
7693 (or articles (error "No articles marked"))
7694 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7695 (error "Undefined key"))
7697 (gnus-summary-goto-subject (car articles))
7698 (command-execute func)
7699 (gnus-summary-remove-process-mark (car articles))
7700 (setq articles (cdr articles)))))
7702 (defun gnus-summary-toggle-truncation (&optional arg)
7703 "Toggle truncation of summary lines.
7704 With arg, turn line truncation on iff arg is positive."
7706 (setq truncate-lines
7707 (if (null arg) (not truncate-lines)
7708 (> (prefix-numeric-value arg) 0)))
7711 (defun gnus-summary-reselect-current-group (&optional all)
7712 "Once exit and then reselect the current newsgroup.
7713 The prefix argument ALL means to select all articles."
7715 (gnus-set-global-variables)
7716 (let ((current-subject (gnus-summary-article-number))
7717 (group gnus-newsgroup-name))
7718 (setq gnus-newsgroup-begin nil)
7719 (gnus-summary-exit t)
7720 ;; We have to adjust the point of group mode buffer because the
7721 ;; current point was moved to the next unread newsgroup by
7723 (gnus-summary-jump-to-group group)
7724 (gnus-group-read-group all t)
7725 (gnus-summary-goto-subject current-subject)))
7727 (defun gnus-summary-rescan-group (&optional all)
7728 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7730 (gnus-set-global-variables)
7731 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7732 (let ((group gnus-newsgroup-name))
7734 (gnus-summary-jump-to-group group)
7736 (set-buffer gnus-group-buffer)
7737 (gnus-group-get-new-news-this-group 1))
7738 (gnus-summary-jump-to-group group)
7739 (gnus-group-read-group all)))
7741 (defun gnus-summary-update-info ()
7742 (let* ((group gnus-newsgroup-name))
7743 (if gnus-newsgroup-kill-headers
7744 (setq gnus-newsgroup-killed
7745 (gnus-compress-sequence
7747 (gnus-set-sorted-intersection
7748 (gnus-uncompress-range gnus-newsgroup-killed)
7749 (setq gnus-newsgroup-unselected
7750 (sort gnus-newsgroup-unselected '<)))
7751 (setq gnus-newsgroup-unreads
7752 (sort gnus-newsgroup-unreads '<))) t)))
7753 (or (listp (cdr gnus-newsgroup-killed))
7754 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7755 (let ((headers gnus-newsgroup-headers))
7756 (gnus-close-group group)
7757 (run-hooks 'gnus-exit-group-hook)
7758 (gnus-update-read-articles
7759 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7760 gnus-newsgroup-marked
7761 t gnus-newsgroup-replied gnus-newsgroup-expirable
7762 gnus-newsgroup-killed gnus-newsgroup-dormant
7763 gnus-newsgroup-bookmarks
7764 (and gnus-save-score gnus-newsgroup-scored))
7765 (and gnus-use-cross-reference
7766 (gnus-mark-xrefs-as-read
7767 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7768 ;; Do adaptive scoring, and possibly save score files.
7769 (and gnus-newsgroup-adaptive
7770 (gnus-score-adaptive))
7771 (and gnus-use-scoring
7772 (fboundp 'gnus-score-save)
7773 (funcall 'gnus-score-save))
7774 ;; Do not switch windows but change the buffer to work.
7775 (set-buffer gnus-group-buffer)
7776 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7777 (gnus-group-update-group group)))))
7779 (defun gnus-summary-exit (&optional temporary)
7780 "Exit reading current newsgroup, and then return to group selection mode.
7781 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7783 (gnus-set-global-variables)
7784 (gnus-kill-save-kill-buffer)
7785 (let* ((group gnus-newsgroup-name)
7786 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7787 gnus-newsgroup-name))))
7789 (buf (current-buffer)))
7790 (run-hooks 'gnus-summary-prepare-exit-hook)
7791 ;; Make all changes in this group permanent.
7792 (gnus-summary-update-info)
7794 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7795 ;; Make sure where I was, and go to next newsgroup.
7796 (set-buffer gnus-group-buffer)
7799 (gnus-group-jump-to-group group)
7800 (gnus-group-next-unread-group 1)))
7803 ;; We set all buffer-local variables to nil. It is unclear why
7804 ;; this is needed, but if we don't, buffer-local variables are
7805 ;; not garbage-collected, it seems. This would the lead to en
7806 ;; ever-growing Emacs.
7808 (gnus-summary-clear-local-variables)
7809 ;; We clear the global counterparts of the buffer-local
7810 ;; variables as well, just to be on the safe side.
7811 (gnus-configure-windows 'group 'force)
7812 (gnus-summary-clear-local-variables)
7813 ;; Return to group mode buffer.
7814 (if (eq mode 'gnus-summary-mode)
7815 (gnus-kill-buffer buf))
7816 (if (get-buffer gnus-article-buffer)
7817 (bury-buffer gnus-article-buffer))
7818 (setq gnus-current-select-method gnus-select-method)
7819 (pop-to-buffer gnus-group-buffer)
7820 (if (not quit-config)
7822 (gnus-group-jump-to-group group)
7823 (gnus-group-next-unread-group 1))
7824 (if (not (buffer-name (car quit-config)))
7825 (gnus-configure-windows 'group 'force)
7826 (set-buffer (car quit-config))
7827 (and (eq major-mode 'gnus-summary-mode)
7828 (gnus-set-global-variables))
7829 (gnus-configure-windows (cdr quit-config))))
7830 (run-hooks 'gnus-summary-exit-hook))))
7832 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7833 (defun gnus-summary-exit-no-update (&optional no-questions)
7834 "Quit reading current newsgroup without updating read article info."
7836 (gnus-set-global-variables)
7837 (let* ((group gnus-newsgroup-name)
7838 (quit-config (nth 1 (assoc 'quit-config
7839 (gnus-find-method-for-group group)))))
7840 (if (or no-questions
7842 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7844 (gnus-close-group group)
7845 (gnus-summary-clear-local-variables)
7846 (set-buffer gnus-group-buffer)
7847 (gnus-summary-clear-local-variables)
7848 ;; Return to group selection mode.
7849 (gnus-configure-windows 'group 'force)
7850 (if (get-buffer gnus-summary-buffer)
7851 (kill-buffer gnus-summary-buffer))
7852 (if (get-buffer gnus-article-buffer)
7853 (bury-buffer gnus-article-buffer))
7854 (if (equal (gnus-group-group-name) group)
7855 (gnus-group-next-unread-group 1))
7858 (if (not (buffer-name (car quit-config)))
7859 (gnus-configure-windows 'group 'force)
7860 (set-buffer (car quit-config))
7861 (and (eq major-mode 'gnus-summary-mode)
7862 (gnus-set-global-variables))
7863 (gnus-configure-windows (cdr quit-config)))))))))
7865 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7866 (defun gnus-summary-fetch-faq (group)
7867 "Fetch the FAQ for the current group."
7868 (interactive (list gnus-newsgroup-name))
7869 (let (gnus-faq-buffer)
7870 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group))
7871 (gnus-configure-windows 'summary-faq))))
7873 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7874 (defun gnus-summary-describe-group (&optional force)
7875 "Describe the current newsgroup."
7877 (gnus-group-describe-group force gnus-newsgroup-name))
7879 (defun gnus-summary-describe-briefly ()
7880 "Describe summary mode commands briefly."
7883 (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")))
7885 ;; Walking around group mode buffer from summary mode.
7887 (defun gnus-summary-next-group (&optional no-article target-group backward)
7888 "Exit current newsgroup and then select next unread newsgroup.
7889 If prefix argument NO-ARTICLE is non-nil, no article is selected
7890 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7891 previous group instead."
7893 (gnus-set-global-variables)
7894 (let ((current-group gnus-newsgroup-name)
7895 (current-buffer (current-buffer))
7897 ;; First we semi-exit this group to update Xrefs and all variables.
7898 ;; We can't do a real exit, because the window conf must remain
7899 ;; the same in case the user is prompted for info, and we don't
7900 ;; want the window conf to change before that...
7901 (gnus-summary-exit t)
7902 (while (not entered)
7903 ;; Then we find what group we are supposed to enter.
7904 (set-buffer gnus-group-buffer)
7905 (gnus-group-jump-to-group current-group)
7908 (if (eq gnus-keep-same-level 'best)
7909 (gnus-summary-best-group gnus-newsgroup-name)
7910 (gnus-summary-search-group backward gnus-keep-same-level))))
7911 (if (not target-group)
7912 ;; There are no further groups, so we return to the group
7915 (gnus-message 5 "Returning to the group buffer")
7917 (set-buffer current-buffer)
7918 (gnus-summary-exit))
7919 ;; We try to enter the target group.
7920 (gnus-group-jump-to-group target-group)
7921 (let ((unreads (gnus-group-group-unread)))
7922 (if (and (or (eq t unreads)
7923 (and unreads (not (zerop unreads))))
7924 (gnus-summary-read-group
7925 target-group nil no-article current-buffer))
7927 (setq current-group target-group
7928 target-group nil)))))))
7930 (defun gnus-summary-next-group-old (&optional no-article group backward)
7931 "Exit current newsgroup and then select next unread newsgroup.
7932 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7933 If BACKWARD, go to previous group instead."
7935 (gnus-set-global-variables)
7936 (let ((ingroup gnus-newsgroup-name)
7937 (sumbuf (current-buffer))
7939 (set-buffer gnus-group-buffer)
7941 (or (and (numberp (setq num (car (gnus-gethash
7942 group gnus-newsrc-hashtb))))
7946 (gnus-group-jump-to-group group)
7948 (gnus-group-jump-to-group ingroup))
7949 (gnus-summary-search-group backward)
7950 (let ((group (or group (gnus-summary-search-group backward))))
7952 (gnus-summary-exit t) ;Update all information.
7954 (gnus-summary-exit-no-update t)
7955 (gnus-group-jump-to-group ingroup)
7956 (setq group (gnus-summary-search-group backward))
7957 (gnus-message 5 "Selecting %s..." group)
7958 (set-buffer gnus-group-buffer)
7959 ;; We are now in group mode buffer.
7960 ;; Make sure group mode buffer point is on GROUP.
7961 (gnus-group-jump-to-group group)
7962 (if (not (eq gnus-auto-select-next 'quietly))
7964 (gnus-summary-read-group group nil no-article sumbuf)
7965 (and (string= gnus-newsgroup-name ingroup)
7966 (bufferp sumbuf) (buffer-name sumbuf)
7968 (set-buffer (setq gnus-summary-buffer sumbuf))
7969 (gnus-summary-exit-no-update t))))
7970 (let ((prevgroup group))
7971 (gnus-group-jump-to-group ingroup)
7972 (setq group (gnus-summary-search-group backward))
7973 (gnus-summary-read-group group nil no-article sumbuf)
7974 (while (and (string= gnus-newsgroup-name ingroup)
7976 (buffer-name sumbuf)
7977 (not (string= prevgroup (gnus-group-group-name))))
7978 (set-buffer gnus-group-buffer)
7979 (gnus-summary-read-group
7980 (setq prevgroup (gnus-group-group-name))
7981 nil no-article sumbuf))
7982 (and (string= prevgroup (gnus-group-group-name))
7983 ;; We have reached the final group in the group
7986 (if (buffer-name sumbuf)
7989 (gnus-summary-exit)))))))))))
7991 (defun gnus-summary-prev-group (&optional no-article)
7992 "Exit current newsgroup and then select previous unread newsgroup.
7993 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7995 (gnus-summary-next-group no-article nil t))
7997 ;; Walking around summary lines.
7999 (defun gnus-summary-first-subject (&optional unread)
8000 "Go to the first unread subject.
8001 If UNREAD is non-nil, go to the first unread article.
8002 Returns nil if there are no unread articles."
8006 (goto-char (point-min)))
8009 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
8012 ;; There are no unread articles.
8013 (gnus-message 3 "No more unread articles")
8015 (gnus-summary-position-cursor)))
8017 (defun gnus-summary-next-subject (n &optional unread dont-display)
8018 "Go to next N'th summary line.
8019 If N is negative, go to the previous N'th subject line.
8020 If UNREAD is non-nil, only unread articles are selected.
8021 The difference between N and the actual number of steps taken is
8024 (let ((backward (< n 0))
8027 (gnus-summary-search-forward unread nil backward))
8029 (if (/= 0 n) (gnus-message 7 "No more%s articles"
8030 (if unread " unread" "")))
8033 (gnus-summary-recenter)
8034 (gnus-summary-position-cursor)))
8037 (defun gnus-summary-next-unread-subject (n)
8038 "Go to next N'th unread summary line."
8040 (gnus-summary-next-subject n t))
8042 (defun gnus-summary-prev-subject (n &optional unread)
8043 "Go to previous N'th summary line.
8044 If optional argument UNREAD is non-nil, only unread article is selected."
8046 (gnus-summary-next-subject (- n) unread))
8048 (defun gnus-summary-prev-unread-subject (n)
8049 "Go to previous N'th unread summary line."
8051 (gnus-summary-next-subject (- n) t))
8053 (defun gnus-summary-goto-subject (article)
8054 "Go the subject line of ARTICLE."
8058 (completing-read "Article number: "
8062 (int-to-string (mail-header-number headers))))
8063 gnus-newsgroup-headers)
8064 nil 'require-match))))
8065 (or article (error "No article number"))
8067 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
8068 'gnus-number article)))
8070 (gnus-summary-show-thread)
8071 ;; Skip dummy articles.
8072 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8079 (gnus-summary-position-cursor)))))
8081 ;; Walking around summary lines with displaying articles.
8083 (defun gnus-summary-expand-window (&optional arg)
8084 "Make the summary buffer take up the entire Emacs frame.
8085 Given a prefix, will force an `article' buffer configuration."
8087 (gnus-set-global-variables)
8089 (gnus-configure-windows 'article 'force)
8090 (gnus-configure-windows 'summary 'force)))
8092 (defun gnus-summary-display-article (article &optional all-header)
8093 "Display ARTICLE in article buffer."
8094 (gnus-set-global-variables)
8098 (gnus-article-prepare article all-header)
8099 (gnus-summary-show-thread)
8100 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8103 (gnus-summary-position-cursor)))
8104 (run-hooks 'gnus-select-article-hook)
8105 (gnus-summary-recenter)
8106 (gnus-summary-goto-subject article)
8107 ;; Successfully display article.
8108 (gnus-summary-update-line)
8109 (gnus-article-set-window-start
8110 (cdr (assq article gnus-newsgroup-bookmarks)))
8113 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8114 "Select the current article.
8115 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8116 non-nil, the article will be re-fetched even if it already present in
8117 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8119 (and (not pseudo) (gnus-summary-pseudo-article)
8120 (error "This is a pseudo-article."))
8121 (let ((article (or article (gnus-summary-article-number)))
8122 (all-headers (not (not all-headers))) ;Must be T or NIL.
8126 (set-buffer gnus-summary-buffer)
8127 (if (or (null gnus-current-article)
8128 (null gnus-article-current)
8129 (null (get-buffer gnus-article-buffer))
8130 (not (eq article (cdr gnus-article-current)))
8131 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8133 ;; The requested article is different from the current article.
8135 (gnus-summary-display-article article all-headers)
8137 (if (or all-headers gnus-show-all-headers)
8138 (gnus-article-show-all-headers))
8141 (gnus-article-set-window-start
8142 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8144 (defun gnus-summary-set-current-mark (&optional current-mark)
8145 "Obsolete function."
8148 (defun gnus-summary-next-article (&optional unread subject backward)
8149 "Select the next article.
8150 If UNREAD, only unread articles are selected.
8151 If SUBJECT, only articles with SUBJECT are selected.
8152 If BACKWARD, the previous article is selected instead of the next."
8154 (gnus-set-global-variables)
8157 ;; Is there such an article?
8158 ((and (gnus-summary-search-forward unread subject backward)
8159 (or (gnus-summary-display-article (gnus-summary-article-number))
8160 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8161 (gnus-summary-position-cursor))
8162 ;; If not, we try the first unread, if that is wanted.
8164 gnus-auto-select-same
8165 (or (gnus-summary-first-unread-article)
8166 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8167 (gnus-summary-position-cursor)
8168 (gnus-message 6 "Wrapped"))
8169 ;; Try to get next/previous article not displayed in this group.
8170 ((and gnus-auto-extend-newsgroup
8171 (not unread) (not subject)
8172 (setq header (gnus-more-header-forward backward)))
8173 (gnus-extend-newsgroup header backward)
8174 (let ((buffer-read-only nil))
8175 (goto-char (if backward (point-min) (point-max)))
8176 (gnus-summary-prepare-threads (list header)))
8177 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8178 gnus-newsgroup-end)))
8179 ;; Go to next/previous group.
8181 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8182 (gnus-summary-jump-to-group gnus-newsgroup-name))
8183 (let ((cmd last-command-char)
8185 (if (eq gnus-keep-same-level 'best)
8186 (gnus-summary-best-group gnus-newsgroup-name)
8187 (gnus-summary-search-group backward gnus-keep-same-level))))
8188 ;; For some reason, the group window gets selected. We change
8190 (select-window (get-buffer-window (current-buffer)))
8191 ;; Keep just the event type of CMD.
8192 ;(and (listp cmd) (setq cmd (car cmd)))
8193 ;; Select next unread newsgroup automagically.
8195 ((not gnus-auto-select-next)
8196 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8197 ((eq gnus-auto-select-next 'quietly)
8199 (if (assoc 'quit-config (gnus-find-method-for-group
8200 gnus-newsgroup-name))
8202 (gnus-message 7 "No more%s articles (%s)..."
8203 (if unread " unread" "")
8204 (if group (concat "selecting " group)
8206 (gnus-summary-next-group nil group backward)))
8208 (let ((keystrokes '(?\C-n ?\C-p))
8210 (while (or (null key) (memq key keystrokes))
8212 7 "No more%s articles%s" (if unread " unread" "")
8213 (if (and group (not (assoc 'quit-config
8214 (gnus-find-method-for-group
8215 gnus-newsgroup-name))))
8216 (format " (Type %s for %s [%s])"
8217 (single-key-description cmd) group
8218 (car (gnus-gethash group gnus-newsrc-hashtb)))
8219 (format " (Type %s to exit %s)"
8220 (single-key-description cmd)
8221 gnus-newsgroup-name)))
8222 ;; Confirm auto selection.
8223 (let* ((event (read-char)))
8224 (setq key (if (listp event) (car event) event))
8225 (if (memq key keystrokes)
8226 (let ((obuf (current-buffer)))
8227 (switch-to-buffer gnus-group-buffer)
8229 (gnus-group-jump-to-group group))
8231 (execute-kbd-macro (char-to-string key))
8233 (setq group (gnus-group-group-name))
8234 (switch-to-buffer obuf)))))
8236 (if (or (not group) (assoc 'quit-config
8237 (gnus-find-method-for-group
8238 gnus-newsgroup-name)))
8240 (gnus-summary-next-group nil group backward))
8241 (execute-kbd-macro (char-to-string key)))))))))))
8243 (defun gnus-summary-next-unread-article ()
8244 "Select unread article after current one."
8246 (gnus-summary-next-article t (and gnus-auto-select-same
8247 (gnus-summary-subject-string))))
8249 (defun gnus-summary-prev-article (&optional unread subject)
8250 "Select the article after the current one.
8251 If UNREAD is non-nil, only unread articles are selected."
8253 (gnus-summary-next-article unread subject t))
8255 (defun gnus-summary-prev-unread-article ()
8256 "Select unred article before current one."
8258 (gnus-summary-prev-article t (and gnus-auto-select-same
8259 (gnus-summary-subject-string))))
8261 (defun gnus-summary-next-page (&optional lines circular)
8262 "Show next page of selected article.
8263 If end of article, select next article.
8264 Argument LINES specifies lines to be scrolled up.
8265 If CIRCULAR is non-nil, go to the start of the article instead of
8266 instead of selecting the next article when reaching the end of the
8269 (setq gnus-summary-buffer (current-buffer))
8270 (gnus-set-global-variables)
8271 (let ((article (gnus-summary-article-number))
8273 (gnus-configure-windows 'article)
8274 (if (or (null gnus-current-article)
8275 (null gnus-article-current)
8276 (/= article (cdr gnus-article-current))
8277 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8278 ;; Selected subject is different from current article's.
8279 (gnus-summary-display-article article)
8280 (gnus-eval-in-buffer-window
8282 (setq endp (gnus-article-next-page lines)))
8285 (gnus-summary-beginning-of-article))
8287 (gnus-message 3 "End of message"))
8289 (gnus-summary-next-unread-article)))))
8290 (gnus-summary-recenter)
8291 (gnus-summary-position-cursor)))
8293 (defun gnus-summary-prev-page (&optional lines)
8294 "Show previous page of selected article.
8295 Argument LINES specifies lines to be scrolled down."
8297 (gnus-set-global-variables)
8298 (let ((article (gnus-summary-article-number)))
8299 (gnus-configure-windows 'article)
8300 (if (or (null gnus-current-article)
8301 (null gnus-article-current)
8302 (/= article (cdr gnus-article-current))
8303 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8304 ;; Selected subject is different from current article's.
8305 (gnus-summary-display-article article)
8306 (gnus-summary-recenter)
8307 (gnus-eval-in-buffer-window gnus-article-buffer
8308 (gnus-article-prev-page lines))))
8309 (gnus-summary-position-cursor))
8311 (defun gnus-summary-scroll-up (lines)
8312 "Scroll up (or down) one line current article.
8313 Argument LINES specifies lines to be scrolled up (or down if negative)."
8315 (gnus-set-global-variables)
8316 (gnus-configure-windows 'article)
8317 (or (gnus-summary-select-article nil nil 'pseudo)
8318 (gnus-eval-in-buffer-window
8321 (if (gnus-article-next-page lines)
8322 (gnus-message 3 "End of message")))
8324 (gnus-article-prev-page (- lines))))))
8325 (gnus-summary-recenter)
8326 (gnus-summary-position-cursor))
8328 (defun gnus-summary-next-same-subject ()
8329 "Select next article which has the same subject as current one."
8331 (gnus-set-global-variables)
8332 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8334 (defun gnus-summary-prev-same-subject ()
8335 "Select previous article which has the same subject as current one."
8337 (gnus-set-global-variables)
8338 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8340 (defun gnus-summary-next-unread-same-subject ()
8341 "Select next unread article which has the same subject as current one."
8343 (gnus-set-global-variables)
8344 (gnus-summary-next-article t (gnus-summary-subject-string)))
8346 (defun gnus-summary-prev-unread-same-subject ()
8347 "Select previous unread article which has the same subject as current one."
8349 (gnus-set-global-variables)
8350 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8352 (defun gnus-summary-first-unread-article ()
8353 "Select the first unread article.
8354 Return nil if there are no unread articles."
8356 (gnus-set-global-variables)
8358 (if (gnus-summary-first-subject t)
8360 (gnus-summary-show-thread)
8361 (gnus-summary-first-subject t)
8362 (gnus-summary-display-article (gnus-summary-article-number))))
8363 (gnus-summary-position-cursor)))
8365 (defun gnus-summary-best-unread-article ()
8366 "Select the unread article with the highest score."
8368 (gnus-set-global-variables)
8369 (let ((best -1000000)
8372 (or (gnus-summary-first-subject t)
8373 (error "No unread articles"))
8377 (and (> (setq score (gnus-summary-article-score)) best)
8379 article (gnus-summary-article-number)))
8381 (gnus-summary-search-subject nil t))))
8383 (error "No unread articles")
8384 (gnus-summary-goto-article article))
8385 (gnus-summary-position-cursor)))
8387 (defun gnus-summary-goto-article (article &optional all-headers)
8388 "Fetch ARTICLE and display it if it exists.
8389 If ALL-HEADERS is non-nil, no header lines are hidden."
8395 (mapcar (lambda (headers)
8396 (list (int-to-string (mail-header-number headers))))
8397 gnus-newsgroup-headers)
8398 nil 'require-match))))
8400 (and (gnus-summary-goto-subject article)
8401 (gnus-summary-display-article article all-headers))
8402 (gnus-summary-position-cursor)))
8404 (defun gnus-summary-goto-last-article ()
8405 "Go to the previously read article."
8408 (and gnus-last-article
8409 (gnus-summary-goto-article gnus-last-article))
8410 (gnus-summary-position-cursor)))
8412 (defun gnus-summary-pop-article (number)
8413 "Pop one article off the history and go to the previous.
8414 NUMBER articles will be popped off."
8417 (setq gnus-newsgroup-history
8418 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8420 (gnus-summary-goto-article (car to))
8421 (error "Article history empty")))
8422 (gnus-summary-position-cursor))
8424 ;; Summary article oriented commands
8426 (defun gnus-summary-refer-parent-article (n)
8427 "Refer parent article N times.
8428 The difference between N and the number of articles fetched is returned."
8430 (gnus-set-global-variables)
8434 (let ((ref (mail-header-references (gnus-get-header-by-num
8435 (gnus-summary-article-number)))))
8436 (if (and ref (not (equal ref ""))
8437 (string-match "<[^<>]*>[ \t]*$" ref))
8438 (gnus-summary-refer-article
8439 (substring ref (match-beginning 0) (match-end 0)))
8440 (gnus-message 1 "No references in article %d"
8441 (gnus-summary-article-number))
8444 (gnus-summary-position-cursor)
8447 (defun gnus-summary-refer-article (message-id)
8448 "Refer article specified by MESSAGE-ID.
8449 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8450 (interactive "sMessage-ID: ")
8451 (if (or (not (stringp message-id))
8452 (zerop (length message-id)))
8454 ;; Construct the correct Message-ID if necessary.
8455 ;; Suggested by tale@pawl.rpi.edu.
8456 (or (string-match "^<" message-id)
8457 (setq message-id (concat "<" message-id)))
8458 (or (string-match ">$" message-id)
8459 (setq message-id (concat message-id ">")))
8460 (let ((header (car (gnus-gethash (downcase message-id)
8461 gnus-newsgroup-dependencies))))
8463 (or (gnus-summary-goto-article (mail-header-number header))
8464 ;; The header has been read, but the article had been
8465 ;; expunged, so we insert it again.
8467 (gnus-summary-insert-line
8468 nil header 0 nil gnus-read-mark nil nil
8469 (mail-header-subject header))
8471 (mail-header-number header)))
8472 (let ((gnus-override-method gnus-refer-article-method)
8473 (gnus-ancient-mark gnus-read-mark)
8474 (tmp-point (window-start
8475 (get-buffer-window gnus-article-buffer)))
8477 (and gnus-refer-article-method
8478 (gnus-check-server gnus-refer-article-method))
8479 ;; Save the old article buffer.
8481 (set-buffer (gnus-article-setup-buffer))
8482 (gnus-kill-buffer " *temp Article*")
8483 (setq tmp-buf (rename-buffer " *temp Article*")))
8485 (if (gnus-article-prepare
8486 message-id nil (gnus-read-header message-id))
8488 (setq number (mail-header-number gnus-current-headers))
8489 (gnus-rebuild-thread message-id)
8490 (gnus-summary-goto-subject number)
8491 (if (null gnus-use-full-window)
8493 (delete-windows-on tmp-buf)
8494 (gnus-configure-windows 'article 'force)))
8495 (gnus-summary-recenter)
8496 (gnus-article-set-window-start
8497 (cdr (assq number gnus-newsgroup-bookmarks)))
8499 ;; We restore the old article buffer.
8501 (kill-buffer gnus-article-buffer)
8502 (set-buffer tmp-buf)
8503 (rename-buffer gnus-article-buffer)
8504 (let ((buffer-read-only nil))
8506 (set-window-start (get-buffer-window (current-buffer))
8507 tmp-point)))))))))))
8509 (defun gnus-summary-enter-digest-group ()
8510 "Enter a digest group based on the current article."
8512 (gnus-set-global-variables)
8513 (gnus-summary-select-article)
8514 ;; We do not want a narrowed article.
8515 (gnus-summary-stop-page-breaking)
8516 (let ((name (format "%s-%d"
8517 (gnus-group-prefixed-name
8518 gnus-newsgroup-name (list 'nndoc ""))
8519 gnus-current-article))
8520 (ogroup gnus-newsgroup-name)
8521 (buf (current-buffer)))
8522 (if (gnus-group-read-ephemeral-group
8523 name (list 'nndoc name
8524 (list 'nndoc-address (get-buffer gnus-article-buffer))
8525 '(nndoc-article-type digest))
8527 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8528 (list (list (cons 'to-group ogroup))))
8529 (switch-to-buffer buf)
8530 (gnus-set-global-variables)
8531 (gnus-configure-windows 'summary)
8532 (gnus-message 3 "Article not a digest?"))))
8534 (defun gnus-summary-isearch-article ()
8535 "Do incremental search forward on current article."
8537 (gnus-set-global-variables)
8538 (gnus-summary-select-article)
8539 (gnus-eval-in-buffer-window
8540 gnus-article-buffer (isearch-forward)))
8542 (defun gnus-summary-search-article-forward (regexp &optional backward)
8543 "Search for an article containing REGEXP forward.
8544 If BACKWARD, search backward instead."
8547 (format "Search article %s (regexp%s): "
8548 (if current-prefix-arg "backward" "forward")
8549 (if gnus-last-search-regexp
8550 (concat ", default " gnus-last-search-regexp)
8552 current-prefix-arg))
8553 (gnus-set-global-variables)
8554 (if (string-equal regexp "")
8555 (setq regexp (or gnus-last-search-regexp ""))
8556 (setq gnus-last-search-regexp regexp))
8557 (if (gnus-summary-search-article regexp backward)
8558 (gnus-article-set-window-start
8559 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8560 (error "Search failed: \"%s\"" regexp)))
8562 (defun gnus-summary-search-article-backward (regexp)
8563 "Search for an article containing REGEXP backward."
8566 (format "Search article backward (regexp%s): "
8567 (if gnus-last-search-regexp
8568 (concat ", default " gnus-last-search-regexp)
8570 (gnus-summary-search-article-forward regexp 'backward))
8572 (defun gnus-summary-search-article (regexp &optional backward)
8573 "Search for an article containing REGEXP.
8574 Optional argument BACKWARD means do search for backward.
8575 gnus-select-article-hook is not called during the search."
8576 (let ((gnus-select-article-hook nil) ;Disable hook.
8577 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8580 (function re-search-backward) (function re-search-forward)))
8583 ;; Hidden thread subtrees must be searched for ,too.
8584 (gnus-summary-show-all-threads)
8585 (if (eobp) (forward-line -1))
8586 ;; First of all, search current article.
8587 ;; We don't want to read article again from NNTP server nor reset
8589 (gnus-summary-select-article)
8590 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8591 (setq last gnus-current-article)
8592 (gnus-eval-in-buffer-window
8596 ;; Begin search from current point.
8597 (setq found (funcall re-search regexp nil t))))
8598 ;; Then search next articles.
8599 (while (and (not found)
8600 (gnus-summary-display-article
8601 (gnus-summary-search-subject backward nil nil)))
8602 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8603 (gnus-eval-in-buffer-window
8607 (goto-char (if backward (point-max) (point-min)))
8608 (setq found (funcall re-search regexp nil t)))))
8610 ;; Adjust article pointer.
8611 (or (eq last gnus-current-article)
8612 (setq gnus-last-article last))
8613 ;; Return T if found such article.
8616 (defun gnus-summary-execute-command (header regexp command &optional backward)
8617 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8618 If HEADER is an empty string (or nil), the match is done on the entire
8619 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8621 (list (let ((completion-ignore-case t))
8624 (mapcar (lambda (string) (list string))
8625 '("Number" "Subject" "From" "Lines" "Date"
8626 "Message-ID" "Xref" "References"))
8627 nil 'require-match))
8628 (read-string "Regexp: ")
8629 (read-key-sequence "Command: ")
8630 current-prefix-arg))
8631 (gnus-set-global-variables)
8632 ;; Hidden thread subtrees must be searched as well.
8633 (gnus-summary-show-all-threads)
8634 ;; We don't want to change current point nor window configuration.
8636 (save-window-excursion
8637 (gnus-message 6 "Executing %s..." (key-description command))
8638 ;; We'd like to execute COMMAND interactively so as to give arguments.
8639 (gnus-execute header regexp
8641 (call-interactively '(, (key-binding command)))))
8643 (gnus-message 6 "Executing %s...done" (key-description command)))))
8645 (defun gnus-summary-beginning-of-article ()
8646 "Scroll the article back to the beginning."
8648 (gnus-set-global-variables)
8649 (gnus-summary-select-article)
8650 (gnus-configure-windows 'article)
8651 (gnus-eval-in-buffer-window
8654 (goto-char (point-min))
8655 (and gnus-break-pages (gnus-narrow-to-page))))
8657 (defun gnus-summary-end-of-article ()
8658 "Scroll to the end of the article."
8660 (gnus-set-global-variables)
8661 (gnus-summary-select-article)
8662 (gnus-configure-windows 'article)
8663 (gnus-eval-in-buffer-window
8666 (goto-char (point-max))
8668 (and gnus-break-pages (gnus-narrow-to-page))))
8670 (defun gnus-summary-show-article ()
8671 "Force re-fetching of the current article."
8673 (gnus-set-global-variables)
8674 (gnus-summary-select-article nil 'force)
8675 (gnus-configure-windows 'article)
8676 (gnus-summary-position-cursor))
8678 (defun gnus-summary-verbose-headers (&optional arg)
8679 "Toggle permanent full header display.
8680 If ARG is a positive number, turn header display on.
8681 If ARG is a negative number, turn header display off."
8683 (gnus-set-global-variables)
8684 (gnus-summary-toggle-header arg)
8685 (setq gnus-show-all-headers
8686 (cond ((or (not (numberp arg))
8688 (not gnus-show-all-headers))
8692 (defun gnus-summary-toggle-header (&optional arg)
8693 "Show the headers if they are hidden, or hide them if they are shown.
8694 If ARG is a positive number, show the entire header.
8695 If ARG is a negative number, hide the unwanted header lines."
8697 (gnus-set-global-variables)
8699 (set-buffer gnus-article-buffer)
8700 (let ((buffer-read-only nil))
8702 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8703 gnus-hidden-properties)
8704 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8705 (if (text-property-any (point-min) (point-max) 'invisible t)
8706 (remove-text-properties
8707 (point-min) (point-max) gnus-hidden-properties)
8708 ;; We hide the headers. This song and dance act below is
8709 ;; done because `gnus-have-all-headers' is buffer-local to
8710 ;; the summary buffer, and we only want to temporarily
8711 ;; change it in that buffer. Ugh.
8712 (let ((have gnus-have-all-headers))
8714 (set-buffer gnus-summary-buffer)
8715 (setq gnus-have-all-headers nil)
8717 (set-buffer gnus-article-buffer)
8718 (run-hooks 'gnus-article-display-hook))
8719 (setq gnus-have-all-headers have)))))
8720 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8722 (defun gnus-summary-show-all-headers ()
8723 "Make all header lines visible."
8725 (gnus-set-global-variables)
8726 (gnus-article-show-all-headers))
8728 (defun gnus-summary-toggle-mime (&optional arg)
8729 "Toggle MIME processing.
8730 If ARG is a positive number, turn MIME processing on."
8732 (gnus-set-global-variables)
8733 (setq gnus-show-mime
8734 (if (null arg) (not gnus-show-mime)
8735 (> (prefix-numeric-value arg) 0)))
8736 (gnus-summary-select-article t 'force))
8738 (defun gnus-summary-caesar-message (&optional arg)
8739 "Caesar rotate the current article by 13.
8740 The numerical prefix specifies how manu places to rotate each letter
8743 (gnus-set-global-variables)
8744 (gnus-summary-select-article)
8745 (let ((mail-header-separator ""))
8746 (gnus-eval-in-buffer-window
8750 (let ((start (window-start)))
8751 (news-caesar-buffer-body arg)
8752 (set-window-start (get-buffer-window (current-buffer)) start))))))
8754 (defun gnus-summary-stop-page-breaking ()
8755 "Stop page breaking in the current article."
8757 (gnus-set-global-variables)
8758 (gnus-summary-select-article)
8759 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8761 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8763 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8764 "Move the current article to a different newsgroup.
8765 If N is a positive number, move the N next articles.
8766 If N is a negative number, move the N previous articles.
8767 If N is nil and any articles have been marked with the process mark,
8768 move those articles instead.
8769 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8770 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8771 re-spool using this method.
8772 For this function to work, both the current newsgroup and the
8773 newsgroup that you want to move to have to support the `request-move'
8774 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8776 (gnus-set-global-variables)
8777 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8778 (error "The current newsgroup does not support article moving"))
8779 (let ((articles (gnus-summary-work-articles n))
8780 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8781 art-group to-method sel-met)
8782 (if (and (not to-newsgroup) (not select-method))
8785 (format "Where do you want to move %s? %s"
8786 (if (> (length articles) 1)
8787 (format "these %d articles" (length articles))
8789 (if gnus-current-move-group
8790 (format "(%s default) " gnus-current-move-group)
8792 gnus-active-hashtb nil nil prefix)))
8795 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8796 (setq to-newsgroup (or gnus-current-move-group "")))
8797 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8798 (gnus-activate-group to-newsgroup)
8799 (error "No such group: %s" to-newsgroup))
8800 (setq gnus-current-move-group to-newsgroup)))
8801 (setq to-method (if select-method (list select-method "")
8802 (gnus-find-method-for-group to-newsgroup)))
8803 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8804 (error "%s does not support article copying" (car to-method)))
8805 (or (gnus-check-server to-method)
8806 (error "Can't open server %s" (car to-method)))
8807 (gnus-message 6 "Moving to %s: %s..."
8808 (or select-method to-newsgroup) articles)
8811 (gnus-request-move-article
8812 (car articles) ; Article to move
8813 gnus-newsgroup-name ; From newsgrouo
8814 (nth 1 (gnus-find-method-for-group
8815 gnus-newsgroup-name)) ; Server
8816 (list 'gnus-request-accept-article
8818 (list 'quote select-method)
8820 (not (cdr articles))) ; Accept form
8821 (not (cdr articles)))) ; Only save nov last time
8822 (let* ((buffer-read-only nil)
8825 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8827 (gnus-group-prefixed-name
8829 (if select-method (list select-method "")
8830 (gnus-find-method-for-group to-newsgroup)))
8831 gnus-newsrc-hashtb)))
8832 (info (nth 2 entry))
8833 (article (car articles)))
8834 (gnus-summary-goto-subject article)
8836 (delete-region (point) (progn (forward-line 1) (point)))
8837 ;; Update the group that has been moved to.
8839 () ; This group does not exist yet.
8840 (if (not (memq article gnus-newsgroup-unreads))
8841 (setcar (cdr (cdr info))
8842 (gnus-add-to-range (nth 2 info)
8843 (list (cdr art-group)))))
8844 ;; Copy any marks over to the new group.
8845 (let ((marks '((tick . gnus-newsgroup-marked)
8846 (dormant . gnus-newsgroup-dormant)
8847 (expire . gnus-newsgroup-expirable)
8848 (bookmark . gnus-newsgroup-bookmarks)
8849 (reply . gnus-newsgroup-replied)))
8850 (to-article (cdr art-group)))
8852 (if (memq article (symbol-value (cdr (car marks))))
8853 (gnus-add-marked-articles
8854 (car info) (car (car marks)) (list to-article) info))
8855 (setq marks (cdr marks)))))
8857 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8858 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8859 (setq gnus-newsgroup-dormant
8860 (delq article gnus-newsgroup-dormant))
8861 (setq gnus-newsgroup-reads
8862 (cons (cons article gnus-canceled-mark)
8863 gnus-newsgroup-reads)))
8864 (gnus-message 1 "Couldn't move article %s" (car articles)))
8865 (gnus-summary-remove-process-mark (car articles))
8866 (setq articles (cdr articles)))))
8868 (defun gnus-summary-respool-article (&optional n respool-method)
8869 "Respool the current article.
8870 The article will be squeezed through the mail spooling process again,
8871 which means that it will be put in some mail newsgroup or other
8872 depending on `nnmail-split-methods'.
8873 If N is a positive number, respool the N next articles.
8874 If N is a negative number, respool the N previous articles.
8875 If N is nil and any articles have been marked with the process mark,
8876 respool those articles instead.
8878 Respooling can be done both from mail groups and \"real\" newsgroups.
8879 In the former case, the articles in question will be moved from the
8880 current group into whatever groups they are destined to. In the
8881 latter case, they will be copied into the relevant groups."
8883 (gnus-set-global-variables)
8884 (let ((respool-methods (gnus-methods-using 'respool))
8886 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8888 (setq respool-method
8890 "What method do you want to use when respooling? "
8891 respool-methods nil t methname)))
8892 (or (string= respool-method "")
8893 (if (assoc (symbol-name
8894 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8896 (gnus-summary-move-article n nil (intern respool-method))
8897 (gnus-summary-copy-article n nil (intern respool-method))))))
8899 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8900 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8901 "Move the current article to a different newsgroup.
8902 If N is a positive number, move the N next articles.
8903 If N is a negative number, move the N previous articles.
8904 If N is nil and any articles have been marked with the process mark,
8905 move those articles instead.
8906 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8907 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8908 re-spool using this method.
8909 For this function to work, the newsgroup that you want to move to have
8910 to support the `request-move' and `request-accept'
8911 functions. (Ie. mail newsgroups at present.)"
8913 (gnus-set-global-variables)
8914 (let ((articles (gnus-summary-work-articles n))
8915 (copy-buf (get-buffer-create "*copy work*"))
8916 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8917 art-group to-method)
8918 (buffer-disable-undo copy-buf)
8919 (if (and (not to-newsgroup) (not select-method))
8922 (format "Where do you want to copy %s? %s"
8923 (if (> (length articles) 1)
8924 (format "these %d articles" (length articles))
8926 (if gnus-current-move-group
8927 (format "(%s default) " gnus-current-move-group)
8929 gnus-active-hashtb nil nil prefix)))
8932 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8933 (setq to-newsgroup (or gnus-current-move-group "")))
8934 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8935 (gnus-activate-group to-newsgroup)
8936 (error "No such group: %s" to-newsgroup))
8937 (setq gnus-current-move-group to-newsgroup)))
8938 (setq to-method (if select-method (list select-method "")
8939 (gnus-find-method-for-group to-newsgroup)))
8940 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8941 (error "%s does not support article copying" (car to-method)))
8942 (or (gnus-check-server to-method)
8943 (error "Can't open server %s" (car to-method)))
8945 (gnus-message 6 "Copying to %s: %s..."
8946 (or select-method to-newsgroup) articles)
8949 (set-buffer copy-buf)
8950 (gnus-request-article-this-buffer
8951 (car articles) gnus-newsgroup-name)
8952 (gnus-request-accept-article
8953 (if select-method (quote select-method) to-newsgroup)
8954 (not (cdr articles)))))
8957 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8959 (gnus-group-prefixed-name
8961 (if select-method (list select-method "")
8962 (gnus-find-method-for-group to-newsgroup)))
8963 gnus-newsrc-hashtb)))
8964 (info (nth 2 entry))
8965 (article (car articles)))
8966 ;; We copy the info over to the new group.
8968 () ; This group does not exist (yet).
8969 (if (not (memq article gnus-newsgroup-unreads))
8970 (setcar (cdr (cdr info))
8971 (gnus-add-to-range (nth 2 info)
8972 (list (cdr art-group)))))
8973 ;; Copy any marks over to the new group.
8974 (let ((marks '((tick . gnus-newsgroup-marked)
8975 (dormant . gnus-newsgroup-dormant)
8976 (expire . gnus-newsgroup-expirable)
8977 (bookmark . gnus-newsgroup-bookmarks)
8978 (reply . gnus-newsgroup-replied)))
8979 (to-article (cdr art-group)))
8981 (if (memq article (symbol-value (cdr (car marks))))
8982 (gnus-add-marked-articles
8983 (car info) (car (car marks)) (list to-article) info))
8984 (setq marks (cdr marks))))))
8985 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8986 (gnus-summary-remove-process-mark (car articles))
8987 (setq articles (cdr articles)))
8988 (kill-buffer copy-buf)))
8990 (defun gnus-summary-import-article (file)
8991 "Import a random file into a mail newsgroup."
8992 (interactive "fImport file: ")
8993 (let ((group gnus-newsgroup-name)
8995 (or (gnus-check-backend-function 'request-accept-article group)
8996 (error "%s does not support article importing" group))
8997 (or (file-readable-p file)
8998 (not (file-regular-p file))
8999 (error "Can't read %s" file))
9001 (set-buffer (get-buffer-create " *import file*"))
9002 (buffer-disable-undo (current-buffer))
9004 (insert-file-contents file)
9005 (goto-char (point-min))
9006 (if (nnheader-article-p)
9008 (setq atts (file-attributes file))
9009 (insert "From: " (read-string "From: ") "\n"
9010 "Subject: " (read-string "Subject: ") "\n"
9011 "Date: " (current-time-string (nth 5 atts)) "\n"
9012 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9013 (gnus-request-accept-article group t)
9014 (kill-buffer (current-buffer)))))
9016 (defun gnus-summary-expire-articles ()
9017 "Expire all articles that are marked as expirable in the current group."
9019 (if (not (gnus-check-backend-function
9020 'request-expire-articles gnus-newsgroup-name))
9022 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
9023 gnus-newsrc-hashtb)))
9024 (total (memq 'total-expire (nth 5 info)))
9025 (expirable (if total
9026 (gnus-list-of-read-articles gnus-newsgroup-name)
9027 (setq gnus-newsgroup-expirable
9028 (sort gnus-newsgroup-expirable '<))))
9032 (gnus-message 6 "Expiring articles...")
9033 ;; The list of articles that weren't expired is returned.
9034 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
9035 (or total (setq gnus-newsgroup-expirable es))
9036 ;; We go through the old list of expirable, and mark all
9037 ;; really expired articles as non-existant.
9038 (or (eq es expirable) ;If nothing was expired, we don't mark.
9039 (let ((gnus-use-cache nil))
9041 (or (memq (car expirable) es)
9042 (gnus-summary-mark-article
9043 (car expirable) gnus-canceled-mark))
9044 (setq expirable (cdr expirable)))))
9045 (gnus-message 6 "Expiring articles...done")))))
9047 (defun gnus-summary-expire-articles-now ()
9048 "Expunge all expirable articles in the current group.
9049 This means that *all* articles that are marked as expirable will be
9050 deleted forever, right now."
9052 (or gnus-expert-user
9054 "Are you really, really, really sure you want to expunge? ")
9056 (let ((nnmail-expiry-wait -1)
9057 (nnmail-expiry-wait-function nil))
9058 (gnus-summary-expire-articles)))
9060 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9061 (defun gnus-summary-delete-article (&optional n)
9062 "Delete the N next (mail) articles.
9063 This command actually deletes articles. This is not a marking
9064 command. The article will disappear forever from you life, never to
9066 If N is negative, delete backwards.
9067 If N is nil and articles have been marked with the process mark,
9068 delete these instead."
9070 (or (gnus-check-backend-function 'request-expire-articles
9071 gnus-newsgroup-name)
9072 (error "The current newsgroup does not support article deletion."))
9073 ;; Compute the list of articles to delete.
9074 (let ((articles (gnus-summary-work-articles n))
9076 (if (and gnus-novice-user
9078 (format "Do you really want to delete %s forever? "
9079 (if (> (length articles) 1) "these articles"
9082 ;; Delete the articles.
9083 (setq not-deleted (gnus-request-expire-articles
9084 articles gnus-newsgroup-name 'force))
9086 (gnus-summary-remove-process-mark (car articles))
9087 ;; The backend might not have been able to delete the article
9089 (or (memq (car articles) not-deleted)
9090 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9091 (setq articles (cdr articles))))
9092 (gnus-summary-position-cursor)
9095 (defun gnus-summary-edit-article (&optional force)
9096 "Enter into a buffer and edit the current article.
9097 This will have permanent effect only in mail groups.
9098 If FORCE is non-nil, allow editing of articles even in read-only
9102 (not (gnus-group-read-only-p))
9103 (error "The current newsgroup does not support article editing."))
9104 (gnus-summary-select-article t)
9105 (gnus-configure-windows 'article)
9106 (select-window (get-buffer-window gnus-article-buffer))
9107 (gnus-message 6 "C-c C-c to end edits")
9108 (setq buffer-read-only nil)
9110 (use-local-map (copy-keymap (current-local-map)))
9111 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9112 (buffer-enable-undo)
9114 (goto-char (point-min))
9115 (search-forward "\n\n" nil t))
9117 (defun gnus-summary-edit-article-done ()
9118 "Make edits to the current article permanent."
9120 (if (gnus-group-read-only-p)
9122 (gnus-summary-edit-article-postpone)
9123 (message "The current newsgroup does not support article editing.")
9125 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9128 (if (not (gnus-request-replace-article
9129 (cdr gnus-article-current) (car gnus-article-current)
9131 (error "Couldn't replace article.")
9133 (use-local-map gnus-article-mode-map)
9134 (setq buffer-read-only t)
9135 (buffer-disable-undo (current-buffer))
9136 (gnus-configure-windows 'summary))
9137 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))))
9139 (defun gnus-summary-edit-article-postpone ()
9140 "Postpone changes to the current article."
9143 (use-local-map gnus-article-mode-map)
9144 (setq buffer-read-only t)
9145 (buffer-disable-undo (current-buffer))
9146 (gnus-configure-windows 'summary)
9147 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9149 (defun gnus-summary-fancy-query ()
9150 "Query where the fancy respool algorithm would put this article."
9152 (gnus-summary-select-article)
9154 (set-buffer gnus-article-buffer)
9156 (goto-char (point-min))
9157 (search-forward "\n\n")
9158 (narrow-to-region (point-min) (point))
9159 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9161 ;; Summary score commands.
9163 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9165 (defun gnus-summary-raise-score (n)
9166 "Raise the score of the current article by N."
9168 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9170 (defun gnus-summary-set-score (n)
9171 "Set the score of the current article to N."
9173 ;; Skip dummy header line.
9175 (gnus-summary-show-thread)
9176 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9178 (let ((buffer-read-only nil))
9180 (gnus-summary-update-mark
9181 (if (= n (or gnus-summary-default-score 0)) ?
9182 (if (< n (or gnus-summary-default-score 0))
9183 gnus-score-below-mark gnus-score-over-mark)) 'score))
9184 (let* ((article (gnus-summary-article-number))
9185 (score (assq article gnus-newsgroup-scored)))
9186 (if score (setcdr score n)
9187 (setq gnus-newsgroup-scored
9188 (cons (cons article n) gnus-newsgroup-scored))))
9189 (gnus-summary-update-line)))
9191 (defun gnus-summary-current-score ()
9192 "Return the score of the current article."
9194 (message "%s" (gnus-summary-article-score)))
9196 ;; Summary marking commands.
9198 (defun gnus-summary-raise-same-subject-and-select (score)
9199 "Raise articles which has the same subject with SCORE and select the next."
9201 (let ((subject (gnus-summary-subject-string)))
9202 (gnus-summary-raise-score score)
9203 (while (gnus-summary-search-subject nil nil subject)
9204 (gnus-summary-raise-score score))
9205 (gnus-summary-next-article t)))
9207 (defun gnus-summary-raise-same-subject (score)
9208 "Raise articles which has the same subject with SCORE."
9210 (let ((subject (gnus-summary-subject-string)))
9211 (gnus-summary-raise-score score)
9212 (while (gnus-summary-search-subject nil nil subject)
9213 (gnus-summary-raise-score score))
9214 (gnus-summary-next-subject 1 t)))
9216 (defun gnus-score-default (level)
9217 (if level (prefix-numeric-value level)
9218 gnus-score-interactive-default-score))
9220 (defun gnus-summary-raise-thread (&optional score)
9221 "Raise the score of the articles in the current thread with SCORE."
9223 (setq score (gnus-score-default score))
9226 (let ((level (gnus-summary-thread-level)))
9227 (gnus-summary-raise-score score)
9228 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9229 (> (gnus-summary-thread-level) level))
9230 (gnus-summary-raise-score score))
9232 (let ((gnus-summary-check-current t))
9233 (or (zerop (gnus-summary-next-subject 1 t))
9235 (gnus-summary-recenter)
9236 (gnus-summary-position-cursor)
9237 (gnus-set-mode-line 'summary))
9239 (defun gnus-summary-lower-same-subject-and-select (score)
9240 "Raise articles which has the same subject with SCORE and select the next."
9242 (gnus-summary-raise-same-subject-and-select (- score)))
9244 (defun gnus-summary-lower-same-subject (score)
9245 "Raise articles which has the same subject with SCORE."
9247 (gnus-summary-raise-same-subject (- score)))
9249 (defun gnus-summary-lower-thread (&optional score)
9250 "Lower score of articles in the current thread with SCORE."
9252 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9254 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9255 "Mark articles which has the same subject as read, and then select the next.
9256 If UNMARK is positive, remove any kind of mark.
9257 If UNMARK is negative, tick articles."
9260 (setq unmark (prefix-numeric-value unmark)))
9262 (gnus-summary-mark-same-subject
9263 (gnus-summary-subject-string) unmark)))
9264 ;; Select next unread article. If auto-select-same mode, should
9265 ;; select the first unread article.
9266 (gnus-summary-next-article t (and gnus-auto-select-same
9267 (gnus-summary-subject-string)))
9268 (gnus-message 7 "%d article%s marked as %s"
9269 count (if (= count 1) " is" "s are")
9270 (if unmark "unread" "read"))))
9272 (defun gnus-summary-kill-same-subject (&optional unmark)
9273 "Mark articles which has the same subject as read.
9274 If UNMARK is positive, remove any kind of mark.
9275 If UNMARK is negative, tick articles."
9278 (setq unmark (prefix-numeric-value unmark)))
9280 (gnus-summary-mark-same-subject
9281 (gnus-summary-subject-string) unmark)))
9282 ;; If marked as read, go to next unread subject.
9284 ;; Go to next unread subject.
9285 (gnus-summary-next-subject 1 t))
9286 (gnus-message 7 "%d articles are marked as %s"
9287 count (if unmark "unread" "read"))))
9289 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9290 "Mark articles with same SUBJECT as read, and return marked number.
9291 If optional argument UNMARK is positive, remove any kinds of marks.
9292 If optional argument UNMARK is negative, mark articles as unread instead."
9296 ((null unmark) ; Mark as read.
9299 (gnus-summary-mark-article-as-read gnus-killed-mark)
9300 (gnus-summary-show-thread) t)
9301 (gnus-summary-search-forward nil subject))
9302 (setq count (1+ count))))
9303 ((> unmark 0) ; Tick.
9306 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9307 (gnus-summary-show-thread) t)
9308 (gnus-summary-search-forward nil subject))
9309 (setq count (1+ count))))
9310 (t ; Mark as unread.
9313 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9314 (gnus-summary-show-thread) t)
9315 (gnus-summary-search-forward nil subject))
9316 (setq count (1+ count)))))
9317 (gnus-set-mode-line 'summary)
9318 ;; Return the number of marked articles.
9321 (defun gnus-summary-mark-as-processable (n &optional unmark)
9322 "Set the process mark on the next N articles.
9323 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9324 the process mark instead. The difference between N and the actual
9325 number of articles marked is returned."
9327 (let ((backward (< n 0))
9332 (gnus-summary-remove-process-mark
9333 (gnus-summary-article-number))
9334 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9335 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9337 (if (/= 0 n) (gnus-message 7 "No more articles"))
9338 (gnus-summary-recenter)
9339 (gnus-summary-position-cursor)
9342 (defun gnus-summary-unmark-as-processable (n)
9343 "Remove the process mark from the next N articles.
9344 If N is negative, mark backward instead. The difference between N and
9345 the actual number of articles marked is returned."
9347 (gnus-summary-mark-as-processable n t))
9349 (defun gnus-summary-unmark-all-processable ()
9350 "Remove the process mark from all articles."
9353 (while gnus-newsgroup-processable
9354 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9355 (gnus-summary-position-cursor))
9357 (defun gnus-summary-mark-as-expirable (n)
9358 "Mark N articles forward as expirable.
9359 If N is negative, mark backward instead. The difference between N and
9360 the actual number of articles marked is returned."
9362 (gnus-summary-mark-forward n gnus-expirable-mark))
9364 (defun gnus-summary-mark-article-as-replied (article)
9365 "Mark ARTICLE replied and update the summary line."
9366 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9367 (let ((buffer-read-only nil))
9368 (if (gnus-summary-goto-subject article)
9370 (gnus-summary-update-mark gnus-replied-mark 'replied)
9373 (defun gnus-summary-set-bookmark (article)
9374 "Set a bookmark in current article."
9375 (interactive (list (gnus-summary-article-number)))
9376 (if (or (not (get-buffer gnus-article-buffer))
9377 (not gnus-current-article)
9378 (not gnus-article-current)
9379 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9380 (error "No current article selected"))
9381 ;; Remove old bookmark, if one exists.
9382 (let ((old (assq article gnus-newsgroup-bookmarks)))
9383 (if old (setq gnus-newsgroup-bookmarks
9384 (delq old gnus-newsgroup-bookmarks))))
9385 ;; Set the new bookmark, which is on the form
9386 ;; (article-number . line-number-in-body).
9387 (setq gnus-newsgroup-bookmarks
9391 (set-buffer gnus-article-buffer)
9395 (goto-char (point-min))
9396 (search-forward "\n\n" nil t)
9399 gnus-newsgroup-bookmarks))
9400 (gnus-message 6 "A bookmark has been added to the current article."))
9402 (defun gnus-summary-remove-bookmark (article)
9403 "Remove the bookmark from the current article."
9404 (interactive (list (gnus-summary-article-number)))
9405 ;; Remove old bookmark, if one exists.
9406 (let ((old (assq article gnus-newsgroup-bookmarks)))
9409 (setq gnus-newsgroup-bookmarks
9410 (delq old gnus-newsgroup-bookmarks))
9411 (gnus-message 6 "Removed bookmark."))
9412 (gnus-message 6 "No bookmark in current article."))))
9414 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9415 (defun gnus-summary-mark-as-dormant (n)
9416 "Mark N articles forward as dormant.
9417 If N is negative, mark backward instead. The difference between N and
9418 the actual number of articles marked is returned."
9420 (gnus-summary-mark-forward n gnus-dormant-mark))
9422 (defun gnus-summary-set-process-mark (article)
9423 "Set the process mark on ARTICLE and update the summary line."
9424 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9425 (let ((buffer-read-only nil))
9426 (if (gnus-summary-goto-subject article)
9428 (gnus-summary-show-thread)
9429 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9431 (gnus-summary-update-mark gnus-process-mark 'replied)
9434 (defun gnus-summary-remove-process-mark (article)
9435 "Remove the process mark from ARTICLE and update the summary line."
9436 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9437 (let ((buffer-read-only nil))
9438 (if (gnus-summary-goto-subject article)
9440 (gnus-summary-show-thread)
9441 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9443 (gnus-summary-update-mark ? 'replied)
9444 (if (memq article gnus-newsgroup-replied)
9445 (gnus-summary-update-mark gnus-replied-mark 'replied))
9448 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9449 "Mark N articles as read forwards.
9450 If N is negative, mark backwards instead.
9451 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9453 The difference between N and the actual number of articles marked is
9456 (gnus-set-global-variables)
9457 (let ((backward (< n 0))
9458 (gnus-summary-goto-unread
9459 (and gnus-summary-goto-unread
9460 (not (memq mark (list gnus-unread-mark
9461 gnus-ticked-mark gnus-dormant-mark)))))
9463 (mark (or mark gnus-del-mark)))
9465 (gnus-summary-mark-article nil mark no-expire)
9466 (zerop (gnus-summary-next-subject
9467 (if backward -1 1) gnus-summary-goto-unread t)))
9469 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9470 (gnus-summary-recenter)
9471 (gnus-summary-position-cursor)
9472 (gnus-set-mode-line 'summary)
9475 (defun gnus-summary-mark-article-as-read (mark)
9476 "Mark the current article quickly as read with MARK."
9477 (let ((article (gnus-summary-article-number)))
9478 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9479 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9480 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9481 (setq gnus-newsgroup-reads
9482 (cons (cons article mark) gnus-newsgroup-reads))
9483 ;; Possibly remove from cache, if that is used.
9484 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9485 (and gnus-newsgroup-auto-expire
9486 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9487 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9488 (= mark gnus-read-mark))
9490 (setq mark gnus-expirable-mark)
9491 (setq gnus-newsgroup-expirable
9492 (cons article gnus-newsgroup-expirable))))
9493 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9496 (gnus-summary-update-mark mark 'unread)
9499 (defun gnus-summary-mark-article-as-unread (mark)
9500 "Mark the current article quickly as unread with MARK."
9501 (let ((article (gnus-summary-article-number)))
9502 (or (memq article gnus-newsgroup-unreads)
9503 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9504 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9505 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9506 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9507 (setq gnus-newsgroup-reads
9508 (delq (assq article gnus-newsgroup-reads)
9509 gnus-newsgroup-reads))
9510 (if (= mark gnus-ticked-mark)
9511 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9512 (if (= mark gnus-dormant-mark)
9513 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9515 ;; See whether the article is to be put in the cache.
9517 (vectorp (gnus-get-header-by-num article))
9519 (gnus-cache-possibly-enter-article
9520 gnus-newsgroup-name article
9521 (gnus-get-header-by-num article)
9522 (= mark gnus-ticked-mark)
9523 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9525 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9528 (gnus-summary-update-mark mark 'unread)
9531 (defun gnus-summary-mark-article (&optional article mark no-expire)
9532 "Mark ARTICLE with MARK. MARK can be any character.
9533 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9534 (dormant) and `?E' (expirable).
9535 If MARK is nil, then the default character `?D' is used.
9536 If ARTICLE is nil, then the article on the current line will be
9539 (setq mark (aref mark 0)))
9540 ;; If no mark is given, then we check auto-expiring.
9541 (and (not no-expire)
9542 gnus-newsgroup-auto-expire
9545 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9546 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9547 (= mark gnus-read-mark))))
9548 (setq mark gnus-expirable-mark))
9549 (let* ((mark (or mark gnus-del-mark))
9550 (article (or article (gnus-summary-article-number))))
9551 (or article (error "No article on current line"))
9552 (if (or (= mark gnus-unread-mark)
9553 (= mark gnus-ticked-mark)
9554 (= mark gnus-dormant-mark))
9555 (gnus-mark-article-as-unread article mark)
9556 (gnus-mark-article-as-read article mark))
9558 ;; See whether the article is to be put in the cache.
9560 (not (= mark gnus-canceled-mark))
9561 (vectorp (gnus-get-header-by-num article))
9563 (gnus-cache-possibly-enter-article
9564 gnus-newsgroup-name article
9565 (gnus-get-header-by-num article)
9566 (= mark gnus-ticked-mark)
9567 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9569 (if (gnus-summary-goto-subject article)
9570 (let ((buffer-read-only nil))
9571 (gnus-summary-show-thread)
9572 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9575 (gnus-summary-update-mark mark 'unread)
9578 (defun gnus-summary-update-mark (mark type)
9580 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9581 (buffer-read-only nil)
9585 (forward-char forward)
9586 (setq plist (text-properties-at (point)))
9589 (and plist (add-text-properties (1- (point)) (point) plist))
9590 (and (eq type 'unread)
9592 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark))
9593 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9595 (defun gnus-mark-article-as-read (article &optional mark)
9596 "Enter ARTICLE in the pertinent lists and remove it from others."
9597 ;; Make the article expirable.
9598 (let ((mark (or mark gnus-del-mark)))
9599 (if (= mark gnus-expirable-mark)
9600 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9601 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9602 ;; Remove from unread and marked lists.
9603 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9604 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9605 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9606 (setq gnus-newsgroup-reads
9607 (cons (cons article mark) gnus-newsgroup-reads))
9608 ;; Possibly remove from cache, if that is used.
9609 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9611 (defun gnus-mark-article-as-unread (article &optional mark)
9612 "Enter ARTICLE in the pertinent lists and remove it from others."
9613 (let ((mark (or mark gnus-ticked-mark)))
9614 ;; Add to unread list.
9615 (or (memq article gnus-newsgroup-unreads)
9616 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9617 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9618 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9619 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9620 (setq gnus-newsgroup-reads
9621 (delq (assq article gnus-newsgroup-reads)
9622 gnus-newsgroup-reads))
9623 (if (= mark gnus-ticked-mark)
9624 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9625 (if (= mark gnus-dormant-mark)
9626 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9628 (defalias 'gnus-summary-mark-as-unread-forward
9629 'gnus-summary-tick-article-forward)
9630 (make-obsolete 'gnus-summary-mark-as-unread-forward
9631 'gnus-summary-tick-article-forward)
9632 (defun gnus-summary-tick-article-forward (n)
9633 "Tick N articles forwards.
9634 If N is negative, tick backwards instead.
9635 The difference between N and the number of articles ticked is returned."
9637 (gnus-summary-mark-forward n gnus-ticked-mark))
9639 (defalias 'gnus-summary-mark-as-unread-backward
9640 'gnus-summary-tick-article-backward)
9641 (make-obsolete 'gnus-summary-mark-as-unread-backward
9642 'gnus-summary-tick-article-backward)
9643 (defun gnus-summary-tick-article-backward (n)
9644 "Tick N articles backwards.
9645 The difference between N and the number of articles ticked is returned."
9647 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9649 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9650 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9651 (defun gnus-summary-tick-article (&optional article clear-mark)
9652 "Mark current article as unread.
9653 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9654 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9655 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9658 (defun gnus-summary-mark-as-read-forward (n)
9659 "Mark N articles as read forwards.
9660 If N is negative, mark backwards instead.
9661 The difference between N and the actual number of articles marked is
9664 (gnus-summary-mark-forward n gnus-del-mark t))
9666 (defun gnus-summary-mark-as-read-backward (n)
9667 "Mark the N articles as read backwards.
9668 The difference between N and the actual number of articles marked is
9671 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9673 (defun gnus-summary-mark-as-read (&optional article mark)
9674 "Mark current article as read.
9675 ARTICLE specifies the article to be marked as read.
9676 MARK specifies a string to be inserted at the beginning of the line."
9677 (gnus-summary-mark-article article mark))
9679 (defun gnus-summary-clear-mark-forward (n)
9680 "Clear marks from N articles forward.
9681 If N is negative, clear backward instead.
9682 The difference between N and the number of marks cleared is returned."
9684 (gnus-summary-mark-forward n gnus-unread-mark))
9686 (defun gnus-summary-clear-mark-backward (n)
9687 "Clear marks from N articles backward.
9688 The difference between N and the number of marks cleared is returned."
9690 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9692 (defun gnus-summary-mark-unread-as-read ()
9693 "Intended to be used by `gnus-summary-mark-article-hook'."
9694 (or (memq gnus-current-article gnus-newsgroup-marked)
9695 (memq gnus-current-article gnus-newsgroup-dormant)
9696 (memq gnus-current-article gnus-newsgroup-expirable)
9697 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9699 (defun gnus-summary-mark-region-as-read (point mark all)
9700 "Mark all unread articles between point and mark as read.
9701 If given a prefix, mark all articles between point and mark as read,
9702 even ticked and dormant ones."
9703 (interactive "r\nP")
9713 (not (memq (gnus-summary-article-number)
9714 gnus-newsgroup-marked))
9715 (not (memq (gnus-summary-article-number)
9716 gnus-newsgroup-dormant))))
9717 (gnus-summary-mark-article
9718 (gnus-summary-article-number) gnus-del-mark))
9720 (zerop (forward-line 1))))))
9722 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9723 (defalias 'gnus-summary-delete-marked-as-read
9724 'gnus-summary-remove-lines-marked-as-read)
9725 (make-obsolete 'gnus-summary-delete-marked-as-read
9726 'gnus-summary-remove-lines-marked-as-read)
9727 (defun gnus-summary-remove-lines-marked-as-read ()
9728 "Remove lines that are marked as read."
9730 (gnus-summary-remove-lines-marked-with
9732 (lambda (char) (char-to-string (symbol-value char)))
9733 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9734 gnus-killed-mark gnus-kill-file-mark
9735 gnus-low-score-mark gnus-expirable-mark
9736 gnus-canceled-mark gnus-catchup-mark)
9739 (defalias 'gnus-summary-delete-marked-with
9740 'gnus-summary-remove-lines-marked-with)
9741 (make-obsolete 'gnus-summary-delete-marked-with
9742 'gnus-summary-remove-lines-marked-with)
9743 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9744 (defun gnus-summary-remove-lines-marked-with (marks)
9745 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9746 (interactive "sMarks: ")
9747 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9748 (gnus-set-global-variables)
9749 (let ((buffer-read-only nil)
9750 (orig-article (gnus-summary-article-number))
9751 (marks (concat "^[" marks "]")))
9752 (goto-char (point-min))
9753 (if gnus-newsgroup-adaptive
9754 (gnus-score-remove-lines-adaptive marks)
9755 (while (re-search-forward marks nil t)
9756 (gnus-delete-line)))
9757 ;; If we use dummy roots, we have to do an additional sweep over
9759 (if (not (eq gnus-summary-make-false-root 'dummy))
9761 (goto-char (point-min))
9762 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9763 (while (re-search-forward marks nil t)
9764 (if (gnus-subject-equal
9765 (gnus-summary-subject-string)
9768 (gnus-summary-subject-string)))
9771 (gnus-delete-line))))
9772 (or (zerop (buffer-size))
9773 (gnus-summary-goto-subject orig-article)
9775 (gnus-summary-prev-subject 1)
9776 (gnus-summary-position-cursor)))))
9778 (defun gnus-summary-expunge-below (&optional score)
9779 "Remove articles with score less than SCORE."
9781 (gnus-set-global-variables)
9782 (setq score (if score
9783 (prefix-numeric-value score)
9784 (or gnus-summary-default-score 0)))
9786 (set-buffer gnus-summary-buffer)
9787 (goto-char (point-min))
9788 (let ((buffer-read-only nil)
9791 (if (< (gnus-summary-article-score) score)
9795 (delete-region beg (point)))
9798 (or (zerop (buffer-size))
9800 (gnus-summary-prev-subject 1)
9801 (gnus-summary-position-cursor))))))
9803 (defun gnus-summary-mark-below (score mark)
9804 "Mark articles with score less than SCORE with MARK."
9805 (interactive "P\ncMark: ")
9806 (gnus-set-global-variables)
9807 (setq score (if score
9808 (prefix-numeric-value score)
9809 (or gnus-summary-default-score 0)))
9811 (set-buffer gnus-summary-buffer)
9812 (goto-char (point-min))
9814 (and (< (gnus-summary-article-score) score)
9815 (gnus-summary-mark-article nil mark))
9818 (defun gnus-summary-kill-below (&optional score)
9819 "Mark articles with score below SCORE as read."
9821 (gnus-set-global-variables)
9822 (gnus-summary-mark-below score gnus-killed-mark))
9824 (defun gnus-summary-clear-above (&optional score)
9825 "Clear all marks from articles with score above SCORE."
9827 (gnus-set-global-variables)
9828 (gnus-summary-mark-above score gnus-unread-mark))
9830 (defun gnus-summary-tick-above (&optional score)
9831 "Tick all articles with score above SCORE."
9833 (gnus-set-global-variables)
9834 (gnus-summary-mark-above score gnus-ticked-mark))
9836 (defun gnus-summary-mark-above (score mark)
9837 "Mark articles with score over SCORE with MARK."
9838 (interactive "P\ncMark: ")
9839 (gnus-set-global-variables)
9840 (setq score (if score
9841 (prefix-numeric-value score)
9842 (or gnus-summary-default-score 0)))
9844 (set-buffer gnus-summary-buffer)
9845 (goto-char (point-min))
9847 (if (> (gnus-summary-article-score) score)
9849 (gnus-summary-mark-article nil mark)
9851 (forward-line 1)))))
9853 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9854 (defun gnus-summary-show-all-expunged ()
9855 "Display all the hidden articles that were expunged for low scores."
9857 (gnus-set-global-variables)
9858 (let ((buffer-read-only nil))
9859 (let ((scored gnus-newsgroup-scored)
9862 (or (gnus-summary-goto-subject (car (car scored)))
9863 (and (setq h (gnus-get-header-by-num (car (car scored))))
9864 (< (cdr (car scored)) gnus-summary-expunge-below)
9865 (setq headers (cons h headers))))
9866 (setq scored (cdr scored)))
9867 (or headers (error "No expunged articles hidden."))
9868 (goto-char (point-min))
9870 (gnus-summary-update-lines
9873 (gnus-summary-prepare-unthreaded (nreverse headers))
9875 (goto-char (point-min))
9876 (gnus-summary-position-cursor)))
9878 (defun gnus-summary-show-all-dormant ()
9879 "Display all the hidden articles that are marked as dormant."
9881 (gnus-set-global-variables)
9882 (let ((buffer-read-only nil))
9883 (let ((dormant gnus-newsgroup-dormant)
9886 (or (gnus-summary-goto-subject (car dormant))
9887 (and (setq h (gnus-get-header-by-num (car dormant)))
9888 (setq headers (cons h headers))))
9889 (setq dormant (cdr dormant)))
9890 (or headers (error "No dormant articles hidden."))
9891 (goto-char (point-min))
9893 (gnus-summary-update-lines
9896 (gnus-summary-prepare-unthreaded (nreverse headers))
9898 (goto-char (point-min))
9899 (gnus-summary-position-cursor)))
9901 (defun gnus-summary-hide-all-dormant ()
9902 "Hide all dormant articles."
9904 (gnus-set-global-variables)
9905 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9906 (gnus-summary-position-cursor))
9908 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9909 "Mark all articles not marked as unread in this newsgroup as read.
9910 If prefix argument ALL is non-nil, all articles are marked as read.
9911 If QUIETLY is non-nil, no questions will be asked.
9912 If TO-HERE is non-nil, it should be a point in the buffer. All
9913 articles before this point will be marked as read.
9914 The number of articles marked as read is returned."
9916 (gnus-set-global-variables)
9919 (not gnus-interactive-catchup) ;Without confirmation?
9923 "Mark absolutely all articles as read? "
9924 "Mark all unread articles as read? ")))
9926 (not gnus-newsgroup-adaptive)
9927 (not gnus-newsgroup-auto-expire))
9929 (and all (setq gnus-newsgroup-marked nil
9930 gnus-newsgroup-dormant nil))
9931 (setq gnus-newsgroup-unreads
9932 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9933 ;; We actually mark all articles as canceled, which we
9934 ;; have to do when using auto-expiry or adaptive scoring.
9935 (gnus-summary-show-all-threads)
9936 (if (gnus-summary-first-subject (not all))
9938 (if to-here (< (point) to-here) t)
9939 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9940 (gnus-summary-search-subject nil (not all)))))
9942 (setq gnus-newsgroup-unreads
9943 (append gnus-newsgroup-marked
9944 gnus-newsgroup-dormant)))))
9945 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9946 (if (and (not to-here) (eq 'nnvirtual (car method)))
9947 (nnvirtual-catchup-group
9948 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9949 (gnus-summary-position-cursor)))
9951 (defun gnus-summary-catchup-to-here (&optional all)
9952 "Mark all unticked articles before the current one as read.
9953 If ALL is non-nil, also mark ticked and dormant articles as read."
9955 (gnus-set-global-variables)
9957 (and (zerop (forward-line -1))
9960 (gnus-summary-catchup all t (point))
9961 (gnus-set-mode-line 'summary))))
9962 (gnus-summary-position-cursor))
9964 (defun gnus-summary-catchup-all (&optional quietly)
9965 "Mark all articles in this newsgroup as read."
9967 (gnus-set-global-variables)
9968 (gnus-summary-catchup t quietly))
9970 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9971 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9972 If prefix argument ALL is non-nil, all articles are marked as read."
9974 (gnus-set-global-variables)
9975 (gnus-summary-catchup all quietly nil 'fast)
9976 ;; Select next newsgroup or exit.
9977 (if (eq gnus-auto-select-next 'quietly)
9978 (gnus-summary-next-group nil)
9979 (gnus-summary-exit)))
9981 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9982 "Mark all articles in this newsgroup as read, and then exit."
9984 (gnus-set-global-variables)
9985 (gnus-summary-catchup-and-exit t quietly))
9987 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9988 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9989 "Mark all articles in this group as read and select the next group.
9990 If given a prefix, mark all articles, unread as well as ticked, as
9993 (gnus-set-global-variables)
9994 (gnus-summary-catchup all)
9995 (gnus-summary-next-group))
9997 ;; Thread-based commands.
9999 (defun gnus-summary-toggle-threads (&optional arg)
10000 "Toggle showing conversation threads.
10001 If ARG is positive number, turn showing conversation threads on."
10003 (gnus-set-global-variables)
10004 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10005 (setq gnus-show-threads
10006 (if (null arg) (not gnus-show-threads)
10007 (> (prefix-numeric-value arg) 0)))
10008 (gnus-summary-prepare)
10009 (gnus-summary-goto-subject current)
10010 (gnus-summary-position-cursor)))
10012 (defun gnus-summary-show-all-threads ()
10013 "Show all threads."
10015 (gnus-set-global-variables)
10017 (let ((buffer-read-only nil))
10018 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10019 (gnus-summary-position-cursor))
10021 (defun gnus-summary-show-thread ()
10022 "Show thread subtrees.
10023 Returns nil if no thread was there to be shown."
10025 (gnus-set-global-variables)
10026 (let ((buffer-read-only nil)
10027 (orig (prog1 (point) (gnus-summary-hide-thread)))
10028 ;; first goto end then to beg, to have point at beg after let
10029 (end (progn (end-of-line) (point)))
10030 (beg (progn (beginning-of-line) (point))))
10032 ;; Any hidden lines here?
10033 (search-forward "\r" end t)
10034 (subst-char-in-region beg end ?\^M ?\n t)
10036 (gnus-summary-position-cursor))))
10038 (defun gnus-summary-hide-all-threads ()
10039 "Hide all thread subtrees."
10041 (gnus-set-global-variables)
10043 (goto-char (point-min))
10044 (gnus-summary-hide-thread)
10045 (while (and (not (eobp)) (zerop (forward-line 1)))
10046 (gnus-summary-hide-thread)))
10047 (gnus-summary-position-cursor))
10049 (defun gnus-summary-hide-thread ()
10050 "Hide thread subtrees.
10051 Returns nil if no threads were there to be hidden."
10053 (gnus-set-global-variables)
10054 (let ((buffer-read-only nil)
10056 (level (gnus-summary-thread-level))
10058 ;; Go forward until either the buffer ends or the subthread
10062 (while (and (zerop (forward-line 1))
10063 (> (gnus-summary-thread-level) level))
10064 (setq end (point)))
10068 (search-backward "\n" start t))
10069 (subst-char-in-region start end ?\n ?\^M t)
10071 (gnus-summary-position-cursor)))))
10073 (defun gnus-summary-go-to-next-thread (&optional previous)
10074 "Go to the same level (or less) next thread.
10075 If PREVIOUS is non-nil, go to previous thread instead.
10076 Return the article number moved to, or nil if moving was impossible."
10077 (let ((level (gnus-summary-thread-level))
10078 (article (gnus-summary-article-number)))
10080 (while (and (zerop (forward-line -1))
10081 (> (gnus-summary-thread-level) level)))
10082 (while (and (save-excursion
10085 (zerop (forward-line 1))
10086 (> (gnus-summary-thread-level) level))))
10087 (gnus-summary-recenter)
10088 (gnus-summary-position-cursor)
10089 (let ((oart (gnus-summary-article-number)))
10090 (and (/= oart article) oart))))
10092 (defun gnus-summary-next-thread (n)
10093 "Go to the same level next N'th thread.
10094 If N is negative, search backward instead.
10095 Returns the difference between N and the number of skips actually
10098 (gnus-set-global-variables)
10099 (let ((backward (< n 0))
10101 (while (and (> n 0)
10102 (gnus-summary-go-to-next-thread backward))
10104 (gnus-summary-position-cursor)
10105 (if (/= 0 n) (gnus-message 7 "No more threads"))
10108 (defun gnus-summary-prev-thread (n)
10109 "Go to the same level previous N'th thread.
10110 Returns the difference between N and the number of skips actually
10113 (gnus-set-global-variables)
10114 (gnus-summary-next-thread (- n)))
10116 (defun gnus-summary-go-down-thread (&optional same)
10117 "Go down one level in the current thread.
10118 If SAME is non-nil, also move to articles of the same level."
10119 (let ((level (gnus-summary-thread-level))
10121 (if (and (zerop (forward-line 1))
10122 (> (gnus-summary-thread-level) level))
10127 (defun gnus-summary-go-up-thread ()
10128 "Go up one level in the current thread."
10129 (let ((level (gnus-summary-thread-level))
10131 (while (and (zerop (forward-line -1))
10132 (>= (gnus-summary-thread-level) level)))
10133 (if (>= (gnus-summary-thread-level) level)
10139 (defun gnus-summary-down-thread (n)
10140 "Go down thread N steps.
10141 If N is negative, go up instead.
10142 Returns the difference between N and how many steps down that were
10145 (gnus-set-global-variables)
10148 (while (and (> n 0)
10149 (if up (gnus-summary-go-up-thread)
10150 (gnus-summary-go-down-thread)))
10152 (gnus-summary-position-cursor)
10153 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10156 (defun gnus-summary-up-thread (n)
10157 "Go up thread N steps.
10158 If N is negative, go up instead.
10159 Returns the difference between N and how many steps down that were
10162 (gnus-set-global-variables)
10163 (gnus-summary-down-thread (- n)))
10165 (defun gnus-summary-kill-thread (&optional unmark)
10166 "Mark articles under current thread as read.
10167 If the prefix argument is positive, remove any kinds of marks.
10168 If the prefix argument is negative, tick articles instead."
10170 (gnus-set-global-variables)
10172 (setq unmark (prefix-numeric-value unmark)))
10174 (level (gnus-summary-thread-level)))
10176 ;; Expand the thread.
10177 (gnus-summary-show-thread)
10179 ;; Mark the article...
10180 (cond ((null unmark) (gnus-summary-mark-article-as-read
10182 ((> unmark 0) (gnus-summary-mark-article-as-unread
10184 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10185 ;; ...and go forward until either the buffer ends or the subtree
10187 (if (not (and (zerop (forward-line 1))
10188 (> (gnus-summary-thread-level) level)))
10189 (setq killing nil))))
10190 ;; Hide killed subtrees.
10192 gnus-thread-hide-killed
10193 (gnus-summary-hide-thread))
10194 ;; If marked as read, go to next unread subject.
10196 ;; Go to next unread subject.
10197 (gnus-summary-next-subject 1 t)))
10198 (gnus-set-mode-line 'summary))
10200 ;; Summary sorting commands
10202 (defun gnus-summary-sort-by-number (&optional reverse)
10203 "Sort summary buffer by article number.
10204 Argument REVERSE means reverse order."
10206 (gnus-set-global-variables)
10208 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10209 ;; a function, so we wrap it.
10210 (cons (lambda () (gnus-summary-article-number))
10211 'gnus-thread-sort-by-number) reverse))
10213 (defun gnus-summary-sort-by-author (&optional reverse)
10214 "Sort summary buffer by author name alphabetically.
10215 If case-fold-search is non-nil, case of letters is ignored.
10216 Argument REVERSE means reverse order."
10218 (gnus-set-global-variables)
10222 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10224 gnus-extract-address-components
10225 (mail-header-from header))))
10226 (concat (or (car extract) (cdr extract))
10227 "\r" (mail-header-subject header))))
10228 'gnus-thread-sort-by-author)
10231 (defun gnus-summary-sort-by-subject (&optional reverse)
10232 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10233 If case-fold-search is non-nil, case of letters is ignored.
10234 Argument REVERSE means reverse order."
10236 (gnus-set-global-variables)
10240 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10242 gnus-extract-address-components
10243 (mail-header-from header))))
10245 (downcase (gnus-simplify-subject (gnus-summary-subject-string) t))
10246 "\r" (or (car extract) (cdr extract)))))
10247 'gnus-thread-sort-by-subject)
10250 (defun gnus-summary-sort-by-date (&optional reverse)
10251 "Sort summary buffer by date.
10252 Argument REVERSE means reverse order."
10254 (gnus-set-global-variables)
10258 (gnus-sortable-date
10260 (gnus-get-header-by-num (gnus-summary-article-number)))))
10261 'gnus-thread-sort-by-date)
10264 (defun gnus-summary-sort-by-score (&optional reverse)
10265 "Sort summary buffer by score.
10266 Argument REVERSE means reverse order."
10268 (gnus-set-global-variables)
10270 (cons (lambda () (gnus-summary-article-score))
10271 'gnus-thread-sort-by-score)
10274 (defvar gnus-summary-already-sorted nil)
10275 (defun gnus-summary-sort (predicate reverse)
10276 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10277 (if gnus-summary-already-sorted
10279 (let (buffer-read-only)
10280 (if (not gnus-show-threads)
10281 ;; We do untreaded sorting...
10283 (goto-char (point-min))
10284 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10285 ;; ... or we do threaded sorting.
10286 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10287 (gnus-summary-prepare-hook nil)
10288 (gnus-summary-already-sorted nil))
10289 ;; We do that by simply regenerating the threads.
10290 (gnus-summary-prepare)
10291 (and gnus-show-threads
10292 gnus-thread-hide-subtree
10293 (gnus-summary-hide-all-threads))
10294 ;; If in async mode, we send some info to the backend.
10295 (and gnus-newsgroup-async
10296 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10297 (gnus-request-asynchronous
10298 gnus-newsgroup-name
10299 (if (and gnus-asynchronous-article-function
10300 (fboundp gnus-asynchronous-article-function))
10301 (funcall gnus-asynchronous-article-function
10302 gnus-newsgroup-threads)
10303 gnus-newsgroup-threads))))))))
10306 (defun gnus-sortable-date (date)
10307 "Make sortable string by string-lessp from DATE.
10308 Timezone package is used."
10309 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10310 (year (aref date 0))
10311 (month (aref date 1))
10312 (day (aref date 2)))
10313 (timezone-make-sortable-date
10315 (timezone-make-time-string
10316 (aref date 3) (aref date 4) (aref date 5)))))
10319 ;; Summary saving commands.
10321 (defun gnus-summary-save-article (&optional n)
10322 "Save the current article using the default saver function.
10323 If N is a positive number, save the N next articles.
10324 If N is a negative number, save the N previous articles.
10325 If N is nil and any articles have been marked with the process mark,
10326 save those articles instead.
10327 The variable `gnus-default-article-saver' specifies the saver function."
10329 (gnus-set-global-variables)
10330 (let ((articles (gnus-summary-work-articles n)))
10332 (let ((header (gnus-get-header-by-num (car articles))))
10333 (if (vectorp header)
10335 (save-window-excursion
10336 (gnus-summary-select-article t nil nil (car articles)))
10337 (or gnus-save-all-headers
10338 (gnus-article-hide-headers t))
10339 ;; Remove any X-Gnus lines.
10342 (set-buffer gnus-article-buffer)
10343 (let ((buffer-read-only nil))
10344 (goto-char (point-min))
10345 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10347 (while (re-search-forward "^X-Gnus" nil t)
10348 (beginning-of-line)
10349 (delete-region (point)
10350 (progn (forward-line 1) (point))))
10352 (save-window-excursion
10353 (if gnus-default-article-saver
10354 (funcall gnus-default-article-saver)
10355 (error "No default saver is defined."))))
10356 (if (assq 'name header)
10357 (gnus-copy-file (cdr (assq 'name header)))
10358 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10359 (gnus-summary-remove-process-mark (car articles))
10360 (setq articles (cdr articles)))
10361 (gnus-summary-position-cursor)
10364 (defun gnus-summary-pipe-output (&optional arg)
10365 "Pipe the current article to a subprocess.
10366 If N is a positive number, pipe the N next articles.
10367 If N is a negative number, pipe the N previous articles.
10368 If N is nil and any articles have been marked with the process mark,
10369 pipe those articles instead."
10371 (gnus-set-global-variables)
10372 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10373 (gnus-summary-save-article arg)))
10375 (defun gnus-summary-save-article-mail (&optional arg)
10376 "Append the current article to an mail file.
10377 If N is a positive number, save the N next articles.
10378 If N is a negative number, save the N previous articles.
10379 If N is nil and any articles have been marked with the process mark,
10380 save those articles instead."
10382 (gnus-set-global-variables)
10383 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10384 (gnus-summary-save-article arg)))
10386 (defun gnus-summary-save-article-rmail (&optional arg)
10387 "Append the current article to an rmail file.
10388 If N is a positive number, save the N next articles.
10389 If N is a negative number, save the N previous articles.
10390 If N is nil and any articles have been marked with the process mark,
10391 save those articles instead."
10393 (gnus-set-global-variables)
10394 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10395 (gnus-summary-save-article arg)))
10397 (defun gnus-summary-save-article-file (&optional arg)
10398 "Append the current article to a file.
10399 If N is a positive number, save the N next articles.
10400 If N is a negative number, save the N previous articles.
10401 If N is nil and any articles have been marked with the process mark,
10402 save those articles instead."
10404 (gnus-set-global-variables)
10405 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10406 (gnus-summary-save-article arg)))
10408 (defun gnus-read-save-file-name (prompt default-name)
10409 (let ((methods gnus-split-methods)
10411 (if (not gnus-split-methods)
10414 (set-buffer gnus-article-buffer)
10415 (gnus-narrow-to-headers)
10417 (goto-char (point-min))
10418 (and (condition-case ()
10419 (re-search-forward (car (car methods)) nil t)
10421 (setq split-name (cons (nth 1 (car methods)) split-name)))
10422 (setq methods (cdr methods)))
10424 (cond ((null split-name)
10426 (concat prompt " (default "
10427 (file-name-nondirectory default-name) ") ")
10428 (file-name-directory default-name)
10430 ((= 1 (length split-name))
10432 (concat prompt " (default " (car split-name) ") ")
10433 gnus-article-save-directory
10434 (concat gnus-article-save-directory (car split-name))))
10436 (setq split-name (mapcar (lambda (el) (list el))
10437 (nreverse split-name)))
10438 (let ((result (completing-read
10439 (concat prompt " ")
10440 split-name nil nil)))
10441 (concat gnus-article-save-directory
10442 (if (string= result "")
10443 (car (car split-name))
10446 (defun gnus-summary-save-in-rmail (&optional filename)
10447 "Append this article to Rmail file.
10448 Optional argument FILENAME specifies file name.
10449 Directory to save to is default to `gnus-article-save-directory' which
10450 is initialized from the SAVEDIR environment variable."
10452 (gnus-set-global-variables)
10453 (let ((default-name
10454 (funcall gnus-rmail-save-name gnus-newsgroup-name
10455 gnus-current-headers gnus-newsgroup-last-rmail)))
10457 (setq filename (gnus-read-save-file-name
10458 "Save in rmail file:" default-name)))
10459 (gnus-make-directory (file-name-directory filename))
10460 (gnus-eval-in-buffer-window
10461 gnus-article-buffer
10465 (gnus-output-to-rmail filename))))
10466 ;; Remember the directory name to save articles
10467 (setq gnus-newsgroup-last-rmail filename)))
10469 (defun gnus-summary-save-in-mail (&optional filename)
10470 "Append this article to Unix mail file.
10471 Optional argument FILENAME specifies file name.
10472 Directory to save to is default to `gnus-article-save-directory' which
10473 is initialized from the SAVEDIR environment variable."
10475 (gnus-set-global-variables)
10476 (let ((default-name
10477 (funcall gnus-mail-save-name gnus-newsgroup-name
10478 gnus-current-headers gnus-newsgroup-last-mail)))
10480 (setq filename (gnus-read-save-file-name
10481 "Save in Unix mail file:" default-name)))
10483 (expand-file-name filename
10485 (file-name-directory default-name))))
10486 (gnus-make-directory (file-name-directory filename))
10487 (gnus-eval-in-buffer-window
10488 gnus-article-buffer
10492 (if (and (file-readable-p filename) (rmail-file-p filename))
10493 (gnus-output-to-rmail filename)
10494 (rmail-output filename 1 t t)))))
10495 ;; Remember the directory name to save articles.
10496 (setq gnus-newsgroup-last-mail filename)))
10498 (defun gnus-summary-save-in-file (&optional filename)
10499 "Append this article to file.
10500 Optional argument FILENAME specifies file name.
10501 Directory to save to is default to `gnus-article-save-directory' which
10502 is initialized from the SAVEDIR environment variable."
10504 (gnus-set-global-variables)
10505 (let ((default-name
10506 (funcall gnus-file-save-name gnus-newsgroup-name
10507 gnus-current-headers gnus-newsgroup-last-file)))
10509 (setq filename (gnus-read-save-file-name
10510 "Save in file:" default-name)))
10511 (gnus-make-directory (file-name-directory filename))
10512 (gnus-eval-in-buffer-window
10513 gnus-article-buffer
10517 (gnus-output-to-file filename))))
10518 ;; Remember the directory name to save articles.
10519 (setq gnus-newsgroup-last-file filename)))
10521 (defun gnus-summary-save-in-pipe (&optional command)
10522 "Pipe this article to subprocess."
10524 (gnus-set-global-variables)
10525 (let ((command (read-string "Shell command on article: "
10526 gnus-last-shell-command)))
10527 (if (string-equal command "")
10528 (setq command gnus-last-shell-command))
10529 (gnus-eval-in-buffer-window
10530 gnus-article-buffer
10533 (shell-command-on-region (point-min) (point-max) command nil)))
10534 (setq gnus-last-shell-command command)))
10536 ;; Summary extract commands
10538 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10539 (let ((buffer-read-only nil)
10540 (article (gnus-summary-article-number))
10542 (or (gnus-summary-goto-subject article)
10543 (error (format "No such article: %d" article)))
10544 (gnus-summary-position-cursor)
10545 ;; If all commands are to be bunched up on one line, we collect
10547 (if gnus-view-pseudos-separately
10549 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10552 (setq action (cdr (assq 'action (car ps))))
10553 (setq files (list (cdr (assq 'name (car ps)))))
10554 (while (and ps (cdr ps)
10555 (string= (or action "1")
10556 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10557 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10558 (setcdr ps (cdr (cdr ps))))
10561 (if (not (string-match "%s" action))
10562 (setq files (cons " " files)))
10563 (setq files (cons " " files))
10564 (and (assq 'execute (car ps))
10565 (setcdr (assq 'execute (car ps))
10566 (funcall (if (string-match "%s" action)
10569 (mapconcat (lambda (f) f) files " ")))))
10570 (setq ps (cdr ps)))))
10571 (if (and gnus-view-pseudos (not not-view))
10573 (and (assq 'execute (car pslist))
10574 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10575 (eq gnus-view-pseudos 'not-confirm)))
10576 (setq pslist (cdr pslist)))
10579 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10580 (gnus-summary-article-number)))
10583 (insert " " (file-name-nondirectory
10584 (cdr (assq 'name (car pslist))))
10585 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10586 (add-text-properties
10587 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10588 'gnus-mark gnus-unread-mark
10590 'gnus-pseudo (car pslist)))
10592 (gnus-sethash (int-to-string gnus-reffed-article-number)
10593 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10594 (setq gnus-newsgroup-unreads
10595 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10596 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10597 (setq pslist (cdr pslist)))))))
10599 (defun gnus-pseudos< (p1 p2)
10600 (let ((c1 (cdr (assq 'action p1)))
10601 (c2 (cdr (assq 'action p2))))
10602 (and c1 c2 (string< c1 c2))))
10604 (defun gnus-request-pseudo-article (props)
10605 (cond ((assq 'execute props)
10606 (gnus-execute-command (cdr (assq 'execute props)))))
10607 (let ((gnus-current-article (gnus-summary-article-number)))
10608 (run-hooks 'gnus-mark-article-hook)))
10610 (defun gnus-execute-command (command &optional automatic)
10612 (gnus-article-setup-buffer)
10613 (set-buffer gnus-article-buffer)
10614 (let ((command (if automatic command (read-string "Command: " command)))
10615 (buffer-read-only nil))
10617 (insert "$ " command "\n\n")
10618 (if gnus-view-pseudo-asynchronously
10619 (start-process "gnus-execute" nil "sh" "-c" command)
10620 (call-process "sh" nil t nil "-c" command)))))
10622 (defun gnus-copy-file (file &optional to)
10625 (list (read-file-name "Copy file: " default-directory)
10626 (read-file-name "Copy file to: " default-directory)))
10627 (gnus-set-global-variables)
10628 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10629 (and (file-directory-p to)
10630 (setq to (concat (file-name-as-directory to)
10631 (file-name-nondirectory file))))
10632 (copy-file file to))
10634 ;; Summary kill commands.
10636 (defun gnus-summary-edit-global-kill (article)
10637 "Edit the \"global\" kill file."
10638 (interactive (list (gnus-summary-article-number)))
10639 (gnus-set-global-variables)
10640 (gnus-group-edit-global-kill article))
10642 (defun gnus-summary-edit-local-kill ()
10643 "Edit a local kill file applied to the current newsgroup."
10645 (gnus-set-global-variables)
10646 (setq gnus-current-headers
10648 (int-to-string (gnus-summary-article-number))
10649 gnus-newsgroup-headers-hashtb-by-number))
10650 (gnus-set-global-variables)
10651 (gnus-group-edit-local-kill
10652 (gnus-summary-article-number) gnus-newsgroup-name))
10656 ;;; Gnus article mode
10659 (put 'gnus-article-mode 'mode-class 'special)
10661 (defvar gnus-boogaboo nil)
10663 (if gnus-article-mode-map
10665 (setq gnus-article-mode-map (make-keymap))
10666 (suppress-keymap gnus-article-mode-map)
10667 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10668 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10669 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10670 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10671 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10672 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10673 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10674 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10675 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10676 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10677 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10679 ;; Duplicate almost all summary keystrokes in the article mode map.
10682 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10683 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10684 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10685 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10686 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10687 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10688 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10689 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10690 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10691 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10692 "\C-c\C-v\C-v" "\C-d" "v"
10693 ;; "Mt" "M!" "Md" "Mr"
10694 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10695 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10696 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10697 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10698 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10699 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10700 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10701 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10702 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10703 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10704 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10706 (while (and gnus-boogaboo commands) ; disabled
10707 (define-key gnus-article-mode-map (car commands)
10708 'gnus-article-summary-command)
10709 (setq commands (cdr commands))))
10711 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10712 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10713 "=" "n" "^" "\M-^")))
10714 (while (and gnus-boogaboo commands) ; disabled
10715 (define-key gnus-article-mode-map (car commands)
10716 'gnus-article-summary-command-nosave)
10717 (setq commands (cdr commands)))))
10720 (defun gnus-article-mode ()
10721 "Major mode for displaying an article.
10723 All normal editing commands are switched off.
10725 The following commands are available:
10727 \\<gnus-article-mode-map>
10728 \\[gnus-article-next-page]\t Scroll the article one page forwards
10729 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10730 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10731 \\[gnus-article-show-summary]\t Display the summary buffer
10732 \\[gnus-article-mail]\t Send a reply to the address near point
10733 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10734 \\[gnus-info-find-node]\t Go to the Gnus info node"
10736 (if gnus-visual (gnus-article-make-menu-bar))
10737 (kill-all-local-variables)
10738 (setq mode-line-modified "-- ")
10739 (make-local-variable 'mode-line-format)
10740 (setq mode-line-format (copy-sequence mode-line-format))
10741 (and (equal (nth 3 mode-line-format) " ")
10742 (setcar (nthcdr 3 mode-line-format) ""))
10743 (setq mode-name "Article")
10744 (setq major-mode 'gnus-article-mode)
10745 (make-local-variable 'minor-mode-alist)
10746 (or (assq 'gnus-show-mime minor-mode-alist)
10747 (setq minor-mode-alist
10748 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10749 (use-local-map gnus-article-mode-map)
10750 (make-local-variable 'page-delimiter)
10751 (setq page-delimiter gnus-page-delimiter)
10752 (buffer-disable-undo (current-buffer))
10753 (setq buffer-read-only t) ;Disable modification
10754 (run-hooks 'gnus-article-mode-hook))
10756 (defun gnus-article-setup-buffer ()
10757 "Initialize article mode buffer."
10758 ;; Returns the article buffer.
10759 (if (get-buffer gnus-article-buffer)
10761 (set-buffer gnus-article-buffer)
10762 (buffer-disable-undo (current-buffer))
10763 (setq buffer-read-only t)
10764 (gnus-add-current-to-buffer-list)
10765 (or (eq major-mode 'gnus-article-mode)
10766 (gnus-article-mode))
10769 (set-buffer (get-buffer-create gnus-article-buffer))
10770 (gnus-add-current-to-buffer-list)
10771 (gnus-article-mode)
10772 (current-buffer))))
10774 ;; Set article window start at LINE, where LINE is the number of lines
10775 ;; from the head of the article.
10776 (defun gnus-article-set-window-start (&optional line)
10778 (get-buffer-window gnus-article-buffer)
10780 (set-buffer gnus-article-buffer)
10781 (goto-char (point-min))
10784 (gnus-message 6 "Moved to bookmark")
10785 (search-forward "\n\n" nil t)
10786 (forward-line line)
10789 (defun gnus-request-article-this-buffer (article group)
10790 "Get an article and insert it into this buffer."
10791 (setq group (or group gnus-newsgroup-name))
10793 ;; Open server if it has closed.
10794 (gnus-check-server (gnus-find-method-for-group group))
10796 ;; Using `gnus-request-article' directly will insert the article into
10797 ;; `nntp-server-buffer' - so we'll save some time by not having to
10798 ;; copy it from the server buffer into the article buffer.
10800 ;; We only request an article by message-id when we do not have the
10801 ;; headers for it, so we'll have to get those.
10802 (and (stringp article)
10803 (let ((gnus-override-method gnus-refer-article-method))
10804 (gnus-read-header article)))
10806 ;; If the article number is negative, that means that this article
10807 ;; doesn't belong in this newsgroup (possibly), so we find its
10808 ;; message-id and request it by id instead of number.
10809 (if (not (numberp article))
10812 (set-buffer gnus-summary-buffer)
10813 (let ((header (gnus-get-header-by-num article)))
10815 (if (vectorp header)
10816 ;; It's a real article.
10817 (setq article (mail-header-id header))
10818 ;; It is an extracted pseudo-article.
10819 (setq article 'pseudo)
10820 (gnus-request-pseudo-article header)))
10822 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10823 (if (not (eq (car method) 'nneething))
10825 (let ((dir (concat (file-name-as-directory (nth 1 method))
10826 (mail-header-subject header))))
10827 (if (file-directory-p dir)
10829 (setq article 'nneething)
10830 (gnus-group-enter-directory dir)))))))))
10832 ;; Check the cache.
10833 (if (and gnus-use-cache
10835 (gnus-cache-request-article article group))
10837 ;; Get the article and into the article buffer.
10838 (if (or (stringp article) (numberp article))
10841 (let ((gnus-override-method
10842 (and (stringp article) gnus-refer-article-method)))
10843 (and (gnus-request-article article group (current-buffer))
10847 (defun gnus-read-header (id)
10848 "Read the headers of article ID and enter them into the Gnus system."
10850 (if (not (setq header
10851 (car (if (let ((gnus-nov-is-evil t))
10852 (gnus-retrieve-headers
10853 (list id) gnus-newsgroup-name))
10854 (gnus-get-newsgroup-headers)))))
10857 (mail-header-set-number header gnus-reffed-article-number))
10858 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10859 (gnus-sethash (int-to-string (mail-header-number header)) header
10860 gnus-newsgroup-headers-hashtb-by-number)
10862 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10863 (setq gnus-current-headers header)
10866 (defun gnus-article-prepare (article &optional all-headers header)
10867 "Prepare ARTICLE in article mode buffer.
10868 ARTICLE should either be an article number or a Message-ID.
10869 If ARTICLE is an id, HEADER should be the article headers.
10870 If ALL-HEADERS is non-nil, no headers are hidden."
10872 ;; Make sure we start in a summary buffer.
10873 (or (eq major-mode 'gnus-summary-mode)
10874 (set-buffer gnus-summary-buffer))
10875 (setq gnus-summary-buffer (current-buffer))
10876 ;; Make sure the connection to the server is alive.
10877 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10880 (gnus-find-method-for-group gnus-newsgroup-name))
10881 (gnus-request-group gnus-newsgroup-name t)))
10882 (let* ((article (if header (mail-header-number header) article))
10883 (summary-buffer (current-buffer))
10884 (internal-hook gnus-article-internal-prepare-hook)
10885 (group gnus-newsgroup-name)
10888 (gnus-article-setup-buffer)
10889 (set-buffer gnus-article-buffer)
10890 (if (not (setq result (let ((buffer-read-only nil))
10891 (gnus-request-article-this-buffer
10893 ;; There is no such article.
10895 (if (not (numberp article))
10897 (setq gnus-article-current
10898 (cons gnus-newsgroup-name article))
10899 (set-buffer gnus-summary-buffer)
10900 (setq gnus-current-article article)
10901 (gnus-summary-mark-article article gnus-canceled-mark))
10902 (gnus-message 1 "No such article (may be canceled)")
10905 (if (or (eq result 'pseudo) (eq result 'nneething))
10908 (set-buffer summary-buffer)
10909 (setq gnus-last-article gnus-current-article
10910 gnus-newsgroup-history (cons gnus-current-article
10911 gnus-newsgroup-history)
10912 gnus-current-article 0
10913 gnus-current-headers nil
10914 gnus-article-current nil)
10915 (if (eq result 'nneething)
10916 (gnus-configure-windows 'summary)
10917 (gnus-configure-windows 'article))
10918 (gnus-set-global-variables))
10919 (gnus-set-mode-line 'article))
10920 ;; The result from the `request' was an actual article -
10921 ;; or at least some text that is now displayed in the
10923 (if (and (numberp article)
10924 (not (eq article gnus-current-article)))
10925 ;; Seems like a new article has been selected.
10926 ;; `gnus-current-article' must be an article number.
10928 (set-buffer summary-buffer)
10929 (setq gnus-last-article gnus-current-article
10930 gnus-newsgroup-history (cons gnus-current-article
10931 gnus-newsgroup-history)
10932 gnus-current-article article
10933 gnus-current-headers
10934 (gnus-get-header-by-num gnus-current-article)
10935 gnus-article-current
10936 (cons gnus-newsgroup-name gnus-current-article))
10937 (gnus-summary-show-thread)
10938 (run-hooks 'gnus-mark-article-hook)
10939 (gnus-set-mode-line 'summary)
10941 (run-hooks 'gnus-visual-mark-article-hook))
10942 ;; Set the global newsgroup variables here.
10943 ;; Suggested by Jim Sisolak
10944 ;; <sisolak@trans4.neep.wisc.edu>.
10945 (gnus-set-global-variables)
10946 (setq gnus-have-all-headers
10947 (or all-headers gnus-show-all-headers))
10948 (and gnus-use-cache
10949 (vectorp (gnus-get-header-by-number article))
10950 (gnus-cache-possibly-enter-article
10952 (gnus-get-header-by-number article)
10953 (memq article gnus-newsgroup-marked)
10954 (memq article gnus-newsgroup-dormant)
10955 (memq article gnus-newsgroup-unreads)))))
10956 ;; Hooks for getting information from the article.
10957 ;; This hook must be called before being narrowed.
10958 (let (buffer-read-only)
10959 (run-hooks 'internal-hook)
10960 (run-hooks 'gnus-article-prepare-hook)
10961 ;; Decode MIME message.
10962 (if (and gnus-show-mime
10963 (or (not gnus-strict-mime)
10964 (gnus-fetch-field "Mime-Version")))
10965 (funcall gnus-show-mime-method))
10966 ;; Perform the article display hooks.
10967 (run-hooks 'gnus-article-display-hook))
10969 (goto-char (point-min))
10970 (and gnus-break-pages (gnus-narrow-to-page))
10971 (gnus-set-mode-line 'article)
10972 (gnus-configure-windows 'article)
10973 (goto-char (point-min))
10976 (defun gnus-article-show-all-headers ()
10977 "Show all article headers in article mode buffer."
10979 (gnus-article-setup-buffer)
10980 (set-buffer gnus-article-buffer)
10981 (let ((buffer-read-only nil))
10982 (remove-text-properties (point-min) (point-max)
10983 gnus-hidden-properties))))
10985 (defun gnus-article-hide-headers-if-wanted ()
10986 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10987 Provided for backwards compatability."
10988 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10989 (gnus-article-hide-headers)))
10991 (defun gnus-article-hide-headers (&optional delete)
10992 "Hide unwanted headers and possibly sort them as well."
10995 (set-buffer gnus-article-buffer)
10997 (let ((sorted gnus-sorted-header-list)
10998 (buffer-read-only nil)
10999 want-list beg want-l)
11000 ;; First we narrow to just the headers.
11002 (goto-char (point-min))
11003 ;; Hide any "From " lines at the beginning of (mail) articles.
11004 (while (looking-at "From ")
11007 (add-text-properties (point-min) (point) gnus-hidden-properties))
11008 ;; Then treat the rest of the header lines.
11011 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
11012 ;; Then we use the two regular expressions
11013 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
11014 ;; select which header lines is to remain visible in the
11016 (goto-char (point-min))
11017 (while (re-search-forward "^[^ \t]*:" nil t)
11018 (beginning-of-line)
11019 ;; We add the headers we want to keep to a list and delete
11020 ;; them from the buffer.
11021 (if (or (and (stringp gnus-visible-headers)
11022 (looking-at gnus-visible-headers))
11023 (and (not (stringp gnus-visible-headers))
11024 (stringp gnus-ignored-headers)
11025 (not (looking-at gnus-ignored-headers))))
11029 ;; Be sure to get multi-line headers...
11030 (re-search-forward "^[^ \t]*:" nil t)
11031 (beginning-of-line)
11033 (cons (buffer-substring beg (point)) want-list))
11034 (delete-region beg (point))
11037 ;; Next we perform the sorting by looking at
11038 ;; `gnus-sorted-header-list'.
11039 (goto-char (point-min))
11040 (while (and sorted want-list)
11041 (setq want-l want-list)
11043 (not (string-match (car sorted) (car want-l))))
11044 (setq want-l (cdr want-l)))
11047 (insert (car want-l))
11048 (setq want-list (delq (car want-l) want-list))))
11049 (setq sorted (cdr sorted)))
11050 ;; Any headers that were not matched by the sorted list we
11051 ;; just tack on the end of the visible header list.
11053 (insert (car want-list))
11054 (setq want-list (cdr want-list)))
11055 ;; And finally we make the unwanted headers invisible.
11057 (delete-region (point) (point-max))
11058 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11059 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11061 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11062 (defun gnus-article-treat-overstrike ()
11063 "Translate overstrikes into bold text."
11066 (set-buffer gnus-article-buffer)
11067 (let ((buffer-read-only nil))
11068 (while (search-forward "\b" nil t)
11069 (let ((next (following-char))
11070 (previous (char-after (- (point) 2))))
11071 (cond ((eq next previous)
11072 (put-text-property (- (point) 2) (point)
11074 (put-text-property (point) (1+ (point))
11077 (put-text-property (1- (point)) (1+ (point))
11079 (put-text-property (1- (point)) (point)
11082 (put-text-property (- (point) 2) (point)
11084 (put-text-property (point) (1+ (point))
11085 'face 'underline))))))))
11087 (defun gnus-article-word-wrap ()
11088 "Format too long lines."
11091 (set-buffer gnus-article-buffer)
11092 (let ((buffer-read-only nil))
11093 (goto-char (point-min))
11094 (search-forward "\n\n" nil t)
11096 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11097 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11098 (adaptive-fill-mode t))
11099 (while (not (eobp))
11100 (and (>= (current-column) (min fill-column (window-width)))
11101 (/= (preceding-char) ?:)
11102 (fill-paragraph nil))
11103 (end-of-line 2))))))
11105 (defun gnus-article-remove-cr ()
11106 "Remove carriage returns from an article."
11109 (set-buffer gnus-article-buffer)
11110 (let ((buffer-read-only nil))
11111 (goto-char (point-min))
11112 (while (search-forward "\r" nil t)
11113 (replace-match "" t t)))))
11115 (defun gnus-article-display-x-face (&optional force)
11116 "Look for an X-Face header and display it if present."
11117 (interactive (list 'force))
11119 (set-buffer gnus-article-buffer)
11120 (let ((inhibit-point-motion-hooks t)
11121 (case-fold-search nil)
11124 (goto-char (point-min))
11125 (search-forward "\n\n")
11126 (narrow-to-region (point-min) (point))
11127 (goto-char (point-min))
11128 (setq from (mail-fetch-field "from"))
11129 (if (not (and gnus-article-x-face-command
11131 (not gnus-article-x-face-too-ugly)
11132 (and gnus-article-x-face-too-ugly from
11133 (not (string-match gnus-article-x-face-too-ugly
11136 (goto-char (point-min))
11137 (re-search-forward "^X-Face: " nil t))))
11139 (let ((beg (point))
11140 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11141 (if (symbolp gnus-article-x-face-command)
11142 (and (or (fboundp gnus-article-x-face-command)
11143 (error "%s is not a function"
11144 gnus-article-x-face-command))
11145 (funcall gnus-article-x-face-command beg end))
11146 (call-process-region beg end "sh" nil 0 nil
11147 "-c" gnus-article-x-face-command))))))))
11149 (defun gnus-article-de-quoted-unreadable (&optional force)
11150 "Do a naive translation of a quoted-printable-encoded article.
11151 This is in no way, shape or form meant as a replacement for real MIME
11152 processing, but is simply a stop-gap measure until MIME support is
11154 If FORCE, decode the article whether it is marked as quoted-printable
11156 (interactive (list 'force))
11158 (set-buffer gnus-article-buffer)
11159 (let ((case-fold-search t)
11160 (buffer-read-only nil)
11161 (type (gnus-fetch-field "content-transfer-encoding")))
11162 (if (or force (and type (string-match "quoted-printable" type)))
11164 (goto-char (point-min))
11165 (search-forward "\n\n" nil 'move)
11166 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11168 (defun gnus-mime-decode-quoted-printable (from to)
11169 ;; Decode quoted-printable from region between FROM and TO.
11172 (while (search-forward "=" to t)
11173 (cond ((eq (following-char) ?\n)
11176 ((looking-at "[0-9A-F][0-9A-F]")
11178 (insert (hexl-hex-string-to-integer
11179 (buffer-substring (point) (+ 2 (point)))))
11183 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11185 (defvar gnus-article-time-units
11186 (list (cons 'year (* 365.25 24 60 60))
11187 (cons 'week (* 7 24 60 60))
11188 (cons 'day (* 24 60 60))
11189 (cons 'hour (* 60 60))
11193 (defun gnus-article-date-ut (&optional type)
11194 "Convert DATE date to universal time in the current article.
11195 If TYPE is `local', convert to local time; if it is `lapsed', output
11196 how much time has lapsed since DATE."
11197 (interactive (list 'ut))
11198 (let ((date (mail-header-date (or gnus-current-headers
11199 (gnus-get-header-by-number
11200 (gnus-summary-article-number))"")))
11201 (date-regexp "^Date: \\|^X-Sent: "))
11206 (set-buffer gnus-article-buffer)
11207 (let ((buffer-read-only nil))
11208 (goto-char (point-min))
11209 (if (and (re-search-forward date-regexp nil t)
11211 (beginning-of-line)
11212 (looking-at date-regexp)))
11213 (delete-region (gnus-point-at-bol)
11214 (progn (end-of-line) (1+ (point))))
11215 (goto-char (point-min))
11216 (goto-char (- (search-forward "\n\n") 2)))
11220 (concat "Date: " (condition-case ()
11221 (timezone-make-date-arpa-standard date)
11227 (timezone-make-date-arpa-standard date nil "UT")
11231 ;; If the date is seriously mangled, the timezone
11232 ;; functions are liable to bug out, so we condition-case
11233 ;; the entire thing.
11234 (let* ((real-sec (condition-case ()
11235 (- (gnus-seconds-since-epoch
11236 (timezone-make-date-arpa-standard
11237 (current-time-string)
11238 (current-time-zone) "UT"))
11239 (gnus-seconds-since-epoch
11240 (timezone-make-date-arpa-standard
11243 (sec (abs real-sec))
11251 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11253 (setq sec (- sec (* num (cdr unit))))
11255 (concat (if prev ", " "") (int-to-string
11257 " " (symbol-name (car unit))
11258 (if (> num 1) "s" ""))
11260 gnus-article-time-units "")
11263 " in the future\n")))))
11265 (error "Unknown conversion type: %s" type)))))))))
11267 (defun gnus-article-date-local ()
11268 "Convert the current article date to the local timezone."
11270 (gnus-article-date-ut 'local))
11272 (defun gnus-article-date-lapsed ()
11273 "Convert the current article date to time lapsed since it was sent."
11275 (gnus-article-date-ut 'lapsed))
11277 (defun gnus-article-maybe-highlight ()
11278 "Do some article highlighting if `gnus-visual' is non-nil."
11279 (if gnus-visual (gnus-article-highlight-some)))
11283 (defun gnus-output-to-rmail (file-name)
11284 "Append the current article to an Rmail file named FILE-NAME."
11286 ;; Most of these codes are borrowed from rmailout.el.
11287 (setq file-name (expand-file-name file-name))
11288 (setq rmail-default-rmail-file file-name)
11289 (let ((artbuf (current-buffer))
11290 (tmpbuf (get-buffer-create " *Gnus-output*")))
11292 (or (get-file-buffer file-name)
11293 (file-exists-p file-name)
11294 (if (gnus-yes-or-no-p
11295 (concat "\"" file-name "\" does not exist, create it? "))
11296 (let ((file-buffer (create-file-buffer file-name)))
11298 (set-buffer file-buffer)
11299 (rmail-insert-rmail-file-header)
11300 (let ((require-final-newline nil))
11301 (write-region (point-min) (point-max) file-name t 1)))
11302 (kill-buffer file-buffer))
11303 (error "Output file does not exist")))
11304 (set-buffer tmpbuf)
11305 (buffer-disable-undo (current-buffer))
11307 (insert-buffer-substring artbuf)
11308 (gnus-convert-article-to-rmail)
11309 ;; Decide whether to append to a file or to an Emacs buffer.
11310 (let ((outbuf (get-file-buffer file-name)))
11312 (append-to-file (point-min) (point-max) file-name)
11313 ;; File has been visited, in buffer OUTBUF.
11314 (set-buffer outbuf)
11315 (let ((buffer-read-only nil)
11316 (msg (and (boundp 'rmail-current-message)
11317 (symbol-value 'rmail-current-message))))
11318 ;; If MSG is non-nil, buffer is in RMAIL mode.
11321 (narrow-to-region (point-max) (point-max))))
11322 (insert-buffer-substring tmpbuf)
11325 (goto-char (point-min))
11327 (search-backward "\^_")
11328 (narrow-to-region (point) (point-max))
11329 (goto-char (1+ (point-min)))
11330 (rmail-count-new-messages t)
11331 (rmail-show-message msg)))))))
11332 (kill-buffer tmpbuf)))
11334 (defun gnus-output-to-file (file-name)
11335 "Append the current article to a file named FILE-NAME."
11336 (setq file-name (expand-file-name file-name))
11337 (let ((artbuf (current-buffer))
11338 (tmpbuf (get-buffer-create " *Gnus-output*")))
11340 (set-buffer tmpbuf)
11341 (buffer-disable-undo (current-buffer))
11343 (insert-buffer-substring artbuf)
11344 ;; Append newline at end of the buffer as separator, and then
11345 ;; save it to file.
11346 (goto-char (point-max))
11348 (append-to-file (point-min) (point-max) file-name))
11349 (kill-buffer tmpbuf)))
11351 (defun gnus-convert-article-to-rmail ()
11352 "Convert article in current buffer to Rmail message format."
11353 (let ((buffer-read-only nil))
11354 ;; Convert article directly into Babyl format.
11355 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11356 (goto-char (point-min))
11357 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11358 (while (search-forward "\n\^_" nil t) ;single char
11359 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11360 (goto-char (point-max))
11363 (defun gnus-narrow-to-page (&optional arg)
11364 "Make text outside current page invisible except for page delimiter.
11365 A numeric arg specifies to move forward or backward by that many pages,
11366 thus showing a page other than the one point was originally in."
11368 (setq arg (if arg (prefix-numeric-value arg) 0))
11370 (forward-page -1) ;Beginning of current page.
11375 (forward-page (1- arg))))
11376 ;; Find the end of the page.
11378 ;; If we stopped due to end of buffer, stay there.
11379 ;; If we stopped after a page delimiter, put end of restriction
11380 ;; at the beginning of that line.
11381 ;; These are commented out.
11382 ;; (if (save-excursion (beginning-of-line)
11383 ;; (looking-at page-delimiter))
11384 ;; (beginning-of-line))
11385 (narrow-to-region (point)
11387 ;; Find the top of the page.
11389 ;; If we found beginning of buffer, stay there.
11390 ;; If extra text follows page delimiter on same line,
11392 ;; Otherwise, show text starting with following line.
11393 (if (and (eolp) (not (bobp)))
11397 (defun gnus-gmt-to-local ()
11398 "Rewrite Date header described in GMT to local in current buffer.
11399 Intended to be used with gnus-article-prepare-hook."
11403 (goto-char (point-min))
11404 (narrow-to-region (point-min)
11405 (progn (search-forward "\n\n" nil 'move) (point)))
11406 (goto-char (point-min))
11407 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11408 (let ((buffer-read-only nil)
11409 (date (buffer-substring-no-properties
11410 (match-beginning 1) (match-end 1))))
11411 (delete-region (match-beginning 1) (match-end 1))
11413 (timezone-make-date-arpa-standard
11414 date nil (current-time-zone))))))))
11417 ;; Article mode commands
11419 (defun gnus-article-next-page (&optional lines)
11420 "Show next page of current article.
11421 If end of article, return non-nil. Otherwise return nil.
11422 Argument LINES specifies lines to be scrolled up."
11424 (move-to-window-line -1)
11425 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11426 (if (save-excursion
11428 (and (pos-visible-in-window-p) ;Not continuation line.
11430 ;; Nothing in this page.
11431 (if (or (not gnus-break-pages)
11434 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11436 (gnus-narrow-to-page 1) ;Go to next page.
11438 ;; More in this page.
11442 ;; Long lines may cause an end-of-buffer error.
11443 (goto-char (point-max))))
11446 (defun gnus-article-prev-page (&optional lines)
11447 "Show previous page of current article.
11448 Argument LINES specifies lines to be scrolled down."
11450 (move-to-window-line 0)
11451 (if (and gnus-break-pages
11453 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11455 (gnus-narrow-to-page -1) ;Go to previous page.
11456 (goto-char (point-max))
11458 (scroll-down lines)))
11460 (defun gnus-article-refer-article ()
11461 "Read article specified by message-id around point."
11463 (search-forward ">" nil t) ;Move point to end of "<....>".
11464 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11466 (buffer-substring (match-beginning 1) (match-end 1))))
11467 (set-buffer gnus-summary-buffer)
11468 (gnus-summary-refer-article message-id))
11469 (error "No references around point")))
11471 (defun gnus-article-show-summary ()
11472 "Reconfigure windows to show summary buffer."
11474 (gnus-configure-windows 'article)
11475 (gnus-summary-goto-subject gnus-current-article))
11477 (defun gnus-article-describe-briefly ()
11478 "Describe article mode commands briefly."
11481 (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")))
11483 (defun gnus-article-summary-command ()
11484 "Execute the last keystroke in the summary buffer."
11486 (let ((obuf (current-buffer))
11487 (owin (current-window-configuration))
11489 (switch-to-buffer gnus-summary-buffer 'norecord)
11490 (setq func (lookup-key (current-local-map) (this-command-keys)))
11491 (call-interactively func)
11493 (set-window-configuration owin)
11494 (set-window-point (get-buffer-window (current-buffer)) (point))))
11496 (defun gnus-article-summary-command-nosave ()
11497 "Execute the last keystroke in the summary buffer."
11500 (pop-to-buffer gnus-summary-buffer 'norecord)
11501 (setq func (lookup-key (current-local-map) (this-command-keys)))
11502 (call-interactively func)))
11505 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11508 (defalias 'gnus-batch-kill 'gnus-batch-score)
11510 (defun gnus-batch-score ()
11511 "Run batched scoring.
11512 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11513 Newsgroups is a list of strings in Bnews format. If you want to score
11514 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11515 score the alt hierarchy, you'd say \"!alt.all\"."
11518 (gnus-newsrc-parse-options
11519 (apply (function concat)
11520 (mapcar (lambda (g) (concat g " "))
11521 command-line-args-left))))
11522 (gnus-expert-user t)
11523 (nnmail-spool-file nil)
11524 (gnus-use-dribble-file nil)
11525 (yes (car yes-and-no))
11526 (no (cdr yes-and-no))
11528 ;; Disable verbose message.
11529 gnus-novice-user gnus-large-newsgroup)
11530 ;; Eat all arguments.
11531 (setq command-line-args-left nil)
11534 ;; Apply kills to specified newsgroups in command line arguments.
11535 (setq newsrc (cdr gnus-newsrc-alist))
11537 (setq group (car (car newsrc)))
11538 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11539 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11541 (or (eq (car entry) t)
11542 (not (zerop (car entry)))))
11543 (if yes (string-match yes group) t)
11544 (or (null no) (not (string-match no group))))
11546 (gnus-summary-read-group group nil t)
11547 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11548 (gnus-summary-exit))))
11549 (setq newsrc (cdr newsrc)))
11551 (switch-to-buffer gnus-group-buffer)
11552 (gnus-group-save-newsrc)))
11554 (defun gnus-apply-kill-file ()
11555 "Apply a kill file to the current newsgroup.
11556 Returns the number of articles marked as read."
11557 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11558 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11559 (gnus-apply-kill-file-internal)
11562 (defun gnus-kill-save-kill-buffer ()
11564 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11565 (if (get-file-buffer file)
11567 (set-buffer (get-file-buffer file))
11568 (and (buffer-modified-p) (save-buffer))
11569 (kill-buffer (current-buffer)))))))
11571 (defvar gnus-kill-file-name "KILL"
11572 "Suffix of the kill files.")
11574 (defun gnus-newsgroup-kill-file (newsgroup)
11575 "Return the name of a kill file name for NEWSGROUP.
11576 If NEWSGROUP is nil, return the global kill file name instead."
11577 (cond ((or (null newsgroup)
11578 (string-equal newsgroup ""))
11579 ;; The global KILL file is placed at top of the directory.
11580 (expand-file-name gnus-kill-file-name
11581 (or gnus-kill-files-directory "~/News")))
11582 ((gnus-use-long-file-name 'not-kill)
11583 ;; Append ".KILL" to newsgroup name.
11584 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
11585 "." gnus-kill-file-name)
11586 (or gnus-kill-files-directory "~/News")))
11588 ;; Place "KILL" under the hierarchical directory.
11589 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11590 "/" gnus-kill-file-name)
11591 (or gnus-kill-files-directory "~/News")))))
11598 (defvar gnus-dribble-ignore nil)
11599 (defvar gnus-dribble-eval-file nil)
11601 (defun gnus-dribble-file-name ()
11602 (concat gnus-current-startup-file "-dribble"))
11604 (defun gnus-dribble-enter (string)
11605 (if (and (not gnus-dribble-ignore)
11606 gnus-dribble-buffer
11607 (buffer-name gnus-dribble-buffer))
11608 (let ((obuf (current-buffer)))
11609 (set-buffer gnus-dribble-buffer)
11610 (insert string "\n")
11611 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11612 (set-buffer obuf))))
11614 (defun gnus-dribble-read-file ()
11615 (let ((dribble-file (gnus-dribble-file-name)))
11617 (set-buffer (setq gnus-dribble-buffer
11619 (file-name-nondirectory dribble-file))))
11620 (gnus-add-current-to-buffer-list)
11622 (set-visited-file-name dribble-file)
11623 (buffer-disable-undo (current-buffer))
11624 (bury-buffer (current-buffer))
11625 (set-buffer-modified-p nil)
11626 (let ((auto (make-auto-save-file-name))
11627 (gnus-dribble-ignore t))
11628 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11630 (if (file-newer-than-file-p auto dribble-file)
11631 (setq dribble-file auto))
11632 (insert-file-contents dribble-file)
11633 (if (not (zerop (buffer-size)))
11634 (set-buffer-modified-p t))
11636 "Auto-save file exists. Do you want to read it? ")
11637 (setq gnus-dribble-eval-file t))))))))
11639 (defun gnus-dribble-eval-file ()
11640 (if (not gnus-dribble-eval-file)
11642 (setq gnus-dribble-eval-file nil)
11644 (let ((gnus-dribble-ignore t))
11645 (set-buffer gnus-dribble-buffer)
11646 (eval-buffer (current-buffer))))))
11648 (defun gnus-dribble-delete-file ()
11649 (if (file-exists-p (gnus-dribble-file-name))
11650 (delete-file (gnus-dribble-file-name)))
11651 (if gnus-dribble-buffer
11653 (set-buffer gnus-dribble-buffer)
11654 (let ((auto (make-auto-save-file-name)))
11655 (if (file-exists-p auto)
11656 (delete-file auto))
11658 (set-buffer-modified-p nil)))))
11660 (defun gnus-dribble-save ()
11661 (if (and gnus-dribble-buffer
11662 (buffer-name gnus-dribble-buffer))
11664 (set-buffer gnus-dribble-buffer)
11667 (defun gnus-dribble-clear ()
11669 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11671 (set-buffer gnus-dribble-buffer)
11673 (set-buffer-modified-p nil)
11674 (setq buffer-saved-size (buffer-size))))))
11677 ;;; Server Communication
11680 (defun gnus-start-news-server (&optional confirm)
11681 "Open a method for getting news.
11682 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11684 (if gnus-current-select-method
11685 ;; Stream is already opened.
11687 ;; Open NNTP server.
11688 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11691 ;; Read server name with completion.
11692 (setq gnus-nntp-server
11693 (completing-read "NNTP server: "
11694 (mapcar (lambda (server) (list server))
11695 (cons (list gnus-nntp-server)
11696 gnus-secondary-servers))
11697 nil nil gnus-nntp-server))))
11699 (if (and gnus-nntp-server
11700 (stringp gnus-nntp-server)
11701 (not (string= gnus-nntp-server "")))
11702 (setq gnus-select-method
11703 (cond ((or (string= gnus-nntp-server "")
11704 (string= gnus-nntp-server "::"))
11705 (list 'nnspool (system-name)))
11706 ((string-match "^:" gnus-nntp-server)
11707 (list 'nnmh gnus-nntp-server
11708 (list 'nnmh-directory
11709 (file-name-as-directory
11711 (concat "~/" (substring
11712 gnus-nntp-server 1)))))
11713 (list 'nnmh-get-new-mail nil)))
11715 (list 'nntp gnus-nntp-server)))))
11717 (setq how (car gnus-select-method))
11718 (cond ((eq how 'nnspool)
11720 (gnus-message 5 "Looking up local news spool..."))
11723 (gnus-message 5 "Looking up mh spool..."))
11726 (setq gnus-current-select-method gnus-select-method)
11727 (run-hooks 'gnus-open-server-hook)
11729 ;; gnus-open-server-hook might have opened it
11730 (gnus-server-opened gnus-select-method)
11731 (gnus-open-server gnus-select-method)
11734 "%s open error: '%s'. Continue? "
11735 (nth 1 gnus-select-method)
11736 (gnus-status-message gnus-select-method)))
11738 (gnus-message 1 "Couldn't open server on %s"
11739 (nth 1 gnus-select-method))
11743 (defun gnus-check-server (&optional method)
11744 "If the news server is down, start it up again."
11745 (let ((method (if method method gnus-select-method)))
11746 (and (stringp method)
11747 (setq method (gnus-server-to-method method)))
11748 (if (gnus-server-opened method)
11749 ;; Stream is already opened.
11752 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11753 (run-hooks 'gnus-open-server-hook)
11755 (gnus-open-server method)
11758 (defun gnus-nntp-message (&optional message)
11759 "Check the status of the NNTP server.
11760 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11761 is returned insted of the status string."
11762 (let ((status (gnus-status-message (gnus-find-method-for-group
11763 gnus-newsgroup-name)))
11764 (message (or message "")))
11765 (if (and (stringp status) (> (length status) 0))
11768 (defun gnus-get-function (method function)
11769 (and (stringp method)
11770 (setq method (gnus-server-to-method method)))
11771 (let ((func (intern (format "%s-%s" (car method) function))))
11772 (if (not (fboundp func))
11774 (require (car method))
11775 (if (not (fboundp func))
11776 (error "No such function: %s" func))))
11779 ;;; Interface functions to the backends.
11781 (defun gnus-open-server (method)
11782 (funcall (gnus-get-function method 'open-server)
11783 (nth 1 method) (nthcdr 2 method)))
11785 (defun gnus-close-server (method)
11786 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11788 (defun gnus-request-list (method)
11789 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11791 (defun gnus-request-list-newsgroups (method)
11792 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11794 (defun gnus-request-newgroups (date method)
11795 (funcall (gnus-get-function method 'request-newgroups)
11796 date (nth 1 method)))
11798 (defun gnus-server-opened (method)
11799 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11801 (defun gnus-status-message (method)
11802 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11804 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11806 (defun gnus-request-group (group &optional dont-check)
11807 (let ((method (gnus-find-method-for-group group)))
11808 (funcall (gnus-get-function method 'request-group)
11809 (gnus-group-real-name group) (nth 1 method) dont-check)))
11811 (defun gnus-request-asynchronous (group &optional articles)
11812 (let ((method (gnus-find-method-for-group group)))
11813 (funcall (gnus-get-function method 'request-asynchronous)
11814 (gnus-group-real-name group) (nth 1 method) articles)))
11816 (defun gnus-list-active-group (group)
11817 (let ((method (gnus-find-method-for-group group))
11818 (func 'list-active-group))
11819 (and (gnus-check-backend-function func group)
11820 (funcall (gnus-get-function method func)
11821 (gnus-group-real-name group) (nth 1 method)))))
11823 (defun gnus-request-group-description (group)
11824 (let ((method (gnus-find-method-for-group group))
11825 (func 'request-group-description))
11826 (and (gnus-check-backend-function func group)
11827 (funcall (gnus-get-function method func)
11828 (gnus-group-real-name group) (nth 1 method)))))
11830 (defun gnus-close-group (group)
11831 (let ((method (gnus-find-method-for-group group)))
11832 (funcall (gnus-get-function method 'close-group)
11833 (gnus-group-real-name group) (nth 1 method))))
11835 (defun gnus-retrieve-headers (articles group)
11836 (let ((method (gnus-find-method-for-group group)))
11837 (if (and gnus-use-cache (numberp (car articles)))
11838 (gnus-cache-retrieve-headers articles group)
11839 (funcall (gnus-get-function method 'retrieve-headers)
11840 articles (gnus-group-real-name group) (nth 1 method)))))
11842 (defun gnus-retrieve-groups (groups method)
11843 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11845 (defun gnus-request-article (article group &optional buffer)
11846 (let ((method (gnus-find-method-for-group group)))
11847 (funcall (gnus-get-function method 'request-article)
11848 article (gnus-group-real-name group) (nth 1 method) buffer)))
11850 (defun gnus-request-head (article group)
11851 (let ((method (gnus-find-method-for-group group)))
11852 (funcall (gnus-get-function method 'request-head)
11853 article (gnus-group-real-name group) (nth 1 method))))
11855 (defun gnus-request-body (article group)
11856 (let ((method (gnus-find-method-for-group group)))
11857 (funcall (gnus-get-function method 'request-body)
11858 article (gnus-group-real-name group) (nth 1 method))))
11860 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11861 (defun gnus-request-post-buffer (post group subject header artbuf
11862 info follow-to respect-poster)
11863 (let* ((info (or info (and group (nth 2 (gnus-gethash
11864 group gnus-newsrc-hashtb)))))
11866 (if (and gnus-post-method
11867 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11869 (format "%s" (car (gnus-find-method-for-group
11870 gnus-newsgroup-name)))
11871 gnus-valid-select-methods)))
11873 (gnus-find-method-for-group gnus-newsgroup-name))))
11874 (or (gnus-check-server method)
11875 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11876 (let ((mail-self-blind nil)
11877 (mail-archive-file-name nil))
11878 (funcall (gnus-get-function method 'request-post-buffer)
11879 post group subject header artbuf info follow-to
11882 (defun gnus-request-post (method &optional force)
11883 (and (stringp method)
11884 (setq method (gnus-server-to-method method)))
11885 (and (not force) gnus-post-method
11886 (memq 'post (assoc (format "%s" (car method))
11887 gnus-valid-select-methods))
11888 (setq method gnus-post-method))
11889 (funcall (gnus-get-function method 'request-post)
11892 (defun gnus-request-expire-articles (articles group &optional force)
11893 (let ((method (gnus-find-method-for-group group)))
11894 (funcall (gnus-get-function method 'request-expire-articles)
11895 articles (gnus-group-real-name group) (nth 1 method)
11898 (defun gnus-request-move-article
11899 (article group server accept-function &optional last)
11900 (let ((method (gnus-find-method-for-group group)))
11901 (funcall (gnus-get-function method 'request-move-article)
11902 article (gnus-group-real-name group)
11903 (nth 1 method) accept-function last)))
11905 (defun gnus-request-accept-article (group &optional last)
11906 (let ((func (if (symbolp group) group
11907 (car (gnus-find-method-for-group group)))))
11908 (funcall (intern (format "%s-request-accept-article" func))
11909 (if (stringp group) (gnus-group-real-name group) group)
11912 (defun gnus-request-replace-article (article group buffer)
11913 (let ((func (car (gnus-find-method-for-group group))))
11914 (funcall (intern (format "%s-request-replace-article" func))
11915 article (gnus-group-real-name group) buffer)))
11917 (defun gnus-request-create-group (group)
11918 (let ((method (gnus-find-method-for-group group)))
11919 (funcall (gnus-get-function method 'request-create-group)
11920 (gnus-group-real-name group) (nth 1 method))))
11922 (defun gnus-member-of-valid (symbol group)
11923 (memq symbol (assoc
11924 (format "%s" (car (gnus-find-method-for-group group)))
11925 gnus-valid-select-methods)))
11927 (defun gnus-secondary-method-p (method)
11928 (let ((methods gnus-secondary-select-methods)
11929 (gmethod (gnus-server-get-method nil method)))
11930 (while (and methods
11931 (not (equal (gnus-server-get-method nil (car methods))
11933 (setq methods (cdr methods)))
11936 (defun gnus-find-method-for-group (group &optional info)
11937 (or gnus-override-method
11939 gnus-select-method)
11940 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11943 (not (setq method (nth 4 info))))
11944 (setq method gnus-select-method)
11946 (cond ((stringp method)
11947 (gnus-server-to-method method))
11948 ((stringp (car method))
11949 (gnus-server-extend-method group method))
11952 (gnus-server-add-address method))))
11954 (defun gnus-check-backend-function (func group)
11955 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11957 (fboundp (intern (format "%s-%s" method func)))))
11959 (defun gnus-methods-using (method)
11960 (let ((valids gnus-valid-select-methods)
11963 (if (memq method (car valids))
11964 (setq outs (cons (car valids) outs)))
11965 (setq valids (cdr valids)))
11969 ;;; Active & Newsrc File Handling
11972 ;; Newsrc related functions.
11973 ;; Gnus internal format of gnus-newsrc-alist:
11974 ;; (("alt.general" 3 (1 . 1))
11975 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11976 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11977 ;; The first item is the group name; the second is the subscription
11978 ;; level; the third is either a range of a list of ranges of read
11979 ;; articles, the optional fourth element is a list of marked articles,
11980 ;; the optional fifth element is the select method.
11982 ;; Gnus internal format of gnus-newsrc-hashtb:
11983 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11984 ;; This is the entry for "alt.misc". The first element is the number
11985 ;; of unread articles in "alt.misc". The cdr of this entry is the
11986 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
11987 ;; trivial to remove or add new elements into gnus-newsrc-alist
11988 ;; without scanning the entire list. So, to get the actual information
11989 ;; of "alt.misc", you'd say something like
11990 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11992 ;; Gnus internal format of gnus-active-hashtb:
11996 ;; The only element in each entry in this hash table is a range of
11997 ;; (possibly) available articles. (Articles in this range may have
11998 ;; been expired or canceled.)
12000 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12001 ;; ("alt.misc" "alt.test" "alt.general" ...)
12003 (defun gnus-setup-news (&optional rawfile level)
12004 "Setup news information.
12005 If RAWFILE is non-nil, the .newsrc file will also be read.
12006 If LEVEL is non-nil, the news will be set up at level LEVEL."
12007 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12008 ;; Clear some variables to re-initialize news information.
12009 (if init (setq gnus-newsrc-alist nil
12010 gnus-active-hashtb nil))
12012 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12013 (if init (gnus-read-newsrc-file rawfile))
12015 ;; If we don't read the complete active file, we fill in the
12017 (if (or (null gnus-read-active-file)
12018 (eq gnus-read-active-file 'some))
12019 (gnus-update-active-hashtb-from-killed))
12021 ;; Read the active file and create `gnus-active-hashtb'.
12022 ;; If `gnus-read-active-file' is nil, then we just create an empty
12023 ;; hash table. The partial filling out of the hash table will be
12024 ;; done in `gnus-get-unread-articles'.
12025 (and gnus-read-active-file
12027 (gnus-read-active-file))
12029 (or gnus-active-hashtb
12030 (setq gnus-active-hashtb (make-vector 4095 0)))
12032 ;; Possibly eval the dribble file.
12033 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12035 (gnus-update-format-specifications)
12037 ;; Find new newsgroups and treat them.
12038 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12039 (gnus-server-opened gnus-select-method))
12040 (gnus-find-new-newsgroups))
12042 ;; Find the number of unread articles in each non-dead group.
12043 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12044 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12046 (if (and init gnus-check-bogus-newsgroups
12047 gnus-read-active-file (not level)
12048 (gnus-server-opened gnus-select-method))
12049 (gnus-check-bogus-newsgroups))))
12051 (defun gnus-find-new-newsgroups ()
12052 "Search for new newsgroups and add them.
12053 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12054 The `-n' option line from .newsrc is respected."
12056 (or (gnus-check-first-time-used)
12057 (if (or (consp gnus-check-new-newsgroups)
12058 (eq gnus-check-new-newsgroups 'ask-server))
12059 (gnus-ask-server-for-new-groups)
12061 group new-newsgroups)
12062 (gnus-message 5 "Looking for new newsgroups...")
12063 (or gnus-have-read-active-file (gnus-read-active-file))
12064 (setq gnus-newsrc-last-checked-date (current-time-string))
12065 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12066 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12067 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12070 (if (or (null (setq group (symbol-name sym)))
12071 (null (symbol-value sym))
12072 (gnus-gethash group gnus-killed-hashtb)
12073 (gnus-gethash group gnus-newsrc-hashtb))
12075 (let ((do-sub (gnus-matches-options-n group)))
12077 ((eq do-sub 'subscribe)
12078 (setq groups (1+ groups))
12079 (gnus-sethash group group gnus-killed-hashtb)
12080 (funcall gnus-subscribe-options-newsgroup-method group))
12081 ((eq do-sub 'ignore)
12084 (setq groups (1+ groups))
12085 (gnus-sethash group group gnus-killed-hashtb)
12086 (if gnus-subscribe-hierarchical-interactive
12087 (setq new-newsgroups (cons group new-newsgroups))
12088 (funcall gnus-subscribe-newsgroup-method group)))))))
12089 gnus-active-hashtb)
12091 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12092 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12094 (gnus-message 6 "%d new newsgroup%s arrived."
12095 groups (if (> groups 1) "s have" " has"))
12096 (gnus-message 6 "No new newsgroups."))))))
12098 (defun gnus-matches-options-n (group)
12099 ;; Returns `subscribe' if the group is to be uncoditionally
12100 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12101 ;; no match for the group.
12103 ;; First we check the two user variables.
12105 ((and gnus-options-subscribe
12106 (string-match gnus-options-subscribe group))
12108 ((and gnus-options-not-subscribe
12109 (string-match gnus-options-not-subscribe group))
12111 ;; Then we go through the list that was retrieved from the .newsrc
12112 ;; file. This list has elements on the form
12113 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12114 ;; is in the reverse order of the options line) is returned.
12116 (let ((regs gnus-newsrc-options-n))
12118 (not (string-match (car (car regs)) group)))
12119 (setq regs (cdr regs)))
12120 (and regs (cdr (car regs)))))))
12122 (defun gnus-ask-server-for-new-groups ()
12123 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12124 (methods (cons gnus-select-method
12126 (and (consp gnus-check-new-newsgroups)
12127 gnus-check-new-newsgroups)
12128 gnus-secondary-select-methods)))
12130 (new-date (current-time-string))
12131 (hashtb (gnus-make-hashtable 100))
12132 group new-newsgroups got-new method)
12133 ;; Go through both primary and secondary select methods and
12134 ;; request new newsgroups.
12136 (setq method (gnus-server-get-method nil (car methods)))
12137 (and (gnus-check-server method)
12138 (gnus-request-newgroups date method)
12141 (set-buffer nntp-server-buffer)
12142 ;; Enter all the new groups in a hashtable.
12143 (gnus-active-to-gnus-format method hashtb 'ignore)))
12144 (setq methods (cdr methods)))
12145 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12146 ;; Now all new groups from all select methods are in `hashtb'.
12148 (lambda (group-sym)
12149 (setq group (symbol-name group-sym))
12150 (if (or (null group)
12151 (null (symbol-value group-sym))
12152 (gnus-gethash group gnus-newsrc-hashtb)
12153 (member group gnus-zombie-list)
12154 (member group gnus-killed-list))
12155 ;; The group is already known.
12157 (and (symbol-value group-sym)
12158 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12159 (let ((do-sub (gnus-matches-options-n group)))
12160 (cond ((eq do-sub 'subscribe)
12161 (setq groups (1+ groups))
12162 (gnus-sethash group group gnus-killed-hashtb)
12164 gnus-subscribe-options-newsgroup-method group))
12165 ((eq do-sub 'ignore)
12168 (setq groups (1+ groups))
12169 (gnus-sethash group group gnus-killed-hashtb)
12170 (if gnus-subscribe-hierarchical-interactive
12171 (setq new-newsgroups (cons group new-newsgroups))
12172 (funcall gnus-subscribe-newsgroup-method group)))))))
12175 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12176 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12178 (gnus-message 6 "%d new newsgroup%s arrived."
12179 groups (if (> groups 1) "s have" " has")))
12182 (defun gnus-check-first-time-used ()
12183 (if (or (> (length gnus-newsrc-alist) 1)
12184 (file-exists-p gnus-startup-file)
12185 (file-exists-p (concat gnus-startup-file ".el"))
12186 (file-exists-p (concat gnus-startup-file ".eld")))
12188 (gnus-message 6 "First time user; subscribing you to default groups")
12189 (or gnus-have-read-active-file (gnus-read-active-file))
12190 (setq gnus-newsrc-last-checked-date (current-time-string))
12191 (let ((groups gnus-default-subscribed-newsgroups)
12195 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12198 (if (null (setq group (symbol-name sym)))
12200 (let ((do-sub (gnus-matches-options-n group)))
12202 ((eq do-sub 'subscribe)
12203 (gnus-sethash group group gnus-killed-hashtb)
12204 (funcall gnus-subscribe-options-newsgroup-method group))
12205 ((eq do-sub 'ignore)
12208 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12209 gnus-active-hashtb)
12211 (if (gnus-gethash (car groups) gnus-active-hashtb)
12212 (gnus-group-change-level
12213 (car groups) gnus-level-default-subscribed gnus-level-killed))
12214 (setq groups (cdr groups)))
12215 (gnus-group-make-help-group)
12216 (and gnus-novice-user
12217 (gnus-message 7 "`A k' to list killed groups"))))))
12219 (defun gnus-subscribe-group (group previous &optional method)
12220 (gnus-group-change-level
12222 (list t group gnus-level-default-subscribed nil nil method)
12224 gnus-level-default-subscribed gnus-level-killed previous t))
12226 ;; `gnus-group-change-level' is the fundamental function for changing
12227 ;; subscription levels of newsgroups. This might mean just changing
12228 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12229 ;; again, which subscribes/unsubscribes a group, which is equally
12230 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12231 ;; from 8-9 to 1-7 means that you remove the group from the list of
12232 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12233 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12234 ;; which is trivial.
12235 ;; ENTRY can either be a string (newsgroup name) or a list (if
12236 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12237 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12239 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12240 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12242 (defun gnus-group-change-level (entry level &optional oldlevel
12243 previous fromkilled)
12244 (let (group info active num)
12245 ;; Glean what info we can from the arguments
12247 (if fromkilled (setq group (nth 1 entry))
12248 (setq group (car (nth 2 entry))))
12249 (setq group entry))
12250 (if (and (stringp entry)
12252 (< oldlevel gnus-level-zombie))
12253 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12254 (if (and (not oldlevel)
12256 (setq oldlevel (car (cdr (nth 2 entry)))))
12257 (if (stringp previous)
12258 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12260 (if (and (>= oldlevel gnus-level-zombie)
12261 (gnus-gethash group gnus-newsrc-hashtb))
12262 ;; We are trying to subscribe a group that is already
12266 (gnus-dribble-enter
12267 (format "(gnus-group-change-level %S %S %S %S %S)"
12268 group level oldlevel (car (nth 2 previous)) fromkilled))
12270 ;; Then we remove the newgroup from any old structures, if needed.
12271 ;; If the group was killed, we remove it from the killed or zombie
12272 ;; list. If not, and it is in fact going to be killed, we remove
12273 ;; it from the newsrc hash table and assoc.
12274 (cond ((>= oldlevel gnus-level-zombie)
12275 (if (= oldlevel gnus-level-zombie)
12276 (setq gnus-zombie-list (delete group gnus-zombie-list))
12277 (setq gnus-killed-list (delete group gnus-killed-list))))
12279 (if (and (>= level gnus-level-zombie)
12282 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12284 (setcdr (gnus-gethash (car (nth 3 entry))
12285 gnus-newsrc-hashtb)
12287 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12289 ;; Finally we enter (if needed) the list where it is supposed to
12290 ;; go, and change the subscription level. If it is to be killed,
12291 ;; we enter it into the killed or zombie list.
12292 (cond ((>= level gnus-level-zombie)
12293 ;; Remove from the hash table.
12294 (gnus-sethash group nil gnus-newsrc-hashtb)
12295 (or (gnus-group-foreign-p group)
12296 ;; We do not enter foreign groups into the list of dead
12298 (if (= level gnus-level-zombie)
12299 (setq gnus-zombie-list (cons group gnus-zombie-list))
12300 (setq gnus-killed-list (cons group gnus-killed-list)))))
12302 ;; If the list is to be entered into the newsrc assoc, and
12303 ;; it was killed, we have to create an entry in the newsrc
12304 ;; hashtb format and fix the pointers in the newsrc assoc.
12305 (if (>= oldlevel gnus-level-zombie)
12309 (setq info (cdr entry))
12310 (setq num (car entry)))
12311 (setq active (gnus-gethash group gnus-active-hashtb))
12313 (if active (- (1+ (cdr active)) (car active)) t))
12314 ;; Check whether the group is foreign. If so, the
12315 ;; foreign select method has to be entered into the
12317 (let ((method (gnus-group-method-name group)))
12318 (if (eq method gnus-select-method)
12319 (setq info (list group level nil))
12320 (setq info (list group level nil nil method)))))
12323 (let ((p gnus-newsrc-alist))
12324 (while (cdr (cdr p))
12327 (setq entry (cons info (cdr (cdr previous))))
12330 (setcdr (cdr previous) entry)
12331 (gnus-sethash group (cons num (cdr previous))
12332 gnus-newsrc-hashtb))
12333 (setcdr previous entry)
12334 (gnus-sethash group (cons num previous)
12335 gnus-newsrc-hashtb))
12337 (setcdr (gnus-gethash (car (car (cdr entry)))
12338 gnus-newsrc-hashtb)
12340 ;; It was alive, and it is going to stay alive, so we
12341 ;; just change the level and don't change any pointers or
12342 ;; hash table entries.
12343 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12345 (defun gnus-kill-newsgroup (newsgroup)
12346 "Obsolete function. Kills a newsgroup."
12347 (gnus-group-change-level
12348 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12350 (defun gnus-check-bogus-newsgroups (&optional confirm)
12351 "Remove bogus newsgroups.
12352 If CONFIRM is non-nil, the user has to confirm the deletion of every
12354 (let ((newsrc (cdr gnus-newsrc-alist))
12356 (gnus-message 5 "Checking bogus newsgroups...")
12357 (or gnus-have-read-active-file (gnus-read-active-file))
12358 ;; Find all bogus newsgroup that are subscribed.
12360 (setq group (car (car newsrc)))
12361 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12362 (nth 4 (car newsrc)) ; Foreign
12364 (not (gnus-y-or-n-p
12365 (format "Remove bogus newsgroup: %s " group)))))
12368 ;; Found a bogus newsgroup.
12369 (setq bogus (cons group bogus)))
12370 (setq newsrc (cdr newsrc)))
12371 ;; Remove all bogus subscribed groups by first killing them, and
12372 ;; then removing them from the list of killed groups.
12374 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12376 (gnus-group-change-level entry gnus-level-killed)
12377 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12378 (setq bogus (cdr bogus)))
12379 ;; Then we remove all bogus groups from the list of killed and
12380 ;; zombie groups. They are are removed without confirmation.
12381 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12384 (setq killed (symbol-value (car dead-lists)))
12386 (setq group (car killed))
12387 (or (gnus-gethash group gnus-active-hashtb)
12388 ;; The group is bogus.
12389 (set (car dead-lists)
12390 (delete group (symbol-value (car dead-lists)))))
12391 (setq killed (cdr killed)))
12392 (setq dead-lists (cdr dead-lists))))
12393 (gnus-message 5 "Checking bogus newsgroups...done")))
12395 (defun gnus-check-duplicate-killed-groups ()
12396 "Remove duplicates from the list of killed groups."
12398 (let ((killed gnus-killed-list))
12400 (gnus-message 9 "%d" (length killed))
12401 (setcdr killed (delete (car killed) (cdr killed)))
12402 (setq killed (cdr killed)))))
12404 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12405 ;; and compute how many unread articles there are in each group.
12406 (defun gnus-get-unread-articles (&optional level)
12407 (let* ((newsrc (cdr gnus-newsrc-alist))
12408 (level (or level (1+ gnus-level-subscribed)))
12411 (cond ((and gnus-activate-foreign-newsgroups
12412 (not (numberp gnus-activate-foreign-newsgroups)))
12413 (1+ gnus-level-subscribed))
12414 ((numberp gnus-activate-foreign-newsgroups)
12415 gnus-activate-foreign-newsgroups)
12418 info group active virtuals method)
12419 (gnus-message 5 "Checking new news...")
12422 (setq info (car newsrc)
12424 active (gnus-gethash group gnus-active-hashtb))
12426 ;; Check newsgroups. If the user doesn't want to check them, or
12427 ;; they can't be checked (for instance, if the news server can't
12428 ;; be reached) we just set the number of unread articles in this
12429 ;; newsgroup to t. This means that Gnus thinks that there are
12430 ;; unread articles, but it has no idea how many.
12431 (if (and (setq method (nth 4 info))
12432 (not (gnus-server-equal gnus-select-method
12433 (gnus-server-get-method nil method)))
12434 (not (gnus-secondary-method-p method)))
12435 ;; These groups are foreign. Check the level.
12436 (if (<= (nth 1 info) foreign-level)
12437 (if (eq (car (if (stringp method)
12438 (gnus-server-to-method method)
12439 (nth 4 info))) 'nnvirtual)
12440 ;; We have to activate the virtual groups after all
12441 ;; the others, so we just pop them on a list for
12443 (setq virtuals (cons info virtuals))
12444 (and (setq active (gnus-activate-group (car info)))
12445 ;; Close the groups as we look at them!
12446 (gnus-close-group group))))
12448 ;; These groups are native or secondary.
12449 (if (and (not gnus-read-active-file)
12450 (<= (nth 1 info) level))
12452 (or gnus-read-active-file (gnus-check-server method))
12453 (setq active (gnus-activate-group (car info))))))
12456 (gnus-get-unread-articles-in-group info active)
12457 ;; The group couldn't be reached, so we nix out the number of
12458 ;; unread articles and stuff.
12459 (gnus-sethash group nil gnus-active-hashtb)
12460 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12462 (setq newsrc (cdr newsrc)))
12464 ;; Activate the virtual groups. This has to be done after all the
12466 ;; !!! If one virtual group contains another virtual group, even
12467 ;; doing it this way might cause problems.
12469 (and (setq active (gnus-activate-group (car (car virtuals))))
12470 (gnus-get-unread-articles-in-group (car virtuals) active))
12471 (setq virtuals (cdr virtuals)))
12473 (gnus-message 5 "Checking new news...done")))
12475 ;; Create a hash table out of the newsrc alist. The `car's of the
12476 ;; alist elements are used as keys.
12477 (defun gnus-make-hashtable-from-newsrc-alist ()
12478 (let ((alist gnus-newsrc-alist)
12479 (ohashtb gnus-newsrc-hashtb)
12481 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12483 (setq prev (setq gnus-newsrc-alist
12484 (if (equal (car (car gnus-newsrc-alist))
12487 (cons (list "dummy.group" 0 nil) alist)))))
12489 (gnus-sethash (car (car alist))
12490 (cons (and ohashtb (car (gnus-gethash
12491 (car (car alist)) ohashtb)))
12492 prev) gnus-newsrc-hashtb)
12494 alist (cdr alist)))))
12496 (defun gnus-make-hashtable-from-killed ()
12497 "Create a hash table from the killed and zombie lists."
12498 (let ((lists '(gnus-killed-list gnus-zombie-list))
12500 (setq gnus-killed-hashtb
12501 (gnus-make-hashtable
12502 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12504 (setq list (symbol-value (car lists)))
12505 (setq lists (cdr lists))
12507 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12508 (setq list (cdr list))))))
12510 (defun gnus-get-unread-articles-in-group (info active)
12511 (let* ((range (nth 2 info))
12513 (marked (nth 3 info)))
12514 ;; If a cache is present, we may have to alter the active info.
12515 (and gnus-use-cache
12516 (gnus-cache-possibly-alter-active (car info) active))
12517 ;; Modify the list of read articles according to what articles
12518 ;; are available; then tally the unread articles and add the
12519 ;; number to the group hash table entry.
12521 ((zerop (cdr active))
12524 (setq num (- (1+ (cdr active)) (car active))))
12525 ((not (listp (cdr range)))
12526 ;; Fix a single (num . num) range according to the
12527 ;; active hash table.
12528 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12529 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12530 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12531 ;; Compute number of unread articles.
12532 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12534 ;; The read list is a list of ranges. Fix them according to
12535 ;; the active hash table.
12536 ;; First peel off any elements that are below the lower
12538 (while (and (cdr range)
12540 (or (and (atom (car (cdr range))) (car (cdr range)))
12541 (car (car (cdr range))))))
12542 (if (numberp (car range))
12545 (or (and (numberp (car (cdr range)))
12547 (cdr (car (cdr range))))))
12548 (setcdr (car range)
12549 (or (and (numberp (nth 1 range)) (nth 1 range))
12550 (cdr (car (cdr range))))))
12551 (setcdr range (cdr (cdr range))))
12552 ;; Adjust the first element to be the same as the lower limit.
12553 (if (and (not (atom (car range)))
12554 (< (cdr (car range)) (car active)))
12555 (setcdr (car range) (1- (car active))))
12556 ;; Then we want to peel off any elements that are higher
12557 ;; than the upper active limit.
12558 (let ((srange range))
12559 ;; Go past all legal elements.
12560 (while (and (cdr srange)
12561 (<= (or (and (atom (car (cdr srange)))
12562 (car (cdr srange)))
12563 (car (car (cdr srange)))) (cdr active)))
12564 (setq srange (cdr srange)))
12566 ;; Nuke all remaining illegal elements.
12567 (setcdr srange nil))
12569 ;; Adjust the final element.
12570 (if (and (not (atom (car srange)))
12571 (> (cdr (car srange)) (cdr active)))
12572 (setcdr (car srange) (cdr active))))
12573 ;; Compute the number of unread articles.
12575 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12576 (cdr (car range))))
12577 (or (and (atom (car range)) (car range))
12578 (car (car range))))))
12579 (setq range (cdr range)))
12580 (setq num (max 0 (- (cdr active) num)))))
12583 (and (assq 'tick marked)
12584 (inline (gnus-remove-illegal-marked-articles
12585 (assq 'tick marked) (nth 2 info))))
12586 (and (assq 'dormant marked)
12587 (inline (gnus-remove-illegal-marked-articles
12588 (assq 'dormant marked) (nth 2 info))))
12590 (gnus-gethash (car info) gnus-newsrc-hashtb)
12591 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12592 (length (cdr (assq 'dormant marked)))))))))
12595 (defun gnus-remove-illegal-marked-articles (marked ranges)
12596 (let ((m (cdr marked)))
12597 ;; Make sure that all ticked articles are a subset of the unread
12600 (if (gnus-member-of-range (car m) ranges)
12601 (setcdr marked (cdr m))
12603 (setq m (cdr m)))))
12605 (defun gnus-activate-group (group)
12606 ;; Check whether a group has been activated or not.
12607 (let ((method (gnus-find-method-for-group group))
12609 (and (gnus-check-server method)
12610 ;; We escape all bugs and quit here to make it possible to
12611 ;; continue if a group is so out-there that it reports bugs
12614 (gnus-request-group group)
12618 (set-buffer nntp-server-buffer)
12619 (goto-char (point-min))
12620 ;; Parse the result we got from `gnus-request-group'.
12621 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12623 (goto-char (match-beginning 1))
12625 group (setq active (cons (read (current-buffer))
12626 (read (current-buffer))))
12627 gnus-active-hashtb))
12628 ;; Return the new active info.
12631 (defun gnus-update-read-articles
12632 (group unread unselected ticked &optional domarks replied expirable killed
12633 dormant bookmark score)
12634 "Update the list of read and ticked articles in GROUP using the
12635 UNREAD and TICKED lists.
12636 Note: UNSELECTED has to be sorted over `<'.
12637 Returns whether the updating was successful."
12638 (let* ((active (or gnus-newsgroup-active
12639 (gnus-gethash group gnus-active-hashtb)))
12640 (entry (gnus-gethash group gnus-newsrc-hashtb))
12641 (info (nth 2 entry))
12642 (marked (nth 3 info))
12644 (unread (sort (copy-sequence unread) (function <)))
12646 (if (or (not info) (not active))
12647 ;; There is no info on this group if it was, in fact,
12648 ;; killed. Gnus stores no information on killed groups, so
12649 ;; there's nothing to be done.
12650 ;; One could store the information somewhere temporarily,
12651 ;; perhaps... Hmmm...
12653 ;; Remove any negative articles numbers.
12654 (while (and unread (< (car unread) 0))
12655 (setq unread (cdr unread)))
12656 ;; Remove any expired article numbers
12657 (while (and unread (< (car unread) (car active)))
12658 (setq unread (cdr unread)))
12659 (while (and ticked (< (car ticked) (car active)))
12660 (setq ticked (cdr ticked)))
12661 (while (and dormant (< (car dormant) (car active)))
12662 (setq dormant (cdr dormant)))
12663 (setq unread (sort (append unselected unread) '<))
12664 ;; Compute the ranges of read articles by looking at the list of
12665 ;; unread articles.
12667 (if (/= (car unread) prev)
12668 (setq read (cons (if (= prev (1- (car unread))) prev
12669 (cons prev (1- (car unread)))) read)))
12670 (setq prev (1+ (car unread)))
12671 (setq unread (cdr unread)))
12672 (if (<= prev (cdr active))
12673 (setq read (cons (cons prev (cdr active)) read)))
12674 ;; Enter this list into the group info.
12675 (setcar (cdr (cdr info))
12676 (if (> (length read) 1) (nreverse read) read))
12677 ;; Enter the list of ticked articles.
12678 (gnus-set-marked-articles
12680 (if domarks replied (cdr (assq 'reply marked)))
12681 (if domarks expirable (cdr (assq 'expire marked)))
12682 (if domarks killed (cdr (assq 'killed marked)))
12683 (if domarks dormant (cdr (assq 'dormant marked)))
12684 (if domarks bookmark (cdr (assq 'bookmark marked)))
12685 (if domarks score (cdr (assq 'score marked))))
12686 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12687 (gnus-get-unread-articles-in-group
12688 info (gnus-gethash group gnus-active-hashtb))
12691 (defun gnus-make-articles-unread (group articles)
12692 "Mark ARTICLES in GROUP as unread."
12693 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12694 (gnus-gethash (gnus-group-real-name group)
12695 gnus-newsrc-hashtb))))
12696 (ranges (nth 2 info))
12699 (and (gnus-member-of-range (car articles) ranges)
12700 (setq news (cons (car articles) news)))
12701 (setq articles (cdr articles)))
12704 (setcar (nthcdr 2 info)
12705 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12706 (gnus-group-update-group group t))))
12708 ;; Enter all dead groups into the hashtb.
12709 (defun gnus-update-active-hashtb-from-killed ()
12710 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12711 (lists (list gnus-killed-list gnus-zombie-list))
12714 (setq killed (car lists))
12716 (gnus-sethash (car killed) nil hashtb)
12717 (setq killed (cdr killed)))
12718 (setq lists (cdr lists)))))
12720 ;; Get the active file(s) from the backend(s).
12721 (defun gnus-read-active-file ()
12722 (gnus-group-set-mode-line)
12723 (let ((methods (if (gnus-check-server gnus-select-method)
12724 ;; The native server is available.
12725 (cons gnus-select-method gnus-secondary-select-methods)
12726 ;; The native server is down, so we just do the
12728 gnus-secondary-select-methods))
12730 (setq gnus-have-read-active-file nil)
12732 (set-buffer nntp-server-buffer)
12734 (let* ((method (gnus-server-get-method nil (car methods)))
12735 (where (nth 1 method))
12736 (mesg (format "Reading active file%s via %s..."
12737 (if (and where (not (zerop (length where))))
12738 (concat " from " where) "")
12740 (gnus-message 5 mesg)
12741 (if (not (gnus-check-server method))
12744 ((and (eq gnus-read-active-file 'some)
12745 (gnus-check-backend-function 'retrieve-groups (car method)))
12746 (let ((newsrc (cdr gnus-newsrc-alist))
12747 (gmethod (gnus-server-get-method nil method))
12750 (and (gnus-server-equal
12751 (gnus-find-method-for-group
12752 (car (car newsrc)) (car newsrc))
12754 (setq groups (cons (gnus-group-real-name
12755 (car (car newsrc))) groups)))
12756 (setq newsrc (cdr newsrc)))
12757 (gnus-check-server method)
12758 (setq list-type (gnus-retrieve-groups groups method))
12762 1 "Cannot read partial active file from %s server."
12766 ((eq list-type 'active)
12767 (gnus-active-to-gnus-format method gnus-active-hashtb))
12769 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12771 (if (not (gnus-request-list method))
12773 (gnus-message 1 "Cannot read active file from %s server."
12776 (gnus-active-to-gnus-format method)
12777 ;; We mark this active file as read.
12778 (setq gnus-have-read-active-file
12779 (cons method gnus-have-read-active-file))
12780 (gnus-message 5 "%sdone" mesg))))))
12781 (setq methods (cdr methods))))))
12783 ;; Read an active file and place the results in `gnus-active-hashtb'.
12784 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12785 (let ((cur (current-buffer))
12787 (if (and gnus-active-hashtb
12788 (not (equal method gnus-select-method)))
12790 (setq gnus-active-hashtb
12791 (if (equal method gnus-select-method)
12792 (gnus-make-hashtable
12793 (count-lines (point-min) (point-max)))
12794 (gnus-make-hashtable 4096))))))
12795 (flag-hashtb (gnus-make-hashtable 60)))
12796 ;; Delete unnecessary lines.
12797 (goto-char (point-min))
12798 (while (search-forward "\nto." nil t)
12799 (delete-region (1+ (match-beginning 0))
12800 (progn (forward-line 1) (point))))
12801 (or (string= gnus-ignored-newsgroups "")
12803 (goto-char (point-min))
12804 (delete-matching-lines gnus-ignored-newsgroups)))
12805 ;; Make the group names readable as a lisp expression even if they
12806 ;; contain special characters.
12807 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12808 (goto-char (point-max))
12809 (while (re-search-backward "[][';?()#]" nil t)
12811 ;; If these are groups from a foreign select method, we insert the
12812 ;; group prefix in front of the group names.
12813 (and method (not (gnus-server-equal
12814 (gnus-server-get-method nil method)
12815 (gnus-server-get-method nil gnus-select-method)))
12816 (let ((prefix (gnus-group-prefixed-name "" method)))
12817 (goto-char (point-min))
12818 (while (and (not (eobp))
12819 (progn (insert prefix)
12820 (zerop (forward-line 1)))))))
12821 ;; Store the active file in a hash table.
12822 (goto-char (point-min))
12823 (if (string-match "%[oO]" gnus-group-line-format)
12824 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12825 ;; If we want information on moderated groups, we use this
12827 (let* ((mod-hashtb (make-vector 7 0))
12828 (m (intern "m" mod-hashtb))
12830 (while (not (eobp))
12831 (condition-case nil
12833 (narrow-to-region (point) (gnus-point-at-eol))
12834 (setq group (let ((obarray hashtb)) (read cur)))
12835 (if (and (numberp (setq max (read cur)))
12836 (numberp (setq min (read cur)))
12838 (skip-chars-forward " \t")
12840 (or (= (following-char) ?=)
12841 (= (following-char) ?x)
12842 (= (following-char) ?j)))))
12843 (set group (cons min max))
12845 ;; Enter moderated groups into a list.
12846 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12847 (setq gnus-moderated-list
12848 (cons (symbol-name group) gnus-moderated-list))))
12855 ;; And if we do not care about moderation, we use this loop,
12856 ;; which is faster.
12857 (let (group max min)
12858 (while (not (eobp))
12861 (narrow-to-region (point) (gnus-point-at-eol))
12862 ;; group gets set to a symbol interned in the hash table
12863 ;; (what a hack!!) - jwz
12864 (setq group (let ((obarray hashtb)) (read cur)))
12865 (if (and (numberp (setq max (read cur)))
12866 (numberp (setq min (read cur)))
12868 (skip-chars-forward " \t")
12870 (or (= (following-char) ?=)
12871 (= (following-char) ?x)
12872 (= (following-char) ?j)))))
12873 (set group (cons min max))
12881 (gnus-message 3 "Warning - illegal active: %s"
12883 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12885 (forward-line 1))))))
12887 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12888 ;; Parse a "groups" active file.
12889 (let ((cur (current-buffer))
12891 (if (and method gnus-active-hashtb)
12893 (setq gnus-active-hashtb
12894 (gnus-make-hashtable
12895 (count-lines (point-min) (point-max)))))))
12896 (prefix (and method
12897 (not (gnus-server-equal
12898 (gnus-server-get-method nil method)
12899 (gnus-server-get-method nil gnus-select-method)))
12900 (gnus-group-prefixed-name "" method))))
12902 (goto-char (point-min))
12903 ;; We split this into to separate loops, one with the prefix
12904 ;; and one without to speed the reading up somewhat.
12906 (let (min max opoint group)
12907 (while (not (eobp))
12910 (read cur) (read cur)
12911 (setq min (read cur)
12914 (skip-chars-forward " \t")
12917 (set (let ((obarray hashtb)) (read cur))
12919 (error (and group (symbolp group) (set group nil))))
12921 (let (min max group)
12922 (while (not (eobp))
12924 (if (= (following-char) ?2)
12926 (read cur) (read cur)
12927 (setq min (read cur)
12929 (set (setq group (let ((obarray hashtb)) (read cur)))
12931 (error (and group (symbolp group) (set group nil))))
12932 (forward-line 1))))))
12934 (defun gnus-read-newsrc-file (&optional force)
12935 "Read startup file.
12936 If FORCE is non-nil, the .newsrc file is read."
12937 ;; Reset variables that might be defined in the .newsrc.eld file.
12938 (let ((variables gnus-variable-list))
12940 (set (car variables) nil)
12941 (setq variables (cdr variables))))
12942 (let* ((newsrc-file gnus-current-startup-file)
12943 (quick-file (concat newsrc-file ".el")))
12945 ;; We always load the .newsrc.eld file. If always contains
12946 ;; much information that can not be gotten from the .newsrc
12947 ;; file (ticked articles, killed groups, foreign methods, etc.)
12948 (gnus-read-newsrc-el-file quick-file)
12951 (and (file-newer-than-file-p newsrc-file quick-file)
12952 (file-newer-than-file-p newsrc-file
12953 (concat quick-file "d")))
12954 (not gnus-newsrc-alist))
12955 ;; We read the .newsrc file. Note that if there if a
12956 ;; .newsrc.eld file exists, it has already been read, and
12957 ;; the `gnus-newsrc-hashtb' has been created. While reading
12958 ;; the .newsrc file, Gnus will only use the information it
12959 ;; can find there for changing the data already read -
12960 ;; ie. reading the .newsrc file will not trash the data
12961 ;; already read (except for read articles).
12963 (gnus-message 5 "Reading %s..." newsrc-file)
12964 (set-buffer (find-file-noselect newsrc-file))
12965 (buffer-disable-undo (current-buffer))
12966 (gnus-newsrc-to-gnus-format)
12967 (kill-buffer (current-buffer))
12968 (gnus-message 5 "Reading %s...done" newsrc-file))))))
12970 (defun gnus-read-newsrc-el-file (file)
12971 (let ((ding-file (concat file "d")))
12972 ;; We always, always read the .eld file.
12973 (gnus-message 5 "Reading %s..." ding-file)
12974 (let (gnus-newsrc-assoc)
12975 (condition-case nil
12976 (load ding-file t t t)
12978 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
12979 (let ((inhibit-quit t))
12980 (gnus-uncompress-newsrc-alist))
12981 (gnus-make-hashtable-from-newsrc-alist)
12982 (if (not (file-newer-than-file-p file ding-file))
12984 ;; Old format quick file
12985 (gnus-message 5 "Reading %s..." file)
12986 ;; The .el file is newer than the .eld file, so we read that one
12988 (gnus-read-old-newsrc-el-file file))))
12990 ;; Parse the old-style quick startup file
12991 (defun gnus-read-old-newsrc-el-file (file)
12992 (let (newsrc killed marked group m)
12994 (let ((gnus-killed-assoc nil)
12995 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
12997 (condition-case nil
13000 (setq newsrc gnus-newsrc-assoc
13001 killed gnus-killed-assoc
13002 marked gnus-marked-assoc)))
13003 (setq gnus-newsrc-alist nil)
13005 (setq group (car newsrc))
13006 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13009 (setcar (nthcdr 2 info) (cdr (cdr group)))
13011 (if (nth 1 group) gnus-level-default-subscribed
13012 gnus-level-default-unsubscribed))
13013 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13014 (setq gnus-newsrc-alist
13018 (if (nth 1 group) gnus-level-default-subscribed
13019 gnus-level-default-unsubscribed)
13020 (cdr (cdr group))))
13021 gnus-newsrc-alist)))
13022 (if (setq m (assoc (car group) marked))
13023 (setcdr (cdr (cdr info))
13024 (cons (list (cons 'tick (cdr m))) nil))))
13025 (setq newsrc (cdr newsrc)))
13026 (setq newsrc killed)
13028 (setcar newsrc (car (car newsrc)))
13029 (setq newsrc (cdr newsrc)))
13030 (setq gnus-killed-list killed))
13031 ;; The .el file version of this variable does not begin with
13032 ;; "options", while the .eld version does, so we just add it if it
13035 gnus-newsrc-options
13037 (and (not (string-match "^ *options" gnus-newsrc-options))
13038 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13039 (and (not (string-match "\n$" gnus-newsrc-options))
13040 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
13041 ;; Finally, if we read some options lines, we parse them.
13042 (or (string= gnus-newsrc-options "")
13043 (gnus-newsrc-parse-options gnus-newsrc-options))))
13045 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13046 (gnus-make-hashtable-from-newsrc-alist)))
13048 (defun gnus-make-newsrc-file (file)
13049 "Make server dependent file name by catenating FILE and server host name."
13050 (let* ((file (expand-file-name file nil))
13051 (real-file (concat file "-" (nth 1 gnus-select-method))))
13052 (if (or (file-exists-p real-file)
13053 (file-exists-p (concat real-file ".el"))
13054 (file-exists-p (concat real-file ".eld")))
13057 (defun gnus-uncompress-newsrc-alist ()
13058 ;; Uncompress all lists of marked articles in the newsrc assoc.
13059 (let ((newsrc gnus-newsrc-alist)
13062 (if (not (setq marked (nth 3 (car newsrc))))
13065 (or (eq 'score (car (car marked)))
13066 (eq 'bookmark (car (car marked)))
13067 (eq 'killed (car (car marked)))
13068 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13069 (setq marked (cdr marked))))
13070 (setq newsrc (cdr newsrc)))))
13072 (defun gnus-compress-newsrc-alist ()
13073 ;; Compress all lists of marked articles in the newsrc assoc.
13074 (let ((newsrc gnus-newsrc-alist)
13077 (if (not (setq marked (nth 3 (car newsrc))))
13080 (or (eq 'score (car (car marked)))
13081 (eq 'bookmark (car (car marked)))
13082 (eq 'killed (car (car marked)))
13083 (setcdr (car marked)
13085 (gnus-compress-sequence
13086 (sort (cdr (car marked)) '<) t)
13087 (error (cdr (car marked))))))
13088 (setq marked (cdr marked))))
13089 (setq newsrc (cdr newsrc)))))
13091 (defun gnus-newsrc-to-gnus-format ()
13092 (setq gnus-newsrc-options "")
13093 (setq gnus-newsrc-options-n nil)
13095 (or gnus-active-hashtb
13096 (setq gnus-active-hashtb (make-vector 4095 0)))
13097 (let ((buf (current-buffer))
13098 (already-read (> (length gnus-newsrc-alist) 1))
13099 group subscribed options-symbol newsrc Options-symbol
13101 (goto-char (point-min))
13102 ;; We intern the symbol `options' in the active hashtb so that we
13103 ;; can `eq' against it later.
13104 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13105 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13107 (while (not (eobp))
13108 ;; We first read the first word on the line by narrowing and
13109 ;; then reading into `gnus-active-hashtb'. Most groups will
13110 ;; already exist in that hashtb, so this will save some string
13114 (progn (skip-chars-forward "^ \t!:\n") (point)))
13115 (goto-char (point-min))
13117 (and (/= (point-min) (point-max))
13118 (let ((obarray gnus-active-hashtb)) (read buf))))
13120 ;; Now, the symbol we have read is either `options' or a group
13121 ;; name. If it is an options line, we just add it to a string.
13123 ((or (eq symbol options-symbol)
13124 (eq symbol Options-symbol))
13125 (setq gnus-newsrc-options
13126 ;; This concatting is quite inefficient, but since our
13127 ;; thorough studies show that approx 99.37% of all
13128 ;; .newsrc files only contain a single options line, we
13129 ;; don't give a damn, frankly, my dear.
13130 (concat gnus-newsrc-options
13132 (gnus-point-at-bol)
13133 ;; Options may continue on the next line.
13134 (or (and (re-search-forward "^[^ \t]" nil 'move)
13135 (progn (beginning-of-line) (point)))
13138 (or (boundp symbol) (set symbol nil))
13139 ;; It was a group name.
13140 (setq subscribed (= (following-char) ?:)
13141 group (symbol-name symbol)
13144 ;; If the line ends here, this is clearly a buggy line, so
13145 ;; we put point a the beginning of line and let the cond
13146 ;; below do the error handling.
13147 (beginning-of-line)
13148 ;; We skip to the beginning of the ranges.
13149 (skip-chars-forward "!: \t"))
13150 ;; We are now at the beginning of the list of read articles.
13151 ;; We read them range by range.
13154 ((looking-at "[0-9]+")
13155 ;; We narrow and read a number instead of buffer-substring/
13156 ;; string-to-int because it's faster. narrow/widen is
13157 ;; faster than save-restriction/narrow, and save-restriction
13158 ;; produces a garbage object.
13160 (narrow-to-region (match-beginning 0) (match-end 0))
13163 ;; If the next character is a dash, then this is a range.
13164 (if (= (following-char) ?-)
13166 ;; We read the upper bound of the range.
13168 (if (not (looking-at "[0-9]+"))
13169 ;; This is a buggy line, by we pretend that
13170 ;; it's kinda OK. Perhaps the user should be
13172 (setq reads (cons num1 reads))
13177 (narrow-to-region (match-beginning 0)
13182 ;; It was just a simple number, so we add it to the
13184 (setq reads (cons num1 reads)))
13185 ;; If the next char in ?\n, then we have reached the end
13186 ;; of the line and return nil.
13187 (/= (following-char) ?\n))
13188 ((= (following-char) ?\n)
13189 ;; End of line, so we end.
13192 ;; Not numbers and not eol, so this might be a buggy
13195 ;; If it was eob instead of ?\n, we allow it.
13197 ;; The line was buggy.
13199 (gnus-message 3 "Mangled line: %s"
13200 (buffer-substring (gnus-point-at-bol)
13201 (gnus-point-at-eol)))
13205 ;; Skip past ", ". Spaces are illegal in these ranges, but
13206 ;; we allow them, because it's a common mistake to put a
13207 ;; space after the comma.
13208 (skip-chars-forward ", "))
13210 ;; We have already read .newsrc.eld, so we gently update the
13211 ;; data in the hash table with the information we have just
13215 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13218 ;; There is an entry for this file in the alist.
13220 (setcar (nthcdr 2 info) (nreverse reads))
13221 ;; We update the level very gently. In fact, we
13222 ;; only change it if there's been a status change
13223 ;; from subscribed to unsubscribed, or vice versa.
13224 (setq level (nth 1 info))
13225 (cond ((and (<= level gnus-level-subscribed)
13227 (setq level (if reads
13228 gnus-level-default-unsubscribed
13229 (1+ gnus-level-default-unsubscribed))))
13230 ((and (> level gnus-level-subscribed) subscribed)
13231 (setq level gnus-level-default-subscribed)))
13232 (setcar (cdr info) level))
13233 ;; This is a new group.
13234 (setq info (list group
13236 gnus-level-default-subscribed
13238 (1+ gnus-level-subscribed)
13239 gnus-level-default-unsubscribed))
13240 (nreverse reads))))
13241 (setq newsrc (cons info newsrc))))))
13244 (setq newsrc (nreverse newsrc))
13246 (if (not already-read)
13248 ;; We now have two newsrc lists - `newsrc', which is what we
13249 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13250 ;; what we've read from .newsrc.eld. We have to merge these
13251 ;; lists. We do this by "attaching" any (foreign) groups in the
13252 ;; gnus-newsrc-alist to the (native) group that precedes them.
13253 (let ((rc (cdr gnus-newsrc-alist))
13254 (prev gnus-newsrc-alist)
13257 (or (null (nth 4 (car rc))) ; It's a native group.
13258 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13259 (if (setq entry (assoc (car (car prev)) newsrc))
13260 (setcdr (setq mentry (memq entry newsrc))
13261 (cons (car rc) (cdr mentry)))
13262 (setq newsrc (cons (car rc) newsrc))))
13266 (setq gnus-newsrc-alist newsrc)
13267 ;; We make the newsrc hashtb.
13268 (gnus-make-hashtable-from-newsrc-alist)
13270 ;; Finally, if we read some options lines, we parse them.
13271 (or (string= gnus-newsrc-options "")
13272 (gnus-newsrc-parse-options gnus-newsrc-options))))
13274 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13275 ;; The return value will be a list on the form
13276 ;; ((regexp1 . ignore)
13277 ;; (regexp2 . subscribe)...)
13278 ;; When handling new newsgroups, groups that match a `ignore' regexp
13279 ;; will be ignored, and groups that match a `subscribe' regexp will be
13280 ;; subscribed. A line like
13281 ;; options -n !all rec.all
13282 ;; will lead to a list that looks like
13283 ;; (("^rec\\..+" . subscribe)
13284 ;; ("^.+" . ignore))
13285 ;; So all "rec.*" groups will be subscribed, while all the other
13286 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13287 ;; different from "options -n rec.all !all".
13288 (defun gnus-newsrc-parse-options (options)
13291 (gnus-set-work-buffer)
13292 (insert (regexp-quote options))
13293 ;; First we treat all continuation lines.
13294 (goto-char (point-min))
13295 (while (re-search-forward "\n[ \t]+" nil t)
13296 (replace-match " " t t))
13297 ;; Then we transform all "all"s into ".+"s.
13298 (goto-char (point-min))
13299 (while (re-search-forward "\\ball\\b" nil t)
13300 (replace-match ".+" t t))
13301 (goto-char (point-min))
13302 ;; We remove all other options than the "-n" ones.
13303 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13304 (replace-match " ")
13306 (goto-char (point-min))
13308 ;; We are only interested in "options -n" lines - we
13309 ;; ignore the other option lines.
13310 (while (re-search-forward "[ \t]-n" nil t)
13312 (or (save-excursion
13313 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13315 (gnus-point-at-eol)))
13316 ;; Search for all "words"...
13317 (while (re-search-forward "[^ \t,\n]+" eol t)
13318 (if (= (char-after (match-beginning 0)) ?!)
13319 ;; If the word begins with a bang (!), this is a "not"
13320 ;; spec. We put this spec (minus the bang) and the
13321 ;; symbol `ignore' into the list.
13322 (setq out (cons (cons (concat
13323 "^" (buffer-substring
13324 (1+ (match-beginning 0))
13327 ;; There was no bang, so this is a "yes" spec.
13328 (setq out (cons (cons (concat
13329 "^" (buffer-substring (match-beginning 0)
13331 'subscribe) out)))))
13333 (setq gnus-newsrc-options-n out))))
13336 (defun gnus-save-newsrc-file ()
13337 "Save .newsrc file."
13338 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13339 ;; from the variable gnus-newsrc-alist.
13340 (and (or gnus-newsrc-alist gnus-killed-list)
13341 gnus-current-startup-file
13343 (run-hooks 'gnus-save-newsrc-hook)
13345 (if (and gnus-use-dribble-file
13346 (or (not gnus-dribble-buffer)
13347 (not (buffer-name gnus-dribble-buffer))
13348 (zerop (save-excursion
13349 (set-buffer gnus-dribble-buffer)
13351 (gnus-message 4 "(No changes need to be saved)")
13352 (if gnus-save-newsrc-file
13354 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13355 ;; Make backup file of master newsrc.
13356 (gnus-gnus-to-newsrc-format)
13357 (gnus-message 5 "Saving %s...done"
13358 gnus-current-startup-file)))
13359 ;; Quickly loadable .newsrc.
13360 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13361 (setq buffer-file-name (concat gnus-current-startup-file ".eld"))
13362 (gnus-add-current-to-buffer-list)
13363 (buffer-disable-undo (current-buffer))
13365 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13366 (gnus-gnus-to-quick-newsrc-format)
13368 (kill-buffer (current-buffer))
13369 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13370 (gnus-dribble-delete-file))))))
13372 (defun gnus-gnus-to-quick-newsrc-format ()
13373 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13374 (insert ";; Gnus startup file.\n")
13375 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13376 (insert ";; to read .newsrc.\n")
13377 (insert "(setq gnus-newsrc-file-version "
13378 (prin1-to-string gnus-version) ")\n")
13379 (let ((variables gnus-variable-list)
13381 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13383 ;; insert lisp expressions.
13384 (gnus-compress-newsrc-alist)
13386 (setq variable (car variables))
13387 (and (boundp variable)
13388 (symbol-value variable)
13389 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13390 (insert "(setq " (symbol-name variable) " '"
13391 (prin1-to-string (symbol-value variable))
13393 (setq variables (cdr variables)))
13394 (gnus-uncompress-newsrc-alist)))
13397 (defun gnus-gnus-to-newsrc-format ()
13398 ;; Generate and save the .newsrc file.
13399 (let ((newsrc (cdr gnus-newsrc-alist))
13402 (set-buffer (create-file-buffer gnus-current-startup-file))
13403 (setq buffer-file-name gnus-current-startup-file)
13404 (buffer-disable-undo (current-buffer))
13407 (if gnus-newsrc-options (insert gnus-newsrc-options))
13408 ;; Write subscribed and unsubscribed.
13410 (setq info (car newsrc))
13411 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13413 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13415 (if (setq ranges (nth 2 info))
13418 (if (not (listp (cdr ranges)))
13419 (if (= (car ranges) (cdr ranges))
13420 (insert (int-to-string (car ranges)))
13421 (insert (int-to-string (car ranges)) "-"
13422 (int-to-string (cdr ranges))))
13424 (setq range (car ranges)
13425 ranges (cdr ranges))
13426 (if (or (atom range) (= (car range) (cdr range)))
13427 (insert (int-to-string
13428 (or (and (atom range) range)
13430 (insert (int-to-string (car range)) "-"
13431 (int-to-string (cdr range))))
13432 (if ranges (insert ","))))))
13434 (setq newsrc (cdr newsrc)))
13435 ;; It has been reported that sometime the modtime on the .newsrc
13436 ;; file seems to be off. We really do want to overwrite it, so
13437 ;; we clear the modtime here before saving. It's a bit odd,
13439 ;; sometimes the modtime clear isn't sufficient. most brute force:
13440 ;; delete the silly thing entirely first. but this fails to provide
13441 ;; such niceties as .newsrc~ creation.
13442 (if gnus-modtime-botch
13443 (delete-file gnus-startup-file)
13444 (clear-visited-file-modtime))
13446 (kill-buffer (current-buffer)))))
13448 (defun gnus-read-all-descriptions-files ()
13449 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13451 (gnus-read-descriptions-file (car methods))
13452 (setq methods (cdr methods)))
13455 (defun gnus-read-descriptions-file (&optional method)
13456 (let ((method (or method gnus-select-method)))
13457 ;; We create the hashtable whether we manage to read the desc file
13458 ;; to avoid trying to re-read after a failed read.
13459 (or gnus-description-hashtb
13460 (setq gnus-description-hashtb
13461 (gnus-make-hashtable (length gnus-active-hashtb))))
13462 ;; Mark this method's desc file as read.
13463 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13464 gnus-description-hashtb)
13466 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13468 ((not (gnus-check-server method))
13469 (gnus-message 1 "Couldn't open server")
13471 ((not (gnus-request-list-newsgroups method))
13472 (gnus-message 1 "Couldn't read newsgroups descriptions")
13478 (set-buffer nntp-server-buffer)
13479 (goto-char (point-min))
13480 (if (or (search-forward "\n.\n" nil t)
13481 (goto-char (point-max)))
13483 (beginning-of-line)
13484 (narrow-to-region (point-min) (point))))
13485 (goto-char (point-min))
13486 (while (not (eobp))
13487 ;; If we get an error, we set group to 0, which is not a
13491 (let ((obarray gnus-description-hashtb))
13492 ;; Group is set to a symbol interned in this
13494 (read nntp-server-buffer))
13496 (skip-chars-forward " \t")
13497 ;; ... which leads to this line being effectively ignored.
13498 (and (symbolp group)
13499 (set group (buffer-substring
13500 (point) (progn (end-of-line) (point)))))
13501 (forward-line 1))))
13502 (gnus-message 5 "Reading descriptions file...done")
13505 (defun gnus-group-get-description (group)
13506 ;; Get the description of a group by sending XGTITLE to the server.
13507 (and (gnus-request-group-description group)
13509 (set-buffer nntp-server-buffer)
13510 (goto-char (point-min))
13511 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13512 (buffer-substring (match-beginning 1) (match-end 1))))))
13518 (defvar gnus-server-mode-hook nil
13519 "Hook run in `gnus-server-mode' buffers.")
13521 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13522 "Format of server lines.
13523 It works along the same lines as a normal formatting string,
13524 with some simple extensions.")
13526 (defvar gnus-server-mode-line-format "Gnus List of servers"
13527 "The format specification for the server mode line.")
13529 (defconst gnus-server-line-format-alist
13530 (list (list ?h 'how ?s)
13532 (list ?w 'where ?s)
13535 (defconst gnus-server-mode-line-format-alist
13536 (list (list ?S 'news-server ?s)
13537 (list ?M 'news-method ?s)
13538 (list ?u 'user-defined ?s)))
13540 (defvar gnus-server-line-format-spec nil)
13541 (defvar gnus-server-mode-line-format-spec nil)
13542 (defvar gnus-server-killed-servers nil)
13544 (defvar gnus-server-mode-map nil)
13545 (put 'gnus-server-mode 'mode-class 'special)
13547 (if gnus-server-mode-map
13549 (setq gnus-server-mode-map (make-sparse-keymap))
13550 (suppress-keymap gnus-server-mode-map)
13551 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13552 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13553 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13554 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13555 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13556 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13557 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13558 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13559 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13560 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13562 (defun gnus-server-mode ()
13563 "Major mode for listing and editing servers.
13565 All normal editing commands are switched off.
13566 \\<gnus-server-mode-map>
13568 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13570 The following commands are available:
13572 \\{gnus-server-mode-map}"
13574 (if gnus-visual (gnus-server-make-menu-bar))
13575 (kill-all-local-variables)
13576 (setq mode-line-modified "-- ")
13577 (make-local-variable 'mode-line-format)
13578 (setq mode-line-format (copy-sequence mode-line-format))
13579 (and (equal (nth 3 mode-line-format) " ")
13580 (setcar (nthcdr 3 mode-line-format) ""))
13581 (setq major-mode 'gnus-server-mode)
13582 (setq mode-name "Server")
13583 ; (gnus-group-set-mode-line)
13584 (setq mode-line-process nil)
13585 (use-local-map gnus-server-mode-map)
13586 (buffer-disable-undo (current-buffer))
13587 (setq truncate-lines t)
13588 (setq buffer-read-only t)
13589 (run-hooks 'gnus-server-mode-hook))
13591 (defun gnus-server-insert-server-line (sformat name method)
13592 (let* ((sformat (or sformat gnus-server-line-format-spec))
13594 (where (nth 1 method))
13596 (beginning-of-line)
13598 ;; Insert the text.
13599 (insert (eval sformat))
13600 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13602 (defun gnus-server-setup-buffer ()
13603 (if (get-buffer gnus-server-buffer)
13606 (set-buffer (get-buffer-create gnus-server-buffer))
13608 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13610 (defun gnus-server-prepare ()
13611 (setq gnus-server-mode-line-format-spec
13612 (gnus-parse-format gnus-server-mode-line-format
13613 gnus-server-mode-line-format-alist))
13614 (setq gnus-server-line-format-spec
13615 (gnus-parse-format gnus-server-line-format
13616 gnus-server-line-format-alist))
13617 (let ((alist gnus-server-alist)
13618 (buffer-read-only nil))
13621 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13622 (setq alist (cdr alist))))
13623 (goto-char (point-min))
13624 (gnus-server-position-cursor))
13626 (defun gnus-server-server-name ()
13627 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13628 (and server (symbol-name server))))
13630 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13632 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13634 (defun gnus-server-update-server (server)
13636 (set-buffer gnus-server-buffer)
13637 (let ((buffer-read-only nil)
13638 (info (cdr (assoc server gnus-server-alist))))
13639 (gnus-dribble-enter
13640 (concat "(gnus-server-set-info \"" server "\" '"
13641 (prin1-to-string info) ")"))
13642 ;; Buffer may be narrowed.
13645 (if (gnus-server-goto-server server)
13646 (delete-region (progn (beginning-of-line) (point))
13647 (progn (forward-line 1) (point))))
13648 (let ((entry (assoc server gnus-server-alist)))
13649 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13650 (gnus-server-position-cursor))))))
13652 (defun gnus-server-set-info (server info)
13653 ;; Enter a select method into the virtual server alist.
13654 (gnus-dribble-enter
13655 (concat "(gnus-server-set-info \"" server "\" '"
13656 (prin1-to-string info) ")"))
13657 (let* ((server (nth 1 info))
13658 (entry (assoc server gnus-server-alist)))
13659 (if entry (setcdr entry info)
13660 (setq gnus-server-alist
13661 (nconc gnus-server-alist (list (cons server info)))))))
13663 (defun gnus-server-to-method (server)
13664 ;; Map virtual server names to select methods.
13665 (or (and (equal server "native") gnus-select-method)
13666 (cdr (assoc server gnus-server-alist))))
13668 (defun gnus-server-extend-method (group method)
13669 ;; This function "extends" a virtual server. If the server is
13670 ;; "hello", and the select method is ("hello" (my-var "something"))
13671 ;; in the group "alt.alt", this will result in a new virtual server
13672 ;; called "helly+alt.alt".
13674 (gnus-copy-sequence
13675 (if (equal (car method) "native") gnus-select-method
13676 (cdr (assoc (car method) gnus-server-alist))))))
13677 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13678 (nconc entry (cdr method))))
13680 (defun gnus-server-get-method (group method)
13681 ;; Input either a server name, and extended server name, or a
13682 ;; select method, and return a select method.
13683 (cond ((stringp method)
13684 (gnus-server-to-method method))
13685 ((and (stringp (car method)) group)
13686 (gnus-server-extend-method group method))
13688 (gnus-server-add-address method))))
13690 (defun gnus-server-add-address (method)
13691 (let ((method-name (symbol-name (car method))))
13692 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13693 (not (assq (intern (concat method-name "-address")) method)))
13694 (append method (list (list (intern (concat method-name "-address"))
13698 (defun gnus-server-equal (s1 s2)
13700 (and (= (length s1) (length s2))
13702 (while (and s1 (member (car s1) s2))
13703 (setq s1 (cdr s1)))
13706 ;;; Interactive server functions.
13708 (defun gnus-server-kill-server (server)
13709 "Kill the server on the current line."
13710 (interactive (list (gnus-server-server-name)))
13711 (or (gnus-server-goto-server server)
13712 (if server (error "No such server: %s" server)
13713 (error "No server on the current line")))
13714 (gnus-dribble-enter "")
13715 (let ((buffer-read-only nil))
13716 (delete-region (progn (beginning-of-line) (point))
13717 (progn (forward-line 1) (point))))
13718 (setq gnus-server-killed-servers
13719 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13720 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13721 gnus-server-alist))
13722 (gnus-server-position-cursor))
13724 (defun gnus-server-yank-server ()
13725 "Yank the previously killed server."
13727 (or gnus-server-killed-servers
13728 (error "No killed servers to be yanked"))
13729 (let ((alist gnus-server-alist)
13730 (server (gnus-server-server-name))
13731 (killed (car gnus-server-killed-servers)))
13733 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13734 (if (string= server (car (car gnus-server-alist)))
13735 (setq gnus-server-alist (cons killed gnus-server-alist))
13736 (while (and (cdr alist)
13737 (not (string= server (car (car (cdr alist))))))
13738 (setq alist (cdr alist)))
13739 (setcdr alist (cons killed (cdr alist)))))
13740 (gnus-server-update-server (car killed))
13741 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13742 (gnus-server-position-cursor)))
13744 (defun gnus-server-exit ()
13745 "Return to the group buffer."
13747 (kill-buffer (current-buffer))
13748 (switch-to-buffer gnus-group-buffer))
13750 (defun gnus-server-list-servers ()
13751 "List all available servers."
13753 (let ((cur (gnus-server-server-name)))
13754 (gnus-server-prepare)
13755 (if cur (gnus-server-goto-server cur)
13756 (goto-char (point-max))
13758 (gnus-server-position-cursor)))
13760 (defun gnus-server-copy-server (from to)
13763 (or (gnus-server-server-name)
13764 (error "No server on the current line"))
13765 (read-string "Copy to: ")))
13766 (or from (error "No server on current line"))
13767 (or (and to (not (string= to ""))) (error "No name to copy to"))
13768 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13769 (or (assoc from gnus-server-alist)
13770 (error "%s: no such server" from))
13771 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13772 (setcar to-entry to)
13773 (setcar (nthcdr 2 to-entry) to)
13774 (setq gnus-server-killed-servers
13775 (cons to-entry gnus-server-killed-servers))
13776 (gnus-server-yank-server)))
13778 (defun gnus-server-add-server (how where)
13780 (list (intern (completing-read "Server method: "
13781 gnus-valid-select-methods nil t))
13782 (read-string "Server name: ")))
13783 (setq gnus-server-killed-servers
13784 (cons (list where how where) gnus-server-killed-servers))
13785 (gnus-server-yank-server))
13787 (defun gnus-server-goto-server (server)
13788 "Jump to a server line."
13790 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13791 (let ((to (text-property-any (point-min) (point-max)
13792 'gnus-server (intern server))))
13796 (gnus-server-position-cursor)))))
13798 (defun gnus-server-edit-server (server)
13799 "Edit the server on the current line."
13800 (interactive (list (gnus-server-server-name)))
13802 (error "No server on current line"))
13803 (let ((winconf (current-window-configuration)))
13804 (get-buffer-create gnus-server-edit-buffer)
13805 (gnus-configure-windows 'edit-server)
13806 (gnus-add-current-to-buffer-list)
13808 (make-local-variable 'gnus-prev-winconf)
13809 (setq gnus-prev-winconf winconf)
13810 (use-local-map (copy-keymap (current-local-map)))
13811 (let ((done-func '(lambda ()
13812 "Exit editing mode and update the information."
13814 (gnus-server-edit-server-done 'group))))
13815 (setcar (cdr (nth 4 done-func)) server)
13816 (local-set-key "\C-c\C-c" done-func))
13818 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13819 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13821 (defun gnus-server-edit-server-done (server)
13823 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13824 (goto-char (point-min))
13825 (let ((form (read (current-buffer)))
13826 (winconf gnus-prev-winconf))
13827 (gnus-server-set-info server form)
13828 (kill-buffer (current-buffer))
13829 (and winconf (set-window-configuration winconf))
13830 (set-buffer gnus-server-buffer)
13831 (gnus-server-update-server (gnus-server-server-name))
13832 (gnus-server-list-servers)
13833 (gnus-server-position-cursor)))
13835 (defun gnus-server-read-server (server)
13837 (interactive (list (gnus-server-server-name)))
13838 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13840 (defun gnus-mouse-pick-server (e)
13842 (mouse-set-point e)
13843 (gnus-server-read-server (gnus-server-server-name)))
13846 ;;; entry points into gnus-score.el
13849 ;;; Finding score files.
13851 (defvar gnus-global-score-files nil
13852 "*List of global score files and directories.
13853 Set this variable if you want to use people's score files. One entry
13854 for each score file or each score file directory. Gnus will decide
13855 by itself what score files are applicable to which group.
13857 Say you want to use the single score file
13858 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13859 score files in the \"/ftp.some-where:/pub/score\" directory.
13861 (setq gnus-global-score-files
13862 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13863 \"/ftp.some-where:/pub/score\"))")
13865 (defun gnus-score-score-files (group)
13866 "Return a list of all possible score files."
13867 ;; Search and set any global score files.
13868 (and gnus-global-score-files
13869 (or gnus-internal-global-score-files
13870 (gnus-score-search-global-directories gnus-global-score-files)))
13871 ;; Fix the kill-file dir variable.
13872 (setq gnus-kill-files-directory
13873 (file-name-as-directory
13874 (or gnus-kill-files-directory "~/News/")))
13875 ;; If we can't read it, there are no score files.
13876 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13877 (setq gnus-score-file-list nil)
13878 (if (gnus-use-long-file-name 'not-score)
13879 ;; We want long file names.
13880 (if (or (not gnus-score-file-list)
13881 (not (car gnus-score-file-list))
13882 (gnus-file-newer-than gnus-kill-files-directory
13883 (car gnus-score-file-list)))
13884 (setq gnus-score-file-list
13885 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13888 gnus-kill-files-directory t
13889 (gnus-score-file-regexp))))))
13890 ;; We do not use long file names, so we have to do some
13891 ;; directory traversing.
13892 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13893 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13896 (setq dir (expand-file-name
13897 (concat gnus-kill-files-directory
13898 (gnus-replace-chars-in-string group ?. ?/))))
13899 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13900 (setq suffix (car suffixes)
13901 suffixes (cdr suffixes))
13902 (if (file-exists-p (concat dir "/" suffix))
13903 (setq files (cons (concat dir "/" suffix) files)))
13904 (while (>= (1+ (length dir)) mdir)
13905 (and (file-exists-p (concat dir "/all/" suffix))
13906 (setq files (cons (concat dir "/all/" suffix) files)))
13907 (string-match "/[^/]*$" dir)
13908 (setq dir (substring dir 0 (match-beginning 0)))))
13909 (setq gnus-score-file-list
13910 (cons nil (nreverse files)))))
13911 (cdr gnus-score-file-list)))
13913 (defun gnus-score-file-regexp ()
13914 (concat "\\(" gnus-score-file-suffix
13915 "\\|" gnus-adaptive-file-suffix "\\)$"))
13917 (defun gnus-score-find-bnews (group)
13918 "Return a list of score files for GROUP.
13919 The score files are those files in the ~/News directory which matches
13920 GROUP using BNews sys file syntax."
13921 (let* ((sfiles (append (gnus-score-score-files group)
13922 gnus-internal-global-score-files))
13923 (kill-dir (file-name-as-directory
13924 (expand-file-name gnus-kill-files-directory)))
13925 (klen (length kill-dir))
13926 ofiles not-match regexp)
13928 (set-buffer (get-buffer-create "*gnus score files*"))
13929 (buffer-disable-undo (current-buffer))
13930 ;; Go through all score file names and create regexp with them
13934 (insert (car sfiles))
13935 (goto-char (point-min))
13936 ;; First remove the suffix itself.
13937 (re-search-forward (concat "." (gnus-score-file-regexp)))
13938 (replace-match "" t t)
13939 (goto-char (point-min))
13940 (if (looking-at (regexp-quote kill-dir))
13941 ;; If the file name was just "SCORE", `klen' is one character
13943 (delete-char (min (1- (point-max)) klen))
13944 (goto-char (point-max))
13945 (search-backward "/")
13946 (delete-region (1+ (point)) (point-min)))
13947 ;; If short file names were used, we have to translate slashes.
13948 (goto-char (point-min))
13949 (while (re-search-forward "[/:]" nil t)
13950 (replace-match "." t t))
13951 ;; Cludge to get rid of "nntp+" problems.
13952 (goto-char (point-min))
13953 (and (looking-at "nn[a-z]+\\+")
13955 (search-forward "+")
13958 ;; Translate "all" to ".*".
13959 (while (search-forward "all" nil t)
13960 (replace-match ".*" t t))
13961 (goto-char (point-min))
13962 ;; Deal with "not."s.
13963 (if (looking-at "not.")
13966 (setq regexp (buffer-substring 5 (point-max))))
13967 (setq regexp (buffer-substring 1 (point-max)))
13968 (setq not-match nil))
13969 ;; Finally - if this resulting regexp matches the group name,
13970 ;; we add this score file to the list of score files
13971 ;; applicable to this group.
13972 (if (or (and not-match
13973 (not (string-match regexp group)))
13974 (and (not not-match)
13975 (string-match regexp group)))
13976 (setq ofiles (cons (car sfiles) ofiles)))
13977 (setq sfiles (cdr sfiles)))
13978 (kill-buffer (current-buffer))
13979 ;; Slight kludge here - the last score file returned should be
13980 ;; the local score file, whether it exists or not. This is so
13981 ;; that any score commands the user enters will go to the right
13982 ;; file, and not end up in some global score file.
13985 (if (gnus-use-long-file-name 'not-score)
13986 (concat gnus-kill-files-directory group "."
13987 gnus-score-file-suffix)
13988 (concat gnus-kill-files-directory
13989 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
13990 "/" gnus-score-file-suffix)))))
13991 (and (member localscore ofiles)
13992 (delete localscore ofiles))
13993 (setq ofiles (cons localscore ofiles)))
13994 (nreverse ofiles))))
13996 (defun gnus-score-find-single (group)
13997 "Return list containing the score file for GROUP."
13998 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
13999 (gnus-score-file-name group)))
14001 (defun gnus-score-find-hierarchical (group)
14002 "Return list of score files for GROUP.
14003 This includes the score file for the group and all its parents."
14004 (let ((all (copy-sequence '(nil)))
14006 (while (string-match "\\." group (1+ start))
14007 (setq start (match-beginning 0))
14008 (setq all (cons (substring group 0 start) all)))
14009 (setq all (cons group all))
14011 (mapcar (lambda (newsgroup)
14012 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14013 (setq all (nreverse all)))
14014 (mapcar 'gnus-score-file-name all))))
14016 (defvar gnus-score-file-alist-cache nil)
14018 (defun gnus-score-find-alist (group)
14019 "Return list of score files for GROUP.
14020 The list is determined from the variable gnus-score-file-alist."
14021 (let ((alist gnus-score-file-multiple-match-alist)
14023 ;; if this group has been seen before, return the cached entry
14024 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14025 (cdr score-files) ;ensures caching groups with no matches
14026 ;; handle the multiple match alist
14028 (and (string-match (car (car alist)) group)
14030 (nconc score-files (copy-sequence (cdr (car alist))))))
14031 (setq alist (cdr alist)))
14032 (setq alist gnus-score-file-single-match-alist)
14033 ;; handle the single match alist
14035 (and (string-match (car (car alist)) group)
14036 ;; progn used just in case ("regexp") has no files
14037 ;; and score-files is still nil. -sj
14038 ;; this can be construed as a "stop searching here" feature :>
14039 ;; and used to simplify regexps in the single-alist
14042 (nconc score-files (copy-sequence (cdr (car alist)))))
14044 (setq alist (cdr alist)))
14045 ;; cache the score files
14046 (setq gnus-score-file-alist-cache
14047 (cons (cons group score-files) gnus-score-file-alist-cache))
14051 (defun gnus-possibly-score-headers (&optional trace)
14052 (let ((func gnus-score-find-score-files-function)
14054 (and func (not (listp func))
14055 (setq func (list func)))
14056 ;; Go through all the functions for finding score files (or actual
14057 ;; scores) and add them to a list.
14058 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14060 (and (symbolp (car func))
14061 (fboundp (car func))
14063 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14064 (setq func (cdr func)))
14065 (if score-files (gnus-score-headers score-files trace))))
14067 (defun gnus-score-file-name (newsgroup &optional suffix)
14068 "Return the name of a score file for NEWSGROUP."
14069 (let ((suffix (or suffix gnus-score-file-suffix)))
14071 ((or (null newsgroup)
14072 (string-equal newsgroup ""))
14073 ;; The global score file is placed at top of the directory.
14075 suffix (or gnus-kill-files-directory "~/News")))
14076 ((gnus-use-long-file-name 'not-score)
14077 ;; Append ".SCORE" to newsgroup name.
14078 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14080 (or gnus-kill-files-directory "~/News")))
14082 ;; Place "SCORE" under the hierarchical directory.
14083 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14085 (or gnus-kill-files-directory "~/News"))))))
14087 (defun gnus-score-search-global-directories (files)
14088 "Scan all global score directories for score files."
14089 ;; Set the variable `gnus-internal-global-score-files' to all
14090 ;; available global score files.
14091 (interactive (list gnus-global-score-files))
14094 (if (string-match "/$" (car files))
14095 (setq out (nconc (directory-files
14097 (concat (gnus-score-file-regexp) "$"))))
14098 (setq out (cons (car files) out)))
14099 (setq files (cdr files)))
14100 (setq gnus-internal-global-score-files out)))
14102 ;; Allow redefinition of Gnus functions.
14104 (gnus-ems-redefine)
14108 ;;; gnus.el ends here