1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although Gnus looks suspiciously like GNUS, it isn't quite the same
27 ;; beast. Most internal structures have been changed. If you have
28 ;; written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
40 ;; Site dependent variables. These variables should be defined in
43 (defvar gnus-default-nntp-server nil
44 "Specify a default NNTP server.
45 This variable should be defined in paths.el, and should never be set
47 If you want to change servers, you should use `gnus-select-method'.
48 See the documentation to that variable.")
50 (defconst gnus-backup-default-subscribed-newsgroups
51 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
52 "Default default new newsgroups the first time Gnus is run.
53 Should be set in paths.el, and shouldn't be touched by the user.")
55 (defvar gnus-local-domain nil
56 "Local domain name without a host name.
57 The DOMAINNAME environment variable is used instead if it is defined.
58 If the `system-name' function returns the full Internet name, there is
59 no need to set this variable.")
61 (defvar gnus-local-organization nil
62 "String with a description of what organization (if any) the user belongs to.
63 The ORGANIZATION environment variable is used instead if it is defined.
64 If this variable contains a function, this function will be called
65 with the current newsgroup name as the argument. The function should
68 In any case, if the string (either in the variable, in the environment
69 variable, or returned by the function) is a file name, the contents of
70 this file will be used as the organization.")
72 (defvar gnus-use-generic-from nil
73 "If nil, the full host name will be the system name prepended to the domain name.
74 If this is a string, the full host name will be this string.
75 If this is non-nil, non-string, the domain name will be used as the
78 (defvar gnus-use-generic-path nil
79 "If nil, use the NNTP server name in the Path header.
80 If stringp, use this; if non-nil, use no host name (user name only).")
83 ;; Customization variables
85 (defvar gnus-select-method
86 (list 'nntp (or (getenv "NNTPSERVER")
87 (if (and gnus-default-nntp-server
88 (not (string= gnus-default-nntp-server "")))
89 gnus-default-nntp-server)
91 "*Default method for selecting a newsgroup.
92 This variable should be a list, where the first element is how the
93 news is to be fetched, the second is the address.
95 For instance, if you want to get your news via NNTP from
96 \"flab.flab.edu\", you could say:
98 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
100 If you want to use your local spool, say:
102 (setq gnus-select-method (list 'nnspool (system-name)))
104 If you use this variable, you must set `gnus-nntp-server' to nil.
106 There is a lot more to know about select methods and virtual servers -
107 see the manual for details.")
109 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
110 (defvar gnus-post-method nil
111 "*Preferred method for posting USENET news.
112 If this variable is nil, Gnus will use the current method to decide
113 which method to use when posting. If it is non-nil, it will override
114 the current method. This method will not be used in mail groups and
115 the like, only in \"real\" newsgroups.
117 The value must be a valid method as discussed in the documentation of
118 `gnus-select-method'.")
120 (defvar gnus-refer-article-method nil
121 "*Preferred method for fetching an article by Message-ID.
122 If you are reading news from the local spool (with nnspool), fetching
123 articles by Message-ID is painfully slow. By setting this method to an
124 nntp method, you might get acceptable results.
126 The value of this variable must be a valid select method as discussed
127 in the documentation of `gnus-select-method'")
129 (defvar gnus-secondary-select-methods nil
130 "*A list of secondary methods that will be used for reading news.
131 This is a list where each element is a complete select method (see
132 `gnus-select-method').
134 If, for instance, you want to read your mail with the nnml backend,
135 you could set this variable:
137 (setq gnus-secondary-select-methods '((nnml \"\")))")
139 (defvar gnus-secondary-servers nil
140 "*List of NNTP servers that the user can choose between interactively.
141 To make Gnus query you for a server, you have to give `gnus' a
142 non-numeric prefix - `C-u M-x gnus', in short.")
144 (defvar gnus-nntp-server nil
145 "*The name of the host running the NNTP server.
146 This variable is semi-obsolete. Use the `gnus-select-method'
149 (defvar gnus-nntp-service "nntp"
150 "*NNTP service name (\"nntp\" or 119).
151 This is an obsolete variable, which is scarcely used. If you use an
152 nntp server for your newsgroup and want to change the port number
153 used to 899, you would say something along these lines:
155 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
157 (defvar gnus-startup-file "~/.newsrc"
158 "*Your `.newsrc' file.
159 `.newsrc-SERVER' will be used instead if that exists.")
161 (defvar gnus-init-file "~/.gnus"
162 "*Your Gnus elisp startup file.
163 If a file with the .el or .elc suffixes exist, it will be read
166 (defvar gnus-group-faq-directory
167 "/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
168 "*Directory where the group FAQs are stored.
169 This will most commonly be on a remote machine, and the file will be
172 Note that Gnus uses an aol machine as the default directory. If this
173 feels fundamentally unclean, just think of it as a way to finally get
174 something of value back from them.
176 If the default site is too slow, try one of these:
178 North America: ftp.uu.net /usenet/news.answers
179 mirrors.aol.com /pub/rtfm/usenet
180 ftp.seas.gwu.edu /pub/rtfm
181 rtfm.mit.edu /pub/usenet/news.answers
182 Europe: ftp.uni-paderborn.de /pub/FAQ
183 ftp.Germany.EU.net /pub/newsarchive/news.answers
184 ftp.sunet.se /pub/usenet
185 Asia: nctuccca.edu.tw /USENET/FAQ
186 hwarang.postech.ac.kr /pub/usenet/news.answers
187 ftp.hk.super.net /mirror/faqs")
189 (defvar gnus-group-archive-directory
190 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
191 "*The address of the (ding) archives.")
193 (defvar gnus-group-recent-archive-directory
194 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
195 "*The address of the most recent (ding) articles.")
197 (defvar gnus-default-subscribed-newsgroups nil
198 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
199 It should be a list of strings.
200 If it is `t', Gnus will not do anything special the first time it is
201 started; it'll just use the normal newsgroups subscription methods.")
203 (defvar gnus-use-cross-reference t
204 "*Non-nil means that cross referenced articles will be marked as read.
205 If nil, ignore cross references. If t, mark articles as read in
206 subscribed newsgroups. If neither t nor nil, mark as read in all
209 (defvar gnus-use-dribble-file t
210 "*Non-nil means that Gnus will use a dribble file to store user updates.
211 If Emacs should crash without saving the .newsrc files, complete
212 information can be restored from the dribble file.")
214 (defvar gnus-asynchronous nil
215 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
217 (defvar gnus-asynchronous-article-function nil
218 "*Function for picking articles to pre-fetch, possibly.")
220 (defvar gnus-score-file-single-match-alist nil
221 "*Alist mapping regexps to lists of score files.
222 Each element of this alist should be of the form
223 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
225 If the name of a group is matched by REGEXP, the corresponding scorefiles
226 will be used for that group.
227 The first match found is used, subsequent matching entries are ignored (to
228 use multiple matches, see gnus-score-file-multiple-match-alist).
230 These score files are loaded in addition to any files returned by
231 gnus-score-find-score-files-function (which see).")
233 (defvar gnus-score-file-multiple-match-alist nil
234 "*Alist mapping regexps to lists of score files.
235 Each element of this alist should be of the form
236 (\"REGEXP\" [ \"SCORE-FILE-1\" ] [ \"SCORE-FILE-2\" ] ... )
238 If the name of a group is matched by REGEXP, the corresponding scorefiles
239 will be used for that group.
240 If multiple REGEXPs match a group, the score files corresponding to each
241 match will be used (for only one match to be used, see
242 gnus-score-file-single-match-alist).
244 These score files are loaded in addition to any files returned by
245 gnus-score-find-score-files-function (which see).")
248 (defvar gnus-score-file-suffix "SCORE"
249 "*Suffix of the score files.")
251 (defvar gnus-adaptive-file-suffix "ADAPT"
252 "*Suffix of the adaptive score files.")
254 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
255 "*Function used to find score files.
256 The function will be called with the group name as the argument, and
257 should return a list of score files to apply to that group. The score
258 files do not actually have to exist.
260 Predefined values are:
262 gnus-score-find-single: Only apply the group's own score file.
263 gnus-score-find-hierarchical: Also apply score files from parent groups.
264 gnus-score-find-bnews: Apply score files whose names matches.
266 See the documentation to these functions for more information.
268 This variable can also be a list of functions to be called. Each
269 function should either return a list of score files, or a list of
272 (defvar gnus-score-interactive-default-score 1000
273 "*Scoring commands will raise/lower the score with this number as the default.")
275 (defvar gnus-large-newsgroup 200
276 "*The number of articles which indicates a large newsgroup.
277 If the number of articles in a newsgroup is greater than this value,
278 confirmation is required for selecting the newsgroup.")
280 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
281 (defvar gnus-no-groups-message "No news is horrible news"
282 "*Message displayed by Gnus when no groups are available.")
284 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
285 "*Non-nil means that the default name of a file to save articles in is the group name.
286 If it's nil, the directory form of the group name is used instead.
288 If this variable is a list, and the list contains the element
289 `not-score', long file names will not be used for score files; if it
290 contains the element `not-save', long file names will not be used for
291 saving; and if it contains the element `not-kill', long file names
292 will not be used for kill files.")
294 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
295 "*Name of the directory articles will be saved in (default \"~/News\").
296 Initialized from the SAVEDIR environment variable.")
298 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
299 "*Name of the directory where kill files will be stored (default \"~/News\").
300 Initialized from the SAVEDIR environment variable.")
302 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
303 "*A function to save articles in your favorite format.
304 The function must be interactively callable (in other words, it must
305 be an Emacs command).
307 Gnus provides the following functions:
309 * gnus-summary-save-in-rmail (Rmail format)
310 * gnus-summary-save-in-mail (Unix mail format)
311 * gnus-summary-save-in-folder (MH folder)
312 * gnus-summary-save-in-file (article format).
313 * gnus-summary-save-in-vm (use VM's folder format).")
315 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
316 "*A function generating a file name to save articles in Rmail format.
317 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
319 (defvar gnus-mail-save-name (function gnus-plain-save-name)
320 "*A function generating a file name to save articles in Unix mail format.
321 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
323 (defvar gnus-folder-save-name (function gnus-folder-save-name)
324 "*A function generating a file name to save articles in MH folder.
325 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
327 (defvar gnus-file-save-name (function gnus-numeric-save-name)
328 "*A function generating a file name to save articles in article format.
329 The function is called with NEWSGROUP, HEADERS, and optional
332 (defvar gnus-split-methods nil
333 "*Variable used to suggest where articles are to be saved.
334 The syntax of this variable is the same as `nnmail-split-methods'.
336 For instance, if you would like to save articles related to Gnus in
337 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
338 you could set this variable to something like:
340 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
341 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
343 (defvar gnus-save-score nil
344 "*If non-nil, save group scoring info.")
346 (defvar gnus-use-adaptive-scoring nil
347 "*If non-nil, use some adaptive scoring scheme.")
349 (defvar gnus-use-cache nil
350 "*If non-nil, Gnus will cache (some) articles locally.")
352 (defvar gnus-use-scoring t
353 "*If non-nil, enable scoring.")
355 (defvar gnus-fetch-old-headers nil
356 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
357 If an unread article in the group refers to an older, already read (or
358 just marked as read) article, the old article will not normally be
359 displayed in the Summary buffer. If this variable is non-nil, Gnus
360 will attempt to grab the headers to the old articles, and thereby
361 build complete threads. If it has the value `some', only enough
362 headers to connect otherwise loose threads will be displayed.
364 The server has to support XOVER for any of this to work.")
367 ;(defvar gnus-visual t
368 ; "*If non-nil, will do various highlighting.
369 ;If nil, no mouse highlights (or any other highlights) will be
370 ;performed. This might speed up Gnus some when generating large group
371 ;and summary buffers.")
373 (defvar gnus-novice-user t
374 "*Non-nil means that you are a usenet novice.
375 If non-nil, verbose messages may be displayed and confirmations may be
378 (defvar gnus-expert-user nil
379 "*Non-nil means that you will never be asked for confirmation about anything.
380 And that means *anything*.")
382 (defvar gnus-verbose 7
383 "*Integer that says how verbose Gnus should be.
384 The higher the number, the more messages Gnus will flash to say what
385 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
386 display most important messages; and at ten, Gnus will keep on
387 jabbering all the time.")
389 (defvar gnus-keep-same-level nil
390 "*Non-nil means that the next newsgroup after the current will be on the same level.
391 When you type, for instance, `n' after reading the last article in the
392 current newsgroup, you will go to the next newsgroup. If this variable
393 is nil, the next newsgroup will be the next from the group
395 If this variable is non-nil, Gnus will either put you in the
396 next newsgroup with the same level, or, if no such newsgroup is
397 available, the next newsgroup with the lowest possible level higher
398 than the current level.
399 If this variable is `best', Gnus will make the next newsgroup the one
400 with the best level.")
402 (defvar gnus-summary-make-false-root 'adopt
403 "*nil means that Gnus won't gather loose threads.
404 If the root of a thread has expired or been read in a previous
405 session, the information necessary to build a complete thread has been
406 lost. Instead of having many small sub-threads from this original thread
407 scattered all over the summary buffer, Gnus can gather them.
409 If non-nil, Gnus will try to gather all loose sub-threads from an
410 original thread into one large thread.
412 If this variable is non-nil, it should be one of `none', `adopt',
415 If this variable is `none', Gnus will not make a false root, but just
416 present the sub-threads after another.
417 If this variable is `dummy', Gnus will create a dummy root that will
418 have all the sub-threads as children.
419 If this variable is `adopt', Gnus will make one of the \"children\"
420 the parent and mark all the step-children as such.
421 If this variable is `empty', the \"children\" are printed with empty
422 subject fields. (Or rather, they will be printed with a string
423 given by the `gnus-summary-same-subject' variable.)")
425 (defvar gnus-summary-gather-subject-limit nil
426 "*Maximum length of subject comparisons when gathering loose threads.
427 Use nil to compare full subjects. Setting this variable to a low
428 number will help gather threads that have been corrupted by
429 newsreaders chopping off subject lines, but it might also mean that
430 unrelated articles that have subject that happen to begin with the
431 same few characters will be incorrectly gathered.
433 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
434 comparing subjects.")
436 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
437 (defvar gnus-summary-same-subject ""
438 "*String indicating that the current article has the same subject as the previous.
439 This variable will only be used if the value of
440 `gnus-summary-make-false-root' is `empty'.")
442 (defvar gnus-summary-goto-unread t
443 "*If non-nil, marking commands will go to the next unread article.")
445 (defvar gnus-group-goto-unread t
446 "*If non-nil, movement commands will go to the next unread and subscribed group.")
448 (defvar gnus-check-new-newsgroups t
449 "*Non-nil means that Gnus will add new newsgroups at startup.
450 If this variable is `ask-server', Gnus will ask the server for new
451 groups since the last time it checked. This means that the killed list
452 is no longer necessary, so you could set `gnus-save-killed-list' to
455 A variant is to have this variable be a list of select methods. Gnus
456 will then use the `ask-server' method on all these select methods to
457 query for new groups from all those servers.
460 (setq gnus-check-new-newsgroups
461 '((nntp \"some.server\") (nntp \"other.server\")))
463 If this variable is nil, then you have to tell Gnus explicitly to
464 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
466 (defvar gnus-check-bogus-newsgroups nil
467 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
468 If this variable is nil, then you have to tell Gnus explicitly to
469 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
471 (defvar gnus-read-active-file t
472 "*Non-nil means that Gnus will read the entire active file at startup.
473 If this variable is nil, Gnus will only know about the groups in your
476 If this variable is `some', Gnus will try to only read the relevant
477 parts of the active file from the server. Not all servers support
478 this, and it might be quite slow with other servers, but this should
479 generally be faster than both the t and nil value.
481 If you set this variable to nil or `some', you probably still want to
482 be told about new newsgroups that arrive. To do that, set
483 `gnus-check-new-newsgroups' to `ask-server'. This may not work
484 properly with all servers.")
486 (defvar gnus-level-subscribed 5
487 "*Groups with levels less than or equal to this variable are subscribed.")
489 (defvar gnus-level-unsubscribed 7
490 "*Groups with levels less than or equal to this variable are unsubscribed.
491 Groups with levels less than `gnus-level-subscribed', which should be
492 less than this variable, are subscribed.")
494 (defvar gnus-level-zombie 8
495 "*Groups with this level are zombie groups.")
497 (defvar gnus-level-killed 9
498 "*Groups with this level are killed.")
500 (defvar gnus-level-default-subscribed 3
501 "*New subscribed groups will be subscribed at this level.")
503 (defvar gnus-level-default-unsubscribed 6
504 "*New unsubscribed groups will be unsubscribed at this level.")
506 (defvar gnus-activate-foreign-newsgroups 4
507 "*If nil, Gnus will not check foreign newsgroups at startup.
508 If it is non-nil, it should be a number between one and nine. Foreign
509 newsgroups that have a level lower or equal to this number will be
510 activated on startup. For instance, if you want to active all
511 subscribed newsgroups, but not the rest, you'd set this variable to
512 `gnus-level-subscribed'.
514 If you subscribe to lots of newsgroups from different servers, startup
515 might take a while. By setting this variable to nil, you'll save time,
516 but you won't be told how many unread articles there are in the
519 (defvar gnus-save-newsrc-file t
520 "*Non-nil means that Gnus will save the `.newsrc' file.
521 Gnus always saves its own startup file, which is called
522 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
523 be readily understood by other newsreaders. If you don't plan on
524 using other newsreaders, set this variable to nil to save some time on
527 (defvar gnus-save-killed-list t
528 "*If non-nil, save the list of killed groups to the startup file.
529 This will save both time (when starting and quitting) and space (both
530 memory and disk), but it will also mean that Gnus has no record of
531 which groups are new and which are old, so the automatic new
532 newsgroups subscription methods become meaningless. You should always
533 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
536 (defvar gnus-interactive-catchup t
537 "*If non-nil, require your confirmation when catching up a group.")
539 (defvar gnus-interactive-post t
540 "*If non-nil, group name will be asked for when posting.")
542 (defvar gnus-interactive-exit t
543 "*If non-nil, require your confirmation when exiting Gnus.")
545 (defvar gnus-kill-killed t
546 "*If non-nil, Gnus will apply kill files to already killed articles.
547 If it is nil, Gnus will never apply kill files to articles that have
548 already been through the scoring process, which might very well save lots
551 (defvar gnus-extract-address-components 'gnus-extract-address-components
552 "*Function for extracting address components from a From header.
553 Two pre-defined function exist: `gnus-extract-address-components',
554 which is the default, quite fast, and too simplistic solution, and
555 `mail-extract-address-components', which works much better, but is
558 (defvar gnus-summary-default-score 0
559 "*Default article score level.
560 If this variable is nil, scoring will be disabled.")
562 (defvar gnus-summary-zcore-fuzz 0
563 "*Fuzziness factor for the zcore in the summary buffer.
564 Articles with scores closer than this to `gnus-summary-default-score'
565 will not be marked.")
567 (defvar gnus-simplify-subject-fuzzy-regexp nil
568 "*Regular expression that will be removed from subject strings if
569 fuzzy subject simplification is selected.")
571 (defvar gnus-group-default-list-level gnus-level-subscribed
572 "*Default listing level.
573 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
575 (defvar gnus-group-use-permanent-levels nil
576 "*If non-nil, once you set a level, Gnus will use this level.")
578 (defvar gnus-show-mime nil
579 "*If non-nil, do mime processing of articles.
580 The articles will simply be fed to the function given by
581 `gnus-show-mime-method'.")
583 (defvar gnus-strict-mime t
584 "*If nil, decode MIME header even if there is not Mime-Version field.")
586 (defvar gnus-show-mime-method (function metamail-buffer)
587 "*Function to process a MIME message.
588 The function is called from the article buffer.")
590 (defvar gnus-show-threads t
591 "*If non-nil, display threads in summary mode.")
593 (defvar gnus-thread-hide-subtree nil
594 "*If non-nil, hide all threads initially.
595 If threads are hidden, you have to run the command
596 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
597 to expose hidden threads.")
599 (defvar gnus-thread-hide-killed t
600 "*If non-nil, hide killed threads automatically.")
602 (defvar gnus-thread-ignore-subject nil
603 "*If non-nil, ignore subjects and do all threading based on the Reference header.
604 If nil, which is the default, articles that have different subjects
605 from their parents will start separate threads.")
607 (defvar gnus-thread-indent-level 4
608 "*Number that says how much each sub-thread should be indented.")
610 (defvar gnus-ignored-newsgroups
611 (purecopy (mapconcat 'identity
612 '("^to\\." ; not "real" groups
613 "^[0-9. \t]+ " ; all digits in name
614 "[][\"#'()]" ; bogus characters
617 "*A regexp to match uninteresting newsgroups in the active file.
618 Any lines in the active file matching this regular expression are
619 removed from the newsgroup list before anything else is done to it,
620 thus making them effectively non-existent.")
622 (defvar gnus-ignored-headers
623 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
624 "*All headers that match this regexp will be hidden.
625 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
627 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
628 "*All headers that do not match this regexp will be hidden.
629 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
631 (defvar gnus-sorted-header-list
632 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
633 "^Cc:" "^Date:" "^Organization:")
634 "*This variable is a list of regular expressions.
635 If it is non-nil, headers that match the regular expressions will
636 be placed first in the article buffer in the sequence specified by
639 (defvar gnus-show-all-headers nil
640 "*If non-nil, don't hide any headers.")
642 (defvar gnus-save-all-headers t
643 "*If non-nil, don't remove any headers before saving.")
645 (defvar gnus-inhibit-startup-message nil
646 "*If non-nil, the startup message will not be displayed.")
648 (defvar gnus-signature-separator "^-- *$"
649 "Regexp matching signature separator.")
651 (defvar gnus-auto-extend-newsgroup t
652 "*If non-nil, extend newsgroup forward and backward when requested.")
654 (defvar gnus-auto-select-first t
655 "*If non-nil, select the first unread article when entering a group.
656 If you want to prevent automatic selection of the first unread article
657 in some newsgroups, set the variable to nil in
658 `gnus-select-group-hook'.")
660 (defvar gnus-auto-select-next t
661 "*If non-nil, offer to go to the next group from the end of the previous.
662 If the value is t and the next newsgroup is empty, Gnus will exit
663 summary mode and go back to group mode. If the value is neither nil
664 nor t, Gnus will select the following unread newsgroup. In
665 particular, if the value is the symbol `quietly', the next unread
666 newsgroup will be selected without any confirmations.")
668 (defvar gnus-auto-select-same nil
669 "*If non-nil, select the next article with the same subject.")
671 (defvar gnus-summary-check-current nil
672 "*If non-nil, consider the current article when moving.
673 The \"unread\" movement commands will stay on the same line if the
674 current article is unread.")
676 (defvar gnus-auto-center-summary t
677 "*If non-nil, always center the current summary buffer.")
679 (defvar gnus-break-pages t
680 "*If non-nil, do page breaking on articles.
681 The page delimiter is specified by the `gnus-page-delimiter'
684 (defvar gnus-page-delimiter "^\^L"
685 "*Regexp describing what to use as article page delimiters.
686 The default value is \"^\^L\", which is a form linefeed at the
687 beginning of a line.")
689 (defvar gnus-use-full-window t
690 "*If non-nil, use the entire Emacs screen.")
692 (defvar gnus-window-configuration nil
693 "Obsolete variable. See `gnus-buffer-configuration'.")
695 (defvar gnus-buffer-configuration
696 '((group ([group 1.0 point]
697 (if gnus-carpal [group-carpal 4])))
698 (summary ([summary 1.0 point]
699 (if gnus-carpal [summary-carpal 4])))
700 (article ([summary 0.25 point]
701 (if gnus-carpal [summary-carpal 4])
703 (server ([server 1.0 point]
704 (if gnus-carpal [server-carpal 2])))
705 (browse ([browse 1.0 point]
706 (if gnus-carpal [browse-carpal 2])))
707 (group-mail ([mail 1.0 point]))
708 (summary-mail ([mail 1.0 point]))
709 (summary-reply ([article 0.5]
711 (info ([nil 1.0 point]))
712 (summary-faq ([summary 0.25]
714 (edit-group ([group 0.5]
715 [edit-group 1.0 point]))
716 (edit-server ([server 0.5]
717 [edit-server 1.0 point]))
718 (edit-score ([summary 0.25]
719 [edit-score 1.0 point]))
720 (post ([post 1.0 point]))
721 (reply ([article 0.5]
723 (mail-forward ([mail 1.0 point]))
724 (post-forward ([post 1.0 point]))
725 (reply-yank ([mail 1.0 point]))
726 (followup ([article 0.5]
728 (followup-yank ([post 1.0 point])))
729 "Window configuration for all possible Gnus buffers.
730 This variable is a list of lists. Each of these lists has a NAME and
731 a RULE. The NAMEs are commonsense names like `group', which names a
732 rule used when displaying the group buffer; `summary', which names a
733 rule for what happens when you enter a group and do not display an
734 article buffer; and so on. See the value of this variable for a
735 complete list of NAMEs.
737 Each RULE is a list of vectors. The first element in this vector is
738 the name of the buffer to be displayed; the second element is the
739 percentage of the screen this buffer is to occupy (a number in the
740 0.0-0.99 range); the optional third element is `point', which should
741 be present to denote which buffer point is to go to after making this
742 buffer configuration.")
744 (defvar gnus-window-to-buffer
745 '((group . gnus-group-buffer)
746 (summary . gnus-summary-buffer)
747 (article . gnus-article-buffer)
748 (server . gnus-server-buffer)
749 (browse . "*Gnus Browse Server*")
750 (edit-group . gnus-group-edit-buffer)
751 (edit-server . gnus-server-edit-buffer)
752 (group-carpal . gnus-carpal-group-buffer)
753 (summary-carpal . gnus-carpal-summary-buffer)
754 (server-carpal . gnus-carpal-server-buffer)
755 (browse-carpal . gnus-carpal-browse-buffer)
756 (edit-score . gnus-score-edit-buffer)
757 (mail . gnus-mail-buffer)
758 (post . gnus-post-news-buffer)
759 (faq . gnus-faq-buffer))
760 "Mapping from short symbols to buffer names or buffer variables.")
762 (defvar gnus-carpal nil
763 "*If non-nil, display clickable icons.")
765 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
766 "*Function called with a group name when new group is detected.
767 A few pre-made functions are supplied: `gnus-subscribe-randomly'
768 inserts new groups at the beginning of the list of groups;
769 `gnus-subscribe-alphabetically' inserts new groups in strict
770 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
771 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
774 ;; Suggested by a bug report by Hallvard B Furuseth.
775 ;; <h.b.furuseth@usit.uio.no>.
776 (defvar gnus-subscribe-options-newsgroup-method
777 (function gnus-subscribe-alphabetically)
778 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
779 If, for instance, you want to subscribe to all newsgroups in the
780 \"no\" and \"alt\" hierarchies, you'd put the following in your
783 options -n no.all alt.all
785 Gnus will the subscribe all new newsgroups in these hierarchies with
786 the subscription method in this variable.")
788 (defvar gnus-subscribe-hierarchical-interactive nil
789 "*If non-nil, Gnus will offer to subscribe hierarchically.
790 When a new hierarchy appears, Gnus will ask the user:
792 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
794 If the user pressed `d', Gnus will descend the hierarchy, `y' will
795 subscribe to all newsgroups in the hierarchy and `s' will skip this
796 hierarchy in its entirety.")
798 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
799 "*Function used for sorting the group buffer.
800 This function will be called with group info entries as the arguments
801 for the groups to be sorted. Pre-made functions include
802 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread' and
803 `gnus-group-sort-by-level'")
805 ;; Mark variables suggested by Thomas Michanek
806 ;; <Thomas.Michanek@telelogic.se>.
807 (defvar gnus-unread-mark ?
808 "*Mark used for unread articles.")
809 (defvar gnus-ticked-mark ?!
810 "*Mark used for ticked articles.")
811 (defvar gnus-dormant-mark ??
812 "*Mark used for dormant articles.")
813 (defvar gnus-del-mark ?r
814 "*Mark used for del'd articles.")
815 (defvar gnus-read-mark ?R
816 "*Mark used for read articles.")
817 (defvar gnus-expirable-mark ?E
818 "*Mark used for expirable articles.")
819 (defvar gnus-killed-mark ?K
820 "*Mark used for killed articles.")
821 (defvar gnus-kill-file-mark ?X
822 "*Mark used for articles killed by kill files.")
823 (defvar gnus-low-score-mark ?Y
824 "*Mark used for articles with a low score.")
825 (defvar gnus-catchup-mark ?C
826 "*Mark used for articles that are caught up.")
827 (defvar gnus-replied-mark ?A
828 "*Mark used for articles that have been replied to.")
829 (defvar gnus-process-mark ?#
831 (defvar gnus-ancient-mark ?O
832 "*Mark used for ancient articles.")
833 (defvar gnus-canceled-mark ?G
834 "*Mark used for canceled articles.")
835 (defvar gnus-score-over-mark ?+
836 "*Score mark used for articles with high scores.")
837 (defvar gnus-score-below-mark ?-
838 "*Score mark used for articles with low scores.")
839 (defvar gnus-empty-thread-mark ?
840 "*There is no thread under the article.")
841 (defvar gnus-not-empty-thread-mark ?=
842 "*There is a thread under the article.")
843 (defvar gnus-dummy-mark ?Z
844 "*This is a dummy article.")
846 (defvar gnus-view-pseudo-asynchronously nil
847 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
849 (defvar gnus-view-pseudos nil
850 "*If `automatic', pseudo-articles will be viewed automatically.
851 If `not-confirm', pseudos will be viewed automatically, and the user
852 will not be asked to confirm the command.")
854 (defvar gnus-view-pseudos-separately t
855 "*If non-nil, one pseudo-article will be created for each file to be viewed.
856 If nil, all files that use the same viewing command will be given as a
857 list of parameters to that command.")
859 (defvar gnus-group-line-format "%M%S%p%5y: %(%g%)\n"
860 "*Format of group lines.
861 It works along the same lines as a normal formatting string,
862 with some simple extensions.
864 %M Only marked articles (character, \"*\" or \" \")
865 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
866 %L Level of subscribedness (integer)
867 %N Number of unread articles (integer)
868 %I Number of dormant articles (integer)
869 %i Number of ticked and dormant (integer)
870 %T Number of ticked articles (integer)
871 %R Number of read articles (integer)
872 %t Total number of articles (integer)
873 %y Number of unread, unticked articles (integer)
874 %G Group name (string)
875 %g Qualified group name (string)
876 %D Group description (string)
877 %s Select method (string)
878 %o Moderated group (char, \"m\")
879 %p Process mark (char)
880 %O Moderated group (string, \"(m)\" or \"\")
881 %n Select from where (string)
882 %z A string that look like `<%s:%n>' if a foreign select method is used
883 %u User defined specifier. The next character in the format string should
884 be a letter. Gnus will call the function gnus-user-format-function-X,
885 where X is the letter following %u. The function will be passed the
886 current header as argument. The function should return a string, which
887 will be inserted into the buffer just like information from any other
890 Text between %( and %) will be highlighted with `gnus-mouse-face' when
891 the mouse point move inside the area. There can only be one such area.
893 Note that this format specification is not always respected. For
894 reasons of efficiency, when listing killed groups, this specification
895 is ignored altogether. If the spec is changed considerably, your
896 output may end up looking strange when listing both alive and killed
899 If you use %o or %O, reading the active file will be slower and quite
900 a bit of extra memory will be used. %D will also worsen performance.
901 Also note that if you change the format specification to include any
902 of these specs, you must probably re-start Gnus to see them go into
905 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
906 "*The format specification of the lines in the summary buffer.
908 It works along the same lines as a normal formatting string,
909 with some simple extensions.
911 %N Article number, left padded with spaces (string)
913 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
914 %n Name of the poster (string)
915 %a Extracted name of the poster (string)
916 %A Extracted address of the poster (string)
917 %F Contents of the From: header (string)
918 %x Contents of the Xref: header (string)
919 %D Date of the article (string)
920 %d Date of the article (string) in DD-MMM format
921 %M Message-id of the article (string)
922 %r References of the article (string)
923 %c Number of characters in the article (integer)
924 %L Number of lines in the article (integer)
925 %I Indentation based on thread level (a string of spaces)
926 %T A string with two possible values: 80 spaces if the article
927 is on thread level two or larger and 0 spaces on level one
928 %R \"R\" if this article has been replied to, \" \" otherwise (character)
929 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
930 %[ Opening bracket (character, \"[\" or \"<\")
931 %] Closing bracket (character, \"]\" or \">\")
932 %> Spaces of length thread-level (string)
933 %< Spaces of length (- 20 thread-level) (string)
934 %i Article score (number)
935 %z Article zcore (character)
936 %t Number of articles under the current thread (number).
937 %e Whether the thread is empty or not (character).
938 %u User defined specifier. The next character in the format string should
939 be a letter. Gnus will call the function gnus-user-format-function-X,
940 where X is the letter following %u. The function will be passed the
941 current header as argument. The function should return a string, which
942 will be inserted into the summary just like information from any other
945 Text between %( and %) will be highlighted with `gnus-mouse-face'
946 when the mouse point is placed inside the area. There can only be one
949 The %U (status), %R (replied) and %z (zcore) specs have to be handled
950 with care. For reasons of efficiency, Gnus will compute what column
951 these characters will end up in, and \"hard-code\" that. This means that
952 it is illegal to have these specs after a variable-length spec. Well,
953 you might not be arrested, but your summary buffer will look strange,
956 The smart choice is to have these specs as for to the left as
959 This restriction may disappear in later versions of Gnus.")
961 (defvar gnus-summary-dummy-line-format "* : : %S\n"
962 "*The format specification for the dummy roots in the summary buffer.
963 It works along the same lines as a normal formatting string,
964 with some simple extensions.
968 (defvar gnus-summary-mode-line-format "Gnus %G/%A %Z"
969 "*The format specification for the summary mode line.")
971 (defvar gnus-article-mode-line-format "Gnus %G/%A %S"
972 "*The format specification for the article mode line.")
974 (defvar gnus-group-mode-line-format "Gnus List of groups {%M:%S} "
975 "*The format specification for the group mode line.")
977 (defvar gnus-valid-select-methods
978 '(("nntp" post address prompt-address)
980 ("nnvirtual" none virtual prompt-address)
981 ("nnmbox" mail respool)
982 ("nnml" mail respool)
983 ("nnmh" mail respool)
984 ("nndir" none prompt-address address)
985 ("nneething" none prompt-address)
987 ("nndoc" none prompt-address)
988 ("nnbabyl" mail respool)
989 ("nnkiboze" post virtual)
991 ("nnfolder" mail respool))
992 "An alist of valid select methods.
993 The first element of each list lists should be a string with the name
994 of the select method. The other elements may be be the category of
995 this method (ie. `post', `mail', `none' or whatever) or other
996 properties that this method has (like being respoolable).
997 If you implement a new select method, all you should have to change is
998 this variable. I think.")
1000 (defvar gnus-updated-mode-lines '(group article summary)
1001 "*List of buffers that should update their mode lines.
1002 The list may contain the symbols `group', `article' and `summary'. If
1003 the corresponding symbol is present, Gnus will keep that mode line
1004 updated with information that may be pertinent.
1005 If this variable is nil, screen refresh may be quicker.")
1007 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1008 (defvar gnus-mode-non-string-length 21
1009 "*Max length of mode-line non-string contents.
1010 If this is nil, Gnus will take space as is needed, leaving the rest
1011 of the modeline intact.")
1014 ;(defvar gnus-mouse-face 'highlight
1015 ; "*Face used for mouse highlighting in Gnus.
1016 ;No mouse highlights will be done if `gnus-visual' is nil.")
1018 (defvar gnus-summary-mark-below nil
1019 "*Mark all articles with a score below this variable as read.
1020 This variable is local to each summary buffer and usually set by the
1023 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1024 "*List of functions used for sorting threads in the summary buffer.
1025 By default, threads are sorted by article number.
1027 Each function takes two threads and return non-nil if the first thread
1028 should be sorted before the other. If you use more than one function,
1029 the primary sort function should be the last.
1031 Ready-mady functions include `gnus-thread-sort-by-number',
1032 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1033 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1034 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1036 (defvar gnus-thread-score-function '+
1037 "*Function used for calculating the total score of a thread.
1039 The function is called with the scores of the article and each
1040 subthread and should then return the score of the thread.
1042 Some functions you can use are `+', `max', or `min'.")
1044 (defvar gnus-options-subscribe nil
1045 "*All new groups matching this regexp will be subscribed unconditionally.
1046 Note that this variable deals only with new newsgroups. This variable
1047 does not affect old newsgroups.")
1049 (defvar gnus-options-not-subscribe nil
1050 "*All new groups matching this regexp will be ignored.
1051 Note that this variable deals only with new newsgroups. This variable
1052 does not affect old (already subscribed) newsgroups.")
1054 (defvar gnus-auto-expirable-newsgroups nil
1055 "*Groups in which to automatically mark read articles as expirable.
1056 If non-nil, this should be a regexp that should match all groups in
1057 which to perform auto-expiry. This only makes sense for mail groups.")
1059 (defvar gnus-hidden-properties '(invisible t intangible t)
1060 "Property list to use for hiding text.")
1062 (defvar gnus-modtime-botch nil
1063 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1064 due to the bogus appearance that .newsrc was modified on disc.")
1068 (defvar gnus-group-mode-hook nil
1069 "*A hook for Gnus group mode.")
1071 (defvar gnus-summary-mode-hook nil
1072 "*A hook for Gnus summary mode.
1073 This hook is run before any variables are set in the summary buffer.")
1075 (defvar gnus-article-mode-hook nil
1076 "*A hook for Gnus article mode.")
1078 (defun gnus-summary-prepare-exit-hook nil
1079 "*A hook called when preparing to exit from the summary buffer.
1080 It calls `gnus-summary-expire-articles' by default.")
1081 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1083 (defun gnus-summary-exit-hook nil
1084 "*A hook called on exit from the summary buffer.")
1086 (defvar gnus-open-server-hook nil
1087 "*A hook called just before opening connection to the news server.")
1089 (defvar gnus-startup-hook nil
1090 "*A hook called at startup.
1091 This hook is called after Gnus is connected to the NNTP server.")
1093 (defvar gnus-get-new-news-hook nil
1094 "*A hook run just before Gnus checks for new news.")
1096 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1097 "*A function that is called to generate the group buffer.
1098 The function is called with three arguments: The first is a number;
1099 all group with a level less or equal to that number should be listed,
1100 if the second is non-nil, empty groups should also be displayed. If
1101 the third is non-nil, it is a number. No groups with a level lower
1102 than this number should be displayed.
1104 The only current function implemented is `gnus-group-prepare-flat'.")
1106 (defvar gnus-group-prepare-hook nil
1107 "*A hook called after the group buffer has been generated.
1108 If you want to modify the group buffer, you can use this hook.")
1110 (defvar gnus-summary-prepare-hook nil
1111 "*A hook called after the summary buffer has been generated.
1112 If you want to modify the summary buffer, you can use this hook.")
1114 (defvar gnus-article-prepare-hook nil
1115 "*A hook called after an article has been prepared in the article buffer.
1116 If you want to run a special decoding program like nkf, use this hook.")
1118 ;(defvar gnus-article-display-hook nil
1119 ; "*A hook called after the article is displayed in the article buffer.
1120 ;The hook is designed to change the contents of the article
1121 ;buffer. Typical functions that this hook may contain are
1122 ;`gnus-article-hide-headers' (hide selected headers),
1123 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1124 ;`gnus-article-hide-signature' (hide signature) and
1125 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1126 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1127 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1128 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1130 (defvar gnus-article-x-face-command
1131 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1132 "String or function to be executed to display an X-Face header.
1133 If it is a string, the command will be executed in a sub-shell
1134 asynchronously. The compressed face will be piped to this command.")
1136 (defvar gnus-article-x-face-too-ugly nil
1137 "Regexp matching posters whose face shouldn't be shown automatically.")
1139 (defvar gnus-select-group-hook nil
1140 "*A hook called when a newsgroup is selected.
1142 If you'd like to simplify subjects like the
1143 `gnus-summary-next-same-subject' command does, you can use the
1146 (setq gnus-select-group-hook
1149 (mapcar (lambda (header)
1150 (mail-header-set-subject
1152 (gnus-simplify-subject
1153 (mail-header-subject header) 're-only)))
1154 gnus-newsgroup-headers))))")
1156 (defvar gnus-select-article-hook
1157 '(gnus-summary-show-thread)
1158 "*A hook called when an article is selected.
1159 The default hook shows conversation thread subtrees of the selected
1160 article automatically using `gnus-summary-show-thread'.")
1162 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1163 "*A hook called to apply kill files to a group.
1164 This hook is intended to apply a kill file to the selected newsgroup.
1165 The function `gnus-apply-kill-file' is called by default.
1167 Since a general kill file is too heavy to use only for a few
1168 newsgroups, I recommend you to use a lighter hook function. For
1169 example, if you'd like to apply a kill file to articles which contains
1170 a string `rmgroup' in subject in newsgroup `control', you can use the
1173 (setq gnus-apply-kill-hook
1176 (cond ((string-match \"control\" gnus-newsgroup-name)
1177 (gnus-kill \"Subject\" \"rmgroup\")
1178 (gnus-expunge \"X\"))))))")
1180 (defvar gnus-visual-mark-article-hook
1181 (list 'gnus-highlight-selected-summary)
1182 "*Hook run after selecting an article in the summary buffer.
1183 It is meant to be used for highlighting the article in some way. It
1184 is not run if `gnus-visual' is nil.")
1186 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1187 "*A hook called after preparing body, but before preparing header headers.
1188 The default hook (`gnus-inews-insert-signature') inserts a signature
1189 file specified by the variable `gnus-signature-file'.")
1191 (defvar gnus-exit-group-hook nil
1192 "*A hook called when exiting (not quitting) summary mode.")
1194 (defvar gnus-suspend-gnus-hook nil
1195 "*A hook called when suspending (not exiting) Gnus.")
1197 (defvar gnus-exit-gnus-hook nil
1198 "*A hook called when exiting Gnus.")
1200 (defvar gnus-save-newsrc-hook nil
1201 "*A hook called when saving the newsrc file.")
1203 (defvar gnus-summary-update-hook
1204 (list 'gnus-summary-highlight-line)
1205 "*A hook called when a summary line is changed.
1206 The hook will not be called if `gnus-visual' is nil.
1208 The default function `gnus-summary-highlight-line' will
1209 highlight the line according to the `gnus-summary-highlight'
1212 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1213 "*A hook called when an article is selected for the first time.
1214 The hook is intended to mark an article as read (or unread)
1215 automatically when it is selected.")
1217 ;; Remove any hilit infestation.
1218 (add-hook 'gnus-startup-hook
1220 (remove-hook 'gnus-summary-prepare-hook
1221 'hilit-rehighlight-buffer-quietly)
1222 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1223 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1224 (remove-hook 'gnus-article-prepare-hook
1225 'hilit-rehighlight-buffer-quietly)))
1229 ;; Internal variables
1231 ;; Avoid highlighting in kill files.
1232 (defvar gnus-summary-inhibit-highlight nil)
1233 (defvar gnus-newsgroup-selected-overlay nil)
1235 (defvar gnus-article-mode-map nil)
1236 (defvar gnus-dribble-buffer nil)
1237 (defvar gnus-headers-retrieved-by nil)
1238 (defvar gnus-article-reply nil)
1239 (defvar gnus-override-method nil)
1240 (defvar gnus-article-check-size nil)
1242 (defvar gnus-current-score-file nil)
1243 (defvar gnus-internal-global-score-files nil)
1244 (defvar gnus-score-file-list nil)
1247 (defvar gnus-current-move-group nil)
1249 (defvar gnus-newsgroup-dependencies nil)
1250 (defvar gnus-newsgroup-threads nil)
1251 (defvar gnus-newsgroup-async nil)
1252 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1254 (defvar gnus-newsgroup-adaptive nil)
1256 (defvar gnus-summary-display-table nil)
1258 (defconst gnus-group-line-format-alist
1259 (list (list ?M 'marked ?c)
1260 (list ?S 'subscribed ?c)
1262 (list ?N 'number ?s)
1263 (list ?I 'number-of-dormant ?d)
1264 (list ?T 'number-of-ticked ?d)
1265 (list ?R 'number-of-read ?s)
1266 (list ?t 'number-total ?d)
1267 (list ?y 'number-of-unread-unticked ?s)
1268 (list ?i 'number-of-ticked-and-dormant ?d)
1270 (list ?G 'qualified-group ?s)
1271 (list ?D 'newsgroup-description ?s)
1272 (list ?o 'moderated ?c)
1273 (list ?O 'moderated-string ?s)
1274 (list ?p 'process-marked ?c)
1275 (list ?s 'news-server ?s)
1276 (list ?n 'news-method ?s)
1277 (list ?z 'news-method-string ?s)
1278 (list ?u 'user-defined ?s)))
1280 (defconst gnus-summary-line-format-alist
1281 (list (list ?N 'number ?d)
1282 (list ?S 'subject ?s)
1283 (list ?s 'subject-or-nil ?s)
1285 (list ?A '(car (cdr (funcall gnus-extract-address-components from)))
1287 (list ?a '(or (car (funcall gnus-extract-address-components from))
1290 (list ?x (macroexpand '(mail-header-xref header)) ?s)
1291 (list ?D (macroexpand '(mail-header-date header)) ?s)
1292 (list ?d '(gnus-dd-mmm (mail-header-date header)) ?s)
1293 (list ?M (macroexpand '(mail-header-id header)) ?s)
1294 (list ?r (macroexpand '(mail-header-references header)) ?s)
1295 (list ?c '(or (mail-header-chars header) 0) ?d)
1297 (list ?I 'indentation ?s)
1298 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1299 (list ?R 'replied ?c)
1300 (list ?\[ 'opening-bracket ?c)
1301 (list ?\] 'closing-bracket ?c)
1302 (list ?\> '(make-string level ? ) ?s)
1303 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1305 (list ?z 'score-char ?c)
1306 (list ?U 'unread ?c)
1307 (list ?t '(gnus-summary-number-of-articles-in-thread
1308 (and (boundp 'thread) (car thread)))
1310 (list ?e '(gnus-summary-number-of-articles-in-thread
1311 (and (boundp 'thread) (car thread)) t)
1313 (list ?u 'user-defined ?s))
1314 "An alist of format specifications that can appear in summary lines,
1315 and what variables they correspond with, along with the type of the
1316 variable (string, integer, character, etc).")
1318 (defconst gnus-summary-dummy-line-format-alist
1319 (list (list ?S 'subject ?s)
1320 (list ?N 'number ?d)
1321 (list ?u 'user-defined ?s)))
1323 (defconst gnus-summary-mode-line-format-alist
1324 (list (list ?G 'group-name ?s)
1325 (list ?g '(gnus-short-group-name group-name) ?s)
1326 (list ?A 'article-number ?d)
1327 (list ?Z 'unread-and-unselected ?s)
1328 (list ?V 'gnus-version ?s)
1329 (list ?U 'unread ?d)
1330 (list ?S 'subject ?s)
1331 (list ?e 'unselected ?d)
1332 (list ?u 'user-defined ?s)
1333 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1335 (defconst gnus-group-mode-line-format-alist
1336 (list (list ?S 'news-server ?s)
1337 (list ?M 'news-method ?s)
1338 (list ?u 'user-defined ?s)))
1340 (defvar gnus-have-read-active-file nil)
1342 (defconst gnus-maintainer
1343 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1344 "The mail address of the Gnus maintainers.")
1346 (defconst gnus-version "(ding) Gnus v0.99.28"
1347 "Version number for this version of Gnus.")
1349 (defvar gnus-info-nodes
1350 '((gnus-group-mode "(gnus)The Group Buffer")
1351 (gnus-summary-mode "(gnus)The Summary Buffer")
1352 (gnus-article-mode "(gnus)The Article Buffer"))
1353 "Assoc list of major modes and related Info nodes.")
1355 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1356 "The location of the Gnus documentation group.")
1358 (defvar gnus-group-buffer "*Group*")
1359 (defvar gnus-summary-buffer "*Summary*")
1360 (defvar gnus-article-buffer "*Article*")
1361 (defvar gnus-server-buffer "*Server*")
1363 (defvar gnus-work-buffer " *gnus work*")
1365 (defvar gnus-buffer-list nil
1366 "Gnus buffers that should be killed on exit.")
1368 (defvar gnus-server-alist nil
1369 "List of available servers.")
1371 (defvar gnus-variable-list
1372 '(gnus-newsrc-options gnus-newsrc-options-n
1373 gnus-newsrc-last-checked-date
1374 gnus-newsrc-alist gnus-server-alist
1375 gnus-killed-list gnus-zombie-list)
1376 "Gnus variables saved in the quick startup file.")
1378 (defvar gnus-overload-functions
1379 '((news-inews gnus-inews-news "rnewspost"))
1380 "Functions overloaded by gnus.
1381 It is a list of `(original overload &optional file)'.")
1383 (defvar gnus-newsrc-options nil
1384 "Options line in the .newsrc file.")
1386 (defvar gnus-newsrc-options-n nil
1387 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1389 (defvar gnus-newsrc-last-checked-date nil
1390 "Date Gnus last asked server for new newsgroups.")
1392 (defvar gnus-newsrc-alist nil
1393 "Assoc list of read articles.
1394 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1396 (defvar gnus-newsrc-hashtb nil
1397 "Hashtable of gnus-newsrc-alist.")
1399 (defvar gnus-killed-list nil
1400 "List of killed newsgroups.")
1402 (defvar gnus-killed-hashtb nil
1403 "Hash table equivalent of gnus-killed-list.")
1405 (defvar gnus-zombie-list nil
1406 "List of almost dead newsgroups.")
1408 (defvar gnus-description-hashtb nil
1409 "Descriptions of newsgroups.")
1411 (defvar gnus-list-of-killed-groups nil
1412 "List of newsgroups that have recently been killed by the user.")
1414 (defvar gnus-active-hashtb nil
1415 "Hashtable of active articles.")
1417 (defvar gnus-moderated-list nil
1418 "List of moderated newsgroups.")
1420 (defvar gnus-group-marked nil)
1422 (defvar gnus-current-startup-file nil
1423 "Startup file for the current host.")
1425 (defvar gnus-last-search-regexp nil
1426 "Default regexp for article search command.")
1428 (defvar gnus-last-shell-command nil
1429 "Default shell command on article.")
1431 (defvar gnus-current-select-method nil
1432 "The current method for selecting a newsgroup.")
1434 (defvar gnus-group-list-mode nil)
1436 (defvar gnus-article-internal-prepare-hook nil)
1438 (defvar gnus-newsgroup-name nil)
1439 (defvar gnus-newsgroup-begin nil)
1440 (defvar gnus-newsgroup-end nil)
1441 (defvar gnus-newsgroup-last-rmail nil)
1442 (defvar gnus-newsgroup-last-mail nil)
1443 (defvar gnus-newsgroup-last-folder nil)
1444 (defvar gnus-newsgroup-last-file nil)
1445 (defvar gnus-newsgroup-auto-expire nil)
1446 (defvar gnus-newsgroup-active nil)
1448 (defvar gnus-newsgroup-unreads nil
1449 "List of unread articles in the current newsgroup.")
1451 (defvar gnus-newsgroup-unselected nil
1452 "List of unselected unread articles in the current newsgroup.")
1454 (defvar gnus-newsgroup-reads nil
1455 "Alist of read articles and article marks in the current newsgroup.")
1457 (defvar gnus-newsgroup-marked nil
1458 "List of ticked articles in the current newsgroup (a subset of unread art).")
1460 (defvar gnus-newsgroup-killed nil
1461 "List of ranges of articles that have been through the scoring process.")
1463 (defvar gnus-newsgroup-kill-headers nil)
1465 (defvar gnus-newsgroup-replied nil
1466 "List of articles that have been replied to in the current newsgroup.")
1468 (defvar gnus-newsgroup-expirable nil
1469 "List of articles in the current newsgroup that can be expired.")
1471 (defvar gnus-newsgroup-processable nil
1472 "List of articles in the current newsgroup that can be processed.")
1474 (defvar gnus-newsgroup-bookmarks nil
1475 "List of articles in the current newsgroup that have bookmarks.")
1477 (defvar gnus-newsgroup-dormant nil
1478 "List of dormant articles in the current newsgroup.")
1480 (defvar gnus-newsgroup-scored nil
1481 "List of scored articles in the current newsgroup.")
1483 (defvar gnus-newsgroup-headers nil
1484 "List of article headers in the current newsgroup.")
1485 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1487 (defvar gnus-newsgroup-ancient nil
1488 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1490 (defvar gnus-current-article nil)
1491 (defvar gnus-article-current nil)
1492 (defvar gnus-current-headers nil)
1493 (defvar gnus-have-all-headers nil)
1494 (defvar gnus-last-article nil)
1495 (defvar gnus-newsgroup-history nil)
1496 (defvar gnus-current-kill-article nil)
1498 ;; Save window configuration.
1499 (defvar gnus-prev-winconf nil)
1502 (defvar gnus-summary-line-format-spec nil)
1503 (defvar gnus-summary-dummy-line-format-spec nil)
1504 (defvar gnus-group-line-format-spec nil)
1505 (defvar gnus-summary-mode-line-format-spec nil)
1506 (defvar gnus-article-mode-line-format-spec nil)
1507 (defvar gnus-group-mode-line-format-spec nil)
1508 (defvar gnus-summary-mark-positions nil)
1509 (defvar gnus-group-mark-positions nil)
1511 (defvar gnus-summary-expunge-below nil)
1512 (defvar gnus-reffed-article-number nil)
1514 ; Let the byte-compiler know that we know about this variable.
1515 (defvar rmail-default-rmail-file)
1517 (defvar gnus-cache-removeable-articles nil)
1519 (defconst gnus-summary-local-variables
1520 '(gnus-newsgroup-name
1521 gnus-newsgroup-begin gnus-newsgroup-end
1522 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1523 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1524 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1525 gnus-newsgroup-unselected gnus-newsgroup-marked
1526 gnus-newsgroup-reads
1527 gnus-newsgroup-replied gnus-newsgroup-expirable
1528 gnus-newsgroup-processable gnus-newsgroup-killed
1529 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1530 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1531 gnus-current-article gnus-current-headers gnus-have-all-headers
1532 gnus-last-article gnus-article-internal-prepare-hook
1533 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1534 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1535 gnus-newsgroup-threads gnus-newsgroup-async
1536 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1537 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1538 gnus-newsgroup-history gnus-newsgroup-ancient
1539 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1540 gnus-cache-removeable-articles)
1541 "Variables that are buffer-local to the summary buffers.")
1543 (defconst gnus-bug-message
1544 "Sending a bug report to the Gnus Towers.
1545 ========================================
1547 The buffer below is a mail buffer. When you press `C-c C-c', it will
1548 be sent to the Gnus Bug Exterminators.
1550 At the bottom of the buffer you'll see lots of variable settings.
1551 Please do not delete those. They will tell the Bug People what your
1552 environment is, so that it will be easier to locate the bugs.
1554 If you have found a bug that makes Emacs go \"beep\", set
1555 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1556 and include the backtrace in your bug report.
1558 Please describe the bug in annoying, painstaking detail.
1560 Thank you for your help in stamping out bugs.
1563 ;;; End of variables.
1565 ;; Define some autoload functions Gnus might use.
1569 (autoload 'metamail-buffer "metamail")
1570 (autoload 'Info-goto-node "info")
1571 (autoload 'hexl-hex-string-to-integer "hexl")
1573 (autoload 'pp-to-string "pp")
1574 (autoload 'pp-eval-expression "pp")
1575 (autoload 'mail-extract-address-components "mail-extr")
1577 (autoload 'nnmail-split-fancy "nnmail")
1578 (autoload 'nnvirtual-catchup-group "nnvirtual")
1581 (autoload 'timezone-make-date-arpa-standard "timezone")
1582 (autoload 'timezone-fix-time "timezone")
1583 (autoload 'timezone-make-sortable-date "timezone")
1584 (autoload 'timezone-make-time-string "timezone")
1587 (autoload 'mail-position-on-field "sendmail")
1588 (autoload 'mail-setup "sendmail")
1589 (autoload 'rmail-output "rmailout")
1590 (autoload 'news-mail-other-window "rnewspost")
1591 (autoload 'news-reply-yank-original "rnewspost")
1592 (autoload 'news-caesar-buffer-body "rnewspost")
1593 (autoload 'rmail-insert-rmail-file-header "rmail")
1594 (autoload 'rmail-count-new-messages "rmail")
1595 (autoload 'rmail-show-message "rmail")
1598 ;;(autoload 'gnus-group-brew-soup "gnus-soup" nil t)
1599 ;;(autoload 'gnus-brew-soup "gnus-soup" nil t)
1600 ;;(autoload 'gnus-soup-add-article "gnus-soup" nil t)
1601 ;;(autoload 'gnus-soup-send-replies "gnus-soup" nil t)
1602 ;;(autoload 'gnus-soup-save-areas "gnus-soup" nil t)
1603 ;;(autoload 'gnus-soup-pack-packet "gnus-soup" nil t)
1604 ;;(autoload 'nnsoup-pack-replies "nnsoup" nil t)
1607 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1608 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1609 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1610 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1611 (autoload 'gnus-summary-save-article-folder "gnus-mh")
1612 (autoload 'gnus-Folder-save-name "gnus-mh")
1613 (autoload 'gnus-folder-save-name "gnus-mh")
1616 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1617 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1618 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1619 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1620 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1621 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1622 (autoload 'gnus-summary-highlight-line "gnus-vis")
1623 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1626 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1627 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1628 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1629 (autoload 'gnus-article-highlight-some "gnus-vis" nil t)
1630 (autoload 'gnus-article-hide "gnus-vis" nil t)
1631 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1632 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1633 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1634 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1635 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1636 (autoload 'gnus-article-add-button "gnus-vis")
1639 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1640 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1641 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1644 (autoload 'gnus-kill "gnus-kill")
1645 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1646 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1647 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1648 (autoload 'gnus-execute "gnus-kill")
1649 (autoload 'gnus-expunge "gnus-kill")
1652 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1653 (autoload 'gnus-cache-save-buffers "gnus-cache")
1654 (autoload 'gnus-cache-possibly-remove-articles "gnus-cache")
1655 (autoload 'gnus-cache-request-article "gnus-cache")
1656 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1657 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1658 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1659 (autoload 'gnus-cache-enter-remove-article "gnus-cache")
1662 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1663 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1664 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1665 (autoload 'gnus-score-save "gnus-score")
1666 (autoload 'gnus-score-headers "gnus-score")
1667 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1668 (autoload 'gnus-score-adaptive "gnus-score")
1669 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1670 (autoload 'gnus-score-find-trace "gnus-score")
1673 (autoload 'gnus-score-customize "gnus-edit" nil t)
1676 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1677 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1678 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1679 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1680 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1681 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1682 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1683 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1684 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1685 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1686 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1687 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1688 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1689 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1690 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1691 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1692 (autoload 'gnus-uu-decode-uu-view "gnus-uu" nil t)
1693 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu" nil t)
1694 (autoload 'gnus-uu-decode-unshar-view "gnus-uu" nil t)
1695 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu" nil t)
1696 (autoload 'gnus-uu-decode-save-view "gnus-uu" nil t)
1697 (autoload 'gnus-uu-decode-binhex-view "gnus-uu" nil t)
1700 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1701 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1702 (autoload 'gnus-group-mail "gnus-msg" nil t)
1703 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1704 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1705 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1706 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1707 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1708 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1709 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1710 (autoload 'gnus-post-news "gnus-msg" nil t)
1711 (autoload 'gnus-inews-news "gnus-msg" nil t)
1712 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1713 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1714 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1715 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1716 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1717 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1718 (autoload 'gnus-mail-yank-original "gnus-msg")
1719 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1720 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1721 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1722 (autoload 'gnus-article-mail-with-original "gnus-msg")
1723 (autoload 'gnus-article-mail "gnus-msg")
1724 (autoload 'gnus-bug "gnus-msg" nil t)
1727 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1728 (autoload 'gnus-summary-save-article-vm "gnus-vm" nil t)
1729 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1730 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1731 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1732 (autoload 'gnus-yank-article "gnus-vm" nil t)
1738 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1739 ;; If you want the cursor to go somewhere else, set these two
1740 ;; functions in some startup hook to whatever you want.
1741 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1742 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1744 ;;; Various macros and substs.
1746 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1747 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1748 (` (let ((GnusStartBufferWindow (selected-window)))
1751 (pop-to-buffer (, buffer))
1753 (select-window GnusStartBufferWindow)))))
1755 (defmacro gnus-gethash (string hashtable)
1756 "Get hash value of STRING in HASHTABLE."
1757 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1758 ;;(` (abbrev-expansion (, string) (, hashtable)))
1759 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1761 (defmacro gnus-sethash (string value hashtable)
1762 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1763 ;; We cannot use define-abbrev since it only accepts string as value.
1764 ;; (set (intern string hashtable) value))
1765 (` (set (intern (, string) (, hashtable)) (, value))))
1767 (defsubst gnus-buffer-substring (beg end)
1768 (buffer-substring (match-beginning beg) (match-end end)))
1770 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1771 ;; function `substring' might cut on a middle of multi-octet
1773 (defun gnus-truncate-string (str width)
1774 (substring str 0 width))
1776 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
1777 ;; to limit the length of a string. This function is necessary since
1778 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
1779 (defsubst gnus-limit-string (str width)
1780 (if (> (length str) width)
1781 (substring str 0 width)
1784 (defsubst gnus-simplify-subject-re (subject)
1785 "Remove \"Re:\" from subject lines."
1786 (let ((case-fold-search t))
1787 (if (string-match "^re: *" subject)
1788 (substring subject (match-end 0))
1791 (defsubst gnus-goto-char (point)
1792 (and point (goto-char point)))
1794 (defmacro gnus-buffer-exists-p (buffer)
1796 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1799 (defmacro gnus-kill-buffer (buffer)
1800 (` (if (gnus-buffer-exists-p (, buffer))
1801 (kill-buffer (, buffer)))))
1803 (defsubst gnus-point-at-bol ()
1804 "Return point at the beginning of line."
1811 (defsubst gnus-point-at-eol ()
1812 "Return point at the beginning of line."
1819 ;; Delete the current line (and the next N lines.);
1820 (defmacro gnus-delete-line (&optional n)
1821 (` (delete-region (progn (beginning-of-line) (point))
1822 (progn (forward-line (, (or n 1))) (point)))))
1824 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1825 (defvar gnus-init-inhibit nil)
1826 (defun gnus-read-init-file (&optional inhibit-next)
1827 (if gnus-init-inhibit
1828 (setq gnus-init-inhibit nil)
1829 (setq gnus-init-inhibit inhibit-next)
1831 (or (and (file-exists-p gnus-init-file)
1832 ;; Don't try to load a directory.
1833 (not (file-directory-p gnus-init-file)))
1834 (file-exists-p (concat gnus-init-file ".el"))
1835 (file-exists-p (concat gnus-init-file ".elc")))
1836 (load gnus-init-file nil t))))
1838 ;;; Load the user startup file.
1839 (eval '(gnus-read-init-file 'inhibit))
1841 ;;; Load the compatability functions.
1848 ;;; Gnus Utility Functions
1851 (defun gnus-extract-address-components (from)
1853 ;; First find the address - the thing with the @ in it. This may
1854 ;; not be accurate in mail addresses, but does the trick most of
1855 ;; the time in news messages.
1856 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1857 (setq address (substring from (match-beginning 0) (match-end 0))))
1858 ;; Then we check whether the "name <address>" format is used.
1860 (string-match (concat "<" (regexp-quote address) ">") from)
1861 (and (setq name (substring from 0 (1- (match-beginning 0))))
1862 ;; Strip any quotes from the name.
1863 (string-match "\".*\"" name)
1864 (setq name (substring name 1 (1- (match-end 0))))))
1865 ;; If not, then "address (name)" is used.
1867 (and (string-match "(.+)" from)
1868 (setq name (substring from (1+ (match-beginning 0))
1869 (1- (match-end 0)))))
1870 (and (string-match "()" from)
1871 (setq name address))
1872 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
1873 ;; XOVER might not support folded From headers.
1874 (and (string-match "(.*" from)
1875 (setq name (substring from (1+ (match-beginning 0))
1877 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1878 (list (or name from) (or address from))))
1880 (defun gnus-fetch-field (field)
1881 "Return the value of the header FIELD of current article."
1884 (let ((case-fold-search t))
1885 (gnus-narrow-to-headers)
1886 (mail-fetch-field field)))))
1888 (defun gnus-goto-colon ()
1890 (search-forward ":" (gnus-point-at-eol) t))
1892 (defun gnus-narrow-to-headers ()
1896 (goto-char (point-min))
1897 (if (search-forward "\n\n" nil t)
1901 (defvar gnus-old-specs nil)
1903 (defun gnus-update-format-specifications ()
1904 (gnus-make-thread-indent-array)
1906 (let ((formats '(summary summary-dummy group
1907 summary-mode group-mode article-mode))
1908 old-format new-format)
1910 (setq new-format (symbol-value
1911 (intern (format "gnus-%s-line-format" (car formats)))))
1912 (or (and (setq old-format (cdr (assq (car formats) gnus-old-specs)))
1913 (equal old-format new-format))
1914 (set (intern (format "gnus-%s-line-format-spec" (car formats)))
1918 (intern (format "gnus-%s-line-format-alist"
1919 (if (eq (car formats) 'article-mode)
1920 'summary-mode (car formats))))))))
1921 (setq gnus-old-specs (cons (cons (car formats) new-format)
1922 (delq (car formats) gnus-old-specs)))
1923 (setq formats (cdr formats))))
1925 (gnus-update-group-mark-positions)
1926 (gnus-update-summary-mark-positions)
1928 (if (and (string-match "%D" gnus-group-line-format)
1929 (not gnus-description-hashtb)
1930 gnus-read-active-file)
1931 (gnus-read-all-descriptions-files)))
1933 (defun gnus-update-summary-mark-positions ()
1935 (let ((gnus-replied-mark 129)
1936 (gnus-score-below-mark 130)
1937 (gnus-score-over-mark 130)
1940 (gnus-set-work-buffer)
1941 (gnus-summary-insert-line
1942 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1943 (goto-char (point-min))
1944 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1946 (goto-char (point-min))
1947 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1948 (- (point) 2))) pos))
1949 (goto-char (point-min))
1950 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1951 (- (point) 2))) pos))
1952 (setq gnus-summary-mark-positions pos))))
1954 (defun gnus-update-group-mark-positions ()
1956 (let ((gnus-process-mark 128)
1957 (gnus-group-marked '("dummy.group")))
1958 (gnus-sethash "dummy.group" '(0 . 0) gnus-active-hashtb)
1959 (gnus-set-work-buffer)
1960 (gnus-group-insert-group-line nil "dummy.group" 0 nil 0 nil)
1961 (goto-char (point-min))
1962 (setq gnus-group-mark-positions
1963 (list (cons 'process (and (search-forward "\200" nil t)
1964 (- (point) 2))))))))
1966 (defun gnus-mouse-face-function (form)
1967 (` (let ((string (, form)))
1968 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1971 (defun gnus-max-width-function (el max-width)
1972 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
1973 (` (let* ((val (eval (, el)))
1974 (valstr (if (numberp val)
1975 (int-to-string val) val)))
1976 (if (> (length valstr) (, max-width))
1977 (substring valstr 0 (, max-width))
1980 (defun gnus-parse-format (format spec-alist)
1981 ;; This function parses the FORMAT string with the help of the
1982 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1983 ;; string. If the FORMAT string contains the specifiers %( and %)
1984 ;; the text between them will have the mouse-face text property.
1985 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1986 (if (and gnus-visual gnus-mouse-face)
1987 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1988 (button (substring format (match-beginning 2) (match-end 2)))
1989 (post (substring format (match-beginning 3) (match-end 3))))
1991 (gnus-parse-simple-format pre spec-alist)
1992 (gnus-mouse-face-function
1993 (gnus-parse-simple-format button spec-alist))
1994 (gnus-parse-simple-format post spec-alist)))
1995 (gnus-parse-simple-format
1996 (concat (substring format (match-beginning 1) (match-end 1))
1997 (substring format (match-beginning 2) (match-end 2))
1998 (substring format (match-beginning 3) (match-end 3)))
2000 (gnus-parse-simple-format format spec-alist)))
2002 (defun gnus-parse-simple-format (format spec-alist)
2003 ;; This function parses the FORMAT string with the help of the
2004 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2005 ;; string. The list will consist of the symbol `format', a format
2006 ;; specification string, and a list of forms depending on the
2009 spec flist fstring newspec elem beg)
2011 (gnus-set-work-buffer)
2013 (goto-char (point-min))
2014 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
2015 (setq spec (string-to-char (buffer-substring (match-beginning 2)
2017 ;; First check if there are any specs that look anything like
2018 ;; "%12,12A", ie. with a "max width specification". These have
2019 ;; to be treated specially.
2020 (if (setq beg (match-beginning 1))
2023 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
2025 (setq beg (match-beginning 2)))
2026 ;; Find the specification from `spec-alist'.
2027 (if (not (setq elem (cdr (assq spec spec-alist))))
2028 (setq elem '("*" ?s)))
2029 ;; Treat user defined format specifiers specially
2030 (and (eq (car elem) 'user-defined)
2033 (list (intern (concat "gnus-user-format-function-"
2039 (delete-region (match-beginning 3) (match-end 3)))
2040 (if (not (zerop max-width))
2041 (let ((el (car elem)))
2042 (cond ((= (car (cdr elem)) ?c)
2043 (setq el (list 'char-to-string el)))
2044 ((= (car (cdr elem)) ?d)
2045 (numberp el) (setq el (list 'int-to-string el))))
2046 (setq flist (cons (gnus-max-width-function el max-width)
2049 (setq flist (cons (car elem) flist))
2050 (setq newspec (car (cdr elem))))
2051 ;; Remove the old specification (and possibly a ",12" string).
2052 (delete-region beg (match-end 2))
2053 ;; Insert the new specification.
2056 (setq fstring (buffer-substring 1 (point-max))))
2057 (cons 'format (cons fstring (nreverse flist)))))
2059 (defun gnus-set-work-buffer ()
2060 (if (get-buffer gnus-work-buffer)
2062 (set-buffer gnus-work-buffer)
2064 (set-buffer (get-buffer-create gnus-work-buffer))
2065 (kill-all-local-variables)
2066 (buffer-disable-undo (current-buffer))
2067 (gnus-add-current-to-buffer-list)))
2069 ;; Article file names when saving.
2071 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2072 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2073 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2074 Otherwise, it is like ~/News/news/group/num."
2077 (concat (if (gnus-use-long-file-name 'not-save)
2078 (gnus-capitalize-newsgroup newsgroup)
2079 (gnus-newsgroup-directory-form newsgroup))
2080 "/" (int-to-string (mail-header-number headers)))
2081 (or gnus-article-save-directory "~/News"))))
2083 (string-equal (file-name-directory default)
2084 (file-name-directory last-file))
2085 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2087 (or last-file default))))
2089 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2090 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2091 If variable `gnus-use-long-file-name' is non-nil, it is
2092 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2095 (concat (if (gnus-use-long-file-name 'not-save)
2097 (gnus-newsgroup-directory-form newsgroup))
2098 "/" (int-to-string (mail-header-number headers)))
2099 (or gnus-article-save-directory "~/News"))))
2101 (string-equal (file-name-directory default)
2102 (file-name-directory last-file))
2103 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2105 (or last-file default))))
2107 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2108 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2109 If variable `gnus-use-long-file-name' is non-nil, it is
2110 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2113 (if (gnus-use-long-file-name 'not-save)
2114 (gnus-capitalize-newsgroup newsgroup)
2115 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2116 (or gnus-article-save-directory "~/News"))))
2118 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2119 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2120 If variable `gnus-use-long-file-name' is non-nil, it is
2121 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2124 (if (gnus-use-long-file-name 'not-save)
2126 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2127 (or gnus-article-save-directory "~/News"))))
2129 ;; For subscribing new newsgroup
2131 (defun gnus-subscribe-hierarchical-interactive (groups)
2132 (let ((groups (sort groups 'string<))
2133 prefixes prefix start ans group starts)
2135 (setq prefixes (list "^"))
2136 (while (and groups prefixes)
2137 (while (not (string-match (car prefixes) (car groups)))
2138 (setq prefixes (cdr prefixes)))
2139 (setq prefix (car prefixes))
2140 (setq start (1- (length prefix)))
2141 (if (and (string-match "[^\\.]\\." (car groups) start)
2144 (concat "^" (substring (car groups) 0 (match-end 0))))
2145 (string-match prefix (car (cdr groups))))
2147 (setq prefixes (cons prefix prefixes))
2148 (message "Descend hierarchy %s? ([y]nsq): "
2149 (substring prefix 1 (1- (length prefix))))
2150 (setq ans (read-char))
2153 (string-match prefix
2154 (setq group (car groups))))
2155 (setq gnus-killed-list
2156 (cons group gnus-killed-list))
2157 (gnus-sethash group group gnus-killed-hashtb)
2158 (setq groups (cdr groups)))
2159 (setq starts (cdr starts)))
2162 (string-match prefix
2163 (setq group (car groups))))
2164 (gnus-sethash group group gnus-killed-hashtb)
2165 (gnus-subscribe-alphabetically (car groups))
2166 (setq groups (cdr groups)))
2167 (setq starts (cdr starts)))
2170 (setq group (car groups))
2171 (setq gnus-killed-list (cons group gnus-killed-list))
2172 (gnus-sethash group group gnus-killed-hashtb)
2173 (setq groups (cdr groups))))
2175 (message "Subscribe %s? ([n]yq)" (car groups))
2176 (setq ans (read-char))
2177 (setq group (car groups))
2179 (gnus-subscribe-alphabetically (car groups))
2180 (gnus-sethash group group gnus-killed-hashtb))
2183 (setq group (car groups))
2184 (setq gnus-killed-list (cons group gnus-killed-list))
2185 (gnus-sethash group group gnus-killed-hashtb)
2186 (setq groups (cdr groups))))
2188 (setq gnus-killed-list (cons group gnus-killed-list))
2189 (gnus-sethash group group gnus-killed-hashtb)))
2190 (setq groups (cdr groups)))))))
2192 (defun gnus-subscribe-randomly (newsgroup)
2193 "Subscribe new NEWSGROUP by making it the first newsgroup."
2194 (gnus-subscribe-newsgroup newsgroup))
2196 (defun gnus-subscribe-alphabetically (newgroup)
2197 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2198 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2199 (let ((groups (cdr gnus-newsrc-alist))
2201 (while (and (not before) groups)
2202 (if (string< newgroup (car (car groups)))
2203 (setq before (car (car groups)))
2204 (setq groups (cdr groups))))
2205 (gnus-subscribe-newsgroup newgroup before)))
2207 (defun gnus-subscribe-hierarchically (newgroup)
2208 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2209 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2211 (set-buffer (find-file-noselect gnus-current-startup-file))
2212 (let ((groupkey newgroup)
2214 (while (and (not before) groupkey)
2215 (goto-char (point-min))
2217 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2218 (while (and (re-search-forward groupkey-re nil t)
2220 (setq before (buffer-substring
2221 (match-beginning 1) (match-end 1)))
2222 (string< before newgroup)))))
2223 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2225 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2226 (substring groupkey (match-beginning 1) (match-end 1)))))
2227 (gnus-subscribe-newsgroup newgroup before))))
2229 (defun gnus-subscribe-interactively (newsgroup)
2230 "Subscribe new NEWSGROUP interactively.
2231 It is inserted in hierarchical newsgroup order if subscribed. If not,
2233 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2234 (gnus-subscribe-hierarchically newsgroup)
2235 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2237 (defun gnus-subscribe-zombies (newsgroup)
2238 "Make new NEWSGROUP a zombie group."
2239 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2241 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2242 "Subscribe new NEWSGROUP.
2243 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2244 the first newsgroup."
2245 ;; We subscribe the group by changing its level to `subscribed'.
2246 (gnus-group-change-level
2247 newsgroup gnus-level-default-subscribed
2248 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2249 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2253 (defun gnus-newsgroup-directory-form (newsgroup)
2254 "Make hierarchical directory name from NEWSGROUP name."
2255 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2256 (len (length newsgroup))
2258 ;; If this is a foreign group, we don't want to translate the
2260 (if (setq idx (string-match ":" newsgroup))
2261 (aset newsgroup idx ?/)
2263 ;; Replace all occurrences of `.' with `/'.
2265 (if (= (aref newsgroup idx) ?.)
2266 (aset newsgroup idx ?/))
2267 (setq idx (1+ idx)))
2270 (defun gnus-newsgroup-saveable-name (group)
2271 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2273 (gnus-replace-chars-in-string group ?/ ?.))
2275 (defun gnus-make-directory (dir)
2276 "Make DIRECTORY recursively."
2277 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2278 ;; of the many mysteries of the universe.
2279 (let* ((dir (expand-file-name dir default-directory))
2281 (if (string-match "/$" dir)
2282 (setq dir (substring dir 0 (match-beginning 0))))
2283 ;; First go down the path until we find a directory that exists.
2284 (while (not (file-exists-p dir))
2285 (setq dirs (cons dir dirs))
2286 (string-match "/[^/]+$" dir)
2287 (setq dir (substring dir 0 (match-beginning 0))))
2288 ;; Then create all the subdirs.
2289 (while (and dirs (not err))
2291 (make-directory (car dirs))
2292 (error (setq err t)))
2293 (setq dirs (cdr dirs)))
2294 ;; We return whether we were successful or not.
2297 (defun gnus-capitalize-newsgroup (newsgroup)
2298 "Capitalize NEWSGROUP name."
2299 (and (not (zerop (length newsgroup)))
2300 (concat (char-to-string (upcase (aref newsgroup 0)))
2301 (substring newsgroup 1))))
2305 (defun gnus-simplify-subject (subject &optional re-only)
2306 "Remove `Re:' and words in parentheses.
2307 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2308 (let ((case-fold-search t)) ;Ignore case.
2309 ;; Remove `Re:' and `Re^N:'.
2310 (if (string-match "^re:[ \t]*" subject)
2311 (setq subject (substring subject (match-end 0))))
2312 ;; Remove words in parentheses from end.
2314 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2315 (setq subject (substring subject 0 (match-beginning 0)))))
2316 ;; Return subject string.
2319 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2321 (defun gnus-simplify-subject-fuzzy (subject)
2322 (let ((case-fold-search t))
2324 (gnus-set-work-buffer)
2326 (inline (gnus-simplify-buffer-fuzzy))
2329 (defun gnus-simplify-buffer-fuzzy ()
2330 (goto-char (point-min))
2331 ;; Fix by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2332 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2334 (replace-match "" t t))
2335 (goto-char (point-min))
2336 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2337 (replace-match "" t t))
2338 (goto-char (point-min))
2339 (while (re-search-forward "[ \t]+" nil t)
2340 (replace-match " " t t))
2341 (goto-char (point-min))
2342 (while (re-search-forward "[ \t]+$" nil t)
2343 (replace-match "" t t))
2344 (goto-char (point-min))
2345 (while (re-search-forward "^[ \t]+" nil t)
2346 (replace-match "" t t))
2347 (if gnus-simplify-subject-fuzzy-regexp
2348 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2349 (replace-match "" t t))))
2351 ;; Add the current buffer to the list of buffers to be killed on exit.
2352 (defun gnus-add-current-to-buffer-list ()
2353 (or (memq (current-buffer) gnus-buffer-list)
2354 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2356 (defun gnus-string> (s1 s2)
2357 (not (or (string< s1 s2)
2360 ;; Functions accessing headers.
2361 ;; Functions are more convenient than macros in some cases.
2363 (defun gnus-header-number (header)
2364 (mail-header-number header))
2366 (defun gnus-header-subject (header)
2367 (mail-header-subject header))
2369 (defun gnus-header-from (header)
2370 (mail-header-from header))
2372 (defun gnus-header-xref (header)
2373 (mail-header-xref header))
2375 (defun gnus-header-lines (header)
2376 (mail-header-lines header))
2378 (defun gnus-header-date (header)
2379 (mail-header-date header))
2381 (defun gnus-header-id (header)
2382 (mail-header-id header))
2384 (defun gnus-header-message-id (header)
2385 (mail-header-id header))
2387 (defun gnus-header-chars (header)
2388 (mail-header-chars header))
2390 (defun gnus-header-references (header)
2391 (mail-header-references header))
2393 ;;; General various misc type functions.
2395 (defun gnus-clear-system ()
2396 "Clear all variables and buffers."
2397 ;; Clear Gnus variables.
2398 (let ((variables gnus-variable-list))
2400 (set (car variables) nil)
2401 (setq variables (cdr variables))))
2402 ;; Clear other internal variables.
2403 (setq gnus-list-of-killed-groups nil
2404 gnus-have-read-active-file nil
2405 gnus-newsrc-alist nil
2406 gnus-newsrc-hashtb nil
2407 gnus-killed-list nil
2408 gnus-zombie-list nil
2409 gnus-killed-hashtb nil
2410 gnus-active-hashtb nil
2411 gnus-moderated-list nil
2412 gnus-description-hashtb nil
2413 gnus-newsgroup-headers nil
2414 gnus-newsgroup-headers-hashtb-by-number nil
2415 gnus-newsgroup-name nil
2416 gnus-server-alist nil
2417 gnus-current-select-method nil)
2418 ;; Reset any score variables.
2419 (and (boundp 'gnus-score-cache)
2420 (set 'gnus-score-cache nil))
2421 (and (boundp 'gnus-internal-global-score-files)
2422 (set 'gnus-internal-global-score-files nil))
2423 ;; Kill the startup file.
2424 (and gnus-current-startup-file
2425 (get-file-buffer gnus-current-startup-file)
2426 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2427 ;; Save any cache buffers.
2428 (and gnus-use-cache (gnus-cache-save-buffers))
2429 ;; Clear the dribble buffer.
2430 (gnus-dribble-clear)
2431 ;; Kill global KILL file buffer.
2432 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2433 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2434 (gnus-kill-buffer nntp-server-buffer)
2435 ;; Kill Gnus buffers.
2436 (while gnus-buffer-list
2437 (gnus-kill-buffer (car gnus-buffer-list))
2438 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2440 (defun gnus-windows-old-to-new (setting)
2441 (if (symbolp setting)
2443 (cond ((eq setting 'SelectArticle)
2445 ((eq setting 'SelectSubject)
2447 ((eq setting 'SelectNewsgroup)
2450 (if (or (listp setting)
2451 (not (and gnus-window-configuration
2452 (memq setting '(group summary article)))))
2454 (let* ((setting (if (eq setting 'group)
2455 (if (assq 'newsgroup gnus-window-configuration)
2457 'newsgroups) setting))
2458 (elem (car (cdr (assq setting gnus-window-configuration))))
2459 (total (apply '+ elem))
2460 (types '(group summary article))
2461 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2466 (or (zerop (nth i elem))
2468 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2469 (setq out (cons (if (eq pbuf (nth i types))
2470 (vector (nth i types) perc 'point)
2471 (vector (nth i types) perc))
2474 (list (nreverse out)))))
2476 (defun gnus-add-configuration (conf)
2477 (setq gnus-buffer-configuration
2478 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
2479 gnus-buffer-configuration))))
2481 (defun gnus-configure-windows (setting &optional force)
2482 (setq setting (gnus-windows-old-to-new setting))
2483 (let ((r (if (symbolp setting)
2484 (cdr (assq setting gnus-buffer-configuration))
2486 (in-buf (current-buffer))
2487 rule val w height hor ohor heights sub jump-buffer
2488 rel total to-buf all-visible)
2489 (or r (error "No such setting: %s" setting))
2491 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p r)))
2492 ;; All the windows mentioned are already visibe, so we just
2493 ;; put point in the assigned buffer, and do not touch the
2495 (select-window (get-buffer-window all-visible))
2497 ;; Either remove all windows or just remove all Gnus windows.
2498 (if gnus-use-full-window
2499 (delete-other-windows)
2500 (gnus-remove-some-windows)
2501 (switch-to-buffer nntp-server-buffer))
2507 ;; We have to do the (possible) horizontal splitting before the
2509 (if (and (listp (car hor))
2510 (eq (car (car hor)) 'horizontal))
2514 (if (integerp (nth 1 (car hor)))
2516 (- (frame-width) (floor (* (frame-width) (nth 1 (car hor))))))
2518 (setq hor (cdr hor))))
2520 ;; Go through the rules and eval the elements that are to be
2523 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2525 ;; Expand short buffer name.
2526 (setq w (aref val 0))
2527 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2529 (setq val (apply 'vector (mapcar 'identity val)))
2531 (setq ohor (cons val ohor))))
2532 (setq hor (cdr hor)))
2533 (setq rule (cons (nreverse ohor) rule))
2535 (setq rule (nreverse rule))
2537 ;; We tally the window sizes.
2538 (setq total (window-height))
2540 (setq hor (car rule))
2541 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2542 (setq hor (cdr hor)))
2545 (setq rel (aref (car hor) 1)
2547 (cond ((and (floatp rel) (= 1.0 rel))
2552 (max (floor (* total rel)) 4)))
2554 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2556 (setq heights (nreverse heights)
2559 ;; We then go through these heighs and create windows for them.
2561 (setq height (car heights)
2562 heights (cdr heights))
2564 (setq height (- total sub)))
2566 (split-window nil height))
2567 (setq to-buf (aref (car hor) 0))
2572 (symbol-value (aref (car hor) 0)))
2574 (aref (car hor) 0))))
2575 (and (> (length (car hor)) 2)
2576 (eq (aref (car hor) 2) 'point)
2577 (setq jump-buffer (current-buffer)))
2579 (setq hor (cdr hor)))
2581 (setq rule (cdr rule)))
2583 ;; Finally, we pop to the buffer that's supposed to have point.
2584 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2586 (select-window (get-buffer-window jump-buffer))
2587 (set-buffer jump-buffer))))
2589 (defun gnus-all-windows-visible-p (rule)
2590 (let (invisible hor jump-buffer val buffer)
2591 ;; Go through the rules and eval the elements that are to be
2593 (while (and rule (not invisible))
2594 (setq hor (car rule)
2596 (while (and hor (not invisible))
2597 (if (setq val (if (vectorp (car hor))
2599 (if (not (eq (car (car hor)) 'horizontal))
2602 ;; Expand short buffer name.
2603 (setq buffer (or (cdr (assq (aref val 0) gnus-window-to-buffer))
2605 (setq buffer (if (symbolp buffer) (symbol-value buffer)
2607 (and (> (length val) 2) (eq 'point (aref val 2))
2608 (setq jump-buffer buffer))
2609 (setq invisible (not (and buffer (get-buffer-window buffer))))))
2610 (setq hor (cdr hor))))
2611 (and (not invisible) jump-buffer)))
2613 (defun gnus-window-top-edge (&optional window)
2614 (nth 1 (window-edges window)))
2616 (defun gnus-remove-some-windows ()
2617 (let ((buffers gnus-window-to-buffer)
2618 buf bufs lowest-buf lowest)
2620 ;; Remove windows on all known Gnus buffers.
2622 (setq buf (cdr (car buffers)))
2624 (setq buf (and (boundp buf) (symbol-value buf))))
2626 (get-buffer-window buf)
2628 (setq bufs (cons buf bufs))
2630 (if (or (not lowest)
2631 (< (gnus-window-top-edge) lowest))
2633 (setq lowest (gnus-window-top-edge))
2634 (setq lowest-buf buf)))))
2635 (setq buffers (cdr buffers)))
2636 ;; Remove windows on *all* summary buffers.
2640 (let ((buf (window-buffer win)))
2641 (if (string-match "^\\*Summary" (buffer-name buf))
2643 (setq bufs (cons buf bufs))
2645 (if (or (not lowest)
2646 (< (gnus-window-top-edge) lowest))
2648 (setq lowest-buf buf)
2649 (setq lowest (gnus-window-top-edge))))))))))
2652 (pop-to-buffer lowest-buf)
2653 (switch-to-buffer nntp-server-buffer)))
2655 (and (not (eq (car bufs) lowest-buf))
2656 (delete-windows-on (car bufs)))
2657 (setq bufs (cdr bufs))))))
2659 (defun gnus-version ()
2660 "Version numbers of this version of Gnus."
2662 (let ((methods gnus-valid-select-methods)
2665 ;; Go through all the legal select methods and add their version
2666 ;; numbers to the total version string. Only the backends that are
2667 ;; currently in use will have their message numbers taken into
2670 (setq meth (intern (concat (car (car methods)) "-version")))
2672 (stringp (symbol-value meth))
2673 (setq mess (concat mess "; " (symbol-value meth))))
2674 (setq methods (cdr methods)))
2675 (gnus-message 2 mess)))
2677 (defun gnus-info-find-node ()
2678 "Find Info documentation of Gnus."
2680 ;; Enlarge info window if needed.
2681 (let ((mode major-mode))
2682 (gnus-configure-windows 'info)
2683 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2685 (defun gnus-overload-functions (&optional overloads)
2686 "Overload functions specified by optional argument OVERLOADS.
2687 If nothing is specified, use the variable gnus-overload-functions."
2689 (overloads (or overloads gnus-overload-functions)))
2691 (setq defs (car overloads))
2692 (setq overloads (cdr overloads))
2693 ;; Load file before overloading function if necessary. Make
2694 ;; sure we cannot use `require' always.
2695 (and (not (fboundp (car defs)))
2696 (car (cdr (cdr defs)))
2697 (load (car (cdr (cdr defs))) nil 'nomessage))
2698 (fset (car defs) (car (cdr defs))))))
2700 (defun gnus-replace-chars-in-string (string &rest pairs)
2701 "Replace characters in STRING from FROM to TO."
2702 (let ((string (substring string 0)) ;Copy string.
2703 (len (length string))
2706 (or (zerop (% (length pairs) 2))
2707 (error "Odd number of translation pairs"))
2708 (setplist 'sym pairs)
2709 ;; Replace all occurrences of FROM with TO.
2711 (if (setq to (get 'sym (aref string idx)))
2712 (aset string idx to))
2713 (setq idx (1+ idx)))
2716 (defun gnus-days-between (date1 date2)
2717 ;; Return the number of days between date1 and date2.
2718 (- (gnus-day-number date1) (gnus-day-number date2)))
2720 (defun gnus-day-number (date)
2721 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2722 (timezone-parse-date date))))
2723 (timezone-absolute-from-gregorian
2724 (nth 1 dat) (nth 2 dat) (car dat))))
2726 ;; Returns a floating point number that says how many seconds have
2727 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2728 (defun gnus-seconds-since-epoch (date)
2729 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2730 (timezone-parse-date date)))
2731 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2732 (timezone-parse-time
2733 (aref (timezone-parse-date date) 3))))
2734 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2735 (timezone-parse-date "Jan 1 12:00:00 1970")))
2736 (tday (- (timezone-absolute-from-gregorian
2737 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2738 (timezone-absolute-from-gregorian
2739 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2741 (* (nth 1 ttime) 60)
2742 (* 1.0 (nth 0 ttime) 60 60)
2743 (* 1.0 tday 60 60 24))))
2745 (defun gnus-file-newer-than (file date)
2746 (let ((fdate (nth 5 (file-attributes file))))
2747 (or (> (car fdate) (car date))
2748 (and (= (car fdate) (car date))
2749 (> (nth 1 fdate) (nth 1 date))))))
2751 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2753 (defun gnus-y-or-n-p (prompt)
2758 (defun gnus-yes-or-no-p (prompt)
2760 (yes-or-no-p prompt)
2763 ;; Check whether to use long file names.
2764 (defun gnus-use-long-file-name (symbol)
2765 ;; The variable has to be set...
2766 (and gnus-use-long-file-name
2767 ;; If it isn't a list, then we return t.
2768 (or (not (listp gnus-use-long-file-name))
2769 ;; If it is a list, and the list contains `symbol', we
2771 (not (memq symbol gnus-use-long-file-name)))))
2773 ;; I suspect there's a better way, but I haven't taken the time to do
2774 ;; it yet. -erik selberg@cs.washington.edu
2775 (defun gnus-dd-mmm (messy-date)
2776 "Return a string like DD-MMM from a big messy string"
2777 (let ((datevec (timezone-parse-date messy-date)))
2779 (or (aref datevec 2) "??")
2782 (nth (1- (string-to-number (aref datevec 1)))
2783 timezone-months-assoc))
2786 ;; Make a hash table (default and minimum size is 255).
2787 ;; Optional argument HASHSIZE specifies the table size.
2788 (defun gnus-make-hashtable (&optional hashsize)
2789 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2791 ;; Make a number that is suitable for hashing; bigger than MIN and one
2793 (defun gnus-create-hash-size (min)
2799 ;; Show message if message has a lower level than `gnus-verbose'.
2800 ;; Guide-line for numbers:
2801 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2802 ;; for things that take a long time, 7 - not very important messages
2803 ;; on stuff, 9 - messages inside loops.
2804 (defun gnus-message (level &rest args)
2805 (if (<= level gnus-verbose)
2806 (apply 'message args)
2807 ;; We have to do this format thingie here even if the result isn't
2808 ;; shown - the return value has to be the same as the return value
2810 (apply 'format args)))
2812 ;; Generate a unique new group name.
2813 (defun gnus-generate-new-group-name (leaf)
2816 (while (gnus-gethash name gnus-newsrc-hashtb)
2817 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
2820 ;;; List and range functions
2822 (defun gnus-last-element (list)
2823 "Return last element of LIST."
2825 (setq list (cdr list)))
2828 (defun gnus-copy-sequence (list)
2829 "Do a complete, total copy of a list."
2830 (if (and (consp list) (not (consp (cdr list))))
2831 (cons (car list) (cdr list))
2832 (mapcar (lambda (elem) (if (consp elem)
2833 (if (consp (cdr elem))
2834 (gnus-copy-sequence elem)
2835 (cons (car elem) (cdr elem)))
2839 (defun gnus-set-difference (list1 list2)
2840 "Return a list of elements of LIST1 that do not appear in LIST2."
2841 (let ((list1 (copy-sequence list1)))
2843 (setq list1 (delq (car list2) list1))
2844 (setq list2 (cdr list2)))
2847 (defun gnus-sorted-complement (list1 list2)
2848 "Return a list of elements of LIST1 that do not appear in LIST2.
2849 Both lists have to be sorted over <."
2851 (if (or (null list1) (null list2))
2853 (while (and list1 list2)
2854 (cond ((= (car list1) (car list2))
2855 (setq list1 (cdr list1)
2857 ((< (car list1) (car list2))
2858 (setq out (cons (car list1) out))
2859 (setq list1 (cdr list1)))
2861 (setq out (cons (car list2) out))
2862 (setq list2 (cdr list2)))))
2863 (nconc (nreverse out) (or list1 list2)))))
2865 (defun gnus-intersection (list1 list2)
2868 (if (memq (car list2) list1)
2869 (setq result (cons (car list2) result)))
2870 (setq list2 (cdr list2)))
2873 (defun gnus-sorted-intersection (list1 list2)
2874 ;; LIST1 and LIST2 have to be sorted over <.
2876 (while (and list1 list2)
2877 (cond ((= (car list1) (car list2))
2878 (setq out (cons (car list1) out)
2881 ((< (car list1) (car list2))
2882 (setq list1 (cdr list1)))
2884 (setq list2 (cdr list2)))))
2887 (defun gnus-set-sorted-intersection (list1 list2)
2888 ;; LIST1 and LIST2 have to be sorted over <.
2889 ;; This function modifies LIST1.
2890 (let* ((top (cons nil list1))
2892 (while (and list1 list2)
2893 (cond ((= (car list1) (car list2))
2897 ((< (car list1) (car list2))
2898 (setcdr prev (cdr list1))
2899 (setq list1 (cdr list1)))
2901 (setq list2 (cdr list2)))))
2905 (defun gnus-compress-sequence (numbers &optional always-list)
2906 "Convert list of numbers to a list of ranges or a single range.
2907 If ALWAYS-LIST is non-nil, this function will always release a list of
2909 (let* ((first (car numbers))
2910 (last (car numbers))
2914 (if (not (listp (cdr numbers)))
2917 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2918 ((= (1+ last) (car numbers)) ;Still in sequence
2919 (setq last (car numbers)))
2920 (t ;End of one sequence
2922 (cons (if (= first last) first
2923 (cons first last)) result))
2924 (setq first (car numbers))
2925 (setq last (car numbers))))
2926 (setq numbers (cdr numbers)))
2927 (if (and (not always-list) (null result))
2928 (if (= first last) (list first) (cons first last))
2929 (nreverse (cons (if (= first last) first (cons first last))
2932 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2933 (defun gnus-uncompress-range (ranges)
2934 "Expand a list of ranges into a list of numbers.
2935 RANGES is either a single range on the form `(num . num)' or a list of
2937 (let (first last result)
2941 ((not (listp (cdr ranges)))
2942 (setq first (car ranges))
2943 (setq last (cdr ranges))
2944 (while (<= first last)
2945 (setq result (cons first result))
2946 (setq first (1+ first)))
2950 (if (atom (car ranges))
2951 (if (numberp (car ranges))
2952 (setq result (cons (car ranges) result)))
2953 (setq first (car (car ranges)))
2954 (setq last (cdr (car ranges)))
2955 (while (<= first last)
2956 (setq result (cons first result))
2957 (setq first (1+ first))))
2958 (setq ranges (cdr ranges)))
2959 (nreverse result)))))
2961 (defun gnus-add-to-range (ranges list)
2962 "Return a list of ranges that has all articles from both RANGES and LIST.
2963 Note: LIST has to be sorted over `<'."
2965 (gnus-compress-sequence list t)
2966 (setq list (copy-sequence list))
2967 (or (listp (cdr ranges))
2968 (setq ranges (list ranges)))
2970 ilist lowest highest temp)
2971 (while (and ranges list)
2973 (setq lowest (or (and (atom (car ranges)) (car ranges))
2974 (car (car ranges))))
2975 (while (and list (cdr list) (< (car (cdr list)) lowest))
2976 (setq list (cdr list)))
2977 (if (< (car ilist) lowest)
2980 (setq list (cdr list))
2982 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2983 (setq highest (or (and (atom (car ranges)) (car ranges))
2984 (cdr (car ranges))))
2985 (while (and list (<= (car list) highest))
2986 (setq list (cdr list)))
2987 (setq ranges (cdr ranges)))
2989 (setq out (nconc (gnus-compress-sequence list t) out)))
2990 (setq out (sort out (lambda (r1 r2)
2991 (< (or (and (atom r1) r1) (car r1))
2992 (or (and (atom r2) r2) (car r2))))))
2995 (if (atom (car ranges))
2997 (if (atom (car (cdr ranges)))
2998 (if (= (1+ (car ranges)) (car (cdr ranges)))
3000 (setcar ranges (cons (car ranges)
3001 (car (cdr ranges))))
3002 (setcdr ranges (cdr (cdr ranges)))))
3003 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3005 (setcar (car (cdr ranges)) (car ranges))
3006 (setcar ranges (car (cdr ranges)))
3007 (setcdr ranges (cdr (cdr ranges)))))))
3009 (if (atom (car (cdr ranges)))
3010 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3012 (setcdr (car ranges) (car (cdr ranges)))
3013 (setcdr ranges (cdr (cdr ranges)))))
3014 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3016 (setcdr (car ranges) (cdr (car (cdr ranges))))
3017 (setcdr ranges (cdr (cdr ranges))))))))
3018 (setq ranges (cdr ranges)))
3021 (defun gnus-remove-from-range (ranges list)
3022 "Return a list of ranges that has all articles from LIST removed from RANGES.
3023 Note: LIST has to be sorted over `<'."
3024 ;; !!! This function shouldn't look like this, but I've got a headache.
3025 (gnus-compress-sequence
3026 (gnus-sorted-complement
3027 (gnus-uncompress-range ranges) list)))
3029 (defun gnus-member-of-range (number ranges)
3030 (if (not (listp (cdr ranges)))
3031 (and (>= number (car ranges))
3032 (<= number (cdr ranges)))
3035 (if (numberp (car ranges))
3036 (>= number (car ranges))
3037 (>= number (car (car ranges))))
3039 (if (if (numberp (car ranges))
3040 (= number (car ranges))
3041 (and (>= number (car (car ranges)))
3042 (<= number (cdr (car ranges)))))
3043 (setq not-stop nil))
3044 (setq ranges (cdr ranges)))
3052 (defvar gnus-group-mode-map nil)
3053 (defvar gnus-group-group-map nil)
3054 (defvar gnus-group-mark-map nil)
3055 (defvar gnus-group-list-map nil)
3056 (defvar gnus-group-sub-map nil)
3057 (put 'gnus-group-mode 'mode-class 'special)
3059 (if gnus-group-mode-map
3061 (setq gnus-group-mode-map (make-keymap))
3062 (suppress-keymap gnus-group-mode-map)
3063 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3064 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3065 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3066 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3067 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3068 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3069 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3070 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3071 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3072 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
3073 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
3074 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3075 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3076 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3077 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3078 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3079 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3080 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3081 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3082 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3083 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3084 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3085 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3086 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3087 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3088 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3089 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3090 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3091 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3092 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3093 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
3094 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3095 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3096 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3097 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3098 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3099 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3100 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3101 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3102 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3103 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3104 (define-key gnus-group-mode-map "V" 'gnus-version)
3105 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3106 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3107 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3108 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3109 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3110 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
3111 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3112 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3113 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3114 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3115 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3116 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3117 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3118 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3119 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3121 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3122 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3123 (define-prefix-command 'gnus-group-mark-map)
3124 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3125 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3126 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3127 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3129 (define-prefix-command 'gnus-group-group-map)
3130 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3131 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3132 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3133 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3134 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3135 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3136 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3137 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3138 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3139 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3140 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3141 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3142 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3143 ;;(define-key gnus-group-group-map "sb" 'gnus-group-brew-soup)
3144 ;;(define-key gnus-group-group-map "sw" 'gnus-soup-save-areas)
3145 ;;(define-key gnus-group-group-map "ss" 'gnus-soup-send-replies)
3146 ;;(define-key gnus-group-group-map "sp" 'gnus-soup-pack-packet)
3147 ;;(define-key gnus-group-group-map "sr" 'nnsoup-pack-replies)
3149 (define-prefix-command 'gnus-group-list-map)
3150 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3151 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3152 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3153 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3154 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3155 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3156 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3157 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3158 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3160 (define-prefix-command 'gnus-group-sub-map)
3161 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3162 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3163 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3164 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3165 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3166 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3167 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3168 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3170 (defun gnus-group-mode ()
3171 "Major mode for reading news.
3173 All normal editing commands are switched off.
3174 \\<gnus-group-mode-map>
3175 The group buffer lists (some of) the groups available. For instance,
3176 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3177 lists all zombie groups.
3179 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3180 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3182 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3184 The following commands are available:
3186 \\{gnus-group-mode-map}"
3188 (if gnus-visual (gnus-group-make-menu-bar))
3189 (kill-all-local-variables)
3190 (setq mode-line-modified "-- ")
3191 (make-local-variable 'mode-line-format)
3192 (setq mode-line-format (copy-sequence mode-line-format))
3193 (and (equal (nth 3 mode-line-format) " ")
3194 (setcar (nthcdr 3 mode-line-format) ""))
3195 (setq major-mode 'gnus-group-mode)
3196 (setq mode-name "Group")
3197 (gnus-group-set-mode-line)
3198 (setq mode-line-process nil)
3199 (use-local-map gnus-group-mode-map)
3200 (buffer-disable-undo (current-buffer))
3201 (setq truncate-lines t)
3202 (setq buffer-read-only t)
3203 (run-hooks 'gnus-group-mode-hook))
3205 (defun gnus-mouse-pick-group (e)
3208 (gnus-group-read-group nil))
3210 ;; Look at LEVEL and find out what the level is really supposed to be.
3211 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3212 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3213 (defun gnus-group-default-level (&optional level number-or-nil)
3215 (gnus-group-use-permanent-levels
3216 (setq gnus-group-default-list-level
3217 (or level gnus-group-default-list-level))
3218 (or gnus-group-default-list-level gnus-level-subscribed))
3222 (or level gnus-group-default-list-level gnus-level-subscribed))))
3226 (defun gnus-no-server (&optional arg)
3228 If ARG is a positive number, Gnus will use that as the
3229 startup level. If ARG is nil, Gnus will be started at level 2.
3230 If ARG is non-nil and not a positive number, Gnus will
3231 prompt the user for the name of an NNTP server to use.
3232 As opposed to `gnus', this command will not connect to the local server."
3234 (setq gnus-group-use-permanent-levels t)
3235 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3238 (defun gnus (&optional arg dont-connect)
3240 If ARG is non-nil and a positive number, Gnus will use that as the
3241 startup level. If ARG is non-nil and not a positive number, Gnus will
3242 prompt the user for the name of an NNTP server to use."
3244 (if (get-buffer gnus-group-buffer)
3246 (switch-to-buffer gnus-group-buffer)
3247 (gnus-group-get-new-news))
3251 (nnheader-init-server-buffer)
3252 (gnus-read-init-file)
3254 (gnus-group-setup-buffer)
3255 (let ((buffer-read-only nil))
3257 (if (not gnus-inhibit-startup-message)
3259 (gnus-group-startup-message)
3262 (let ((level (and arg (numberp arg) (> arg 0) arg))
3268 (gnus-start-news-server (and arg (not level))))))
3269 (if (and (not dont-connect)
3272 (run-hooks 'gnus-startup-hook)
3273 ;; NNTP server is successfully open.
3275 ;; Find the current startup file name.
3276 (setq gnus-current-startup-file
3277 (gnus-make-newsrc-file gnus-startup-file))
3279 ;; Read the dribble file.
3280 (and gnus-use-dribble-file (gnus-dribble-read-file))
3282 (gnus-summary-make-display-table)
3283 (gnus-setup-news nil level)
3284 (gnus-group-list-groups level)
3285 (gnus-configure-windows 'group))))))
3287 (defun gnus-unload ()
3288 "Unload all Gnus features."
3290 (or (boundp 'load-history)
3291 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
3292 (let ((history load-history)
3295 (and (string-match "^gnus" (car (car history)))
3296 (setq feature (cdr (assq 'provide (car history))))
3297 (unload-feature feature 'force))
3298 (setq history (cdr history)))))
3300 (defun gnus-group-startup-message (&optional x y)
3301 "Insert startup message in current buffer."
3302 ;; Insert the message.
3307 _ ___ __ ___ __ _ ___
3325 Gnus * A newsreader for Emacsen
3326 A Praxis release * larsi@ifi.uio.no
3329 ;; And then hack it.
3330 ;; 18 is the longest line.
3331 (indent-rigidly (point-min) (point-max)
3332 (/ (max (- (window-width) (or x 46)) 0) 2))
3333 (goto-char (point-min))
3334 (let* ((pheight (count-lines (point-min) (point-max)))
3335 (wheight (window-height))
3336 (rest (- wheight pheight)))
3337 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
3342 (goto-char (point-min))
3343 (search-forward "Praxis")
3344 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3345 (goto-char (point-min)))
3347 (defun gnus-group-startup-message-old (&optional x y)
3348 "Insert startup message in current buffer."
3349 ;; Insert the message.
3365 ;; And then hack it.
3366 ;; 18 is the longest line.
3367 (indent-rigidly (point-min) (point-max)
3368 (/ (max (- (window-width) (or x 28)) 0) 2))
3369 (goto-char (point-min))
3370 ;; +4 is fuzzy factor.
3371 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
3374 (goto-char (point-min))
3375 (search-forward "Praxis")
3376 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
3377 (goto-char (point-min)))
3379 (defun gnus-group-setup-buffer ()
3380 (or (get-buffer gnus-group-buffer)
3382 (switch-to-buffer gnus-group-buffer)
3383 (gnus-add-current-to-buffer-list)
3385 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3387 (defun gnus-group-list-groups (&optional level unread)
3388 "List newsgroups with level LEVEL or lower that have unread articles.
3389 Default is all subscribed groups.
3390 If argument UNREAD is non-nil, groups with no unread articles are also
3392 (interactive (list (if current-prefix-arg
3393 (prefix-numeric-value current-prefix-arg)
3395 (gnus-group-default-level nil t)
3396 gnus-group-default-list-level
3397 gnus-level-subscribed))))
3399 (setq level (car gnus-group-list-mode)
3400 unread (cdr gnus-group-list-mode)))
3401 (setq level (gnus-group-default-level level))
3402 (gnus-group-setup-buffer) ;May call from out of group buffer
3403 (let ((case-fold-search nil)
3404 (group (gnus-group-group-name)))
3405 (funcall gnus-group-prepare-function level unread nil)
3406 (if (zerop (buffer-size))
3407 (gnus-message 5 gnus-no-groups-message)
3408 (goto-char (point-min))
3410 ;; Go to the first group with unread articles.
3411 (gnus-group-search-forward nil nil nil t)
3412 ;; Find the right group to put point on. If the current group
3413 ;; has disapeared in the new listing, try to find the next
3414 ;; one. If no next one can be found, just leave point at the
3415 ;; first newsgroup in the buffer.
3416 (if (not (gnus-goto-char
3417 (text-property-any (point-min) (point-max)
3418 'gnus-group (intern group))))
3419 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3421 (not (gnus-goto-char
3423 (point-min) (point-max) 'gnus-group
3424 (intern (car (car newsrc)))))))
3425 (setq newsrc (cdr newsrc)))
3426 (or newsrc (progn (goto-char (point-max))
3427 (forward-line -1))))))
3428 ;; Adjust cursor point.
3429 (gnus-group-position-cursor))))
3431 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3432 "List all newsgroups with unread articles of level LEVEL or lower.
3433 If ALL is non-nil, list groups that have no unread articles.
3434 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3435 If REGEXP, only list groups matching REGEXP."
3436 (set-buffer gnus-group-buffer)
3437 (let ((buffer-read-only nil)
3438 (newsrc (cdr gnus-newsrc-alist))
3439 (lowest (or lowest 1))
3440 info clevel unread group)
3442 (if (< lowest gnus-level-zombie)
3443 ;; List living groups.
3445 (setq info (car newsrc)
3448 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3449 (and unread ; This group might be bogus
3451 (string-match regexp group))
3452 (<= (setq clevel (car (cdr info))) level)
3454 (or all ; We list all groups?
3455 (eq unread t) ; We list unactivated groups
3456 (> unread 0) ; We list groups with unread articles
3457 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3458 (gnus-group-insert-group-line
3459 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3461 ;; List dead groups.
3462 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3463 (gnus-group-prepare-flat-list-dead
3464 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3465 gnus-level-zombie ?Z
3467 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3468 (gnus-group-prepare-flat-list-dead
3469 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3470 gnus-level-killed ?K regexp))
3472 (gnus-group-set-mode-line)
3473 (setq gnus-group-list-mode (cons level all))
3474 (run-hooks 'gnus-group-prepare-hook)))
3476 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3477 ;; List zombies and killed lists somehwat faster, which was
3478 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3479 ;; this by ignoring the group format specification altogether.
3482 (setq group (car groups)
3483 groups (cdr groups))
3484 (if (or (not regexp)
3485 (string-match regexp group))
3488 (insert (format " %c *: %s\n" mark group))
3489 (add-text-properties
3491 (list 'gnus-group (intern group)
3493 'gnus-level level)))))))
3495 (defun gnus-group-real-name (group)
3496 "Find the real name of a foreign newsgroup."
3497 (if (string-match ":[^:]+$" group)
3498 (substring group (1+ (match-beginning 0)))
3501 (defun gnus-group-prefixed-name (group method)
3502 "Return the whole name from GROUP and METHOD."
3503 (and (stringp method) (setq method (gnus-server-to-method method)))
3504 (concat (format "%s" (car method))
3506 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3507 (not (string= (nth 1 method) "")))
3508 (concat "+" (nth 1 method)))
3511 (defun gnus-group-real-prefix (group)
3512 "Return the prefix of the current group name."
3513 (if (string-match "^[^:]+:" group)
3514 (substring group 0 (match-end 0))
3517 (defun gnus-group-method-name (group)
3518 "Return the method used for selecting GROUP."
3519 (let ((prefix (gnus-group-real-prefix group)))
3520 (if (equal prefix "")
3522 (if (string-match "^[^\\+]+\\+" prefix)
3523 (list (intern (substring prefix 0 (1- (match-end 0))))
3524 (substring prefix (match-end 0) (1- (length prefix))))
3525 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3527 (defun gnus-group-foreign-p (group)
3528 "Return nil if GROUP is native, non-nil if it is foreign."
3529 (string-match ":" group))
3531 (defun gnus-group-set-info (info &optional method-only-group part)
3532 (let* ((entry (gnus-gethash
3533 (or method-only-group (car info)) gnus-newsrc-hashtb))
3535 (info (if method-only-group (nth 2 entry) info)))
3536 (if (not method-only-group)
3539 (error "Trying to change non-existent group %s" method-only-group))
3540 ;; We have recevied parts of the actual group info - either the
3541 ;; select method or the group parameters. We first check
3542 ;; whether we have to extend the info, and if so, do that.
3543 (let ((len (length info))
3544 (total (if (eq part 'method) 5 6)))
3546 (setcdr (nthcdr (1- len) info)
3547 (make-list (- total len) nil)))
3548 ;; Then we enter the new info.
3549 (setcar (nthcdr (1- total) info) part-info)))
3550 ;; We uncompress some lists of marked articles.
3552 (if (not (setq marked (nth 3 info)))
3555 (or (eq 'score (car (car marked)))
3556 (eq 'bookmark (car (car marked)))
3557 (eq 'killed (car (car marked)))
3558 (setcdr (car marked)
3559 (gnus-uncompress-range (cdr (car marked)))))
3560 (setq marked (cdr marked)))))
3563 ;; This is a new group, so we just create it.
3565 (set-buffer gnus-group-buffer)
3567 ;; It's a foreign group...
3568 (gnus-group-make-group
3569 (gnus-group-real-name (car info))
3570 (prin1-to-string (car (nth 4 info)))
3571 (nth 1 (nth 4 info)))
3572 ;; It's a native group.
3573 (gnus-group-make-group
3575 (prin1-to-string (car gnus-select-method))
3576 (nth 1 gnus-select-method)))
3577 (gnus-message 6 "Note: New group created")
3579 (gnus-gethash (gnus-group-prefixed-name
3580 (gnus-group-real-name (car info))
3581 (or (nth 4 info) gnus-select-method))
3582 gnus-newsrc-hashtb))))
3583 ;; Whether it was a new group or not, we now have the entry, so we
3584 ;; can do the update.
3587 (setcar (nthcdr 2 entry) info)
3588 (if (and (not (eq (car entry) t))
3589 (gnus-gethash (car info) gnus-active-hashtb))
3590 (let ((marked (nth 3 info)))
3592 (max 0 (- (length (gnus-list-of-unread-articles
3594 (length (cdr (assq 'tick marked)))
3595 (length (cdr (assq 'dormant marked)))))))))
3596 (error "No such group: %s" (car info)))))
3598 (defun gnus-group-set-method-info (group select-method)
3599 (gnus-group-set-info select-method group 'method))
3601 (defun gnus-group-set-params-info (group params)
3602 (gnus-group-set-info params group 'params))
3604 (defun gnus-group-update-group-line ()
3605 "This function updates the current line in the newsgroup buffer and
3606 moves the point to the colon."
3607 (let* ((buffer-read-only nil)
3608 (group (gnus-group-group-name))
3609 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3612 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3615 (delete-region (point) (progn (forward-line 1) (point)))
3616 (gnus-group-insert-group-line-info group)
3618 (gnus-group-position-cursor)))
3620 (defun gnus-group-insert-group-line-info (group)
3621 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3625 (setq info (nth 2 entry))
3626 (gnus-group-insert-group-line
3627 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3628 (setq active (gnus-gethash group gnus-active-hashtb))
3629 (gnus-group-insert-group-line
3631 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
3632 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3634 (defun gnus-group-insert-group-line (gformat group level marked number method)
3635 (let* ((gformat (or gformat gnus-group-line-format-spec))
3636 (active (gnus-gethash group gnus-active-hashtb))
3637 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3638 (number-of-dormant (length (cdr (assq 'dormant marked))))
3639 (number-of-ticked (length (cdr (assq 'tick marked))))
3640 (number-of-ticked-and-dormant
3641 (+ number-of-ticked number-of-dormant))
3642 (number-of-unread-unticked
3643 (if (numberp number) (int-to-string (max 0 number))
3646 (if (numberp number)
3647 (max 0 (- number-total number))
3649 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3650 ((<= level gnus-level-unsubscribed) ?U)
3651 ((= level gnus-level-zombie) ?Z)
3653 (qualified-group (gnus-group-real-name group))
3654 (newsgroup-description
3655 (if gnus-description-hashtb
3656 (or (gnus-gethash group gnus-description-hashtb) "")
3658 (moderated (if (member group gnus-moderated-list) ?m ? ))
3659 (moderated-string (if (eq moderated ?m) "(m)" ""))
3660 (method (gnus-server-get-method group method))
3661 (news-server (or (car (cdr method)) ""))
3662 (news-method (or (car method) ""))
3664 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3668 (> number-of-ticked 0))
3670 (number (if (eq number t) "*" (+ number number-of-dormant
3672 (process-marked (if (member group gnus-group-marked)
3673 gnus-process-mark ? ))
3674 (buffer-read-only nil)
3675 header ; passed as parameter to user-funcs.
3680 (insert (eval gformat))
3682 (add-text-properties
3683 b (1+ b) (list 'gnus-group (intern group)
3684 'gnus-unread (if (numberp number)
3685 (string-to-int number-of-unread-unticked)
3688 'gnus-level level))))
3690 (defun gnus-group-update-group (group &optional visible-only)
3691 "Update newsgroup info of GROUP.
3692 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3694 (set-buffer gnus-group-buffer)
3695 (let ((buffer-read-only nil)
3697 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3700 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3702 ;; Buffer may be narrowed.
3705 ;; Search a line to modify. If the buffer is large, the search
3706 ;; takes long time. In most cases, current point is on the line
3707 ;; we are looking for. So, first of all, check current line.
3710 (eq (get-text-property (point) 'gnus-group)
3715 (point-min) (point-max) 'gnus-group (intern group)))))
3716 ;; GROUP is listed in current buffer. So, delete old line.
3720 (delete-region (point) (progn (forward-line 1) (point))))
3721 ;; No such line in the buffer, find out where it's supposed to
3722 ;; go, and insert it there (or at the end of the buffer).
3723 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3726 (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
3732 (point-min) (point-max)
3733 'gnus-group (intern (car (car entry)))))))
3734 (setq entry (cdr entry)))
3735 (or entry (goto-char (point-max)))))))
3736 (if (or visible (not visible-only))
3737 (gnus-group-insert-group-line-info group))
3738 (gnus-group-set-mode-line))))
3740 (defun gnus-group-set-mode-line ()
3741 (if (memq 'group gnus-updated-mode-lines)
3742 (let* ((gformat (or gnus-group-mode-line-format-spec
3743 (setq gnus-group-mode-line-format-spec
3745 gnus-group-mode-line-format
3746 gnus-group-mode-line-format-alist))))
3747 (news-server (car (cdr gnus-select-method)))
3748 (news-method (car gnus-select-method))
3750 (mode-string (eval gformat)))
3751 (setq mode-string (eval gformat))
3752 (if (> (length mode-string) max-len)
3753 (setq mode-string (substring mode-string 0 (- max-len 4))))
3754 (setq mode-line-buffer-identification mode-string)
3755 (set-buffer-modified-p t))))
3757 (defun gnus-group-group-name ()
3758 "Get the name of the newsgroup on the current line."
3759 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3760 (and group (symbol-name group))))
3762 (defun gnus-group-group-level ()
3763 "Get the level of the newsgroup on the current line."
3764 (get-text-property (gnus-point-at-bol) 'gnus-level))
3766 (defun gnus-group-group-unread ()
3767 "Get the number of unread articles of the newsgroup on the current line."
3768 (get-text-property (gnus-point-at-bol) 'gnus-unread))
3770 (defun gnus-group-search-forward (&optional backward all level first-too)
3771 "Find the next newsgroup with unread articles.
3772 If BACKWARD is non-nil, find the previous newsgroup instead.
3773 If ALL is non-nil, just find any newsgroup.
3774 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3776 If FIRST-TOO, the current line is also eligible as a target."
3777 (let ((way (if backward -1 1))
3778 (low gnus-level-killed)
3781 (if (and backward (progn (beginning-of-line)) (bobp))
3783 (or first-too (forward-line way))
3791 (get-text-property (point) 'gnus-unread)))
3792 (or (eq unread t) (and unread (> unread 0))))
3793 (setq lev (get-text-property (point)
3795 (<= lev gnus-level-subscribed)))
3797 (and (setq lev (get-text-property (point)
3806 (zerop (forward-line way)))))
3808 (progn (gnus-group-position-cursor) t)
3809 (goto-char (or pos beg))
3812 ;;; Gnus group mode commands
3816 (defun gnus-group-mark-group (n &optional unmark no-advance)
3817 "Mark the current group."
3819 (let ((buffer-read-only nil)
3823 (setq group (gnus-group-group-name))
3827 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
3832 (setq gnus-group-marked (delete group gnus-group-marked)))
3834 (setq gnus-group-marked
3835 (cons group (delete group gnus-group-marked))))
3837 (or no-advance (zerop (gnus-group-next-group 1))))
3839 (gnus-summary-position-cursor)
3842 (defun gnus-group-unmark-group (n)
3843 "Remove the mark from the current group."
3845 (gnus-group-mark-group n 'unmark))
3847 (defun gnus-group-mark-region (unmark beg end)
3848 "Mark all groups between point and mark.
3849 If UNMARK, remove the mark instead."
3850 (interactive "P\nr")
3851 (let ((num (count-lines beg end)))
3854 (- num (gnus-group-mark-group num unmark)))))
3856 (defun gnus-group-remove-mark (group)
3857 (and (gnus-group-goto-group group)
3859 (gnus-group-mark-group 1 'unmark t))))
3861 ;; Return a list of groups to work on. Take into consideration N (the
3862 ;; prefix) and the list of marked groups.
3863 (defun gnus-group-process-prefix (n)
3865 (setq n (prefix-numeric-value n))
3866 ;; There is a prefix, so we return a list of the N next
3868 (let ((way (if (< n 0) -1 1))
3873 (setq group (gnus-group-group-name)))
3874 (setq groups (cons group groups))
3876 (forward-line way)))
3879 ;; No prefix, but a list of marked articles.
3880 (reverse gnus-group-marked))
3882 ;; Neither marked articles or a prefix, so we return the
3884 (let ((group (gnus-group-group-name)))
3885 (and group (list group))))))
3887 ;; Selecting groups.
3889 (defun gnus-group-read-group (&optional all no-article group)
3890 "Read news in this newsgroup.
3891 If the prefix argument ALL is non-nil, already read articles become
3892 readable. If the optional argument NO-ARTICLE is non-nil, no article
3893 will be auto-selected upon group entry."
3895 (let ((group (or group (gnus-group-group-name)))
3896 number active marked entry)
3897 (or group (error "No group on current line"))
3899 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3900 ;; This group might be a dead group. In that case we have to get
3901 ;; the number of unread articles from `gnus-active-hashtb'.
3903 (setq number (car entry))
3904 (if (setq active (gnus-gethash group gnus-active-hashtb))
3905 (setq number (- (1+ (cdr active)) (car active)))))
3906 (gnus-summary-read-group
3907 group (or all (and (numberp number)
3908 (zerop (+ number (length (cdr (assq 'tick marked)))
3909 (length (cdr (assq 'dormant marked)))))))
3912 (defun gnus-group-select-group (&optional all)
3913 "Select this newsgroup.
3914 No article is selected automatically.
3915 If argument ALL is non-nil, already read articles become readable."
3917 (gnus-group-read-group all t))
3919 (defun gnus-group-select-group-all ()
3920 "Select the current group and display all articles in it."
3922 (gnus-group-select-group 'all))
3924 ;; Enter a group that is not in the group buffer. Non-nil is returned
3925 ;; if selection was successful.
3926 (defun gnus-group-read-ephemeral-group
3927 (group method &optional activate quit-config)
3928 (let ((group (if (gnus-group-foreign-p group) group
3929 (gnus-group-prefixed-name group method))))
3932 (list t nil (list group gnus-level-default-subscribed nil nil
3936 (if quit-config quit-config
3937 (cons (current-buffer) 'summary)))))))
3939 (set-buffer gnus-group-buffer)
3940 (or (gnus-check-server method)
3941 (error "Unable to contact server: %s" (gnus-status-message method)))
3942 (if activate (or (gnus-request-group group)
3943 (error "Couldn't request group")))
3945 (gnus-group-read-group t t group)
3948 (not (equal major-mode 'gnus-group-mode))))
3950 (defun gnus-group-jump-to-group (group)
3951 "Jump to newsgroup GROUP."
3953 (list (completing-read
3954 "Group: " gnus-active-hashtb nil
3955 (memq gnus-select-method gnus-have-read-active-file))))
3957 (if (equal group "")
3958 (error "Empty group name"))
3960 (let ((b (text-property-any
3961 (point-min) (point-max) 'gnus-group (intern group))))
3963 ;; Either go to the line in the group buffer...
3965 ;; ... or insert the line.
3967 (gnus-gethash group gnus-active-hashtb)
3968 (gnus-activate-group group)
3969 (error "%s error: %s" group (gnus-status-message group)))
3971 (gnus-group-update-group group)
3972 (goto-char (text-property-any
3973 (point-min) (point-max) 'gnus-group (intern group)))))
3974 ;; Adjust cursor point.
3975 (gnus-group-position-cursor))
3977 (defun gnus-group-goto-group (group)
3978 "Goto to newsgroup GROUP."
3979 (let ((b (text-property-any (point-min) (point-max)
3980 'gnus-group (intern group))))
3981 (and b (goto-char b))))
3983 (defun gnus-group-next-group (n)
3984 "Go to next N'th newsgroup.
3985 If N is negative, search backward instead.
3986 Returns the difference between N and the number of skips actually
3989 (gnus-group-next-unread-group n t))
3991 (defun gnus-group-next-unread-group (n &optional all level)
3992 "Go to next N'th unread newsgroup.
3993 If N is negative, search backward instead.
3994 If ALL is non-nil, choose any newsgroup, unread or not.
3995 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3996 such group can be found, the next group with a level higher than
3998 Returns the difference between N and the number of skips actually
4001 (let ((backward (< n 0))
4004 (gnus-group-search-forward
4005 backward (or (not gnus-group-goto-unread) all) level))
4007 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4008 (if level " on this level or higher" "")))
4011 (defun gnus-group-prev-group (n)
4012 "Go to previous N'th newsgroup.
4013 Returns the difference between N and the number of skips actually
4016 (gnus-group-next-unread-group (- n) t))
4018 (defun gnus-group-prev-unread-group (n)
4019 "Go to previous N'th unread newsgroup.
4020 Returns the difference between N and the number of skips actually
4023 (gnus-group-next-unread-group (- n)))
4025 (defun gnus-group-next-unread-group-same-level (n)
4026 "Go to next N'th unread newsgroup on the same level.
4027 If N is negative, search backward instead.
4028 Returns the difference between N and the number of skips actually
4031 (gnus-group-next-unread-group n t (gnus-group-group-level))
4032 (gnus-group-position-cursor))
4034 (defun gnus-group-prev-unread-group-same-level (n)
4035 "Go to next N'th unread newsgroup on the same level.
4036 Returns the difference between N and the number of skips actually
4039 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4040 (gnus-group-position-cursor))
4042 (defun gnus-group-best-unread-group (&optional exclude-group)
4043 "Go to the group with the highest level.
4044 If EXCLUDE-GROUP, do not go to that group."
4046 (goto-char (point-min))
4049 (while (setq unread (get-text-property (point) 'gnus-unread))
4050 (if (and (numberp unread) (> unread 0))
4052 (if (and (< (get-text-property (point) 'gnus-level) best)
4053 (or (not exclude-group)
4054 (not (equal exclude-group (gnus-group-group-name)))))
4056 (setq best (get-text-property (point) 'gnus-level))
4057 (setq best-point (point))))))
4059 (if best-point (goto-char best-point))
4060 (gnus-summary-position-cursor)
4061 (and best-point (gnus-group-group-name))))
4063 (defun gnus-group-first-unread-group ()
4064 "Go to the first group with unread articles."
4067 (let ((opoint (point))
4069 (goto-char (point-min))
4070 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
4071 (not (zerop unread)) ; Has unread articles.
4072 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
4075 nil)) ; Not success.
4076 (gnus-group-position-cursor)))
4078 (defun gnus-group-enter-server-mode ()
4079 "Jump to the server buffer."
4081 (gnus-server-setup-buffer)
4082 (gnus-configure-windows 'server)
4083 (gnus-server-prepare))
4085 (defun gnus-group-make-group (name method &optional address)
4086 "Add a new newsgroup.
4087 The user will be prompted for a NAME, for a select METHOD, and an
4091 (read-string "Group name: ")
4094 "Method: " (append gnus-valid-select-methods gnus-server-alist)
4096 (if (assoc method gnus-valid-select-methods)
4098 (if (memq 'prompt-address
4099 (assoc method gnus-valid-select-methods))
4100 (read-string "Address: ")
4102 (list method nil)))))
4104 (let* ((meth (if address (list (intern method) address) method))
4105 (nname (gnus-group-prefixed-name name meth))
4107 (and (gnus-gethash nname gnus-newsrc-hashtb)
4108 (error "Group %s already exists" nname))
4109 (gnus-group-change-level
4110 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
4111 gnus-level-default-subscribed gnus-level-killed
4112 (and (gnus-group-group-name)
4113 (gnus-gethash (gnus-group-group-name)
4114 gnus-newsrc-hashtb))
4116 (gnus-sethash nname (cons 1 0) gnus-active-hashtb)
4118 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
4119 (gnus-group-insert-group-line-info nname)
4121 (if (assoc method gnus-valid-select-methods)
4122 (require (intern method)))
4123 (and (gnus-check-backend-function 'request-create-group nname)
4124 (gnus-request-create-group nname))))
4126 (defun gnus-group-edit-group (group &optional part)
4127 "Edit the group on the current line."
4128 (interactive (list (gnus-group-group-name)))
4129 (let ((done-func '(lambda ()
4130 "Exit editing mode and update the information."
4132 (gnus-group-edit-group-done 'part 'group)))
4133 (part (or part 'info))
4134 (winconf (current-window-configuration))
4136 (or group (error "No group on current line"))
4137 (or (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4138 (error "Killed group; can't be edited"))
4139 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4140 (gnus-configure-windows 'edit-group)
4141 (gnus-add-current-to-buffer-list)
4143 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4144 (use-local-map (copy-keymap emacs-lisp-mode-map))
4145 (local-set-key "\C-c\C-c" done-func)
4146 (make-local-variable 'gnus-prev-winconf)
4147 (setq gnus-prev-winconf winconf)
4148 ;; We modify the func to let it know what part it is editing.
4149 (setcar (cdr (nth 4 done-func)) (list 'quote part))
4150 (setcar (cdr (cdr (nth 4 done-func))) group)
4155 ";; Type `C-c C-c' after editing the select method.\n\n")
4157 ";; Type `C-c C-c' after editing the group parameters.\n\n")
4159 ";; Type `C-c C-c' after editing the group info.\n\n")))
4160 (let ((cinfo (gnus-copy-sequence info))
4162 (if (not (setq marked (nth 3 cinfo)))
4165 (or (eq 'score (car (car marked)))
4166 (eq 'bookmark (car (car marked)))
4167 (eq 'killed (car (car marked)))
4168 (not (numberp (car (cdr (car marked)))))
4169 (setcdr (car marked)
4170 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
4171 (setq marked (cdr marked))))
4174 (cond ((eq part 'method)
4175 (or (nth 4 info) "native"))
4182 (defun gnus-group-edit-group-method (group)
4183 "Edit the select method of GROUP."
4184 (interactive (list (gnus-group-group-name)))
4185 (gnus-group-edit-group group 'method))
4187 (defun gnus-group-edit-group-parameters (group)
4188 "Edit the group parameters of GROUP."
4189 (interactive (list (gnus-group-group-name)))
4190 (gnus-group-edit-group group 'params))
4192 (defun gnus-group-edit-group-done (part group)
4193 "Get info from buffer, update variables and jump to the group buffer."
4194 (set-buffer (get-buffer-create gnus-group-edit-buffer))
4195 (goto-char (point-min))
4196 (let ((form (read (current-buffer)))
4197 (winconf gnus-prev-winconf))
4199 (gnus-group-set-info form)
4200 (gnus-group-set-info form group part))
4201 (kill-buffer (current-buffer))
4202 (and winconf (set-window-configuration winconf))
4203 (set-buffer gnus-group-buffer)
4204 (gnus-group-update-group (gnus-group-group-name))
4205 (gnus-group-position-cursor)))
4207 (defun gnus-group-make-help-group ()
4208 "Create the Gnus documentation group."
4210 (let ((path load-path)
4212 (and (gnus-gethash (setq name (gnus-group-prefixed-name
4213 "gnus-help" '(nndoc "gnus-help")))
4215 (error "Documentation group already exists"))
4217 (not (file-exists-p (concat (file-name-as-directory (car path))
4219 (setq path (cdr path)))
4220 (or path (error "Couldn't find doc group"))
4221 (gnus-group-make-group
4222 (gnus-group-real-name name)
4224 (list 'nndoc-address (concat (file-name-as-directory (car path)) "doc.txt"))
4225 (list 'nndoc-article-type 'mbox))))
4226 (gnus-group-position-cursor))
4228 (defun gnus-group-make-doc-group (file type)
4229 "Create a group that uses a single file as the source."
4231 (list (read-file-name "File name: ")
4235 (message "%sFile type (mbox, babyl, digest) [mbd]: " err)
4236 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
4237 ((= char ?b) 'babyl)
4238 ((= char ?d) 'digest)
4239 (t (setq err (format "%c unknown. " char))
4242 (let* ((file (expand-file-name file))
4243 (name (gnus-generate-new-group-name
4244 (gnus-group-prefixed-name
4245 (file-name-nondirectory file) '(nndoc "")))))
4246 (gnus-group-make-group
4247 (gnus-group-real-name name)
4249 (list 'nndoc-address file)
4250 (list 'nndoc-article-type type)))))
4252 (defun gnus-group-make-archive-group (&optional all)
4253 "Create the (ding) Gnus archive group of the most recent articles.
4254 Given a prefix, create a full group."
4256 (let ((group (gnus-group-prefixed-name
4257 (if all "ding.archives" "ding.recent") '(nndir ""))))
4258 (and (gnus-gethash group gnus-newsrc-hashtb)
4259 (error "Archive group already exists"))
4260 (gnus-group-make-group
4261 (gnus-group-real-name group)
4263 (if all gnus-group-archive-directory
4264 gnus-group-recent-archive-directory)))
4265 (gnus-group-position-cursor))
4267 (defun gnus-group-make-directory-group (dir)
4268 "Create an nndir group.
4269 The user will be prompted for a directory. The contents of this
4270 directory will be used as a newsgroup. The directory should contain
4271 mail messages or news articles in files that have numeric names."
4273 (list (read-file-name "Create group from directory: ")))
4274 (or (file-exists-p dir) (error "No such directory"))
4275 (or (file-directory-p dir) (error "Not a directory"))
4276 (gnus-group-make-group dir "nndir" dir)
4277 (gnus-group-position-cursor))
4279 (defun gnus-group-make-kiboze-group (group address scores)
4280 "Create an nnkiboze group.
4281 The user will be prompted for a name, a regexp to match groups, and
4282 score file entries for articles to include in the group."
4285 (read-string "nnkiboze group name: ")
4286 (read-string "Source groups (regexp): ")
4287 (let ((headers (mapcar (lambda (group) (list group))
4288 '("subject" "from" "number" "date" "message-id"
4289 "references" "chars" "lines" "xref")))
4290 scores header regexp regexps)
4291 (while (not (equal "" (setq header (completing-read
4292 "Match on header: " headers nil t))))
4294 (while (not (equal "" (setq regexp (read-string
4295 (format "Match on %s (string): "
4297 (setq regexps (cons (list regexp nil nil 'r) regexps)))
4298 (setq scores (cons (cons header regexps) scores)))
4300 (gnus-group-make-group group "nnkiboze" address)
4302 (gnus-set-work-buffer)
4303 (let (emacs-lisp-mode-hook)
4304 (pp scores (current-buffer)))
4305 (write-region (point-min) (point-max)
4306 (concat (or gnus-kill-files-directory "~/News")
4307 "nnkiboze:" group "." gnus-score-file-suffix)))
4308 (gnus-group-position-cursor))
4310 (defun gnus-group-add-to-virtual (n vgroup)
4311 "Add the current group to a virtual group."
4313 (list current-prefix-arg
4314 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
4316 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
4317 (error "%s is not an nnvirtual group" vgroup))
4318 (let* ((groups (gnus-group-process-prefix n))
4319 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
4320 (setcar (cdr method)
4322 (nth 1 method) "\\|"
4325 (gnus-group-remove-mark s)
4326 (concat "\\(^" (regexp-quote s) "$\\)"))
4328 (gnus-group-position-cursor))
4330 (defun gnus-group-make-empty-virtual (group)
4331 "Create a new, fresh, empty virtual group."
4332 (interactive "sCreate new, empty virtual group: ")
4333 (let* ((method (list 'nnvirtual "^$"))
4334 (pgroup (gnus-group-prefixed-name group method)))
4335 ;; Check whether it exists already.
4336 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
4337 (error "Group %s already exists." pgroup))
4338 ;; Subscribe the new group after the group on the current line.
4339 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
4340 (gnus-group-update-group pgroup)
4342 (gnus-group-position-cursor)))
4344 (defun gnus-group-enter-directory (dir)
4345 "Enter an ephemeral nneething group."
4346 (interactive "DDirectory to read: ")
4347 (let* ((method (list 'nneething dir))
4348 (leaf (gnus-group-prefixed-name
4349 (file-name-nondirectory (directory-file-name dir))
4351 (name (gnus-generate-new-group-name leaf)))
4352 (let ((nneething-read-only t))
4353 (or (gnus-group-read-ephemeral-group
4355 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
4357 (error "Couldn't enter %s" dir)))))
4359 ;; Group sorting commands
4360 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
4362 (defun gnus-group-sort-groups ()
4363 "Sort the group buffer using `gnus-group-sort-function'."
4365 (setq gnus-newsrc-alist
4366 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4367 (gnus-make-hashtable-from-newsrc-alist)
4368 (gnus-group-list-groups))
4370 (defun gnus-group-sort-by-alphabet (info1 info2)
4371 (string< (car info1) (car info2)))
4373 (defun gnus-group-sort-by-unread (info1 info2)
4374 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4375 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4376 (< (or (and (numberp n1) n1) 0)
4377 (or (and (numberp n2) n2) 0))))
4379 (defun gnus-group-sort-by-level (info1 info2)
4380 (< (nth 1 info1) (nth 1 info2)))
4382 ;; Group catching up.
4384 (defun gnus-group-catchup-current (&optional n all)
4385 "Mark all articles not marked as unread in current newsgroup as read.
4386 If prefix argument N is numeric, the ARG next newsgroups will be
4387 caught up. If ALL is non-nil, marked articles will also be marked as
4388 read. Cross references (Xref: header) of articles are ignored.
4389 The difference between N and actual number of newsgroups that were
4390 caught up is returned."
4392 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4396 "Do you really want to mark all articles as read? "
4397 "Mark all unread articles as read? "))))
4399 (let ((groups (gnus-group-process-prefix n))
4402 ;; Virtual groups have to be given special treatment.
4403 (let ((method (gnus-find-method-for-group (car groups))))
4404 (if (eq 'nnvirtual (car method))
4405 (nnvirtual-catchup-group
4406 (gnus-group-real-name (car groups)) (nth 1 method) all)))
4407 (gnus-group-remove-mark (car groups))
4409 (gnus-group-goto-group (car groups))
4410 (gnus-group-catchup (car groups) all))
4411 (gnus-group-update-group-line)
4412 (setq ret (1+ ret)))
4413 (setq groups (cdr groups)))
4414 (gnus-group-next-unread-group 1)
4417 (defun gnus-group-catchup-current-all (&optional n)
4418 "Mark all articles in current newsgroup as read.
4419 Cross references (Xref: header) of articles are ignored."
4421 (gnus-group-catchup-current n 'all))
4423 (defun gnus-group-catchup (group &optional all)
4424 "Mark all articles in GROUP as read.
4425 If ALL is non-nil, all articles are marked as read.
4426 The return value is the number of articles that were marked as read,
4427 or nil if no action could be taken."
4428 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4430 (marked (nth 3 (nth 2 entry))))
4431 (if (not (numberp (car entry)))
4432 (gnus-message 1 "Can't catch up; non-active group")
4433 ;; Do the updating only if the newsgroup isn't killed.
4436 (gnus-update-read-articles
4437 group (and (not all) (append (cdr (assq 'tick marked))
4438 (cdr (assq 'dormant marked))))
4439 nil (and (not all) (cdr (assq 'tick marked))))
4441 (setq marked (nth 3 (nth 2 entry)))
4442 (setcar (nthcdr 3 (nth 2 entry))
4443 (delq (assq 'dormant marked)
4444 (nth 3 (nth 2 entry)))))))
4447 (defun gnus-group-expire-articles (&optional n)
4448 "Expire all expirable articles in the current newsgroup."
4450 (let ((groups (gnus-group-process-prefix n))
4452 (or groups (error "No groups to expire"))
4454 (setq group (car groups)
4455 groups (cdr groups))
4456 (gnus-group-remove-mark group)
4457 (if (not (gnus-check-backend-function 'request-expire-articles group))
4459 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4460 (expirable (if (memq 'total-expire (nth 5 info))
4461 (cons nil (gnus-list-of-read-articles group))
4462 (assq 'expire (nth 3 info)))))
4465 (gnus-request-expire-articles
4466 (cdr expirable) group))))))))
4468 (defun gnus-group-expire-all-groups ()
4469 "Expire all expirable articles in all newsgroups."
4472 (gnus-message 5 "Expiring...")
4473 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4474 (cdr gnus-newsrc-alist))))
4475 (gnus-group-expire-articles nil)))
4476 (gnus-group-position-cursor)
4477 (gnus-message 5 "Expiring...done"))
4479 (defun gnus-group-set-current-level (n level)
4480 "Set the level of the next N groups to LEVEL."
4481 (interactive "P\nnLevel: ")
4482 (or (and (>= level 1) (<= level gnus-level-killed))
4483 (error "Illegal level: %d" level))
4484 (let ((groups (gnus-group-process-prefix n))
4487 (setq group (car groups)
4488 groups (cdr groups))
4489 (gnus-group-remove-mark group)
4490 (gnus-message 6 "Changed level of %s from %d to %d"
4491 group (gnus-group-group-level) level)
4492 (gnus-group-change-level group level
4493 (gnus-group-group-level))
4494 (gnus-group-update-group-line)))
4495 (gnus-group-position-cursor))
4497 (defun gnus-group-unsubscribe-current-group (&optional n)
4498 "Toggle subscription of the current group.
4499 If given numerical prefix, toggle the N next groups."
4501 (let ((groups (gnus-group-process-prefix n))
4504 (setq group (car groups)
4505 groups (cdr groups))
4506 (gnus-group-remove-mark group)
4507 (gnus-group-unsubscribe-group
4508 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
4509 gnus-level-default-unsubscribed
4510 gnus-level-default-subscribed))
4511 (gnus-group-update-group-line))
4512 (gnus-group-next-group 1)))
4514 (defun gnus-group-unsubscribe-group (group &optional level)
4515 "Toggle subscribe from/to unsubscribe GROUP.
4516 New newsgroup is added to .newsrc automatically."
4518 (list (completing-read
4519 "Group: " gnus-active-hashtb nil
4520 (memq gnus-select-method gnus-have-read-active-file))))
4521 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4523 ;; Toggle subscription flag.
4524 (gnus-group-change-level
4525 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4526 gnus-level-subscribed)
4527 (1+ gnus-level-subscribed)
4528 gnus-level-default-subscribed)))
4529 (gnus-group-update-group group))
4530 ((and (stringp group)
4531 (or (not (memq gnus-select-method gnus-have-read-active-file))
4532 (gnus-gethash group gnus-active-hashtb)))
4533 ;; Add new newsgroup.
4534 (gnus-group-change-level
4536 (if level level gnus-level-default-subscribed)
4537 (or (and (member group gnus-zombie-list)
4540 (and (gnus-group-group-name)
4541 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4542 (gnus-group-update-group group))
4543 (t (error "No such newsgroup: %s" group)))
4544 (gnus-group-position-cursor)))
4546 (defun gnus-group-transpose-groups (n)
4547 "Move the current newsgroup up N places.
4548 If given a negative prefix, move down instead. The difference between
4549 N and the number of steps taken is returned."
4551 (or (gnus-group-group-name)
4552 (error "No group on current line"))
4553 (gnus-group-kill-group 1)
4555 (forward-line (- n))
4556 (gnus-group-yank-group)
4557 (gnus-group-position-cursor)))
4559 (defun gnus-group-kill-all-zombies ()
4560 "Kill all zombie newsgroups."
4562 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4563 (setq gnus-zombie-list nil)
4564 (gnus-group-list-groups))
4566 (defun gnus-group-kill-region (begin end)
4567 "Kill newsgroups in current region (excluding current point).
4568 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4583 (beginning-of-line) ;Important when LINES < 1
4584 (gnus-group-kill-group lines)))
4586 (defun gnus-group-kill-group (&optional n)
4587 "The the next N groups.
4588 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4589 However, only groups that were alive can be yanked; already killed
4590 groups or zombie groups can't be yanked.
4591 The return value is the name of the (last) group that was killed."
4593 (let ((buffer-read-only nil)
4594 (groups (gnus-group-process-prefix n))
4597 (setq group (car groups)
4598 groups (cdr groups))
4599 (gnus-group-remove-mark group)
4600 (setq level (gnus-group-group-level))
4602 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4603 (setq gnus-list-of-killed-groups
4604 (cons (cons (car entry) (nth 2 entry))
4605 gnus-list-of-killed-groups)))
4606 (gnus-group-change-level
4607 (if entry entry group) gnus-level-killed (if entry nil level)))
4608 (gnus-group-position-cursor)
4611 (defun gnus-group-yank-group (&optional arg)
4612 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4613 inserting it before the current newsgroup. The numeric ARG specifies
4614 how many newsgroups are to be yanked. The name of the (last)
4615 newsgroup yanked is returned."
4617 (if (not arg) (setq arg 1))
4618 (let (info group prev)
4619 (while (>= (setq arg (1- arg)) 0)
4620 (if (not (setq info (car gnus-list-of-killed-groups)))
4621 (error "No more newsgroups to yank"))
4622 (setq group (nth 2 info))
4623 ;; Find which newsgroup to insert this one before - search
4624 ;; backward until something suitable is found. If there are no
4625 ;; other newsgroups in this buffer, just make this newsgroup the
4627 (setq prev (gnus-group-group-name))
4628 (gnus-group-change-level
4629 info (nth 2 info) gnus-level-killed
4630 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4632 (gnus-group-insert-group-line-info (nth 1 info))
4633 (setq gnus-list-of-killed-groups
4634 (cdr gnus-list-of-killed-groups)))
4636 (gnus-group-position-cursor)
4639 (defun gnus-group-list-all-groups (&optional arg)
4640 "List all newsgroups with level ARG or lower.
4641 Default is gnus-level-unsubscribed, which lists all subscribed and most
4642 unsubscribed groups."
4644 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
4646 (defun gnus-group-list-killed ()
4647 "List all killed newsgroups in the group buffer."
4649 (if (not gnus-killed-list)
4650 (gnus-message 6 "No killed groups")
4651 (let (gnus-group-list-mode)
4652 (funcall gnus-group-prepare-function
4653 gnus-level-killed t gnus-level-killed))
4654 (goto-char (point-min)))
4655 (gnus-group-position-cursor))
4657 (defun gnus-group-list-zombies ()
4658 "List all zombie newsgroups in the group buffer."
4660 (if (not gnus-zombie-list)
4661 (gnus-message 6 "No zombie groups")
4662 (let (gnus-group-list-mode)
4663 (funcall gnus-group-prepare-function
4664 gnus-level-zombie t gnus-level-zombie))
4665 (goto-char (point-min)))
4666 (gnus-group-position-cursor))
4668 (defun gnus-group-get-new-news (&optional arg)
4669 "Get newly arrived articles.
4670 If ARG is non-nil, it should be a number between one and nine to
4671 specify which levels you are interested in re-scanning."
4673 (run-hooks 'gnus-get-new-news-hook)
4674 (setq arg (gnus-group-default-level arg t))
4675 (if (and gnus-read-active-file (not arg))
4677 (gnus-read-active-file)
4678 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4679 (let ((gnus-read-active-file (not arg))
4680 (gnus-have-read-active-file
4681 (and (not arg) gnus-have-read-active-file)))
4682 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4683 (gnus-group-list-groups))
4685 (defun gnus-group-get-new-news-this-group (&optional n)
4686 "Check for newly arrived news in the current group (and the N-1 next groups).
4687 The difference between N and the number of newsgroup checked is returned.
4688 If N is negative, this group and the N-1 previous groups will be checked."
4690 (let* ((groups (gnus-group-process-prefix n))
4691 (ret (if (numberp n) (- n (length groups)) 0))
4694 (setq group (car groups)
4695 groups (cdr groups))
4696 (gnus-group-remove-mark group)
4697 (or (gnus-get-new-news-in-group group)
4700 (message "%s error: %s" group (gnus-status-message group))
4702 (gnus-group-next-unread-group 1 t)
4703 (gnus-summary-position-cursor)
4706 (defun gnus-get-new-news-in-group (group)
4708 (gnus-activate-group group)
4710 (gnus-get-unread-articles-in-group
4711 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4712 (gnus-gethash group gnus-active-hashtb))
4713 (gnus-group-update-group-line)
4716 (defun gnus-group-fetch-faq (group)
4717 "Fetch the FAQ for the current group."
4718 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4719 (or group (error "No group name given"))
4720 (let ((file (concat gnus-group-faq-directory (gnus-group-real-name group))))
4721 (if (not (file-exists-p file))
4722 (error "No such file: %s" file)
4725 (defun gnus-group-describe-group (force &optional group)
4726 "Display a description of the current newsgroup."
4727 (interactive (list current-prefix-arg (gnus-group-group-name)))
4728 (and force (setq gnus-description-hashtb nil))
4729 (let ((method (gnus-find-method-for-group group))
4731 (or group (error "No group name given"))
4732 (and (or (and gnus-description-hashtb
4733 ;; We check whether this group's method has been
4734 ;; queried for a description file.
4736 (gnus-group-prefixed-name "" method)
4737 gnus-description-hashtb))
4738 (setq desc (gnus-group-get-description group))
4739 (gnus-read-descriptions-file method))
4741 (or desc (gnus-gethash group gnus-description-hashtb)
4742 "No description available")))))
4744 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4745 (defun gnus-group-describe-all-groups (&optional force)
4746 "Pop up a buffer with descriptions of all newsgroups."
4748 (and force (setq gnus-description-hashtb nil))
4749 (if (not (or gnus-description-hashtb
4750 (gnus-read-all-descriptions-files)))
4751 (error "Couldn't request descriptions file"))
4752 (let ((buffer-read-only nil)
4758 (insert (format " *: %-20s %s\n" (symbol-name group)
4759 (symbol-value group)))
4760 (add-text-properties
4761 b (1+ b) (list 'gnus-group group
4762 'gnus-unread t 'gnus-marked nil
4763 'gnus-level (1+ gnus-level-subscribed))))
4764 gnus-description-hashtb)
4765 (goto-char (point-min))
4766 (gnus-group-position-cursor)))
4768 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4769 (defun gnus-group-apropos (regexp &optional search-description)
4770 "List all newsgroups that have names that match a regexp."
4771 (interactive "sGnus apropos (regexp): ")
4773 (obuf (current-buffer))
4775 ;; Go through all newsgroups that are known to Gnus.
4778 (and (symbol-name group)
4779 (string-match regexp (symbol-name group))
4780 (setq groups (cons (symbol-name group) groups))))
4782 ;; Go through all descriptions that are known to Gnus.
4783 (if search-description
4786 (and (string-match regexp (symbol-value group))
4787 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4788 (setq groups (cons (symbol-name group) groups))))
4789 gnus-description-hashtb))
4791 (gnus-message 3 "No groups matched \"%s\"." regexp)
4792 ;; Print out all the groups.
4794 (pop-to-buffer "*Gnus Help*")
4795 (buffer-disable-undo (current-buffer))
4797 (setq groups (sort groups 'string<))
4799 ;; Groups may be entered twice into the list of groups.
4800 (if (not (string= (car groups) prev))
4802 (insert (setq prev (car groups)) "\n")
4803 (if (and gnus-description-hashtb
4804 (setq des (gnus-gethash (car groups)
4805 gnus-description-hashtb)))
4806 (insert " " des "\n"))))
4807 (setq groups (cdr groups)))
4808 (goto-char (point-min))))
4809 (pop-to-buffer obuf)))
4811 (defun gnus-group-description-apropos (regexp)
4812 "List all newsgroups that have names or descriptions that match a regexp."
4813 (interactive "sGnus description apropos (regexp): ")
4814 (if (not (or gnus-description-hashtb
4815 (gnus-read-all-descriptions-files)))
4816 (error "Couldn't request descriptions file"))
4817 (gnus-group-apropos regexp t))
4819 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4820 (defun gnus-group-list-matching (level regexp &optional all lowest)
4821 "List all groups with unread articles that match REGEXP.
4822 If the prefix LEVEL is non-nil, it should be a number that says which
4823 level to cut off listing groups.
4824 If ALL, also list groups with no unread articles.
4825 If LOWEST, don't list groups with level lower than LOWEST."
4826 (interactive "P\nsList newsgroups matching: ")
4827 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4828 all (or lowest 1) regexp)
4829 (goto-char (point-min))
4830 (gnus-group-position-cursor))
4832 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4833 "List all groups that match REGEXP.
4834 If the prefix LEVEL is non-nil, it should be a number that says which
4835 level to cut off listing groups.
4836 If LOWEST, don't list groups with level lower than LOWEST."
4837 (interactive "P\nsList newsgroups matching: ")
4838 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4840 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4841 (defun gnus-group-save-newsrc ()
4842 "Save the Gnus startup files."
4844 (gnus-save-newsrc-file))
4846 (defun gnus-group-restart (&optional arg)
4847 "Force Gnus to read the .newsrc file."
4849 (gnus-save-newsrc-file)
4850 (gnus-setup-news 'force)
4851 (gnus-group-list-groups arg))
4853 (defun gnus-group-read-init-file ()
4854 "Read the Gnus elisp init file."
4856 (gnus-read-init-file))
4858 (defun gnus-group-check-bogus-groups (&optional silent)
4859 "Check bogus newsgroups.
4860 If given a prefix, don't ask for confirmation before removing a bogus
4863 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
4864 (gnus-group-list-groups))
4866 (defun gnus-group-edit-global-kill (&optional article group)
4867 "Edit the global kill file.
4868 If GROUP, edit that local kill file instead."
4870 (setq gnus-current-kill-article article)
4871 (gnus-kill-file-edit-file group)
4873 (substitute-command-keys
4874 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4876 (defun gnus-group-edit-local-kill (article group)
4877 "Edit a local kill file."
4878 (interactive (list nil (gnus-group-group-name)))
4879 (gnus-group-edit-global-kill article group))
4881 (defun gnus-group-force-update ()
4882 "Update `.newsrc' file."
4884 (gnus-save-newsrc-file))
4886 (defun gnus-group-suspend ()
4887 "Suspend the current Gnus session.
4888 In fact, cleanup buffers except for group mode buffer.
4889 The hook gnus-suspend-gnus-hook is called before actually suspending."
4891 (run-hooks 'gnus-suspend-gnus-hook)
4892 ;; Kill Gnus buffers except for group mode buffer.
4893 (let ((group-buf (get-buffer gnus-group-buffer)))
4894 ;; Do this on a separate list in case the user does a ^G before we finish
4895 (let ((gnus-buffer-list
4896 (delq group-buf (delq gnus-dribble-buffer
4897 (append gnus-buffer-list nil)))))
4898 (while gnus-buffer-list
4899 (gnus-kill-buffer (car gnus-buffer-list))
4900 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4903 (setq gnus-buffer-list (list group-buf))
4904 (bury-buffer group-buf)
4905 (delete-windows-on group-buf t)))))
4907 (defun gnus-group-clear-dribble ()
4908 "Clear all information from the dribble buffer."
4910 (gnus-dribble-clear))
4912 (defun gnus-group-exit ()
4913 "Quit reading news after updating .newsrc.eld and .newsrc.
4914 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4916 (if (or noninteractive ;For gnus-batch-kill
4917 (zerop (buffer-size)) ;No news is good news.
4918 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4919 (not gnus-interactive-exit) ;Without confirmation
4921 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4923 (run-hooks 'gnus-exit-gnus-hook)
4924 ;; Offer to save data from non-quitted summary buffers.
4925 (gnus-offer-save-summaries)
4926 ;; Save the newsrc file(s).
4927 (gnus-save-newsrc-file)
4929 (gnus-close-backends)
4930 ;; Reset everything.
4931 (gnus-clear-system))))
4933 (defun gnus-close-backends ()
4934 ;; Send a close request to all backends that support such a request.
4935 (let ((methods gnus-valid-select-methods)
4938 (if (fboundp (setq func (intern (concat (car (car methods))
4939 "-request-close"))))
4941 (setq methods (cdr methods)))))
4943 (defun gnus-group-quit ()
4944 "Quit reading news without updating .newsrc.eld or .newsrc.
4945 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4947 (if (or noninteractive ;For gnus-batch-kill
4948 (zerop (buffer-size))
4949 (not (gnus-server-opened gnus-select-method))
4951 (not gnus-current-startup-file)
4953 (format "Quit reading news without saving %s? "
4954 (file-name-nondirectory gnus-current-startup-file))))
4956 (run-hooks 'gnus-exit-gnus-hook)
4957 (if gnus-use-full-window
4958 (delete-other-windows)
4959 (gnus-remove-some-windows))
4961 (gnus-close-backends)
4962 (gnus-clear-system))))
4964 (defun gnus-offer-save-summaries ()
4966 (let ((buflist (buffer-list))
4969 (and (setq bufname (buffer-name (car buflist)))
4970 (string-match "Summary" bufname)
4972 (set-buffer bufname)
4973 ;; We check that this is, indeed, a summary buffer.
4974 (eq major-mode 'gnus-summary-mode))
4975 (setq buffers (cons bufname buffers)))
4976 (setq buflist (cdr buflist)))
4979 "Update summary buffer %s? "
4982 (gnus-summary-exit))
4985 (defun gnus-group-describe-briefly ()
4986 "Give a one line description of the group mode commands."
4988 (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")))
4990 (defun gnus-group-browse-foreign-server (method)
4991 "Browse a foreign news server.
4992 If called interactively, this function will ask for a select method
4993 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4994 If not, METHOD should be a list where the first element is the method
4995 and the second element is the address."
4997 (list (let ((how (completing-read
4999 (append gnus-valid-select-methods gnus-server-alist)
5001 ;; We either got a backend name or a virtual server name.
5002 ;; If the first, we also need an address.
5003 (if (assoc how gnus-valid-select-methods)
5005 ;; Suggested by mapjph@bath.ac.uk.
5008 (mapcar (lambda (server) (list server))
5009 gnus-secondary-servers)))
5010 ;; We got a server name, so we find the method.
5011 (gnus-server-to-method how)))))
5012 (gnus-browse-foreign-server method))
5016 ;;; Browse Server Mode
5019 (defvar gnus-browse-mode-hook nil)
5020 (defvar gnus-browse-mode-map nil)
5021 (put 'gnus-browse-mode 'mode-class 'special)
5023 (if gnus-browse-mode-map
5025 (setq gnus-browse-mode-map (make-keymap))
5026 (suppress-keymap gnus-browse-mode-map)
5027 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
5028 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
5029 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
5030 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
5031 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
5032 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
5033 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
5034 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
5035 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
5036 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
5037 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
5038 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
5039 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
5040 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
5041 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
5042 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
5043 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
5044 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
5047 (defvar gnus-browse-current-method nil)
5048 (defvar gnus-browse-return-buffer nil)
5050 (defvar gnus-browse-buffer "*Gnus Browse Server*")
5052 (defun gnus-browse-foreign-server (method &optional return-buffer)
5053 (setq gnus-browse-current-method method)
5054 (setq gnus-browse-return-buffer return-buffer)
5055 (let ((gnus-select-method method)
5057 (gnus-message 5 "Connecting to %s..." (nth 1 method))
5058 (or (gnus-check-server method)
5059 (error "Unable to contact server: %s" (gnus-status-message method)))
5060 (or (gnus-request-list method)
5061 (error "Couldn't request list: %s" (gnus-status-message method)))
5062 (get-buffer-create gnus-browse-buffer)
5063 (gnus-add-current-to-buffer-list)
5064 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
5065 (gnus-configure-windows 'browse)
5066 (buffer-disable-undo (current-buffer))
5067 (let ((buffer-read-only nil))
5070 (setq mode-line-buffer-identification
5072 "Gnus Browse Server {%s:%s}" (car method) (car (cdr method))))
5074 (set-buffer nntp-server-buffer)
5075 (let ((cur (current-buffer)))
5076 (goto-char (point-min))
5077 (or (string= gnus-ignored-newsgroups "")
5078 (delete-matching-lines gnus-ignored-newsgroups))
5079 (while (re-search-forward
5080 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
5081 (goto-char (match-end 1))
5082 (setq groups (cons (cons (buffer-substring (match-beginning 1)
5084 (max 0 (- (1+ (read cur)) (read cur))))
5086 (setq groups (sort groups
5088 (string< (car l1) (car l2)))))
5089 (let ((buffer-read-only nil))
5091 (setq group (car groups))
5093 (format "K%7d: %s\n" (cdr group) (car group)))
5094 (setq groups (cdr groups))))
5095 (switch-to-buffer (current-buffer))
5096 (goto-char (point-min))
5097 (gnus-group-position-cursor)))
5099 (defun gnus-browse-mode ()
5100 "Major mode for browsing a foreign server.
5102 All normal editing commands are switched off.
5104 \\<gnus-browse-mode-map>
5105 The only things you can do in this buffer is
5107 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
5108 The group will be inserted into the group buffer upon exit from this
5111 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
5113 3) `\\[gnus-browse-exit]' to return to the group buffer."
5115 (kill-all-local-variables)
5116 (if gnus-visual (gnus-browse-make-menu-bar))
5117 (setq mode-line-modified "-- ")
5118 (make-local-variable 'mode-line-format)
5119 (setq mode-line-format (copy-sequence mode-line-format))
5120 (and (equal (nth 3 mode-line-format) " ")
5121 (setcar (nthcdr 3 mode-line-format) ""))
5122 (setq major-mode 'gnus-browse-mode)
5123 (setq mode-name "Browse Server")
5124 (setq mode-line-process nil)
5125 (use-local-map gnus-browse-mode-map)
5126 (buffer-disable-undo (current-buffer))
5127 (setq truncate-lines t)
5128 (setq buffer-read-only t)
5129 (run-hooks 'gnus-browse-mode-hook))
5131 (defun gnus-browse-read-group (&optional no-article)
5132 "Enter the group at the current line."
5134 (let ((group (gnus-browse-group-name)))
5135 (or (gnus-group-read-ephemeral-group
5136 group gnus-browse-current-method nil
5137 (cons (current-buffer) 'browse))
5138 (error "Couldn't enter %s" group))))
5140 (defun gnus-browse-select-group ()
5141 "Select the current group."
5143 (gnus-browse-read-group 'no))
5145 (defun gnus-browse-next-group (n)
5146 "Go to the next group."
5150 (gnus-group-position-cursor)))
5152 (defun gnus-browse-prev-group (n)
5153 "Go to the next group."
5155 (gnus-browse-next-group (- n)))
5157 (defun gnus-browse-unsubscribe-current-group (arg)
5158 "(Un)subscribe to the next ARG groups."
5161 (error "No group at current line."))
5162 (let ((ward (if (< arg 0) -1 1))
5164 (while (and (> arg 0)
5166 (gnus-browse-unsubscribe-group)
5167 (zerop (gnus-browse-next-group ward)))
5168 (setq arg (1- arg)))
5169 (gnus-group-position-cursor)
5170 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
5173 (defun gnus-browse-group-name ()
5176 (if (not (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t))
5178 (gnus-group-prefixed-name
5179 (buffer-substring (match-beginning 1) (match-end 1))
5180 gnus-browse-current-method))))
5182 (defun gnus-browse-unsubscribe-group ()
5184 (buffer-read-only nil)
5188 (if (= (following-char) ?K) (setq sub t))
5189 (setq group (gnus-browse-group-name))
5194 (gnus-group-change-level
5195 (list t group gnus-level-default-subscribed
5196 nil nil gnus-browse-current-method)
5197 gnus-level-default-subscribed gnus-level-killed
5198 (and (car (nth 1 gnus-newsrc-alist))
5199 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
5200 gnus-newsrc-hashtb))
5203 (gnus-group-change-level
5204 group gnus-level-killed gnus-level-default-subscribed)
5208 (defun gnus-browse-exit ()
5209 "Quit browsing and return to the group buffer."
5211 (if (eq major-mode 'gnus-browse-mode)
5212 (kill-buffer (current-buffer)))
5213 (if gnus-browse-return-buffer
5214 (gnus-configure-windows 'server 'force)
5215 (gnus-configure-windows 'group 'force)
5216 (gnus-group-list-groups nil)))
5218 (defun gnus-browse-describe-briefly ()
5219 "Give a one line description of the group mode commands."
5222 (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")))
5226 ;;; Gnus summary mode
5229 (defvar gnus-summary-mode-map nil)
5230 (defvar gnus-summary-mark-map nil)
5231 (defvar gnus-summary-mscore-map nil)
5232 (defvar gnus-summary-article-map nil)
5233 (defvar gnus-summary-thread-map nil)
5234 (defvar gnus-summary-goto-map nil)
5235 (defvar gnus-summary-exit-map nil)
5236 (defvar gnus-summary-interest-map nil)
5237 (defvar gnus-summary-sort-map nil)
5238 (defvar gnus-summary-backend-map nil)
5239 (defvar gnus-summary-save-map nil)
5240 (defvar gnus-summary-wash-map nil)
5241 (defvar gnus-summary-wash-hide-map nil)
5242 (defvar gnus-summary-wash-highlight-map nil)
5243 (defvar gnus-summary-wash-time-map nil)
5244 (defvar gnus-summary-help-map nil)
5246 (put 'gnus-summary-mode 'mode-class 'special)
5248 (if gnus-summary-mode-map
5250 (setq gnus-summary-mode-map (make-keymap))
5251 (suppress-keymap gnus-summary-mode-map)
5253 ;; Non-orthogonal keys
5255 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
5256 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
5257 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
5258 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
5259 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
5260 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
5261 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
5262 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
5263 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
5264 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
5265 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
5266 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
5267 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
5268 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
5269 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
5270 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
5271 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
5272 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
5273 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
5274 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
5275 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
5276 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
5277 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
5278 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
5279 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
5280 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
5281 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
5282 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
5283 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
5284 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
5285 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
5286 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
5287 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
5288 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
5289 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
5290 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
5291 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
5292 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
5293 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
5294 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
5295 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
5296 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
5297 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
5298 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
5299 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
5300 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
5301 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
5302 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
5303 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
5304 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
5305 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
5306 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
5307 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
5308 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
5309 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
5310 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
5311 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
5312 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
5313 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
5314 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
5315 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
5316 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
5317 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
5318 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
5319 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
5320 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
5321 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
5322 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
5323 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
5324 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
5325 (define-key gnus-summary-mode-map "V" 'gnus-version)
5326 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
5327 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
5328 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
5329 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
5330 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
5331 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
5332 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
5333 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
5334 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
5335 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
5336 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
5337 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
5338 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
5339 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
5340 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
5341 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
5342 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
5343 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
5346 ;; Sort of orthogonal keymap
5347 (define-prefix-command 'gnus-summary-mark-map)
5348 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
5349 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
5350 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
5351 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
5352 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
5353 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
5354 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
5355 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
5356 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
5357 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
5358 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
5359 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
5360 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
5361 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
5362 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
5363 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
5364 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
5365 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
5366 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
5367 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
5368 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
5369 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
5370 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
5371 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
5373 (define-prefix-command 'gnus-summary-mscore-map)
5374 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
5375 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
5376 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
5377 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
5378 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
5380 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
5382 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
5384 (define-prefix-command 'gnus-summary-goto-map)
5385 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
5386 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
5387 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
5388 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
5389 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
5390 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
5391 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
5392 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
5393 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
5394 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
5395 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
5396 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
5397 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
5398 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
5401 (define-prefix-command 'gnus-summary-thread-map)
5402 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
5403 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
5404 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
5405 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
5406 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
5407 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
5408 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
5409 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
5410 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
5411 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
5412 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
5413 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
5414 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
5415 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
5418 (define-prefix-command 'gnus-summary-exit-map)
5419 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
5420 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
5421 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
5422 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
5423 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
5424 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
5425 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
5426 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
5427 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
5428 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
5429 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
5432 (define-prefix-command 'gnus-summary-article-map)
5433 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
5434 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
5435 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
5436 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
5437 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
5438 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
5439 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
5440 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
5441 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
5442 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5443 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5444 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5445 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5446 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5450 (define-prefix-command 'gnus-summary-wash-map)
5451 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5453 (define-prefix-command 'gnus-summary-wash-hide-map)
5454 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
5455 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
5456 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
5457 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
5458 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
5459 (define-key gnus-summary-wash-hide-map "\C-c" 'gnus-article-hide-citation-maybe)
5461 (define-prefix-command 'gnus-summary-wash-highlight-map)
5462 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
5463 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
5464 (define-key gnus-summary-wash-highlight-map "h" 'gnus-article-highlight-headers)
5465 (define-key gnus-summary-wash-highlight-map "c" 'gnus-article-highlight-citation)
5466 (define-key gnus-summary-wash-highlight-map "s" 'gnus-article-highlight-signature)
5468 (define-prefix-command 'gnus-summary-wash-time-map)
5469 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
5470 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
5471 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
5472 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
5473 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
5475 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5476 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5477 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5478 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
5479 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5480 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5481 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
5482 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
5483 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
5484 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
5487 (define-prefix-command 'gnus-summary-help-map)
5488 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5489 (define-key gnus-summary-help-map "v" 'gnus-version)
5490 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5491 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5492 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5493 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5496 (define-prefix-command 'gnus-summary-backend-map)
5497 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5498 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5499 (define-key gnus-summary-backend-map "\M-\C-e"
5500 'gnus-summary-expire-articles-now)
5501 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5502 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5503 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5504 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5505 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5506 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
5507 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
5510 (define-prefix-command 'gnus-summary-save-map)
5511 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5512 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5513 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5514 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5515 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5516 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5517 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5518 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5519 ; (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
5521 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5523 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
5524 ; (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5525 ; (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5526 ; (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5527 ; (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5528 ; (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5529 ; (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5530 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
5531 ; (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5532 ; (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5534 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
5536 ; (define-prefix-command 'gnus-summary-sort-map)
5537 ; (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5538 ; (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5539 ; (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5540 ; (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5541 ; (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5542 ; (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5544 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
5545 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5551 (defun gnus-summary-mode (&optional group)
5552 "Major mode for reading articles.
5554 All normal editing commands are switched off.
5555 \\<gnus-summary-mode-map>
5556 Each line in this buffer represents one article. To read an
5557 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5558 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5561 You can also post articles and send mail from this buffer. To
5562 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5563 of an article, type `\\[gnus-summary-reply]'.
5565 There are approx. one gazillion commands you can execute in this
5566 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5568 The following commands are available:
5570 \\{gnus-summary-mode-map}"
5572 (if gnus-visual (gnus-summary-make-menu-bar))
5573 (kill-all-local-variables)
5574 (let ((locals gnus-summary-local-variables))
5576 (if (consp (car locals))
5578 (make-local-variable (car (car locals)))
5579 (set (car (car locals)) (eval (cdr (car locals)))))
5580 (make-local-variable (car locals))
5581 (set (car locals) nil))
5582 (setq locals (cdr locals))))
5583 (gnus-make-thread-indent-array)
5584 (setq mode-line-modified "-- ")
5585 (make-local-variable 'mode-line-format)
5586 (setq mode-line-format (copy-sequence mode-line-format))
5587 (and (equal (nth 3 mode-line-format) " ")
5588 (setcar (nthcdr 3 mode-line-format) ""))
5589 (setq major-mode 'gnus-summary-mode)
5590 (setq mode-name "Summary")
5591 (make-local-variable 'minor-mode-alist)
5592 (use-local-map gnus-summary-mode-map)
5593 (buffer-disable-undo (current-buffer))
5594 (setq buffer-read-only t) ;Disable modification
5595 (setq truncate-lines t)
5596 (setq selective-display t)
5597 (setq selective-display-ellipses t) ;Display `...'
5598 (setq buffer-display-table gnus-summary-display-table)
5599 (setq gnus-newsgroup-name group)
5600 (run-hooks 'gnus-summary-mode-hook))
5602 (defun gnus-summary-make-display-table ()
5603 ;; Change the display table. Odd characters have a tendency to mess
5604 ;; up nicely formatted displays - we make all possible glyphs
5605 ;; display only a single character.
5607 ;; We start from the standard display table, if any.
5608 (setq gnus-summary-display-table
5609 (or (copy-sequence standard-display-table)
5610 (make-display-table)))
5611 ;; Nix out all the control chars...
5613 (while (>= (setq i (1- i)) 0)
5614 (aset gnus-summary-display-table i [??])))
5615 ;; ... but not newline and cr, of course. (cr is necessary for the
5616 ;; selective display).
5617 (aset gnus-summary-display-table ?\n nil)
5618 (aset gnus-summary-display-table ?\r nil)
5619 ;; We nix out any glyphs over 126 that are not set already.
5621 (while (>= (setq i (1- i)) 127)
5622 ;; Only modify if the entry is nil.
5623 (or (aref gnus-summary-display-table i)
5624 (aset gnus-summary-display-table i [??])))))
5626 (defun gnus-summary-clear-local-variables ()
5627 (let ((locals gnus-summary-local-variables))
5629 (if (consp (car locals))
5630 (and (vectorp (car (car locals)))
5631 (set (car (car locals)) nil))
5632 (and (vectorp (car locals))
5633 (set (car locals) nil)))
5634 (setq locals (cdr locals)))))
5636 ;; Some summary mode macros.
5638 ;; Return a header specified by a NUMBER.
5639 (defun gnus-get-header-by-number (number)
5641 (set-buffer gnus-summary-buffer)
5642 (or gnus-newsgroup-headers-hashtb-by-number
5643 (gnus-make-headers-hashtable-by-number))
5644 (gnus-gethash (int-to-string number)
5645 gnus-newsgroup-headers-hashtb-by-number)))
5647 ;; Fast version of the function above.
5648 (defmacro gnus-get-header-by-num (number)
5649 (` (gnus-gethash (int-to-string (, number))
5650 gnus-newsgroup-headers-hashtb-by-number)))
5652 (defmacro gnus-summary-search-forward (&optional unread subject backward)
5653 "Search for article forward.
5654 If UNREAD is non-nil, only unread articles are selected.
5655 If SUBJECT is non-nil, the article which has the same subject will be
5657 If BACKWARD is non-nil, the search will be performed backwards instead."
5658 (` (gnus-summary-search-subject (, backward) (, unread) (, subject))))
5660 (defmacro gnus-summary-search-backward (&optional unread subject)
5661 "Search for article backward.
5662 If 1st optional argument UNREAD is non-nil, only unread article is selected.
5663 If 2nd optional argument SUBJECT is non-nil, the article which has
5664 the same subject will be searched for."
5665 (` (gnus-summary-search-forward (, unread) (, subject) t)))
5667 (defmacro gnus-summary-article-number (&optional number-or-nil)
5668 "The article number of the article on the current line.
5669 If there isn's an article number here, then we return the current
5672 '(get-text-property (gnus-point-at-bol) 'gnus-number)
5673 '(or (get-text-property (gnus-point-at-bol) 'gnus-number)
5674 gnus-current-article)))
5676 (defmacro gnus-summary-thread-level ()
5677 "The thread level of the article on the current line."
5678 '(or (get-text-property (gnus-point-at-bol) 'gnus-level)
5681 (defmacro gnus-summary-article-mark ()
5682 "The mark on the current line."
5683 '(get-text-property (gnus-point-at-bol) 'gnus-mark))
5685 (defun gnus-summary-subject-string ()
5686 "Return current subject string or nil if nothing."
5687 (let ((article (gnus-summary-article-number))
5690 (setq header (gnus-get-header-by-num article))
5692 (mail-header-subject header))))
5694 ;; Various summary mode internalish functions.
5696 (defun gnus-mouse-pick-article (e)
5699 (gnus-summary-next-page nil t))
5701 (defun gnus-summary-setup-buffer (group)
5702 "Initialize summary buffer."
5703 (let ((buffer (concat "*Summary " group "*")))
5704 (if (get-buffer buffer)
5707 (not gnus-newsgroup-begin))
5708 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5709 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5710 (gnus-add-current-to-buffer-list)
5711 (gnus-summary-mode group)
5712 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5713 (setq gnus-newsgroup-name group)
5716 (defun gnus-set-global-variables ()
5717 ;; Set the global equivalents of the summary buffer-local variables
5718 ;; to the latest values they had. These reflect the summary buffer
5719 ;; that was in action when the last article was fetched.
5720 (if (eq major-mode 'gnus-summary-mode)
5722 (setq gnus-summary-buffer (current-buffer))
5723 (let ((name gnus-newsgroup-name)
5724 (marked gnus-newsgroup-marked)
5725 (unread gnus-newsgroup-unreads)
5726 (headers gnus-current-headers)
5727 (score-file gnus-current-score-file))
5729 (set-buffer gnus-group-buffer)
5730 (setq gnus-newsgroup-name name)
5731 (setq gnus-newsgroup-marked marked)
5732 (setq gnus-newsgroup-unreads unread)
5733 (setq gnus-current-headers headers)
5734 (setq gnus-current-score-file score-file))))))
5736 (defun gnus-summary-insert-dummy-line (sformat subject number)
5738 (setq sformat gnus-summary-dummy-line-format-spec))
5742 (insert (eval sformat))
5743 (add-text-properties
5745 (list 'gnus-number number
5746 'gnus-mark gnus-dummy-mark
5749 (defvar gnus-thread-indent-array nil)
5750 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5751 (defun gnus-make-thread-indent-array ()
5753 (if (and gnus-thread-indent-array
5754 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5756 (setq gnus-thread-indent-array (make-vector 201 "")
5757 gnus-thread-indent-array-level gnus-thread-indent-level)
5759 (aset gnus-thread-indent-array n
5760 (make-string (* n gnus-thread-indent-level) ? ))
5763 (defun gnus-summary-insert-line
5764 (sformat header level current unread replied expirable subject-or-nil
5765 &optional dummy score)
5766 (or sformat (setq sformat gnus-summary-line-format-spec))
5767 (let* ((indentation (aref gnus-thread-indent-array level))
5768 (lines (mail-header-lines header))
5769 (score (or score gnus-summary-default-score 0))
5771 (if (or (null gnus-summary-default-score)
5772 (<= (abs (- score gnus-summary-default-score))
5773 gnus-summary-zcore-fuzz)) ?
5774 (if (< score gnus-summary-default-score)
5775 gnus-score-below-mark gnus-score-over-mark)))
5776 (replied (if replied gnus-replied-mark ? ))
5777 (from (mail-header-from header))
5779 ((string-match "(.+)" from)
5780 (substring from (1+ (match-beginning 0)) (1- (match-end 0))))
5781 ((string-match "<[^>]+> *$" from)
5782 (let ((beg (match-beginning 0)))
5783 (or (and (string-match "^\"[^\"]*\"" from)
5784 (substring from (1+ (match-beginning 0))
5785 (1- (match-end 0))))
5786 (substring from 0 beg))))
5788 (subject (mail-header-subject header))
5789 (number (mail-header-number header))
5790 (opening-bracket (if dummy ?\< ?\[))
5791 (closing-bracket (if dummy ?\> ?\]))
5792 (buffer-read-only nil)
5793 (b (progn (beginning-of-line) (point))))
5794 (or (numberp lines) (setq lines 0))
5795 (insert (eval sformat))
5796 (add-text-properties
5797 b (1+ b) (list 'gnus-number number
5798 'gnus-mark (or unread gnus-unread-mark)
5799 'gnus-level level))))
5801 (defun gnus-summary-update-line (&optional dont-update)
5802 ;; Update summary line after change.
5803 (or (not gnus-summary-default-score)
5804 gnus-summary-inhibit-highlight
5805 (let ((gnus-summary-inhibit-highlight t)
5806 (article (gnus-summary-article-number)))
5809 (if (and gnus-summary-mark-below
5810 (< (gnus-summary-article-score)
5811 gnus-summary-mark-below))
5812 (and (not (memq article gnus-newsgroup-marked))
5813 (not (memq article gnus-newsgroup-dormant))
5814 (memq article gnus-newsgroup-unreads)
5815 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5816 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5817 (gnus-summary-mark-article-as-unread gnus-unread-mark))))
5819 (run-hooks 'gnus-summary-update-hook))))))
5821 (defun gnus-summary-update-lines (&optional beg end)
5822 ;; Mark article as read (or not) by taking into account scores.
5823 (let ((beg (or beg (point-min)))
5824 (end (or end (point-max))))
5825 (if (or (not gnus-summary-default-score)
5826 gnus-summary-inhibit-highlight)
5828 (let ((gnus-summary-inhibit-highlight t)
5831 (set-buffer gnus-summary-buffer)
5834 (while (and (not (eobp)) (< (point) end))
5835 (if (and gnus-summary-mark-below
5837 (setq article (get-text-property
5838 (point) 'gnus-number))
5839 gnus-newsgroup-scored))
5840 gnus-summary-default-score 0)
5841 gnus-summary-mark-below))
5842 ;; We want to possibly mark it as read...
5843 (and (not (memq article gnus-newsgroup-marked))
5844 (not (memq article gnus-newsgroup-dormant))
5845 (memq article gnus-newsgroup-unreads)
5846 (gnus-summary-mark-article-as-read gnus-low-score-mark))
5847 ;; We want to possibly mark it as unread.
5848 (and (eq (get-text-property (point) 'gnus-mark)
5849 gnus-low-score-mark)
5850 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
5851 ;; Do the visual highlights at the same time.
5852 (and gnus-visual (run-hooks 'gnus-summary-update-hook))
5853 (forward-line 1)))))))
5855 (defvar gnus-tmp-gathered nil)
5857 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5858 ;; Sum up all elements (and sub-elements) in a list.
5860 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
5861 (if (and (consp thread) (cdr thread))
5864 'gnus-summary-number-of-articles-in-thread
5868 (if (> number 1) gnus-not-empty-thread-mark
5869 gnus-empty-thread-mark)
5872 (defun gnus-summary-read-group
5873 (group &optional show-all no-article kill-buffer)
5874 "Start reading news in newsgroup GROUP.
5875 If SHOW-ALL is non-nil, already read articles are also listed.
5876 If NO-ARTICLE is non-nil, no article is selected initially."
5877 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5878 (let* ((new-group (gnus-summary-setup-buffer group))
5879 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
5881 (did-select (and new-group (gnus-select-newsgroup group show-all))))
5884 (gnus-set-global-variables)
5885 (gnus-kill-buffer kill-buffer)
5886 (gnus-configure-windows 'summary 'force)
5887 (gnus-set-mode-line 'summary)
5888 (gnus-summary-position-cursor)
5892 (and (eq major-mode 'gnus-summary-mode)
5893 (not (equal (current-buffer) kill-buffer))
5895 (kill-buffer (current-buffer))
5896 (if (not quit-config)
5898 (set-buffer gnus-group-buffer)
5899 (gnus-group-jump-to-group group)
5900 (gnus-group-next-unread-group 1))
5901 (if (not (buffer-name (car quit-config)))
5902 (gnus-configure-windows 'group 'force)
5903 (set-buffer (car quit-config))
5904 (and (eq major-mode 'gnus-summary-mode)
5905 (gnus-set-global-variables))
5906 (gnus-configure-windows (cdr quit-config))))))
5907 (message "Can't select group")
5909 ((eq did-select 'quit)
5910 (and (eq major-mode 'gnus-summary-mode)
5911 (not (equal (current-buffer) kill-buffer))
5912 (kill-buffer (current-buffer)))
5913 (gnus-kill-buffer kill-buffer)
5914 (if (not quit-config)
5916 (set-buffer gnus-group-buffer)
5917 (gnus-group-jump-to-group group)
5918 (gnus-group-next-unread-group 1)
5919 (gnus-configure-windows 'group 'force))
5920 (if (not (buffer-name (car quit-config)))
5921 (gnus-configure-windows 'group 'force)
5922 (set-buffer (car quit-config))
5923 (and (eq major-mode 'gnus-summary-mode)
5924 (gnus-set-global-variables))
5925 (gnus-configure-windows (cdr quit-config))))
5928 (gnus-set-global-variables)
5929 ;; Save the active value in effect when the group was entered.
5930 (setq gnus-newsgroup-active
5932 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5933 ;; You can change the subjects in this hook.
5934 (run-hooks 'gnus-select-group-hook)
5935 ;; Do score processing.
5936 (and gnus-use-scoring (gnus-possibly-score-headers))
5937 (gnus-update-format-specifications)
5938 ;; Generate the summary buffer.
5939 (gnus-summary-prepare)
5940 (if (zerop (buffer-size))
5941 (cond (gnus-newsgroup-dormant
5942 (gnus-summary-show-all-dormant))
5943 ((and gnus-newsgroup-scored show-all)
5944 (gnus-summary-show-all-expunged))))
5945 ;; Function `gnus-apply-kill-file' must be called in this hook.
5946 (run-hooks 'gnus-apply-kill-hook)
5947 (if (zerop (buffer-size))
5949 ;; This newsgroup is empty.
5950 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5951 (gnus-message 6 "No unread news")
5952 (gnus-kill-buffer kill-buffer)
5956 ;; (let ((gnus-summary-buffer kill-buffer))
5957 ;; (gnus-configure-windows 'group))))
5958 ;; Hide conversation thread subtrees. We cannot do this in
5959 ;; gnus-summary-prepare-hook since kill processing may not
5960 ;; work with hidden articles.
5961 (and gnus-show-threads
5962 gnus-thread-hide-subtree
5963 (gnus-summary-hide-all-threads))
5964 ;; Show first unread article if requested.
5965 (goto-char (point-min))
5966 (if (and (not no-article)
5967 gnus-auto-select-first
5968 (gnus-summary-first-unread-article))
5970 (gnus-configure-windows 'summary 'force))
5971 (gnus-set-mode-line 'summary)
5972 (gnus-summary-position-cursor)
5973 ;; If in async mode, we send some info to the backend.
5974 (and gnus-newsgroup-async
5975 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5976 (gnus-request-asynchronous
5978 (if (and gnus-asynchronous-article-function
5979 (fboundp gnus-asynchronous-article-function))
5980 (funcall gnus-asynchronous-article-function
5981 gnus-newsgroup-threads)
5982 gnus-newsgroup-threads)))
5983 (gnus-kill-buffer kill-buffer)
5984 (if (not (get-buffer-window gnus-group-buffer))
5986 ;; gotta use windows, because recenter does wierd stuff if
5987 ;; the current buffer ain't the displayed window.
5988 (let ((owin (selected-window)))
5989 (select-window (get-buffer-window gnus-group-buffer))
5990 (and (gnus-group-goto-group group)
5992 (select-window owin))))
5995 (defun gnus-summary-prepare ()
5996 ;; Generate the summary buffer.
5997 (let ((buffer-read-only nil))
5999 (gnus-summary-prepare-threads
6000 (if gnus-show-threads
6001 (gnus-gather-threads
6003 (if (and gnus-summary-expunge-below
6004 (not gnus-fetch-old-headers))
6005 (gnus-make-threads-and-expunge)
6006 (gnus-make-threads))))
6007 gnus-newsgroup-headers)
6009 (gnus-summary-update-lines)
6010 ;; Create the header hashtb.
6011 (gnus-make-headers-hashtable-by-number)
6012 ;; Call hooks for modifying summary buffer.
6013 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
6014 (goto-char (point-min))
6015 (run-hooks 'gnus-summary-prepare-hook)))
6017 (defun gnus-gather-threads (threads)
6018 "Gather threads that have lost their roots."
6019 (if (not gnus-summary-make-false-root)
6021 (let ((hashtb (gnus-make-hashtable 1023))
6024 subject hthread whole-subject)
6027 (setq subject (mail-header-subject (car (car threads)))))
6028 (if gnus-summary-gather-subject-limit
6029 (or (and (numberp gnus-summary-gather-subject-limit)
6030 (> (length subject) gnus-summary-gather-subject-limit)
6032 (substring subject 0
6033 gnus-summary-gather-subject-limit)))
6034 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
6035 (setq subject (gnus-simplify-subject-fuzzy subject))))
6036 (setq subject (gnus-simplify-subject-re subject)))
6038 (gnus-gethash subject hashtb))
6040 (or (stringp (car (car hthread)))
6041 (setcar hthread (list whole-subject (car hthread))))
6042 (setcdr (car hthread) (nconc (cdr (car hthread))
6043 (list (car threads))))
6044 (setcdr prev (cdr threads))
6045 (setq threads prev))
6046 (gnus-sethash subject threads hashtb))
6048 (setq threads (cdr threads)))
6051 (defun gnus-make-threads ()
6052 ;; This function takes the dependencies already made by
6053 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6054 ;; through the dependecies in the hash table and finds all the
6055 ;; roots. Roots do not refer back to any valid articles.
6056 (gnus-message 6 "Threading...")
6057 (let (roots new-roots)
6058 (and gnus-fetch-old-headers
6059 (eq gnus-headers-retrieved-by 'nov)
6060 (gnus-build-old-threads))
6063 (if (not (car (symbol-value refs)))
6064 (setq roots (append (cdr (symbol-value refs)) roots))
6065 ;; Ok, these refer back to valid articles, but if
6066 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6067 ;; the root has the same subject as its children. The children
6068 ;; that do not are made into roots and removed from the list
6070 (or gnus-thread-ignore-subject
6071 (let* ((prev (symbol-value refs))
6072 (subject (gnus-simplify-subject-re
6073 (mail-header-subject (car prev))))
6074 (headers (cdr prev)))
6076 (if (not (string= subject
6077 (gnus-simplify-subject-re
6078 (mail-header-subject (car headers)))))
6080 (setq new-roots (cons (car headers) new-roots))
6081 (setcdr prev (cdr headers)))
6082 (setq prev headers))
6083 (setq headers (cdr headers)))))))
6084 gnus-newsgroup-dependencies)
6086 ;; We enter the new roots into the dependencies structure to
6087 ;; ensure that any possible later thread-regeneration will be
6089 (let ((r new-roots))
6091 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6092 (list nil (car r)) gnus-newsgroup-dependencies)
6095 (setq roots (nconc new-roots roots))
6098 (mapcar 'gnus-trim-thread
6100 (mapcar 'gnus-cut-thread
6101 (mapcar 'gnus-make-sub-thread roots))))
6102 (gnus-message 6 "Threading...done"))))
6105 (defun gnus-make-threads-and-expunge ()
6106 ;; This function takes the dependencies already made by
6107 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
6108 ;; through the dependecies in the hash table and finds all the
6109 ;; roots. Roots do not refer back to any valid articles.
6110 (gnus-message 6 "Threading...")
6111 (let ((default (or gnus-summary-default-score 0))
6112 (below gnus-summary-expunge-below)
6113 roots article new-roots)
6114 (and gnus-fetch-old-headers
6115 (eq gnus-headers-retrieved-by 'nov)
6116 (gnus-build-old-threads))
6119 (if (not (car (symbol-value refs)))
6120 ;; These articles do not refer back to any other articles -
6122 (let ((headers (cdr (symbol-value refs))))
6123 ;; We weed out the low-scored articles.
6125 (if (not (< (or (cdr (assq (mail-header-number (car headers))
6126 gnus-newsgroup-scored)) default)
6129 (setq roots (cons (car headers) roots))
6130 ;; It is below, so we mark it as read.
6131 (setq gnus-newsgroup-unreads
6132 (delq (mail-header-number (car headers))
6133 gnus-newsgroup-unreads))
6134 (setq gnus-newsgroup-reads
6135 (cons (cons (mail-header-number (car headers))
6136 gnus-low-score-mark)
6137 gnus-newsgroup-reads)))
6138 (setq headers (cdr headers))))
6139 ;; Ok, these refer back to valid articles, but if
6140 ;; `gnus-thread-ignore-subject' is nil, we have to check that
6141 ;; the root has the same subject as its children. The children
6142 ;; that do not are made into roots and removed from the list
6144 (or gnus-thread-ignore-subject
6145 (let* ((prev (symbol-value refs))
6146 (subject (gnus-simplify-subject-re
6147 (mail-header-subject (car prev))))
6148 (headers (cdr prev)))
6150 (if (not (string= subject
6151 (gnus-simplify-subject-re
6152 (mail-header-subject (car headers)))))
6154 (if (not (< (or (cdr (assq (mail-header-number (car headers))
6155 gnus-newsgroup-scored))
6157 (setq new-roots (cons (car headers) new-roots))
6158 (setq gnus-newsgroup-unreads
6159 (delq (mail-header-number (car headers))
6160 gnus-newsgroup-unreads))
6161 (setq gnus-newsgroup-reads
6162 (cons (cons (mail-header-number (car headers))
6163 gnus-low-score-mark)
6164 gnus-newsgroup-reads)))
6165 (setcdr prev (cdr headers)))
6166 (setq prev headers))
6167 (setq headers (cdr headers)))))
6168 ;; If this article is expunged, some of the children might be
6170 (if (< (or (cdr (assq (mail-header-number (car (symbol-value refs)))
6171 gnus-newsgroup-scored)) default)
6173 (let* ((prev (symbol-value refs))
6174 (headers (cdr prev)))
6176 (setq article (mail-header-number (car headers)))
6177 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6179 (progn (setq new-roots (cons (car headers) new-roots))
6180 (setq prev headers))
6181 (setq gnus-newsgroup-unreads
6182 (delq article gnus-newsgroup-unreads))
6183 (setq gnus-newsgroup-reads
6184 (cons (cons article gnus-low-score-mark)
6185 gnus-newsgroup-reads))
6186 (setcdr prev (cdr headers)))
6187 (setq headers (cdr headers))))
6188 ;; It was not expunged, but we look at expunged children.
6189 (let* ((prev (symbol-value refs))
6190 (headers (cdr prev))
6193 (setq article (mail-header-number (car headers)))
6194 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
6197 (setq gnus-newsgroup-unreads
6198 (delq article gnus-newsgroup-unreads))
6199 (setq gnus-newsgroup-reads
6200 (cons (cons article gnus-low-score-mark)
6201 gnus-newsgroup-reads))
6202 (setcdr prev (cdr headers)))
6203 (setq headers (cdr headers)))))))
6204 gnus-newsgroup-dependencies)
6206 ;; We enter the new roots into the dependencies structure to
6207 ;; ensure that any possible later thread-regeneration will be
6209 (let ((r new-roots))
6211 (gnus-sethash (concat (mail-header-id (car r)) ".boo")
6212 (list nil (car r)) gnus-newsgroup-dependencies)
6215 (setq roots (nconc new-roots roots))
6218 (mapcar 'gnus-trim-thread
6220 (mapcar 'gnus-cut-thread
6221 (mapcar 'gnus-make-sub-thread roots))))
6222 (gnus-message 6 "Threading...done"))))
6225 (defun gnus-cut-thread (thread)
6226 ;; Remove leaf dormant or ancient articles from THREAD.
6227 (let ((head (car thread))
6228 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
6229 (if (and (null tail)
6230 (let ((number (mail-header-number head)))
6231 (or (memq number gnus-newsgroup-ancient)
6232 (memq number gnus-newsgroup-dormant)
6233 (and gnus-summary-expunge-below
6234 (eq gnus-fetch-old-headers 'some)
6235 (< (or (cdr (assq number gnus-newsgroup-scored))
6236 gnus-summary-default-score 0)
6237 gnus-summary-expunge-below)
6239 (setq gnus-newsgroup-unreads
6240 (delq number gnus-newsgroup-unreads))
6241 (setq gnus-newsgroup-reads
6242 (cons (cons number gnus-low-score-mark)
6243 gnus-newsgroup-reads))
6246 (list (cons head tail)))))
6248 (defun gnus-trim-thread (thread)
6249 ;; Remove root ancient articles with only one child from THREAD.
6250 (if (and (eq gnus-fetch-old-headers 'some)
6251 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient)
6252 (= (length thread) 2))
6253 (gnus-trim-thread (nth 1 thread))
6256 (defun gnus-make-sub-thread (root)
6257 ;; This function makes a sub-tree for a node in the tree.
6258 (let ((children (reverse (cdr (gnus-gethash (downcase (mail-header-id root))
6259 gnus-newsgroup-dependencies)))))
6260 (cons root (mapcar 'gnus-make-sub-thread children))))
6262 (defun gnus-build-old-threads ()
6263 ;; Look at all the articles that refer back to old articles, and
6264 ;; fetch the headers for the articles that aren't there. This will
6265 ;; build complete threads - if the roots haven't been expired by the
6270 (if (not (car (symbol-value refs)))
6272 (setq heads (cdr (symbol-value refs)))
6274 (if (not (memq (mail-header-number (car heads))
6275 gnus-newsgroup-dormant))
6277 (setq id (symbol-name refs))
6278 (while (and (setq id (gnus-build-get-header id))
6279 (not (car (gnus-gethash
6280 id gnus-newsgroup-dependencies)))))
6282 (setq heads (cdr heads)))))))
6283 gnus-newsgroup-dependencies)))
6285 (defun gnus-build-get-header (id)
6286 ;; Look through the buffer of NOV lines and find the header to
6287 ;; ID. Enter this line into the dependencies hash table, and return
6288 ;; the id of the parent article (if any).
6289 (let ((deps gnus-newsgroup-dependencies)
6293 (set-buffer nntp-server-buffer)
6294 (goto-char (point-min))
6295 (while (and (not found) (search-forward id nil t))
6297 (setq found (looking-at
6298 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
6299 (regexp-quote id))))
6300 (or found (beginning-of-line 2)))
6305 (setq header (gnus-nov-parse-line
6306 (read (current-buffer)) deps))
6307 (setq ref (mail-header-references header))
6308 (string-match "\\(<[^>]+>\\) *$" ref)
6309 (substring ref (match-beginning 1) (match-end 1))))))
6311 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
6312 gnus-newsgroup-ancient (cons (mail-header-number header)
6313 gnus-newsgroup-ancient))))))
6315 ;; Re-build the thread containing ID.
6316 (defun gnus-rebuild-thread (id)
6317 (let ((dep gnus-newsgroup-dependencies)
6318 (buffer-read-only nil)
6319 parent headers refs thread art)
6320 (while (and id (setq headers
6321 (car (setq art (gnus-gethash (downcase id) dep)))))
6323 (setq id (and (setq refs (mail-header-references headers))
6324 (string-match "\\(<[^>]+>\\) *$" refs)
6325 (substring refs (match-beginning 1) (match-end 1)))))
6326 (setq thread (gnus-make-sub-thread (car parent)))
6327 (gnus-rebuild-remove-articles thread)
6328 (let ((beg (point)))
6329 (gnus-summary-prepare-threads (list thread))
6330 (gnus-summary-update-lines beg (point)))))
6332 ;; Delete all lines in the summary buffer that correspond to articles
6334 (defun gnus-rebuild-remove-articles (thread)
6335 (and (gnus-summary-goto-subject (mail-header-number (car thread)))
6337 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
6339 (defun gnus-sort-threads (threads)
6340 ;; Sort threads as specified in `gnus-thread-sort-functions'.
6341 (let ((fun gnus-thread-sort-functions))
6343 (setq threads (sort threads (car fun))
6347 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
6348 (defmacro gnus-thread-header (thread)
6349 ;; Return header of first article in THREAD.
6350 ;; Note that THREAD must never, evr be anything else than a variable -
6351 ;; using some other form will lead to serious barfage.
6352 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
6353 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
6354 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
6357 (defun gnus-thread-sort-by-number (h1 h2)
6358 "Sort threads by root article number."
6359 (< (mail-header-number (gnus-thread-header h1))
6360 (mail-header-number (gnus-thread-header h2))))
6362 (defun gnus-thread-sort-by-author (h1 h2)
6363 "Sort threads by root author."
6365 (let ((extract (funcall
6366 gnus-extract-address-components
6367 (mail-header-from (gnus-thread-header h1)))))
6368 (or (car extract) (cdr extract)))
6369 (let ((extract (funcall
6370 gnus-extract-address-components
6371 (mail-header-from (gnus-thread-header h2)))))
6372 (or (car extract) (cdr extract)))))
6374 (defun gnus-thread-sort-by-subject (h1 h2)
6375 "Sort threads by root subject."
6377 (downcase (gnus-simplify-subject
6378 (mail-header-subject (gnus-thread-header h1))))
6379 (downcase (gnus-simplify-subject
6380 (mail-header-subject (gnus-thread-header h2))))))
6382 (defun gnus-thread-sort-by-date (h1 h2)
6383 "Sort threads by root article date."
6385 (gnus-sortable-date (mail-header-date (gnus-thread-header h1)))
6386 (gnus-sortable-date (mail-header-date (gnus-thread-header h2)))))
6388 (defun gnus-thread-sort-by-score (h1 h2)
6389 "Sort threads by root article score.
6390 Unscored articles will be counted as having a score of zero."
6391 (> (or (cdr (assq (mail-header-number (gnus-thread-header h1))
6392 gnus-newsgroup-scored))
6393 gnus-summary-default-score 0)
6394 (or (cdr (assq (mail-header-number (gnus-thread-header h2))
6395 gnus-newsgroup-scored))
6396 gnus-summary-default-score 0)))
6398 (defun gnus-thread-sort-by-total-score (h1 h2)
6399 "Sort threads by the sum of all scores in the thread.
6400 Unscored articles will be counted as having a score of zero."
6401 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
6403 (defun gnus-thread-total-score (thread)
6404 ;; This function find the total score of THREAD.
6406 (if (stringp (car thread))
6407 (apply gnus-thread-score-function 0
6408 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
6409 (gnus-thread-total-score-1 thread))
6410 (gnus-thread-total-score-1 (list thread))))
6412 (defun gnus-thread-total-score-1 (root)
6413 ;; This function find the total score of the thread below ROOT.
6414 (setq root (car root))
6415 (apply gnus-thread-score-function
6416 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
6417 gnus-summary-default-score 0)
6418 (mapcar 'gnus-thread-total-score
6419 (cdr (gnus-gethash (downcase (mail-header-id root))
6420 gnus-newsgroup-dependencies)))))
6422 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
6423 (defvar gnus-tmp-prev-subject "")
6425 (defun gnus-summary-prepare-threads (threads &optional cull)
6426 "Prepare summary buffer from THREADS and indentation LEVEL.
6427 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
6428 or a straight list of headers."
6429 (message "Generating summary...")
6431 thread header number subject stack state gnus-tmp-gathered)
6432 (if (vectorp (car threads))
6433 ;; If this is a straight (sic) list of headers, then a
6434 ;; threaded summary display isn't required, so we just create
6435 ;; an unthreaded one.
6436 (gnus-summary-prepare-unthreaded threads cull)
6438 ;; Do the threaded display.
6440 (while (or threads stack)
6443 ;; If there are some threads, we do them before the
6444 ;; threads on the stack.
6445 (setq thread threads
6446 header (car (car thread)))
6447 ;; There were no current threads, so we pop something off
6449 (setq state (car stack)
6453 header (car (car thread))))
6455 (if (stringp header)
6457 ;; The header is a dummy root.
6459 ((eq gnus-summary-make-false-root 'adopt)
6460 ;; We let the first article adopt the rest.
6461 (let ((th (car (cdr (car thread)))))
6464 (setcdr th (cdr (cdr (car thread))))
6465 (setq gnus-tmp-gathered
6467 (lambda (h) (mail-header-number (car h)))
6468 (cdr (cdr (car thread))))
6470 (setcdr (cdr (car thread)) nil))
6472 ((eq gnus-summary-make-false-root 'empty)
6473 ;; We print adopted articles with empty subject fields.
6474 (setq gnus-tmp-gathered
6476 (lambda (h) (mail-header-number (car h)))
6477 (cdr (cdr (car thread))))
6480 ((eq gnus-summary-make-false-root 'dummy)
6481 ;; We output a dummy root.
6482 (gnus-summary-insert-dummy-line
6483 nil header (mail-header-number (car (car (cdr (car thread)))))))
6485 ;; We do not make a root for the gathered
6486 ;; sub-threads at all.
6489 (setq number (mail-header-number header)
6490 subject (mail-header-subject header))
6492 ;; Do the async thing.
6493 (and gnus-newsgroup-async
6494 (setq gnus-newsgroup-threads
6495 (cons (cons number (mail-header-lines header))
6496 gnus-newsgroup-threads)))
6498 ;; We may have to root out some bad articles...
6501 (cond ((and (memq (setq number (mail-header-number header))
6502 gnus-newsgroup-dormant)
6505 ((and gnus-summary-expunge-below
6506 (< (or (cdr (assq number gnus-newsgroup-scored))
6507 gnus-summary-default-score 0)
6508 gnus-summary-expunge-below))
6510 (setq gnus-newsgroup-unreads
6511 (delq number gnus-newsgroup-unreads))
6512 (setq gnus-newsgroup-reads
6513 (cons (cons number gnus-low-score-mark)
6514 gnus-newsgroup-reads)))))
6520 (gnus-summary-insert-line
6521 nil header level nil
6523 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6524 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6525 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6526 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6527 (t (or (cdr (assq number gnus-newsgroup-reads))
6528 gnus-ancient-mark)))
6529 (memq number gnus-newsgroup-replied)
6530 (memq number gnus-newsgroup-expirable)
6531 (if (and (eq gnus-summary-make-false-root 'empty)
6532 (memq number gnus-tmp-gathered))
6533 gnus-summary-same-subject
6534 (if (or (zerop level)
6535 (and gnus-thread-ignore-subject
6537 (gnus-simplify-subject-re
6538 gnus-tmp-prev-subject)
6539 (gnus-simplify-subject-re
6542 gnus-summary-same-subject))
6543 (and (eq gnus-summary-make-false-root 'adopt)
6544 (memq number gnus-tmp-gathered))
6545 (cdr (assq number gnus-newsgroup-scored)))
6547 (setq gnus-tmp-prev-subject subject)))))
6550 (setq stack (cons (cons (max 0 level) (nthcdr 1 thread)) stack)))
6551 (setq level (1+ level))
6552 (setq threads (cdr (car thread))))))
6553 (message "Generating summary...done"))
6557 (defun gnus-summary-prepare-unthreaded (headers &optional cull)
6558 (let (header number)
6560 ;; Do the async thing, if that is required.
6561 (if gnus-newsgroup-async
6562 (setq gnus-newsgroup-threads
6563 (mapcar (lambda (h) (cons (mail-header-number h) (mail-header-lines h)))
6567 (setq header (car headers)
6568 headers (cdr headers)
6569 number (mail-header-number header))
6571 ;; We may have to root out some bad articles...
6574 (memq (setq number (mail-header-number header))
6575 gnus-newsgroup-dormant)))
6576 ((and cull gnus-summary-expunge-below
6577 (< (or (cdr (assq number gnus-newsgroup-scored))
6578 gnus-summary-default-score 0)
6579 gnus-summary-expunge-below))
6580 (setq gnus-newsgroup-unreads
6581 (delq number gnus-newsgroup-unreads))
6582 (setq gnus-newsgroup-reads
6583 (cons (cons number gnus-low-score-mark)
6584 gnus-newsgroup-reads)))
6586 (gnus-summary-insert-line
6588 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
6589 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
6590 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
6591 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
6592 (t (or (cdr (assq number gnus-newsgroup-reads))
6593 gnus-ancient-mark)))
6594 (memq number gnus-newsgroup-replied)
6595 (memq number gnus-newsgroup-expirable)
6596 (mail-header-subject header) nil
6597 (cdr (assq number gnus-newsgroup-scored))))))))
6599 (defun gnus-select-newsgroup (group &optional read-all)
6600 "Select newsgroup GROUP.
6601 If READ-ALL is non-nil, all articles in the group are selected."
6602 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6603 (info (nth 2 entry))
6606 (setq gnus-current-select-method (gnus-find-method-for-group group)))
6608 (or (gnus-check-server gnus-current-select-method)
6609 (error "Couldn't open server"))
6611 (or (and (null entry)
6612 (gnus-activate-group group))
6613 (and (eq (car entry) t)
6614 (gnus-activate-group (car info)))
6615 (gnus-request-group group t)
6617 (kill-buffer (current-buffer))
6618 (error "Couldn't request group %s: %s"
6619 group (gnus-status-message group))))
6621 (setq gnus-newsgroup-name group)
6622 (setq gnus-newsgroup-unselected nil)
6623 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
6625 (and gnus-asynchronous
6626 (gnus-check-backend-function
6627 'request-asynchronous gnus-newsgroup-name)
6628 (setq gnus-newsgroup-async
6629 (gnus-request-asynchronous gnus-newsgroup-name)))
6631 (setq articles (gnus-articles-to-read group read-all))
6635 (gnus-message 3 "Couldn't select newsgroup")
6637 ((eq articles 0) nil)
6639 ;; Init the dependencies hash table.
6640 (setq gnus-newsgroup-dependencies
6641 (gnus-make-hashtable (length articles)))
6642 ;; Retrieve the headers and read them in.
6643 (gnus-message 5 "Fetching headers...")
6644 (setq gnus-newsgroup-headers
6645 (if (eq 'nov (setq gnus-headers-retrieved-by
6646 ;; This is a naughty hack. To get the
6647 ;; retrieval of old headers to work, we
6648 ;; set `nntp-nov-gap' to nil (locally),
6649 ;; and then just retrieve the headers.
6651 (if gnus-fetch-old-headers
6653 (gnus-retrieve-headers
6654 (if (not (eq 1 (car articles)))
6657 gnus-newsgroup-name))
6658 (gnus-retrieve-headers
6659 articles gnus-newsgroup-name))))
6661 (gnus-get-newsgroup-headers-xover articles))
6662 ;; If we were to fetch old headers, but the backend didn't
6663 ;; support XOVER, then it is possible we fetched one article
6664 ;; that we shouldn't have. If that's the case, we remove it.
6665 (if (or (not gnus-fetch-old-headers)
6666 (eq 1 (car articles)))
6669 (set-buffer nntp-server-buffer)
6670 (goto-char (point-min))
6672 (looking-at "[0-9]+[ \t]+1[ \t]") ; This is not a NOV line.
6673 (delete-region ; So we delete this head.
6675 (search-forward "\n.\n" nil t)))))
6676 (gnus-get-newsgroup-headers)))
6677 (gnus-message 5 "Fetching headers...done")
6678 ;; Remove canceled articles from the list of unread articles.
6679 (setq gnus-newsgroup-unreads
6680 (gnus-set-sorted-intersection
6681 gnus-newsgroup-unreads
6682 (mapcar (lambda (headers) (mail-header-number headers))
6683 gnus-newsgroup-headers)))
6684 ;; Adjust and set lists of article marks.
6687 (gnus-adjust-marked-articles info)
6688 (setq gnus-newsgroup-marked
6690 (cdr (assq 'tick (setq marked (nth 3 info))))))
6691 (setq gnus-newsgroup-replied
6692 (copy-sequence (cdr (assq 'reply marked))))
6693 (setq gnus-newsgroup-expirable
6694 (copy-sequence (cdr (assq 'expire marked))))
6695 (setq gnus-newsgroup-killed
6696 (copy-sequence (cdr (assq 'killed marked))))
6697 (setq gnus-newsgroup-bookmarks
6698 (copy-sequence (cdr (assq 'bookmark marked))))
6699 (setq gnus-newsgroup-dormant
6700 (copy-sequence (cdr (assq 'dormant marked))))
6701 (setq gnus-newsgroup-scored
6702 (copy-sequence (cdr (assq 'score marked))))
6703 (setq gnus-newsgroup-processable nil)))
6704 ;; Check whether auto-expire is to be done in this group.
6705 (setq gnus-newsgroup-auto-expire
6706 (or (and (stringp gnus-auto-expirable-newsgroups)
6707 (string-match gnus-auto-expirable-newsgroups group))
6708 (memq 'auto-expire (nth 5 info))))
6709 ;; First and last article in this newsgroup.
6710 (and gnus-newsgroup-headers
6711 (setq gnus-newsgroup-begin
6712 (mail-header-number (car gnus-newsgroup-headers)))
6713 (setq gnus-newsgroup-end
6714 (mail-header-number (gnus-last-element gnus-newsgroup-headers))))
6715 (setq gnus-reffed-article-number -1)
6716 ;; GROUP is successfully selected.
6717 (or gnus-newsgroup-headers t)))))
6719 (defun gnus-articles-to-read (group read-all)
6720 ;; Find out what articles the user wants to read.
6722 ;; Select all articles if `read-all' is non-nil, or if all the
6723 ;; unread articles are dormant articles.
6724 (if (or (and read-all (not (numberp read-all)))
6725 (= (length gnus-newsgroup-unreads)
6726 (length gnus-newsgroup-dormant)))
6727 (gnus-uncompress-range
6728 (gnus-gethash group gnus-active-hashtb))
6729 gnus-newsgroup-unreads))
6730 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
6731 (scored (length scored-list))
6732 (number (length articles))
6733 (marked (+ (length gnus-newsgroup-marked)
6734 (length gnus-newsgroup-dormant)))
6741 (cond ((and (or (<= scored marked)
6743 (numberp gnus-large-newsgroup)
6744 (> number gnus-large-newsgroup))
6748 "How many articles from %s (default %d): "
6749 gnus-newsgroup-name number))))
6750 (if (string-match "^[ \t]*$" input)
6752 ((and (> scored marked) (< scored number))
6756 "%s %s (%d scored, %d total): "
6757 "How many articles from"
6758 group scored number))))
6759 (if (string-match "^[ \t]*$" input)
6763 (setq select (if (stringp select) (string-to-number select) select))
6764 (if (or (null select) (zerop select))
6766 (if (and (not (zerop scored)) (<= (abs select) scored))
6768 (setq articles (sort scored-list '<))
6769 (setq number (length articles)))
6770 (setq articles (copy-sequence articles)))
6772 (if (< (abs select) number)
6774 ;; Select the N oldest articles.
6775 (setcdr (nthcdr (1- (abs select)) articles) nil)
6776 ;; Select the N most recent articles.
6777 (setq articles (nthcdr (- number select) articles))))
6778 (setq gnus-newsgroup-unselected
6779 (gnus-sorted-intersection
6780 gnus-newsgroup-unreads
6781 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6784 (defun gnus-killed-articles (killed articles)
6787 (if (inline (gnus-member-of-range (car articles) killed))
6788 (setq out (cons (car articles) out)))
6789 (setq articles (cdr articles)))
6792 (defun gnus-adjust-marked-articles (info &optional active)
6793 "Remove all marked articles that are no longer legal."
6794 (let ((marked-lists (nth 3 info))
6795 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6797 ;; There are many types of marked articles.
6799 (setq m (cdr (setq prev (car marked-lists))))
6800 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6801 ;; Make sure that all ticked articles are a subset of the
6802 ;; unread/unselected articles.
6804 (if (or (memq (car m) gnus-newsgroup-unreads)
6805 (memq (car m) gnus-newsgroup-unselected))
6807 (setcdr prev (cdr m)))
6809 ((eq 'score (car prev))
6810 ;; Scored articles should be a subset of
6811 ;; unread/unselected articles.
6813 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6814 (memq (car (car m)) gnus-newsgroup-unreads))
6816 (setcdr prev (cdr m)))
6818 ((eq 'bookmark (car prev))
6819 ;; Bookmarks should be a subset of active articles.
6821 (if (< (car (car m)) (car active))
6822 (setcdr prev (cdr m))
6825 ((eq 'killed (car prev))
6826 ;; Articles that have been through the kill process are
6827 ;; to be a subset of active articles.
6828 (while (and m (< (or (and (numberp (car m)) (car m))
6831 (setcdr prev (cdr m))
6833 (if (and m (< (or (and (numberp (car m)) (car m))
6836 (setcar (if (numberp (car m)) m (car m)) (car active))))
6837 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6838 ;; The replied and expirable articles have to be articles
6841 (if (< (car m) (car active))
6842 (setcdr prev (cdr m))
6845 (setq marked-lists (cdr marked-lists)))
6846 ;; Remove all lists that are empty.
6847 (setq marked-lists (nth 3 info))
6850 (while (= 1 (length (car marked-lists)))
6851 (setq marked-lists (cdr marked-lists)))
6852 (setq m (cdr (setq prev marked-lists)))
6854 (if (= 1 (length (car m)))
6855 (setcdr prev (cdr m))
6858 (setcar (nthcdr 3 info) marked-lists)))
6859 ;; Finally, if there are no marked lists at all left, and if there
6860 ;; are no elements after the lists in the info list, we just chop
6861 ;; the info list off before the marked lists.
6862 (and (null marked-lists)
6863 (not (nthcdr 4 info))
6864 (setcdr (nthcdr 2 info) nil)))
6867 (defun gnus-set-marked-articles
6868 (info ticked replied expirable killed dormant bookmark score)
6869 "Enter the various lists of marked articles into the newsgroup info list."
6871 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6872 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6873 (and expirable (setq newmarked (cons (cons 'expire expirable)
6875 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6876 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6877 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6879 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6882 (setcar (nthcdr 3 info) newmarked)
6883 (and (not newmarked)
6884 (not (nthcdr 4 info))
6885 (setcdr (nthcdr 2 info) nil)))
6887 (setcdr (nthcdr 2 info) (list newmarked))))))
6889 (defun gnus-add-marked-articles (group type articles &optional info force)
6890 ;; Add ARTICLES of TYPE to the info of GROUP.
6891 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6892 ;; add, but replace marked articles of TYPE with ARTICLES.
6893 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6896 (and (not (setq marked (nthcdr 3 info)))
6897 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6898 (and (not (setq m (assq type (car marked))))
6899 (setcar marked (cons (cons type articles) (car marked))))
6902 (nconc m articles)))))
6904 (defun gnus-set-mode-line (where)
6905 "This function sets the mode line of the article or summary buffers.
6906 If WHERE is `summary', the summary mode line format will be used."
6907 (if (memq where gnus-updated-mode-lines)
6910 (set-buffer gnus-summary-buffer)
6911 (let* ((mformat (if (eq where 'article)
6912 gnus-article-mode-line-format-spec
6913 gnus-summary-mode-line-format-spec))
6914 (group-name gnus-newsgroup-name)
6915 (article-number (or gnus-current-article 0))
6916 (unread (- (length gnus-newsgroup-unreads)
6917 (length gnus-newsgroup-dormant)))
6918 (unread-and-unticked
6919 (- unread (length gnus-newsgroup-marked)))
6920 (unselected (length gnus-newsgroup-unselected))
6921 (unread-and-unselected
6922 (cond ((and (zerop unread-and-unticked)
6923 (zerop unselected)) "")
6925 (format "{%d more}" unread-and-unticked))
6926 (t (format "{%d(+%d) more}"
6927 unread-and-unticked unselected))))
6929 (if gnus-current-headers
6930 (mail-header-subject gnus-current-headers) ""))
6931 (max-len (and gnus-mode-non-string-length
6932 (- (frame-width) gnus-mode-non-string-length)))
6933 header);; passed as argument to any user-format-funcs
6934 (setq mode-string (eval mformat))
6935 (or (numberp max-len)
6936 (setq max-len (length mode-string)))
6937 (if (< max-len 4) (setq max-len 4))
6938 (if (> (length mode-string) max-len)
6939 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
6940 ;; function `substring' might cut on a middle
6941 ;; of multi-octet character.
6943 (concat (gnus-truncate-string mode-string (- max-len 3))
6945 (setq mode-string (format (format "%%-%ds" max-len)
6947 (setq mode-line-buffer-identification mode-string)
6948 (set-buffer-modified-p t))))
6950 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6951 "Go through the HEADERS list and add all Xrefs to a hash table.
6952 The resulting hash table is returned, or nil if no Xrefs were found."
6953 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6955 (gnus-group-foreign-p from-newsgroup)
6957 (assoc (symbol-name (car from-method))
6958 gnus-valid-select-methods))))
6959 (gnus-group-real-prefix from-newsgroup)))
6960 (xref-hashtb (make-vector 63 0))
6961 start group entry number xrefs header)
6963 (setq header (car headers))
6964 (if (and (setq xrefs (mail-header-xref header))
6965 (not (memq (mail-header-number header) unreads)))
6968 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6969 (setq start (match-end 0))
6970 (setq group (concat prefix (substring xrefs (match-beginning 1)
6973 (string-to-int (substring xrefs (match-beginning 2)
6975 (if (setq entry (gnus-gethash group xref-hashtb))
6976 (setcdr entry (cons number (cdr entry)))
6977 (gnus-sethash group (cons number nil) xref-hashtb)))))
6978 (setq headers (cdr headers)))
6979 (if start xref-hashtb nil)))
6981 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6982 "Look through all the headers and mark the Xrefs as read."
6983 (let ((virtual (memq 'virtual
6984 (assoc (symbol-name (car (gnus-find-method-for-group
6986 gnus-valid-select-methods)))
6987 name entry info xref-hashtb idlist method
6990 (set-buffer gnus-group-buffer)
6991 (if (setq xref-hashtb
6992 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6995 (if (string= from-newsgroup (setq name (symbol-name group)))
6997 (setq idlist (symbol-value group))
6998 ;; Dead groups are not updated.
7000 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
7002 (if (stringp (setq nth4 (nth 4 info)))
7003 (setq nth4 (gnus-server-to-method nth4))))
7004 ;; Only do the xrefs if the group has the same
7005 ;; select method as the group we have just read.
7006 (or (gnus-methods-equal-p
7007 nth4 (gnus-find-method-for-group from-newsgroup))
7010 (setq method (gnus-find-method-for-group
7012 (and (equal (car nth4) (car method))
7013 (equal (nth 1 nth4) (nth 1 method))))
7014 gnus-use-cross-reference
7015 (or (not (eq gnus-use-cross-reference t))
7017 ;; Only do cross-references on subscribed
7018 ;; groups, if that is what is wanted.
7019 (<= (nth 1 info) gnus-level-subscribed)))
7020 (gnus-group-make-articles-read name idlist expirable))))
7023 (defun gnus-group-make-articles-read (group articles expirable)
7025 (entry (gnus-gethash group gnus-newsrc-hashtb))
7026 (info (nth 2 entry))
7027 (active (gnus-gethash group gnus-active-hashtb))
7028 exps expirable range)
7029 ;; First peel off all illegal article numbers.
7031 (let ((ids articles)
7032 (ticked (cdr (assq 'tick (nth 3 info))))
7033 (dormant (cdr (assq 'dormant (nth 3 info))))
7038 (if (or (> id (cdr active))
7042 (setq articles (delq id articles)))
7043 (and (memq id expirable)
7044 (setq exps (cons id exps)))
7045 (setq ids (cdr ids)))))
7046 ;; Update expirable articles.
7047 (gnus-add-marked-articles nil 'expirable exps info)
7051 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
7052 (setcar (nthcdr 2 info)
7056 (setq articles (sort articles '<)))))
7057 ;; Then we have to re-compute how many unread
7058 ;; articles there are in this group.
7063 (setq num (- (1+ (cdr active)) (car active))))
7064 ((not (listp (cdr range)))
7065 (setq num (- (cdr active) (- (1+ (cdr range))
7069 (if (numberp (car range))
7071 (setq num (+ num (- (1+ (cdr (car range)))
7072 (car (car range))))))
7073 (setq range (cdr range)))
7074 (setq num (- (cdr active) num))))
7075 ;; Update the number of unread articles.
7079 (length (cdr (assq 'tick (nth 3 info))))
7081 (cdr (assq 'dormant (nth 3 info)))))))
7082 ;; Update the group buffer.
7083 (gnus-group-update-group group t)))))
7085 (defun gnus-methods-equal-p (m1 m2)
7086 (let ((m1 (or m1 gnus-select-method))
7087 (m2 (or m2 gnus-select-method)))
7089 (and (eq (car m1) (car m2))
7090 (or (not (memq 'address (assoc (symbol-name (car m1))
7091 gnus-valid-select-methods)))
7092 (equal (nth 1 m1) (nth 1 m2)))))))
7094 (defsubst gnus-header-value ()
7095 (buffer-substring (match-end 0) (gnus-point-at-eol)))
7097 (defvar gnus-newsgroup-none-id 0)
7099 (defun gnus-get-newsgroup-headers ()
7100 (setq gnus-article-internal-prepare-hook nil)
7101 (let ((cur nntp-server-buffer)
7102 (dependencies gnus-newsgroup-dependencies)
7103 headers id dep end ref)
7105 (set-buffer nntp-server-buffer)
7106 (goto-char (point-min))
7107 ;; Search to the beginning of the next header. Error messages
7108 ;; do not begin with 2 or 3.
7109 (while (re-search-forward "^[23][0-9]+ " nil t)
7110 (let ((header (make-vector 9 nil))
7111 (case-fold-search t)
7116 (mail-header-set-number header (read cur))
7117 ;; This implementation of this function, with nine
7118 ;; search-forwards instead of the one re-search-forward and
7119 ;; a case (which basically was the old function) is actually
7120 ;; about twice as fast, even though it looks messier. You
7121 ;; can't have everything, I guess. Speed and elegance
7122 ;; doesn't always come hand in hand.
7124 (narrow-to-region (point) (or (save-excursion
7125 (search-forward "\n.\n" nil t))
7127 (if (search-forward "\nfrom: " nil t)
7128 (mail-header-set-from header (gnus-header-value))
7129 (mail-header-set-from header "(nobody)"))
7131 (if (search-forward "\nsubject: " nil t)
7132 (mail-header-set-subject header (gnus-header-value))
7133 (mail-header-set-subject header "(none)"))
7135 (and (search-forward "\nxref: " nil t)
7136 (mail-header-set-xref header (gnus-header-value)))
7138 (or (numberp (and (search-forward "\nlines: " nil t)
7139 (mail-header-set-lines header (read cur))))
7140 (mail-header-set-lines header 0))
7142 (and (search-forward "\ndate: " nil t)
7143 (mail-header-set-date header (gnus-header-value)))
7145 (if (search-forward "\nmessage-id: " nil t)
7146 (mail-header-set-id header (setq id (gnus-header-value)))
7147 ;; If there was no message-id, we just fake one to make
7148 ;; subsequent routines simpler.
7151 (setq id (concat "none+"
7153 (setq gnus-newsgroup-none-id
7154 (1+ gnus-newsgroup-none-id)))))))
7156 (if (search-forward "\nreferences: " nil t)
7158 (mail-header-set-references header (gnus-header-value))
7159 (setq end (match-end 0))
7166 (search-backward ">" end t)
7169 (search-backward "<" end t)
7171 ;; Get the references from the in-reply-to header if there
7172 ;; ware no references and the in-reply-to header looks
7174 (if (and (search-forward "\nin-reply-to: " nil t)
7175 (setq in-reply-to (gnus-header-value))
7176 (string-match "<[^>]+>" in-reply-to))
7178 (mail-header-set-references
7180 (setq ref (substring in-reply-to (match-beginning 0)
7182 (setq ref (downcase ref)))
7184 ;; We do some threading while we read the headers. The
7185 ;; message-id and the last reference are both entered into
7186 ;; the same hash table. Some tippy-toeing around has to be
7187 ;; done in case an article has arrived before the article
7188 ;; which it refers to.
7189 (if (boundp (setq dep (intern (downcase id) dependencies)))
7190 (if (car (symbol-value dep))
7191 ;; An article with this Message-ID has already
7192 ;; been seen, so we ignore this one, except we add
7193 ;; any additional Xrefs (in case the two articles
7194 ;; came from different servers.
7196 (mail-header-set-xref
7197 (car (symbol-value dep))
7198 (concat (or (mail-header-xref (car (symbol-value dep))) "")
7199 (or (mail-header-xref header) "")))
7201 (setcar (symbol-value dep) header))
7202 (set dep (list header)))
7205 (if (boundp (setq dep (intern ref dependencies)))
7206 (setcdr (symbol-value dep)
7207 (cons header (cdr (symbol-value dep))))
7208 (set dep (list nil header)))
7209 (setq headers (cons header headers))))
7210 (goto-char (point-max))))))
7211 (nreverse headers)))
7213 ;; The following macros and functions were written by Felix Lee
7214 ;; <flee@cse.psu.edu>.
7216 (defmacro gnus-nov-read-integer ()
7218 (if (= (following-char) ?\t)
7220 (let ((num (condition-case nil (read buffer) (error nil))))
7221 (if (numberp num) num 0)))
7222 (or (eobp) (forward-char 1))))
7224 (defmacro gnus-nov-skip-field ()
7225 '(search-forward "\t" eol 'move))
7227 (defmacro gnus-nov-field ()
7228 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
7230 ;; Goes through the xover lines and returns a list of vectors
7231 (defun gnus-get-newsgroup-headers-xover (sequence)
7232 "Parse the news overview data in the server buffer, and return a
7233 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
7234 ;; Get the Xref when the users reads the articles since most/some
7235 ;; NNTP servers do not include Xrefs when using XOVER.
7236 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
7237 (let ((cur nntp-server-buffer)
7238 (dependencies gnus-newsgroup-dependencies)
7239 number headers header)
7241 (set-buffer nntp-server-buffer)
7242 (goto-char (point-min))
7243 (while (and sequence (not (eobp)))
7244 (setq number (read cur))
7245 (while (and sequence (< (car sequence) number))
7246 (setq sequence (cdr sequence)))
7248 (eq number (car sequence))
7250 (setq sequence (cdr sequence))
7252 (inline (gnus-nov-parse-line number dependencies)))
7253 (setq headers (cons header headers)))))
7255 (setq headers (nreverse headers)))
7258 ;; This function has to be called with point after the article number
7259 ;; on the beginning of the line.
7260 (defun gnus-nov-parse-line (number dependencies)
7262 (eol (gnus-point-at-eol))
7263 (buffer (current-buffer))
7266 ;; overview: [num subject from date id refs chars lines misc]
7267 (narrow-to-region (point) eol)
7274 (gnus-nov-field) ; subject
7275 (gnus-nov-field) ; from
7276 (gnus-nov-field) ; date
7277 (setq id (or (gnus-nov-field)
7280 (setq none (1+ none)))))) ; id
7283 (let ((beg (point)))
7284 (search-forward "\t" eol)
7285 (if (search-backward ">" beg t)
7291 (search-backward "<" beg t)
7294 (gnus-nov-field)) ; refs
7295 (gnus-nov-read-integer) ; chars
7296 (gnus-nov-read-integer) ; lines
7297 (if (= (following-char) ?\n)
7299 (gnus-nov-field)) ; misc
7303 (message "Strange nov line.")
7309 ;; We build the thread tree.
7311 (if (boundp (setq dep (intern (downcase id) dependencies)))
7312 (if (car (symbol-value dep))
7313 ;; An article with this Message-ID has already been seen,
7314 ;; so we ignore this one, except we add any additional
7315 ;; Xrefs (in case the two articles came from different
7318 (mail-header-set-xref
7319 (car (symbol-value dep))
7320 (concat (or (mail-header-xref (car (symbol-value dep))) "")
7321 (or (mail-header-xref header) "")))
7323 (setcar (symbol-value dep) header))
7324 (set dep (list header))))
7327 (if (boundp (setq dep (intern (or ref "none")
7329 (setcdr (symbol-value dep)
7330 (cons header (cdr (symbol-value dep))))
7331 (set dep (list nil header)))))
7334 (defun gnus-article-get-xrefs ()
7335 "Fill in the Xref value in `gnus-current-headers', if necessary.
7336 This is meant to be called in `gnus-article-internal-prepare-hook'."
7337 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
7338 gnus-current-headers)))
7339 (or (not gnus-use-cross-reference)
7341 (and (mail-header-xref headers)
7342 (not (string= (mail-header-xref headers) "")))
7343 (let ((case-fold-search t)
7346 (gnus-narrow-to-headers)
7347 (goto-char (point-min))
7348 (if (or (and (eq (downcase (following-char)) ?x)
7349 (looking-at "Xref:"))
7350 (search-forward "\nXref:" nil t))
7352 (goto-char (1+ (match-end 0)))
7353 (setq xref (buffer-substring (point)
7354 (progn (end-of-line) (point))))
7355 (mail-header-set-xref headers xref))))))))
7357 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
7358 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
7360 (defun gnus-make-headers-hashtable-by-number ()
7361 "Make hashtable for the variable gnus-newsgroup-headers by number."
7363 (set-buffer gnus-summary-buffer)
7364 (let ((headers gnus-newsgroup-headers)
7366 (setq gnus-newsgroup-headers-hashtb-by-number
7367 (gnus-make-hashtable (length headers)))
7369 (setq header (car headers))
7370 (gnus-sethash (int-to-string (mail-header-number header))
7371 header gnus-newsgroup-headers-hashtb-by-number)
7372 (setq headers (cdr headers))))))
7374 (defun gnus-more-header-backward ()
7375 "Find new header backward."
7376 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7377 (artnum gnus-newsgroup-begin)
7379 (while (and (not header)
7381 (setq artnum (1- artnum))
7382 (setq header (gnus-read-header artnum)))
7385 (defun gnus-more-header-forward (&optional backward)
7386 "Find new header forward.
7387 If BACKWARD, find new header backward instead."
7389 (gnus-more-header-backward)
7390 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
7391 (artnum gnus-newsgroup-end)
7393 (while (and (not header)
7395 (setq artnum (1+ artnum))
7396 (setq header (gnus-read-header artnum)))
7399 (defun gnus-extend-newsgroup (header &optional backward)
7400 "Extend newsgroup selection with HEADER.
7401 Optional argument BACKWARD means extend toward backward."
7403 (let ((artnum (mail-header-number header)))
7404 (setq gnus-newsgroup-headers
7406 (cons header gnus-newsgroup-headers)
7407 (nconc gnus-newsgroup-headers (list header))))
7408 (setq gnus-newsgroup-unselected
7409 (delq artnum gnus-newsgroup-unselected))
7410 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
7411 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
7413 (defun gnus-summary-work-articles (n)
7414 "Return a list of articles to be worked upon. The prefix argument,
7415 the list of process marked articles, and the current article will be
7416 taken into consideration."
7418 (if (and n (numberp n))
7419 (let ((backward (< n 0))
7423 (setq articles (cons (gnus-summary-article-number)
7425 (gnus-summary-search-forward nil nil backward))
7427 (sort articles (function <)))
7428 (or (reverse gnus-newsgroup-processable)
7429 (list (gnus-summary-article-number))))))
7431 (defun gnus-summary-search-group (&optional backward use-level)
7432 "Search for next unread newsgroup.
7433 If optional argument BACKWARD is non-nil, search backward instead."
7435 (set-buffer gnus-group-buffer)
7436 (if (gnus-group-search-forward
7437 backward nil (if use-level (gnus-group-group-level) nil))
7438 (gnus-group-group-name))))
7440 (defun gnus-summary-best-group (&optional exclude-group)
7441 "Find the name of the best unread group.
7442 If EXCLUDE-GROUP, do not go to this group."
7444 (set-buffer gnus-group-buffer)
7446 (gnus-group-best-unread-group exclude-group))))
7448 (defun gnus-subject-equal (s1 s2)
7450 ((null gnus-summary-gather-subject-limit)
7451 (equal (gnus-simplify-subject-re s1)
7452 (gnus-simplify-subject-re s2)))
7453 ((eq gnus-summary-gather-subject-limit 'fuzzy)
7454 (equal (gnus-simplify-subject-fuzzy s1)
7455 (gnus-simplify-subject-fuzzy s2)))
7456 ((numberp gnus-summary-gather-subject-limit)
7457 (equal (gnus-limit-string s1 gnus-summary-gather-subject-limit)
7458 (gnus-limit-string s2 gnus-summary-gather-subject-limit)))
7462 (defun gnus-summary-search-subject (&optional backward unread subject)
7463 "Search for article forward.
7464 If BACKWARD is non-nil, search backward.
7465 If UNREAD is non-nil, only unread articles are selected.
7466 If SUBJECT is non-nil, the article which has the same subject will be
7468 (let ((func (if backward 'previous-single-property-change
7469 'next-single-property-change))
7474 (and gnus-summary-check-current unread
7475 (eq (get-text-property (point) 'gnus-mark) gnus-unread-mark)
7479 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
7482 (setq pos (funcall func (point) 'gnus-number))
7483 (goto-char (if backward (1- pos) pos))
7487 (eq (get-text-property (point) 'gnus-mark)
7491 (inline (gnus-summary-subject-string)))
7493 (gnus-subject-equal subject psubject)))))))
7494 (if backward (if (bobp) nil (forward-char -1) t)
7495 (if (eobp) nil (forward-char 1) t)))))
7497 (progn (goto-char beg) nil)
7499 (get-text-property (point) 'gnus-number)
7500 (gnus-summary-position-cursor)))))
7502 (defun gnus-summary-pseudo-article ()
7503 "The thread level of the article on the current line."
7504 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
7506 (defalias 'gnus-summary-score 'gnus-summary-article-score)
7507 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
7508 (defun gnus-summary-article-score ()
7509 "Return current article score."
7510 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
7511 gnus-summary-default-score 0))
7513 (defun gnus-summary-recenter ()
7514 "Center point in the summary window.
7515 If `gnus-auto-center-summary' is nil, or the article buffer isn't
7516 displayed, no centering will be performed."
7517 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
7518 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
7519 (let* ((top (cond ((< (window-height) 4) 0)
7520 ((< (window-height) 7) 1)
7522 (height (1- (window-height)))
7523 (bottom (save-excursion (goto-char (point-max))
7524 (forward-line (- height))
7526 (window (get-buffer-window (current-buffer))))
7528 ;; The user has to want it,
7529 gnus-auto-center-summary
7530 ;; the article buffer must be displayed,
7531 (get-buffer-window gnus-article-buffer)
7532 ;; Set the window start to either `bottom', which is the biggest
7533 ;; possible valid number, or the second line from the top,
7534 ;; whichever is the least.
7536 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
7538 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
7539 (defun gnus-short-group-name (group &optional levels)
7540 "Collapse GROUP name LEVELS."
7541 (let* ((name "") (foreign "") (depth -1) (skip 1)
7544 (while (string-match "\\." group skip)
7545 (setq skip (match-end 0)
7548 (if (string-match ":" group)
7549 (setq foreign (substring group 0 (match-end 0))
7550 group (substring group (match-end 0))))
7552 (if (and (string-match "\\." group) (> levels 0))
7553 (setq name (concat name (substring group 0 1))
7554 group (substring group (match-end 0))
7556 name (concat name "."))
7557 (setq name (concat foreign name group)
7561 (defun gnus-summary-jump-to-group (newsgroup)
7562 "Move point to NEWSGROUP in group mode buffer."
7563 ;; Keep update point of group mode buffer if visible.
7564 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
7565 (save-window-excursion
7566 ;; Take care of tree window mode.
7567 (if (get-buffer-window gnus-group-buffer)
7568 (pop-to-buffer gnus-group-buffer))
7569 (gnus-group-jump-to-group newsgroup))
7571 ;; Take care of tree window mode.
7572 (if (get-buffer-window gnus-group-buffer)
7573 (pop-to-buffer gnus-group-buffer)
7574 (set-buffer gnus-group-buffer))
7575 (gnus-group-jump-to-group newsgroup))))
7577 ;; This function returns a list of article numbers based on the
7578 ;; difference between the ranges of read articles in this group and
7579 ;; the range of active articles.
7580 (defun gnus-list-of-unread-articles (group)
7581 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
7582 (active (gnus-gethash group gnus-active-hashtb))
7585 ;; If none are read, then all are unread.
7587 (setq first (car active))
7588 ;; If the range of read articles is a single range, then the
7589 ;; first unread article is the article after the last read
7590 ;; article. Sounds logical, doesn't it?
7591 (if (not (listp (cdr read)))
7592 (setq first (1+ (cdr read)))
7593 ;; `read' is a list of ranges.
7594 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
7595 (car (car read)))) 1)
7599 (while (< first nlast)
7600 (setq unread (cons first unread))
7601 (setq first (1+ first))))
7602 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
7603 (setq nlast (if (atom (car (cdr read)))
7605 (car (car (cdr read)))))
7606 (setq read (cdr read)))))
7607 ;; And add the last unread articles.
7608 (while (<= first last)
7609 (setq unread (cons first unread))
7610 (setq first (1+ first)))
7611 ;; Return the list of unread articles.
7614 (defun gnus-list-of-read-articles (group)
7615 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
7616 (active (gnus-gethash group gnus-active-hashtb)))
7618 (gnus-sorted-complement
7619 (gnus-uncompress-range active)
7620 (gnus-list-of-unread-articles group)))))
7622 ;; Various summary commands
7624 (defun gnus-summary-universal-argument ()
7625 "Perform any operation on all articles marked with the process mark."
7627 (gnus-set-global-variables)
7628 (let ((articles (reverse gnus-newsgroup-processable))
7630 (or articles (error "No articles marked"))
7631 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
7632 (error "Undefined key"))
7634 (gnus-summary-goto-subject (car articles))
7635 (command-execute func)
7636 (gnus-summary-remove-process-mark (car articles))
7637 (setq articles (cdr articles)))))
7639 (defun gnus-summary-toggle-truncation (&optional arg)
7640 "Toggle truncation of summary lines.
7641 With arg, turn line truncation on iff arg is positive."
7643 (setq truncate-lines
7644 (if (null arg) (not truncate-lines)
7645 (> (prefix-numeric-value arg) 0)))
7648 (defun gnus-summary-reselect-current-group (&optional all)
7649 "Once exit and then reselect the current newsgroup.
7650 The prefix argument ALL means to select all articles."
7652 (gnus-set-global-variables)
7653 (let ((current-subject (gnus-summary-article-number))
7654 (group gnus-newsgroup-name))
7655 (setq gnus-newsgroup-begin nil)
7656 (gnus-summary-exit t)
7657 ;; We have to adjust the point of group mode buffer because the
7658 ;; current point was moved to the next unread newsgroup by
7660 (gnus-summary-jump-to-group group)
7661 (gnus-group-read-group all t)
7662 (gnus-summary-goto-subject current-subject)))
7664 (defun gnus-summary-rescan-group (&optional all)
7665 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7667 (gnus-set-global-variables)
7668 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
7669 (let ((group gnus-newsgroup-name))
7671 (gnus-summary-jump-to-group group)
7673 (set-buffer gnus-group-buffer)
7674 (gnus-group-get-new-news-this-group 1))
7675 (gnus-summary-jump-to-group group)
7676 (gnus-group-read-group all)))
7678 (defun gnus-summary-update-info ()
7679 (let* ((group gnus-newsgroup-name))
7680 (if gnus-newsgroup-kill-headers
7681 (setq gnus-newsgroup-killed
7682 (gnus-compress-sequence
7684 (gnus-set-sorted-intersection
7685 (gnus-uncompress-range gnus-newsgroup-killed)
7686 (setq gnus-newsgroup-unselected
7687 (sort gnus-newsgroup-unselected '<)))
7688 (setq gnus-newsgroup-unreads
7689 (sort gnus-newsgroup-unreads '<))) t)))
7690 (or (listp (cdr gnus-newsgroup-killed))
7691 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7692 (let ((headers gnus-newsgroup-headers))
7693 (gnus-close-group group)
7694 (run-hooks 'gnus-exit-group-hook)
7695 (gnus-update-read-articles
7696 group gnus-newsgroup-unreads gnus-newsgroup-unselected
7697 gnus-newsgroup-marked
7698 t gnus-newsgroup-replied gnus-newsgroup-expirable
7699 gnus-newsgroup-killed gnus-newsgroup-dormant
7700 gnus-newsgroup-bookmarks
7701 (and gnus-save-score gnus-newsgroup-scored))
7702 (and gnus-use-cross-reference
7703 (gnus-mark-xrefs-as-read
7704 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
7705 ;; Do adaptive scoring, and possibly save score files.
7706 (and gnus-newsgroup-adaptive
7707 (gnus-score-adaptive))
7708 (and gnus-use-scoring
7709 (fboundp 'gnus-score-save)
7710 (funcall 'gnus-score-save))
7711 ;; Do not switch windows but change the buffer to work.
7712 (set-buffer gnus-group-buffer)
7713 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
7714 (gnus-group-update-group group)))))
7716 (defun gnus-summary-exit (&optional temporary)
7717 "Exit reading current newsgroup, and then return to group selection mode.
7718 gnus-exit-group-hook is called with no arguments if that value is non-nil."
7720 (gnus-set-global-variables)
7721 (gnus-kill-save-kill-buffer)
7722 (let* ((group gnus-newsgroup-name)
7723 (quit-config (nth 1 (assoc 'quit-config (gnus-find-method-for-group
7724 gnus-newsgroup-name))))
7726 (buf (current-buffer)))
7727 (run-hooks 'gnus-summary-prepare-exit-hook)
7728 (gnus-summary-update-info) ; Make all changes in this group permanent.
7730 (and gnus-use-cache (gnus-cache-possibly-remove-articles))
7731 ;; Make sure where I was, and go to next newsgroup.
7732 (set-buffer gnus-group-buffer)
7735 (gnus-group-jump-to-group group)
7736 (gnus-group-next-unread-group 1)))
7739 ;; We set all buffer-local variables to nil. It is unclear why
7740 ;; this is needed, but if we don't, buffer-local variables are
7741 ;; not garbage-collected, it seems. This would the lead to en
7742 ;; ever-growing Emacs.
7744 (gnus-summary-clear-local-variables)
7745 ;; We clear the global counterparts of the buffer-local
7746 ;; variables as well, just to be on the safe side.
7747 (gnus-configure-windows 'group 'force)
7748 (gnus-summary-clear-local-variables)
7749 ;; Return to group mode buffer.
7750 (if (eq mode 'gnus-summary-mode)
7751 (gnus-kill-buffer buf))
7752 (if (get-buffer gnus-article-buffer)
7753 (bury-buffer gnus-article-buffer))
7754 (setq gnus-current-select-method gnus-select-method)
7755 (pop-to-buffer gnus-group-buffer)
7756 (if (not quit-config)
7758 (gnus-group-jump-to-group group)
7759 (gnus-group-next-unread-group 1))
7760 (if (not (buffer-name (car quit-config)))
7761 (gnus-configure-windows 'group 'force)
7762 (set-buffer (car quit-config))
7763 (and (eq major-mode 'gnus-summary-mode)
7764 (gnus-set-global-variables))
7765 (gnus-configure-windows (cdr quit-config))))
7766 (run-hooks 'gnus-summary-exit-hook))))
7768 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7769 (defun gnus-summary-exit-no-update (&optional no-questions)
7770 "Quit reading current newsgroup without updating read article info."
7772 (gnus-set-global-variables)
7773 (let* ((group gnus-newsgroup-name)
7774 (quit-config (nth 1 (assoc 'quit-config
7775 (gnus-find-method-for-group group)))))
7776 (if (or no-questions
7778 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7780 (gnus-close-group group)
7781 (gnus-summary-clear-local-variables)
7782 (set-buffer gnus-group-buffer)
7783 (gnus-summary-clear-local-variables)
7784 ;; Return to group selection mode.
7785 (gnus-configure-windows 'group 'force)
7786 (if (get-buffer gnus-summary-buffer)
7787 (kill-buffer gnus-summary-buffer))
7788 (if (get-buffer gnus-article-buffer)
7789 (bury-buffer gnus-article-buffer))
7790 (if (equal (gnus-group-group-name) group)
7791 (gnus-group-next-unread-group 1))
7794 (if (not (buffer-name (car quit-config)))
7795 (gnus-configure-windows 'group 'force)
7796 (set-buffer (car quit-config))
7797 (and (eq major-mode 'gnus-summary-mode)
7798 (gnus-set-global-variables))
7799 (gnus-configure-windows (cdr quit-config)))))))))
7801 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7802 (defun gnus-summary-fetch-faq (group)
7803 "Fetch the FAQ for the current group."
7804 (interactive (list gnus-newsgroup-name))
7805 (let (gnus-faq-buffer)
7806 (and (setq gnus-faq-buffer (gnus-group-fetch-faq group))
7807 (gnus-configure-windows 'summary-faq))))
7809 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7810 (defun gnus-summary-describe-group (&optional force)
7811 "Describe the current newsgroup."
7813 (gnus-group-describe-group force gnus-newsgroup-name))
7815 (defun gnus-summary-describe-briefly ()
7816 "Describe summary mode commands briefly."
7819 (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")))
7821 ;; Walking around group mode buffer from summary mode.
7823 (defun gnus-summary-next-group (&optional no-article target-group backward)
7824 "Exit current newsgroup and then select next unread newsgroup.
7825 If prefix argument NO-ARTICLE is non-nil, no article is selected
7826 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
7827 previous group instead."
7829 (gnus-set-global-variables)
7830 (let ((current-group gnus-newsgroup-name)
7831 (current-buffer (current-buffer))
7833 ;; First we semi-exit this group to update Xrefs and all variables.
7834 ;; We can't do a real exit, because the window conf must remain
7835 ;; the same in case the user is prompted for info, and we don't
7836 ;; want the window conf to change before that...
7837 (gnus-summary-exit t)
7838 (while (not entered)
7839 ;; Then we find what group we are supposed to enter.
7840 (set-buffer gnus-group-buffer)
7841 (gnus-group-jump-to-group current-group)
7844 (if (eq gnus-keep-same-level 'best)
7845 (gnus-summary-best-group gnus-newsgroup-name)
7846 (gnus-summary-search-group backward gnus-keep-same-level))))
7847 (if (not target-group)
7848 ;; There are no further groups, so we return to the group
7851 (gnus-message 5 "Returning to the group buffer")
7853 (set-buffer current-buffer)
7854 (gnus-summary-exit))
7855 ;; We try to enter the target group.
7856 (gnus-group-jump-to-group target-group)
7857 (let ((unreads (gnus-group-group-unread)))
7858 (if (and (or (eq t unreads)
7859 (and unreads (not (zerop unreads))))
7860 (gnus-summary-read-group
7861 target-group nil no-article current-buffer))
7863 (setq current-group target-group
7864 target-group nil)))))))
7866 (defun gnus-summary-next-group-old (&optional no-article group backward)
7867 "Exit current newsgroup and then select next unread newsgroup.
7868 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7869 If BACKWARD, go to previous group instead."
7871 (gnus-set-global-variables)
7872 (let ((ingroup gnus-newsgroup-name)
7873 (sumbuf (current-buffer))
7875 (set-buffer gnus-group-buffer)
7877 (or (and (numberp (setq num (car (gnus-gethash
7878 group gnus-newsrc-hashtb))))
7882 (gnus-group-jump-to-group group)
7884 (gnus-group-jump-to-group ingroup))
7885 (gnus-summary-search-group backward)
7886 (let ((group (or group (gnus-summary-search-group backward))))
7888 (gnus-summary-exit t) ;Update all information.
7890 (gnus-summary-exit-no-update t)
7891 (gnus-group-jump-to-group ingroup)
7892 (setq group (gnus-summary-search-group backward))
7893 (gnus-message 5 "Selecting %s..." group)
7894 (set-buffer gnus-group-buffer)
7895 ;; We are now in group mode buffer.
7896 ;; Make sure group mode buffer point is on GROUP.
7897 (gnus-group-jump-to-group group)
7898 (if (not (eq gnus-auto-select-next 'quietly))
7900 (gnus-summary-read-group group nil no-article sumbuf)
7901 (and (string= gnus-newsgroup-name ingroup)
7902 (bufferp sumbuf) (buffer-name sumbuf)
7904 (set-buffer (setq gnus-summary-buffer sumbuf))
7905 (gnus-summary-exit-no-update t))))
7906 (let ((prevgroup group))
7907 (gnus-group-jump-to-group ingroup)
7908 (setq group (gnus-summary-search-group backward))
7909 (gnus-summary-read-group group nil no-article sumbuf)
7910 (while (and (string= gnus-newsgroup-name ingroup)
7912 (buffer-name sumbuf)
7913 (not (string= prevgroup (gnus-group-group-name))))
7914 (set-buffer gnus-group-buffer)
7915 (gnus-summary-read-group
7916 (setq prevgroup (gnus-group-group-name))
7917 nil no-article sumbuf))
7918 (and (string= prevgroup (gnus-group-group-name))
7919 ;; We have reached the final group in the group
7922 (if (buffer-name sumbuf)
7925 (gnus-summary-exit)))))))))))
7927 (defun gnus-summary-prev-group (&optional no-article)
7928 "Exit current newsgroup and then select previous unread newsgroup.
7929 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7931 (gnus-summary-next-group no-article nil t))
7933 ;; Walking around summary lines.
7935 (defun gnus-summary-first-subject (&optional unread)
7936 "Go to the first unread subject.
7937 If UNREAD is non-nil, go to the first unread article.
7938 Returns nil if there are no unread articles."
7942 (goto-char (point-min)))
7945 (point-min) (point-max) 'gnus-mark gnus-unread-mark))
7948 ;; There are no unread articles.
7949 (gnus-message 3 "No more unread articles")
7951 (gnus-summary-position-cursor)))
7953 (defun gnus-summary-next-subject (n &optional unread dont-display)
7954 "Go to next N'th summary line.
7955 If N is negative, go to the previous N'th subject line.
7956 If UNREAD is non-nil, only unread articles are selected.
7957 The difference between N and the actual number of steps taken is
7960 (let ((backward (< n 0))
7963 (gnus-summary-search-forward unread nil backward))
7965 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7966 (if unread " unread" "")))
7969 (gnus-summary-recenter)
7970 (gnus-summary-position-cursor)))
7973 (defun gnus-summary-next-unread-subject (n)
7974 "Go to next N'th unread summary line."
7976 (gnus-summary-next-subject n t))
7978 (defun gnus-summary-prev-subject (n &optional unread)
7979 "Go to previous N'th summary line.
7980 If optional argument UNREAD is non-nil, only unread article is selected."
7982 (gnus-summary-next-subject (- n) unread))
7984 (defun gnus-summary-prev-unread-subject (n)
7985 "Go to previous N'th unread summary line."
7987 (gnus-summary-next-subject (- n) t))
7989 (defun gnus-summary-goto-subject (article)
7990 "Go the subject line of ARTICLE."
7994 (completing-read "Article number: "
7998 (int-to-string (mail-header-number headers))))
7999 gnus-newsgroup-headers)
8000 nil 'require-match))))
8001 (or article (error "No article number"))
8003 (if (not (gnus-goto-char (text-property-any (point-min) (point-max)
8004 'gnus-number article)))
8006 (gnus-summary-show-thread)
8007 ;; Skip dummy articles.
8008 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8015 (gnus-summary-position-cursor)))))
8017 ;; Walking around summary lines with displaying articles.
8019 (defun gnus-summary-expand-window (&optional arg)
8020 "Make the summary buffer take up the entire Emacs frame.
8021 Given a prefix, will force an `article' buffer configuration."
8023 (gnus-set-global-variables)
8025 (gnus-configure-windows 'article 'force)
8026 (gnus-configure-windows 'summary 'force)))
8028 (defun gnus-summary-display-article (article &optional all-header)
8029 "Display ARTICLE in article buffer."
8030 (gnus-set-global-variables)
8034 (gnus-article-prepare article all-header)
8035 (gnus-summary-show-thread)
8036 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
8039 (gnus-summary-position-cursor)))
8040 (run-hooks 'gnus-select-article-hook)
8041 (gnus-summary-recenter)
8042 (gnus-summary-goto-subject article)
8043 ;; Successfully display article.
8044 (gnus-summary-update-line)
8045 (gnus-article-set-window-start
8046 (cdr (assq article gnus-newsgroup-bookmarks)))
8049 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
8050 "Select the current article.
8051 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
8052 non-nil, the article will be re-fetched even if it already present in
8053 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
8055 (and (not pseudo) (gnus-summary-pseudo-article)
8056 (error "This is a pseudo-article."))
8057 (let ((article (or article (gnus-summary-article-number)))
8058 (all-headers (not (not all-headers))) ;Must be T or NIL.
8062 (set-buffer gnus-summary-buffer)
8063 (if (or (null gnus-current-article)
8064 (null gnus-article-current)
8065 (null (get-buffer gnus-article-buffer))
8066 (not (eq article (cdr gnus-article-current)))
8067 (not (equal (car gnus-article-current) gnus-newsgroup-name))
8069 ;; The requested article is different from the current article.
8071 (gnus-summary-display-article article all-headers)
8073 (if (or all-headers gnus-show-all-headers)
8074 (gnus-article-show-all-headers))
8077 (gnus-article-set-window-start
8078 (cdr (assq article gnus-newsgroup-bookmarks)))))))
8080 (defun gnus-summary-set-current-mark (&optional current-mark)
8081 "Obsolete function."
8084 (defun gnus-summary-next-article (&optional unread subject backward)
8085 "Select the next article.
8086 If UNREAD, only unread articles are selected.
8087 If SUBJECT, only articles with SUBJECT are selected.
8088 If BACKWARD, the previous article is selected instead of the next."
8090 (gnus-set-global-variables)
8093 ;; Is there such an article?
8094 ((and (gnus-summary-search-forward unread subject backward)
8095 (or (gnus-summary-display-article (gnus-summary-article-number))
8096 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8097 (gnus-summary-position-cursor))
8098 ;; If not, we try the first unread, if that is wanted.
8100 gnus-auto-select-same
8101 (or (gnus-summary-first-unread-article)
8102 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
8103 (gnus-summary-position-cursor)
8104 (gnus-message 6 "Wrapped"))
8105 ;; Try to get next/previous article not displayed in this group.
8106 ((and gnus-auto-extend-newsgroup
8107 (not unread) (not subject)
8108 (setq header (gnus-more-header-forward backward)))
8109 (gnus-extend-newsgroup header backward)
8110 (let ((buffer-read-only nil))
8111 (goto-char (if backward (point-min) (point-max)))
8112 (gnus-summary-prepare-threads (list header)))
8113 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
8114 gnus-newsgroup-end)))
8115 ;; Go to next/previous group.
8117 (or (assoc 'quit-config (gnus-find-method-for-group gnus-newsgroup-name))
8118 (gnus-summary-jump-to-group gnus-newsgroup-name))
8119 (let ((cmd last-command-char)
8121 (if (eq gnus-keep-same-level 'best)
8122 (gnus-summary-best-group gnus-newsgroup-name)
8123 (gnus-summary-search-group backward gnus-keep-same-level))))
8124 ;; For some reason, the group window gets selected. We change
8126 (select-window (get-buffer-window (current-buffer)))
8127 ;; Keep just the event type of CMD.
8128 ;(and (listp cmd) (setq cmd (car cmd)))
8129 ;; Select next unread newsgroup automagically.
8131 ((not gnus-auto-select-next)
8132 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
8133 ((eq gnus-auto-select-next 'quietly)
8135 (if (assoc 'quit-config (gnus-find-method-for-group
8136 gnus-newsgroup-name))
8138 (gnus-message 7 "No more%s articles (%s)..."
8139 (if unread " unread" "")
8140 (if group (concat "selecting " group)
8142 (gnus-summary-next-group nil group backward)))
8144 (let ((keystrokes '(?\C-n ?\C-p))
8146 (while (or (null key) (memq key keystrokes))
8148 7 "No more%s articles%s" (if unread " unread" "")
8149 (if (and group (not (assoc 'quit-config
8150 (gnus-find-method-for-group
8151 gnus-newsgroup-name))))
8152 (format " (Type %s for %s [%s])"
8153 (single-key-description cmd) group
8154 (car (gnus-gethash group gnus-newsrc-hashtb)))
8155 (format " (Type %s to exit %s)"
8156 (single-key-description cmd)
8157 gnus-newsgroup-name)))
8158 ;; Confirm auto selection.
8159 (let* ((event (read-char)))
8160 (setq key (if (listp event) (car event) event))
8161 (if (memq key keystrokes)
8162 (let ((obuf (current-buffer)))
8163 (switch-to-buffer gnus-group-buffer)
8165 (gnus-group-jump-to-group group))
8167 (execute-kbd-macro (char-to-string key))
8169 (setq group (gnus-group-group-name))
8170 (switch-to-buffer obuf)))))
8172 (if (or (not group) (assoc 'quit-config
8173 (gnus-find-method-for-group
8174 gnus-newsgroup-name)))
8176 (gnus-summary-next-group nil group backward))
8177 (execute-kbd-macro (char-to-string key)))))))))))
8179 (defun gnus-summary-next-unread-article ()
8180 "Select unread article after current one."
8182 (gnus-summary-next-article t (and gnus-auto-select-same
8183 (gnus-summary-subject-string))))
8185 (defun gnus-summary-prev-article (&optional unread subject)
8186 "Select the article after the current one.
8187 If UNREAD is non-nil, only unread articles are selected."
8189 (gnus-summary-next-article unread subject t))
8191 (defun gnus-summary-prev-unread-article ()
8192 "Select unred article before current one."
8194 (gnus-summary-prev-article t (and gnus-auto-select-same
8195 (gnus-summary-subject-string))))
8197 (defun gnus-summary-next-page (&optional lines circular)
8198 "Show next page of selected article.
8199 If end of article, select next article.
8200 Argument LINES specifies lines to be scrolled up.
8201 If CIRCULAR is non-nil, go to the start of the article instead of
8202 instead of selecting the next article when reaching the end of the
8205 (setq gnus-summary-buffer (current-buffer))
8206 (gnus-set-global-variables)
8207 (let ((article (gnus-summary-article-number))
8209 (gnus-configure-windows 'article)
8210 (if (or (null gnus-current-article)
8211 (null gnus-article-current)
8212 (/= article (cdr gnus-article-current))
8213 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8214 ;; Selected subject is different from current article's.
8215 (gnus-summary-display-article article)
8216 (gnus-eval-in-buffer-window
8218 (setq endp (gnus-article-next-page lines)))
8221 (gnus-summary-beginning-of-article))
8223 (gnus-message 3 "End of message"))
8225 (gnus-summary-next-unread-article)))))
8226 (gnus-summary-recenter)
8227 (gnus-summary-position-cursor)))
8229 (defun gnus-summary-prev-page (&optional lines)
8230 "Show previous page of selected article.
8231 Argument LINES specifies lines to be scrolled down."
8233 (gnus-set-global-variables)
8234 (let ((article (gnus-summary-article-number)))
8235 (gnus-configure-windows 'article)
8236 (if (or (null gnus-current-article)
8237 (null gnus-article-current)
8238 (/= article (cdr gnus-article-current))
8239 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
8240 ;; Selected subject is different from current article's.
8241 (gnus-summary-display-article article)
8242 (gnus-summary-recenter)
8243 (gnus-eval-in-buffer-window gnus-article-buffer
8244 (gnus-article-prev-page lines))))
8245 (gnus-summary-position-cursor))
8247 (defun gnus-summary-scroll-up (lines)
8248 "Scroll up (or down) one line current article.
8249 Argument LINES specifies lines to be scrolled up (or down if negative)."
8251 (gnus-set-global-variables)
8252 (gnus-configure-windows 'article)
8253 (or (gnus-summary-select-article nil nil 'pseudo)
8254 (gnus-eval-in-buffer-window
8257 (if (gnus-article-next-page lines)
8258 (gnus-message 3 "End of message")))
8260 (gnus-article-prev-page (- lines))))))
8261 (gnus-summary-recenter)
8262 (gnus-summary-position-cursor))
8264 (defun gnus-summary-next-same-subject ()
8265 "Select next article which has the same subject as current one."
8267 (gnus-set-global-variables)
8268 (gnus-summary-next-article nil (gnus-summary-subject-string)))
8270 (defun gnus-summary-prev-same-subject ()
8271 "Select previous article which has the same subject as current one."
8273 (gnus-set-global-variables)
8274 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
8276 (defun gnus-summary-next-unread-same-subject ()
8277 "Select next unread article which has the same subject as current one."
8279 (gnus-set-global-variables)
8280 (gnus-summary-next-article t (gnus-summary-subject-string)))
8282 (defun gnus-summary-prev-unread-same-subject ()
8283 "Select previous unread article which has the same subject as current one."
8285 (gnus-set-global-variables)
8286 (gnus-summary-prev-article t (gnus-summary-subject-string)))
8288 (defun gnus-summary-first-unread-article ()
8289 "Select the first unread article.
8290 Return nil if there are no unread articles."
8292 (gnus-set-global-variables)
8294 (if (gnus-summary-first-subject t)
8296 (gnus-summary-show-thread)
8297 (gnus-summary-first-subject t)
8298 (gnus-summary-display-article (gnus-summary-article-number))))
8299 (gnus-summary-position-cursor)))
8301 (defun gnus-summary-best-unread-article ()
8302 "Select the unread article with the highest score."
8304 (gnus-set-global-variables)
8305 (let ((scored gnus-newsgroup-scored)
8309 (or (> best (cdr (car scored)))
8310 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
8311 (not (memq art gnus-newsgroup-marked))
8312 (not (memq art gnus-newsgroup-dormant))
8313 (if (= best (cdr (car scored)))
8314 (setq article (min art article))
8316 (setq best (cdr (car scored))))))
8317 (setq scored (cdr scored)))
8319 ((or (not article) (null gnus-newsgroup-unreads))
8320 ;; We didn't find any scored articles, so we just jump to the
8322 (gnus-summary-first-unread-article))
8323 ((> best gnus-summary-default-score)
8324 ;; We found one, and it's bigger than the default score, so we
8326 (gnus-summary-goto-article article))
8328 ;; We found an article, but it has a score lower than the
8329 ;; defaults, so we try to find an article with the default
8331 (goto-char (point-min))
8332 (while (and (or (not (= (gnus-summary-article-mark) gnus-unread-mark))
8333 (and (assq (gnus-summary-article-number)
8334 gnus-newsgroup-scored)
8335 (< (cdr (assq (gnus-summary-article-number)
8336 gnus-newsgroup-scored))
8337 gnus-summary-default-score)))
8338 (zerop (forward-line 1))
8340 (if (= (gnus-summary-article-mark) gnus-unread-mark)
8341 ;; We jump to the article we have finally found.
8342 (gnus-summary-goto-article (gnus-summary-article-number))
8343 ;; Or there were no default-scored articles.
8344 (gnus-summary-goto-article article))))
8345 (gnus-summary-position-cursor)))
8347 (defun gnus-summary-goto-article (article &optional all-headers)
8348 "Fetch ARTICLE and display it if it exists.
8349 If ALL-HEADERS is non-nil, no header lines are hidden."
8355 (mapcar (lambda (headers) (list (int-to-string (mail-header-number headers))))
8356 gnus-newsgroup-headers)
8357 nil 'require-match))))
8359 (and (gnus-summary-goto-subject article)
8360 (gnus-summary-display-article article all-headers))
8361 (gnus-summary-position-cursor)))
8363 (defun gnus-summary-goto-last-article ()
8364 "Go to the previously read article."
8367 (and gnus-last-article
8368 (gnus-summary-goto-article gnus-last-article))
8369 (gnus-summary-position-cursor)))
8371 (defun gnus-summary-pop-article (number)
8372 "Pop one article off the history and go to the previous.
8373 NUMBER articles will be popped off."
8376 (setq gnus-newsgroup-history
8377 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8379 (gnus-summary-goto-article (car to))
8380 (error "Article history empty")))
8381 (gnus-summary-position-cursor))
8383 ;; Summary article oriented commands
8385 (defun gnus-summary-refer-parent-article (n)
8386 "Refer parent article N times.
8387 The difference between N and the number of articles fetched is returned."
8389 (gnus-set-global-variables)
8393 (let ((ref (mail-header-references (gnus-get-header-by-num
8394 (gnus-summary-article-number)))))
8395 (if (and ref (not (equal ref ""))
8396 (string-match "<[^<>]*>[ \t]*$" ref))
8397 (gnus-summary-refer-article
8398 (substring ref (match-beginning 0) (match-end 0)))
8399 (gnus-message 1 "No references in article %d"
8400 (gnus-summary-article-number))
8403 (gnus-summary-position-cursor)
8406 (defun gnus-summary-refer-article (message-id)
8407 "Refer article specified by MESSAGE-ID.
8408 NOTE: This command only works with newsgroups that use real or simulated NNTP."
8409 (interactive "sMessage-ID: ")
8410 (if (or (not (stringp message-id))
8411 (zerop (length message-id)))
8413 ;; Construct the correct Message-ID if necessary.
8414 ;; Suggested by tale@pawl.rpi.edu.
8415 (or (string-match "^<" message-id)
8416 (setq message-id (concat "<" message-id)))
8417 (or (string-match ">$" message-id)
8418 (setq message-id (concat message-id ">")))
8419 (let ((header (car (gnus-gethash (downcase message-id)
8420 gnus-newsgroup-dependencies))))
8422 (or (gnus-summary-goto-article (mail-header-number header))
8423 ;; The header has been read, but the article had been
8424 ;; expunged, so we insert it again.
8426 (gnus-summary-insert-line
8427 nil header 0 nil gnus-read-mark nil nil
8428 (mail-header-subject header))
8430 (mail-header-number header)))
8431 (let ((gnus-override-method gnus-refer-article-method)
8432 (gnus-ancient-mark gnus-read-mark)
8433 (tmp-point (window-start
8434 (get-buffer-window gnus-article-buffer)))
8436 (and gnus-refer-article-method
8437 (gnus-check-server gnus-refer-article-method))
8438 ;; Save the old article buffer.
8440 (set-buffer (gnus-article-setup-buffer))
8441 (gnus-kill-buffer " *temp Article*")
8442 (setq tmp-buf (rename-buffer " *temp Article*")))
8444 (if (gnus-article-prepare
8445 message-id nil (gnus-read-header message-id))
8447 (setq number (mail-header-number gnus-current-headers))
8448 (gnus-rebuild-thread message-id)
8449 (gnus-summary-goto-subject number)
8450 (if (null gnus-use-full-window)
8452 (delete-windows-on tmp-buf)
8453 (gnus-configure-windows 'article 'force)))
8454 (gnus-summary-recenter)
8455 (gnus-article-set-window-start
8456 (cdr (assq number gnus-newsgroup-bookmarks)))
8458 ;; We restore the old article buffer.
8460 (kill-buffer gnus-article-buffer)
8461 (set-buffer tmp-buf)
8462 (rename-buffer gnus-article-buffer)
8463 (let ((buffer-read-only nil))
8465 (set-window-start (get-buffer-window (current-buffer))
8466 tmp-point)))))))))))
8468 (defun gnus-summary-enter-digest-group ()
8469 "Enter a digest group based on the current article."
8471 (gnus-set-global-variables)
8472 (gnus-summary-select-article)
8473 ;; We do not want a narrowed article.
8474 (gnus-summary-stop-page-breaking)
8475 (let ((name (format "%s-%d"
8476 (gnus-group-prefixed-name
8477 gnus-newsgroup-name (list 'nndoc ""))
8478 gnus-current-article))
8479 (ogroup gnus-newsgroup-name)
8480 (buf (current-buffer)))
8481 (if (gnus-group-read-ephemeral-group
8482 name (list 'nndoc name
8483 (list 'nndoc-address (get-buffer gnus-article-buffer))
8484 '(nndoc-article-type digest))
8486 (setcdr (nthcdr 4 (nth 2 (gnus-gethash name gnus-newsrc-hashtb)))
8487 (list (list (cons 'to-group ogroup))))
8488 (switch-to-buffer buf)
8489 (gnus-set-global-variables)
8490 (gnus-configure-windows 'summary)
8491 (gnus-message 3 "Article not a digest?"))))
8493 (defun gnus-summary-isearch-article ()
8494 "Do incremental search forward on current article."
8496 (gnus-set-global-variables)
8497 (gnus-summary-select-article)
8498 (gnus-eval-in-buffer-window
8499 gnus-article-buffer (isearch-forward)))
8501 (defun gnus-summary-search-article-forward (regexp &optional backward)
8502 "Search for an article containing REGEXP forward.
8503 If BACKWARD, search backward instead."
8506 (format "Search article %s (regexp%s): "
8507 (if current-prefix-arg "backward" "forward")
8508 (if gnus-last-search-regexp
8509 (concat ", default " gnus-last-search-regexp)
8511 current-prefix-arg))
8512 (gnus-set-global-variables)
8513 (if (string-equal regexp "")
8514 (setq regexp (or gnus-last-search-regexp ""))
8515 (setq gnus-last-search-regexp regexp))
8516 (if (gnus-summary-search-article regexp backward)
8517 (gnus-article-set-window-start
8518 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
8519 (error "Search failed: \"%s\"" regexp)))
8521 (defun gnus-summary-search-article-backward (regexp)
8522 "Search for an article containing REGEXP backward."
8525 (format "Search article backward (regexp%s): "
8526 (if gnus-last-search-regexp
8527 (concat ", default " gnus-last-search-regexp)
8529 (gnus-summary-search-article-forward regexp 'backward))
8531 (defun gnus-summary-search-article (regexp &optional backward)
8532 "Search for an article containing REGEXP.
8533 Optional argument BACKWARD means do search for backward.
8534 gnus-select-article-hook is not called during the search."
8535 (let ((gnus-select-article-hook nil) ;Disable hook.
8536 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8539 (function re-search-backward) (function re-search-forward)))
8542 ;; Hidden thread subtrees must be searched for ,too.
8543 (gnus-summary-show-all-threads)
8544 (if (eobp) (forward-line -1))
8545 ;; First of all, search current article.
8546 ;; We don't want to read article again from NNTP server nor reset
8548 (gnus-summary-select-article)
8549 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8550 (setq last gnus-current-article)
8551 (gnus-eval-in-buffer-window gnus-article-buffer
8554 ;; Begin search from current point.
8555 (setq found (funcall re-search regexp nil t))))
8556 ;; Then search next articles.
8557 (while (and (not found)
8558 (gnus-summary-display-article
8559 (gnus-summary-search-subject backward nil nil)))
8560 (gnus-message 9 "Searching article: %d..." gnus-current-article)
8561 (gnus-eval-in-buffer-window gnus-article-buffer
8564 (goto-char (if backward (point-max) (point-min)))
8565 (setq found (funcall re-search regexp nil t)))))
8567 ;; Adjust article pointer.
8568 (or (eq last gnus-current-article)
8569 (setq gnus-last-article last))
8570 ;; Return T if found such article.
8573 (defun gnus-summary-execute-command (header regexp command &optional backward)
8574 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8575 If HEADER is an empty string (or nil), the match is done on the entire
8576 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8578 (list (let ((completion-ignore-case t))
8581 (mapcar (lambda (string) (list string))
8582 '("Number" "Subject" "From" "Lines" "Date"
8583 "Message-ID" "Xref" "References"))
8584 nil 'require-match))
8585 (read-string "Regexp: ")
8586 (read-key-sequence "Command: ")
8587 current-prefix-arg))
8588 (gnus-set-global-variables)
8589 ;; Hidden thread subtrees must be searched as well.
8590 (gnus-summary-show-all-threads)
8591 ;; We don't want to change current point nor window configuration.
8593 (save-window-excursion
8594 (gnus-message 6 "Executing %s..." (key-description command))
8595 ;; We'd like to execute COMMAND interactively so as to give arguments.
8596 (gnus-execute header regexp
8598 (call-interactively '(, (key-binding command)))))
8600 (gnus-message 6 "Executing %s...done" (key-description command)))))
8602 (defun gnus-summary-beginning-of-article ()
8603 "Scroll the article back to the beginning."
8605 (gnus-set-global-variables)
8606 (gnus-summary-select-article)
8607 (gnus-configure-windows 'article)
8608 (gnus-eval-in-buffer-window
8611 (goto-char (point-min))
8612 (and gnus-break-pages (gnus-narrow-to-page))))
8614 (defun gnus-summary-end-of-article ()
8615 "Scroll to the end of the article."
8617 (gnus-set-global-variables)
8618 (gnus-summary-select-article)
8619 (gnus-configure-windows 'article)
8620 (gnus-eval-in-buffer-window
8623 (goto-char (point-max))
8625 (and gnus-break-pages (gnus-narrow-to-page))))
8627 (defun gnus-summary-show-article ()
8628 "Force re-fetching of the current article."
8630 (gnus-set-global-variables)
8631 (gnus-summary-select-article nil 'force)
8632 (gnus-configure-windows 'article)
8633 (gnus-summary-position-cursor))
8635 (defun gnus-summary-verbose-headers (&optional arg)
8636 "Toggle permanent full header display.
8637 If ARG is a positive number, turn header display on.
8638 If ARG is a negative number, turn header display off."
8640 (gnus-set-global-variables)
8641 (gnus-summary-toggle-header arg)
8642 (setq gnus-show-all-headers
8643 (cond ((or (not (numberp arg))
8645 (not gnus-show-all-headers))
8649 (defun gnus-summary-toggle-header (&optional arg)
8650 "Show the headers if they are hidden, or hide them if they are shown.
8651 If ARG is a positive number, show the entire header.
8652 If ARG is a negative number, hide the unwanted header lines."
8654 (gnus-set-global-variables)
8656 (set-buffer gnus-article-buffer)
8657 (let ((buffer-read-only nil))
8659 (if (> arg 0) (remove-text-properties (point-min) (point-max)
8660 gnus-hidden-properties)
8661 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
8662 (if (text-property-any (point-min) (point-max) 'invisible t)
8663 (remove-text-properties
8664 (point-min) (point-max) gnus-hidden-properties)
8665 ;; We hide the headers. This song and dance act below is
8666 ;; done because `gnus-have-all-headers' is buffer-local to
8667 ;; the summary buffer, and we only want to temporarily
8668 ;; change it in that buffer. Ugh.
8669 (let ((have gnus-have-all-headers))
8671 (set-buffer gnus-summary-buffer)
8672 (setq gnus-have-all-headers nil)
8674 (set-buffer gnus-article-buffer)
8675 (run-hooks 'gnus-article-display-hook))
8676 (setq gnus-have-all-headers have)))))
8677 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
8679 (defun gnus-summary-show-all-headers ()
8680 "Make all header lines visible."
8682 (gnus-set-global-variables)
8683 (gnus-article-show-all-headers))
8685 (defun gnus-summary-toggle-mime (&optional arg)
8686 "Toggle MIME processing.
8687 If ARG is a positive number, turn MIME processing on."
8689 (gnus-set-global-variables)
8690 (setq gnus-show-mime
8691 (if (null arg) (not gnus-show-mime)
8692 (> (prefix-numeric-value arg) 0)))
8693 (gnus-summary-select-article t 'force))
8695 (defun gnus-summary-caesar-message (&optional arg)
8696 "Caesar rotate the current article by 13.
8697 The numerical prefix specifies how manu places to rotate each letter
8700 (gnus-set-global-variables)
8701 (gnus-summary-select-article)
8702 (let ((mail-header-separator ""))
8703 (gnus-eval-in-buffer-window
8707 (let ((start (window-start)))
8708 (news-caesar-buffer-body arg)
8709 (set-window-start (get-buffer-window (current-buffer)) start))))))
8711 (defun gnus-summary-stop-page-breaking ()
8712 "Stop page breaking in the current article."
8714 (gnus-set-global-variables)
8715 (gnus-summary-select-article)
8716 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
8718 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
8720 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
8721 "Move the current article to a different newsgroup.
8722 If N is a positive number, move the N next articles.
8723 If N is a negative number, move the N previous articles.
8724 If N is nil and any articles have been marked with the process mark,
8725 move those articles instead.
8726 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8727 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8728 re-spool using this method.
8729 For this function to work, both the current newsgroup and the
8730 newsgroup that you want to move to have to support the `request-move'
8731 and `request-accept' functions. (Ie. mail newsgroups at present.)"
8733 (gnus-set-global-variables)
8734 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
8735 (error "The current newsgroup does not support article moving"))
8736 (let ((articles (gnus-summary-work-articles n))
8737 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8738 art-group to-method sel-met)
8739 (if (and (not to-newsgroup) (not select-method))
8742 (format "Where do you want to move %s? %s"
8743 (if (> (length articles) 1)
8744 (format "these %d articles" (length articles))
8746 (if gnus-current-move-group
8747 (format "(%s default) " gnus-current-move-group)
8749 gnus-active-hashtb nil nil prefix)))
8752 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8753 (setq to-newsgroup (or gnus-current-move-group "")))
8754 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8755 (gnus-activate-group to-newsgroup)
8756 (error "No such group: %s" to-newsgroup))
8757 (setq gnus-current-move-group to-newsgroup)))
8758 (setq to-method (if select-method (list select-method "")
8759 (gnus-find-method-for-group to-newsgroup)))
8760 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8761 (error "%s does not support article copying" (car to-method)))
8762 (or (gnus-check-server to-method)
8763 (error "Can't open server %s" (car to-method)))
8764 (gnus-message 6 "Moving to %s: %s..."
8765 (or select-method to-newsgroup) articles)
8768 (gnus-request-move-article
8769 (car articles) ; Article to move
8770 gnus-newsgroup-name ; From newsgrouo
8771 (nth 1 (gnus-find-method-for-group
8772 gnus-newsgroup-name)) ; Server
8773 (list 'gnus-request-accept-article
8775 (list 'quote select-method)
8777 (not (cdr articles))) ; Accept form
8778 (not (cdr articles)))) ; Only save nov last time
8779 (let* ((buffer-read-only nil)
8782 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8784 (gnus-group-prefixed-name
8786 (if select-method (list select-method "")
8787 (gnus-find-method-for-group to-newsgroup)))
8788 gnus-newsrc-hashtb)))
8789 (info (nth 2 entry))
8790 (article (car articles)))
8791 (gnus-summary-goto-subject article)
8793 (delete-region (point) (progn (forward-line 1) (point)))
8794 ;; Update the group that has been moved to.
8796 () ; This group does not exist yet.
8797 (if (not (memq article gnus-newsgroup-unreads))
8798 (setcar (cdr (cdr info))
8799 (gnus-add-to-range (nth 2 info)
8800 (list (cdr art-group)))))
8801 ;; Copy any marks over to the new group.
8802 (let ((marks '((tick . gnus-newsgroup-marked)
8803 (dormant . gnus-newsgroup-dormant)
8804 (expire . gnus-newsgroup-expirable)
8805 (bookmark . gnus-newsgroup-bookmarks)
8806 (reply . gnus-newsgroup-replied)))
8807 (to-article (cdr art-group)))
8809 (if (memq article (symbol-value (cdr (car marks))))
8810 (gnus-add-marked-articles
8811 (car info) (car (car marks)) (list to-article) info))
8812 (setq marks (cdr marks)))))
8814 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8815 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8816 (setq gnus-newsgroup-dormant
8817 (delq article gnus-newsgroup-dormant))
8818 (setq gnus-newsgroup-reads
8819 (cons (cons article gnus-canceled-mark)
8820 gnus-newsgroup-reads)))
8821 (gnus-message 1 "Couldn't move article %s" (car articles)))
8822 (gnus-summary-remove-process-mark (car articles))
8823 (setq articles (cdr articles)))))
8825 (defun gnus-summary-respool-article (&optional n respool-method)
8826 "Respool the current article.
8827 The article will be squeezed through the mail spooling process again,
8828 which means that it will be put in some mail newsgroup or other
8829 depending on `nnmail-split-methods'.
8830 If N is a positive number, respool the N next articles.
8831 If N is a negative number, respool the N previous articles.
8832 If N is nil and any articles have been marked with the process mark,
8833 respool those articles instead.
8835 Respooling can be done both from mail groups and \"real\" newsgroups.
8836 In the former case, the articles in question will be moved from the
8837 current group into whatever groups they are destined to. In the
8838 latter case, they will be copied into the relevant groups."
8840 (gnus-set-global-variables)
8841 (let ((respool-methods (gnus-methods-using 'respool))
8843 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
8845 (setq respool-method
8847 "What method do you want to use when respooling? "
8848 respool-methods nil t methname)))
8849 (or (string= respool-method "")
8850 (if (assoc (symbol-name
8851 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8853 (gnus-summary-move-article n nil (intern respool-method))
8854 (gnus-summary-copy-article n nil (intern respool-method))))))
8856 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
8857 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8858 "Move the current article to a different newsgroup.
8859 If N is a positive number, move the N next articles.
8860 If N is a negative number, move the N previous articles.
8861 If N is nil and any articles have been marked with the process mark,
8862 move those articles instead.
8863 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8864 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
8865 re-spool using this method.
8866 For this function to work, the newsgroup that you want to move to have
8867 to support the `request-move' and `request-accept'
8868 functions. (Ie. mail newsgroups at present.)"
8870 (gnus-set-global-variables)
8871 (let ((articles (gnus-summary-work-articles n))
8872 (copy-buf (get-buffer-create "*copy work*"))
8873 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
8874 art-group to-method)
8875 (buffer-disable-undo copy-buf)
8876 (if (and (not to-newsgroup) (not select-method))
8879 (format "Where do you want to copy %s? %s"
8880 (if (> (length articles) 1)
8881 (format "these %d articles" (length articles))
8883 (if gnus-current-move-group
8884 (format "(%s default) " gnus-current-move-group)
8886 gnus-active-hashtb nil nil prefix)))
8889 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8890 (setq to-newsgroup (or gnus-current-move-group "")))
8891 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8892 (gnus-activate-group to-newsgroup)
8893 (error "No such group: %s" to-newsgroup))
8894 (setq gnus-current-move-group to-newsgroup)))
8895 (setq to-method (if select-method (list select-method "")
8896 (gnus-find-method-for-group to-newsgroup)))
8897 (or (gnus-check-backend-function 'request-accept-article (car to-method))
8898 (error "%s does not support article copying" (car to-method)))
8899 (or (gnus-check-server to-method)
8900 (error "Can't open server %s" (car to-method)))
8902 (gnus-message 6 "Copying to %s: %s..."
8903 (or select-method to-newsgroup) articles)
8906 (set-buffer copy-buf)
8907 (gnus-request-article-this-buffer
8908 (car articles) gnus-newsgroup-name)
8909 (gnus-request-accept-article
8910 (if select-method (quote select-method) to-newsgroup)
8911 (not (cdr articles)))))
8914 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8916 (gnus-group-prefixed-name
8918 (if select-method (list select-method "")
8919 (gnus-find-method-for-group to-newsgroup)))
8920 gnus-newsrc-hashtb)))
8921 (info (nth 2 entry))
8922 (article (car articles)))
8923 ;; We copy the info over to the new group.
8925 () ; This group does not exist (yet).
8926 (if (not (memq article gnus-newsgroup-unreads))
8927 (setcar (cdr (cdr info))
8928 (gnus-add-to-range (nth 2 info)
8929 (list (cdr art-group)))))
8930 ;; Copy any marks over to the new group.
8931 (let ((marks '((tick . gnus-newsgroup-marked)
8932 (dormant . gnus-newsgroup-dormant)
8933 (expire . gnus-newsgroup-expirable)
8934 (bookmark . gnus-newsgroup-bookmarks)
8935 (reply . gnus-newsgroup-replied)))
8936 (to-article (cdr art-group)))
8938 (if (memq article (symbol-value (cdr (car marks))))
8939 (gnus-add-marked-articles
8940 (car info) (car (car marks)) (list to-article) info))
8941 (setq marks (cdr marks))))))
8942 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8943 (gnus-summary-remove-process-mark (car articles))
8944 (setq articles (cdr articles)))
8945 (kill-buffer copy-buf)))
8947 (defun gnus-summary-import-article (file)
8948 "Import a random file into a mail newsgroup."
8949 (interactive "fImport file: ")
8950 (let ((group gnus-newsgroup-name)
8952 (or (gnus-check-backend-function 'request-accept-article group)
8953 (error "%s does not support article importing" group))
8954 (or (file-readable-p file)
8955 (not (file-regular-p file))
8956 (error "Can't read %s" file))
8958 (set-buffer (get-buffer-create " *import file*"))
8959 (buffer-disable-undo (current-buffer))
8961 (insert-file-contents file)
8962 (goto-char (point-min))
8963 (if (nnheader-article-p)
8965 (setq atts (file-attributes file))
8966 (insert "From: " (read-string "From: ") "\n"
8967 "Subject: " (read-string "Subject: ") "\n"
8968 "Date: " (current-time-string (nth 5 atts)) "\n"
8969 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8970 (gnus-request-accept-article group t)
8971 (kill-buffer (current-buffer)))))
8973 (defun gnus-summary-expire-articles ()
8974 "Expire all articles that are marked as expirable in the current group."
8976 (if (not (gnus-check-backend-function
8977 'request-expire-articles gnus-newsgroup-name))
8979 (let* ((info (nth 2 (gnus-gethash gnus-newsgroup-name
8980 gnus-newsrc-hashtb)))
8981 (total (memq 'total-expire (nth 5 info)))
8982 (expirable (if total
8983 (gnus-list-of-read-articles gnus-newsgroup-name)
8984 (setq gnus-newsgroup-expirable
8985 (sort gnus-newsgroup-expirable '<))))
8989 (gnus-message 6 "Expiring articles...")
8990 ;; The list of articles that weren't expired is returned.
8991 (setq es (gnus-request-expire-articles expirable gnus-newsgroup-name))
8992 (or total (setq gnus-newsgroup-expirable es))
8993 ;; We go through the old list of expirable, and mark all
8994 ;; really expired articles as non-existant.
8995 (or (eq es expirable) ; If nothing was expired, we don't mark.
8996 (let ((gnus-use-cache nil))
8998 (or (memq (car expirable) es)
8999 (gnus-summary-mark-article
9000 (car expirable) gnus-canceled-mark))
9001 (setq expirable (cdr expirable)))))
9002 (gnus-message 6 "Expiring articles...done")))))
9004 (defun gnus-summary-expire-articles-now ()
9005 "Expunge all expirable articles in the current group.
9006 This means that *all* articles that are marked as expirable will be
9007 deleted forever, right now."
9009 (or gnus-expert-user
9011 "Are you really, really, really sure you want to expunge? ")
9013 (let ((nnmail-expiry-wait -1)
9014 (nnmail-expiry-wait-function nil))
9015 (gnus-summary-expire-articles)))
9017 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9018 (defun gnus-summary-delete-article (&optional n)
9019 "Delete the N next (mail) articles.
9020 This command actually deletes articles. This is not a marking
9021 command. The article will disappear forever from you life, never to
9023 If N is negative, delete backwards.
9024 If N is nil and articles have been marked with the process mark,
9025 delete these instead."
9027 (or (gnus-check-backend-function 'request-expire-articles
9028 gnus-newsgroup-name)
9029 (error "The current newsgroup does not support article deletion."))
9030 ;; Compute the list of articles to delete.
9031 (let ((articles (gnus-summary-work-articles n))
9033 (if (and gnus-novice-user
9035 (format "Do you really want to delete %s forever? "
9036 (if (> (length articles) 1) "these articles"
9039 ;; Delete the articles.
9040 (setq not-deleted (gnus-request-expire-articles
9041 articles gnus-newsgroup-name 'force))
9043 (gnus-summary-remove-process-mark (car articles))
9044 ;; The backend might not have been able to delete the article
9046 (or (memq (car articles) not-deleted)
9047 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9048 (setq articles (cdr articles))))
9049 (gnus-summary-position-cursor)
9052 (defun gnus-summary-edit-article ()
9053 "Enter into a buffer and edit the current article.
9054 This will have permanent effect only in mail groups."
9056 (or (gnus-check-backend-function
9057 'request-replace-article gnus-newsgroup-name)
9058 (error "The current newsgroup does not support article editing."))
9059 (gnus-summary-select-article t)
9060 (gnus-configure-windows 'article)
9061 (select-window (get-buffer-window gnus-article-buffer))
9062 (gnus-message 6 "C-c C-c to end edits")
9063 (setq buffer-read-only nil)
9065 (use-local-map (copy-keymap (current-local-map)))
9066 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
9067 (buffer-enable-undo)
9069 (goto-char (point-min))
9070 (search-forward "\n\n" nil t))
9072 (defun gnus-summary-edit-article-done ()
9073 "Make edits to the current article permanent."
9075 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
9078 (if (not (gnus-request-replace-article
9079 (cdr gnus-article-current) (car gnus-article-current)
9081 (error "Couldn't replace article.")
9083 (use-local-map gnus-article-mode-map)
9084 (setq buffer-read-only t)
9085 (buffer-disable-undo (current-buffer))
9086 (gnus-configure-windows 'summary))
9087 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook))))
9089 (defun gnus-summary-edit-article-postpone ()
9090 "Postpone changes to the current article."
9093 (use-local-map gnus-article-mode-map)
9094 (setq buffer-read-only t)
9095 (buffer-disable-undo (current-buffer))
9096 (gnus-configure-windows 'summary)
9097 (and gnus-visual (run-hooks 'gnus-visual-mark-article-hook)))
9099 (defun gnus-summary-fancy-query ()
9100 "Query where the fancy respool algorithm would put this article."
9102 (gnus-summary-select-article)
9104 (set-buffer gnus-article-buffer)
9106 (goto-char (point-min))
9107 (search-forward "\n\n")
9108 (narrow-to-region (point-min) (point))
9109 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
9111 ;; Summary score commands.
9113 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
9115 (defun gnus-summary-raise-score (n)
9116 "Raise the score of the current article by N."
9118 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
9120 (defun gnus-summary-set-score (n)
9121 "Set the score of the current article to N."
9123 ;; Skip dummy header line.
9125 (gnus-summary-show-thread)
9126 (if (eq (gnus-summary-article-mark) gnus-dummy-mark)
9128 (let ((buffer-read-only nil))
9130 (gnus-summary-update-mark
9131 (if (= n (or gnus-summary-default-score 0)) ?
9132 (if (< n (or gnus-summary-default-score 0))
9133 gnus-score-below-mark gnus-score-over-mark)) 'score))
9134 (let* ((article (gnus-summary-article-number))
9135 (score (assq article gnus-newsgroup-scored)))
9136 (if score (setcdr score n)
9137 (setq gnus-newsgroup-scored
9138 (cons (cons article n) gnus-newsgroup-scored))))
9139 (gnus-summary-update-line)))
9141 (defun gnus-summary-current-score ()
9142 "Return the score of the current article."
9144 (message "%s" (gnus-summary-article-score)))
9146 ;; Summary marking commands.
9148 (defun gnus-summary-raise-same-subject-and-select (score)
9149 "Raise articles which has the same subject with SCORE and select the next."
9151 (let ((subject (gnus-summary-subject-string)))
9152 (gnus-summary-raise-score score)
9153 (while (gnus-summary-search-subject nil nil subject)
9154 (gnus-summary-raise-score score))
9155 (gnus-summary-next-article t)))
9157 (defun gnus-summary-raise-same-subject (score)
9158 "Raise articles which has the same subject with SCORE."
9160 (let ((subject (gnus-summary-subject-string)))
9161 (gnus-summary-raise-score score)
9162 (while (gnus-summary-search-subject nil nil subject)
9163 (gnus-summary-raise-score score))
9164 (gnus-summary-next-subject 1 t)))
9166 (defun gnus-score-default (level)
9167 (if level (prefix-numeric-value level)
9168 gnus-score-interactive-default-score))
9170 (defun gnus-summary-raise-thread (&optional score)
9171 "Raise the score of the articles in the current thread with SCORE."
9173 (setq score (gnus-score-default score))
9176 (let ((level (gnus-summary-thread-level)))
9177 (gnus-summary-raise-score score)
9178 (while (and (zerop (gnus-summary-next-subject 1 nil t))
9179 (> (gnus-summary-thread-level) level))
9180 (gnus-summary-raise-score score))
9182 (let ((gnus-summary-check-current t))
9183 (or (zerop (gnus-summary-next-subject 1 t))
9185 (gnus-summary-recenter)
9186 (gnus-summary-position-cursor)
9187 (gnus-set-mode-line 'summary))
9189 (defun gnus-summary-lower-same-subject-and-select (score)
9190 "Raise articles which has the same subject with SCORE and select the next."
9192 (gnus-summary-raise-same-subject-and-select (- score)))
9194 (defun gnus-summary-lower-same-subject (score)
9195 "Raise articles which has the same subject with SCORE."
9197 (gnus-summary-raise-same-subject (- score)))
9199 (defun gnus-summary-lower-thread (&optional score)
9200 "Lower score of articles in the current thread with SCORE."
9202 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
9204 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9205 "Mark articles which has the same subject as read, and then select the next.
9206 If UNMARK is positive, remove any kind of mark.
9207 If UNMARK is negative, tick articles."
9210 (setq unmark (prefix-numeric-value unmark)))
9212 (gnus-summary-mark-same-subject
9213 (gnus-summary-subject-string) unmark)))
9214 ;; Select next unread article. If auto-select-same mode, should
9215 ;; select the first unread article.
9216 (gnus-summary-next-article t (and gnus-auto-select-same
9217 (gnus-summary-subject-string)))
9218 (gnus-message 7 "%d article%s marked as %s"
9219 count (if (= count 1) " is" "s are")
9220 (if unmark "unread" "read"))))
9222 (defun gnus-summary-kill-same-subject (&optional unmark)
9223 "Mark articles which has the same subject as read.
9224 If UNMARK is positive, remove any kind of mark.
9225 If UNMARK is negative, tick articles."
9228 (setq unmark (prefix-numeric-value unmark)))
9230 (gnus-summary-mark-same-subject
9231 (gnus-summary-subject-string) unmark)))
9232 ;; If marked as read, go to next unread subject.
9234 ;; Go to next unread subject.
9235 (gnus-summary-next-subject 1 t))
9236 (gnus-message 7 "%d articles are marked as %s"
9237 count (if unmark "unread" "read"))))
9239 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9240 "Mark articles with same SUBJECT as read, and return marked number.
9241 If optional argument UNMARK is positive, remove any kinds of marks.
9242 If optional argument UNMARK is negative, mark articles as unread instead."
9246 ((null unmark) ; Mark as read.
9249 (gnus-summary-mark-article-as-read gnus-killed-mark)
9250 (gnus-summary-show-thread) t)
9251 (gnus-summary-search-forward nil subject))
9252 (setq count (1+ count))))
9253 ((> unmark 0) ; Tick.
9256 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9257 (gnus-summary-show-thread) t)
9258 (gnus-summary-search-forward nil subject))
9259 (setq count (1+ count))))
9260 (t ; Mark as unread.
9263 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9264 (gnus-summary-show-thread) t)
9265 (gnus-summary-search-forward nil subject))
9266 (setq count (1+ count)))))
9267 (gnus-set-mode-line 'summary)
9268 ;; Return the number of marked articles.
9271 (defun gnus-summary-mark-as-processable (n &optional unmark)
9272 "Set the process mark on the next N articles.
9273 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9274 the process mark instead. The difference between N and the actual
9275 number of articles marked is returned."
9277 (let ((backward (< n 0))
9282 (gnus-summary-remove-process-mark (gnus-summary-article-number))
9283 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9284 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9286 (if (/= 0 n) (gnus-message 7 "No more articles"))
9287 (gnus-summary-recenter)
9288 (gnus-summary-position-cursor)
9291 (defun gnus-summary-unmark-as-processable (n)
9292 "Remove the process mark from the next N articles.
9293 If N is negative, mark backward instead. The difference between N and
9294 the actual number of articles marked is returned."
9296 (gnus-summary-mark-as-processable n t))
9298 (defun gnus-summary-unmark-all-processable ()
9299 "Remove the process mark from all articles."
9302 (while gnus-newsgroup-processable
9303 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9304 (gnus-summary-position-cursor))
9306 (defun gnus-summary-mark-as-expirable (n)
9307 "Mark N articles forward as expirable.
9308 If N is negative, mark backward instead. The difference between N and
9309 the actual number of articles marked is returned."
9311 (gnus-summary-mark-forward n gnus-expirable-mark))
9313 (defun gnus-summary-mark-article-as-replied (article)
9314 "Mark ARTICLE replied and update the summary line."
9315 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
9316 (let ((buffer-read-only nil))
9317 (if (gnus-summary-goto-subject article)
9319 (gnus-summary-update-mark gnus-replied-mark 'replied)
9322 (defun gnus-summary-set-bookmark (article)
9323 "Set a bookmark in current article."
9324 (interactive (list (gnus-summary-article-number)))
9325 (if (or (not (get-buffer gnus-article-buffer))
9326 (not gnus-current-article)
9327 (not gnus-article-current)
9328 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9329 (error "No current article selected"))
9330 ;; Remove old bookmark, if one exists.
9331 (let ((old (assq article gnus-newsgroup-bookmarks)))
9332 (if old (setq gnus-newsgroup-bookmarks
9333 (delq old gnus-newsgroup-bookmarks))))
9334 ;; Set the new bookmark, which is on the form
9335 ;; (article-number . line-number-in-body).
9336 (setq gnus-newsgroup-bookmarks
9340 (set-buffer gnus-article-buffer)
9344 (goto-char (point-min))
9345 (search-forward "\n\n" nil t)
9348 gnus-newsgroup-bookmarks))
9349 (gnus-message 6 "A bookmark has been added to the current article."))
9351 (defun gnus-summary-remove-bookmark (article)
9352 "Remove the bookmark from the current article."
9353 (interactive (list (gnus-summary-article-number)))
9354 ;; Remove old bookmark, if one exists.
9355 (let ((old (assq article gnus-newsgroup-bookmarks)))
9358 (setq gnus-newsgroup-bookmarks
9359 (delq old gnus-newsgroup-bookmarks))
9360 (gnus-message 6 "Removed bookmark."))
9361 (gnus-message 6 "No bookmark in current article."))))
9363 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9364 (defun gnus-summary-mark-as-dormant (n)
9365 "Mark N articles forward as dormant.
9366 If N is negative, mark backward instead. The difference between N and
9367 the actual number of articles marked is returned."
9369 (gnus-summary-mark-forward n gnus-dormant-mark))
9371 (defun gnus-summary-set-process-mark (article)
9372 "Set the process mark on ARTICLE and update the summary line."
9373 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
9374 (let ((buffer-read-only nil))
9375 (if (gnus-summary-goto-subject article)
9377 (gnus-summary-show-thread)
9378 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9380 (gnus-summary-update-mark gnus-process-mark 'replied)
9383 (defun gnus-summary-remove-process-mark (article)
9384 "Remove the process mark from ARTICLE and update the summary line."
9385 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9386 (let ((buffer-read-only nil))
9387 (if (gnus-summary-goto-subject article)
9389 (gnus-summary-show-thread)
9390 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9392 (gnus-summary-update-mark ? 'replied)
9393 (if (memq article gnus-newsgroup-replied)
9394 (gnus-summary-update-mark gnus-replied-mark 'replied))
9397 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9398 "Mark N articles as read forwards.
9399 If N is negative, mark backwards instead.
9400 Mark with MARK. If MARK is ? , ?! or ??, articles will be
9402 The difference between N and the actual number of articles marked is
9405 (gnus-set-global-variables)
9406 (let ((backward (< n 0))
9407 (gnus-summary-goto-unread
9408 (and gnus-summary-goto-unread
9409 (not (memq mark (list gnus-unread-mark
9410 gnus-ticked-mark gnus-dormant-mark)))))
9412 (mark (or mark gnus-del-mark)))
9414 (gnus-summary-mark-article nil mark no-expire)
9415 (zerop (gnus-summary-next-subject
9416 (if backward -1 1) gnus-summary-goto-unread t)))
9418 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9419 (gnus-summary-recenter)
9420 (gnus-summary-position-cursor)
9421 (gnus-set-mode-line 'summary)
9424 (defun gnus-summary-mark-article-as-read (mark)
9425 "Mark the current article quickly as read with MARK."
9426 (let ((article (gnus-summary-article-number)))
9427 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9428 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9429 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9430 (setq gnus-newsgroup-reads
9431 (cons (cons article mark) gnus-newsgroup-reads))
9432 ;; Possibly remove from cache, if that is used.
9433 (and gnus-use-cache (gnus-cache-enter-remove-article article))
9434 (and gnus-newsgroup-auto-expire
9435 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9436 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9437 (= mark gnus-read-mark))
9439 (setq mark gnus-expirable-mark)
9440 (setq gnus-newsgroup-expirable
9441 (cons article gnus-newsgroup-expirable))))
9442 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9445 (gnus-summary-update-mark mark 'unread)
9448 (defun gnus-summary-mark-article-as-unread (mark)
9449 "Mark the current article quickly as unread with MARK."
9450 (let ((article (gnus-summary-article-number)))
9451 (or (memq article gnus-newsgroup-unreads)
9452 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9453 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9454 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9455 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9456 (setq gnus-newsgroup-reads
9457 (delq (assq article gnus-newsgroup-reads)
9458 gnus-newsgroup-reads))
9459 (if (= mark gnus-ticked-mark)
9460 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9461 (if (= mark gnus-dormant-mark)
9462 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))
9464 ;; See whether the article is to be put in the cache.
9466 (vectorp (gnus-get-header-by-num article))
9468 (gnus-cache-possibly-enter-article
9469 gnus-newsgroup-name article
9470 (gnus-get-header-by-num article)
9471 (= mark gnus-ticked-mark)
9472 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9474 (while (eq (gnus-summary-article-mark) gnus-dummy-mark)
9477 (gnus-summary-update-mark mark 'unread)
9480 (defun gnus-summary-mark-article (&optional article mark no-expire)
9481 "Mark ARTICLE with MARK. MARK can be any character.
9482 Four MARK strings are reserved: `? ' (unread), `?!' (ticked), `??'
9483 (dormant) and `?E' (expirable).
9484 If MARK is nil, then the default character `?D' is used.
9485 If ARTICLE is nil, then the article on the current line will be
9488 (setq mark (aref mark 0)))
9489 ;; If no mark is given, then we check auto-expiring.
9490 (and (not no-expire)
9491 gnus-newsgroup-auto-expire
9494 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
9495 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
9496 (= mark gnus-read-mark))))
9497 (setq mark gnus-expirable-mark))
9498 (let* ((mark (or mark gnus-del-mark))
9499 (article (or article (gnus-summary-article-number))))
9500 (or article (error "No article on current line"))
9501 (if (or (= mark gnus-unread-mark)
9502 (= mark gnus-ticked-mark)
9503 (= mark gnus-dormant-mark))
9504 (gnus-mark-article-as-unread article mark)
9505 (gnus-mark-article-as-read article mark))
9507 ;; See whether the article is to be put in the cache.
9509 (not (= mark gnus-canceled-mark))
9510 (vectorp (gnus-get-header-by-num article))
9512 (gnus-cache-possibly-enter-article
9513 gnus-newsgroup-name article
9514 (gnus-get-header-by-num article)
9515 (= mark gnus-ticked-mark)
9516 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9518 (if (gnus-summary-goto-subject article)
9519 (let ((buffer-read-only nil))
9520 (gnus-summary-show-thread)
9521 (and (eq (gnus-summary-article-mark) gnus-dummy-mark)
9524 (gnus-summary-update-mark mark 'unread)
9527 (defun gnus-summary-update-mark (mark type)
9529 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9530 (buffer-read-only nil)
9534 (forward-char forward)
9535 (setq plist (text-properties-at (point)))
9538 (and plist (add-text-properties (1- (point)) (point) plist))
9539 (and (eq type 'unread)
9540 (add-text-properties (1- (point)) (point) (list 'gnus-mark mark)))
9541 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
9543 (defun gnus-mark-article-as-read (article &optional mark)
9544 "Enter ARTICLE in the pertinent lists and remove it from others."
9545 ;; Make the article expirable.
9546 (let ((mark (or mark gnus-del-mark)))
9547 (if (= mark gnus-expirable-mark)
9548 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
9549 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9550 ;; Remove from unread and marked lists.
9551 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9552 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9553 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9554 (setq gnus-newsgroup-reads
9555 (cons (cons article mark) gnus-newsgroup-reads))
9556 ;; Possibly remove from cache, if that is used.
9557 (and gnus-use-cache (gnus-cache-enter-remove-article article))))
9559 (defun gnus-mark-article-as-unread (article &optional mark)
9560 "Enter ARTICLE in the pertinent lists and remove it from others."
9561 (let ((mark (or mark gnus-ticked-mark)))
9562 ;; Add to unread list.
9563 (or (memq article gnus-newsgroup-unreads)
9564 (setq gnus-newsgroup-unreads (cons article gnus-newsgroup-unreads)))
9565 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9566 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9567 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9568 (setq gnus-newsgroup-reads
9569 (delq (assq article gnus-newsgroup-reads)
9570 gnus-newsgroup-reads))
9571 (if (= mark gnus-ticked-mark)
9572 (setq gnus-newsgroup-marked (cons article gnus-newsgroup-marked)))
9573 (if (= mark gnus-dormant-mark)
9574 (setq gnus-newsgroup-dormant (cons article gnus-newsgroup-dormant)))))
9576 (defalias 'gnus-summary-mark-as-unread-forward
9577 'gnus-summary-tick-article-forward)
9578 (make-obsolete 'gnus-summary-mark-as-unread-forward
9579 'gnus-summary-tick-article-forward)
9580 (defun gnus-summary-tick-article-forward (n)
9581 "Tick N articles forwards.
9582 If N is negative, tick backwards instead.
9583 The difference between N and the number of articles ticked is returned."
9585 (gnus-summary-mark-forward n gnus-ticked-mark))
9587 (defalias 'gnus-summary-mark-as-unread-backward
9588 'gnus-summary-tick-article-backward)
9589 (make-obsolete 'gnus-summary-mark-as-unread-backward
9590 'gnus-summary-tick-article-backward)
9591 (defun gnus-summary-tick-article-backward (n)
9592 "Tick N articles backwards.
9593 The difference between N and the number of articles ticked is returned."
9595 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9597 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9598 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9599 (defun gnus-summary-tick-article (&optional article clear-mark)
9600 "Mark current article as unread.
9601 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9602 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9603 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9606 (defun gnus-summary-mark-as-read-forward (n)
9607 "Mark N articles as read forwards.
9608 If N is negative, mark backwards instead.
9609 The difference between N and the actual number of articles marked is
9612 (gnus-summary-mark-forward n gnus-del-mark t))
9614 (defun gnus-summary-mark-as-read-backward (n)
9615 "Mark the N articles as read backwards.
9616 The difference between N and the actual number of articles marked is
9619 (gnus-summary-mark-forward (- n) gnus-del-mark t))
9621 (defun gnus-summary-mark-as-read (&optional article mark)
9622 "Mark current article as read.
9623 ARTICLE specifies the article to be marked as read.
9624 MARK specifies a string to be inserted at the beginning of the line."
9625 (gnus-summary-mark-article article mark))
9627 (defun gnus-summary-clear-mark-forward (n)
9628 "Clear marks from N articles forward.
9629 If N is negative, clear backward instead.
9630 The difference between N and the number of marks cleared is returned."
9632 (gnus-summary-mark-forward n gnus-unread-mark))
9634 (defun gnus-summary-clear-mark-backward (n)
9635 "Clear marks from N articles backward.
9636 The difference between N and the number of marks cleared is returned."
9638 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9640 (defun gnus-summary-mark-unread-as-read ()
9641 "Intended to be used by `gnus-summary-mark-article-hook'."
9642 (or (memq gnus-current-article gnus-newsgroup-marked)
9643 (memq gnus-current-article gnus-newsgroup-dormant)
9644 (memq gnus-current-article gnus-newsgroup-expirable)
9645 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9647 (defun gnus-summary-mark-region-as-read (point mark all)
9648 "Mark all unread articles between point and mark as read.
9649 If given a prefix, mark all articles between point and mark as read,
9650 even ticked and dormant ones."
9651 (interactive "r\nP")
9661 (not (memq (gnus-summary-article-number)
9662 gnus-newsgroup-marked))
9663 (not (memq (gnus-summary-article-number)
9664 gnus-newsgroup-dormant))))
9665 (gnus-summary-mark-article
9666 (gnus-summary-article-number) gnus-del-mark))
9668 (zerop (forward-line 1))))))
9670 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
9671 (defalias 'gnus-summary-delete-marked-as-read
9672 'gnus-summary-remove-lines-marked-as-read)
9673 (make-obsolete 'gnus-summary-delete-marked-as-read
9674 'gnus-summary-remove-lines-marked-as-read)
9675 (defun gnus-summary-remove-lines-marked-as-read ()
9676 "Remove lines that are marked as read."
9678 (gnus-summary-remove-lines-marked-with
9680 (lambda (char) (char-to-string (symbol-value char)))
9681 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
9682 gnus-killed-mark gnus-kill-file-mark
9683 gnus-low-score-mark gnus-expirable-mark
9684 gnus-canceled-mark gnus-catchup-mark)
9687 (defalias 'gnus-summary-delete-marked-with
9688 'gnus-summary-remove-lines-marked-with)
9689 (make-obsolete 'gnus-summary-delete-marked-with
9690 'gnus-summary-remove-lines-marked-with)
9691 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
9692 (defun gnus-summary-remove-lines-marked-with (marks)
9693 "Remove lines that are marked with MARKS (e.g. \"DK\")."
9694 (interactive "sMarks: ")
9695 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
9696 (gnus-set-global-variables)
9697 (let ((buffer-read-only nil)
9698 (marks (concat "^[" marks "]")))
9699 (goto-char (point-min))
9700 (if gnus-newsgroup-adaptive
9701 (gnus-score-remove-lines-adaptive marks)
9702 (while (re-search-forward marks nil t)
9703 (gnus-delete-line)))
9704 ;; If we use dummy roots, we have to do an additional sweep over
9706 (if (not (eq gnus-summary-make-false-root 'dummy))
9708 (goto-char (point-min))
9709 (setq marks (concat "^[" (char-to-string gnus-dummy-mark) "]"))
9710 (while (re-search-forward marks nil t)
9711 (if (gnus-subject-equal
9712 (gnus-summary-subject-string)
9715 (gnus-summary-subject-string)))
9718 (gnus-delete-line)))))
9719 (or (zerop (buffer-size))
9721 (gnus-summary-prev-subject 1)
9722 (gnus-summary-position-cursor))))
9724 (defun gnus-summary-expunge-below (&optional score)
9725 "Remove articles with score less than SCORE."
9727 (gnus-set-global-variables)
9728 (setq score (if score
9729 (prefix-numeric-value score)
9730 (or gnus-summary-default-score 0)))
9732 (set-buffer gnus-summary-buffer)
9733 (goto-char (point-min))
9734 (let ((buffer-read-only nil)
9737 (if (< (gnus-summary-article-score) score)
9741 (delete-region beg (point)))
9744 (or (zerop (buffer-size))
9746 (gnus-summary-prev-subject 1)
9747 (gnus-summary-position-cursor))))))
9749 (defun gnus-summary-mark-below (score mark)
9750 "Mark articles with score less than SCORE with MARK."
9751 (interactive "P\ncMark: ")
9752 (gnus-set-global-variables)
9753 (setq score (if score
9754 (prefix-numeric-value score)
9755 (or gnus-summary-default-score 0)))
9757 (set-buffer gnus-summary-buffer)
9758 (goto-char (point-min))
9760 (and (< (gnus-summary-article-score) score)
9761 (gnus-summary-mark-article nil mark))
9764 (defun gnus-summary-kill-below (&optional score)
9765 "Mark articles with score below SCORE as read."
9767 (gnus-set-global-variables)
9768 (gnus-summary-mark-below score gnus-killed-mark))
9770 (defun gnus-summary-clear-above (&optional score)
9771 "Clear all marks from articles with score above SCORE."
9773 (gnus-set-global-variables)
9774 (gnus-summary-mark-above score gnus-unread-mark))
9776 (defun gnus-summary-tick-above (&optional score)
9777 "Tick all articles with score above SCORE."
9779 (gnus-set-global-variables)
9780 (gnus-summary-mark-above score gnus-ticked-mark))
9782 (defun gnus-summary-mark-above (score mark)
9783 "Mark articles with score over SCORE with MARK."
9784 (interactive "P\ncMark: ")
9785 (gnus-set-global-variables)
9786 (setq score (if score
9787 (prefix-numeric-value score)
9788 (or gnus-summary-default-score 0)))
9790 (set-buffer gnus-summary-buffer)
9791 (goto-char (point-min))
9793 (if (> (gnus-summary-article-score) score)
9795 (gnus-summary-mark-article nil mark)
9797 (forward-line 1)))))
9799 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9800 (defun gnus-summary-show-all-expunged ()
9801 "Display all the hidden articles that were expunged for low scores."
9803 (gnus-set-global-variables)
9804 (let ((buffer-read-only nil))
9805 (let ((scored gnus-newsgroup-scored)
9808 (or (gnus-summary-goto-subject (car (car scored)))
9809 (and (setq h (gnus-get-header-by-num (car (car scored))))
9810 (< (cdr (car scored)) gnus-summary-expunge-below)
9811 (setq headers (cons h headers))))
9812 (setq scored (cdr scored)))
9813 (or headers (error "No expunged articles hidden."))
9814 (goto-char (point-min))
9816 (gnus-summary-update-lines
9819 (gnus-summary-prepare-unthreaded (nreverse headers))
9821 (goto-char (point-min))
9822 (gnus-summary-position-cursor)))
9824 (defun gnus-summary-show-all-dormant ()
9825 "Display all the hidden articles that are marked as dormant."
9827 (gnus-set-global-variables)
9828 (let ((buffer-read-only nil))
9829 (let ((dormant gnus-newsgroup-dormant)
9832 (or (gnus-summary-goto-subject (car dormant))
9833 (and (setq h (gnus-get-header-by-num (car dormant)))
9834 (setq headers (cons h headers))))
9835 (setq dormant (cdr dormant)))
9836 (or headers (error "No dormant articles hidden."))
9837 (goto-char (point-min))
9839 (gnus-summary-update-lines
9842 (gnus-summary-prepare-unthreaded (nreverse headers))
9844 (goto-char (point-min))
9845 (gnus-summary-position-cursor)))
9847 (defun gnus-summary-hide-all-dormant ()
9848 "Hide all dormant articles."
9850 (gnus-set-global-variables)
9851 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
9852 (gnus-summary-position-cursor))
9854 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
9855 "Mark all articles not marked as unread in this newsgroup as read.
9856 If prefix argument ALL is non-nil, all articles are marked as read.
9857 If QUIETLY is non-nil, no questions will be asked.
9858 If TO-HERE is non-nil, it should be a point in the buffer. All
9859 articles before this point will be marked as read.
9860 The number of articles marked as read is returned."
9862 (gnus-set-global-variables)
9865 (not gnus-interactive-catchup) ;Without confirmation?
9869 "Mark absolutely all articles as read? "
9870 "Mark all unread articles as read? ")))
9872 (not gnus-newsgroup-adaptive)
9873 (not gnus-newsgroup-auto-expire))
9875 (and all (setq gnus-newsgroup-marked nil
9876 gnus-newsgroup-dormant nil))
9877 (setq gnus-newsgroup-unreads
9878 (append gnus-newsgroup-marked gnus-newsgroup-dormant)))
9879 ;; We actually mark all articles as canceled, which we
9880 ;; have to do when using auto-expiry or adaptive scoring.
9881 (let ((unreads (length gnus-newsgroup-unreads)))
9882 (gnus-summary-show-all-threads)
9883 (if (gnus-summary-first-subject (not all))
9885 (if to-here (< (point) to-here) t)
9886 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9887 (gnus-summary-search-subject nil (not all)))))
9888 (- unreads (length gnus-newsgroup-unreads))
9890 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
9891 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
9892 (if (and (not to-here) (eq 'nnvirtual (car method)))
9893 (nnvirtual-catchup-group
9894 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
9895 (gnus-summary-position-cursor)))
9897 (defun gnus-summary-catchup-to-here (&optional all)
9898 "Mark all unticked articles before the current one as read.
9899 If ALL is non-nil, also mark ticked and dormant articles as read."
9901 (gnus-set-global-variables)
9903 (and (zerop (forward-line -1))
9906 (gnus-summary-catchup all t (point))
9907 (gnus-set-mode-line 'summary))))
9908 (gnus-summary-position-cursor))
9910 (defun gnus-summary-catchup-all (&optional quietly)
9911 "Mark all articles in this newsgroup as read."
9913 (gnus-set-global-variables)
9914 (gnus-summary-catchup t quietly))
9916 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9917 "Mark all articles not marked as unread in this newsgroup as read, then exit.
9918 If prefix argument ALL is non-nil, all articles are marked as read."
9920 (gnus-set-global-variables)
9921 (gnus-summary-catchup all quietly nil 'fast)
9922 ;; Select next newsgroup or exit.
9923 (if (eq gnus-auto-select-next 'quietly)
9924 (gnus-summary-next-group nil)
9925 (gnus-summary-exit)))
9927 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9928 "Mark all articles in this newsgroup as read, and then exit."
9930 (gnus-set-global-variables)
9931 (gnus-summary-catchup-and-exit t quietly))
9933 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
9934 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9935 "Mark all articles in this group as read and select the next group.
9936 If given a prefix, mark all articles, unread as well as ticked, as
9939 (gnus-set-global-variables)
9940 (gnus-summary-catchup all)
9941 (gnus-summary-next-group))
9943 ;; Thread-based commands.
9945 (defun gnus-summary-toggle-threads (&optional arg)
9946 "Toggle showing conversation threads.
9947 If ARG is positive number, turn showing conversation threads on."
9949 (gnus-set-global-variables)
9950 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9951 (setq gnus-show-threads
9952 (if (null arg) (not gnus-show-threads)
9953 (> (prefix-numeric-value arg) 0)))
9954 (gnus-summary-prepare)
9955 (gnus-summary-goto-subject current)
9956 (gnus-summary-position-cursor)))
9958 (defun gnus-summary-show-all-threads ()
9961 (gnus-set-global-variables)
9963 (let ((buffer-read-only nil))
9964 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9965 (gnus-summary-position-cursor))
9967 (defun gnus-summary-show-thread ()
9968 "Show thread subtrees.
9969 Returns nil if no thread was there to be shown."
9971 (gnus-set-global-variables)
9972 (let ((buffer-read-only nil)
9974 ;; first goto end then to beg, to have point at beg after let
9975 (end (progn (end-of-line) (point)))
9976 (beg (progn (beginning-of-line) (point))))
9978 ;; Any hidden lines here?
9979 (search-forward "\r" end t)
9980 (subst-char-in-region beg end ?\^M ?\n t)
9982 (gnus-summary-position-cursor))))
9984 (defun gnus-summary-hide-all-threads ()
9985 "Hide all thread subtrees."
9987 (gnus-set-global-variables)
9989 (goto-char (point-min))
9990 (gnus-summary-hide-thread)
9991 (while (and (not (eobp)) (zerop (forward-line 1)))
9992 (gnus-summary-hide-thread)))
9993 (gnus-summary-position-cursor))
9995 (defun gnus-summary-hide-thread ()
9996 "Hide thread subtrees.
9997 Returns nil if no threads were there to be hidden."
9999 (gnus-set-global-variables)
10000 (let ((buffer-read-only nil)
10002 (level (gnus-summary-thread-level))
10004 ;; Go forward until either the buffer ends or the subthread
10008 (while (and (zerop (forward-line 1))
10009 (> (gnus-summary-thread-level) level))
10010 (setq end (point)))
10014 (search-backward "\n" start t))
10015 (subst-char-in-region start end ?\n ?\^M t)
10016 (forward-line -1)))))
10018 (defun gnus-summary-go-to-next-thread (&optional previous)
10019 "Go to the same level (or less) next thread.
10020 If PREVIOUS is non-nil, go to previous thread instead.
10021 Return the article number moved to, or nil if moving was impossible."
10022 (let ((level (gnus-summary-thread-level))
10023 (article (gnus-summary-article-number)))
10025 (while (and (zerop (forward-line -1))
10026 (> (gnus-summary-thread-level) level)))
10027 (while (and (save-excursion
10030 (zerop (forward-line 1))
10031 (> (gnus-summary-thread-level) level))))
10032 (gnus-summary-recenter)
10033 (gnus-summary-position-cursor)
10034 (let ((oart (gnus-summary-article-number)))
10035 (and (/= oart article) oart))))
10037 (defun gnus-summary-next-thread (n)
10038 "Go to the same level next N'th thread.
10039 If N is negative, search backward instead.
10040 Returns the difference between N and the number of skips actually
10043 (gnus-set-global-variables)
10044 (let ((backward (< n 0))
10046 (while (and (> n 0)
10047 (gnus-summary-go-to-next-thread backward))
10049 (gnus-summary-position-cursor)
10050 (if (/= 0 n) (gnus-message 7 "No more threads"))
10053 (defun gnus-summary-prev-thread (n)
10054 "Go to the same level previous N'th thread.
10055 Returns the difference between N and the number of skips actually
10058 (gnus-set-global-variables)
10059 (gnus-summary-next-thread (- n)))
10061 (defun gnus-summary-go-down-thread (&optional same)
10062 "Go down one level in the current thread.
10063 If SAME is non-nil, also move to articles of the same level."
10064 (let ((level (gnus-summary-thread-level))
10066 (if (and (zerop (forward-line 1))
10067 (> (gnus-summary-thread-level) level))
10072 (defun gnus-summary-go-up-thread ()
10073 "Go up one level in the current thread."
10074 (let ((level (gnus-summary-thread-level))
10076 (while (and (zerop (forward-line -1))
10077 (>= (gnus-summary-thread-level) level)))
10078 (if (>= (gnus-summary-thread-level) level)
10084 (defun gnus-summary-down-thread (n)
10085 "Go down thread N steps.
10086 If N is negative, go up instead.
10087 Returns the difference between N and how many steps down that were
10090 (gnus-set-global-variables)
10093 (while (and (> n 0)
10094 (if up (gnus-summary-go-up-thread)
10095 (gnus-summary-go-down-thread)))
10097 (gnus-summary-position-cursor)
10098 (if (/= 0 n) (gnus-message 7 "Can't go further"))
10101 (defun gnus-summary-up-thread (n)
10102 "Go up thread N steps.
10103 If N is negative, go up instead.
10104 Returns the difference between N and how many steps down that were
10107 (gnus-set-global-variables)
10108 (gnus-summary-down-thread (- n)))
10110 (defun gnus-summary-kill-thread (&optional unmark)
10111 "Mark articles under current thread as read.
10112 If the prefix argument is positive, remove any kinds of marks.
10113 If the prefix argument is negative, tick articles instead."
10115 (gnus-set-global-variables)
10117 (setq unmark (prefix-numeric-value unmark)))
10119 (level (gnus-summary-thread-level)))
10122 ;; Mark the article...
10123 (cond ((null unmark) (gnus-summary-mark-article-as-read
10125 ((> unmark 0) (gnus-summary-mark-article-as-unread
10127 (t (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10128 ;; ...and go forward until either the buffer ends or the subtree
10130 (if (not (and (zerop (forward-line 1))
10131 (> (gnus-summary-thread-level) level)))
10132 (setq killing nil))))
10133 ;; Hide killed subtrees.
10135 gnus-thread-hide-killed
10136 (gnus-summary-hide-thread))
10137 ;; If marked as read, go to next unread subject.
10139 ;; Go to next unread subject.
10140 (gnus-summary-next-subject 1 t)))
10141 (gnus-set-mode-line 'summary))
10143 ;; Summary sorting commands
10145 (defun gnus-summary-sort-by-number (&optional reverse)
10146 "Sort summary buffer by article number.
10147 Argument REVERSE means reverse order."
10149 (gnus-set-global-variables)
10151 ;; `gnus-summary-article-number' is a macro, and `sort-subr' wants
10152 ;; a function, so we wrap it.
10153 (cons (lambda () (gnus-summary-article-number))
10154 'gnus-thread-sort-by-number) reverse))
10156 (defun gnus-summary-sort-by-author (&optional reverse)
10157 "Sort summary buffer by author name alphabetically.
10158 If case-fold-search is non-nil, case of letters is ignored.
10159 Argument REVERSE means reverse order."
10161 (gnus-set-global-variables)
10165 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10167 gnus-extract-address-components
10168 (mail-header-from header))))
10169 (concat (or (car extract) (cdr extract))
10170 "\r" (mail-header-subject header))))
10171 'gnus-thread-sort-by-author)
10174 (defun gnus-summary-sort-by-subject (&optional reverse)
10175 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
10176 If case-fold-search is non-nil, case of letters is ignored.
10177 Argument REVERSE means reverse order."
10179 (gnus-set-global-variables)
10183 (let* ((header (gnus-get-header-by-num (gnus-summary-article-number)))
10185 gnus-extract-address-components
10186 (mail-header-from header))))
10188 (downcase (gnus-simplify-subject (gnus-summary-subject-string)))
10189 "\r" (or (car extract) (cdr extract)))))
10190 'gnus-thread-sort-by-subject)
10193 (defun gnus-summary-sort-by-date (&optional reverse)
10194 "Sort summary buffer by date.
10195 Argument REVERSE means reverse order."
10197 (gnus-set-global-variables)
10201 (gnus-sortable-date
10203 (gnus-get-header-by-num (gnus-summary-article-number)))))
10204 'gnus-thread-sort-by-date)
10207 (defun gnus-summary-sort-by-score (&optional reverse)
10208 "Sort summary buffer by score.
10209 Argument REVERSE means reverse order."
10211 (gnus-set-global-variables)
10213 (cons (lambda () (gnus-summary-article-score))
10214 'gnus-thread-sort-by-score)
10217 (defvar gnus-summary-already-sorted nil)
10218 (defun gnus-summary-sort (predicate reverse)
10219 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
10220 (if gnus-summary-already-sorted
10222 (let (buffer-read-only)
10223 (if (not gnus-show-threads)
10224 ;; We do untreaded sorting...
10226 (goto-char (point-min))
10227 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
10228 ;; ... or we do threaded sorting.
10229 (let ((gnus-thread-sort-functions (list (cdr predicate)))
10230 (gnus-summary-prepare-hook nil)
10231 (gnus-summary-already-sorted nil))
10232 ;; We do that by simply regenerating the threads.
10233 (gnus-summary-prepare)
10234 (and gnus-show-threads
10235 gnus-thread-hide-subtree
10236 (gnus-summary-hide-all-threads))
10237 ;; If in async mode, we send some info to the backend.
10238 (and gnus-newsgroup-async
10239 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
10240 (gnus-request-asynchronous
10241 gnus-newsgroup-name
10242 (if (and gnus-asynchronous-article-function
10243 (fboundp gnus-asynchronous-article-function))
10244 (funcall gnus-asynchronous-article-function
10245 gnus-newsgroup-threads)))))))))
10248 (defun gnus-sortable-date (date)
10249 "Make sortable string by string-lessp from DATE.
10250 Timezone package is used."
10251 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
10252 (year (aref date 0))
10253 (month (aref date 1))
10254 (day (aref date 2)))
10255 (timezone-make-sortable-date
10257 (timezone-make-time-string
10258 (aref date 3) (aref date 4) (aref date 5)))))
10261 ;; Summary saving commands.
10263 (defun gnus-summary-save-article (&optional n)
10264 "Save the current article using the default saver function.
10265 If N is a positive number, save the N next articles.
10266 If N is a negative number, save the N previous articles.
10267 If N is nil and any articles have been marked with the process mark,
10268 save those articles instead.
10269 The variable `gnus-default-article-saver' specifies the saver function."
10271 (gnus-set-global-variables)
10272 (let ((articles (gnus-summary-work-articles n)))
10274 (let ((header (gnus-get-header-by-num (car articles))))
10275 (if (vectorp header)
10277 (save-window-excursion
10278 (gnus-summary-select-article t nil nil (car articles)))
10279 (or gnus-save-all-headers
10280 (gnus-article-hide-headers t))
10281 ;; Remove any X-Gnus lines.
10284 (set-buffer gnus-article-buffer)
10285 (let ((buffer-read-only nil))
10286 (goto-char (point-min))
10287 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
10289 (while (re-search-forward "^X-Gnus" nil t)
10290 (beginning-of-line)
10291 (delete-region (point)
10292 (progn (forward-line 1) (point))))
10294 (save-window-excursion
10295 (if gnus-default-article-saver
10296 (funcall gnus-default-article-saver)
10297 (error "No default saver is defined."))))
10298 (if (assq 'name header)
10299 (gnus-copy-file (cdr (assq 'name header)))
10300 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
10301 (gnus-summary-remove-process-mark (car articles))
10302 (setq articles (cdr articles)))
10303 (gnus-summary-position-cursor)
10306 (defun gnus-summary-pipe-output (&optional arg)
10307 "Pipe the current article to a subprocess.
10308 If N is a positive number, pipe the N next articles.
10309 If N is a negative number, pipe the N previous articles.
10310 If N is nil and any articles have been marked with the process mark,
10311 pipe those articles instead."
10313 (gnus-set-global-variables)
10314 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10315 (gnus-summary-save-article arg)))
10317 (defun gnus-summary-save-article-mail (&optional arg)
10318 "Append the current article to an mail file.
10319 If N is a positive number, save the N next articles.
10320 If N is a negative number, save the N previous articles.
10321 If N is nil and any articles have been marked with the process mark,
10322 save those articles instead."
10324 (gnus-set-global-variables)
10325 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10326 (gnus-summary-save-article arg)))
10328 (defun gnus-summary-save-article-rmail (&optional arg)
10329 "Append the current article to an rmail file.
10330 If N is a positive number, save the N next articles.
10331 If N is a negative number, save the N previous articles.
10332 If N is nil and any articles have been marked with the process mark,
10333 save those articles instead."
10335 (gnus-set-global-variables)
10336 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10337 (gnus-summary-save-article arg)))
10339 (defun gnus-summary-save-article-file (&optional arg)
10340 "Append the current article to a file.
10341 If N is a positive number, save the N next articles.
10342 If N is a negative number, save the N previous articles.
10343 If N is nil and any articles have been marked with the process mark,
10344 save those articles instead."
10346 (gnus-set-global-variables)
10347 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10348 (gnus-summary-save-article arg)))
10350 (defun gnus-read-save-file-name (prompt default-name)
10351 (let ((methods gnus-split-methods)
10353 (if (not gnus-split-methods)
10356 (set-buffer gnus-article-buffer)
10357 (gnus-narrow-to-headers)
10359 (goto-char (point-min))
10360 (and (condition-case ()
10361 (re-search-forward (car (car methods)) nil t)
10363 (setq split-name (cons (nth 1 (car methods)) split-name)))
10364 (setq methods (cdr methods)))
10366 (cond ((null split-name)
10368 (concat prompt " (default "
10369 (file-name-nondirectory default-name) ") ")
10370 (file-name-directory default-name)
10372 ((= 1 (length split-name))
10374 (concat prompt " (default " (car split-name) ") ")
10375 gnus-article-save-directory
10376 (concat gnus-article-save-directory (car split-name))))
10378 (setq split-name (mapcar (lambda (el) (list el))
10379 (nreverse split-name)))
10380 (let ((result (completing-read
10381 (concat prompt " ")
10382 split-name nil nil)))
10383 (concat gnus-article-save-directory
10384 (if (string= result "")
10385 (car (car split-name))
10388 (defun gnus-summary-save-in-rmail (&optional filename)
10389 "Append this article to Rmail file.
10390 Optional argument FILENAME specifies file name.
10391 Directory to save to is default to `gnus-article-save-directory' which
10392 is initialized from the SAVEDIR environment variable."
10394 (gnus-set-global-variables)
10395 (let ((default-name
10396 (funcall gnus-rmail-save-name gnus-newsgroup-name
10397 gnus-current-headers gnus-newsgroup-last-rmail)))
10399 (setq filename (gnus-read-save-file-name
10400 "Save in rmail file:" default-name)))
10401 (gnus-make-directory (file-name-directory filename))
10402 (gnus-eval-in-buffer-window
10403 gnus-article-buffer
10407 (gnus-output-to-rmail filename))))
10408 ;; Remember the directory name to save articles
10409 (setq gnus-newsgroup-last-rmail filename)))
10411 (defun gnus-summary-save-in-mail (&optional filename)
10412 "Append this article to Unix mail file.
10413 Optional argument FILENAME specifies file name.
10414 Directory to save to is default to `gnus-article-save-directory' which
10415 is initialized from the SAVEDIR environment variable."
10417 (gnus-set-global-variables)
10418 (let ((default-name
10419 (funcall gnus-mail-save-name gnus-newsgroup-name
10420 gnus-current-headers gnus-newsgroup-last-mail)))
10422 (setq filename (gnus-read-save-file-name
10423 "Save in Unix mail file:" default-name)))
10425 (expand-file-name filename
10427 (file-name-directory default-name))))
10428 (gnus-make-directory (file-name-directory filename))
10429 (gnus-eval-in-buffer-window
10430 gnus-article-buffer
10434 (if (and (file-readable-p filename) (rmail-file-p filename))
10435 (gnus-output-to-rmail filename)
10436 (rmail-output filename 1 t t)))))
10437 ;; Remember the directory name to save articles.
10438 (setq gnus-newsgroup-last-mail filename)))
10440 (defun gnus-summary-save-in-file (&optional filename)
10441 "Append this article to file.
10442 Optional argument FILENAME specifies file name.
10443 Directory to save to is default to `gnus-article-save-directory' which
10444 is initialized from the SAVEDIR environment variable."
10446 (gnus-set-global-variables)
10447 (let ((default-name
10448 (funcall gnus-file-save-name gnus-newsgroup-name
10449 gnus-current-headers gnus-newsgroup-last-file)))
10451 (setq filename (gnus-read-save-file-name
10452 "Save in file:" default-name)))
10453 (gnus-make-directory (file-name-directory filename))
10454 (gnus-eval-in-buffer-window
10455 gnus-article-buffer
10459 (gnus-output-to-file filename))))
10460 ;; Remember the directory name to save articles.
10461 (setq gnus-newsgroup-last-file filename)))
10463 (defun gnus-summary-save-in-pipe (&optional command)
10464 "Pipe this article to subprocess."
10466 (gnus-set-global-variables)
10467 (let ((command (read-string "Shell command on article: "
10468 gnus-last-shell-command)))
10469 (if (string-equal command "")
10470 (setq command gnus-last-shell-command))
10471 (gnus-eval-in-buffer-window
10472 gnus-article-buffer
10475 (shell-command-on-region (point-min) (point-max) command nil)))
10476 (setq gnus-last-shell-command command)))
10478 ;; Summary extract commands
10480 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10481 (let ((buffer-read-only nil)
10482 (article (gnus-summary-article-number))
10484 (or (gnus-summary-goto-subject article)
10485 (error (format "No such article: %d" article)))
10486 (gnus-summary-position-cursor)
10487 ;; If all commands are to be bunched up on one line, we collect
10489 (if gnus-view-pseudos-separately
10491 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10494 (setq action (cdr (assq 'action (car ps))))
10495 (setq files (list (cdr (assq 'name (car ps)))))
10496 (while (and ps (cdr ps)
10497 (string= (or action "1")
10498 (or (cdr (assq 'action (car (cdr ps)))) "2")))
10499 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
10500 (setcdr ps (cdr (cdr ps))))
10503 (if (not (string-match "%s" action))
10504 (setq files (cons " " files)))
10505 (setq files (cons " " files))
10506 (and (assq 'execute (car ps))
10507 (setcdr (assq 'execute (car ps))
10508 (funcall (if (string-match "%s" action)
10511 (mapconcat (lambda (f) f) files " ")))))
10512 (setq ps (cdr ps)))))
10513 (if (and gnus-view-pseudos (not not-view))
10515 (and (assq 'execute (car pslist))
10516 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10517 (eq gnus-view-pseudos 'not-confirm)))
10518 (setq pslist (cdr pslist)))
10521 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
10522 (gnus-summary-article-number)))
10525 (insert " " (file-name-nondirectory
10526 (cdr (assq 'name (car pslist))))
10527 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10528 (add-text-properties
10529 b (1+ b) (list 'gnus-number gnus-reffed-article-number
10530 'gnus-mark gnus-unread-mark
10532 'gnus-pseudo (car pslist)))
10534 (gnus-sethash (int-to-string gnus-reffed-article-number)
10535 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
10536 (setq gnus-newsgroup-unreads
10537 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
10538 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10539 (setq pslist (cdr pslist)))))))
10541 (defun gnus-pseudos< (p1 p2)
10542 (let ((c1 (cdr (assq 'action p1)))
10543 (c2 (cdr (assq 'action p2))))
10544 (and c1 c2 (string< c1 c2))))
10546 (defun gnus-request-pseudo-article (props)
10547 (cond ((assq 'execute props)
10548 (gnus-execute-command (cdr (assq 'execute props)))))
10549 (let ((gnus-current-article (gnus-summary-article-number)))
10550 (run-hooks 'gnus-mark-article-hook)))
10552 (defun gnus-execute-command (command &optional automatic)
10554 (gnus-article-setup-buffer)
10555 (set-buffer gnus-article-buffer)
10556 (let ((command (if automatic command (read-string "Command: " command)))
10557 (buffer-read-only nil))
10559 (insert "$ " command "\n\n")
10560 (if gnus-view-pseudo-asynchronously
10561 (start-process "gnus-execute" nil "sh" "-c" command)
10562 (call-process "sh" nil t nil "-c" command)))))
10564 (defun gnus-copy-file (file &optional to)
10567 (list (read-file-name "Copy file: " default-directory)
10568 (read-file-name "Copy file to: " default-directory)))
10569 (gnus-set-global-variables)
10570 (or to (setq to (read-file-name "Copy file to: " default-directory)))
10571 (and (file-directory-p to)
10572 (setq to (concat (file-name-as-directory to)
10573 (file-name-nondirectory file))))
10574 (copy-file file to))
10576 ;; Summary kill commands.
10578 (defun gnus-summary-edit-global-kill (article)
10579 "Edit the \"global\" kill file."
10580 (interactive (list (gnus-summary-article-number)))
10581 (gnus-set-global-variables)
10582 (gnus-group-edit-global-kill article))
10584 (defun gnus-summary-edit-local-kill ()
10585 "Edit a local kill file applied to the current newsgroup."
10587 (gnus-set-global-variables)
10588 (setq gnus-current-headers
10590 (int-to-string (gnus-summary-article-number))
10591 gnus-newsgroup-headers-hashtb-by-number))
10592 (gnus-set-global-variables)
10593 (gnus-group-edit-local-kill
10594 (gnus-summary-article-number) gnus-newsgroup-name))
10598 ;;; Gnus article mode
10601 (put 'gnus-article-mode 'mode-class 'special)
10603 (defvar gnus-boogaboo nil)
10605 (if gnus-article-mode-map
10607 (setq gnus-article-mode-map (make-keymap))
10608 (suppress-keymap gnus-article-mode-map)
10609 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
10610 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
10611 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
10612 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
10613 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
10614 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
10615 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
10616 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
10617 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
10618 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
10619 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
10620 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
10622 ;; Duplicate almost all summary keystrokes in the article mode map.
10625 "p" "N" "P" "\M-\C-n" "\M-\C-p"
10626 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
10627 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
10628 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
10629 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
10630 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
10631 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
10632 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
10633 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
10634 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
10635 "\C-c\C-v\C-v" "\C-d" "v"
10636 ;; "Mt" "M!" "Md" "Mr"
10637 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
10638 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
10639 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
10640 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
10641 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
10642 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
10643 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
10644 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
10645 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
10646 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
10647 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
10649 (while (and gnus-boogaboo commands) ; disabled
10650 (define-key gnus-article-mode-map (car commands)
10651 'gnus-article-summary-command)
10652 (setq commands (cdr commands))))
10654 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
10655 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
10656 "=" "n" "^" "\M-^")))
10657 (while (and gnus-boogaboo commands) ; disabled
10658 (define-key gnus-article-mode-map (car commands)
10659 'gnus-article-summary-command-nosave)
10660 (setq commands (cdr commands)))))
10663 (defun gnus-article-mode ()
10664 "Major mode for displaying an article.
10666 All normal editing commands are switched off.
10668 The following commands are available:
10670 \\<gnus-article-mode-map>
10671 \\[gnus-article-next-page]\t Scroll the article one page forwards
10672 \\[gnus-article-prev-page]\t Scroll the article one page backwards
10673 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
10674 \\[gnus-article-show-summary]\t Display the summary buffer
10675 \\[gnus-article-mail]\t Send a reply to the address near point
10676 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
10677 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
10678 \\[gnus-info-find-node]\t Go to the Gnus info node"
10680 (if gnus-visual (gnus-article-make-menu-bar))
10681 (kill-all-local-variables)
10682 (setq mode-line-modified "-- ")
10683 (make-local-variable 'mode-line-format)
10684 (setq mode-line-format (copy-sequence mode-line-format))
10685 (and (equal (nth 3 mode-line-format) " ")
10686 (setcar (nthcdr 3 mode-line-format) ""))
10687 (setq mode-name "Article")
10688 (setq major-mode 'gnus-article-mode)
10689 (make-local-variable 'minor-mode-alist)
10690 (or (assq 'gnus-show-mime minor-mode-alist)
10691 (setq minor-mode-alist
10692 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
10693 (use-local-map gnus-article-mode-map)
10694 (make-local-variable 'page-delimiter)
10695 (setq page-delimiter gnus-page-delimiter)
10696 (buffer-disable-undo (current-buffer))
10697 (setq buffer-read-only t) ;Disable modification
10698 (run-hooks 'gnus-article-mode-hook))
10700 (defun gnus-article-setup-buffer ()
10701 "Initialize article mode buffer."
10702 ;; Returns the article buffer.
10703 (if (get-buffer gnus-article-buffer)
10705 (set-buffer gnus-article-buffer)
10706 (buffer-disable-undo (current-buffer))
10707 (setq buffer-read-only t)
10708 (gnus-add-current-to-buffer-list)
10709 (or (eq major-mode 'gnus-article-mode)
10710 (gnus-article-mode))
10713 (set-buffer (get-buffer-create gnus-article-buffer))
10714 (gnus-add-current-to-buffer-list)
10715 (gnus-article-mode)
10716 (current-buffer))))
10718 ;; Set article window start at LINE, where LINE is the number of lines
10719 ;; from the head of the article.
10720 (defun gnus-article-set-window-start (&optional line)
10722 (get-buffer-window gnus-article-buffer)
10724 (set-buffer gnus-article-buffer)
10725 (goto-char (point-min))
10728 (gnus-message 6 "Moved to bookmark")
10729 (search-forward "\n\n" nil t)
10730 (forward-line line)
10733 (defun gnus-request-article-this-buffer (article group)
10734 "Get an article and insert it into this buffer."
10735 (setq group (or group gnus-newsgroup-name))
10737 ;; Open server if it has closed.
10738 (gnus-check-server (gnus-find-method-for-group group))
10740 ;; Using `gnus-request-article' directly will insert the article into
10741 ;; `nntp-server-buffer' - so we'll save some time by not having to
10742 ;; copy it from the server buffer into the article buffer.
10744 ;; We only request an article by message-id when we do not have the
10745 ;; headers for it, so we'll have to get those.
10746 (and (stringp article)
10747 (let ((gnus-override-method gnus-refer-article-method))
10748 (gnus-read-header article)))
10750 ;; If the article number is negative, that means that this article
10751 ;; doesn't belong in this newsgroup (possibly), so we find its
10752 ;; message-id and request it by id instead of number.
10753 (if (not (numberp article))
10756 (set-buffer gnus-summary-buffer)
10757 (let ((header (gnus-get-header-by-num article)))
10759 (if (vectorp header)
10760 ;; It's a real article.
10761 (setq article (mail-header-id header))
10762 ;; It is an extracted pseudo-article.
10763 (setq article 'pseudo)
10764 (gnus-request-pseudo-article header)))
10766 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
10767 (if (not (eq (car method) 'nneething))
10769 (let ((dir (concat (file-name-as-directory (nth 1 method))
10770 (mail-header-subject header))))
10771 (if (file-directory-p dir)
10773 (setq article 'nneething)
10774 (gnus-group-enter-directory dir)))))))))
10776 ;; Check the cache.
10777 (if (and gnus-use-cache
10779 (gnus-cache-request-article article group))
10781 ;; Get the article and into the article buffer.
10782 (if (or (stringp article) (numberp article))
10785 (let ((gnus-override-method
10786 (and (stringp article) gnus-refer-article-method)))
10787 (and (gnus-request-article article group (current-buffer))
10791 (defun gnus-read-header (id)
10792 "Read the headers of article ID and enter them into the Gnus system."
10794 (if (not (setq header
10795 (car (if (let ((gnus-nov-is-evil t))
10796 (gnus-retrieve-headers
10797 (list id) gnus-newsgroup-name))
10798 (gnus-get-newsgroup-headers)))))
10801 (mail-header-set-number header gnus-reffed-article-number))
10802 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
10803 (gnus-sethash (int-to-string (mail-header-number header)) header
10804 gnus-newsgroup-headers-hashtb-by-number)
10806 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
10807 (setq gnus-current-headers header)
10810 (defun gnus-article-prepare (article &optional all-headers header)
10811 "Prepare ARTICLE in article mode buffer.
10812 ARTICLE should either be an article number or a Message-ID.
10813 If ARTICLE is an id, HEADER should be the article headers.
10814 If ALL-HEADERS is non-nil, no headers are hidden."
10816 ;; Make sure we start in a summary buffer.
10817 (or (eq major-mode 'gnus-summary-mode)
10818 (set-buffer gnus-summary-buffer))
10819 (setq gnus-summary-buffer (current-buffer))
10820 ;; Make sure the connection to the server is alive.
10821 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
10824 (gnus-find-method-for-group gnus-newsgroup-name))
10825 (gnus-request-group gnus-newsgroup-name t)))
10826 (let* ((article (if header (mail-header-number header) article))
10827 (summary-buffer (current-buffer))
10828 (internal-hook gnus-article-internal-prepare-hook)
10829 (group gnus-newsgroup-name)
10832 (gnus-article-setup-buffer)
10833 (set-buffer gnus-article-buffer)
10834 (if (not (setq result (let ((buffer-read-only nil))
10835 (gnus-request-article-this-buffer
10837 ;; There is no such article.
10839 (if (not (numberp article))
10841 (setq gnus-article-current
10842 (cons gnus-newsgroup-name article))
10843 (set-buffer gnus-summary-buffer)
10844 (setq gnus-current-article article)
10845 (gnus-summary-mark-article article gnus-canceled-mark))
10846 (gnus-message 1 "No such article (may be canceled)")
10849 (if (or (eq result 'pseudo) (eq result 'nneething))
10852 (set-buffer summary-buffer)
10853 (setq gnus-last-article gnus-current-article
10854 gnus-newsgroup-history (cons gnus-current-article
10855 gnus-newsgroup-history)
10856 gnus-current-article 0
10857 gnus-current-headers nil
10858 gnus-article-current nil)
10859 (if (eq result 'nneething)
10860 (gnus-configure-windows 'summary)
10861 (gnus-configure-windows 'article))
10862 (gnus-set-global-variables))
10863 (gnus-set-mode-line 'article))
10864 ;; The result from the `request' was an actual article -
10865 ;; or at least some text that is now displayed in the
10867 (if (and (numberp article)
10868 (not (eq article gnus-current-article)))
10869 ;; Seems like a new article has been selected.
10870 ;; `gnus-current-article' must be an article number.
10872 (set-buffer summary-buffer)
10873 (setq gnus-last-article gnus-current-article
10874 gnus-newsgroup-history (cons gnus-current-article
10875 gnus-newsgroup-history)
10876 gnus-current-article article
10877 gnus-current-headers
10878 (gnus-get-header-by-num gnus-current-article)
10879 gnus-article-current
10880 (cons gnus-newsgroup-name gnus-current-article))
10881 (gnus-summary-show-thread)
10882 (run-hooks 'gnus-mark-article-hook)
10883 (gnus-set-mode-line 'summary)
10885 (run-hooks 'gnus-visual-mark-article-hook))
10886 ;; Set the global newsgroup variables here.
10887 ;; Suggested by Jim Sisolak
10888 ;; <sisolak@trans4.neep.wisc.edu>.
10889 (gnus-set-global-variables)
10890 (setq gnus-have-all-headers
10891 (or all-headers gnus-show-all-headers))
10892 (and gnus-use-cache
10893 (vectorp (gnus-get-header-by-number article))
10894 (gnus-cache-possibly-enter-article
10896 (gnus-get-header-by-number article)
10897 (memq article gnus-newsgroup-marked)
10898 (memq article gnus-newsgroup-dormant)
10899 (memq article gnus-newsgroup-unreads)))))
10900 ;; Hooks for getting information from the article.
10901 ;; This hook must be called before being narrowed.
10902 (let (buffer-read-only)
10903 (run-hooks 'internal-hook)
10904 (run-hooks 'gnus-article-prepare-hook)
10905 ;; Decode MIME message.
10906 (if (and gnus-show-mime
10907 (or (not gnus-strict-mime)
10908 (gnus-fetch-field "Mime-Version")))
10909 (funcall gnus-show-mime-method))
10910 ;; Perform the article display hooks.
10911 (run-hooks 'gnus-article-display-hook))
10913 (goto-char (point-min))
10914 (and gnus-break-pages (gnus-narrow-to-page))
10915 (gnus-set-mode-line 'article)
10916 (gnus-configure-windows 'article)
10917 (goto-char (point-min))
10920 (defun gnus-article-show-all-headers ()
10921 "Show all article headers in article mode buffer."
10923 (gnus-article-setup-buffer)
10924 (set-buffer gnus-article-buffer)
10925 (let ((buffer-read-only nil))
10926 (remove-text-properties (point-min) (point-max)
10927 gnus-hidden-properties))))
10929 (defun gnus-article-hide-headers-if-wanted ()
10930 "Hide unwanted headers if `gnus-have-all-headers' is nil.
10931 Provided for backwards compatability."
10932 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
10933 (gnus-article-hide-headers)))
10935 (defun gnus-article-hide-headers (&optional delete)
10936 "Hide unwanted headers and possibly sort them as well."
10939 (set-buffer gnus-article-buffer)
10941 (let ((sorted gnus-sorted-header-list)
10942 (buffer-read-only nil)
10943 want-list beg want-l)
10944 ;; First we narrow to just the headers.
10946 (goto-char (point-min))
10947 ;; Hide any "From " lines at the beginning of (mail) articles.
10948 (while (looking-at "From ")
10951 (add-text-properties (point-min) (point) gnus-hidden-properties))
10952 ;; Then treat the rest of the header lines.
10955 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
10956 ;; Then we use the two regular expressions
10957 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
10958 ;; select which header lines is to remain visible in the
10960 (goto-char (point-min))
10961 (while (re-search-forward "^[^ \t]*:" nil t)
10962 (beginning-of-line)
10963 ;; We add the headers we want to keep to a list and delete
10964 ;; them from the buffer.
10965 (if (or (and (stringp gnus-visible-headers)
10966 (looking-at gnus-visible-headers))
10967 (and (not (stringp gnus-visible-headers))
10968 (stringp gnus-ignored-headers)
10969 (not (looking-at gnus-ignored-headers))))
10973 ;; Be sure to get multi-line headers...
10974 (re-search-forward "^[^ \t]*:" nil t)
10975 (beginning-of-line)
10977 (cons (buffer-substring beg (point)) want-list))
10978 (delete-region beg (point))
10981 ;; Next we perform the sorting by looking at
10982 ;; `gnus-sorted-header-list'.
10983 (goto-char (point-min))
10984 (while (and sorted want-list)
10985 (setq want-l want-list)
10987 (not (string-match (car sorted) (car want-l))))
10988 (setq want-l (cdr want-l)))
10991 (insert (car want-l))
10992 (setq want-list (delq (car want-l) want-list))))
10993 (setq sorted (cdr sorted)))
10994 ;; Any headers that were not matched by the sorted list we
10995 ;; just tack on the end of the visible header list.
10997 (insert (car want-list))
10998 (setq want-list (cdr want-list)))
10999 ;; And finally we make the unwanted headers invisible.
11001 (delete-region (point) (point-max))
11002 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11003 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
11005 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
11006 (defun gnus-article-treat-overstrike ()
11007 "Translate overstrikes into bold text."
11010 (set-buffer gnus-article-buffer)
11011 (let ((buffer-read-only nil))
11012 (while (search-forward "\b" nil t)
11013 (let ((next (following-char))
11014 (previous (char-after (- (point) 2))))
11015 (cond ((eq next previous)
11016 (put-text-property (- (point) 2) (point)
11018 (put-text-property (point) (1+ (point))
11021 (put-text-property (1- (point)) (1+ (point))
11023 (put-text-property (1- (point)) (point)
11026 (put-text-property (- (point) 2) (point)
11028 (put-text-property (point) (1+ (point))
11029 'face 'underline))))))))
11031 (defun gnus-article-word-wrap ()
11032 "Format too long lines."
11035 (set-buffer gnus-article-buffer)
11036 (let ((buffer-read-only nil))
11037 (goto-char (point-min))
11038 (search-forward "\n\n" nil t)
11040 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
11041 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
11042 (adaptive-fill-mode t))
11043 (while (not (eobp))
11044 (and (>= (current-column) (min fill-column (window-width)))
11045 (/= (preceding-char) ?:)
11046 (fill-paragraph nil))
11047 (end-of-line 2))))))
11049 (defun gnus-article-remove-cr ()
11050 "Remove carriage returns from an article."
11053 (set-buffer gnus-article-buffer)
11054 (let ((buffer-read-only nil))
11055 (goto-char (point-min))
11056 (while (search-forward "\r" nil t)
11057 (replace-match "" t t)))))
11059 (defun gnus-article-display-x-face (&optional force)
11060 "Look for an X-Face header and display it if present."
11061 (interactive (list 'force))
11063 (set-buffer gnus-article-buffer)
11064 (let ((inhibit-point-motion-hooks t)
11065 (case-fold-search nil))
11067 (goto-char (point-min))
11068 (search-forward "\n\n")
11069 (narrow-to-region (point-min) (point))
11070 (goto-char (point-min))
11071 (if (not (and gnus-article-x-face-command
11073 (not gnus-article-x-face-too-ugly)
11074 (and gnus-article-x-face-too-ugly
11075 (not (string-match gnus-article-x-face-too-ugly
11076 (mail-fetch-field "from")))))
11078 (goto-char (point-min))
11079 (re-search-forward "^X-Face: " nil t))))
11081 (let ((beg (point))
11082 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
11083 (if (symbolp gnus-article-x-face-command)
11084 (and (or (fboundp gnus-article-x-face-command)
11085 (error "%s is not a function"
11086 gnus-article-x-face-command))
11087 (funcall gnus-article-x-face-command beg end))
11088 (call-process-region beg end "sh" nil 0 nil
11089 "-c" gnus-article-x-face-command))))))))
11091 (defun gnus-article-de-quoted-unreadable (&optional force)
11092 "Do a naïve translation of a quoted-printable-encoded article.
11093 This is in no way, shape or form meant as a replacement for real MIME
11094 processing, but is simply a stop-gap measure until MIME support is
11096 If FORCE, decode the article whether it is marked as quoted-printable
11098 (interactive (list 'force))
11100 (set-buffer gnus-article-buffer)
11101 (let ((case-fold-search t)
11102 (buffer-read-only nil)
11103 (type (gnus-fetch-field "content-transfer-encoding")))
11104 (if (or force (and type (string-match "quoted-printable" type)))
11106 (goto-char (point-min))
11107 (search-forward "\n\n" nil 'move)
11108 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
11110 (defun gnus-mime-decode-quoted-printable (from to)
11111 ;; Decode quoted-printable from region between FROM and TO.
11114 (while (search-forward "=" to t)
11115 (cond ((eq (following-char) ?\n)
11118 ((looking-at "[0-9A-F][0-9A-F]")
11120 (insert (hexl-hex-string-to-integer
11121 (buffer-substring (point) (+ 2 (point)))))
11125 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
11127 (defvar gnus-article-time-units
11128 (list (cons 'year (* 365.25 24 60 60))
11129 (cons 'week (* 7 24 60 60))
11130 (cons 'day (* 24 60 60))
11131 (cons 'hour (* 60 60))
11135 (defun gnus-article-date-ut (&optional type)
11136 "Convert DATE date to universal time in the current article.
11137 If TYPE is `local', convert to local time; if it is `lapsed', output
11138 how much time has lapsed since DATE."
11139 (interactive (list 'ut))
11140 (let ((date (mail-header-date (or gnus-current-headers
11141 (gnus-get-header-by-number
11142 (gnus-summary-article-number))"")))
11143 (date-regexp "^Date: \\|^X-Sent: "))
11148 (set-buffer gnus-article-buffer)
11149 (let ((buffer-read-only nil))
11150 (goto-char (point-min))
11151 (if (and (re-search-forward date-regexp nil t)
11153 (beginning-of-line)
11154 (looking-at date-regexp)))
11155 (delete-region (gnus-point-at-bol)
11156 (progn (end-of-line) (1+ (point))))
11157 (goto-char (point-min))
11158 (goto-char (- (search-forward "\n\n") 2)))
11162 (concat "Date: " (condition-case ()
11163 (timezone-make-date-arpa-standard date)
11169 (timezone-make-date-arpa-standard date nil "UT")
11173 ;; If the date is seriously mangled, the timezone
11174 ;; functions are liable to bug out, so we condition-case
11175 ;; the entire thing.
11176 (let* ((real-sec (condition-case ()
11177 (- (gnus-seconds-since-epoch
11178 (timezone-make-date-arpa-standard
11179 (current-time-string)
11180 (current-time-zone) "UT"))
11181 (gnus-seconds-since-epoch
11182 (timezone-make-date-arpa-standard
11185 (sec (abs real-sec))
11193 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
11195 (setq sec (- sec (* num (cdr unit))))
11197 (concat (if prev ", " "") (int-to-string
11199 " " (symbol-name (car unit))
11200 (if (> num 1) "s" ""))
11202 gnus-article-time-units "")
11205 " in the future\n")))))
11207 (error "Unknown conversion type: %s" type)))))))))
11209 (defun gnus-article-date-local ()
11210 "Convert the current article date to the local timezone."
11212 (gnus-article-date-ut 'local))
11214 (defun gnus-article-date-lapsed ()
11215 "Convert the current article date to time lapsed since it was sent."
11217 (gnus-article-date-ut 'lapsed))
11219 (defun gnus-article-maybe-highlight ()
11220 "Do some article highlighting if `gnus-visual' is non-nil."
11221 (if gnus-visual (gnus-article-highlight-some)))
11225 (defun gnus-output-to-rmail (file-name)
11226 "Append the current article to an Rmail file named FILE-NAME."
11228 ;; Most of these codes are borrowed from rmailout.el.
11229 (setq file-name (expand-file-name file-name))
11230 (setq rmail-default-rmail-file file-name)
11231 (let ((artbuf (current-buffer))
11232 (tmpbuf (get-buffer-create " *Gnus-output*")))
11234 (or (get-file-buffer file-name)
11235 (file-exists-p file-name)
11236 (if (gnus-yes-or-no-p
11237 (concat "\"" file-name "\" does not exist, create it? "))
11238 (let ((file-buffer (create-file-buffer file-name)))
11240 (set-buffer file-buffer)
11241 (rmail-insert-rmail-file-header)
11242 (let ((require-final-newline nil))
11243 (write-region (point-min) (point-max) file-name t 1)))
11244 (kill-buffer file-buffer))
11245 (error "Output file does not exist")))
11246 (set-buffer tmpbuf)
11247 (buffer-disable-undo (current-buffer))
11249 (insert-buffer-substring artbuf)
11250 (gnus-convert-article-to-rmail)
11251 ;; Decide whether to append to a file or to an Emacs buffer.
11252 (let ((outbuf (get-file-buffer file-name)))
11254 (append-to-file (point-min) (point-max) file-name)
11255 ;; File has been visited, in buffer OUTBUF.
11256 (set-buffer outbuf)
11257 (let ((buffer-read-only nil)
11258 (msg (and (boundp 'rmail-current-message)
11259 (symbol-value 'rmail-current-message))))
11260 ;; If MSG is non-nil, buffer is in RMAIL mode.
11263 (narrow-to-region (point-max) (point-max))))
11264 (insert-buffer-substring tmpbuf)
11267 (goto-char (point-min))
11269 (search-backward "\^_")
11270 (narrow-to-region (point) (point-max))
11271 (goto-char (1+ (point-min)))
11272 (rmail-count-new-messages t)
11273 (rmail-show-message msg)))))))
11274 (kill-buffer tmpbuf)))
11276 (defun gnus-output-to-file (file-name)
11277 "Append the current article to a file named FILE-NAME."
11278 (setq file-name (expand-file-name file-name))
11279 (let ((artbuf (current-buffer))
11280 (tmpbuf (get-buffer-create " *Gnus-output*")))
11282 (set-buffer tmpbuf)
11283 (buffer-disable-undo (current-buffer))
11285 (insert-buffer-substring artbuf)
11286 ;; Append newline at end of the buffer as separator, and then
11287 ;; save it to file.
11288 (goto-char (point-max))
11290 (append-to-file (point-min) (point-max) file-name))
11291 (kill-buffer tmpbuf)))
11293 (defun gnus-convert-article-to-rmail ()
11294 "Convert article in current buffer to Rmail message format."
11295 (let ((buffer-read-only nil))
11296 ;; Convert article directly into Babyl format.
11297 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
11298 (goto-char (point-min))
11299 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
11300 (while (search-forward "\n\^_" nil t) ;single char
11301 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
11302 (goto-char (point-max))
11305 (defun gnus-narrow-to-page (&optional arg)
11306 "Make text outside current page invisible except for page delimiter.
11307 A numeric arg specifies to move forward or backward by that many pages,
11308 thus showing a page other than the one point was originally in."
11310 (setq arg (if arg (prefix-numeric-value arg) 0))
11312 (forward-page -1) ;Beginning of current page.
11317 (forward-page (1- arg))))
11318 ;; Find the end of the page.
11320 ;; If we stopped due to end of buffer, stay there.
11321 ;; If we stopped after a page delimiter, put end of restriction
11322 ;; at the beginning of that line.
11323 ;; These are commented out.
11324 ;; (if (save-excursion (beginning-of-line)
11325 ;; (looking-at page-delimiter))
11326 ;; (beginning-of-line))
11327 (narrow-to-region (point)
11329 ;; Find the top of the page.
11331 ;; If we found beginning of buffer, stay there.
11332 ;; If extra text follows page delimiter on same line,
11334 ;; Otherwise, show text starting with following line.
11335 (if (and (eolp) (not (bobp)))
11339 (defun gnus-gmt-to-local ()
11340 "Rewrite Date header described in GMT to local in current buffer.
11341 Intended to be used with gnus-article-prepare-hook."
11345 (goto-char (point-min))
11346 (narrow-to-region (point-min)
11347 (progn (search-forward "\n\n" nil 'move) (point)))
11348 (goto-char (point-min))
11349 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
11350 (let ((buffer-read-only nil)
11351 (date (buffer-substring-no-properties
11352 (match-beginning 1) (match-end 1))))
11353 (delete-region (match-beginning 1) (match-end 1))
11355 (timezone-make-date-arpa-standard
11356 date nil (current-time-zone))))))))
11359 ;; Article mode commands
11361 (defun gnus-article-next-page (&optional lines)
11362 "Show next page of current article.
11363 If end of article, return non-nil. Otherwise return nil.
11364 Argument LINES specifies lines to be scrolled up."
11366 (move-to-window-line -1)
11367 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
11368 (if (save-excursion
11370 (and (pos-visible-in-window-p) ;Not continuation line.
11372 ;; Nothing in this page.
11373 (if (or (not gnus-break-pages)
11376 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
11378 (gnus-narrow-to-page 1) ;Go to next page.
11380 ;; More in this page.
11384 ;; Long lines may cause an end-of-buffer error.
11385 (goto-char (point-max))))
11388 (defun gnus-article-prev-page (&optional lines)
11389 "Show previous page of current article.
11390 Argument LINES specifies lines to be scrolled down."
11392 (move-to-window-line 0)
11393 (if (and gnus-break-pages
11395 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
11397 (gnus-narrow-to-page -1) ;Go to previous page.
11398 (goto-char (point-max))
11400 (scroll-down lines)))
11402 (defun gnus-article-refer-article ()
11403 "Read article specified by message-id around point."
11405 (search-forward ">" nil t) ;Move point to end of "<....>".
11406 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
11408 (buffer-substring (match-beginning 1) (match-end 1))))
11409 (set-buffer gnus-summary-buffer)
11410 (gnus-summary-refer-article message-id))
11411 (error "No references around point")))
11413 (defun gnus-article-show-summary ()
11414 "Reconfigure windows to show summary buffer."
11416 (gnus-configure-windows 'article)
11417 (gnus-summary-goto-subject gnus-current-article))
11419 (defun gnus-article-describe-briefly ()
11420 "Describe article mode commands briefly."
11423 (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")))
11425 (defun gnus-article-summary-command ()
11426 "Execute the last keystroke in the summary buffer."
11428 (let ((obuf (current-buffer))
11429 (owin (current-window-configuration))
11431 (switch-to-buffer gnus-summary-buffer 'norecord)
11432 (setq func (lookup-key (current-local-map) (this-command-keys)))
11433 (call-interactively func)
11435 (set-window-configuration owin)
11436 (set-window-point (get-buffer-window (current-buffer)) (point))))
11438 (defun gnus-article-summary-command-nosave ()
11439 "Execute the last keystroke in the summary buffer."
11442 (pop-to-buffer gnus-summary-buffer 'norecord)
11443 (setq func (lookup-key (current-local-map) (this-command-keys)))
11444 (call-interactively func)))
11447 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
11450 (defalias 'gnus-batch-kill 'gnus-batch-score)
11452 (defun gnus-batch-score ()
11453 "Run batched scoring.
11454 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
11455 Newsgroups is a list of strings in Bnews format. If you want to score
11456 the comp hierarchy, you'd say \"comp.all\". If you would not like to
11457 score the alt hierarchy, you'd say \"!alt.all\"."
11460 (gnus-newsrc-parse-options
11461 (apply (function concat)
11462 (mapcar (lambda (g) (concat g " "))
11463 command-line-args-left))))
11464 (gnus-expert-user t)
11465 (nnmail-spool-file nil)
11466 (gnus-use-dribble-file nil)
11467 (yes (car yes-and-no))
11468 (no (cdr yes-and-no))
11470 ;; Disable verbose message.
11471 gnus-novice-user gnus-large-newsgroup)
11472 ;; Eat all arguments.
11473 (setq command-line-args-left nil)
11476 ;; Apply kills to specified newsgroups in command line arguments.
11477 (setq newsrc (cdr gnus-newsrc-alist))
11479 (setq group (car (car newsrc)))
11480 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
11481 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
11483 (or (eq (car entry) t)
11484 (not (zerop (car entry)))))
11485 (if yes (string-match yes group) t)
11486 (or (null no) (not (string-match no group))))
11488 (gnus-summary-read-group group nil t)
11489 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
11490 (gnus-summary-exit))))
11491 (setq newsrc (cdr newsrc)))
11493 (switch-to-buffer gnus-group-buffer)
11494 (gnus-group-save-newsrc)))
11496 (defun gnus-apply-kill-file ()
11497 "Apply a kill file to the current newsgroup.
11498 Returns the number of articles marked as read."
11499 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
11500 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11501 (gnus-apply-kill-file-internal)
11504 (defun gnus-kill-save-kill-buffer ()
11506 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
11507 (if (get-file-buffer file)
11509 (set-buffer (get-file-buffer file))
11510 (and (buffer-modified-p) (save-buffer))
11511 (kill-buffer (current-buffer)))))))
11513 (defvar gnus-kill-file-name "KILL"
11514 "Suffix of the kill files.")
11516 (defun gnus-newsgroup-kill-file (newsgroup)
11517 "Return the name of a kill file name for NEWSGROUP.
11518 If NEWSGROUP is nil, return the global kill file name instead."
11519 (cond ((or (null newsgroup)
11520 (string-equal newsgroup ""))
11521 ;; The global KILL file is placed at top of the directory.
11522 (expand-file-name gnus-kill-file-name
11523 (or gnus-kill-files-directory "~/News")))
11524 ((gnus-use-long-file-name 'not-kill)
11525 ;; Append ".KILL" to newsgroup name.
11526 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
11527 "." gnus-kill-file-name)
11528 (or gnus-kill-files-directory "~/News")))
11530 ;; Place "KILL" under the hierarchical directory.
11531 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
11532 "/" gnus-kill-file-name)
11533 (or gnus-kill-files-directory "~/News")))))
11540 (defvar gnus-dribble-ignore nil)
11541 (defvar gnus-dribble-eval-file nil)
11543 (defun gnus-dribble-file-name ()
11544 (concat gnus-current-startup-file "-dribble"))
11546 (defun gnus-dribble-enter (string)
11547 (if (and (not gnus-dribble-ignore)
11548 gnus-dribble-buffer
11549 (buffer-name gnus-dribble-buffer))
11550 (let ((obuf (current-buffer)))
11551 (set-buffer gnus-dribble-buffer)
11552 (insert string "\n")
11553 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11554 (set-buffer obuf))))
11556 (defun gnus-dribble-read-file ()
11557 (let ((dribble-file (gnus-dribble-file-name)))
11559 (set-buffer (setq gnus-dribble-buffer
11561 (file-name-nondirectory dribble-file))))
11562 (gnus-add-current-to-buffer-list)
11564 (set-visited-file-name dribble-file)
11565 (buffer-disable-undo (current-buffer))
11566 (bury-buffer (current-buffer))
11567 (set-buffer-modified-p nil)
11568 (let ((auto (make-auto-save-file-name))
11569 (gnus-dribble-ignore t))
11570 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11572 (if (file-newer-than-file-p auto dribble-file)
11573 (setq dribble-file auto))
11574 (insert-file-contents dribble-file)
11575 (if (not (zerop (buffer-size)))
11576 (set-buffer-modified-p t))
11578 "Auto-save file exists. Do you want to read it? ")
11579 (setq gnus-dribble-eval-file t))))))))
11581 (defun gnus-dribble-eval-file ()
11582 (if (not gnus-dribble-eval-file)
11584 (setq gnus-dribble-eval-file nil)
11586 (let ((gnus-dribble-ignore t))
11587 (set-buffer gnus-dribble-buffer)
11588 (eval-buffer (current-buffer))))))
11590 (defun gnus-dribble-delete-file ()
11591 (if (file-exists-p (gnus-dribble-file-name))
11592 (delete-file (gnus-dribble-file-name)))
11593 (if gnus-dribble-buffer
11595 (set-buffer gnus-dribble-buffer)
11596 (let ((auto (make-auto-save-file-name)))
11597 (if (file-exists-p auto)
11598 (delete-file auto))
11600 (set-buffer-modified-p nil)))))
11602 (defun gnus-dribble-save ()
11603 (if (and gnus-dribble-buffer
11604 (buffer-name gnus-dribble-buffer))
11606 (set-buffer gnus-dribble-buffer)
11609 (defun gnus-dribble-clear ()
11611 (if (gnus-buffer-exists-p gnus-dribble-buffer)
11613 (set-buffer gnus-dribble-buffer)
11615 (set-buffer-modified-p nil)
11616 (setq buffer-saved-size (buffer-size))))))
11619 ;;; Server Communication
11622 ;; All the Gnus backends have the same interface, and should return
11623 ;; data in a similar format. Below is an overview of what functions
11624 ;; these packages must supply and what results they should return.
11628 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11631 ;; Functions for the imaginary backend `choke':
11633 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11634 ;; Should return all headers for all ARTICLES, or return NOV lines for
11637 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11638 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11639 ;; must be returned.
11641 ;; `choke-close-group GROUP &optional SERVER'
11642 ;; Close group. Most backends won't have to do anything with this
11643 ;; call, but it is an opportunity to clean up, if that is needed. It
11644 ;; is called when Gnus exits a group.
11646 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11647 ;; Return ARTICLE, which is either an article number or
11648 ;; message-id. Note that not all backends can return articles based on
11651 ;; `choke-request-list SERVER'
11652 ;; Return a list of all newsgroups on SERVER.
11654 ;; `choke-request-list-newsgroups SERVER'
11655 ;; Return a list of descriptions of all newsgroups on SERVER.
11657 ;; `choke-request-newgroups DATE &optional SERVER'
11658 ;; Return a list of all groups that have arrived after DATE on
11659 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11660 ;; always check whether the groups are old or not. Backends that do
11661 ;; not store date information may just return the entire list of
11662 ;; groups, although this might not be a good idea in general.
11664 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11665 ;; Should return a buffer that is suitable for "posting". nnspool and
11666 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11667 ;; buffer. This function should fill out the appropriate headers.
11669 ;; `choke-request-post &optional SERVER'
11670 ;; Function that will be called from a buffer to be posted.
11672 ;; `choke-open-server SERVER &optional ARGUMENT'
11673 ;; Open a connection to SERVER.
11675 ;; `choke-close-server &optional SERVER'
11676 ;; Close the connection to SERVER.
11678 ;; `choke-server-opened &optional SERVER'
11679 ;; Whether the conenction to SERVER is opened or not.
11681 ;; `choke-server-status &optional SERVER'
11682 ;; Should return a status string (not in the nntp buffer, but as the
11683 ;; result of the function).
11685 ;; `choke-retrieve-groups GROUPS &optional SERVER'
11686 ;; Optional function for retrieving active file info on all groups in
11687 ;; GROUPS. Two return formats are supported: The normal active file
11688 ;; format, and a list of GROUP lines. This function should return (as
11689 ;; a function value) either `active' or `group', depending on what
11690 ;; format it returns.
11692 ;; The following functions are optional and apply only to backends
11693 ;; that are able to control the contents of their groups totally
11694 ;; (ie. mail backends.) Backends that aren't able to do that
11695 ;; shouldn't define these functions at all. Gnus will check for their
11696 ;; presence before attempting to call them.
11698 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11699 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11700 ;; backends will not be able to expire articles. Should return a list
11701 ;; of all articles that were not expired.
11703 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11704 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11705 ;; Removes any information it has added to the article (extra headers,
11706 ;; whatever - make it as clean as possible), and then passes the
11707 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11708 ;; function described below. If the ACCEPT-FORM returns a non-nil
11709 ;; value, the article should then be deleted. If LAST is nil, that
11710 ;; means that there will be further calls to this function. This might
11711 ;; be taken as an advice not to save buffers/internal variables just
11712 ;; yet, but wait until the last call to speed things up.
11714 ;; `choke-request-accept-article GROUP &optional LAST'
11715 ;; The contents of the current buffer will be put into GROUP. There
11716 ;; should, of course, be an article in the current buffer. This
11717 ;; function is normally only called by the function described above,
11718 ;; and LAST works the same way as in that function.
11720 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11721 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11722 ;; This provides an easy interface for allowing editing of
11723 ;; articles. Note that even headers may be edited, so the backend has
11724 ;; to update any tables (nov buffers, etc) that it maintains after
11725 ;; replacing the article.
11727 ;; `choke-request-create-group GROUP &optional SERVER'
11728 ;; Create GROUP on SERVER. This might be a new, empty group, or it
11729 ;; might be a group that already exists, but hasn't been registered
11732 ;; All these functions must return nil if they couldn't service the
11733 ;; request. If the optional arguments are not supplied, some "current"
11734 ;; or "default" values should be used. In short, one should emulate an
11735 ;; NNTP server, in a way.
11737 ;; If you want to write a new backend, you just have to supply the
11738 ;; functions listed above. In addition, you must enter the new backend
11739 ;; into the list of valid select methods:
11740 ;; (setq gnus-valid-select-methods
11741 ;; (cons '("choke" mail) gnus-valid-select-methods))
11742 ;; The first element in this list is the name of the backend. Other
11743 ;; elemnets may be `mail' (for mail groups), `post' (for news
11744 ;; groups), `none' (neither), `respool' (for groups that can control
11745 ;; their contents).
11747 (defun gnus-start-news-server (&optional confirm)
11748 "Open a method for getting news.
11749 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11751 (if gnus-current-select-method
11752 ;; Stream is already opened.
11754 ;; Open NNTP server.
11755 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11758 ;; Read server name with completion.
11759 (setq gnus-nntp-server
11760 (completing-read "NNTP server: "
11761 (mapcar (lambda (server) (list server))
11762 (cons (list gnus-nntp-server)
11763 gnus-secondary-servers))
11764 nil nil gnus-nntp-server))))
11766 (if (and gnus-nntp-server
11767 (stringp gnus-nntp-server)
11768 (not (string= gnus-nntp-server "")))
11769 (setq gnus-select-method
11770 (cond ((or (string= gnus-nntp-server "")
11771 (string= gnus-nntp-server "::"))
11772 (list 'nnspool (system-name)))
11773 ((string-match "^:" gnus-nntp-server)
11774 (list 'nnmh gnus-nntp-server
11775 (list 'nnmh-directory
11776 (file-name-as-directory
11778 (concat "~/" (substring
11779 gnus-nntp-server 1)))))
11780 (list 'nnmh-get-new-mail nil)))
11782 (list 'nntp gnus-nntp-server)))))
11784 (setq how (car gnus-select-method))
11785 (cond ((eq how 'nnspool)
11787 (gnus-message 5 "Looking up local news spool..."))
11790 (gnus-message 5 "Looking up mh spool..."))
11793 (setq gnus-current-select-method gnus-select-method)
11794 (run-hooks 'gnus-open-server-hook)
11796 ;; gnus-open-server-hook might have opened it
11797 (gnus-server-opened gnus-select-method)
11798 (gnus-open-server gnus-select-method)
11801 "%s open error: '%s'. Continue? "
11802 (nth 1 gnus-select-method)
11803 (gnus-status-message gnus-select-method)))
11805 (gnus-message 1 "Couldn't open server on %s"
11806 (nth 1 gnus-select-method))
11810 (defun gnus-check-server (&optional method)
11811 "If the news server is down, start it up again."
11812 (let ((method (if method method gnus-select-method)))
11813 (and (stringp method)
11814 (setq method (gnus-server-to-method method)))
11815 (if (gnus-server-opened method)
11816 ;; Stream is already opened.
11819 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
11820 (run-hooks 'gnus-open-server-hook)
11822 (gnus-open-server method)
11825 (defun gnus-nntp-message (&optional message)
11826 "Check the status of the NNTP server.
11827 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11828 is returned insted of the status string."
11829 (let ((status (gnus-status-message (gnus-find-method-for-group
11830 gnus-newsgroup-name)))
11831 (message (or message "")))
11832 (if (and (stringp status) (> (length status) 0))
11835 (defun gnus-get-function (method function)
11836 (and (stringp method)
11837 (setq method (gnus-server-to-method method)))
11838 (let ((func (intern (format "%s-%s" (car method) function))))
11839 (if (not (fboundp func))
11841 (require (car method))
11842 (if (not (fboundp func))
11843 (error "No such function: %s" func))))
11846 ;;; Interface functions to the backends.
11848 (defun gnus-open-server (method)
11849 (funcall (gnus-get-function method 'open-server)
11850 (nth 1 method) (nthcdr 2 method)))
11852 (defun gnus-close-server (method)
11853 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11855 (defun gnus-request-list (method)
11856 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11858 (defun gnus-request-list-newsgroups (method)
11859 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11861 (defun gnus-request-newgroups (date method)
11862 (funcall (gnus-get-function method 'request-newgroups)
11863 date (nth 1 method)))
11865 (defun gnus-server-opened (method)
11866 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11868 (defun gnus-status-message (method)
11869 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11871 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11873 (defun gnus-request-group (group &optional dont-check)
11874 (let ((method (gnus-find-method-for-group group)))
11875 ; (and t (message "%s GROUP %s" (car method) group))
11876 (funcall (gnus-get-function method 'request-group)
11877 (gnus-group-real-name group) (nth 1 method) dont-check)))
11879 (defun gnus-request-asynchronous (group &optional articles)
11880 (let ((method (gnus-find-method-for-group group)))
11881 (funcall (gnus-get-function method 'request-asynchronous)
11882 (gnus-group-real-name group) (nth 1 method) articles)))
11884 (defun gnus-list-active-group (group)
11885 (let ((method (gnus-find-method-for-group group))
11886 (func 'list-active-group))
11887 (and (gnus-check-backend-function func group)
11888 (funcall (gnus-get-function method func)
11889 (gnus-group-real-name group) (nth 1 method)))))
11891 (defun gnus-request-group-description (group)
11892 (let ((method (gnus-find-method-for-group group))
11893 (func 'request-group-description))
11894 (and (gnus-check-backend-function func group)
11895 (funcall (gnus-get-function method func)
11896 (gnus-group-real-name group) (nth 1 method)))))
11898 (defun gnus-close-group (group)
11899 (let ((method (gnus-find-method-for-group group)))
11900 (funcall (gnus-get-function method 'close-group)
11901 (gnus-group-real-name group) (nth 1 method))))
11903 (defun gnus-retrieve-headers (articles group)
11904 (let ((method (gnus-find-method-for-group group)))
11905 (if (and gnus-use-cache (numberp (car articles)))
11906 (gnus-cache-retrieve-headers articles group)
11907 (funcall (gnus-get-function method 'retrieve-headers)
11908 articles (gnus-group-real-name group) (nth 1 method)))))
11910 (defun gnus-retrieve-groups (groups method)
11911 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
11913 (defun gnus-request-article (article group &optional buffer)
11914 (let ((method (gnus-find-method-for-group group)))
11915 (funcall (gnus-get-function method 'request-article)
11916 article (gnus-group-real-name group) (nth 1 method) buffer)))
11918 (defun gnus-request-head (article group)
11919 (let ((method (gnus-find-method-for-group group)))
11920 (funcall (gnus-get-function method 'request-head)
11921 article (gnus-group-real-name group) (nth 1 method))))
11923 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11924 (defun gnus-request-post-buffer (post group subject header artbuf
11925 info follow-to respect-poster)
11926 (let* ((info (or info (and group (nth 2 (gnus-gethash
11927 group gnus-newsrc-hashtb)))))
11929 (if (and gnus-post-method
11930 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11932 (format "%s" (car (gnus-find-method-for-group
11933 gnus-newsgroup-name)))
11934 gnus-valid-select-methods)))
11936 (gnus-find-method-for-group gnus-newsgroup-name))))
11937 (or (gnus-check-server method)
11938 (error "Can't open server %s:%s" (car method) (nth 1 method)))
11939 (let ((mail-self-blind nil)
11940 (mail-archive-file-name nil))
11941 (funcall (gnus-get-function method 'request-post-buffer)
11942 post group subject header artbuf info follow-to
11945 (defun gnus-request-post (method &optional force)
11946 (and (stringp method)
11947 (setq method (gnus-server-to-method method)))
11948 (and (not force) gnus-post-method
11949 (memq 'post (assoc (format "%s" (car method))
11950 gnus-valid-select-methods))
11951 (setq method gnus-post-method))
11952 (funcall (gnus-get-function method 'request-post)
11955 (defun gnus-request-expire-articles (articles group &optional force)
11956 (let ((method (gnus-find-method-for-group group)))
11957 (funcall (gnus-get-function method 'request-expire-articles)
11958 articles (gnus-group-real-name group) (nth 1 method)
11961 (defun gnus-request-move-article
11962 (article group server accept-function &optional last)
11963 (let ((method (gnus-find-method-for-group group)))
11964 (funcall (gnus-get-function method 'request-move-article)
11965 article (gnus-group-real-name group)
11966 (nth 1 method) accept-function last)))
11968 (defun gnus-request-accept-article (group &optional last)
11969 (let ((func (if (symbolp group) group
11970 (car (gnus-find-method-for-group group)))))
11971 (funcall (intern (format "%s-request-accept-article" func))
11972 (if (stringp group) (gnus-group-real-name group) group)
11975 (defun gnus-request-replace-article (article group buffer)
11976 (let ((func (car (gnus-find-method-for-group group))))
11977 (funcall (intern (format "%s-request-replace-article" func))
11978 article (gnus-group-real-name group) buffer)))
11980 (defun gnus-request-create-group (group)
11981 (let ((method (gnus-find-method-for-group group)))
11982 (funcall (gnus-get-function method 'request-create-group)
11983 (gnus-group-real-name group) (nth 1 method))))
11985 (defun gnus-member-of-valid (symbol group)
11986 (memq symbol (assoc
11987 (format "%s" (car (gnus-find-method-for-group group)))
11988 gnus-valid-select-methods)))
11990 (defun gnus-secondary-method-p (method)
11991 (let ((methods gnus-secondary-select-methods)
11992 (gmethod (gnus-server-get-method nil method)))
11993 (while (and methods
11994 (not (equal (gnus-server-get-method nil (car methods))
11996 (setq methods (cdr methods)))
11999 (defun gnus-find-method-for-group (group &optional info)
12000 (or gnus-override-method
12002 gnus-select-method)
12003 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
12006 (not (setq method (nth 4 info))))
12007 (setq method gnus-select-method)
12009 (cond ((stringp method)
12010 (gnus-server-to-method method))
12011 ((stringp (car method))
12012 (gnus-server-extend-method group method))
12015 (gnus-server-add-address method))))
12017 (defun gnus-check-backend-function (func group)
12018 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12020 (fboundp (intern (format "%s-%s" method func)))))
12022 (defun gnus-methods-using (method)
12023 (let ((valids gnus-valid-select-methods)
12026 (if (memq method (car valids))
12027 (setq outs (cons (car valids) outs)))
12028 (setq valids (cdr valids)))
12032 ;;; Active & Newsrc File Handling
12035 ;; Newsrc related functions.
12036 ;; Gnus internal format of gnus-newsrc-alist:
12037 ;; (("alt.general" 3 (1 . 1))
12038 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12039 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12040 ;; The first item is the group name; the second is the subscription
12041 ;; level; the third is either a range of a list of ranges of read
12042 ;; articles, the optional fourth element is a list of marked articles,
12043 ;; the optional fifth element is the select method.
12045 ;; Gnus internal format of gnus-newsrc-hashtb:
12046 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12047 ;; This is the entry for "alt.misc". The first element is the number
12048 ;; of unread articles in "alt.misc". The cdr of this entry is the
12049 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
12050 ;; trivial to remove or add new elements into gnus-newsrc-alist
12051 ;; without scanning the entire list. So, to get the actual information
12052 ;; of "alt.misc", you'd say something like
12053 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12055 ;; Gnus internal format of gnus-active-hashtb:
12059 ;; The only element in each entry in this hash table is a range of
12060 ;; (possibly) available articles. (Articles in this range may have
12061 ;; been expired or canceled.)
12063 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12064 ;; ("alt.misc" "alt.test" "alt.general" ...)
12066 (defun gnus-setup-news (&optional rawfile level)
12067 "Setup news information.
12068 If RAWFILE is non-nil, the .newsrc file will also be read.
12069 If LEVEL is non-nil, the news will be set up at level LEVEL."
12070 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
12071 ;; Clear some variables to re-initialize news information.
12072 (if init (setq gnus-newsrc-alist nil
12073 gnus-active-hashtb nil))
12075 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12076 (if init (gnus-read-newsrc-file rawfile))
12078 ;; If we don't read the complete active file, we fill in the
12080 (if (or (null gnus-read-active-file)
12081 (eq gnus-read-active-file 'some))
12082 (gnus-update-active-hashtb-from-killed))
12084 ;; Read the active file and create `gnus-active-hashtb'.
12085 ;; If `gnus-read-active-file' is nil, then we just create an empty
12086 ;; hash table. The partial filling out of the hash table will be
12087 ;; done in `gnus-get-unread-articles'.
12088 (and gnus-read-active-file
12090 (gnus-read-active-file))
12092 (or gnus-active-hashtb
12093 (setq gnus-active-hashtb (make-vector 4095 0)))
12095 ;; Possibly eval the dribble file.
12096 (and init gnus-use-dribble-file (gnus-dribble-eval-file))
12098 (gnus-update-format-specifications)
12100 ;; Find the number of unread articles in each non-dead group.
12101 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
12102 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
12103 ;; Find new newsgroups and treat them.
12104 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12105 (gnus-server-opened gnus-select-method))
12106 (gnus-find-new-newsgroups))
12107 (if (and init gnus-check-bogus-newsgroups
12108 gnus-read-active-file (not level)
12109 (gnus-server-opened gnus-select-method))
12110 (gnus-check-bogus-newsgroups))))
12112 (defun gnus-find-new-newsgroups ()
12113 "Search for new newsgroups and add them.
12114 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12115 The `-n' option line from .newsrc is respected."
12117 (or (gnus-check-first-time-used)
12118 (if (or (consp gnus-check-new-newsgroups)
12119 (eq gnus-check-new-newsgroups 'ask-server))
12120 (gnus-ask-server-for-new-groups)
12122 group new-newsgroups)
12123 (gnus-message 5 "Checking for new newsgroups...")
12124 (or gnus-have-read-active-file (gnus-read-active-file))
12125 (setq gnus-newsrc-last-checked-date (current-time-string))
12126 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12127 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12128 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12131 (if (or (null (setq group (symbol-name sym)))
12132 (null (symbol-value sym))
12133 (gnus-gethash group gnus-killed-hashtb)
12134 (gnus-gethash group gnus-newsrc-hashtb))
12136 (let ((do-sub (gnus-matches-options-n group)))
12138 ((eq do-sub 'subscribe)
12139 (setq groups (1+ groups))
12140 (gnus-sethash group group gnus-killed-hashtb)
12141 (funcall gnus-subscribe-options-newsgroup-method group))
12142 ((eq do-sub 'ignore)
12145 (setq groups (1+ groups))
12146 (gnus-sethash group group gnus-killed-hashtb)
12147 (if gnus-subscribe-hierarchical-interactive
12148 (setq new-newsgroups (cons group new-newsgroups))
12149 (funcall gnus-subscribe-newsgroup-method group)))))))
12150 gnus-active-hashtb)
12152 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12153 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12155 (gnus-message 6 "%d new newsgroup%s arrived."
12156 groups (if (> groups 1) "s have" " has"))
12157 (gnus-message 6 "No new newsgroups."))))))
12159 (defun gnus-matches-options-n (group)
12160 ;; Returns `subscribe' if the group is to be uncoditionally
12161 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12162 ;; no match for the group.
12164 ;; First we check the two user variables.
12166 ((and gnus-options-subscribe
12167 (string-match gnus-options-subscribe group))
12169 ((and gnus-options-not-subscribe
12170 (string-match gnus-options-not-subscribe group))
12172 ;; Then we go through the list that was retrieved from the .newsrc
12173 ;; file. This list has elements on the form
12174 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12175 ;; is in the reverse order of the options line) is returned.
12177 (let ((regs gnus-newsrc-options-n))
12179 (not (string-match (car (car regs)) group)))
12180 (setq regs (cdr regs)))
12181 (and regs (cdr (car regs)))))))
12183 (defun gnus-ask-server-for-new-groups ()
12184 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12185 (methods (cons gnus-select-method
12187 (and (consp gnus-check-new-newsgroups)
12188 gnus-check-new-newsgroups)
12189 gnus-secondary-select-methods)))
12191 (new-date (current-time-string))
12192 (hashtb (gnus-make-hashtable 100))
12193 group new-newsgroups got-new method)
12194 ;; Go through both primary and secondary select methods and
12195 ;; request new newsgroups.
12197 (setq method (gnus-server-get-method nil (car methods)))
12198 (and (gnus-check-server method)
12199 (gnus-request-newgroups date method)
12202 (set-buffer nntp-server-buffer)
12203 ;; Enter all the new groups in a hashtable.
12204 (gnus-active-to-gnus-format method hashtb 'ignore)))
12205 (setq methods (cdr methods)))
12206 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12207 ;; Now all new groups from all select methods are in `hashtb'.
12209 (lambda (group-sym)
12210 (setq group (symbol-name group-sym))
12211 (if (or (null group)
12212 (null (symbol-value group-sym))
12213 (gnus-gethash group gnus-newsrc-hashtb)
12214 (member group gnus-zombie-list)
12215 (member group gnus-killed-list))
12216 ;; The group is already known.
12218 (and (symbol-value group-sym)
12219 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb))
12220 (let ((do-sub (gnus-matches-options-n group)))
12221 (cond ((eq do-sub 'subscribe)
12222 (setq groups (1+ groups))
12223 (gnus-sethash group group gnus-killed-hashtb)
12225 gnus-subscribe-options-newsgroup-method group))
12226 ((eq do-sub 'ignore)
12229 (setq groups (1+ groups))
12230 (gnus-sethash group group gnus-killed-hashtb)
12231 (if gnus-subscribe-hierarchical-interactive
12232 (setq new-newsgroups (cons group new-newsgroups))
12233 (funcall gnus-subscribe-newsgroup-method group)))))))
12236 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12237 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12239 (gnus-message 6 "%d new newsgroup%s arrived."
12240 groups (if (> groups 1) "s have" " has")))
12243 (defun gnus-check-first-time-used ()
12244 (if (or (> (length gnus-newsrc-alist) 1)
12245 (file-exists-p gnus-startup-file)
12246 (file-exists-p (concat gnus-startup-file ".el"))
12247 (file-exists-p (concat gnus-startup-file ".eld")))
12249 (gnus-message 6 "First time user; subscribing you to default groups")
12250 (or gnus-have-read-active-file (gnus-read-active-file))
12251 (setq gnus-newsrc-last-checked-date (current-time-string))
12252 (let ((groups gnus-default-subscribed-newsgroups)
12256 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12259 (if (null (setq group (symbol-name sym)))
12261 (let ((do-sub (gnus-matches-options-n group)))
12263 ((eq do-sub 'subscribe)
12264 (gnus-sethash group group gnus-killed-hashtb)
12265 (funcall gnus-subscribe-options-newsgroup-method group))
12266 ((eq do-sub 'ignore)
12269 (setq gnus-killed-list (cons group gnus-killed-list)))))))
12270 gnus-active-hashtb)
12272 (if (gnus-gethash (car groups) gnus-active-hashtb)
12273 (gnus-group-change-level
12274 (car groups) gnus-level-default-subscribed gnus-level-killed))
12275 (setq groups (cdr groups)))
12276 (gnus-group-make-help-group)
12277 (and gnus-novice-user
12278 (gnus-message 7 "`A k' to list killed groups"))))))
12280 (defun gnus-subscribe-group (group previous &optional method)
12281 (gnus-group-change-level
12283 (list t group gnus-level-default-subscribed nil nil method)
12285 gnus-level-default-subscribed gnus-level-killed previous t))
12287 ;; `gnus-group-change-level' is the fundamental function for changing
12288 ;; subscription levels of newsgroups. This might mean just changing
12289 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12290 ;; again, which subscribes/unsubscribes a group, which is equally
12291 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12292 ;; from 8-9 to 1-7 means that you remove the group from the list of
12293 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12294 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12295 ;; which is trivial.
12296 ;; ENTRY can either be a string (newsgroup name) or a list (if
12297 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12298 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12300 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12301 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12303 (defun gnus-group-change-level (entry level &optional oldlevel
12304 previous fromkilled)
12305 (let (group info active num)
12306 ;; Glean what info we can from the arguments
12308 (if fromkilled (setq group (nth 1 entry))
12309 (setq group (car (nth 2 entry))))
12310 (setq group entry))
12311 (if (and (stringp entry)
12313 (< oldlevel gnus-level-zombie))
12314 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12315 (if (and (not oldlevel)
12317 (setq oldlevel (car (cdr (nth 2 entry)))))
12318 (if (stringp previous)
12319 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12321 (if (and (>= oldlevel gnus-level-zombie)
12322 (gnus-gethash group gnus-newsrc-hashtb))
12323 ;; We are trying to subscribe a group that is already
12327 (gnus-dribble-enter
12328 (format "(gnus-group-change-level %S %S %S %S %S)"
12329 group level oldlevel (car (nth 2 previous)) fromkilled))
12331 ;; Then we remove the newgroup from any old structures, if needed.
12332 ;; If the group was killed, we remove it from the killed or zombie
12333 ;; list. If not, and it is in fact going to be killed, we remove
12334 ;; it from the newsrc hash table and assoc.
12335 (cond ((>= oldlevel gnus-level-zombie)
12336 (if (= oldlevel gnus-level-zombie)
12337 (setq gnus-zombie-list (delete group gnus-zombie-list))
12338 (setq gnus-killed-list (delete group gnus-killed-list))))
12340 (if (and (>= level gnus-level-zombie)
12343 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
12345 (setcdr (gnus-gethash (car (nth 3 entry))
12346 gnus-newsrc-hashtb)
12348 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12350 ;; Finally we enter (if needed) the list where it is supposed to
12351 ;; go, and change the subscription level. If it is to be killed,
12352 ;; we enter it into the killed or zombie list.
12353 (cond ((>= level gnus-level-zombie)
12354 ;; Remove from the hash table.
12355 (gnus-sethash group nil gnus-newsrc-hashtb)
12356 (or (gnus-group-foreign-p group)
12357 ;; We do not enter foreign groups into the list of dead
12359 (if (= level gnus-level-zombie)
12360 (setq gnus-zombie-list (cons group gnus-zombie-list))
12361 (setq gnus-killed-list (cons group gnus-killed-list)))))
12363 ;; If the list is to be entered into the newsrc assoc, and
12364 ;; it was killed, we have to create an entry in the newsrc
12365 ;; hashtb format and fix the pointers in the newsrc assoc.
12366 (if (>= oldlevel gnus-level-zombie)
12370 (setq info (cdr entry))
12371 (setq num (car entry)))
12372 (setq active (gnus-gethash group gnus-active-hashtb))
12374 (if active (- (1+ (cdr active)) (car active)) t))
12375 ;; Check whether the group is foreign. If so, the
12376 ;; foreign select method has to be entered into the
12378 (let ((method (gnus-group-method-name group)))
12379 (if (eq method gnus-select-method)
12380 (setq info (list group level nil))
12381 (setq info (list group level nil nil method)))))
12384 (let ((p gnus-newsrc-alist))
12385 (while (cdr (cdr p))
12388 (setq entry (cons info (cdr (cdr previous))))
12391 (setcdr (cdr previous) entry)
12392 (gnus-sethash group (cons num (cdr previous))
12393 gnus-newsrc-hashtb))
12394 (setcdr previous entry)
12395 (gnus-sethash group (cons num previous)
12396 gnus-newsrc-hashtb))
12398 (setcdr (gnus-gethash (car (car (cdr entry)))
12399 gnus-newsrc-hashtb)
12401 ;; It was alive, and it is going to stay alive, so we
12402 ;; just change the level and don't change any pointers or
12403 ;; hash table entries.
12404 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
12406 (defun gnus-kill-newsgroup (newsgroup)
12407 "Obsolete function. Kills a newsgroup."
12408 (gnus-group-change-level
12409 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
12411 (defun gnus-check-bogus-newsgroups (&optional confirm)
12412 "Remove bogus newsgroups.
12413 If CONFIRM is non-nil, the user has to confirm the deletion of every
12415 (let ((newsrc (cdr gnus-newsrc-alist))
12417 (gnus-message 5 "Checking bogus newsgroups...")
12418 (or gnus-have-read-active-file (gnus-read-active-file))
12419 ;; Find all bogus newsgroup that are subscribed.
12421 (setq group (car (car newsrc)))
12422 (if (or (gnus-gethash group gnus-active-hashtb) ; Active
12423 (nth 4 (car newsrc)) ; Foreign
12425 (not (gnus-y-or-n-p
12426 (format "Remove bogus newsgroup: %s " group)))))
12429 ;; Found a bogus newsgroup.
12430 (setq bogus (cons group bogus)))
12431 (setq newsrc (cdr newsrc)))
12432 ;; Remove all bogus subscribed groups by first killing them, and
12433 ;; then removing them from the list of killed groups.
12435 (and (setq entry (gnus-gethash (car bogus) gnus-newsrc-hashtb))
12437 (gnus-group-change-level entry gnus-level-killed)
12438 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))))
12439 (setq bogus (cdr bogus)))
12440 ;; Then we remove all bogus groups from the list of killed and
12441 ;; zombie groups. They are are removed without confirmation.
12442 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12445 (setq killed (symbol-value (car dead-lists)))
12447 (setq group (car killed))
12448 (or (gnus-gethash group gnus-active-hashtb)
12449 ;; The group is bogus.
12450 (set (car dead-lists)
12451 (delete group (symbol-value (car dead-lists)))))
12452 (setq killed (cdr killed)))
12453 (setq dead-lists (cdr dead-lists))))
12454 (gnus-message 5 "Checking bogus newsgroups...done")))
12456 (defun gnus-check-duplicate-killed-groups ()
12457 "Remove duplicates from the list of killed groups."
12459 (let ((killed gnus-killed-list))
12461 (gnus-message 9 "%d" (length killed))
12462 (setcdr killed (delete (car killed) (cdr killed)))
12463 (setq killed (cdr killed)))))
12465 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
12466 ;; and compute how many unread articles there are in each group.
12467 (defun gnus-get-unread-articles (&optional level)
12468 (let* ((newsrc (cdr gnus-newsrc-alist))
12469 (level (or level (1+ gnus-level-subscribed)))
12472 (cond ((and gnus-activate-foreign-newsgroups
12473 (not (numberp gnus-activate-foreign-newsgroups)))
12474 (1+ gnus-level-subscribed))
12475 ((numberp gnus-activate-foreign-newsgroups)
12476 gnus-activate-foreign-newsgroups)
12479 info group active virtuals method)
12480 (gnus-message 5 "Checking new news...")
12483 (setq info (car newsrc)
12485 active (gnus-gethash group gnus-active-hashtb))
12487 ;; Check newsgroups. If the user doesn't want to check them, or
12488 ;; they can't be checked (for instance, if the news server can't
12489 ;; be reached) we just set the number of unread articles in this
12490 ;; newsgroup to t. This means that Gnus thinks that there are
12491 ;; unread articles, but it has no idea how many.
12492 (if (and (setq method (nth 4 info))
12493 (not (gnus-server-equal gnus-select-method
12494 (gnus-server-get-method nil method)))
12495 (not (gnus-secondary-method-p method)))
12496 ;; These groups are foreign. Check the level.
12497 (if (<= (nth 1 info) foreign-level)
12498 (if (eq (car (if (stringp method)
12499 (gnus-server-to-method method)
12500 (nth 4 info))) 'nnvirtual)
12501 ;; We have to activate the virtual groups after all
12502 ;; the others, so we just pop them on a list for
12504 (setq virtuals (cons info virtuals))
12505 (and (setq active (gnus-activate-group (car info)))
12506 ;; Close the groups as we look at them!
12507 (gnus-close-group group))))
12509 ;; These groups are native or secondary.
12510 (if (and (not gnus-read-active-file)
12511 (<= (nth 1 info) level))
12513 (or gnus-read-active-file (gnus-check-server method))
12514 (setq active (gnus-activate-group (car info))))))
12517 (gnus-get-unread-articles-in-group info active)
12518 ;; The group couldn't be reached, so we nix out the number of
12519 ;; unread articles and stuff.
12520 (gnus-sethash group nil gnus-active-hashtb)
12521 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
12523 (setq newsrc (cdr newsrc)))
12525 ;; Activate the virtual groups. This has to be done after all the
12527 ;; !!! If one virtual group contains another virtual group, even
12528 ;; doing it this way might cause problems.
12530 (and (setq active (gnus-activate-group (car (car virtuals))))
12531 (gnus-get-unread-articles-in-group (car virtuals) active))
12532 (setq virtuals (cdr virtuals)))
12534 (gnus-message 5 "Checking new news...done")))
12536 ;; Create a hash table out of the newsrc alist. The `car's of the
12537 ;; alist elements are used as keys.
12538 (defun gnus-make-hashtable-from-newsrc-alist ()
12539 (let ((alist gnus-newsrc-alist)
12540 (ohashtb gnus-newsrc-hashtb)
12542 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12544 (setq prev (setq gnus-newsrc-alist
12545 (if (equal (car (car gnus-newsrc-alist))
12548 (cons (list "dummy.group" 0 nil) alist)))))
12550 (gnus-sethash (car (car alist))
12551 (cons (and ohashtb (car (gnus-gethash
12552 (car (car alist)) ohashtb)))
12553 prev) gnus-newsrc-hashtb)
12555 alist (cdr alist)))))
12557 (defun gnus-make-hashtable-from-killed ()
12558 "Create a hash table from the killed and zombie lists."
12559 (let ((lists '(gnus-killed-list gnus-zombie-list))
12561 (setq gnus-killed-hashtb
12562 (gnus-make-hashtable
12563 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12565 (setq list (symbol-value (car lists)))
12566 (setq lists (cdr lists))
12568 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12569 (setq list (cdr list))))))
12571 (defun gnus-get-unread-articles-in-group (info active)
12572 (let* ((range (nth 2 info))
12574 (marked (nth 3 info)))
12575 ;; If a cache is present, we may have to alter the active info.
12576 (and gnus-use-cache
12577 (gnus-cache-possibly-alter-active (car info) active))
12578 ;; Modify the list of read articles according to what articles
12579 ;; are available; then tally the unread articles and add the
12580 ;; number to the group hash table entry.
12582 ((zerop (cdr active))
12585 (setq num (- (1+ (cdr active)) (car active))))
12586 ((not (listp (cdr range)))
12587 ;; Fix a single (num . num) range according to the
12588 ;; active hash table.
12589 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12590 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12591 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12592 ;; Compute number of unread articles.
12593 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
12595 ;; The read list is a list of ranges. Fix them according to
12596 ;; the active hash table.
12597 ;; First peel off any elements that are below the lower
12599 (while (and (cdr range)
12601 (or (and (atom (car (cdr range))) (car (cdr range)))
12602 (car (car (cdr range))))))
12603 (if (numberp (car range))
12606 (or (and (numberp (car (cdr range)))
12608 (cdr (car (cdr range))))))
12609 (setcdr (car range)
12610 (or (and (numberp (nth 1 range)) (nth 1 range))
12611 (cdr (car (cdr range))))))
12612 (setcdr range (cdr (cdr range))))
12613 ;; Adjust the first element to be the same as the lower limit.
12614 (if (and (not (atom (car range)))
12615 (< (cdr (car range)) (car active)))
12616 (setcdr (car range) (1- (car active))))
12617 ;; Then we want to peel off any elements that are higher
12618 ;; than the upper active limit.
12619 (let ((srange range))
12620 ;; Go past all legal elements.
12621 (while (and (cdr srange)
12622 (<= (or (and (atom (car (cdr srange)))
12623 (car (cdr srange)))
12624 (car (car (cdr srange)))) (cdr active)))
12625 (setq srange (cdr srange)))
12627 ;; Nuke all remaining illegal elements.
12628 (setcdr srange nil))
12630 ;; Adjust the final element.
12631 (if (and (not (atom (car srange)))
12632 (> (cdr (car srange)) (cdr active)))
12633 (setcdr (car srange) (cdr active))))
12634 ;; Compute the number of unread articles.
12636 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12637 (cdr (car range))))
12638 (or (and (atom (car range)) (car range))
12639 (car (car range))))))
12640 (setq range (cdr range)))
12641 (setq num (max 0 (- (cdr active) num)))))
12644 (and (assq 'tick marked)
12645 (inline (gnus-remove-illegal-marked-articles
12646 (assq 'tick marked) (nth 2 info))))
12647 (and (assq 'dormant marked)
12648 (inline (gnus-remove-illegal-marked-articles
12649 (assq 'dormant marked) (nth 2 info))))
12651 (gnus-gethash (car info) gnus-newsrc-hashtb)
12652 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12653 (length (cdr (assq 'dormant marked)))))))))
12656 (defun gnus-remove-illegal-marked-articles (marked ranges)
12657 (let ((m (cdr marked)))
12658 ;; Make sure that all ticked articles are a subset of the unread
12661 (if (gnus-member-of-range (car m) ranges)
12662 (setcdr marked (cdr m))
12664 (setq m (cdr m)))))
12666 (defun gnus-activate-group (group)
12667 ;; Check whether a group has been activated or not.
12668 (let ((method (gnus-find-method-for-group group))
12670 (and (gnus-check-server method)
12671 ;; We escape all bugs and quits here to make it possible to
12672 ;; continue if a group is so out-there that it reports bugs
12675 (gnus-request-group group)
12679 (set-buffer nntp-server-buffer)
12680 (goto-char (point-min))
12681 ;; Parse the result we got from `gnus-request-group'.
12682 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12684 (goto-char (match-beginning 1))
12686 group (setq active (cons (read (current-buffer))
12687 (read (current-buffer))))
12688 gnus-active-hashtb))
12689 ;; Return the new active info.
12692 (defun gnus-update-read-articles
12693 (group unread unselected ticked &optional domarks replied expirable killed
12694 dormant bookmark score)
12695 "Update the list of read and ticked articles in GROUP using the
12696 UNREAD and TICKED lists.
12697 Note: UNSELECTED has to be sorted over `<'.
12698 Returns whether the updating was successful."
12699 (let* ((active (or gnus-newsgroup-active
12700 (gnus-gethash group gnus-active-hashtb)))
12701 (entry (gnus-gethash group gnus-newsrc-hashtb))
12702 (info (nth 2 entry))
12703 (marked (nth 3 info))
12705 (unread (sort (copy-sequence unread) (function <)))
12707 (if (or (not info) (not active))
12708 ;; There is no info on this group if it was, in fact,
12709 ;; killed. Gnus stores no information on killed groups, so
12710 ;; there's nothing to be done.
12711 ;; One could store the information somewhere temporarily,
12712 ;; perhaps... Hmmm...
12714 ;; Remove any negative articles numbers.
12715 (while (and unread (< (car unread) 0))
12716 (setq unread (cdr unread)))
12717 ;; Remove any expired article numbers
12718 (while (and unread (< (car unread) (car active)))
12719 (setq unread (cdr unread)))
12720 (while (and ticked (< (car ticked) (car active)))
12721 (setq ticked (cdr ticked)))
12722 (while (and dormant (< (car dormant) (car active)))
12723 (setq dormant (cdr dormant)))
12724 (setq unread (sort (append unselected unread) '<))
12725 ;; Compute the ranges of read articles by looking at the list of
12726 ;; unread articles.
12728 (if (/= (car unread) prev)
12729 (setq read (cons (if (= prev (1- (car unread))) prev
12730 (cons prev (1- (car unread)))) read)))
12731 (setq prev (1+ (car unread)))
12732 (setq unread (cdr unread)))
12733 (if (<= prev (cdr active))
12734 (setq read (cons (cons prev (cdr active)) read)))
12735 ;; Enter this list into the group info.
12736 (setcar (cdr (cdr info))
12737 (if (> (length read) 1) (nreverse read) read))
12738 ;; Enter the list of ticked articles.
12739 (gnus-set-marked-articles
12741 (if domarks replied (cdr (assq 'reply marked)))
12742 (if domarks expirable (cdr (assq 'expire marked)))
12743 (if domarks killed (cdr (assq 'killed marked)))
12744 (if domarks dormant (cdr (assq 'dormant marked)))
12745 (if domarks bookmark (cdr (assq 'bookmark marked)))
12746 (if domarks score (cdr (assq 'score marked))))
12747 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12748 (gnus-get-unread-articles-in-group
12749 info (gnus-gethash group gnus-active-hashtb))
12752 (defun gnus-make-articles-unread (group articles)
12753 "Mark ARTICLES in GROUP as unread."
12754 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12755 (gnus-gethash (gnus-group-real-name group)
12756 gnus-newsrc-hashtb))))
12757 (ranges (nth 2 info))
12760 (and (gnus-member-of-range (car articles) ranges)
12761 (setq news (cons (car articles) news)))
12762 (setq articles (cdr articles)))
12765 (setcar (nthcdr 2 info)
12766 (gnus-remove-from-range (nth 2 info) (nreverse news)))
12767 (gnus-group-update-group group t))))
12769 ;; Enter all dead groups into the hashtb.
12770 (defun gnus-update-active-hashtb-from-killed ()
12771 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
12772 (lists (list gnus-killed-list gnus-zombie-list))
12775 (setq killed (car lists))
12777 (gnus-sethash (car killed) nil hashtb)
12778 (setq killed (cdr killed)))
12779 (setq lists (cdr lists)))))
12781 ;; Get the active file(s) from the backend(s).
12782 (defun gnus-read-active-file ()
12783 (gnus-group-set-mode-line)
12784 (let ((methods (if (gnus-check-server gnus-select-method)
12785 ;; The native server is available.
12786 (cons gnus-select-method gnus-secondary-select-methods)
12787 ;; The native server is down, so we just do the
12789 gnus-secondary-select-methods))
12791 (setq gnus-have-read-active-file nil)
12793 (set-buffer nntp-server-buffer)
12795 (let* ((method (gnus-server-get-method nil (car methods)))
12796 (where (nth 1 method))
12797 (mesg (format "Reading active file%s via %s..."
12798 (if (and where (not (zerop (length where))))
12799 (concat " from " where) "")
12801 (gnus-message 5 mesg)
12802 (if (not (gnus-check-server method))
12805 ((and (eq gnus-read-active-file 'some)
12806 (gnus-check-backend-function 'retrieve-groups (car method)))
12807 (let ((newsrc (cdr gnus-newsrc-alist))
12808 (gmethod (gnus-server-get-method nil method))
12811 (and (gnus-server-equal
12812 (gnus-find-method-for-group
12813 (car (car newsrc)) (car newsrc))
12815 (setq groups (cons (gnus-group-real-name
12816 (car (car newsrc))) groups)))
12817 (setq newsrc (cdr newsrc)))
12818 (gnus-check-server method)
12819 (setq list-type (gnus-retrieve-groups groups method))
12820 (cond ((not list-type)
12822 1 "Cannot read partial active file from %s server."
12826 ((eq list-type 'active)
12827 (gnus-active-to-gnus-format method gnus-active-hashtb))
12829 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
12831 (if (not (gnus-request-list method))
12833 (gnus-message 1 "Cannot read active file from %s server."
12836 (gnus-active-to-gnus-format method)
12837 ;; We mark this active file as read.
12838 (setq gnus-have-read-active-file
12839 (cons method gnus-have-read-active-file))
12840 (gnus-message 5 "%sdone" mesg))))))
12841 (setq methods (cdr methods))))))
12843 ;; Read an active file and place the results in `gnus-active-hashtb'.
12844 (defun gnus-active-to-gnus-format (method &optional hashtb ignore-errors)
12845 (let ((cur (current-buffer))
12847 (if (and gnus-active-hashtb
12848 (not (equal method gnus-select-method)))
12850 (setq gnus-active-hashtb
12851 (if (equal method gnus-select-method)
12852 (gnus-make-hashtable
12853 (count-lines (point-min) (point-max)))
12854 (gnus-make-hashtable 4096))))))
12855 (flag-hashtb (gnus-make-hashtable 60)))
12856 ;; Delete unnecessary lines.
12857 (goto-char (point-min))
12858 (while (search-forward "\nto." nil t)
12859 (delete-region (1+ (match-beginning 0))
12860 (progn (forward-line 1) (point))))
12861 (or (string= gnus-ignored-newsgroups "")
12863 (goto-char (point-min))
12864 (delete-matching-lines gnus-ignored-newsgroups)))
12865 ;; Make the group names readable as a lisp expression even if they
12866 ;; contain special characters.
12867 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
12868 (goto-char (point-max))
12869 (while (re-search-backward "[][';?()#]" nil t)
12871 ;; If these are groups from a foreign select method, we insert the
12872 ;; group prefix in front of the group names.
12873 (and method (not (gnus-server-equal
12874 (gnus-server-get-method nil method)
12875 (gnus-server-get-method nil gnus-select-method)))
12876 (let ((prefix (gnus-group-prefixed-name "" method)))
12877 (goto-char (point-min))
12878 (while (and (not (eobp))
12879 (progn (insert prefix)
12880 (zerop (forward-line 1)))))))
12881 ;; Store the active file in a hash table.
12882 (goto-char (point-min))
12883 (if (string-match "%[oO]" gnus-group-line-format)
12884 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12885 ;; If we want information on moderated groups, we use this
12887 (let* ((mod-hashtb (make-vector 7 0))
12888 (m (intern "m" mod-hashtb))
12890 (while (not (eobp))
12891 (condition-case nil
12893 (narrow-to-region (point) (gnus-point-at-eol))
12894 (setq group (let ((obarray hashtb)) (read cur)))
12895 (if (and (numberp (setq max (read cur)))
12896 (numberp (setq min (read cur)))
12898 (skip-chars-forward " \t")
12900 (or (= (following-char) ?=)
12901 (= (following-char) ?x)
12902 (= (following-char) ?j)))))
12903 (set group (cons min max))
12905 ;; Enter moderated groups into a list.
12906 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
12907 (setq gnus-moderated-list
12908 (cons (symbol-name group) gnus-moderated-list))))
12915 ;; And if we do not care about moderation, we use this loop,
12916 ;; which is faster.
12917 (let (group max min)
12918 (while (not (eobp))
12921 (narrow-to-region (point) (gnus-point-at-eol))
12922 ;; group gets set to a symbol interned in the hash table
12923 ;; (what a hack!!) - jwz
12924 (setq group (let ((obarray hashtb)) (read cur)))
12925 (if (and (numberp (setq max (read cur)))
12926 (numberp (setq min (read cur)))
12928 (skip-chars-forward " \t")
12930 (or (= (following-char) ?=)
12931 (= (following-char) ?x)
12932 (= (following-char) ?j)))))
12933 (set group (cons min max))
12941 (gnus-message 3 "Warning - illegal active: %s"
12943 (gnus-point-at-bol) (gnus-point-at-eol)))))))
12945 (forward-line 1))))))
12947 (defun gnus-groups-to-gnus-format (method &optional hashtb)
12948 ;; Parse a "groups" active file.
12949 (let ((cur (current-buffer))
12951 (if (and method gnus-active-hashtb)
12953 (setq gnus-active-hashtb
12954 (gnus-make-hashtable
12955 (count-lines (point-min) (point-max)))))))
12956 (prefix (and method
12957 (not (gnus-server-equal
12958 (gnus-server-get-method nil method)
12959 (gnus-server-get-method nil gnus-select-method)))
12960 (gnus-group-prefixed-name "" method))))
12962 (goto-char (point-min))
12963 ;; We split this into to separate loops, one with the prefix
12964 ;; and one without to speed the reading up somewhat.
12966 (let (min max opoint group)
12967 (while (not (eobp))
12970 (read cur) (read cur)
12971 (setq min (read cur)
12974 (skip-chars-forward " \t")
12977 (set (let ((obarray hashtb)) (read cur))
12979 (error (and group (symbolp group) (set group nil))))
12981 (let (min max group)
12982 (while (not (eobp))
12984 (if (= (following-char) ?2)
12986 (read cur) (read cur)
12987 (setq min (read cur)
12989 (set (setq group (let ((obarray hashtb)) (read cur)))
12991 (error (and group (symbolp group) (set group nil))))
12992 (forward-line 1))))))
12994 (defun gnus-read-newsrc-file (&optional force)
12995 "Read startup file.
12996 If FORCE is non-nil, the .newsrc file is read."
12997 ;; Reset variables that might be defined in the .newsrc.eld file.
12998 (let ((variables gnus-variable-list))
13000 (set (car variables) nil)
13001 (setq variables (cdr variables))))
13002 (let* ((newsrc-file gnus-current-startup-file)
13003 (quick-file (concat newsrc-file ".el")))
13005 ;; We always load the .newsrc.eld file. If always contains
13006 ;; much information that can not be gotten from the .newsrc
13007 ;; file (ticked articles, killed groups, foreign methods, etc.)
13008 (gnus-read-newsrc-el-file quick-file)
13011 (and (file-newer-than-file-p newsrc-file quick-file)
13012 (file-newer-than-file-p newsrc-file
13013 (concat quick-file "d")))
13014 (not gnus-newsrc-alist))
13015 ;; We read the .newsrc file. Note that if there if a
13016 ;; .newsrc.eld file exists, it has already been read, and
13017 ;; the `gnus-newsrc-hashtb' has been created. While reading
13018 ;; the .newsrc file, Gnus will only use the information it
13019 ;; can find there for changing the data already read -
13020 ;; ie. reading the .newsrc file will not trash the data
13021 ;; already read (except for read articles).
13023 (gnus-message 5 "Reading %s..." newsrc-file)
13024 (set-buffer (find-file-noselect newsrc-file))
13025 (buffer-disable-undo (current-buffer))
13026 (gnus-newsrc-to-gnus-format)
13027 (kill-buffer (current-buffer))
13028 (gnus-message 5 "Reading %s...done" newsrc-file))))))
13030 (defun gnus-read-newsrc-el-file (file)
13031 (let ((ding-file (concat file "d")))
13032 ;; We always, always read the .eld file.
13033 (gnus-message 5 "Reading %s..." ding-file)
13034 (let (gnus-newsrc-assoc)
13035 (condition-case nil
13036 (load ding-file t t t)
13038 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
13039 (let ((inhibit-quit t))
13040 (gnus-uncompress-newsrc-alist))
13041 (gnus-make-hashtable-from-newsrc-alist)
13042 (if (not (file-newer-than-file-p file ding-file))
13044 ;; Old format quick file
13045 (gnus-message 5 "Reading %s..." file)
13046 ;; The .el file is newer than the .eld file, so we read that one
13048 (gnus-read-old-newsrc-el-file file))))
13050 ;; Parse the old-style quick startup file
13051 (defun gnus-read-old-newsrc-el-file (file)
13052 (let (newsrc killed marked group m)
13054 (let ((gnus-killed-assoc nil)
13055 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
13057 (condition-case nil
13060 (setq newsrc gnus-newsrc-assoc
13061 killed gnus-killed-assoc
13062 marked gnus-marked-assoc)))
13063 (setq gnus-newsrc-alist nil)
13065 (setq group (car newsrc))
13066 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13069 (setcar (nthcdr 2 info) (cdr (cdr group)))
13071 (if (nth 1 group) gnus-level-default-subscribed
13072 gnus-level-default-unsubscribed))
13073 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
13074 (setq gnus-newsrc-alist
13078 (if (nth 1 group) gnus-level-default-subscribed
13079 gnus-level-default-unsubscribed)
13080 (cdr (cdr group))))
13081 gnus-newsrc-alist)))
13082 (if (setq m (assoc (car group) marked))
13083 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
13084 (setq newsrc (cdr newsrc)))
13085 (setq newsrc killed)
13087 (setcar newsrc (car (car newsrc)))
13088 (setq newsrc (cdr newsrc)))
13089 (setq gnus-killed-list killed))
13090 ;; The .el file version of this variable does not begin with
13091 ;; "options", while the .eld version does, so we just add it if it
13094 gnus-newsrc-options
13096 (and (not (string-match "^ *options" gnus-newsrc-options))
13097 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
13098 (and (not (string-match "\n$" gnus-newsrc-options))
13099 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))))
13100 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
13101 (gnus-make-hashtable-from-newsrc-alist)))
13103 (defun gnus-make-newsrc-file (file)
13104 "Make server dependent file name by catenating FILE and server host name."
13105 (let* ((file (expand-file-name file nil))
13106 (real-file (concat file "-" (nth 1 gnus-select-method))))
13107 (if (or (file-exists-p real-file)
13108 (file-exists-p (concat real-file ".el"))
13109 (file-exists-p (concat real-file ".eld")))
13112 (defun gnus-uncompress-newsrc-alist ()
13113 ;; Uncompress all lists of marked articles in the newsrc assoc.
13114 (let ((newsrc gnus-newsrc-alist)
13117 (if (not (setq marked (nth 3 (car newsrc))))
13120 (or (eq 'score (car (car marked)))
13121 (eq 'bookmark (car (car marked)))
13122 (eq 'killed (car (car marked)))
13123 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13124 (setq marked (cdr marked))))
13125 (setq newsrc (cdr newsrc)))))
13127 (defun gnus-compress-newsrc-alist ()
13128 ;; Compress all lists of marked articles in the newsrc assoc.
13129 (let ((newsrc gnus-newsrc-alist)
13132 (if (not (setq marked (nth 3 (car newsrc))))
13135 (or (eq 'score (car (car marked)))
13136 (eq 'bookmark (car (car marked)))
13137 (eq 'killed (car (car marked)))
13138 (setcdr (car marked)
13140 (gnus-compress-sequence
13141 (sort (cdr (car marked)) '<) t)
13142 (error (cdr (car marked))))))
13143 (setq marked (cdr marked))))
13144 (setq newsrc (cdr newsrc)))))
13146 (defun gnus-newsrc-to-gnus-format ()
13147 (setq gnus-newsrc-options "")
13148 (setq gnus-newsrc-options-n nil)
13150 (or gnus-active-hashtb
13151 (setq gnus-active-hashtb (make-vector 4095 0)))
13152 (let ((buf (current-buffer))
13153 (already-read (> (length gnus-newsrc-alist) 1))
13154 group subscribed options-symbol newsrc Options-symbol
13156 (goto-char (point-min))
13157 ;; We intern the symbol `options' in the active hashtb so that we
13158 ;; can `eq' against it later.
13159 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
13160 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
13162 (while (not (eobp))
13163 ;; We first read the first word on the line by narrowing and
13164 ;; then reading into `gnus-active-hashtb'. Most groups will
13165 ;; already exist in that hashtb, so this will save some string
13169 (progn (skip-chars-forward "^ \t!:\n") (point)))
13170 (goto-char (point-min))
13172 (and (/= (point-min) (point-max))
13173 (let ((obarray gnus-active-hashtb)) (read buf))))
13175 ;; Now, the symbol we have read is either `options' or a group
13176 ;; name. If it is an options line, we just add it to a string.
13178 ((or (eq symbol options-symbol)
13179 (eq symbol Options-symbol))
13180 (setq gnus-newsrc-options
13181 ;; This concatting is quite inefficient, but since our
13182 ;; thorough studies show that approx 99.37% of all
13183 ;; .newsrc files only contain a single options line, we
13184 ;; don't give a damn, frankly, my dear.
13185 (concat gnus-newsrc-options
13187 (gnus-point-at-bol)
13188 ;; Options may continue on the next line.
13189 (or (and (re-search-forward "^[^ \t]" nil 'move)
13190 (progn (beginning-of-line) (point)))
13193 (or (boundp symbol) (set symbol nil))
13194 ;; It was a group name.
13195 (setq subscribed (= (following-char) ?:)
13196 group (symbol-name symbol)
13199 ;; If the line ends here, this is clearly a buggy line, so
13200 ;; we put point a the beginning of line and let the cond
13201 ;; below do the error handling.
13202 (beginning-of-line)
13203 ;; We skip to the beginning of the ranges.
13204 (skip-chars-forward "!: \t"))
13205 ;; We are now at the beginning of the list of read articles.
13206 ;; We read them range by range.
13209 ((looking-at "[0-9]+")
13210 ;; We narrow and read a number instead of buffer-substring/
13211 ;; string-to-int because it's faster. narrow/widen is
13212 ;; faster than save-restriction/narrow, and save-restriction
13213 ;; produces a garbage object.
13215 (narrow-to-region (match-beginning 0) (match-end 0))
13218 ;; If the next character is a dash, then this is a range.
13219 (if (= (following-char) ?-)
13221 ;; We read the upper bound of the range.
13223 (if (not (looking-at "[0-9]+"))
13224 ;; This is a buggy line, by we pretend that
13225 ;; it's kinda OK. Perhaps the user should be
13227 (setq reads (cons num1 reads))
13231 (narrow-to-region (match-beginning 0)
13236 ;; It was just a simple number, so we add it to the
13238 (setq reads (cons num1 reads)))
13239 ;; If the next char in ?\n, then we have reached the end
13240 ;; of the line and return nil.
13241 (/= (following-char) ?\n))
13242 ((= (following-char) ?\n)
13243 ;; End of line, so we end.
13246 ;; Not numbers and not eol, so this might be a buggy
13248 (or (eobp) ; If it was eob instead of ?\n, we allow it.
13250 ;; The line was buggy.
13252 (gnus-message 3 "Mangled line: %s"
13253 (buffer-substring (gnus-point-at-bol)
13254 (gnus-point-at-eol)))
13258 ;; Skip past ", ". Spaces are illegal in these ranges, but
13259 ;; we allow them, because it's a common mistake to put a
13260 ;; space after the comma.
13261 (skip-chars-forward ", "))
13263 ;; We have already read .newsrc.eld, so we gently update the
13264 ;; data in the hash table with the information we have just
13268 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
13271 ;; There is an entry for this file in the alist.
13273 (setcar (nthcdr 2 info) (nreverse reads))
13274 ;; We update the level very gently. In fact, we
13275 ;; only change it if there's been a status change
13276 ;; from subscribed to unsubscribed, or vice versa.
13277 (setq level (nth 1 info))
13278 (cond ((and (<= level gnus-level-subscribed)
13280 (setq level (if reads
13281 gnus-level-default-unsubscribed
13282 (1+ gnus-level-default-unsubscribed))))
13283 ((and (> level gnus-level-subscribed) subscribed)
13284 (setq level gnus-level-default-subscribed)))
13285 (setcar (cdr info) level))
13286 ;; This is a new group.
13287 (setq info (list group
13289 gnus-level-default-subscribed
13291 (1+ gnus-level-subscribed)
13292 gnus-level-default-unsubscribed))
13293 (nreverse reads))))
13294 (setq newsrc (cons info newsrc))))))
13297 (setq newsrc (nreverse newsrc))
13299 (if (not already-read)
13301 ;; We now have two newsrc lists - `newsrc', which is what we
13302 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
13303 ;; what we've read from .newsrc.eld. We have to merge these
13304 ;; lists. We do this by "attaching" any (foreign) groups in the
13305 ;; gnus-newsrc-alist to the (native) group that precedes them.
13306 (let ((rc (cdr gnus-newsrc-alist))
13307 (prev gnus-newsrc-alist)
13310 (or (null (nth 4 (car rc))) ; It's a native group.
13311 (assoc (car (car rc)) newsrc) ; It's already in the alist.
13312 (if (setq entry (assoc (car (car prev)) newsrc))
13313 (setcdr (setq mentry (memq entry newsrc))
13314 (cons (car rc) (cdr mentry)))
13315 (setq newsrc (cons (car rc) newsrc))))
13319 (setq gnus-newsrc-alist newsrc)
13320 ;; We make the newsrc hashtb.
13321 (gnus-make-hashtable-from-newsrc-alist)
13323 ;; Finally, if we read some options lines, we parse them.
13324 (or (string= gnus-newsrc-options "")
13325 (gnus-newsrc-parse-options gnus-newsrc-options))))
13327 ;; Parse options lines to find "options -n !all rec.all" and stuff.
13328 ;; The return value will be a list on the form
13329 ;; ((regexp1 . ignore)
13330 ;; (regexp2 . subscribe)...)
13331 ;; When handling new newsgroups, groups that match a `ignore' regexp
13332 ;; will be ignored, and groups that match a `subscribe' regexp will be
13333 ;; subscribed. A line like
13334 ;; options -n !all rec.all
13335 ;; will lead to a list that looks like
13336 ;; (("^rec\\..+" . subscribe)
13337 ;; ("^.+" . ignore))
13338 ;; So all "rec.*" groups will be subscribed, while all the other
13339 ;; groups will be ignored. Note that "options -n !all rec.all" is very
13340 ;; different from "options -n rec.all !all".
13341 (defun gnus-newsrc-parse-options (options)
13344 (gnus-set-work-buffer)
13345 (insert (regexp-quote options))
13346 ;; First we treat all continuation lines.
13347 (goto-char (point-min))
13348 (while (re-search-forward "\n[ \t]+" nil t)
13349 (replace-match " " t t))
13350 ;; Then we transform all "all"s into ".+"s.
13351 (goto-char (point-min))
13352 (while (re-search-forward "\\ball\\b" nil t)
13353 (replace-match ".+" t t))
13354 (goto-char (point-min))
13355 ;; We remove all other options than the "-n" ones.
13356 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
13357 (replace-match " ")
13359 (goto-char (point-min))
13361 ;; We are only interested in "options -n" lines - we
13362 ;; ignore the other option lines.
13363 (while (re-search-forward "[ \t]-n" nil t)
13365 (or (save-excursion
13366 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
13368 (gnus-point-at-eol)))
13369 ;; Search for all "words"...
13370 (while (re-search-forward "[^ \t,\n]+" eol t)
13371 (if (= (char-after (match-beginning 0)) ?!)
13372 ;; If the word begins with a bang (!), this is a "not"
13373 ;; spec. We put this spec (minus the bang) and the
13374 ;; symbol `ignore' into the list.
13375 (setq out (cons (cons (concat
13376 "^" (buffer-substring
13377 (1+ (match-beginning 0))
13380 ;; There was no bang, so this is a "yes" spec.
13381 (setq out (cons (cons (concat
13382 "^" (buffer-substring (match-beginning 0)
13384 'subscribe) out)))))
13386 (setq gnus-newsrc-options-n out))))
13389 (defun gnus-save-newsrc-file ()
13390 "Save .newsrc file."
13391 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13392 ;; from the variable gnus-newsrc-alist.
13393 (and (or gnus-newsrc-alist gnus-killed-list)
13394 gnus-current-startup-file
13396 (run-hooks 'gnus-save-newsrc-hook)
13398 (if (and gnus-use-dribble-file
13399 (or (not gnus-dribble-buffer)
13400 (not (buffer-name gnus-dribble-buffer))
13401 (zerop (save-excursion
13402 (set-buffer gnus-dribble-buffer)
13404 (gnus-message 4 "(No changes need to be saved)")
13405 (if gnus-save-newsrc-file
13407 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
13408 ;; Make backup file of master newsrc.
13409 (gnus-gnus-to-newsrc-format)
13410 (gnus-message 5 "Saving %s...done"
13411 gnus-current-startup-file)))
13412 ;; Quickly loadable .newsrc.
13413 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13414 (setq buffer-file-name (concat gnus-current-startup-file ".eld"))
13415 (gnus-add-current-to-buffer-list)
13416 (buffer-disable-undo (current-buffer))
13418 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
13419 (gnus-gnus-to-quick-newsrc-format)
13421 (kill-buffer (current-buffer))
13422 (gnus-message 5 "Saving %s.eld...done" gnus-current-startup-file)
13423 (gnus-dribble-delete-file))))))
13425 (defun gnus-gnus-to-quick-newsrc-format ()
13426 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
13427 (insert ";; Gnus startup file.\n")
13428 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13429 (insert ";; to read .newsrc.\n")
13430 (insert "(setq gnus-newsrc-file-version "
13431 (prin1-to-string gnus-version) ")\n")
13432 (let ((variables gnus-variable-list)
13434 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
13436 ;; insert lisp expressions.
13437 (gnus-compress-newsrc-alist)
13439 (setq variable (car variables))
13440 (and (boundp variable)
13441 (symbol-value variable)
13442 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13443 (insert "(setq " (symbol-name variable) " '"
13444 (prin1-to-string (symbol-value variable))
13446 (setq variables (cdr variables)))
13447 (gnus-uncompress-newsrc-alist)))
13450 (defun gnus-gnus-to-newsrc-format ()
13451 ;; Generate and save the .newsrc file.
13452 (let ((newsrc (cdr gnus-newsrc-alist))
13455 (set-buffer (create-file-buffer gnus-current-startup-file))
13456 (setq buffer-file-name gnus-current-startup-file)
13457 (buffer-disable-undo (current-buffer))
13460 (if gnus-newsrc-options (insert gnus-newsrc-options))
13461 ;; Write subscribed and unsubscribed.
13463 (setq info (car newsrc))
13464 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13466 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13468 (if (setq ranges (nth 2 info))
13471 (if (not (listp (cdr ranges)))
13472 (if (= (car ranges) (cdr ranges))
13473 (insert (int-to-string (car ranges)))
13474 (insert (int-to-string (car ranges)) "-"
13475 (int-to-string (cdr ranges))))
13477 (setq range (car ranges)
13478 ranges (cdr ranges))
13479 (if (or (atom range) (= (car range) (cdr range)))
13480 (insert (int-to-string
13481 (or (and (atom range) range)
13483 (insert (int-to-string (car range)) "-"
13484 (int-to-string (cdr range))))
13485 (if ranges (insert ","))))))
13487 (setq newsrc (cdr newsrc)))
13488 ;; It has been reported that sometime the modtime on the .newsrc
13489 ;; file seems to be off. We really do want to overwrite it, so
13490 ;; we clear the modtime here before saving. It's a bit odd,
13492 ;; sometimes the modtime clear isn't sufficient. most brute force:
13493 ;; delete the silly thing entirely first. but this fails to provide
13494 ;; such niceties as .newsrc~ creation.
13495 (if gnus-modtime-botch
13496 (delete-file gnus-startup-file)
13497 (clear-visited-file-modtime))
13499 (kill-buffer (current-buffer)))))
13501 (defun gnus-read-all-descriptions-files ()
13502 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13504 (gnus-read-descriptions-file (car methods))
13505 (setq methods (cdr methods)))
13508 (defun gnus-read-descriptions-file (&optional method)
13509 (let ((method (or method gnus-select-method)))
13510 ;; We create the hashtable whether we manage to read the desc file
13511 ;; to avoid trying to re-read after a failed read.
13512 (or gnus-description-hashtb
13513 (setq gnus-description-hashtb
13514 (gnus-make-hashtable (length gnus-active-hashtb))))
13515 ;; Mark this method's desc file as read.
13516 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
13517 gnus-description-hashtb)
13519 (gnus-message 5 "Reading descriptions file via %s..." (car method))
13521 ((not (gnus-check-server method))
13522 (gnus-message 1 "Couldn't open server")
13524 ((not (gnus-request-list-newsgroups method))
13525 (gnus-message 1 "Couldn't read newsgroups descriptions")
13531 (set-buffer nntp-server-buffer)
13532 (goto-char (point-min))
13533 (if (or (search-forward "\n.\n" nil t)
13534 (goto-char (point-max)))
13536 (beginning-of-line)
13537 (narrow-to-region (point-min) (point))))
13538 (goto-char (point-min))
13539 (while (not (eobp))
13540 ;; If we get an error, we set group to 0, which is not a
13544 (let ((obarray gnus-description-hashtb))
13545 ;; Group is set to a symbol interned in this
13547 (read nntp-server-buffer))
13549 (skip-chars-forward " \t")
13550 ;; ... which leads to this line being effectively ignored.
13551 (and (symbolp group)
13552 (set group (buffer-substring
13553 (point) (progn (end-of-line) (point)))))
13554 (forward-line 1))))
13555 (gnus-message 5 "Reading descriptions file...done")
13558 (defun gnus-group-get-description (group)
13559 ;; Get the description of a group by sending XGTITLE to the server.
13560 (and (gnus-request-group-description group)
13562 (set-buffer nntp-server-buffer)
13563 (goto-char (point-min))
13564 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13565 (buffer-substring (match-beginning 1) (match-end 1))))))
13571 (defvar gnus-server-mode-hook nil
13572 "Hook run in `gnus-server-mode' buffers.")
13574 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13575 "Format of server lines.
13576 It works along the same lines as a normal formatting string,
13577 with some simple extensions.")
13579 (defvar gnus-server-mode-line-format "Gnus List of servers"
13580 "The format specification for the server mode line.")
13582 (defconst gnus-server-line-format-alist
13583 (list (list ?h 'how ?s)
13585 (list ?w 'where ?s)
13588 (defconst gnus-server-mode-line-format-alist
13589 (list (list ?S 'news-server ?s)
13590 (list ?M 'news-method ?s)
13591 (list ?u 'user-defined ?s)))
13593 (defvar gnus-server-line-format-spec nil)
13594 (defvar gnus-server-mode-line-format-spec nil)
13595 (defvar gnus-server-killed-servers nil)
13597 (defvar gnus-server-mode-map nil)
13598 (put 'gnus-server-mode 'mode-class 'special)
13600 (if gnus-server-mode-map
13602 (setq gnus-server-mode-map (make-sparse-keymap))
13603 (suppress-keymap gnus-server-mode-map)
13604 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13605 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
13606 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
13607 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13608 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13609 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13610 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13611 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13612 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13613 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13615 (defun gnus-server-mode ()
13616 "Major mode for listing and editing servers.
13618 All normal editing commands are switched off.
13619 \\<gnus-server-mode-map>
13621 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13623 The following commands are available:
13625 \\{gnus-server-mode-map}"
13627 (if gnus-visual (gnus-server-make-menu-bar))
13628 (kill-all-local-variables)
13629 (setq mode-line-modified "-- ")
13630 (make-local-variable 'mode-line-format)
13631 (setq mode-line-format (copy-sequence mode-line-format))
13632 (and (equal (nth 3 mode-line-format) " ")
13633 (setcar (nthcdr 3 mode-line-format) ""))
13634 (setq major-mode 'gnus-server-mode)
13635 (setq mode-name "Server")
13636 ; (gnus-group-set-mode-line)
13637 (setq mode-line-process nil)
13638 (use-local-map gnus-server-mode-map)
13639 (buffer-disable-undo (current-buffer))
13640 (setq truncate-lines t)
13641 (setq buffer-read-only t)
13642 (run-hooks 'gnus-server-mode-hook))
13644 (defun gnus-server-insert-server-line (sformat name method)
13645 (let* ((sformat (or sformat gnus-server-line-format-spec))
13647 (where (nth 1 method))
13649 (beginning-of-line)
13651 ;; Insert the text.
13652 (insert (eval sformat))
13653 (add-text-properties b (1+ b) (list 'gnus-server (intern name)))))
13655 (defun gnus-server-setup-buffer ()
13656 (if (get-buffer gnus-server-buffer)
13659 (set-buffer (get-buffer-create gnus-server-buffer))
13661 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
13663 (defun gnus-server-prepare ()
13664 (setq gnus-server-mode-line-format-spec
13665 (gnus-parse-format gnus-server-mode-line-format
13666 gnus-server-mode-line-format-alist))
13667 (setq gnus-server-line-format-spec
13668 (gnus-parse-format gnus-server-line-format
13669 gnus-server-line-format-alist))
13670 (let ((alist gnus-server-alist)
13671 (buffer-read-only nil))
13674 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13675 (setq alist (cdr alist))))
13676 (goto-char (point-min))
13677 (gnus-server-position-cursor))
13679 (defun gnus-server-server-name ()
13680 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
13681 (and server (symbol-name server))))
13683 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13685 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13687 (defun gnus-server-update-server (server)
13689 (set-buffer gnus-server-buffer)
13690 (let ((buffer-read-only nil)
13691 (info (cdr (assoc server gnus-server-alist))))
13692 (gnus-dribble-enter
13693 (concat "(gnus-server-set-info \"" server "\" '"
13694 (prin1-to-string info) ")"))
13695 ;; Buffer may be narrowed.
13698 (if (gnus-server-goto-server server)
13699 (delete-region (progn (beginning-of-line) (point))
13700 (progn (forward-line 1) (point))))
13701 (let ((entry (assoc server gnus-server-alist)))
13702 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13703 (gnus-server-position-cursor))))))
13705 (defun gnus-server-set-info (server info)
13706 ;; Enter a select method into the virtual server alist.
13707 (gnus-dribble-enter
13708 (concat "(gnus-server-set-info \"" server "\" '"
13709 (prin1-to-string info) ")"))
13710 (let* ((server (nth 1 info))
13711 (entry (assoc server gnus-server-alist)))
13712 (if entry (setcdr entry info)
13713 (setq gnus-server-alist
13714 (nconc gnus-server-alist (list (cons server info)))))))
13716 (defun gnus-server-to-method (server)
13717 ;; Map virtual server names to select methods.
13718 (or (and (equal server "native") gnus-select-method)
13719 (cdr (assoc server gnus-server-alist))))
13721 (defun gnus-server-extend-method (group method)
13722 ;; This function "extends" a virtual server. If the server is
13723 ;; "hello", and the select method is ("hello" (my-var "something"))
13724 ;; in the group "alt.alt", this will result in a new virtual server
13725 ;; called "helly+alt.alt".
13727 (gnus-copy-sequence
13728 (if (equal (car method) "native") gnus-select-method
13729 (cdr (assoc (car method) gnus-server-alist))))))
13730 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13731 (nconc entry (cdr method))))
13733 (defun gnus-server-get-method (group method)
13734 ;; Input either a server name, and extended server name, or a
13735 ;; select method, and return a select method.
13736 (cond ((stringp method)
13737 (gnus-server-to-method method))
13738 ((and (stringp (car method)) group)
13739 (gnus-server-extend-method group method))
13741 (gnus-server-add-address method))))
13743 (defun gnus-server-add-address (method)
13744 (let ((method-name (symbol-name (car method))))
13745 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
13746 (not (assq (intern (concat method-name "-address")) method)))
13747 (append method (list (list (intern (concat method-name "-address"))
13751 (defun gnus-server-equal (s1 s2)
13753 (and (= (length s1) (length s2))
13755 (while (and s1 (member (car s1) s2))
13756 (setq s1 (cdr s1)))
13759 ;;; Interactive server functions.
13761 (defun gnus-server-kill-server (server)
13762 "Kill the server on the current line."
13763 (interactive (list (gnus-server-server-name)))
13764 (or (gnus-server-goto-server server)
13765 (if server (error "No such server: %s" server)
13766 (error "No server on the current line")))
13767 (gnus-dribble-enter "")
13768 (let ((buffer-read-only nil))
13769 (delete-region (progn (beginning-of-line) (point))
13770 (progn (forward-line 1) (point))))
13771 (setq gnus-server-killed-servers
13772 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13773 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13774 gnus-server-alist))
13775 (gnus-server-position-cursor))
13777 (defun gnus-server-yank-server ()
13778 "Yank the previously killed server."
13780 (or gnus-server-killed-servers
13781 (error "No killed servers to be yanked"))
13782 (let ((alist gnus-server-alist)
13783 (server (gnus-server-server-name))
13784 (killed (car gnus-server-killed-servers)))
13786 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13787 (if (string= server (car (car gnus-server-alist)))
13788 (setq gnus-server-alist (cons killed gnus-server-alist))
13789 (while (and (cdr alist)
13790 (not (string= server (car (car (cdr alist))))))
13791 (setq alist (cdr alist)))
13792 (setcdr alist (cons killed (cdr alist)))))
13793 (gnus-server-update-server (car killed))
13794 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13795 (gnus-server-position-cursor)))
13797 (defun gnus-server-exit ()
13798 "Return to the group buffer."
13800 (kill-buffer (current-buffer))
13801 (switch-to-buffer gnus-group-buffer))
13803 (defun gnus-server-list-servers ()
13804 "List all available servers."
13806 (let ((cur (gnus-server-server-name)))
13807 (gnus-server-prepare)
13808 (if cur (gnus-server-goto-server cur)
13809 (goto-char (point-max))
13811 (gnus-server-position-cursor)))
13813 (defun gnus-server-copy-server (from to)
13816 (or (gnus-server-server-name)
13817 (error "No server on the current line"))
13818 (read-string "Copy to: ")))
13819 (or from (error "No server on current line"))
13820 (or (and to (not (string= to ""))) (error "No name to copy to"))
13821 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13822 (or (assoc from gnus-server-alist)
13823 (error "%s: no such server" from))
13824 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13825 (setcar to-entry to)
13826 (setcar (nthcdr 2 to-entry) to)
13827 (setq gnus-server-killed-servers
13828 (cons to-entry gnus-server-killed-servers))
13829 (gnus-server-yank-server)))
13831 (defun gnus-server-add-server (how where)
13833 (list (intern (completing-read "Server method: "
13834 gnus-valid-select-methods nil t))
13835 (read-string "Server name: ")))
13836 (setq gnus-server-killed-servers
13837 (cons (list where how where) gnus-server-killed-servers))
13838 (gnus-server-yank-server))
13840 (defun gnus-server-goto-server (server)
13841 "Jump to a server line."
13843 (list (completing-read "Goto server: " gnus-server-alist nil t)))
13844 (let ((to (text-property-any (point-min) (point-max)
13845 'gnus-server (intern server))))
13849 (gnus-server-position-cursor)))))
13851 (defun gnus-server-edit-server (server)
13852 "Edit the server on the current line."
13853 (interactive (list (gnus-server-server-name)))
13855 (error "No server on current line"))
13856 (let ((winconf (current-window-configuration)))
13857 (get-buffer-create gnus-server-edit-buffer)
13858 (gnus-configure-windows 'edit-server)
13859 (gnus-add-current-to-buffer-list)
13861 (make-local-variable 'gnus-prev-winconf)
13862 (setq gnus-prev-winconf winconf)
13863 (use-local-map (copy-keymap (current-local-map)))
13864 (let ((done-func '(lambda ()
13865 "Exit editing mode and update the information."
13867 (gnus-server-edit-server-done 'group))))
13868 (setcar (cdr (nth 4 done-func)) server)
13869 (local-set-key "\C-c\C-c" done-func))
13871 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
13872 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
13874 (defun gnus-server-edit-server-done (server)
13876 (set-buffer (get-buffer-create gnus-server-edit-buffer))
13877 (goto-char (point-min))
13878 (let ((form (read (current-buffer)))
13879 (winconf gnus-prev-winconf))
13880 (gnus-server-set-info server form)
13881 (kill-buffer (current-buffer))
13882 (and winconf (set-window-configuration winconf))
13883 (set-buffer gnus-server-buffer)
13884 (gnus-server-update-server (gnus-server-server-name))
13885 (gnus-server-list-servers)
13886 (gnus-server-position-cursor)))
13888 (defun gnus-server-read-server (server)
13890 (interactive (list (gnus-server-server-name)))
13891 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
13893 (defun gnus-mouse-pick-server (e)
13895 (mouse-set-point e)
13896 (gnus-server-read-server (gnus-server-server-name)))
13899 ;;; entry points into gnus-score.el
13902 ;;; Finding score files.
13904 (defvar gnus-global-score-files nil
13905 "*List of global score files and directories.
13906 Set this variable if you want to use people's score files. One entry
13907 for each score file or each score file directory. Gnus will decide
13908 by itself what score files are applicable to which group.
13910 Say you want to use the single score file
13911 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
13912 score files in the \"/ftp.some-where:/pub/score\" directory.
13914 (setq gnus-global-score-files
13915 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
13916 \"/ftp.some-where:/pub/score\"))")
13918 (defun gnus-score-score-files (group)
13919 "Return a list of all possible score files."
13920 ;; Search and set any global score files.
13921 (and gnus-global-score-files
13922 (or gnus-internal-global-score-files
13923 (gnus-score-search-global-directories gnus-global-score-files)))
13924 ;; Fix the kill-file dir variable.
13925 (setq gnus-kill-files-directory
13926 (file-name-as-directory
13927 (or gnus-kill-files-directory "~/News/")))
13928 ;; If we can't read it, there are no score files.
13929 (if (not (file-exists-p (expand-file-name gnus-kill-files-directory)))
13930 (setq gnus-score-file-list nil)
13931 (if (gnus-use-long-file-name 'not-score)
13932 ;; We want long file names.
13933 (if (or (not gnus-score-file-list)
13934 (not (car gnus-score-file-list))
13935 (gnus-file-newer-than gnus-kill-files-directory
13936 (car gnus-score-file-list)))
13937 (setq gnus-score-file-list
13938 (cons (nth 5 (file-attributes gnus-kill-files-directory))
13941 gnus-kill-files-directory t
13942 (gnus-score-file-regexp))))))
13943 ;; We do not use long file names, so we have to do some
13944 ;; directory traversing.
13945 (let ((mdir (length (expand-file-name gnus-kill-files-directory)))
13946 (suffixes (list gnus-score-file-suffix gnus-adaptive-file-suffix))
13949 (setq dir (expand-file-name
13950 (concat gnus-kill-files-directory
13951 (gnus-replace-chars-in-string group ?. ?/))))
13952 (setq dir (gnus-replace-chars-in-string dir ?: ?/))
13953 (setq suffix (car suffixes)
13954 suffixes (cdr suffixes))
13955 (if (file-exists-p (concat dir "/" suffix))
13956 (setq files (cons (concat dir "/" suffix) files)))
13957 (while (>= (1+ (length dir)) mdir)
13958 (and (file-exists-p (concat dir "/all/" suffix))
13959 (setq files (cons (concat dir "/all/" suffix) files)))
13960 (string-match "/[^/]*$" dir)
13961 (setq dir (substring dir 0 (match-beginning 0)))))
13962 (setq gnus-score-file-list
13963 (cons nil (nreverse files)))))
13964 (cdr gnus-score-file-list)))
13966 (defun gnus-score-file-regexp ()
13967 (concat "\\(" gnus-score-file-suffix
13968 "\\|" gnus-adaptive-file-suffix "\\)$"))
13970 (defun gnus-score-find-bnews (group)
13971 "Return a list of score files for GROUP.
13972 The score files are those files in the ~/News directory which matches
13973 GROUP using BNews sys file syntax."
13974 (let* ((sfiles (append (gnus-score-score-files group)
13975 gnus-internal-global-score-files))
13976 (kill-dir (file-name-as-directory
13977 (expand-file-name gnus-kill-files-directory)))
13978 (klen (length kill-dir))
13979 ofiles not-match regexp)
13981 (set-buffer (get-buffer-create "*gnus score files*"))
13982 (buffer-disable-undo (current-buffer))
13983 ;; Go through all score file names and create regexp with them
13987 (insert (car sfiles))
13988 (goto-char (point-min))
13989 ;; First remove the suffix itself.
13990 (re-search-forward (concat "." (gnus-score-file-regexp)))
13991 (replace-match "" t t)
13992 (goto-char (point-min))
13993 (if (looking-at (regexp-quote kill-dir))
13994 ;; If the file name was just "SCORE", `klen' is one character
13996 (delete-char (min (1- (point-max)) klen))
13997 (goto-char (point-max))
13998 (search-backward "/")
13999 (delete-region (1+ (point)) (point-min)))
14000 ;; If short file names were used, we have to translate slashes.
14001 (goto-char (point-min))
14002 (while (re-search-forward "[/:]" nil t)
14003 (replace-match "." t t))
14004 ;; Translate "all" to ".*".
14005 (while (search-forward "all" nil t)
14006 (replace-match ".*" t t))
14007 (goto-char (point-min))
14008 ;; Deal with "not."s.
14009 (if (looking-at "not.")
14012 (setq regexp (buffer-substring 5 (point-max))))
14013 (setq regexp (buffer-substring 1 (point-max)))
14014 (setq not-match nil))
14015 ;; Finally - if this resulting regexp matches the group name,
14016 ;; we add this score file to the list of score files
14017 ;; applicable to this group.
14018 (if (or (and not-match
14019 (not (string-match regexp group)))
14020 (and (not not-match)
14021 (string-match regexp group)))
14022 (setq ofiles (cons (car sfiles) ofiles)))
14023 (setq sfiles (cdr sfiles)))
14024 (kill-buffer (current-buffer))
14025 ;; Slight kludge here - the last score file returned should be
14026 ;; the local score file, whether it exists or not. This is so
14027 ;; that any score commands the user enters will go to the right
14028 ;; file, and not end up in some global score file.
14031 (if (gnus-use-long-file-name 'not-score)
14032 (concat gnus-kill-files-directory group "."
14033 gnus-score-file-suffix)
14034 (concat gnus-kill-files-directory
14035 (gnus-replace-chars-in-string group ?. ?/ ?: ?/)
14036 "/" gnus-score-file-suffix)))))
14037 (and (member localscore ofiles)
14038 (delete localscore ofiles))
14039 (setq ofiles (cons localscore ofiles)))
14040 (nreverse ofiles))))
14042 (defun gnus-score-find-single (group)
14043 "Return list containing the score file for GROUP."
14044 (list (gnus-score-file-name group gnus-adaptive-file-suffix)
14045 (gnus-score-file-name group)))
14047 (defun gnus-score-find-hierarchical (group)
14048 "Return list of score files for GROUP.
14049 This includes the score file for the group and all its parents."
14050 (let ((all (copy-sequence '(nil)))
14052 (while (string-match "\\." group (1+ start))
14053 (setq start (match-beginning 0))
14054 (setq all (cons (substring group 0 start) all)))
14055 (setq all (cons group all))
14057 (mapcar (lambda (newsgroup)
14058 (gnus-score-file-name newsgroup gnus-adaptive-file-suffix))
14059 (setq all (nreverse all)))
14060 (mapcar 'gnus-score-file-name all))))
14062 (defvar gnus-score-file-alist-cache nil)
14064 (defun gnus-score-find-alist (group)
14065 "Return list of score files for GROUP.
14066 The list is determined from the variable gnus-score-file-alist."
14067 (let ((alist gnus-score-file-multiple-match-alist)
14069 ;; if this group has been seen before, return the cached entry
14070 (if (setq score-files (assoc group gnus-score-file-alist-cache))
14071 (cdr score-files) ; ensures caching of groups with no matches
14072 ;; handle the multiple match alist
14074 (and (string-match (car (car alist)) group)
14076 (nconc score-files (copy-sequence (cdr (car alist))))))
14077 (setq alist (cdr alist)))
14078 (setq alist gnus-score-file-single-match-alist)
14079 ;; handle the single match alist
14081 (and (string-match (car (car alist)) group)
14082 ;; progn used just in case ("regexp") has no files
14083 ;; and score-files is still nil. -sj
14084 ;; this can be construed as a "stop searching here" feature :>
14085 ;; and used to simplify regexps in the single-alist
14088 (nconc score-files (copy-sequence (cdr (car alist)))))
14090 (setq alist (cdr alist)))
14091 ;; cache the score files
14092 (setq gnus-score-file-alist-cache
14093 (cons (cons group score-files) gnus-score-file-alist-cache))
14097 (defun gnus-possibly-score-headers (&optional trace)
14098 (let ((func gnus-score-find-score-files-function)
14100 (and func (not (listp func))
14101 (setq func (list func)))
14102 ;; Go through all the functions for finding score files (or actual
14103 ;; scores) and add them to a list.
14104 (setq score-files (gnus-score-find-alist gnus-newsgroup-name))
14106 (and (symbolp (car func))
14107 (fboundp (car func))
14109 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
14110 (setq func (cdr func)))
14111 (if score-files (gnus-score-headers score-files trace))))
14113 (defun gnus-score-file-name (newsgroup &optional suffix)
14114 "Return the name of a score file for NEWSGROUP."
14115 (let ((suffix (or suffix gnus-score-file-suffix)))
14117 ((or (null newsgroup)
14118 (string-equal newsgroup ""))
14119 ;; The global score file is placed at top of the directory.
14121 suffix (or gnus-kill-files-directory "~/News")))
14122 ((gnus-use-long-file-name 'not-score)
14123 ;; Append ".SCORE" to newsgroup name.
14124 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
14126 (or gnus-kill-files-directory "~/News")))
14128 ;; Place "SCORE" under the hierarchical directory.
14129 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14131 (or gnus-kill-files-directory "~/News"))))))
14133 (defun gnus-score-search-global-directories (files)
14134 "Scan all global score directories for score files."
14135 ;; Set the variable `gnus-internal-global-score-files' to all
14136 ;; available global score files.
14137 (interactive (list gnus-global-score-files))
14140 (if (string-match "/$" (car files))
14141 (setq out (nconc (directory-files
14143 (concat (gnus-score-file-regexp) "$"))))
14144 (setq out (cons (car files) out)))
14145 (setq files (cdr files)))
14146 (setq gnus-internal-global-score-files out)))
14148 ;; Allow redefinition of Gnus functions.
14150 (gnus-ems-redefine)
14154 ;;; gnus.el ends here