1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although (ding) Gnus looks suspiciously like GNUS, it isn't quite
27 ;; the same beast. Most internal structures have been changed. If you
28 ;; have written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-alist', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
40 ;; Site dependent variables. These variables should be defined in
43 (defvar gnus-default-nntp-server nil
44 "Specify a default NNTP server.
45 This variable should be defined in paths.el, and should never be set
47 If you want to change servers, you should use `gnus-select-method'.
48 See the documentation to that variable.")
50 (defconst gnus-backup-default-subscribed-newsgroups
51 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
52 "Default default new newsgroups the first time Gnus is run.
53 Should be set in paths.el, and shouldn't be touched by the user.")
55 (defvar gnus-local-domain nil
56 "Local domain name without a host name.
57 The DOMAINNAME environment variable is used instead if it is defined.
58 If the `system-name' function returns the full Internet name, there is
59 no need to set this variable.")
61 (defvar gnus-local-organization nil
62 "String with a description of what organization (if any) the user belongs to.
63 The ORGANIZATION environment variable is used instead if it is defined.
64 If this variable contains a function, this function will be called
65 with the current newsgroup name as the argument. The function should
68 In any case, if the string (either in the variable, in the environment
69 variable, or returned by the function) is a file name, the contents of
70 this file will be used as the organization.")
72 (defvar gnus-use-generic-from nil
73 "If nil, the full host name will be the system name prepended to the domain name.
74 If this is a string, the full host name will be this string.
75 If this is non-nil, non-string, the domain name will be used as the
78 (defvar gnus-use-generic-path nil
79 "If nil, use the NNTP server name in the Path header.
80 If stringp, use this; if non-nil, use no host name (user name only).")
83 ;; Customization variables
85 (defvar gnus-select-method
86 (list 'nntp (or (getenv "NNTPSERVER")
87 (if (and gnus-default-nntp-server
88 (not (string= gnus-default-nntp-server "")))
89 gnus-default-nntp-server)
91 "*Default method for selecting a newsgroup.
92 This variable should be a list, where the first element is how the
93 news is to be fetched, the second is the address.
95 For instance, if you want to get your news via NNTP from
96 \"flab.flab.edu\", you could say:
98 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
100 If you want to use your local spool, say:
102 (setq gnus-select-method (list 'nnspool (system-name)))
104 If you use this variable, you must set `gnus-nntp-server' to nil.
106 There is a lot more to know about select methods and virtual servers -
107 see the manual for details.")
109 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
110 (defvar gnus-post-method nil
111 "*Preferred method for posting USENET news.
112 If this variable is nil, Gnus will use the current method to decide
113 which method to use when posting. If it is non-nil, it will override
114 the current method. This method will not be used in mail groups and
115 the like, only in \"real\" newsgroups.
117 The value must be a valid method as discussed in the documentation of
118 `gnus-select-method'.")
120 (defvar gnus-refer-article-method nil
121 "*Preferred method for fetching an article by Message-ID.
122 If you are reading news from the local spool (with nnspool), fetching
123 articles by Message-ID is painfully slow. By setting this method to an
124 nntp method, you might get acceptable results.
126 The value of this variable must be a valid select method as discussed
127 in the documentation of `gnus-select-method'")
129 (defvar gnus-secondary-select-methods nil
130 "*A list of secondary methods that will be used for reading news.
131 This is a list where each element is a complete select methdod (see
132 `gnus-select-method').
134 If, for instance, you want to read your mail with the nnml backend,
135 you could set this variable:
137 (setq gnus-secondary-select-methods '((nnml \"\"))")
139 (defvar gnus-secondary-servers nil
140 "*List of NNTP servers that the user can choose between interactively.
141 To make Gnus query you for a server, you have to give `gnus' a
142 non-numeric prefix - `C-u M-x gnus', in short.")
144 (defvar gnus-nntp-server nil
145 "*The name of the host running the NNTP server.
146 This variable is semi-obsolete. Use the `gnus-select-method'
149 (defvar gnus-nntp-service "nntp"
150 "*NNTP service name (\"nntp\" or 119).
151 This is an obsolete variable, which is scarcely used. If you use an
152 nntp server for your newsgroup and want to change the port number
153 used to 899, you would say something along these lines:
155 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
157 (defvar gnus-startup-file "~/.newsrc"
158 "*Your `.newsrc' file.
159 `.newsrc-SERVER' will be used instead if that exists.")
161 (defvar gnus-init-file "~/.gnus"
162 "*Your Gnus elisp startup file.
163 If a file with the .el or .elc suffixes exist, it will be read
166 (defvar gnus-group-faq-directory
167 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
168 "*Directory where the group FAQs are stored.
169 This will most commonly be on a remote machine, and the file will be
170 fetched by ange-ftp.")
172 (defvar gnus-group-archive-directory
173 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
174 "*The address of the (ding) archives.")
176 (defvar gnus-default-subscribed-newsgroups nil
177 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
178 It should be a list of strings.
179 If it is `t', Gnus will not do anything special the first time it is
180 started; it'll just use the normal newsgroups subscription methods.")
182 (defvar gnus-use-cross-reference t
183 "*Non-nil means that cross referenced articles will be marked as read.
184 If nil, ignore cross references. If t, mark articles as read in
185 subscribed newsgroups. If neither t nor nil, mark as read in all
188 (defvar gnus-use-dribble-file t
189 "*Non-nil means that Gnus will use a dribble file to store user updates.
190 If Emacs should crash without saving the .newsrc files, complete
191 information can be restored from the dribble file.")
193 (defvar gnus-asynchronous nil
194 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
196 (defvar gnus-asynchronous-article-function nil
197 "*Function for picking articles to pre-fetch, possibly.")
199 (defvar gnus-score-file-suffix "SCORE"
200 "*Suffix of the score files.")
202 (defvar gnus-score-interactive-default-score 1000
203 "*Scoring commands will raise/lower the score with this number as the default.")
205 (defvar gnus-large-newsgroup 200
206 "*The number of articles which indicates a large newsgroup.
207 If the number of articles in a newsgroup is greater than this value,
208 confirmation is required for selecting the newsgroup.")
210 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
211 (defvar gnus-no-groups-message "No news is horrible news"
212 "*Message displayed by Gnus when no groups are available.")
214 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
215 "*Non-nil means that the default name of a file to save articles in is the group name.
216 If it's nil, the directory form of the group name is used instead.
218 If this variable is a list, and the list contains the element
219 `not-score', long file names will not be used for score files; if it
220 contains the element `not-save', long file names will not be used for
221 saving; and if it contains the element `not-kill', long file names
222 will not be used for kill files.")
224 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
225 "*Name of the directory articles will be saved in (default \"~/News\").
226 Initialized from the SAVEDIR environment variable.")
228 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
229 "*Name of the directory where kill files will be stored (default \"~/News\").
230 Initialized from the SAVEDIR environment variable.")
232 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
233 "*A function to save articles in your favorite format.
234 The function must be interactively callable (in other words, it must
235 be an Emacs command).
237 Gnus provides the following functions:
239 * gnus-summary-save-in-rmail (Rmail format)
240 * gnus-summary-save-in-mail (Unix mail format)
241 * gnus-summary-save-in-folder (MH folder)
242 * gnus-summary-save-in-file (article format).
243 * gnus-summary-save-in-vm (use VM's folder format).")
245 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
246 "*A function generating a file name to save articles in Rmail format.
247 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
249 (defvar gnus-mail-save-name (function gnus-plain-save-name)
250 "*A function generating a file name to save articles in Unix mail format.
251 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
253 (defvar gnus-folder-save-name (function gnus-folder-save-name)
254 "*A function generating a file name to save articles in MH folder.
255 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
257 (defvar gnus-file-save-name (function gnus-numeric-save-name)
258 "*A function generating a file name to save articles in article format.
259 The function is called with NEWSGROUP, HEADERS, and optional
262 (defvar gnus-split-methods nil
263 "*Variable used to suggest where articles are to be saved.
264 The syntax of this variable is the same as `nnmail-split-methods'.
266 For instance, if you would like to save articles related to Gnus in
267 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
268 you could set this variable to something like:
270 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
271 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
273 (defvar gnus-save-score nil
274 "*If non-nil, save group scoring info.")
276 (defvar gnus-use-adaptive-scoring nil
277 "*If non-nil, use some adaptive scoring scheme.")
279 (defvar gnus-use-cache nil
280 "*If non-nil, Gnus will cache (some) articles locally.")
282 (defvar gnus-use-scoring t
283 "*If non-nil, enable scoring.")
285 (defvar gnus-fetch-old-headers nil
286 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
287 If an unread article in the group refers to an older, already read (or
288 just marked as read) article, the old article will not normally be
289 displayed in the Summary buffer. If this variable is non-nil, Gnus
290 will attempt to grab the headers to the old articles, and thereby
291 build complete threads. If it has the value `some', only enough
292 headers to connect otherwise loose threads will be displayed.
294 The server has to support XOVER for any of this to work.")
296 (defvar gnus-visual t
297 "*If non-nil, will do various highlighting.
298 If nil, no mouse highlights (or any other highlights) will be
299 performed. This might speed up Gnus some when generating large group
300 and summary buffers.")
302 (defvar gnus-novice-user t
303 "*Non-nil means that you are a usenet novice.
304 If non-nil, verbose messages may be displayed and confirmations may be
307 (defvar gnus-expert-user nil
308 "*Non-nil means that you will never be asked for confirmation about anything.
309 And that means *anything*.")
311 (defvar gnus-verbose 7
312 "*Integer that says how verbose Gnus should be.
313 The higher the number, the more messages Gnus will flash to say what
314 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
315 display most important messages; and at ten, Gnus will keep on
316 jabbering all the time.")
318 (defvar gnus-keep-same-level nil
319 "*Non-nil means that the next newsgroup after the current will be on the same level.
320 When you type, for instance, `n' after reading the last article in the
321 current newsgroup, you will go to the next newsgroup. If this variable
322 is nil, the next newsgroup will be the next from the group
324 If this variable is non-nil, Gnus will either put you in the
325 next newsgroup with the same level, or, if no such newsgroup is
326 available, the next newsgroup with the lowest possible level higher
327 than the current level.
328 If this variable is `best', Gnus will make the next newsgroup the one
329 with the best level.")
331 (defvar gnus-summary-make-false-root 'adopt
332 "*nil means that Gnus won't gather loose threads.
333 If the root of a thread has expired or been read in a previous
334 session, the information necessary to build a complete thread has been
335 lost. Instead of having many small sub-threads from this original thread
336 scattered all over the summary buffer, Gnus can gather them.
338 If non-nil, Gnus will try to gather all loose sub-threads from an
339 original thread into one large thread.
341 If this variable is non-nil, it should be one of `none', `adopt',
344 If this variable is `none', Gnus will not make a false root, but just
345 present the sub-threads after another.
346 If this variable is `dummy', Gnus will create a dummy root that will
347 have all the sub-threads as children.
348 If this variable is `adopt', Gnus will make one of the \"children\"
349 the parent and mark all the step-children as such.
350 If this variable is `empty', the \"children\" are printed with empty
351 subject fields. (Or rather, they will be printed with a string
352 given by the `gnus-summary-same-subject' variable.)")
354 (defvar gnus-summary-gather-subject-limit nil
355 "*Maximum length of subject comparisons when gathering loose threads.
356 Use nil to compare full subjects. Setting this variable to a low
357 number will help gather threads that have been corrupted by
358 newsreaders chopping off subject lines, but it might also mean that
359 unrelated articles that have subject that happen to begin with the
360 same few characters will be incorrectly gathered.
362 If this variable is `fuzzy', Gnus will use a fuzzy algortihm when
363 comparing subjects.")
365 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
366 (defvar gnus-summary-same-subject ""
367 "*String indicating that the current article has the same subject as the previous.
368 This variable will only be used if the value of
369 `gnus-summary-make-false-root' is `empty'.")
371 (defvar gnus-summary-goto-unread nil
372 "*If non-nil, marking commands will go to the next unread article.")
374 (defvar gnus-group-goto-unread t
375 "*If non-nil, movement commands will go to the next unread and subscribed group.")
377 (defvar gnus-check-new-newsgroups t
378 "*Non-nil means that Gnus will add new newsgroups at startup.
379 If this variable is `ask-server', Gnus will ask the server for new
380 groups since the last time it checked. This means that the killed list
381 is no longer necessary, so you could set `gnus-save-killed-list' to
384 A variant is to have this variable be a list of select methods. Gnus
385 will then use the `ask-server' method on all these select methods to
386 query for new groups from all those servers.
389 (setq gnus-check-new-newsgroups
390 '((nntp \"some.server\") (nntp \"other.server\")))
392 If this variable is nil, then you have to tell Gnus explicitly to
393 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
395 (defvar gnus-check-bogus-newsgroups nil
396 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
397 If this variable is nil, then you have to tell Gnus explicitly to
398 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
400 (defvar gnus-read-active-file t
401 "*Non-nil means that Gnus will read the entire active file at startup.
402 If this variable is nil, Gnus will only know about the groups in your
405 If this variable is `some', Gnus will try to only read the relevant
406 parts of the active file from the server. Not all servers support
407 this, and it might be quite slow with other servers, but this should
408 generally be faster than both the t and nil value.
410 If you set this variable to nil or `some', you probably still want to
411 be told about new newsgroups that arrive. To do that, set
412 `gnus-check-new-newsgroups' to `ask-server'. This may not work
413 properly with all servers.")
415 (defvar gnus-level-subscribed 5
416 "*Groups with levels less than or equal to this variable are subscribed.")
418 (defvar gnus-level-unsubscribed 7
419 "*Groups with levels less than or equal to this variable are unsubscribed.
420 Groups with levels less than `gnus-level-subscribed', which should be
421 less than this variable, are subscribed.")
423 (defvar gnus-level-zombie 8
424 "*Groups with this level are zombie groups.")
426 (defvar gnus-level-killed 9
427 "*Groups with this level are killed.")
429 (defvar gnus-level-default-subscribed 3
430 "*New subscribed groups will be subscribed at this level.")
432 (defvar gnus-level-default-unsubscribed 6
433 "*New unsubscribed groups will be unsubscribed at this level.")
435 (defvar gnus-activate-foreign-newsgroups nil
436 "*If nil, Gnus will not check foreign newsgroups at startup.
437 If it is non-nil, it should be a number between one and nine. Foreign
438 newsgroups that have a level lower or equal to this number will be
439 activated on startup. For instance, if you want to active all
440 subscribed newsgroups, but not the rest, you'd set this variable to
441 `gnus-level-subscribed'.
443 If you subscribe to lots of newsgroups from different servers, startup
444 might take a while. By setting this variable to nil, you'll save time,
445 but you won't be told how many unread articles there are in the
448 (defvar gnus-save-newsrc-file t
449 "*Non-nil means that Gnus will save the `.newsrc' file.
450 Gnus always saves its own startup file, which is called
451 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
452 be readily understood by other newsreaders. If you don't plan on
453 using other newsreaders, set this variable to nil to save some time on
456 (defvar gnus-save-killed-list t
457 "*If non-nil, save the list of killed groups to the startup file.
458 This will save both time (when starting and quitting) and space (both
459 memory and disk), but it will also mean that Gnus has no record of
460 which groups are new and which are old, so the automatic new
461 newsgroups subscription methods become meaningless. You should always
462 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
465 (defvar gnus-interactive-catchup t
466 "*If non-nil, require your confirmation when catching up a group.")
468 (defvar gnus-interactive-post t
469 "*If non-nil, group name will be asked for when posting.")
471 (defvar gnus-interactive-exit t
472 "*If non-nil, require your confirmation when exiting Gnus.")
474 (defvar gnus-kill-killed nil
475 "*If non-nil, Gnus will apply kill files to already killed articles.
476 If it is nil, Gnus will never apply kill files to articles that have
477 already been through the scoring process, which might very well save lots
480 (defvar gnus-extract-address-components 'gnus-extract-address-components
481 "*Function for extracting address components from a From header.
482 Two pre-defined function exist: `gnus-extract-address-components',
483 which is the default, quite fast, and too simplistic solution, and
484 `mail-extract-address-components', which works much better, but is
487 (defvar gnus-summary-default-score 0
488 "*Default article score level.
489 If this variable is nil, scoring will be disabled.")
491 (defvar gnus-group-default-list-level gnus-level-subscribed
492 "*Default listing level.
493 Ignored if `gnus-group-use-permanent-levels' is nil.")
495 (defvar gnus-group-use-permanent-levels nil
496 "*If non-nil, once you set a level, Gnus will use this level.")
498 (defvar gnus-show-mime nil
499 "*If non-ni, do mime processing of articles.
500 The articles will simply be fed to the function given by
501 `gnus-show-mime-method'.")
503 (defvar gnus-show-mime-method (function metamail-buffer)
504 "*Function to process a MIME message.
505 The function is called from the article buffer.")
507 (defvar gnus-show-threads t
508 "*If non-nil, display threads in summary mode.")
510 (defvar gnus-thread-hide-subtree nil
511 "*If non-nil, hide all threads initially.
512 If threads are hidden, you have to run the command
513 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
514 to expose hidden threads.")
516 (defvar gnus-thread-hide-killed t
517 "*If non-nil, hide killed threads automatically.")
519 (defvar gnus-thread-ignore-subject nil
520 "*If non-nil, ignore subjects and do all threading based on the Reference header.
521 If nil, which is the default, articles that have different subjects
522 from their parents will start separate threads.")
524 (defvar gnus-thread-indent-level 4
525 "*Number that says how much each sub-thread should be indented.")
527 (defvar gnus-ignored-newsgroups ""
528 "*A regexp to match uninteresting newsgroups in the active file.
529 Any lines in the active file matching this regular expression are
530 removed from the newsgroup list before anything else is done to it,
531 thus making them effectively non-existant.")
533 (defvar gnus-ignored-headers
534 "^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:"
535 "*All headers that match this regexp will be hidden.
536 Also see `gnus-visible-headers'.")
538 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
539 "*All headers that do not match this regexp will be hidden.
540 Also see `gnus-ignored-headers'.")
542 (defvar gnus-sorted-header-list
543 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
544 "^Cc:" "^Date:" "^Organization:")
545 "*This variable is a list of regular expressions.
546 If it is non-nil, headers that match the regular expressions will
547 be placed first in the article buffer in the sequence specified by
550 (defvar gnus-show-all-headers nil
551 "*If non-nil, don't hide any headers.")
553 (defvar gnus-save-all-headers t
554 "*If non-nil, don't remove any headers before saving.")
556 (defvar gnus-inhibit-startup-message nil
557 "*If non-nil, the startup message will not be displayed.")
559 (defvar gnus-auto-extend-newsgroup t
560 "*If non-nil, extend newsgroup forward and backward when requested.")
562 (defvar gnus-auto-select-first t
563 "*If non-nil, select the first unread article when entering a group.
564 If you want to prevent automatic selection of the first unread article
565 in some newsgroups, set the variable to nil in
566 `gnus-select-group-hook'.")
568 (defvar gnus-auto-select-next t
569 "*If non-nil, offer to go to the next group from the end of the previous.
570 If the value is t and the next newsgroup is empty, Gnus will exit
571 summary mode and go back to group mode. If the value is neither nil
572 nor t, Gnus will select the following unread newsgroup. In
573 particular, if the value is the symbol `quietly', the next unread
574 newsgroup will be selected without any confirmations.")
576 (defvar gnus-auto-select-same nil
577 "*If non-nil, select the next article with the same subject.")
579 (defvar gnus-summary-check-current nil
580 "*If non-nil, consider the current article when moving.
581 The \"unread\" movement commands will stay on the same line if the
582 current article is unread.")
584 (defvar gnus-auto-center-summary t
585 "*If non-nil, always center the current summary buffer.")
587 (defvar gnus-break-pages t
588 "*If non-nil, do page breaking on articles.
589 The page delimiter is specified by the `gnus-page-delimiter'
592 (defvar gnus-page-delimiter "^\^L"
593 "*Regexp describing what to use as article page delimiters.
594 The default value is \"^\^L\", which is a form linefeed at the
595 beginning of a line.")
597 (defvar gnus-use-full-window t
598 "*If non-nil, use the entire Emacs screen.")
600 (defvar gnus-window-configuration nil
601 "Obsolete variable. See `gnus-buffer-configuration'.")
603 (defvar gnus-buffer-configuration
604 '((group ([group 1.0 point]
605 (if gnus-carpal [group-carpal 4])))
606 (summary ([summary 1.0 point]
607 (if gnus-carpal [summary-carpal 4])))
608 (article ([summary 0.25 point]
609 (if gnus-carpal [summary-carpal 4])
611 (server ([server 1.0 point]
612 (if gnus-carpal [server-carpal 2])))
613 (browse ([browse 1.0 point]
614 (if gnus-carpal [browse-carpal 2])))
615 (group-mail ([mail 1.0 point]))
616 (summary-mail ([mail 1.0 point]))
617 (summary-reply ([article 0.5]
619 (info ([nil 1.0 point]))
620 (summary-faq ([summary 0.25]
621 [article 1.0 point]))
622 (edit-group ([group 0.5]
623 [edit-group 1.0 point]))
624 (edit-server ([server 0.5]
625 [edit-server 1.0 point]))
626 (post ([post 1.0 point]))
627 (reply ([article 0.5]
629 (mail-forward ([mail 1.0 point]))
630 (post-forward ([post 1.0 point]))
631 (reply-yank ([mail 1.0 point]))
632 (followup ([article 0.5]
634 (followup-yank ([post 1.0 point])))
635 "Window configuration for all possible Gnus buffers.
636 This variable is a list of lists. Each of these lists has a NAME and
637 a RULE. The NAMEs are commonsense names like `group', which names a
638 rule used when displaying the group buffer; `summary', which names a
639 rule for what happens when you enter a group and do not display an
640 article buffer; and so on. See the value of this variable for a
641 complete list of NAMEs.
643 Each RULE is a list of vectors. The first element in this vector is
644 the name of the buffer to be displayed; the second element is the
645 percentage of the screen this buffer is to occupy (a number in the
646 0.0-0.99 range); the optional third element is `point', which should
647 be present to denote which buffer point is to go to after making this
648 buffer configuration.")
650 (defvar gnus-window-to-buffer
651 '((group . gnus-group-buffer)
652 (summary . gnus-summary-buffer)
653 (article . gnus-article-buffer)
654 (server . gnus-server-buffer)
655 (browse . "*Gnus Browse Server*")
656 (edit-group . gnus-group-edit-buffer)
657 (edit-server . gnus-server-edit-buffer)
658 (group-carpal . gnus-carpal-group-buffer)
659 (summary-carpal . gnus-carpal-summary-buffer)
660 (server-carpal . gnus-carpal-server-buffer)
661 (browse-carpal . gnus-carpal-browse-buffer)
663 (post . gnus-post-news-buffer))
664 "Mapping from short symbols to buffer names or buffer variables.")
666 (defvar gnus-carpal nil
667 "*If non-nil, display clickable icons.")
669 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
670 "*Function called with a group name when new group is detected.
671 A few pre-made functions are supplied: `gnus-subscribe-randomly'
672 inserts new groups at the beginning of the list of groups;
673 `gnus-subscribe-alphabetically' inserts new groups in strict
674 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
675 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
678 ;; Suggested by a bug report by Hallvard B Furuseth.
679 ;; <h.b.furuseth@usit.uio.no>.
680 (defvar gnus-subscribe-options-newsgroup-method
681 (function gnus-subscribe-alphabetically)
682 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
683 If, for instance, you want to subscribe to all newsgroups in the
684 \"no\" and \"alt\" hierarchies, you'd put the following in your
687 options -n no.all alt.all
689 Gnus will the subscribe all new newsgroups in these hierarchies with
690 the subscription method in this variable.")
692 (defvar gnus-subscribe-hierarchical-interactive nil
693 "*If non-nil, Gnus will offer to subscribe hierarchically.
694 When a new hierarchy appears, Gnus will ask the user:
696 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
698 If the user pressed `d', Gnus will descend the hierarchy, `y' will
699 subscribe to all newsgroups in the hierarchy and `s' will skip this
700 hierarchy in its entirety.")
702 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
703 "*Function used for sorting the group buffer.
704 This function will be called with group info entries as the arguments
705 for the groups to be sorted. Pre-made functions include
706 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
707 `gnus-sort-by-level'")
709 ;; Mark variables suggested by Thomas Michanek
710 ;; <Thomas.Michanek@telelogic.se>.
711 (defvar gnus-unread-mark ?
712 "*Mark used for unread articles.")
713 (defvar gnus-ticked-mark ?!
714 "*Mark used for ticked articles.")
715 (defvar gnus-dormant-mark ??
716 "*Mark used for dormant articles.")
717 (defvar gnus-del-mark ?D
718 "*Mark used for del'd articles.")
719 (defvar gnus-read-mark ?d
720 "*Mark used for read articles.")
721 (defvar gnus-expirable-mark ?E
722 "*Mark used for expirable articles.")
723 (defvar gnus-killed-mark ?K
724 "*Mark used for killed articles.")
725 (defvar gnus-kill-file-mark ?X
726 "*Mark used for articles killed by kill files.")
727 (defvar gnus-low-score-mark ?Y
728 "*Mark used for articles with a low score.")
729 (defvar gnus-catchup-mark ?C
730 "*Mark used for articles that are caught up.")
731 (defvar gnus-replied-mark ?R
732 "*Mark used for articles that have been replied to.")
733 (defvar gnus-process-mark ?#
735 (defvar gnus-ancient-mark ?A
736 "*Mark used for ancient articles.")
737 (defvar gnus-canceled-mark ?G
738 "*Mark used for cancelled articles.")
739 (defvar gnus-score-over-mark ?+
740 "*Score mark used for articles with high scores.")
741 (defvar gnus-score-below-mark ?-
742 "*Score mark used for articles with low scores.")
743 (defvar gnus-empty-thread-mark ?
744 "*There is no thread under the article.")
745 (defvar gnus-not-empty-thread-mark ?=
746 "*There is a thread under the article.")
748 (defvar gnus-view-pseudo-asynchronously nil
749 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
751 (defvar gnus-view-pseudos nil
752 "*If `automatic', pseudo-articles will be viewed automatically.
753 If `not-confirm', pseudos will be viewed automatically, and the user
754 will not be asked to confirm the command.")
756 (defvar gnus-view-pseudos-separately t
757 "*If non-nil, one pseudo-article will be created for each file to be viewed.
758 If nil, all files that use the same viewing command will be given as a
759 list of parameters to that command.")
761 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
762 "*Format of group lines.
763 It works along the same lines as a normal formatting string,
764 with some simple extensions.
766 %M Only marked articles (character, \"*\" or \" \")
767 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
768 %L Level of subscribedness (integer)
769 %N Number of unread articles (integer)
770 %I Number of dormant articles (integer)
771 %i Number of ticked and dormant (integer)
772 %T Number of ticked articles (integer)
773 %R Number of read articles (integer)
774 %t Total number of articles (integer)
775 %y Number of unread, unticked articles (integer)
776 %G Group name (string)
777 %g Qualified group name (string)
778 %D Group description (string)
779 %s Select method (string)
780 %o Moderated group (char, \"m\")
781 %O Moderated group (string, \"(m)\" or \"\")
782 %n Select from where (string)
783 %z A string that look like `<%s:%n>' if a foreign select method is used
784 %u User defined specifier. The next character in the format string should
785 be a letter. Gnus will call the function gnus-user-format-function-X,
786 where X is the letter following %u. The function will be passed the
787 current header as argument. The function should return a string, which
788 will be inserted into the buffer just like information from any other
791 Text between %( and %) will be highlighted with `gnus-mouse-face' when
792 the mouse point move inside the area. There can only be one such area.
794 Note that this format specification is not always respected. For
795 reasons of efficiency, when listing killed groups, this specification
796 is ignored altogether. If the spec is changed considerably, your
797 output may end up looking strange when listing both alive and killed
800 If you use %o or %O, reading the active file will be slower and quite
801 a bit of extra memory will be used. %D will also worsen performance.
802 Also note that if you change the format specification to include any
803 of these specs, you must probably re-start Gnus to see them go into
806 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
807 "*The format specification of the lines in the summary buffer.
809 It works along the same lines as a normal formatting string,
810 with some simple extensions.
812 %N Article number, left padded with spaces (string)
814 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
815 %n Name of the poster (string)
816 %A Address of the poster (string)
817 %F Contents of the From: header (string)
818 %x Contents of the Xref: header (string)
819 %D Date of the article (string)
820 %d Date of the article (string) in DD-MMM format
821 %M Message-id of the article (string)
822 %r References of the article (string)
823 %c Number of characters in the article (integer)
824 %L Number of lines in the article (integer)
825 %I Indentation based on thread level (a string of spaces)
826 %T A string with two possible values: 80 spaces if the article
827 is on thread level two or larger and 0 spaces on level one
828 %R \"R\" if this article has been replied to, \" \" otherwise (character)
829 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
830 %[ Opening bracket (character, \"[\" or \"<\")
831 %] Closing bracket (character, \"]\" or \">\")
832 %> Spaces of length thread-level (string)
833 %< Spaces of length (- 20 thread-level) (string)
834 %i Article score (number)
835 %z Article zcore (character)
836 %t Number of articles under the current thread (number).
837 %e Whether the thread is empty or not (character).
838 %u User defined specifier. The next character in the format string should
839 be a letter. Gnus will call the function gnus-user-format-function-X,
840 where X is the letter following %u. The function will be passed the
841 current header as argument. The function should return a string, which
842 will be inserted into the summary just like information from any other
845 Text between %( and %) will be highlighted with `gnus-mouse-face'
846 when the mouse point is placed inside the area. There can only be one
849 The %U (status), %R (replied) and %z (zcore) specs have to be handled
850 with care. For reasons of efficiency, Gnus will compute what column
851 these characters will end up in, and \"hard-code\" that. This means that
852 it is illegal to have these specs after a variable-length spec. Well,
853 you might not be arrested, but your summary buffer will look strange,
856 The smart choice is to have these specs as for to the left as
859 This restriction may disappear in later versions of Gnus.")
861 (defvar gnus-summary-dummy-line-format "* : : %S\n"
862 "*The format specification for the dummy roots in the summary buffer.
863 It works along the same lines as a normal formatting string,
864 with some simple extensions.
868 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
869 "*The format specification for the summary mode line.")
871 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
872 "*The format specification for the article mode line.")
874 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
875 "*The format specification for the group mode line.")
877 (defvar gnus-valid-select-methods
878 '(("nntp" post address prompt-address)
880 ("nnvirtual" none virtual prompt-address)
881 ("nnmbox" mail respool)
882 ("nnml" mail respool)
883 ("nnmh" mail respool)
884 ("nndir" none prompt-address address)
886 ("nndoc" none prompt-address)
887 ("nnbabyl" mail respool)
888 ("nnkiboze" none virtual)
889 ("nnfolder" mail respool))
890 "An alist of valid select methods.
891 The first element of each list lists should be a string with the name
892 of the select method. The other elements may be be the category of
893 this method (ie. `post', `mail', `none' or whatever) or other
894 properties that this method has (like being respoolable).
895 If you implement a new select method, all you should have to change is
896 this variable. I think.")
898 (defvar gnus-updated-mode-lines '(group article summary)
899 "*List of buffers that should update their mode lines.
900 The list may contain the symbols `group', `article' and `summary'. If
901 the corresponding symbol is present, Gnus will keep that mode line
902 updated with information that may be pertinent.
903 If this variable is nil, screen refresh may be quicker.")
905 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
906 (defvar gnus-mode-non-string-length 21
907 "*Max length of mode-line non-string contents.
908 If this is nil, Gnus will take space as is needed, leaving the rest
909 of the modeline intact.")
911 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
912 (defvar gnus-mouse-face 'highlight
913 "*Face used for mouse highlighting in Gnus.
914 No mouse highlights will be done if `gnus-visual' is nil.")
916 (defvar gnus-summary-mark-below nil
917 "*Mark all articles with a score below this variable as read.
918 This variable is local to each summary buffer and usually set by the
921 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
922 "*List of functions used for sorting threads in the summary buffer.
923 By default, threads are sorted by article number.
925 Each function takes two threads and return non-nil if the first thread
926 should be sorted before the other. If you use more than one function,
927 the primary sort function should be the last.
929 Ready-mady functions include `gnus-thread-sort-by-number',
930 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
931 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
932 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
934 (defvar gnus-thread-score-function '+
935 "*Function used for calculating the total score of a thread.
937 The function is called with the scores of the article and each
938 subthread and should then return the score of the thread.
940 Some functions you can use are `+', `max', or `min'.")
942 (defvar gnus-options-subscribe nil
943 "*All new groups matching this regexp will be subscribed unconditionally.
944 Note that this variable deals only with new newsgroups. This variable
945 does not affect old newsgroups.")
947 (defvar gnus-options-not-subscribe nil
948 "*All new groups matching this regexp will be ignored.
949 Note that this variable deals only with new newsgroups. This variable
950 does not affect old (already subscribed) newsgroups.")
952 (defvar gnus-auto-expirable-newsgroups nil
953 "*Groups in which to automatically mark read articles as expirable.
954 If non-nil, this should be a regexp that should match all groups in
955 which to perform auto-expiry. This only makes sense for mail groups.")
957 (defvar gnus-hidden-properties '(invisible t intangible t)
958 "Property list to use for hiding text.")
962 (defvar gnus-group-mode-hook nil
963 "*A hook for Gnus group mode.")
965 (defvar gnus-summary-mode-hook nil
966 "*A hook for Gnus summary mode.")
968 (defvar gnus-article-mode-hook nil
969 "*A hook for Gnus article mode.")
971 (defvar gnus-open-server-hook nil
972 "*A hook called just before opening connection to the news server.")
974 (defvar gnus-startup-hook nil
975 "*A hook called at startup.
976 This hook is called after Gnus is connected to the NNTP server.")
978 (defvar gnus-get-new-news-hook nil
979 "*A hook run just before Gnus checks for new news.")
981 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
982 "*A function that is called to generate the group buffer.
983 The function is called with three arguments: The first is a number;
984 all group with a level less or equal to that number should be listed,
985 if the second is non-nil, empty groups should also be displayed. If
986 the third is non-nil, it is a number. No groups with a level lower
987 than this number should be displayed.
989 The only current function implemented is `gnus-group-prepare-flat'.")
991 (defvar gnus-group-prepare-hook nil
992 "*A hook called after the group buffer has been generated.
993 If you want to modify the group buffer, you can use this hook.")
995 (defvar gnus-summary-prepare-hook nil
996 "*A hook called after the summary buffer has been generated.
997 If you want to modify the summary buffer, you can use this hook.")
999 (defvar gnus-article-prepare-hook nil
1000 "*A hook called after an article has been prepared in the article buffer.
1001 If you want to run a special decoding program like nkf, use this hook.")
1003 (defvar gnus-article-display-hook nil
1004 "*A hook called after the article is displayed in the article buffer.
1005 The hook is designed to change the contents of the article
1006 buffer. Typical functions that this hook may contain are
1007 `gnus-article-hide-headers' (hide selected headers),
1008 `gnus-article-maybe-highlight' (perform fancy article highlighting),
1009 `gnus-article-hide-signature' (hide signature) and
1010 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1011 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1012 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1014 (defvar gnus-article-x-face-command
1015 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1016 "String or function to be executed to display an X-Face header.
1017 If it is a string, the command will be executed in a sub-shell
1018 asynchronously. The compressed face will be piped to this command.")
1020 (defvar gnus-article-x-face-too-ugly nil
1021 "Regexp matching posters whose face shouldn't be shown automatically.")
1023 (defvar gnus-select-group-hook nil
1024 "*A hook called when a newsgroup is selected.
1026 If you'd like to simplify subjects like the
1027 `gnus-summary-next-same-subject' command does, you can use the
1030 (setq gnus-select-group-hook
1033 (mapcar (lambda (header)
1036 (gnus-simplify-subject
1037 (header-subject header) 're-only)))
1038 gnus-newsgroup-headers))))")
1040 (defvar gnus-select-article-hook
1041 '(gnus-summary-show-thread)
1042 "*A hook called when an article is selected.
1043 The default hook shows conversation thread subtrees of the selected
1044 article automatically using `gnus-summary-show-thread'.")
1046 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1047 "*A hook called to apply kill files to a group.
1048 This hook is intended to apply a kill file to the selected newsgroup.
1049 The function `gnus-apply-kill-file' is called by default.
1051 Since a general kill file is too heavy to use only for a few
1052 newsgroups, I recommend you to use a lighter hook function. For
1053 example, if you'd like to apply a kill file to articles which contains
1054 a string `rmgroup' in subject in newsgroup `control', you can use the
1057 \(setq gnus-apply-kill-hook
1060 (cond ((string-match \"control\" gnus-newsgroup-name)
1061 (gnus-kill \"Subject\" \"rmgroup\")
1062 (gnus-expunge \"X\"))))))")
1064 (defvar gnus-visual-mark-article-hook
1065 (list 'gnus-highlight-selected-summary)
1066 "*Hook run after selecting an article in the summary buffer.
1067 It is meant to be used for highlighting the article in some way. It
1068 is not run if `gnus-visual' is nil.")
1070 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1071 "*A hook called after preparing body, but before preparing header headers.
1072 The default hook (`gnus-inews-insert-signature') inserts a signature
1073 file specified by the variable `gnus-signature-file'.")
1075 (defvar gnus-exit-group-hook nil
1076 "*A hook called when exiting (not quitting) summary mode.")
1078 (defvar gnus-suspend-gnus-hook nil
1079 "*A hook called when suspending (not exiting) Gnus.")
1081 (defvar gnus-exit-gnus-hook nil
1082 "*A hook called when exiting Gnus.")
1084 (defvar gnus-save-newsrc-hook nil
1085 "*A hook called when saving the newsrc file.")
1087 (defvar gnus-summary-update-hook
1088 (list 'gnus-summary-highlight-line)
1089 "*A hook called when a summary line is changed.
1090 The hook will not be called if `gnus-visual' is nil.
1092 The default function `gnus-summary-highlight-line' will
1093 highlight the line according to the `gnus-summary-highlight'
1096 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1097 "*A hook called when an article is selected for the first time.
1098 The hook is intended to mark an article as read (or unread)
1099 automatically when it is selected.")
1102 ;; Internal variables
1104 ;; Avoid highlighting in kill files.
1105 (defvar gnus-summary-inhibit-highlight nil)
1106 (defvar gnus-newsgroup-selected-overlay nil)
1108 (defvar gnus-article-mode-map nil)
1109 (defvar caesar-translate-table nil)
1110 (defvar gnus-dribble-buffer nil)
1111 (defvar gnus-headers-retrieved-by nil)
1112 (defvar gnus-article-reply nil)
1113 (defvar gnus-override-method nil)
1114 (defvar gnus-article-check-size nil)
1116 (defvar gnus-current-score-file nil)
1117 (defvar gnus-current-move-group nil)
1119 (defvar gnus-newsgroup-dependencies nil)
1120 (defvar gnus-newsgroup-threads nil)
1121 (defvar gnus-newsgroup-async nil)
1122 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1124 (defvar gnus-newsgroup-adaptive nil)
1126 (defvar gnus-summary-display-table nil)
1128 (defconst gnus-group-line-format-alist
1129 (list (list ?M 'marked ?c)
1130 (list ?S 'subscribed ?c)
1132 (list ?N 'number ?s)
1133 (list ?I 'number-of-dormant ?d)
1134 (list ?T 'number-of-ticked ?d)
1135 (list ?R 'number-of-read ?s)
1136 (list ?t 'number-total ?d)
1137 (list ?y 'number-of-unread-unticked ?s)
1138 (list ?i 'number-of-ticked-and-dormant ?d)
1140 (list ?G 'qualified-group ?s)
1141 (list ?D 'newsgroup-description ?s)
1142 (list ?o 'moderated ?c)
1143 (list ?O 'moderated-string ?s)
1144 (list ?s 'news-server ?s)
1145 (list ?n 'news-method ?s)
1146 (list ?z 'news-method-string ?s)
1147 (list ?u 'user-defined ?s)))
1149 (defconst gnus-summary-line-format-alist
1150 (list (list ?N 'number ?d)
1151 (list ?S 'subject ?s)
1152 (list ?s 'subject-or-nil ?s)
1154 (list ?A 'address ?s)
1156 (list ?x (macroexpand '(header-xref header)) ?s)
1157 (list ?D (macroexpand '(header-date header)) ?s)
1158 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1159 (list ?M (macroexpand '(header-id header)) ?s)
1160 (list ?r (macroexpand '(header-references header)) ?s)
1161 (list ?c '(or (header-chars header) 0) ?d)
1163 (list ?I 'indentation ?s)
1164 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1165 (list ?R 'replied ?c)
1166 (list ?\[ 'opening-bracket ?c)
1167 (list ?\] 'closing-bracket ?c)
1168 (list ?\> '(make-string level ? ) ?s)
1169 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1171 (list ?z 'score-char ?c)
1172 (list ?U 'unread ?c)
1173 (list ?t '(gnus-summary-number-of-articles-in-thread
1174 (or (prog1 gnus-tmp-adopt-thread
1175 (setq gnus-tmp-adopt-thread nil))
1176 (if (boundp 'thread) (symbol-value 'thread)
1179 (list ?e '(gnus-summary-number-of-articles-in-thread
1180 (or gnus-tmp-adopt-thread
1181 (if (boundp 'thread) (symbol-value 'thread)
1184 (list ?u 'user-defined ?s))
1185 "An alist of format specifications that can appear in summary lines,
1186 and what variables they correspond with, along with the type of the
1187 variable (string, integer, character, etc).")
1189 (defconst gnus-summary-dummy-line-format-alist
1190 (list (list ?S 'subject ?s)
1191 (list ?N 'number ?d)
1192 (list ?u 'user-defined ?s)))
1194 (defconst gnus-summary-mode-line-format-alist
1195 (list (list ?G 'group-name ?s)
1196 (list ?g '(gnus-short-group-name group-name) ?s)
1197 (list ?A 'article-number ?d)
1198 (list ?Z 'unread-and-unselected ?s)
1199 (list ?V 'gnus-version ?s)
1200 (list ?U 'unread ?d)
1201 (list ?S 'subject ?s)
1202 (list ?e 'unselected ?d)
1203 (list ?u 'user-defined ?s)
1204 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1206 (defconst gnus-group-mode-line-format-alist
1207 (list (list ?S 'news-server ?s)
1208 (list ?M 'news-method ?s)
1209 (list ?u 'user-defined ?s)))
1211 (defvar gnus-have-read-active-file nil)
1213 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls & Boys)"
1214 "The mail address of the Gnus maintainer.")
1216 (defconst gnus-version "(ding) Gnus v0.75"
1217 "Version number for this version of Gnus.")
1219 (defvar gnus-info-nodes
1220 '((gnus-group-mode "(gnus)The Group Buffer")
1221 (gnus-summary-mode "(gnus)The Summary Buffer")
1222 (gnus-article-mode "(gnus)The Article Buffer"))
1223 "Assoc list of major modes and related Info nodes.")
1225 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1226 "The location of the (ding) Gnus documentation group.")
1228 (defvar gnus-group-buffer "*Group*")
1229 (defvar gnus-summary-buffer "*Summary*")
1230 (defvar gnus-article-buffer "*Article*")
1231 (defvar gnus-server-buffer "*Server*")
1233 (defvar gnus-work-buffer " *gnus work*")
1235 (defvar gnus-buffer-list nil
1236 "Gnus buffers that should be killed on exit.")
1238 (defvar gnus-server-alist nil
1239 "List of available servers.")
1241 (defvar gnus-variable-list
1242 '(gnus-newsrc-options gnus-newsrc-options-n
1243 gnus-newsrc-last-checked-date
1244 gnus-newsrc-alist gnus-server-alist
1245 gnus-killed-list gnus-zombie-list)
1246 "Gnus variables saved in the quick startup file.")
1248 (defvar gnus-overload-functions
1249 '((news-inews gnus-inews-news "rnewspost")
1250 (caesar-region gnus-caesar-region "rnews"))
1251 "Functions overloaded by gnus.
1252 It is a list of `(original overload &optional file)'.")
1254 (defvar gnus-newsrc-options nil
1255 "Options line in the .newsrc file.")
1257 (defvar gnus-newsrc-options-n nil
1258 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1260 (defvar gnus-newsrc-last-checked-date nil
1261 "Date Gnus last asked server for new newsgroups.")
1263 (defvar gnus-newsrc-alist nil
1264 "Assoc list of read articles.
1265 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1267 (defvar gnus-newsrc-hashtb nil
1268 "Hashtable of gnus-newsrc-alist.")
1270 (defvar gnus-killed-list nil
1271 "List of killed newsgroups.")
1273 (defvar gnus-killed-hashtb nil
1274 "Hash table equivalent of gnus-killed-list.")
1276 (defvar gnus-zombie-list nil
1277 "List of almost dead newsgroups.")
1279 (defvar gnus-description-hashtb nil
1280 "Descriptions of newsgroups.")
1282 (defvar gnus-list-of-killed-groups nil
1283 "List of newsgroups that have recently been killed by the user.")
1285 (defvar gnus-active-hashtb nil
1286 "Hashtable of active articles.")
1288 (defvar gnus-moderated-list nil
1289 "List of moderated newsgroups.")
1291 (defvar gnus-group-marked nil)
1293 (defvar gnus-current-startup-file nil
1294 "Startup file for the current host.")
1296 (defvar gnus-last-search-regexp nil
1297 "Default regexp for article search command.")
1299 (defvar gnus-last-shell-command nil
1300 "Default shell command on article.")
1302 (defvar gnus-current-select-method nil
1303 "The current method for selecting a newsgroup.")
1305 (defvar gnus-have-all-newsgroups nil)
1307 (defvar gnus-article-internal-prepare-hook nil)
1309 (defvar gnus-newsgroup-name nil)
1310 (defvar gnus-newsgroup-begin nil)
1311 (defvar gnus-newsgroup-end nil)
1312 (defvar gnus-newsgroup-last-rmail nil)
1313 (defvar gnus-newsgroup-last-mail nil)
1314 (defvar gnus-newsgroup-last-folder nil)
1315 (defvar gnus-newsgroup-last-file nil)
1316 (defvar gnus-newsgroup-auto-expire nil)
1317 (defvar gnus-newsgroup-active nil)
1319 (defvar gnus-newsgroup-unreads nil
1320 "List of unread articles in the current newsgroup.")
1322 (defvar gnus-newsgroup-unselected nil
1323 "List of unselected unread articles in the current newsgroup.")
1325 (defvar gnus-newsgroup-marked nil
1326 "List of ticked articles in the current newsgroup (a subset of unread art).")
1328 (defvar gnus-newsgroup-killed nil
1329 "List of ranges of articles that have been through the scoring process.")
1331 (defvar gnus-newsgroup-kill-headers nil)
1333 (defvar gnus-newsgroup-replied nil
1334 "List of articles that have been replied to in the current newsgroup.")
1336 (defvar gnus-newsgroup-expirable nil
1337 "List of articles in the current newsgroup that can be expired.")
1339 (defvar gnus-newsgroup-processable nil
1340 "List of articles in the current newsgroup that can be processed.")
1342 (defvar gnus-newsgroup-bookmarks nil
1343 "List of articles in the current newsgroup that have bookmarks.")
1345 (defvar gnus-newsgroup-dormant nil
1346 "List of dormant articles in the current newsgroup.")
1348 (defvar gnus-newsgroup-scored nil
1349 "List of scored articles in the current newsgroup.")
1351 (defvar gnus-newsgroup-headers nil
1352 "List of article headers in the current newsgroup.")
1353 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1355 (defvar gnus-newsgroup-ancient nil
1356 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1358 (defvar gnus-current-article nil)
1359 (defvar gnus-article-current nil)
1360 (defvar gnus-current-headers nil)
1361 (defvar gnus-have-all-headers nil)
1362 (defvar gnus-last-article nil)
1363 (defvar gnus-newsgroup-history nil)
1364 (defvar gnus-current-kill-article nil)
1366 ;; Save window configuration.
1367 (defvar gnus-prev-winconf nil)
1370 (defvar gnus-summary-line-format-spec nil)
1371 (defvar gnus-summary-dummy-line-format-spec nil)
1372 (defvar gnus-group-line-format-spec nil)
1373 (defvar gnus-summary-mode-line-format-spec nil)
1374 (defvar gnus-article-mode-line-format-spec nil)
1375 (defvar gnus-group-mode-line-format-spec nil)
1376 (defvar gnus-summary-mark-positions nil)
1378 (defvar gnus-summary-expunge-below nil)
1379 (defvar gnus-reffed-article-number nil)
1381 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1382 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1384 (defconst gnus-summary-local-variables
1385 '(gnus-newsgroup-name
1386 gnus-newsgroup-begin gnus-newsgroup-end
1387 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1388 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1389 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1390 gnus-newsgroup-unselected gnus-newsgroup-marked
1391 gnus-newsgroup-replied gnus-newsgroup-expirable
1392 gnus-newsgroup-processable gnus-newsgroup-killed
1393 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1394 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1395 gnus-current-article gnus-current-headers gnus-have-all-headers
1396 gnus-last-article gnus-article-internal-prepare-hook
1397 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1398 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1399 gnus-newsgroup-threads gnus-newsgroup-async
1400 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1401 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1402 gnus-newsgroup-history gnus-newsgroup-ancient
1403 gnus-newsgroup-adaptive)
1404 "Variables that are buffer-local to the summary buffers.")
1406 (defconst gnus-bug-message
1407 "Sending a bug report to the Gnus Towers.
1408 ========================================
1410 The buffer below is a mail buffer. When you press `C-c C-c', it will
1411 be sent to the Gnus Bug Exterminators.
1413 At the bottom of the buffer you'll see lots of variable settings.
1414 Please do not delete those. They will tell the Bug People what your
1415 environment is, so that it will be easier to locate the bugs.
1417 If you have found a bug that makes Emacs go \"beep\", set
1418 debug-on-error to t (`M-ESC (setq debug-on-error t)') and include the
1419 backtrace in your bug report.
1421 Please describe the bug in annoying, painstaking detail.
1423 Thank you for your help in stamping out bugs.
1426 ;;; End of variables.
1428 ;; Define some autoload functions Gnus might use.
1432 (autoload 'metamail-buffer "metamail")
1433 (autoload 'Info-goto-node "info")
1434 (autoload 'hexl-hex-string-to-integer "hexl")
1436 (autoload 'pp-to-string "pp")
1437 (autoload 'pp-eval-expression "pp")
1438 (autoload 'mail-extract-address-components "mail-extr")
1440 (autoload 'nnmail-split-fancy "nnmail")
1443 (autoload 'timezone-make-date-arpa-standard "timezone")
1444 (autoload 'timezone-fix-time "timezone")
1445 (autoload 'timezone-make-sortable-date "timezone")
1446 (autoload 'timezone-make-time-string "timezone")
1449 (autoload 'mail-position-on-field "sendmail")
1450 (autoload 'mail-setup "sendmail")
1451 (autoload 'rmail-output "rmailout")
1452 (autoload 'news-mail-other-window "rnewspost")
1453 (autoload 'news-reply-yank-original "rnewspost")
1454 (autoload 'news-caesar-buffer-body "rnewspost")
1455 (autoload 'rmail-insert-rmail-file-header "rmail")
1456 (autoload 'rmail-count-new-messages "rmail")
1457 (autoload 'rmail-show-message "rmail")
1460 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1461 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1462 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1463 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1464 (autoload 'gnus-Folder-save-name "gnus-mh")
1465 (autoload 'gnus-folder-save-name "gnus-mh")
1468 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1469 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1470 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1471 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1472 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1473 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1474 (autoload 'gnus-summary-highlight-line "gnus-vis")
1475 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1478 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1479 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1480 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1481 (autoload 'gnus-article-hide "gnus-vis" nil t)
1482 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1483 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1484 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1485 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1486 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1487 (autoload 'gnus-article-add-button "gnus-vis")
1490 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1491 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1492 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1495 (autoload 'gnus-kill "gnus-kill")
1496 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1497 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1498 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1499 (autoload 'gnus-execute "gnus-kill")
1500 (autoload 'gnus-expunge "gnus-kill")
1503 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1504 (autoload 'gnus-cache-save-buffers "gnus-cache")
1505 (autoload 'gnus-cache-possibly-remove-article "gnus-cache")
1506 (autoload 'gnus-cache-request-article "gnus-cache")
1507 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1508 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1509 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1512 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1513 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1514 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1515 (autoload 'gnus-score-save "gnus-score")
1516 (autoload 'gnus-score-headers "gnus-score")
1517 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1518 (autoload 'gnus-score-adaptive "gnus-score")
1519 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1520 (autoload 'gnus-possibly-score-headers "gnus-score")
1521 (autoload 'gnus-score-find-trace "gnus-score")
1524 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1525 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1526 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1527 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1528 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1529 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1530 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1531 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1532 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1533 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1534 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1535 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1536 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1537 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1538 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1539 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1542 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1543 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1544 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1545 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1546 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1547 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1548 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1549 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1550 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1551 (autoload 'gnus-post-news "gnus-msg" nil t)
1552 (autoload 'gnus-inews-news "gnus-msg" nil t)
1553 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1554 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1555 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1556 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1557 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1558 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1559 (autoload 'gnus-mail-yank-original "gnus-msg")
1560 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1561 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1562 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1563 (autoload 'gnus-article-mail-with-original "gnus-msg")
1564 (autoload 'gnus-article-mail "gnus-msg")
1567 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1568 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1569 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1570 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1571 (autoload 'gnus-yank-article "gnus-vm" nil t)
1577 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1578 ;; If you want the cursor to go somewhere else, set these two
1579 ;; functions in some startup hook to whatever you want.
1580 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1581 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1583 ;;; Various macros and substs.
1585 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1586 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1587 (` (let ((GnusStartBufferWindow (selected-window)))
1590 (pop-to-buffer (, buffer))
1592 (select-window GnusStartBufferWindow)))))
1594 (defmacro gnus-gethash (string hashtable)
1595 "Get hash value of STRING in HASHTABLE."
1596 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1597 ;;(` (abbrev-expansion (, string) (, hashtable)))
1598 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1600 (defmacro gnus-sethash (string value hashtable)
1601 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1602 ;; We cannot use define-abbrev since it only accepts string as value.
1603 ;; (set (intern string hashtable) value))
1604 (` (set (intern (, string) (, hashtable)) (, value))))
1606 (defsubst gnus-buffer-substring (beg end)
1607 (buffer-substring (match-beginning beg) (match-end end)))
1609 (defsubst gnus-simplify-subject-re (subject)
1610 "Remove \"Re:\" from subject lines."
1611 (let ((case-fold-search t))
1612 (if (string-match "^re: *" subject)
1613 (substring subject (match-end 0))
1616 (defsubst gnus-goto-char (point)
1617 (and point (goto-char point)))
1619 (defmacro gnus-buffer-exists-p (buffer)
1621 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1624 (defmacro gnus-kill-buffer (buffer)
1625 (` (if (gnus-buffer-exists-p (, buffer))
1626 (kill-buffer (, buffer)))))
1628 (defsubst gnus-point-at-bol ()
1629 "Return point at the beginning of line."
1636 (defsubst gnus-point-at-eol ()
1637 "Return point at the beginning of line."
1644 ;;; Load the compatability functions.
1650 ;;; Gnus Utility Functions
1653 (defun gnus-extract-address-components (from)
1655 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1656 (setq address (substring from (match-beginning 0) (match-end 0))))
1658 (string-match (concat "<" (regexp-quote address) ">") from)
1659 (setq name (substring from 0 (1- (match-beginning 0)))))
1661 (and (string-match "(.+)" from)
1662 (setq name (substring from (1+ (match-beginning 0))
1663 (1- (match-end 0))))))
1664 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1665 (list (or name from) (or address from))))
1667 (defun gnus-fetch-field (field)
1668 "Return the value of the header FIELD of current article."
1671 (let ((case-fold-search t))
1672 (gnus-narrow-to-headers)
1673 (mail-fetch-field field)))))
1675 (defun gnus-goto-colon ()
1677 (search-forward ":" (gnus-point-at-eol) t))
1679 (defun gnus-narrow-to-headers ()
1683 (goto-char (point-min))
1684 (if (search-forward "\n\n" nil t)
1688 (defun gnus-update-format-specifications ()
1689 (gnus-make-thread-indent-array)
1690 (setq gnus-summary-line-format-spec
1692 gnus-summary-line-format gnus-summary-line-format-alist))
1693 (gnus-update-summary-mark-positions)
1694 (setq gnus-summary-dummy-line-format-spec
1695 (gnus-parse-format gnus-summary-dummy-line-format
1696 gnus-summary-dummy-line-format-alist))
1697 (setq gnus-group-line-format-spec
1699 gnus-group-line-format
1700 gnus-group-line-format-alist))
1701 (if (and (string-match "%D" gnus-group-line-format)
1702 (not gnus-description-hashtb)
1703 gnus-read-active-file)
1704 (gnus-read-descriptions-file))
1705 (setq gnus-summary-mode-line-format-spec
1706 (gnus-parse-format gnus-summary-mode-line-format
1707 gnus-summary-mode-line-format-alist))
1708 (setq gnus-article-mode-line-format-spec
1709 (gnus-parse-format gnus-article-mode-line-format
1710 gnus-summary-mode-line-format-alist))
1711 (setq gnus-group-mode-line-format-spec
1712 (gnus-parse-format gnus-group-mode-line-format
1713 gnus-group-mode-line-format-alist)))
1715 (defun gnus-update-summary-mark-positions ()
1717 (let ((gnus-replied-mark 129)
1718 (gnus-score-below-mark 130)
1719 (gnus-score-over-mark 130)
1722 (gnus-set-work-buffer)
1723 (gnus-summary-insert-line
1724 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1725 (goto-char (point-min))
1726 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1728 (goto-char (point-min))
1729 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1730 (- (point) 2))) pos))
1731 (goto-char (point-min))
1732 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1733 (- (point) 2))) pos))
1734 (setq gnus-summary-mark-positions pos))))
1736 (defun gnus-format-max-width (form length)
1737 (let* ((val (eval form))
1738 (valstr (if (numberp val) (int-to-string val) val)))
1739 (if (> (length valstr) length)
1740 (substring valstr 0 length)
1743 (defun gnus-set-mouse-face (string)
1744 ;; Set mouse face property on STRING.
1745 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1748 (defun gnus-parse-format (format spec-alist)
1749 ;; This function parses the FORMAT string with the help of the
1750 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1751 ;; string. If the FORMAT string contains the specifiers %( and %)
1752 ;; the text between them will have the mouse-face text property.
1753 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1754 (if (and gnus-visual gnus-mouse-face)
1755 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1756 (button (substring format (match-beginning 2) (match-end 2)))
1757 (post (substring format (match-beginning 3) (match-end 3))))
1759 (gnus-parse-simple-format pre spec-alist)
1760 (list 'gnus-set-mouse-face
1761 (gnus-parse-simple-format button spec-alist))
1762 (gnus-parse-simple-format post spec-alist)))
1763 (gnus-parse-simple-format
1764 (concat (substring format (match-beginning 1) (match-end 1))
1765 (substring format (match-beginning 2) (match-end 2))
1766 (substring format (match-beginning 3) (match-end 3)))
1768 (gnus-parse-simple-format format spec-alist)))
1770 (defun gnus-parse-simple-format (format spec-alist)
1771 ;; This function parses the FORMAT string with the help of the
1772 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1773 ;; string. The list will consist of the symbol `format', a format
1774 ;; specification string, and a list of forms depending on the
1777 spec flist fstring b newspec max-width elem beg)
1779 (gnus-set-work-buffer)
1781 (goto-char (point-min))
1782 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1783 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1785 ;; First check if there are any specs that look anything like
1786 ;; "%12,12A", ie. with a "max width specification". These have
1787 ;; to be treated specially.
1788 (if (setq beg (match-beginning 1))
1791 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1793 (setq beg (match-beginning 2)))
1794 ;; Find the specification from `spec-alist'.
1795 (if (not (setq elem (cdr (assq spec spec-alist))))
1796 (setq elem '("*" ?s)))
1797 ;; Treat user defined format specifiers specially
1798 (and (eq (car elem) 'user-defined)
1801 (list (intern (concat "gnus-user-format-function-"
1807 (delete-region (match-beginning 3) (match-end 3)))
1808 (if (not (zerop max-width))
1809 (let ((el (car elem)))
1810 (cond ((= (car (cdr elem)) ?c)
1811 (setq el (list 'char-to-string el)))
1812 ((= (car (cdr elem)) ?d)
1813 (numberp el) (setq el (list 'int-to-string el))))
1814 (setq flist (cons (list 'gnus-format-max-width el max-width)
1817 (setq flist (cons (car elem) flist))
1818 (setq newspec (car (cdr elem))))
1819 ;; Remove the old specification (and possibly a ",12" string).
1820 (delete-region beg (match-end 2))
1821 ;; Insert the new specification.
1824 (setq fstring (buffer-substring 1 (point-max))))
1825 (cons 'format (cons fstring (nreverse flist)))))
1827 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1828 (defun gnus-read-init-file ()
1830 (or (and (file-exists-p gnus-init-file)
1831 ;; Don't try to load a directory.
1832 (not (file-directory-p gnus-init-file)))
1833 (file-exists-p (concat gnus-init-file ".el"))
1834 (file-exists-p (concat gnus-init-file ".elc")))
1835 (load gnus-init-file nil t)))
1837 (defun gnus-set-work-buffer ()
1838 (if (get-buffer gnus-work-buffer)
1840 (set-buffer gnus-work-buffer)
1842 (set-buffer (get-buffer-create gnus-work-buffer))
1843 (buffer-disable-undo (current-buffer))
1844 (gnus-add-current-to-buffer-list)))
1846 ;; Article file names when saving.
1848 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1849 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1850 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1851 Otherwise, it is like ~/News/news/group/num."
1854 (concat (if (gnus-use-long-file-name 'not-save)
1855 (gnus-capitalize-newsgroup newsgroup)
1856 (gnus-newsgroup-directory-form newsgroup))
1857 "/" (int-to-string (header-number headers)))
1858 (or gnus-article-save-directory "~/News"))))
1860 (string-equal (file-name-directory default)
1861 (file-name-directory last-file))
1862 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1864 (or last-file default))))
1866 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1867 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1868 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1869 Otherwise, it is like ~/News/news/group/num."
1872 (concat (if (gnus-use-long-file-name 'not-save)
1874 (gnus-newsgroup-directory-form newsgroup))
1875 "/" (int-to-string (header-number headers)))
1876 (or gnus-article-save-directory "~/News"))))
1878 (string-equal (file-name-directory default)
1879 (file-name-directory last-file))
1880 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1882 (or last-file default))))
1884 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1885 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1886 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1887 Otherwise, it is like ~/News/news/group/news."
1890 (if (gnus-use-long-file-name 'not-save)
1891 (gnus-capitalize-newsgroup newsgroup)
1892 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1893 (or gnus-article-save-directory "~/News"))))
1895 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1896 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1897 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1898 Otherwise, it is like ~/News/news/group/news."
1901 (if (gnus-use-long-file-name 'not-save)
1903 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1904 (or gnus-article-save-directory "~/News"))))
1906 ;; For subscribing new newsgroup
1908 (defun gnus-subscribe-hierarchical-interactive (groups)
1909 (let ((groups (sort groups 'string<))
1910 prefixes prefix start rest ans group starts)
1912 (setq prefixes (list "^"))
1913 (while (and groups prefixes)
1914 (while (not (string-match (car prefixes) (car groups)))
1915 (setq prefixes (cdr prefixes)))
1916 (setq prefix (car prefixes))
1917 (setq start (1- (length prefix)))
1918 (if (and (string-match "[^\\.]\\." (car groups) start)
1921 (concat "^" (substring (car groups) 0 (match-end 0))))
1922 (string-match prefix (car (cdr groups))))
1924 (setq prefixes (cons prefix prefixes))
1925 (message "Descend hierarchy %s? ([y]nsq): "
1926 (substring prefix 1 (1- (length prefix))))
1927 (setq ans (read-char))
1930 (string-match prefix
1931 (setq group (car groups))))
1932 (setq gnus-killed-list
1933 (cons group gnus-killed-list))
1934 (gnus-sethash group group gnus-killed-hashtb)
1935 (setq groups (cdr groups)))
1936 (setq starts (cdr starts)))
1939 (string-match prefix
1940 (setq group (car groups))))
1941 (gnus-sethash group group gnus-killed-hashtb)
1942 (gnus-subscribe-alphabetically (car groups))
1943 (setq groups (cdr groups)))
1944 (setq starts (cdr starts)))
1947 (setq group (car groups))
1948 (setq gnus-killed-list (cons group gnus-killed-list))
1949 (gnus-sethash group group gnus-killed-hashtb)
1950 (setq groups (cdr groups))))
1952 (message "Subscribe %s? ([n]yq)" (car groups))
1953 (setq ans (read-char))
1954 (setq group (car groups))
1956 (gnus-subscribe-alphabetically (car groups))
1957 (gnus-sethash group group gnus-killed-hashtb))
1960 (setq group (car groups))
1961 (setq gnus-killed-list (cons group gnus-killed-list))
1962 (gnus-sethash group group gnus-killed-hashtb)
1963 (setq groups (cdr groups))))
1965 (setq gnus-killed-list (cons group gnus-killed-list))
1966 (gnus-sethash group group gnus-killed-hashtb)))
1967 (setq groups (cdr groups)))))))
1969 (defun gnus-subscribe-randomly (newsgroup)
1970 "Subscribe new NEWSGROUP by making it the first newsgroup."
1971 (gnus-subscribe-newsgroup newsgroup))
1973 (defun gnus-subscribe-alphabetically (newgroup)
1974 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1975 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1976 (let ((groups (cdr gnus-newsrc-alist))
1978 (while (and (not before) groups)
1979 (if (string< newgroup (car (car groups)))
1980 (setq before (car (car groups)))
1981 (setq groups (cdr groups))))
1982 (gnus-subscribe-newsgroup newgroup before)))
1984 (defun gnus-subscribe-hierarchically (newgroup)
1985 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
1986 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1988 (set-buffer (find-file-noselect gnus-current-startup-file))
1989 (let ((groupkey newgroup)
1991 (while (and (not before) groupkey)
1992 (goto-char (point-min))
1994 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
1995 (while (and (re-search-forward groupkey-re nil t)
1997 (setq before (buffer-substring
1998 (match-beginning 1) (match-end 1)))
1999 (string< before newgroup)))))
2000 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2002 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2003 (substring groupkey (match-beginning 1) (match-end 1)))))
2004 (gnus-subscribe-newsgroup newgroup before))))
2006 (defun gnus-subscribe-interactively (newsgroup)
2007 "Subscribe new NEWSGROUP interactively.
2008 It is inserted in hierarchical newsgroup order if subscribed. If not,
2010 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2011 (gnus-subscribe-hierarchically newsgroup)
2012 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2014 (defun gnus-subscribe-zombies (newsgroup)
2015 "Make new NEWSGROUP a zombie group."
2016 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2018 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2019 "Subscribe new NEWSGROUP.
2020 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2021 the first newsgroup."
2022 ;; We subscribe the group by changing its level to `subscribed'.
2023 (gnus-group-change-level
2024 newsgroup gnus-level-default-subscribed
2025 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2026 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2030 (defun gnus-newsgroup-directory-form (newsgroup)
2031 "Make hierarchical directory name from NEWSGROUP name."
2032 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2033 (len (length newsgroup))
2035 ;; If this is a foreign group, we don't want to translate the
2037 (if (setq idx (string-match ":" newsgroup))
2038 (aset newsgroup idx ?/)
2040 ;; Replace all occurrences of `.' with `/'.
2042 (if (= (aref newsgroup idx) ?.)
2043 (aset newsgroup idx ?/))
2044 (setq idx (1+ idx)))
2047 (defun gnus-make-directory (dir)
2048 "Make DIRECTORY recursively."
2049 (let* ((dir (expand-file-name dir default-directory))
2051 (if (string-match "/$" dir)
2052 (setq dir (substring dir 0 (match-beginning 0))))
2053 (while (not (file-exists-p dir))
2054 (setq dirs (cons dir dirs))
2055 (string-match "/[^/]+$" dir)
2056 (setq dir (substring dir 0 (match-beginning 0))))
2058 (make-directory (car dirs))
2059 (setq dirs (cdr dirs)))))
2061 (defun gnus-capitalize-newsgroup (newsgroup)
2062 "Capitalize NEWSGROUP name."
2063 (and (not (zerop (length newsgroup)))
2064 (concat (char-to-string (upcase (aref newsgroup 0)))
2065 (substring newsgroup 1))))
2069 (defun gnus-simplify-subject (subject &optional re-only)
2070 "Remove `Re:' and words in parentheses.
2071 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2072 (let ((case-fold-search t)) ;Ignore case.
2073 ;; Remove `Re:' and `Re^N:'.
2074 (if (string-match "^re:[ \t]*" subject)
2075 (setq subject (substring subject (match-end 0))))
2076 ;; Remove words in parentheses from end.
2078 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2079 (setq subject (substring subject 0 (match-beginning 0)))))
2080 ;; Return subject string.
2083 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2085 (defun gnus-simplify-subject-fuzzy (subject)
2086 (let ((case-fold-search t))
2088 (gnus-set-work-buffer)
2090 (gnus-simplify-buffer-fuzzy)
2093 (defun gnus-simplify-buffer-fuzzy ()
2094 (goto-char (point-min))
2095 (while (re-search-forward "^[ \t]*re:[ \t]*" nil t)
2096 (replace-match "" t t))
2097 (goto-char (point-min))
2098 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2099 (replace-match "" t t))
2100 (goto-char (point-min))
2101 (while (re-search-forward "[ \t]+" nil t)
2102 (replace-match " " t t))
2103 (goto-char (point-min))
2104 (while (re-search-forward "[ \t]+$" nil t)
2105 (replace-match "" t t))
2106 (goto-char (point-min))
2107 (while (re-search-forward "^[ \t]+" nil t)
2108 (replace-match "" t t)))
2110 ;; Add the current buffer to the list of buffers to be killed on exit.
2111 (defun gnus-add-current-to-buffer-list ()
2112 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2114 (defun gnus-string> (s1 s2)
2115 (not (or (string< s1 s2)
2118 ;; Functions accessing headers.
2119 ;; Functions are more convenient than macros in some cases.
2121 (defun gnus-header-number (header)
2122 (header-number header))
2124 (defun gnus-header-subject (header)
2125 (header-subject header))
2127 (defun gnus-header-from (header)
2128 (header-from header))
2130 (defun gnus-header-xref (header)
2131 (header-xref header))
2133 (defun gnus-header-lines (header)
2134 (header-lines header))
2136 (defun gnus-header-date (header)
2137 (header-date header))
2139 (defun gnus-header-id (header)
2142 (defun gnus-header-references (header)
2143 (header-references header))
2145 ;;; General various misc type functions.
2147 (defun gnus-clear-system ()
2148 "Clear all variables and buffers."
2149 ;; Clear Gnus variables.
2150 (let ((variables gnus-variable-list))
2152 (set (car variables) nil)
2153 (setq variables (cdr variables))))
2154 ;; Clear other internal variables.
2155 (setq gnus-list-of-killed-groups nil
2156 gnus-have-read-active-file nil
2157 gnus-newsrc-alist nil
2158 gnus-newsrc-hashtb nil
2159 gnus-killed-list nil
2160 gnus-zombie-list nil
2161 gnus-killed-hashtb nil
2162 gnus-active-hashtb nil
2163 gnus-moderated-list nil
2164 gnus-description-hashtb nil
2165 gnus-newsgroup-headers nil
2166 gnus-newsgroup-headers-hashtb-by-number nil
2167 gnus-newsgroup-name nil
2168 gnus-server-alist nil
2169 gnus-current-select-method nil)
2170 ;; Reset any score variables.
2171 (and (boundp 'gnus-score-cache)
2172 (set 'gnus-score-cache nil))
2173 (and (boundp 'gnus-internal-global-score-files)
2174 (set 'gnus-internal-global-score-files nil))
2175 ;; Kill the startup file.
2176 (and gnus-current-startup-file
2177 (get-file-buffer gnus-current-startup-file)
2178 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2179 ;; Save any cache buffers.
2180 (and gnus-use-cache (gnus-cache-save-buffers))
2181 ;; Clear the dribble buffer.
2182 (gnus-dribble-clear)
2183 ;; Kill global KILL file buffer.
2184 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2185 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2186 (gnus-kill-buffer nntp-server-buffer)
2187 ;; Kill Gnus buffers.
2188 (while gnus-buffer-list
2189 (gnus-kill-buffer (car gnus-buffer-list))
2190 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2192 (defun gnus-windows-old-to-new (setting)
2193 (if (symbolp setting)
2195 (cond ((eq setting 'SelectArticle)
2197 ((eq setting 'SelectSubject)
2199 ((eq setting 'SelectNewsgroup)
2202 (if (or (listp setting)
2203 (not (and gnus-window-configuration
2204 (memq setting '(group summary article)))))
2206 (let* ((setting (if (eq setting 'group)
2207 (if (assq 'newsgroup gnus-window-configuration)
2209 'newsgroups) setting))
2210 (elem (car (cdr (assq setting gnus-window-configuration))))
2211 (total (apply '+ elem))
2212 (types '(group summary article))
2213 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2218 (or (zerop (nth i elem))
2220 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2221 (setq out (cons (if (eq pbuf (nth i types))
2222 (vector (nth i types) perc 'point)
2223 (vector (nth i types) perc))
2226 (list (nreverse out)))))
2228 (defun gnus-configure-windows (setting)
2229 (setq setting (gnus-windows-old-to-new setting))
2230 (let ((r (if (symbolp setting)
2231 (cdr (assq setting gnus-buffer-configuration))
2233 (in-buf (current-buffer))
2234 rule val window w height hor ohor heights sub jump-buffer
2236 (or r (error "No such setting: %s" setting))
2238 ;; Either remove all windows or just remove all Gnus windows.
2239 (if gnus-use-full-window
2240 (delete-other-windows)
2241 (gnus-remove-some-windows)
2242 (switch-to-buffer nntp-server-buffer))
2248 ;; We have to do the (possible) horizontal splitting before the
2250 (if (and (listp (car hor))
2251 (eq (car (car hor)) 'horizontal))
2253 (split-window nil (- (frame-width)
2254 (floor (* (frame-width) (nth 1 (car hor)))))
2256 (setq hor (cdr hor))))
2258 ;; Go through the rules and eval the elements that are to be
2261 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2263 ;; Expand short buffer name.
2264 (setq w (aref val 0))
2265 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2267 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2269 (setq ohor (cons val ohor))))
2270 (setq hor (cdr hor)))
2271 (setq rule (cons (nreverse ohor) rule))
2273 (setq rule (nreverse rule))
2275 ;; We tally the window sizes.
2276 (setq total (window-height))
2278 (setq hor (car rule))
2279 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2280 (setq hor (cdr hor)))
2283 (setq rel (aref (car hor) 1)
2285 (cond ((and (floatp rel) (= 1.0 rel))
2290 (max (floor (* total rel)) 4)))
2292 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2294 (setq heights (nreverse heights)
2297 ;; We then go through these heighs and create windows for them.
2299 (setq height (car heights)
2300 heights (cdr heights))
2302 (setq height (- total sub)))
2304 (split-window nil height))
2305 (setq to-buf (aref (car hor) 0))
2310 (symbol-value (aref (car hor) 0)))
2312 (aref (car hor) 0))))
2313 (and (> (length (car hor)) 2)
2314 (eq (aref (car hor) 2) 'point)
2315 (setq jump-buffer (current-buffer)))
2317 (setq hor (cdr hor)))
2319 (setq rule (cdr rule)))
2321 ;; Finally, we pop to the buffer that's supposed to have point.
2322 (or jump-buffer (error "Missing `point' in spec for %s" setting))
2324 (pop-to-buffer jump-buffer)
2327 (defun gnus-remove-some-windows ()
2328 (let ((buffers gnus-window-to-buffer)
2332 (setq buf (cdr (car buffers)))
2334 (setq buf (and (boundp buf) (symbol-value buf))))
2336 (get-buffer-window buf)
2341 (switch-to-buffer nntp-server-buffer)
2343 (delete-window (get-buffer-window buf)))))
2344 (setq buffers (cdr buffers)))
2345 (set-buffer nntp-server-buffer)))
2347 (defun gnus-version ()
2348 "Version numbers of this version of Gnus."
2350 (let ((methods gnus-valid-select-methods)
2353 ;; Go through all the legal select methods and add their version
2354 ;; numbers to the total version string. Only the backends that are
2355 ;; currently in use will have their message numbers taken into
2358 (setq meth (intern (concat (car (car methods)) "-version")))
2360 (stringp (symbol-value meth))
2361 (setq mess (concat mess "; " (symbol-value meth))))
2362 (setq methods (cdr methods)))
2363 (gnus-message 2 mess)))
2365 (defun gnus-info-find-node ()
2366 "Find Info documentation of Gnus."
2368 ;; Enlarge info window if needed.
2369 (let ((mode major-mode))
2370 (gnus-configure-windows 'info)
2371 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2374 "Send a bug report to the Gnus maintainers."
2376 (let ((winconf (current-window-configuration)))
2377 (delete-other-windows)
2378 (switch-to-buffer "*Gnus Bug Help*")
2380 (insert gnus-bug-message)
2381 (goto-char (point-min))
2382 (pop-to-buffer "*Gnus Bug*")
2385 (mail-setup gnus-maintainer nil nil nil nil nil)
2386 (make-local-variable 'gnus-prev-winconf)
2387 (setq gnus-prev-winconf winconf)
2388 (goto-char (point-min))
2389 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2391 (insert (format "%s\n%s\n\n\n\n\n" (gnus-version) (emacs-version)))
2394 (goto-char (- b 3)))
2397 (defun gnus-debug ()
2398 "Attemps to go through the Gnus source file and report what variables have been changed.
2399 The source file has to be in the Emacs load path."
2401 (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el"))
2402 file dirs expr olist)
2404 (set-buffer (get-buffer-create " *gnus bug info*"))
2405 (buffer-disable-undo (current-buffer))
2406 (message "Please wait while we snoop your variables...")
2410 (setq dirs load-path)
2412 (if (not (file-exists-p
2413 (setq file (concat (file-name-as-directory
2414 (car dirs)) (car files)))))
2415 (setq dirs (cdr dirs))
2417 (insert-file-contents file)
2418 (goto-char (point-min))
2419 (or (re-search-forward "^;;* Internal variables" nil t)
2420 (error "Malformed sources in file %s" file))
2421 (narrow-to-region (point-min) (point))
2422 (goto-char (point-min))
2423 (while (setq expr (condition-case ()
2424 (read (current-buffer)) (error nil)))
2425 (and (eq (car expr) 'defvar)
2426 (stringp (nth 3 expr))
2427 (or (not (boundp (nth 1 expr)))
2428 (not (equal (eval (nth 2 expr))
2429 (symbol-value (nth 1 expr)))))
2430 (setq olist (cons (nth 1 expr) olist))))))
2431 (setq files (cdr files)))
2432 (kill-buffer (current-buffer)))
2433 (insert "------------------- Environment follows -------------------\n\n")
2435 (if (boundp (car olist))
2436 (insert "(setq " (symbol-name (car olist)) " '"
2437 (prin1-to-string (symbol-value (car olist))) ")\n")
2438 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
2439 (setq olist (cdr olist)))
2442 (defun gnus-overload-functions (&optional overloads)
2443 "Overload functions specified by optional argument OVERLOADS.
2444 If nothing is specified, use the variable gnus-overload-functions."
2446 (overloads (or overloads gnus-overload-functions)))
2448 (setq defs (car overloads))
2449 (setq overloads (cdr overloads))
2450 ;; Load file before overloading function if necessary. Make
2451 ;; sure we cannot use `require' always.
2452 (and (not (fboundp (car defs)))
2453 (car (cdr (cdr defs)))
2454 (load (car (cdr (cdr defs))) nil 'nomessage))
2455 (fset (car defs) (car (cdr defs))))))
2457 (defun gnus-replace-chars-in-string (string from to)
2458 "Replace characters in STRING from FROM to TO."
2459 (let ((string (substring string 0)) ;Copy string.
2460 (len (length string))
2462 ;; Replace all occurrences of FROM with TO.
2464 (if (= (aref string idx) from)
2465 (aset string idx to))
2466 (setq idx (1+ idx)))
2469 (defun gnus-days-between (date1 date2)
2470 ;; Return the number of days between date1 and date2.
2471 (- (gnus-day-number date1) (gnus-day-number date2)))
2473 (defun gnus-day-number (date)
2474 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2475 (timezone-parse-date date))))
2476 (timezone-absolute-from-gregorian
2477 (nth 1 dat) (nth 2 dat) (car dat))))
2479 ;; Returns a floating point number that says how many seconds have
2480 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2481 (defun gnus-seconds-since-epoch (date)
2482 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2483 (timezone-parse-date date)))
2484 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2485 (timezone-parse-time
2486 (aref (timezone-parse-date date) 3))))
2487 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2488 (timezone-parse-date "Jan 1 12:00:00 1970")))
2489 (tday (- (timezone-absolute-from-gregorian
2490 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2491 (timezone-absolute-from-gregorian
2492 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2494 (* (nth 1 ttime) 60)
2495 (* 1.0 (nth 0 ttime) 60 60)
2496 (* 1.0 tday 60 60 24))))
2498 (defun gnus-file-newer-than (file date)
2499 (let ((fdate (nth 5 (file-attributes file))))
2500 (or (> (car fdate) (car date))
2501 (and (= (car fdate) (car date))
2502 (> (nth 1 fdate) (nth 1 date))))))
2504 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2506 (defun gnus-y-or-n-p (prompt)
2511 (defun gnus-yes-or-no-p (prompt)
2513 (yes-or-no-p prompt)
2516 ;; Check whether to use long file names.
2517 (defun gnus-use-long-file-name (symbol)
2518 ;; The variable has to be set...
2519 (and gnus-use-long-file-name
2520 ;; If it isn't a list, then we return t.
2521 (or (not (listp gnus-use-long-file-name))
2522 ;; If it is a list, and the list contains `symbol', we
2524 (not (memq symbol gnus-use-long-file-name)))))
2526 ;; I suspect there's a better way, but I haven't taken the time to do
2527 ;; it yet. -erik selberg@cs.washington.edu
2528 (defun gnus-dd-mmm (messy-date)
2529 "Return a string like DD-MMM from a big messy string"
2530 (let ((datevec (timezone-parse-date messy-date)))
2532 (or (aref datevec 2) "??")
2535 (nth (1- (string-to-number (aref datevec 1)))
2536 timezone-months-assoc))
2539 ;; Make a hash table (default and minimum size is 255).
2540 ;; Optional argument HASHSIZE specifies the table size.
2541 (defun gnus-make-hashtable (&optional hashsize)
2542 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2544 ;; Make a number that is suitable for hashing; bigger than MIN and one
2546 (defun gnus-create-hash-size (min)
2552 ;; Delete the current line (and the next N lines.);
2553 (defun gnus-delete-line (&optional n)
2555 (delete-region (progn (beginning-of-line) (point))
2556 (progn (forward-line n) (point)))))
2558 ;; Show message if message has a lower level than `gnus-verbose'.
2559 ;; Guide-line for numbers:
2560 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2561 ;; for things that take a long time, 7 - not very important messages
2562 ;; on stuff, 9 - messages inside loops.
2563 (defun gnus-message (level &rest args)
2564 (if (<= level gnus-verbose)
2565 (apply 'message args)
2566 ;; We have to do this format thingie here even if the result isn't
2567 ;; shown - the return value has to be the same as the return value
2569 (apply 'format args)))
2571 ;;; List and range functions
2573 (defun gnus-last-element (list)
2574 "Return last element of LIST."
2576 (setq list (cdr list)))
2579 (defun gnus-copy-sequence (list)
2580 "Do a complete, total copy of a list."
2581 (if (and (consp list) (not (consp (cdr list))))
2582 (cons (car list) (cdr list))
2583 (mapcar (lambda (elem) (if (consp elem)
2584 (if (consp (cdr elem))
2585 (gnus-copy-sequence elem)
2586 (cons (car elem) (cdr elem)))
2590 (defun gnus-set-difference (list1 list2)
2591 "Return a list of elements of LIST1 that do not appear in LIST2."
2592 (let ((list1 (copy-sequence list1)))
2594 (setq list1 (delq (car list2) list1))
2595 (setq list2 (cdr list2)))
2598 (defun gnus-sorted-complement (list1 list2)
2599 "Return a list of elements of LIST1 that do not appear in LIST2.
2600 Both lists have to be sorted over <."
2602 (if (or (null list1) (null list2))
2604 (while (and list1 list2)
2605 (cond ((= (car list1) (car list2))
2606 (setq list1 (cdr list1)
2608 ((< (car list1) (car list2))
2609 (setq out (cons (car list1) out))
2610 (setq list1 (cdr list1)))
2612 (setq out (cons (car list2) out))
2613 (setq list2 (cdr list2)))))
2614 (nconc (nreverse out) (or list1 list2)))))
2616 (defun gnus-intersection (list1 list2)
2619 (if (memq (car list2) list1)
2620 (setq result (cons (car list2) result)))
2621 (setq list2 (cdr list2)))
2624 (defun gnus-sorted-intersection (list1 list2)
2625 ;; LIST1 and LIST2 have to be sorted over <.
2627 (while (and list1 list2)
2628 (cond ((= (car list1) (car list2))
2629 (setq out (cons (car list1) out)
2632 ((< (car list1) (car list2))
2633 (setq list1 (cdr list1)))
2635 (setq list2 (cdr list2)))))
2638 (defun gnus-set-sorted-intersection (list1 list2)
2639 ;; LIST1 and LIST2 have to be sorted over <.
2640 ;; This function modifies LIST1.
2641 (let* ((top (cons nil list1))
2643 (while (and list1 list2)
2644 (cond ((= (car list1) (car list2))
2648 ((< (car list1) (car list2))
2649 (setcdr prev (cdr list1))
2650 (setq list1 (cdr list1)))
2652 (setq list2 (cdr list2)))))
2656 (defun gnus-compress-sequence (numbers &optional always-list)
2657 "Convert list of numbers to a list of ranges or a single range.
2658 If ALWAYS-LIST is non-nil, this function will always release a list of
2660 (let* ((first (car numbers))
2661 (last (car numbers))
2665 (if (not (listp (cdr numbers)))
2668 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2669 ((= (1+ last) (car numbers)) ;Still in sequence
2670 (setq last (car numbers)))
2671 (t ;End of one sequence
2673 (cons (if (= first last) first
2674 (cons first last)) result))
2675 (setq first (car numbers))
2676 (setq last (car numbers))))
2677 (setq numbers (cdr numbers)))
2678 (if (and (not always-list) (null result))
2679 (if (= first last) (list first) (cons first last))
2680 (nreverse (cons (if (= first last) first (cons first last))
2683 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2684 (defun gnus-uncompress-range (ranges)
2685 "Expand a list of ranges into a list of numbers.
2686 RANGES is either a single range on the form `(num . num)' or a list of
2688 (let (first last result)
2692 ((not (listp (cdr ranges)))
2693 (setq first (car ranges))
2694 (setq last (cdr ranges))
2695 (while (<= first last)
2696 (setq result (cons first result))
2697 (setq first (1+ first)))
2701 (if (atom (car ranges))
2702 (if (numberp (car ranges))
2703 (setq result (cons (car ranges) result)))
2704 (setq first (car (car ranges)))
2705 (setq last (cdr (car ranges)))
2706 (while (<= first last)
2707 (setq result (cons first result))
2708 (setq first (1+ first))))
2709 (setq ranges (cdr ranges)))
2710 (nreverse result)))))
2712 (defun gnus-add-to-range (ranges list)
2713 "Return a list of ranges that has all articles from both RANGES and LIST.
2714 Note: LIST has to be sorted over `<'."
2716 (gnus-compress-sequence list t)
2717 (setq list (copy-sequence list))
2718 (or (listp (cdr ranges))
2719 (setq ranges (list ranges)))
2721 ilist lowest highest temp)
2722 (while (and ranges list)
2724 (setq lowest (or (and (atom (car ranges)) (car ranges))
2725 (car (car ranges))))
2726 (while (and list (cdr list) (< (car (cdr list)) lowest))
2727 (setq list (cdr list)))
2728 (if (< (car ilist) lowest)
2731 (setq list (cdr list))
2733 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2734 (setq highest (or (and (atom (car ranges)) (car ranges))
2735 (cdr (car ranges))))
2736 (while (and list (<= (car list) highest))
2737 (setq list (cdr list)))
2738 (setq ranges (cdr ranges)))
2740 (setq out (nconc (gnus-compress-sequence list t) out)))
2741 (setq out (sort out (lambda (r1 r2)
2742 (< (or (and (atom r1) r1) (car r1))
2743 (or (and (atom r2) r2) (car r2))))))
2746 (if (atom (car ranges))
2748 (if (atom (car (cdr ranges)))
2749 (if (= (1+ (car ranges)) (car (cdr ranges)))
2751 (setcar ranges (cons (car ranges)
2752 (car (cdr ranges))))
2753 (setcdr ranges (cdr (cdr ranges)))))
2754 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2756 (setcar (car (cdr ranges)) (car ranges))
2757 (setcar ranges (car (cdr ranges)))
2758 (setcdr ranges (cdr (cdr ranges)))))))
2760 (if (atom (car (cdr ranges)))
2761 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2763 (setcdr (car ranges) (car (cdr ranges)))
2764 (setcdr ranges (cdr (cdr ranges)))))
2765 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2767 (setcdr (car ranges) (cdr (car (cdr ranges))))
2768 (setcdr ranges (cdr (cdr ranges))))))))
2769 (setq ranges (cdr ranges)))
2772 (defun gnus-remove-from-range (ranges list)
2773 "Return a list of ranges that has all articles from LIST removed from RANGES.
2774 Note: LIST has to be sorted over `<'."
2775 ;; !!! This function shouldn't look like this, but I've got a headache.
2776 (gnus-compress-sequence
2777 (gnus-sorted-complement
2778 (gnus-uncompress-range ranges) list)))
2780 (defun gnus-member-of-range (number ranges)
2781 (if (not (listp (cdr ranges)))
2782 (and (>= number (car ranges))
2783 (<= number (cdr ranges)))
2786 (if (numberp (car ranges))
2787 (>= number (car ranges))
2788 (>= number (car (car ranges))))
2790 (if (if (numberp (car ranges))
2791 (= number (car ranges))
2792 (and (>= number (car (car ranges)))
2793 (<= number (cdr (car ranges)))))
2794 (setq not-stop nil))
2795 (setq ranges (cdr ranges)))
2803 (defvar gnus-group-mode-map nil)
2804 (defvar gnus-group-group-map nil)
2805 (defvar gnus-group-mark-map nil)
2806 (defvar gnus-group-list-map nil)
2807 (defvar gnus-group-sub-map nil)
2808 (put 'gnus-group-mode 'mode-class 'special)
2810 (if gnus-group-mode-map
2812 (setq gnus-group-mode-map (make-keymap))
2813 (suppress-keymap gnus-group-mode-map)
2814 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2815 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2816 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2817 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2818 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2819 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2820 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2821 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2822 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2823 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2824 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2825 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2826 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2827 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2828 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2829 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2830 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2831 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2832 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2833 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2834 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2835 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2836 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2837 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2838 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2839 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2840 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2841 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2842 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2843 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2844 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2845 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2846 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2847 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2848 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2849 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2850 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2851 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2852 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2853 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2854 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2855 (define-key gnus-group-mode-map "V" 'gnus-version)
2856 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2857 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2858 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2859 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2860 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2861 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2862 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2863 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2864 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
2865 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2866 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
2867 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
2868 (define-key gnus-group-mode-map ">" 'end-of-buffer)
2869 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
2871 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
2872 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
2873 (define-prefix-command 'gnus-group-mark-map)
2874 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
2875 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
2876 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
2877 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
2879 (define-prefix-command 'gnus-group-group-map)
2880 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
2881 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
2882 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
2883 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
2884 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
2885 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
2886 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
2887 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
2888 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
2889 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
2891 (define-prefix-command 'gnus-group-list-map)
2892 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
2893 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2894 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2895 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2896 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2897 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2898 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2899 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2900 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2902 (define-prefix-command 'gnus-group-sub-map)
2903 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2904 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2905 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2906 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2907 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2908 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2909 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
2910 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
2912 (defun gnus-group-mode ()
2913 "Major mode for reading news.
2915 All normal editing commands are switched off.
2916 \\<gnus-group-mode-map>
2917 The group buffer lists (some of) the groups available. For instance,
2918 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2919 lists all zombie groups.
2921 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2922 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2924 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2926 The following commands are available:
2928 \\{gnus-group-mode-map}"
2930 (if gnus-visual (gnus-group-make-menu-bar))
2931 (kill-all-local-variables)
2932 (setq mode-line-modified "-- ")
2933 (make-local-variable 'mode-line-format)
2934 (setq mode-line-format (copy-sequence mode-line-format))
2935 (and (equal (nth 3 mode-line-format) " ")
2936 (setcar (nthcdr 3 mode-line-format) ""))
2937 (setq major-mode 'gnus-group-mode)
2938 (setq mode-name "Group")
2939 (gnus-group-set-mode-line)
2940 (setq mode-line-process nil)
2941 (use-local-map gnus-group-mode-map)
2942 (buffer-disable-undo (current-buffer))
2943 (setq truncate-lines t)
2944 (setq buffer-read-only t)
2945 (run-hooks 'gnus-group-mode-hook))
2947 (defun gnus-mouse-pick-group (e)
2950 (gnus-group-read-group nil))
2953 (defun gnus-no-server (&optional arg)
2955 If ARG is a positive number, Gnus will use that as the
2956 startup level. If ARG is nil, Gnus will be started at level 2.
2957 If ARG is non-nil and not a positive number, Gnus will
2958 prompt the user for the name of an NNTP server to use.
2959 As opposed to `gnus', this command will not connect to the local server."
2961 (gnus (or arg (1- gnus-level-default-subscribed)) t))
2963 (defalias '\(ding\) 'gnus)
2966 (defun gnus (&optional arg dont-connect)
2968 If ARG is non-nil and a positive number, Gnus will use that as the
2969 startup level. If ARG is non-nil and not a positive number, Gnus will
2970 prompt the user for the name of an NNTP server to use."
2972 (if (get-buffer gnus-group-buffer)
2974 (switch-to-buffer gnus-group-buffer)
2975 (gnus-group-get-new-news))
2977 (nnheader-init-server-buffer)
2978 (gnus-read-init-file)
2979 (let ((level (and arg (numberp arg) (> arg 0) arg))
2983 (gnus-group-setup-buffer)
2986 (gnus-start-news-server (and arg (not level))))))
2987 (if (and (not dont-connect)
2990 (run-hooks 'gnus-startup-hook)
2991 ;; NNTP server is successfully open.
2992 (gnus-update-format-specifications)
2993 (gnus-summary-make-display-table)
2994 (let ((buffer-read-only nil))
2996 (if (not gnus-inhibit-startup-message)
2998 (gnus-group-startup-message)
3000 (gnus-setup-news nil level)
3001 (and gnus-use-dribble-file (gnus-dribble-open))
3002 (gnus-group-list-groups level)
3003 (gnus-configure-windows 'group))))))
3005 (defun gnus-group-startup-message (&optional x y)
3006 "Insert startup message in current buffer."
3007 ;; Insert the message.
3024 ;; And then hack it.
3025 ;; 18 is the longest line.
3026 (indent-rigidly (point-min) (point-max)
3027 (/ (max (- (window-width) (or x 28)) 0) 2))
3028 (goto-char (point-min))
3029 ;; +4 is fuzzy factor.
3030 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
3032 (defun gnus-group-setup-buffer ()
3033 (or (get-buffer gnus-group-buffer)
3035 (switch-to-buffer gnus-group-buffer)
3036 (gnus-add-current-to-buffer-list)
3038 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3040 (defun gnus-group-list-groups (level &optional unread)
3041 "List newsgroups with level LEVEL or lower that have unread alticles.
3042 Default is all subscribed groups.
3043 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3044 (interactive (list (and current-prefix-arg
3045 (prefix-numeric-value current-prefix-arg))))
3046 (if gnus-group-use-permanent-levels
3048 (setq gnus-group-default-list-level
3049 (or level gnus-group-default-list-level))
3050 (setq level (or gnus-group-default-list-level gnus-level-subscribed)))
3051 (setq level (or level gnus-group-default-list-level
3052 gnus-level-subscribed)))
3053 (gnus-group-setup-buffer) ;May call from out of group buffer
3054 (let ((case-fold-search nil)
3055 (group (gnus-group-group-name)))
3056 (funcall gnus-group-prepare-function level unread nil)
3057 (if (zerop (buffer-size))
3058 (gnus-message 5 gnus-no-groups-message)
3059 (goto-char (point-min))
3061 ;; Go to the first group with unread articles.
3062 (gnus-group-search-forward nil nil nil t)
3063 ;; Find the right group to put point on. If the current group
3064 ;; has disapeared in the new listing, try to find the next
3065 ;; one. If no next one can be found, just leave point at the
3066 ;; first newsgroup in the buffer.
3067 (if (not (gnus-goto-char
3068 (text-property-any (point-min) (point-max)
3069 'gnus-group (intern group))))
3070 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3072 (not (gnus-goto-char
3074 (point-min) (point-max) 'gnus-group
3075 (intern (car (car newsrc)))))))
3076 (setq newsrc (cdr newsrc)))
3077 (or newsrc (progn (goto-char (point-max))
3078 (forward-line -1))))))
3079 ;; Adjust cursor point.
3080 (gnus-group-position-cursor))))
3082 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3083 "List all newsgroups with unread articles of level LEVEL or lower.
3084 If ALL is non-nil, list groups that have no unread articles.
3085 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3086 If REGEXP, only list groups matching REGEXP."
3087 (set-buffer gnus-group-buffer)
3088 (let ((buffer-read-only nil)
3089 (newsrc (cdr gnus-newsrc-alist))
3090 (lowest (or lowest 1))
3091 info clevel unread group)
3093 (if (< lowest gnus-level-zombie)
3094 ;; List living groups.
3096 (setq info (car newsrc)
3099 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3100 (and unread ; This group might be bogus
3102 (string-match regexp group))
3103 (<= (setq clevel (car (cdr info))) level)
3105 (or all ; We list all groups?
3106 (eq unread t) ; We list unactivated groups
3107 (> unread 0) ; We list groups with unread articles
3108 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3109 (gnus-group-insert-group-line
3110 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3112 ;; List dead groups.
3113 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3114 (gnus-group-prepare-flat-list-dead
3115 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3116 gnus-level-zombie ?Z
3118 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3119 (gnus-group-prepare-flat-list-dead
3120 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3121 gnus-level-killed ?K regexp))
3123 (gnus-group-set-mode-line)
3124 (setq gnus-have-all-newsgroups all)
3125 (run-hooks 'gnus-group-prepare-hook)))
3127 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3128 ;; List zombies and killed lists somehwat faster, which was
3129 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3130 ;; this by ignoring the group format specification altogether.
3133 (setq group (car groups)
3134 groups (cdr groups))
3135 (if (or (not regexp)
3136 (string-match regexp group))
3139 (insert (format " %c *: %s\n" mark group))
3140 (add-text-properties
3142 (list 'gnus-group (intern group)
3144 'gnus-level level)))))))
3146 (defun gnus-group-real-name (group)
3147 "Find the real name of a foreign newsgroup."
3148 (if (string-match "^[^:]+:" group)
3149 (substring group (match-end 0))
3152 (defun gnus-group-prefixed-name (group method)
3153 "Return the whole name from GROUP and METHOD."
3154 (and (stringp method) (setq method (gnus-server-to-method method)))
3155 (concat (format "%s" (car method))
3157 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3158 (not (string= (nth 1 method) "")))
3159 (concat "+" (nth 1 method)))
3162 (defun gnus-group-real-prefix (group)
3163 "Return the prefix of the current group name."
3164 (if (string-match "^[^:]+:" group)
3165 (substring group 0 (match-end 0))
3168 (defun gnus-group-method-name (group)
3169 "Return the method used for selecting GROUP."
3170 (let ((prefix (gnus-group-real-prefix group)))
3171 (if (equal prefix "")
3173 (if (string-match "^[^\\+]+\\+" prefix)
3174 (list (intern (substring prefix 0 (1- (match-end 0))))
3175 (substring prefix (match-end 0) (1- (length prefix))))
3176 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3178 (defun gnus-group-foreign-p (group)
3179 "Return nil if GROUP is native, non-nil if it is foreign."
3180 (string-match ":" group))
3182 (defun gnus-group-set-info (info &optional method-only-group part)
3183 (let* ((entry (gnus-gethash
3184 (or method-only-group (car info)) gnus-newsrc-hashtb))
3186 (info (if method-only-group (nth 2 entry) info)))
3187 (if (not method-only-group)
3190 (error "Trying to change non-existant group %s" method-only-group))
3191 ;; We have recevied parts of the actual group info - either the
3192 ;; select method or the group parameters. We first check
3193 ;; whether we have to extend the info, and if so, do that.
3194 (let ((len (length info))
3195 (total (if (eq part 'method) 5 6)))
3197 (setcdr (nthcdr (1- len) info)
3198 (make-list (- total len) nil)))
3199 ;; Then we enter the new info.
3200 (setcar (nthcdr (1- total) info) part-info)))
3201 ;; We uncompress some lists of marked articles.
3203 (if (not (setq marked (nth 3 info)))
3206 (or (eq 'score (car (car marked)))
3207 (eq 'bookmark (car (car marked)))
3208 (eq 'killed (car (car marked)))
3209 (setcdr (car marked)
3210 (gnus-uncompress-range (cdr (car marked)))))
3211 (setq marked (cdr marked)))))
3214 ;; This is a new group, so we just create it.
3216 (set-buffer gnus-group-buffer)
3218 ;; It's a foreign group...
3219 (gnus-group-make-group
3220 (gnus-group-real-name (car info))
3221 (prin1-to-string (car (nth 4 info)))
3222 (nth 1 (nth 4 info)))
3223 ;; It's a native group.
3224 (gnus-group-make-group
3226 (prin1-to-string (car gnus-select-method))
3227 (nth 1 gnus-select-method)))
3228 (gnus-message 6 "Note: New group created")
3230 (gnus-gethash (gnus-group-prefixed-name
3231 (gnus-group-real-name (car info))
3232 (or (nth 4 info) gnus-select-method))
3233 gnus-newsrc-hashtb))))
3234 ;; Whether it was a new group or not, we now have the entry, so we
3235 ;; can do the update.
3238 (setcar (nthcdr 2 entry) info)
3239 (if (and (not (eq (car entry) t))
3240 (gnus-gethash (car info) gnus-active-hashtb))
3241 (let ((marked (nth 3 info)))
3243 (max 0 (- (length (gnus-list-of-unread-articles
3245 (length (cdr (assq 'tick marked)))
3246 (length (cdr (assq 'dormant marked)))))))))
3247 (error "No such group: %s" (car info)))))
3249 (defun gnus-group-set-method-info (group select-method)
3250 (gnus-group-set-info select-method group 'method))
3252 (defun gnus-group-set-params-info (group params)
3253 (gnus-group-set-info params group 'params))
3255 (defun gnus-group-update-group-line ()
3256 "This function updates the current line in the newsgroup buffer and
3257 moves the point to the colon."
3258 (let* ((buffer-read-only nil)
3259 (group (gnus-group-group-name))
3260 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3263 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3266 (delete-region (point) (progn (forward-line 1) (point)))
3267 (gnus-group-insert-group-line-info group)
3269 (gnus-group-position-cursor)))
3271 (defun gnus-group-insert-group-line-info (group)
3272 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3276 (setq info (nth 2 entry))
3277 (gnus-group-insert-group-line
3278 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3279 (setq active (gnus-gethash group gnus-active-hashtb))
3280 (gnus-group-insert-group-line
3281 nil group (if (member group gnus-zombie-list) gnus-level-zombie
3283 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3285 (defun gnus-group-insert-group-line (gformat group level marked number method)
3286 (let* ((gformat (or gformat gnus-group-line-format-spec))
3287 (active (gnus-gethash group gnus-active-hashtb))
3288 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3289 (number-of-dormant (length (cdr (assq 'dormant marked))))
3290 (number-of-ticked (length (cdr (assq 'tick marked))))
3291 (number-of-ticked-and-dormant
3292 (+ number-of-ticked number-of-dormant))
3293 (number-of-unread-unticked
3294 (if (numberp number) (int-to-string (max 0 number))
3297 (if (numberp number)
3298 (max 0 (- number-total number))
3300 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3301 ((<= level gnus-level-unsubscribed) ?U)
3302 ((= level gnus-level-zombie) ?Z)
3304 (qualified-group (gnus-group-real-name group))
3305 (newsgroup-description
3306 (if gnus-description-hashtb
3307 (or (gnus-gethash group gnus-description-hashtb) "")
3309 (moderated (if (member group gnus-moderated-list) ?m ? ))
3310 (moderated-string (if (eq moderated ?m) "(m)" ""))
3311 (method (gnus-server-get-method group method))
3312 (news-server (or (car (cdr method)) ""))
3313 (news-method (or (car method) ""))
3315 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3319 (> number-of-ticked 0))
3321 (number (if (eq number t) "*" (+ number number-of-dormant
3323 (buffer-read-only nil)
3328 (insert (eval gformat))
3330 (add-text-properties
3331 b (1+ b) (list 'gnus-group (intern group)
3332 'gnus-unread (if (numberp number)
3333 (string-to-int number-of-unread-unticked)
3336 'gnus-level level))))
3338 (defun gnus-group-update-group (group &optional visible-only)
3339 "Update newsgroup info of GROUP.
3340 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3342 (set-buffer gnus-group-buffer)
3343 (let ((buffer-read-only nil)
3345 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3348 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3350 ;; Buffer may be narrowed.
3353 ;; Search a line to modify. If the buffer is large, the search
3354 ;; takes long time. In most cases, current point is on the line
3355 ;; we are looking for. So, first of all, check current line.
3358 (eq (get-text-property (point) 'gnus-group)
3363 (point-min) (point-max) 'gnus-group (intern group)))))
3364 ;; GROUP is listed in current buffer. So, delete old line.
3368 (delete-region (point) (progn (forward-line 1) (point))))
3369 ;; No such line in the buffer, find out where it's supposed to
3370 ;; go, and insert it there (or at the end of the buffer).
3371 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3373 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3379 (point-min) (point-max)
3380 'gnus-group (intern (car (car entry)))))))
3381 (setq entry (cdr entry)))
3382 (or entry (goto-char (point-max)))))))
3383 (if (or visible (not visible-only))
3384 (gnus-group-insert-group-line-info group))
3385 (gnus-group-set-mode-line))))
3387 (defun gnus-group-set-mode-line ()
3388 (if (memq 'group gnus-updated-mode-lines)
3389 (let* ((gformat (or gnus-group-mode-line-format-spec
3390 (setq gnus-group-mode-line-format-spec
3392 gnus-group-mode-line-format
3393 gnus-group-mode-line-format-alist))))
3394 (news-server (car (cdr gnus-select-method)))
3395 (news-method (car gnus-select-method))
3397 (mode-string (eval gformat)))
3398 (setq mode-string (eval gformat))
3399 (if (> (length mode-string) max-len)
3400 (setq mode-string (substring mode-string 0 (- max-len 4))))
3401 (setq mode-line-buffer-identification mode-string)
3402 (set-buffer-modified-p t))))
3404 (defun gnus-group-group-name ()
3405 "Get the name of the newsgroup on the current line."
3406 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3407 (and group (symbol-name group))))
3409 (defun gnus-group-group-level ()
3410 "Get the level of the newsgroup on the current line."
3411 (get-text-property (gnus-point-at-bol) 'gnus-level))
3413 (defun gnus-group-search-forward (&optional backward all level first-too)
3414 "Find the next newsgroup with unread articles.
3415 If BACKWARD is non-nil, find the previous newsgroup instead.
3416 If ALL is non-nil, just find any newsgroup.
3417 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3419 If FIRST-TOO, the current line is also eligeble as a target."
3420 (let ((way (if backward -1 1))
3424 (if (and backward (progn (beginning-of-line)) (bobp))
3426 (or first-too (forward-line way))
3434 (get-text-property (point) 'gnus-unread)))
3435 (or (eq unread t) (and unread (> unread 0))))
3436 (let ((lev (get-text-property
3437 (point) 'gnus-level)))
3438 (and lev (<= (get-text-property
3439 (point) 'gnus-level)
3440 gnus-level-subscribed)))))
3442 (let ((lev (get-text-property (point) 'gnus-level)))
3443 (if (and lev (<= lev level))
3448 (setq pos (point))))
3450 (zerop (forward-line way)))))
3452 (progn (gnus-group-position-cursor) t)
3453 (if pos (goto-char pos) (goto-char beg))
3456 ;;; Gnus group mode commands
3460 (defun gnus-group-mark-group (n &optional unmark)
3461 "Mark the current group."
3463 (let ((buffer-read-only nil)
3467 (setq group (gnus-group-group-name))
3475 (setq gnus-group-marked (delete group gnus-group-marked)))
3477 (setq gnus-group-marked (cons group gnus-group-marked)))
3479 (zerop (gnus-group-next-group 1)))
3481 (gnus-summary-position-cursor)
3484 (defun gnus-group-unmark-group (n)
3485 "Remove the mark from the current group."
3487 (gnus-group-mark-group n 'unmark))
3489 (defun gnus-group-mark-region (unmark beg end)
3490 "Mark all groups between point and mark.
3491 If UNMARK, remove the mark instead."
3492 (interactive "P\nr")
3493 (let ((num (count-lines beg end)))
3496 (- num (gnus-group-mark-group num unmark)))))
3498 (defun gnus-group-remove-mark (group)
3499 (and (gnus-group-goto-group group)
3501 (gnus-group-mark-group 1 'unmark))))
3503 ;; Return a list of groups to work on. Take into consideration N (the
3504 ;; prefix) and the list of marked groups.
3505 (defun gnus-group-process-prefix (n)
3507 (setq n (prefix-numeric-value n))
3508 ;; There is a prefix, so we return a list of the N next
3510 (let ((way (if (< n 0) -1 1))
3515 (setq group (gnus-group-group-name)))
3516 (setq groups (cons group groups))
3518 (forward-line way)))
3521 ;; No prefix, but a list of marked articles.
3522 (reverse gnus-group-marked))
3524 ;; Neither marked articles or a prefix, so we return the
3526 (let ((group (gnus-group-group-name)))
3527 (and group (list group))))))
3531 ;; Selecting groups.
3533 (defun gnus-group-read-group (all &optional no-article group)
3534 "Read news in this newsgroup.
3535 If argument ALL is non-nil, already read articles become readable.
3536 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3538 (let ((group (or group (gnus-group-group-name)))
3539 number active marked entry)
3540 (or group (error "No group on current line"))
3542 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3543 ;; This group might be a dead group. In that case we have to get
3544 ;; the number of unread articles from `gnus-active-hashtb'.
3546 (setq number (car entry))
3547 (if (setq active (gnus-gethash group gnus-active-hashtb))
3548 (setq number (- (1+ (cdr active)) (car active)))))
3549 (gnus-summary-read-group
3550 group (or all (and (numberp number)
3551 (zerop (+ number (length (cdr (assq 'tick marked)))
3552 (length (cdr (assq 'dormant marked)))))))
3555 (defun gnus-group-select-group (all)
3556 "Select this newsgroup.
3557 No article is selected automatically.
3558 If argument ALL is non-nil, already read articles become readable."
3560 (gnus-group-read-group all t))
3562 (defun gnus-group-jump-to-group (group)
3563 "Jump to newsgroup GROUP."
3564 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3565 (not (not gnus-read-active-file)))))
3567 (if (equal group "")
3568 (error "empty group name"))
3570 (let ((b (text-property-any (point-min) (point-max)
3571 'gnus-group (intern group))))
3573 ;; Either go to the line in the group buffer...
3575 ;; ... or insert the line.
3577 (gnus-gethash group gnus-active-hashtb)
3578 (gnus-activate-newsgroup group)
3579 (error "%s error: %s" group (gnus-status-message group)))
3581 (gnus-group-update-group group)
3582 (goto-char (text-property-any (point-min) (point-max)
3583 'gnus-group (intern group)))))
3584 ;; Adjust cursor point.
3585 (gnus-group-position-cursor))
3587 (defun gnus-group-goto-group (group)
3588 "Goto to newsgroup GROUP."
3589 (let ((b (text-property-any (point-min) (point-max)
3590 'gnus-group (intern group))))
3591 (and b (goto-char b))))
3593 (defun gnus-group-next-group (n)
3594 "Go to next N'th newsgroup.
3595 If N is negative, search backward instead.
3596 Returns the difference between N and the number of skips actually
3599 (gnus-group-next-unread-group n t))
3601 (defun gnus-group-next-unread-group (n &optional all level)
3602 "Go to next N'th unread newsgroup.
3603 If N is negative, search backward instead.
3604 If ALL is non-nil, choose any newsgroup, unread or not.
3605 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3606 such group can be found, the next group with a level higher than
3608 Returns the difference between N and the number of skips actually
3611 (let ((backward (< n 0))
3614 (gnus-group-search-forward
3615 backward (or (not gnus-group-goto-unread) all) level))
3617 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3618 (if level " on this level or higher" "")))
3621 (defun gnus-group-prev-group (n)
3622 "Go to previous N'th newsgroup.
3623 Returns the difference between N and the number of skips actually
3626 (gnus-group-next-unread-group (- n) t))
3628 (defun gnus-group-prev-unread-group (n)
3629 "Go to previous N'th unread newsgroup.
3630 Returns the difference between N and the number of skips actually
3633 (gnus-group-next-unread-group (- n)))
3635 (defun gnus-group-next-unread-group-same-level (n)
3636 "Go to next N'th unread newsgroup on the same level.
3637 If N is negative, search backward instead.
3638 Returns the difference between N and the number of skips actually
3641 (gnus-group-next-unread-group n t (gnus-group-group-level))
3642 (gnus-group-position-cursor))
3644 (defun gnus-group-prev-unread-group-same-level (n)
3645 "Go to next N'th unread newsgroup on the same level.
3646 Returns the difference between N and the number of skips actually
3649 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3650 (gnus-group-position-cursor))
3652 (defun gnus-group-best-unread-group (&optional exclude-group)
3653 "Go to the group with the highest level.
3654 If EXCLUDE-GROUP, do not go to that group."
3656 (goto-char (point-min))
3659 (while (setq unread (get-text-property (point) 'gnus-unread))
3660 (if (and (numberp unread) (> unread 0))
3662 (or best-point (setq best-point (point)))
3663 (if (and (< (get-text-property (point) 'gnus-level) best)
3664 (or (not exclude-group)
3665 (not (equal exclude-group (gnus-group-group-name)))))
3667 (setq best (get-text-property (point) 'gnus-level))
3668 (setq best-point (point))))))
3670 (if best-point (goto-char best-point))
3671 (gnus-summary-position-cursor)
3672 (and best-point (gnus-group-group-name))))
3674 (defun gnus-group-first-unread-group ()
3675 "Go to the first group with unread articles."
3677 (goto-char (point-min))
3678 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3679 (gnus-group-next-unread-group 1))
3680 (gnus-group-position-cursor))
3682 (defun gnus-group-enter-server-mode ()
3683 "Jump to the server buffer."
3685 (gnus-server-setup-buffer)
3686 (gnus-configure-windows 'server)
3687 (gnus-server-prepare))
3689 (defun gnus-group-make-group (name method address)
3690 "Add a new newsgroup.
3691 The user will be prompted for a NAME, for a select METHOD, and an
3695 (read-string "Group name: ")
3698 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3700 (if (assoc method gnus-valid-select-methods)
3702 (if (memq 'prompt-address
3703 (assoc method gnus-valid-select-methods))
3704 (read-string "Address: ")
3706 (list method nil)))))
3708 (let* ((meth (if address (list (intern method) address) method))
3709 (nname (gnus-group-prefixed-name name meth))
3711 (and (gnus-gethash nname gnus-newsrc-hashtb)
3712 (error "Group %s already exists" nname))
3713 (gnus-group-change-level
3714 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3715 gnus-level-default-subscribed gnus-level-killed
3716 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3717 gnus-newsrc-hashtb) t)
3718 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3720 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3721 (gnus-group-insert-group-line-info nname)
3723 (and (gnus-check-backend-function 'request-create-group nname)
3724 (gnus-request-create-group nname))))
3726 (defun gnus-group-edit-group (group &optional part)
3727 "Edit the group on the current line."
3728 (interactive (list (gnus-group-group-name)))
3729 (let ((done-func '(lambda ()
3730 "Exit editing mode and update the information."
3732 (gnus-group-edit-group-done 'part 'group)))
3733 (part (or part 'info))
3734 (winconf (current-window-configuration))
3736 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3737 (error "No group on current line"))
3738 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3739 (gnus-configure-windows 'edit-group)
3740 (gnus-add-current-to-buffer-list)
3742 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3743 (use-local-map (copy-keymap emacs-lisp-mode-map))
3744 (local-set-key "\C-c\C-c" done-func)
3745 (make-local-variable 'gnus-prev-winconf)
3746 (setq gnus-prev-winconf winconf)
3747 ;; We modify the func to let it know what part it is editing.
3748 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3749 (setcar (cdr (cdr (nth 4 done-func))) group)
3754 ";; Type `C-c C-c' after editing the select method.\n\n")
3756 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3758 ";; Type `C-c C-c' after editing the group info.\n\n")))
3759 (let ((cinfo (gnus-copy-sequence info))
3761 (if (not (setq marked (nth 3 cinfo)))
3764 (or (eq 'score (car (car marked)))
3765 (eq 'bookmark (car (car marked)))
3766 (eq 'killed (car (car marked)))
3767 (setcdr (car marked)
3768 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3769 (setq marked (cdr marked))))
3772 (cond ((eq part 'method)
3773 (or (nth 4 info) "native"))
3780 (defun gnus-group-edit-group-method (group)
3781 "Edit the select method of GROUP."
3782 (interactive (list (gnus-group-group-name)))
3783 (gnus-group-edit-group group 'method))
3785 (defun gnus-group-edit-group-parameters (group)
3786 "Edit the group parameters of GROUP."
3787 (interactive (list (gnus-group-group-name)))
3788 (gnus-group-edit-group group 'params))
3790 (defun gnus-group-edit-group-done (part group)
3791 "Get info from buffer, update variables and jump to the group buffer."
3792 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3793 (goto-char (point-min))
3794 (let ((form (read (current-buffer)))
3795 (winconf gnus-prev-winconf))
3797 (gnus-group-set-info form)
3798 (gnus-group-set-info form group part))
3799 (kill-buffer (current-buffer))
3800 (and winconf (set-window-configuration winconf))
3801 (set-buffer gnus-group-buffer)
3802 (gnus-group-update-group (gnus-group-group-name))
3803 (gnus-group-position-cursor)))
3805 (defun gnus-group-make-help-group ()
3806 "Create the (ding) Gnus documentation group."
3808 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3810 (error "Documentation group already exists"))
3811 (let ((path load-path))
3813 (not (file-exists-p (concat (file-name-as-directory (car path))
3815 (setq path (cdr path)))
3816 (or path (error "Couldn't find doc group"))
3817 (gnus-group-make-group
3819 (concat (file-name-as-directory (car path)) "doc.txt"))
3820 (gnus-group-position-cursor)))
3822 (defun gnus-group-make-archive-group ()
3823 "Create the (ding) Gnus archive group."
3825 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3827 (error "Archive group already exists"))
3828 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3829 (gnus-group-position-cursor))
3831 (defun gnus-group-make-directory-group (dir)
3832 "Create an nndir group.
3833 The user will be prompted for a directory. The contents of this
3834 directory will be used as a newsgroup. The directory should contain
3835 mail messages or news articles in files that have numeric names."
3837 (list (read-file-name "Create group from directory: ")))
3838 (or (file-exists-p dir) (error "No such directory"))
3839 (or (file-directory-p dir) (error "Not a directory"))
3840 (gnus-group-make-group dir "nndir" dir)
3841 (gnus-group-position-cursor))
3843 (defun gnus-group-make-kiboze-group (group address scores)
3844 "Create an nnkiboze group.
3845 The user will be prompted for a name, a regexp to match groups, and
3846 score file entries for articles to include in the group."
3849 (read-string "nnkiboze group name: ")
3850 (read-string "Source groups (regexp): ")
3851 (let ((headers (mapcar (lambda (group) (list group))
3852 '("subject" "from" "number" "date" "message-id"
3853 "references" "chars" "lines" "xref")))
3854 scores header regexp regexps)
3855 (while (not (equal "" (setq header (completing-read
3856 "Match on header: " headers nil t))))
3858 (while (not (equal "" (setq regexp (read-string
3859 (format "Match on %s (string): "
3861 (setq regexps (cons (list regexp nil nil 'r) regexps)))
3862 (setq scores (cons (cons header regexps) scores)))
3864 (gnus-group-make-group group "nnkiboze" address)
3866 (gnus-set-work-buffer)
3867 (let (emacs-lisp-mode-hook)
3868 (pp scores (current-buffer)))
3869 (write-region (point-min) (point-max)
3870 (concat (or gnus-kill-files-directory "~/News")
3871 "nnkiboze:" group "." gnus-score-file-suffix)))
3872 (gnus-group-position-cursor))
3874 (defun gnus-group-add-to-virtual (n vgroup)
3875 "Add the current group to a virtual group."
3877 (list current-prefix-arg
3878 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t)))
3879 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3880 (error "%s is not an nnvirtual group" vgroup))
3881 (let* ((groups (gnus-group-process-prefix n))
3882 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
3883 (setcar (cdr method)
3885 (nth 1 method) "\\|"
3888 (gnus-group-remove-mark s)
3889 (concat "\\(^" (regexp-quote s) "$\\)"))
3892 ;; Group sorting commands
3893 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3895 (defun gnus-group-sort-groups ()
3896 "Sort the group buffer using `gnus-group-sort-function'."
3898 (setq gnus-newsrc-alist
3899 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
3900 (gnus-make-hashtable-from-newsrc-alist)
3901 (gnus-get-unread-articles (1+ gnus-level-subscribed))
3902 (gnus-group-list-groups nil))
3904 (defun gnus-group-sort-by-alphabet (info1 info2)
3905 (string< (car info1) (car info2)))
3907 (defun gnus-group-sort-by-unread (info1 info2)
3908 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3909 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3910 (< (or (and (numberp n1) n1) 0)
3911 (or (and (numberp n2) n2) 0))))
3913 (defun gnus-group-sort-by-level (info1 info2)
3914 (< (nth 1 info1) (nth 1 info2)))
3916 ;; Group catching up.
3918 (defun gnus-group-catchup-current (n &optional all)
3919 "Mark all articles not marked as unread in current newsgroup as read.
3920 If prefix argument N is numeric, the ARG next newsgroups will be
3921 caught up. If ALL is non-nil, marked articles will also be marked as
3922 read. Cross references (Xref: header) of articles are ignored.
3923 The difference between N and actual number of newsgroups that were
3924 caught up is returned."
3926 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
3930 "Do you really want to mark all articles as read? "
3931 "Mark all unread articles as read? "))))
3933 (let ((groups (gnus-group-process-prefix n))
3936 (gnus-group-remove-mark (car groups))
3937 (if (not (gnus-group-goto-group (car groups)))
3939 (gnus-group-catchup (car groups) all)
3940 (gnus-group-update-group-line))
3941 (setq groups (cdr groups)))
3942 (gnus-group-next-unread-group 1)
3945 (defun gnus-group-catchup-current-all (n)
3946 "Mark all articles in current newsgroup as read.
3947 Cross references (Xref: header) of articles are ignored."
3949 (gnus-group-catchup-current n 'all))
3951 (defun gnus-group-catchup (group &optional all)
3952 "Mark all articles in GROUP as read.
3953 If ALL is non-nil, all articles are marked as read.
3954 The return value is the number of articles that were marked as read,
3955 or nil if no action could be taken."
3956 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3958 (marked (nth 3 (nth 2 entry)))
3960 (if (not (numberp (car entry)))
3961 (gnus-message 1 "Can't catch up; non-active group")
3962 ;; Do the updating only if the newsgroup isn't killed.
3965 (setq ticked (if all nil (cdr (assq 'tick marked))))
3966 (gnus-update-read-articles group ticked nil ticked)
3967 (if (and all marked)
3968 (setcar (nthcdr 3 (nth 2 entry))
3969 (delq (assq 'dormant marked) marked))))))
3972 (defun gnus-group-expire-articles (n)
3973 "Expire all expirable articles in the current newsgroup."
3975 (let ((groups (gnus-group-process-prefix n))
3977 (or groups (error "No groups to expire"))
3979 (setq group (car groups)
3980 groups (cdr groups))
3981 (gnus-group-remove-mark group)
3982 (if (not (gnus-check-backend-function 'request-expire-articles group))
3984 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3985 (expirable (if (memq 'total-expire (nth 5 info))
3986 (cons nil (gnus-list-of-read-articles group))
3987 (assq 'expire (nth 3 info)))))
3990 (gnus-request-expire-articles
3991 (cdr expirable) group))))))))
3993 (defun gnus-group-expire-all-groups ()
3994 "Expire all expirable articles in all newsgroups."
3996 (gnus-message 5 "Expiring...")
3997 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
3998 (cdr gnus-newsrc-alist))))
3999 (gnus-group-expire-articles nil))
4000 (gnus-message 5 "Expiring...done"))
4002 (defun gnus-group-set-current-level (n level)
4003 "Set the level of the next N groups to LEVEL."
4004 (interactive "P\nnLevel: ")
4005 (or (and (>= level 1) (<= level gnus-level-killed))
4006 (error "Illegal level: %d" level))
4007 (let ((groups (gnus-group-process-prefix n))
4010 (setq group (car groups)
4011 groups (cdr groups))
4012 (gnus-group-remove-mark group)
4013 (gnus-message 6 "Changed level of %s from %d to %d"
4014 group (gnus-group-group-level) level)
4015 (gnus-group-change-level group level
4016 (gnus-group-group-level))
4017 (gnus-group-update-group-line)))
4018 (gnus-group-position-cursor))
4020 (defun gnus-group-unsubscribe-current-group (arg)
4021 "Toggle subscribe from/to unsubscribe current group."
4023 (let ((group (gnus-group-group-name)))
4024 (or group (error "No newsgroup on current line"))
4025 (or arg (setq arg (if (<= (gnus-group-group-level) gnus-level-subscribed)
4026 gnus-level-default-unsubscribed
4027 gnus-level-default-subscribed)))
4028 (gnus-group-unsubscribe-group group arg)
4029 (gnus-group-next-group 1)))
4031 (defun gnus-group-unsubscribe-group (group &optional level)
4032 "Toggle subscribe from/to unsubscribe GROUP.
4033 New newsgroup is added to .newsrc automatically."
4035 (list (completing-read "Group: " gnus-active-hashtb nil
4036 gnus-have-read-active-file)))
4037 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4039 ;; Toggle subscription flag.
4040 (gnus-group-change-level
4041 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4042 gnus-level-subscribed)
4043 (1+ gnus-level-subscribed)
4044 gnus-level-default-subscribed)))
4045 (gnus-group-update-group group))
4046 ((and (stringp group)
4047 (or (not gnus-have-read-active-file)
4048 (gnus-gethash group gnus-active-hashtb)))
4049 ;; Add new newsgroup.
4050 (gnus-group-change-level
4052 (if level level gnus-level-default-subscribed)
4053 (or (and (member group gnus-zombie-list)
4056 (and (gnus-group-group-name)
4057 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4058 (gnus-group-update-group group))
4059 (t (error "No such newsgroup: %s" group)))
4060 (gnus-group-position-cursor)))
4062 (defun gnus-group-transpose-groups (n)
4063 "Move the current newsgroup up N places.
4064 If given a negative prefix, move down instead. The difference between
4065 N and the number of steps taken is retured."
4067 (or (gnus-group-group-name)
4068 (error "No group on current line"))
4069 (gnus-group-kill-group 1)
4071 (forward-line (- n))
4072 (gnus-group-yank-group)
4073 (gnus-group-position-cursor)))
4075 (defun gnus-group-kill-all-zombies ()
4076 "Kill all zombie newsgroups."
4078 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4079 (setq gnus-zombie-list nil)
4080 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4081 (goto-char (point-min))
4082 (gnus-group-position-cursor))
4084 (defun gnus-group-kill-region (begin end)
4085 "Kill newsgroups in current region (excluding current point).
4086 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4089 ;; Exclude a line where current point is on.
4103 (beginning-of-line) ;Important when LINES < 1
4104 (gnus-group-kill-group lines)))
4106 (defun gnus-group-kill-group (n)
4107 "The the next N groups.
4108 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4109 However, only groups that were alive can be yanked; already killed
4110 groups or zombie groups can't be yanked.
4111 The return value is the name of the (last) group that was killed."
4113 (let ((buffer-read-only nil)
4114 (groups (gnus-group-process-prefix n))
4117 (setq group (car groups)
4118 groups (cdr groups))
4119 (gnus-group-remove-mark group)
4120 (setq level (gnus-group-group-level))
4122 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4123 (setq gnus-list-of-killed-groups
4124 (cons (cons (car entry) (nth 2 entry))
4125 gnus-list-of-killed-groups)))
4126 (gnus-group-change-level
4127 (if entry entry group) gnus-level-killed (if entry nil level)))
4128 (gnus-group-position-cursor)
4131 (defun gnus-group-yank-group (&optional arg)
4132 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4133 inserting it before the current newsgroup. The numeric ARG specifies
4134 how many newsgroups are to be yanked. The name of the (last)
4135 newsgroup yanked is returned."
4137 (if (not arg) (setq arg 1))
4138 (let (info group prev)
4139 (while (>= (setq arg (1- arg)) 0)
4140 (if (not (setq info (car gnus-list-of-killed-groups)))
4141 (error "No more newsgroups to yank"))
4142 (setq group (nth 2 info))
4143 ;; Find which newsgroup to insert this one before - search
4144 ;; backward until something suitable is found. If there are no
4145 ;; other newsgroups in this buffer, just make this newsgroup the
4147 (setq prev (gnus-group-group-name))
4148 (gnus-group-change-level
4149 info (nth 2 info) gnus-level-killed
4150 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4152 (gnus-group-insert-group-line-info (nth 1 info))
4153 (setq gnus-list-of-killed-groups
4154 (cdr gnus-list-of-killed-groups)))
4156 (gnus-group-position-cursor)
4159 (defun gnus-group-list-all-groups (arg)
4160 "List all newsgroups with level ARG or lower.
4161 Default is gnus-level-unsubscribed, which lists all subscribed and most
4162 unsubscribed groups."
4164 (setq arg (or arg gnus-level-unsubscribed))
4165 (gnus-group-list-groups arg t))
4167 (defun gnus-group-list-killed ()
4168 "List all killed newsgroups in the group buffer."
4170 (if (not gnus-killed-list)
4171 (gnus-message 6 "No killed groups")
4172 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4173 (goto-char (point-min)))
4174 (gnus-group-position-cursor))
4176 (defun gnus-group-list-zombies ()
4177 "List all zombie newsgroups in the group buffer."
4179 (if (not gnus-zombie-list)
4180 (gnus-message 6 "No zombie groups")
4181 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4182 (goto-char (point-min)))
4183 (gnus-group-position-cursor))
4185 (defun gnus-group-get-new-news (&optional arg)
4186 "Get newly arrived articles.
4187 If ARG is non-nil, it should be a number between one and nine to
4188 specify which levels you are interested in re-scanning."
4190 (run-hooks 'gnus-get-new-news-hook)
4192 (if gnus-group-use-permanent-levels
4195 (setq gnus-group-default-list-level level)
4196 (setq level (or gnus-group-default-list-level
4197 gnus-level-subscribed)))))
4198 (if (and gnus-read-active-file (not level))
4200 (gnus-read-active-file)
4201 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
4202 (let ((gnus-read-active-file nil))
4203 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))))
4204 (gnus-group-list-groups (or (and gnus-group-use-permanent-levels level)
4205 gnus-level-subscribed)
4206 gnus-have-all-newsgroups)))
4208 (defun gnus-group-get-new-news-this-group (n)
4209 "Check for newly arrived news in the current group (and the N-1 next groups).
4210 The difference between N and the number of newsgroup checked is returned.
4211 If N is negative, this group and the N-1 previous groups will be checked."
4213 (let* ((groups (gnus-group-process-prefix n))
4214 (ret (if (numberp n) (- n (length groups)) 0))
4215 (w-p (window-start))
4218 (setq group (car groups)
4219 groups (cdr groups))
4220 (gnus-group-remove-mark group)
4221 (or (gnus-get-new-news-in-group group)
4224 (message "%s error: %s" group (gnus-status-message group))
4226 ;; !!! I don't know why the buffer scrolls forward when updating
4227 ;; the first line in the group buffer, but it does. So we set the
4228 ;; window start forcibly.
4229 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4231 (gnus-summary-position-cursor)
4234 (defun gnus-get-new-news-in-group (group)
4236 (gnus-activate-newsgroup group)
4238 (gnus-get-unread-articles-in-group
4239 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4240 (gnus-gethash group gnus-active-hashtb))
4241 (gnus-group-update-group-line)
4244 (defun gnus-group-fetch-faq (group)
4245 "Fetch the FAQ for the current group."
4246 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4247 (or group (error "No group name given"))
4248 (let ((file (concat gnus-group-faq-directory group)))
4249 (if (not (file-exists-p file))
4250 (error "No such file: %s" file)
4253 (defun gnus-group-describe-group (force &optional group)
4254 "Display a description of the current newsgroup."
4256 (and force (setq gnus-description-hashtb nil))
4257 (let ((group (or group (gnus-group-group-name)))
4259 (or group (error "No group name given"))
4260 (and (or gnus-description-hashtb
4261 (setq desc (gnus-group-get-description group))
4262 (gnus-read-descriptions-file))
4264 (or desc (gnus-gethash group gnus-description-hashtb)
4265 "No description available")))))
4267 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4268 (defun gnus-group-describe-all-groups (force)
4269 "Pop up a buffer with descriptons of all newsgroups."
4271 (and force (setq gnus-description-hashtb nil))
4272 (if (not (or gnus-description-hashtb
4273 (gnus-read-descriptions-file)))
4274 (error "Couldn't request descriptions file"))
4275 (let ((buffer-read-only nil)
4281 (insert (format " *: %-20s %s\n" (symbol-name group)
4282 (symbol-value group)))
4283 (add-text-properties
4284 b (1+ b) (list 'gnus-group group
4285 'gnus-unread t 'gnus-marked nil
4286 'gnus-level (1+ gnus-level-subscribed))))
4287 gnus-description-hashtb)
4288 (goto-char (point-min))
4289 (gnus-group-position-cursor)))
4291 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4292 (defun gnus-group-apropos (regexp &optional search-description)
4293 "List all newsgroups that have names that match a regexp."
4294 (interactive "sGnus apropos (regexp): ")
4296 (obuf (current-buffer))
4298 ;; Go through all newsgroups that are known to Gnus.
4301 (and (string-match regexp (symbol-name group))
4302 (setq groups (cons (symbol-name group) groups))))
4304 ;; Go through all descriptions that are known to Gnus.
4305 (if search-description
4308 (and (string-match regexp (symbol-value group))
4309 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4310 (setq groups (cons (symbol-name group) groups))))
4311 gnus-description-hashtb))
4313 (gnus-message 3 "No groups matched \"%s\"." regexp)
4314 ;; Print out all the groups.
4316 (pop-to-buffer "*Gnus Help*")
4317 (buffer-disable-undo (current-buffer))
4319 (setq groups (sort groups 'string<))
4321 ;; Groups may be entered twice into the list of groups.
4322 (if (not (string= (car groups) prev))
4324 (insert (setq prev (car groups)) "\n")
4325 (if (and gnus-description-hashtb
4326 (setq des (gnus-gethash (car groups)
4327 gnus-description-hashtb)))
4328 (insert " " des "\n"))))
4329 (setq groups (cdr groups)))
4330 (goto-char (point-min))))
4331 (pop-to-buffer obuf)))
4333 (defun gnus-group-description-apropos (regexp)
4334 "List all newsgroups that have names or desccriptions that match a regexp."
4335 (interactive "sGnus description apropos (regexp): ")
4336 (if (not (or gnus-description-hashtb
4337 (gnus-read-descriptions-file)))
4338 (error "Couldn't request descriptions file"))
4339 (gnus-group-apropos regexp t))
4341 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4342 (defun gnus-group-list-matching (level regexp &optional all lowest)
4343 "List all groups with unread articles that match REGEXP.
4344 If the prefix LEVEL is non-nil, it should be a number that says which
4345 level to cut off listing groups.
4346 If ALL, also list groups with no unread articles.
4347 If LOWEST, don't list groups with level lower than LOWEST."
4348 (interactive "P\nsList newsgroups matching: ")
4349 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4350 all (or lowest 1) regexp)
4351 (goto-char (point-min))
4352 (gnus-group-position-cursor))
4354 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4355 "List all groups that match REGEXP.
4356 If the prefix LEVEL is non-nil, it should be a number that says which
4357 level to cut off listing groups.
4358 If LOWEST, don't list groups with level lower than LOWEST."
4359 (interactive "P\nsList newsgroups matching: ")
4360 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4362 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4363 (defun gnus-group-save-newsrc ()
4364 "Save the Gnus startup files."
4366 (gnus-save-newsrc-file))
4368 (defun gnus-group-restart (&optional arg)
4369 "Force Gnus to read the .newsrc file."
4371 (gnus-save-newsrc-file)
4372 (gnus-setup-news 'force)
4373 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4375 (defun gnus-group-read-init-file ()
4376 "Read the Gnus elisp init file."
4378 (gnus-read-init-file))
4380 (defun gnus-group-check-bogus-groups ()
4381 "Check bogus newsgroups."
4383 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4384 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4386 (defun gnus-group-mail ()
4387 "Start composing a mail."
4391 (defun gnus-group-edit-global-kill (article &optional group)
4392 "Edit the global kill file.
4393 If GROUP, edit that local kill file instead."
4395 (setq gnus-current-kill-article article)
4396 (gnus-kill-file-edit-file group)
4398 (substitute-command-keys
4399 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4401 (defun gnus-group-edit-local-kill (article group)
4402 "Edit a local kill file."
4403 (interactive (list nil (gnus-group-group-name)))
4404 (gnus-group-edit-global-kill article group))
4406 (defun gnus-group-force-update ()
4407 "Update `.newsrc' file."
4409 (gnus-save-newsrc-file))
4411 (defun gnus-group-suspend ()
4412 "Suspend the current Gnus session.
4413 In fact, cleanup buffers except for group mode buffer.
4414 The hook gnus-suspend-gnus-hook is called before actually suspending."
4416 (run-hooks 'gnus-suspend-gnus-hook)
4417 ;; Kill Gnus buffers except for group mode buffer.
4418 (let ((group-buf (get-buffer gnus-group-buffer)))
4419 ;; Do this on a separate list in case the user does a ^G before we finish
4420 (let ((gnus-buffer-list
4421 (delq group-buf (delq gnus-dribble-buffer
4422 (append gnus-buffer-list nil)))))
4423 (while gnus-buffer-list
4424 (gnus-kill-buffer (car gnus-buffer-list))
4425 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4428 (setq gnus-buffer-list (list group-buf))
4429 (bury-buffer group-buf)
4430 (delete-windows-on group-buf t)))))
4432 (defun gnus-group-clear-dribble ()
4433 "Clear all information from the dribble buffer."
4435 (gnus-dribble-clear))
4437 (defun gnus-group-exit ()
4438 "Quit reading news after updating .newsrc.eld and .newsrc.
4439 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4441 (if (or noninteractive ;For gnus-batch-kill
4442 (zerop (buffer-size)) ;No news is good news.
4443 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4444 (not gnus-interactive-exit) ;Without confirmation
4446 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4448 (run-hooks 'gnus-exit-gnus-hook)
4449 (gnus-save-newsrc-file)
4450 (gnus-close-backends)
4451 (gnus-clear-system))))
4453 (defun gnus-close-backends ()
4454 ;; Send a close request to all backends that support such a request.
4455 (let ((methods gnus-valid-select-methods)
4458 (if (fboundp (setq func (intern (concat (car (car methods))
4459 "-request-close"))))
4461 (setq methods (cdr methods)))))
4463 (defun gnus-group-quit ()
4464 "Quit reading news without updating .newsrc.eld or .newsrc.
4465 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4467 (if (or noninteractive ;For gnus-batch-kill
4468 (zerop (buffer-size))
4469 (not (gnus-server-opened gnus-select-method))
4471 (not gnus-current-startup-file)
4473 (format "Quit reading news without saving %s? "
4474 (file-name-nondirectory gnus-current-startup-file))))
4476 (run-hooks 'gnus-exit-gnus-hook)
4478 (gnus-close-backends)
4479 (gnus-clear-system))))
4481 (defun gnus-group-describe-briefly ()
4482 "Give a one line description of the group mode commands."
4485 (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")))
4487 (defun gnus-group-browse-foreign-server (method)
4488 "Browse a foreign news server.
4489 If called interactively, this function will ask for a select method
4490 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4491 If not, METHOD should be a list where the first element is the method
4492 and the second element is the address."
4494 (list (let ((how (completing-read
4496 (append gnus-valid-select-methods gnus-server-alist)
4498 ;; We either got a backend name or a virtual server name.
4499 ;; If the first, we also need an address.
4500 (if (assoc how gnus-valid-select-methods)
4502 ;; Suggested by mapjph@bath.ac.uk.
4505 (mapcar (lambda (server) (list server))
4506 gnus-secondary-servers)))
4507 ;; We got a server name, so we find the method.
4508 (gnus-server-to-method how)))))
4509 (gnus-browse-foreign-server method))
4513 ;;; Browse Server Mode
4516 (defvar gnus-browse-mode-hook nil)
4517 (defvar gnus-browse-mode-map nil)
4518 (put 'gnus-browse-mode 'mode-class 'special)
4520 (if gnus-browse-mode-map
4522 (setq gnus-browse-mode-map (make-keymap))
4523 (suppress-keymap gnus-browse-mode-map)
4524 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4525 (define-key gnus-browse-mode-map "=" 'gnus-browse-read-group)
4526 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4527 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4528 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4529 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4530 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4531 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4532 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4533 (define-key gnus-browse-mode-map "\r" 'gnus-browse-read-group)
4534 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4535 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4536 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4537 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4538 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4539 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4540 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4541 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4544 (defvar gnus-browse-current-method nil)
4545 (defvar gnus-browse-return-buffer nil)
4547 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4549 (defun gnus-browse-foreign-server (method &optional return-buffer)
4550 (setq gnus-browse-current-method method)
4551 (setq gnus-browse-return-buffer return-buffer)
4552 (let ((gnus-select-method method)
4554 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4555 (or (gnus-server-opened method)
4556 (gnus-open-server method)
4557 (error "Unable to contact server: %s" (gnus-status-message method)))
4558 (or (gnus-request-list method)
4559 (error "Couldn't request list: %s" (gnus-status-message method)))
4560 (get-buffer-create gnus-browse-buffer)
4561 (gnus-add-current-to-buffer-list)
4562 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4563 (gnus-configure-windows 'browse)
4564 (buffer-disable-undo (current-buffer))
4565 (let ((buffer-read-only nil))
4568 (setq mode-line-buffer-identification
4570 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4572 (set-buffer nntp-server-buffer)
4573 (let ((cur (current-buffer)))
4574 (goto-char (point-min))
4575 (or (string= gnus-ignored-newsgroups "")
4576 (delete-matching-lines gnus-ignored-newsgroups))
4577 (while (re-search-forward
4578 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4579 (goto-char (match-end 1))
4580 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4582 (max 0 (- (1+ (read cur)) (read cur))))
4584 (setq groups (sort groups
4586 (string< (car l1) (car l2)))))
4587 (let ((buffer-read-only nil))
4589 (setq group (car groups))
4591 (format "K%7d: %s\n" (cdr group) (car group)))
4592 (setq groups (cdr groups))))
4593 (switch-to-buffer (current-buffer))
4594 (goto-char (point-min))
4595 (gnus-group-position-cursor)))
4597 (defun gnus-browse-mode ()
4598 "Major mode for browsing a foreign server."
4600 (kill-all-local-variables)
4601 (if gnus-visual (gnus-browse-make-menu-bar))
4602 (setq mode-line-modified "-- ")
4603 (make-local-variable 'mode-line-format)
4604 (setq mode-line-format (copy-sequence mode-line-format))
4605 (and (equal (nth 3 mode-line-format) " ")
4606 (setcar (nthcdr 3 mode-line-format) ""))
4607 (setq major-mode 'gnus-browse-mode)
4608 (setq mode-name "Browse Server")
4609 (setq mode-line-process nil)
4610 (use-local-map gnus-browse-mode-map)
4611 (buffer-disable-undo (current-buffer))
4612 (setq truncate-lines t)
4613 (setq buffer-read-only t)
4614 (run-hooks 'gnus-browse-mode-hook))
4616 (defun gnus-browse-read-group ()
4617 "Not implemented, and will probably never be."
4619 (error "You can't read while browsing"))
4621 (defun gnus-browse-next-group (n)
4622 "Go to the next group."
4626 (gnus-group-position-cursor)))
4628 (defun gnus-browse-prev-group (n)
4629 "Go to the next group."
4631 (gnus-browse-next-group (- n)))
4633 (defun gnus-browse-unsubscribe-current-group (arg)
4634 "(Un)subscribe to the next ARG groups."
4637 (error "No group at current line."))
4638 (let ((ward (if (< arg 0) -1 1))
4640 (while (and (> arg 0)
4642 (gnus-browse-unsubscribe-group)
4643 (zerop (gnus-browse-next-group ward)))
4644 (setq arg (1- arg)))
4645 (gnus-group-position-cursor)
4646 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
4649 (defun gnus-browse-unsubscribe-group ()
4651 (buffer-read-only nil)
4655 (if (= (following-char) ?K) (setq sub t))
4656 (re-search-forward ": \\(.*\\)$" nil t)
4657 (setq group (gnus-group-prefixed-name
4658 (buffer-substring (match-beginning 1) (match-end 1))
4659 gnus-browse-current-method))
4664 (gnus-group-change-level
4665 (list t group gnus-level-default-subscribed
4666 nil nil gnus-browse-current-method)
4667 gnus-level-default-subscribed gnus-level-killed
4668 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
4671 (gnus-group-change-level
4672 group gnus-level-killed gnus-level-default-subscribed)
4676 (defun gnus-browse-exit ()
4677 "Quit browsing and return to the group buffer."
4679 (if (eq major-mode 'gnus-browse-mode)
4680 (kill-buffer (current-buffer)))
4681 (if gnus-browse-return-buffer
4682 (gnus-configure-windows 'server)
4683 (gnus-configure-windows 'group)))
4685 (defun gnus-browse-describe-briefly ()
4686 "Give a one line description of the group mode commands."
4689 (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")))
4693 ;;; Gnus summary mode
4696 (defvar gnus-summary-mode-map nil)
4697 (defvar gnus-summary-mark-map nil)
4698 (defvar gnus-summary-mscore-map nil)
4699 (defvar gnus-summary-article-map nil)
4700 (defvar gnus-summary-thread-map nil)
4701 (defvar gnus-summary-goto-map nil)
4702 (defvar gnus-summary-exit-map nil)
4703 (defvar gnus-summary-various-map nil)
4704 (defvar gnus-summary-interest-map nil)
4705 (defvar gnus-summary-sort-map nil)
4706 (defvar gnus-summary-backend-map nil)
4707 (defvar gnus-summary-save-map nil)
4708 (defvar gnus-summary-wash-map nil)
4709 (defvar gnus-summary-help-map nil)
4711 (put 'gnus-summary-mode 'mode-class 'special)
4713 (if gnus-summary-mode-map
4715 (setq gnus-summary-mode-map (make-keymap))
4716 (suppress-keymap gnus-summary-mode-map)
4718 ;; Non-orthogonal keys
4720 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4721 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4722 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4723 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4724 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4725 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4726 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4727 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4728 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4729 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4730 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4731 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4732 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4733 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4734 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4735 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4736 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4737 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4738 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4739 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4740 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4741 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4742 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4743 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4744 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4745 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4746 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4747 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4748 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4749 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4750 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4751 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4752 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4753 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4754 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4755 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4756 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4757 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4758 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4759 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4760 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4761 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4762 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4763 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4764 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4765 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4766 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4767 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4768 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4769 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4770 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4771 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4772 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4773 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4774 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4775 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4776 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4777 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4778 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4779 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4780 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4781 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4782 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4783 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4784 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4785 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4786 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4787 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4788 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4789 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4790 (define-key gnus-summary-mode-map "V" 'gnus-version)
4791 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4792 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4793 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4794 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4795 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
4796 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4797 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4798 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
4799 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4800 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4801 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4802 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4803 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4804 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4805 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4806 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4809 ;; Sort of orthogonal keymap
4810 (define-prefix-command 'gnus-summary-mark-map)
4811 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4812 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4813 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4814 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4815 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4816 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4817 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4818 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4819 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4820 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4821 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4822 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4823 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4824 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4825 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4826 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4827 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4828 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4829 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4830 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4831 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4832 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4833 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4834 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4836 (define-prefix-command 'gnus-summary-mscore-map)
4837 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4838 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4839 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4840 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4841 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4843 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
4845 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4847 (define-prefix-command 'gnus-summary-goto-map)
4848 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4849 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4850 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4851 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4852 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4853 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4854 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4855 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4856 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4857 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4858 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4859 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4860 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4861 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4864 (define-prefix-command 'gnus-summary-thread-map)
4865 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4866 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4867 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4868 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4869 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4870 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4871 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4872 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4873 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4874 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4875 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4876 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4877 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4878 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4881 (define-prefix-command 'gnus-summary-exit-map)
4882 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4883 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4884 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4885 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4886 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4887 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4888 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4889 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
4890 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
4891 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
4892 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
4895 (define-prefix-command 'gnus-summary-article-map)
4896 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4897 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4898 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4899 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4900 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4901 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4902 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4903 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4904 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4905 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4906 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4907 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4908 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4909 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4910 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4911 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4912 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4913 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4916 (define-prefix-command 'gnus-summary-wash-map)
4917 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
4918 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
4919 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
4920 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
4921 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
4922 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
4923 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
4924 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
4925 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
4926 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
4927 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
4928 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
4930 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
4931 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
4932 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
4933 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
4934 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
4935 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
4938 (define-prefix-command 'gnus-summary-help-map)
4939 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
4940 (define-key gnus-summary-help-map "v" 'gnus-version)
4941 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
4942 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
4943 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
4944 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
4947 (define-prefix-command 'gnus-summary-backend-map)
4948 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
4949 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
4950 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
4951 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
4952 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
4953 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
4954 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
4955 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
4958 (define-prefix-command 'gnus-summary-save-map)
4959 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
4960 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
4961 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
4962 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
4963 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
4964 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
4965 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
4966 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
4968 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
4970 (define-prefix-command 'gnus-summary-various-map)
4971 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4972 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4973 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4974 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4975 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4976 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4977 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4978 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4979 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4980 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4981 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4983 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4985 (define-prefix-command 'gnus-summary-sort-map)
4986 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4987 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4988 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4989 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4990 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4991 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4993 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
4994 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
5000 (defun gnus-summary-mode ()
5001 "Major mode for reading articles.
5003 All normal editing commands are switched off.
5004 \\<gnus-summary-mode-map>
5005 Each line in this buffer represents one article. To read an
5006 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5007 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5010 You can also post articles and send mail from this buffer. To
5011 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5012 of an article, type `\\[gnus-summary-reply]'.
5014 There are approx. one gazillion commands you can execute in this
5015 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5017 The following commands are available:
5019 \\{gnus-summary-mode-map}"
5021 (if gnus-visual (gnus-summary-make-menu-bar))
5022 (kill-all-local-variables)
5023 (let ((locals gnus-summary-local-variables))
5025 (if (consp (car locals))
5027 (make-local-variable (car (car locals)))
5028 (set (car (car locals)) (eval (cdr (car locals)))))
5029 (make-local-variable (car locals))
5030 (set (car locals) nil))
5031 (setq locals (cdr locals))))
5032 (gnus-make-thread-indent-array)
5033 (gnus-update-format-specifications)
5034 (setq mode-line-modified "-- ")
5035 (make-local-variable 'mode-line-format)
5036 (setq mode-line-format (copy-sequence mode-line-format))
5037 (and (equal (nth 3 mode-line-format) " ")
5038 (setcar (nthcdr 3 mode-line-format) ""))
5039 (setq major-mode 'gnus-summary-mode)
5040 (setq mode-name "Summary")
5041 (make-local-variable 'minor-mode-alist)
5042 (use-local-map gnus-summary-mode-map)
5043 (buffer-disable-undo (current-buffer))
5044 (setq buffer-read-only t) ;Disable modification
5045 (setq truncate-lines t)
5046 (setq selective-display t)
5047 (setq selective-display-ellipses t) ;Display `...'
5048 (setq buffer-display-table gnus-summary-display-table)
5049 (run-hooks 'gnus-summary-mode-hook))
5051 (defun gnus-summary-make-display-table ()
5052 ;; Change the display table. Odd characters have a tendency to mess
5053 ;; up nicely formatted displays - we make all possible glyphs
5054 ;; display only a single character.
5056 ;; We start from the standard display table, if any.
5057 (setq gnus-summary-display-table
5058 (or (copy-sequence standard-display-table)
5059 (make-display-table)))
5060 ;; Nix out all the control chars...
5062 (while (>= (setq i (1- i)) 0)
5063 (aset gnus-summary-display-table i [??])))
5064 ;; ... but not newline, of course.
5065 (aset gnus-summary-display-table ?\n nil)
5066 ;; We nix out any glyphs over 126 that are not set already.
5068 (while (>= (setq i (1- i)) 127)
5069 ;; Only modify if the entry is nil.
5070 (or (aref gnus-summary-display-table i)
5071 (aset gnus-summary-display-table i [??])))))
5073 (defun gnus-summary-clear-local-variables ()
5074 (let ((locals gnus-summary-local-variables))
5076 (if (consp (car locals))
5077 (and (vectorp (car (car locals)))
5078 (set (car (car locals)) nil))
5079 (and (vectorp (car locals))
5080 (set (car locals) nil)))
5081 (setq locals (cdr locals)))))
5083 (defun gnus-mouse-pick-article (e)
5086 (gnus-summary-next-page nil t))
5088 (defun gnus-summary-setup-buffer (group)
5089 "Initialize summary buffer."
5090 (let ((buffer (concat "*Summary " group "*")))
5091 (if (get-buffer buffer)
5094 (not gnus-newsgroup-threads))
5095 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5096 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5097 (gnus-add-current-to-buffer-list)
5099 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5100 (setq gnus-newsgroup-name group)
5103 (defun gnus-set-global-variables ()
5104 ;; Set the global equivalents of the summary buffer-local variables
5105 ;; to the latest values they had. These reflect the summary buffer
5106 ;; that was in action when the last article was fetched.
5107 (if (eq major-mode 'gnus-summary-mode)
5109 (setq gnus-summary-buffer (current-buffer))
5110 (let ((name gnus-newsgroup-name)
5111 (marked gnus-newsgroup-marked)
5112 (unread gnus-newsgroup-unreads)
5113 (headers gnus-current-headers)
5114 (score-file gnus-current-score-file))
5116 (set-buffer gnus-group-buffer)
5117 (setq gnus-newsgroup-name name)
5118 (setq gnus-newsgroup-marked marked)
5119 (setq gnus-newsgroup-unreads unread)
5120 (setq gnus-current-headers headers)
5121 (setq gnus-current-score-file score-file))))))
5123 (defun gnus-summary-insert-dummy-line (sformat subject number)
5125 (setq sformat gnus-summary-dummy-line-format-spec))
5129 (insert (eval sformat))
5130 (add-text-properties
5132 (list 'gnus (list number ?Z 0)))))
5134 (defvar gnus-thread-indent-array nil)
5135 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5136 (defun gnus-make-thread-indent-array ()
5138 (if (and gnus-thread-indent-array
5139 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5141 (setq gnus-thread-indent-array (make-vector 201 "")
5142 gnus-thread-indent-array-level gnus-thread-indent-level)
5144 (aset gnus-thread-indent-array n
5145 (make-string (* n gnus-thread-indent-level) ? ))
5148 (defun gnus-summary-insert-line
5149 (sformat header level current unread replied expirable subject-or-nil
5150 &optional dummy score)
5151 (or sformat (setq sformat gnus-summary-line-format-spec))
5152 (let* ((indentation (aref gnus-thread-indent-array level))
5153 (lines (header-lines header))
5154 (score (or score gnus-summary-default-score 0))
5155 (score-char (if (or (null gnus-summary-default-score)
5156 (= score gnus-summary-default-score)) ?
5157 (if (< score gnus-summary-default-score)
5158 gnus-score-below-mark gnus-score-over-mark)))
5159 (replied (if replied gnus-replied-mark ? ))
5160 (from (header-from header))
5161 (name-address (funcall gnus-extract-address-components from))
5162 (address (car (cdr name-address)))
5163 (name (or (car name-address) (car (cdr name-address))))
5164 (subject (header-subject header))
5165 (number (header-number header))
5166 (opening-bracket (if dummy ?\< ?\[))
5167 (closing-bracket (if dummy ?\> ?\]))
5168 (buffer-read-only nil)
5169 (b (progn (beginning-of-line) (point))))
5170 (or (numberp lines) (setq lines 0))
5171 (insert (eval sformat))
5172 (add-text-properties
5173 b (1+ b) (list 'gnus (list number (or unread gnus-unread-mark) level)))))
5175 (defun gnus-summary-update-line (&optional dont-update)
5176 ;; Update summary line after change.
5177 (or (not gnus-summary-default-score)
5178 gnus-summary-inhibit-highlight
5179 (let ((gnus-summary-inhibit-highlight t)
5180 (article (gnus-summary-article-number)))
5183 (if (and gnus-summary-mark-below
5184 (< (gnus-summary-article-score)
5185 gnus-summary-mark-below))
5186 (and (not (memq article gnus-newsgroup-marked))
5187 (not (memq article gnus-newsgroup-dormant))
5188 (memq article gnus-newsgroup-unreads)
5189 (gnus-summary-mark-article nil gnus-low-score-mark))
5190 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5191 (gnus-summary-mark-article nil gnus-unread-mark))))
5193 (run-hooks 'gnus-summary-update-hook))))))
5195 (defun gnus-summary-update-lines (&optional beg end)
5196 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5197 (let ((beg (or beg (point-min)))
5198 (end (or end (point-max))))
5200 (set-buffer gnus-summary-buffer)
5202 (while (and (not (eobp)) (< (point) end))
5203 (gnus-summary-update-line)
5204 (forward-line 1)))))
5206 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5207 ;; Sum up all elements (and sub-elements) in a list.
5211 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5214 (if (> number 1) gnus-not-empty-thread-mark
5215 gnus-empty-thread-mark)
5218 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5219 "Start reading news in newsgroup GROUP.
5220 If SHOW-ALL is non-nil, already read articles are also listed.
5221 If NO-ARTICLE is non-nil, no article is selected initially."
5222 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5223 (let* ((new-group (gnus-summary-setup-buffer group))
5224 (did-select (and new-group (gnus-select-newsgroup group show-all)))
5225 (method (car (gnus-find-method-for-group group))))
5228 (gnus-set-global-variables)
5229 (gnus-kill-buffer kill-buffer)
5230 (gnus-configure-windows 'summary)
5231 (gnus-set-mode-line 'summary)
5232 (gnus-summary-position-cursor)
5236 (and (eq major-mode 'gnus-summary-mode)
5237 (not (equal (current-buffer) kill-buffer))
5239 (kill-buffer (current-buffer))
5240 (set-buffer gnus-group-buffer)
5241 (gnus-group-next-unread-group 1)))
5242 (message "Can't select group")
5244 ((eq did-select 'quit)
5245 (and (eq major-mode 'gnus-summary-mode)
5246 (not (equal (current-buffer) kill-buffer))
5247 (kill-buffer (current-buffer)))
5248 (gnus-kill-buffer kill-buffer)
5249 (gnus-configure-windows 'group)
5250 (gnus-group-next-unread-group 1)
5253 (gnus-set-global-variables)
5254 ;; Save the active value in effect when the group was entered.
5255 (setq gnus-newsgroup-active
5257 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5258 ;; You can change the subjects in this hook.
5259 (run-hooks 'gnus-select-group-hook)
5260 ;; Do score processing.
5261 (and gnus-use-scoring (gnus-possibly-score-headers))
5262 ;; Update the format specifiers.
5263 (gnus-update-format-specifications)
5264 ;; Generate the summary buffer.
5265 (gnus-summary-prepare)
5266 (if (zerop (buffer-size))
5267 (cond (gnus-newsgroup-dormant
5268 (gnus-summary-show-all-dormant))
5269 ((and gnus-newsgroup-scored show-all)
5270 (gnus-summary-show-all-expunged))))
5271 ;; Function `gnus-apply-kill-file' must be called in this hook.
5272 (run-hooks 'gnus-apply-kill-hook)
5273 (if (zerop (buffer-size))
5275 ;; This newsgroup is empty.
5276 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5277 (gnus-message 6 "No unread news")
5278 (gnus-kill-buffer kill-buffer)
5282 (let ((gnus-summary-buffer kill-buffer))
5283 (gnus-configure-windows 'group))))
5284 ;; Hide conversation thread subtrees. We cannot do this in
5285 ;; gnus-summary-prepare-hook since kill processing may not
5286 ;; work with hidden articles.
5287 (and gnus-show-threads
5288 gnus-thread-hide-subtree
5289 (gnus-summary-hide-all-threads))
5290 ;; Show first unread article if requested.
5291 (goto-char (point-min))
5292 (if (and (not no-article)
5293 gnus-auto-select-first
5294 (gnus-summary-first-unread-article))
5295 (gnus-configure-windows 'article)
5296 (gnus-configure-windows 'summary))
5297 (gnus-set-mode-line 'summary)
5298 (gnus-summary-position-cursor)
5299 ;; If in async mode, we send some info to the backend.
5300 (and gnus-newsgroup-async
5301 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5302 (gnus-request-asynchronous
5304 (if (and gnus-asynchronous-article-function
5305 (fboundp gnus-asynchronous-article-function))
5306 (funcall gnus-asynchronous-article-function
5307 gnus-newsgroup-threads)
5308 gnus-newsgroup-threads)))
5309 (gnus-kill-buffer kill-buffer))
5312 (defun gnus-summary-prepare ()
5313 ;; Generate the summary buffer.
5314 (let ((buffer-read-only nil))
5316 (gnus-summary-prepare-threads
5317 (if gnus-show-threads
5318 (gnus-gather-threads
5320 (if (and gnus-summary-expunge-below
5321 (not gnus-fetch-old-headers))
5322 (gnus-make-threads-and-expunge)
5323 (gnus-make-threads))))
5324 gnus-newsgroup-headers)
5326 ;; Erase header retrieval message.
5327 (gnus-summary-update-lines)
5329 ;; Remove the final newline.
5330 ;;(goto-char (point-max))
5332 ;; Call hooks for modifying summary buffer.
5333 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5334 (goto-char (point-min))
5335 (run-hooks 'gnus-summary-prepare-hook)))
5337 (defun gnus-gather-threads (threads)
5338 "Gather threads that have lost their roots."
5339 (if (not gnus-summary-make-false-root)
5341 (let ((hashtb (gnus-make-hashtable 1023))
5344 thread subject hthread whole-subject)
5347 (setq subject (header-subject (car (car threads)))))
5348 (if gnus-summary-gather-subject-limit
5349 (or (and (numberp gnus-summary-gather-subject-limit)
5350 (> (length subject) gnus-summary-gather-subject-limit)
5352 (substring subject 0
5353 gnus-summary-gather-subject-limit)))
5354 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5355 (setq subject (gnus-simplify-subject-fuzzy subject))))
5356 (setq subject (gnus-simplify-subject-re subject)))
5358 (gnus-gethash subject hashtb))
5360 (or (stringp (car (car hthread)))
5361 (setcar hthread (list whole-subject (car hthread))))
5362 (setcdr (car hthread) (nconc (cdr (car hthread))
5363 (list (car threads))))
5364 (setcdr prev (cdr threads))
5365 (setq threads prev))
5366 (gnus-sethash subject threads hashtb))
5368 (setq threads (cdr threads)))
5371 (defun gnus-make-threads ()
5372 ;; This function takes the dependencies already made by
5373 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5374 ;; through the dependecies in the hash table and finds all the
5375 ;; roots. Roots do not refer back to any valid articles.
5377 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5378 (gnus-build-old-threads))
5381 (if (not (car (symbol-value refs)))
5382 (setq roots (append (cdr (symbol-value refs)) roots))
5383 ;; Ok, these refer back to valid articles, but if
5384 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5385 ;; the root has the same subject as its children. The children
5386 ;; that do not are made into roots and removed from the list
5388 (or gnus-thread-ignore-subject
5389 (let* ((prev (symbol-value refs))
5390 (subject (gnus-simplify-subject-re
5391 (header-subject (car prev))))
5392 (headers (cdr prev)))
5394 (if (not (string= subject
5395 (gnus-simplify-subject-re
5396 (header-subject (car headers)))))
5398 (setq roots (cons (car headers) roots))
5399 (setcdr prev (cdr headers)))
5400 (setq prev headers))
5401 (setq headers (cdr headers)))))))
5402 gnus-newsgroup-dependencies)
5404 (mapcar 'gnus-trim-thread
5406 (mapcar 'gnus-cut-thread
5407 (mapcar 'gnus-make-sub-thread roots))))))
5409 (defun gnus-make-threads-and-expunge ()
5410 ;; This function takes the dependencies already made by
5411 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5412 ;; through the dependecies in the hash table and finds all the
5413 ;; roots. Roots do not refer back to any valid articles.
5414 (let ((default (or gnus-summary-default-score 0))
5415 (below gnus-summary-expunge-below)
5417 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5418 (gnus-build-old-threads))
5421 (if (not (car (symbol-value refs)))
5422 ;; These articles do not refer back to any other articles -
5424 (let ((headers (cdr (symbol-value refs))))
5425 ;; We weed out the low-scored articles.
5427 (if (not (< (or (cdr (assq (header-number (car headers))
5428 gnus-newsgroup-scored)) default)
5431 (setq roots (cons (car headers) roots))
5432 ;; It is below, so we mark it as read.
5433 (setq gnus-newsgroup-unreads
5434 (delq (header-number (car headers))
5435 gnus-newsgroup-unreads)))
5436 (setq headers (cdr headers))))
5437 ;; Ok, these refer back to valid articles, but if
5438 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5439 ;; the root has the same subject as its children. The children
5440 ;; that do not are made into roots and removed from the list
5442 (or gnus-thread-ignore-subject
5443 (let* ((prev (symbol-value refs))
5444 (subject (gnus-simplify-subject-re
5445 (header-subject (car prev))))
5446 (headers (cdr prev)))
5448 (if (not (string= subject
5449 (gnus-simplify-subject-re
5450 (header-subject (car headers)))))
5452 (if (not (< (or (cdr (assq (header-number (car headers))
5453 gnus-newsgroup-scored))
5455 (setq roots (cons (car headers) roots))
5456 (setq gnus-newsgroup-unreads
5457 (delq (header-number (car headers))
5458 gnus-newsgroup-unreads)))
5459 (setcdr prev (cdr headers)))
5460 (setq prev headers))
5461 (setq headers (cdr headers)))))
5462 ;; If this article is expunged, some of the children might be
5464 (if (< (or (cdr (assq (header-number (car (symbol-value refs)))
5465 gnus-newsgroup-scored)) default)
5467 (let* ((prev (symbol-value refs))
5468 (headers (cdr prev)))
5470 (setq article (header-number (car headers)))
5471 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5473 (progn (setq roots (cons (car headers) roots))
5474 (setq prev headers))
5475 (setq gnus-newsgroup-unreads
5476 (delq article gnus-newsgroup-unreads))
5477 (setcdr prev (cdr headers)))
5478 (setq headers (cdr headers))))
5479 ;; It was not expunged, but we look at expunged children.
5480 (let* ((prev (symbol-value refs))
5481 (headers (cdr prev))
5484 (setq article (header-number (car headers)))
5485 (if (not (< (or (cdr (assq article gnus-newsgroup-scored))
5488 (setq gnus-newsgroup-unreads
5489 (delq article gnus-newsgroup-unreads))
5490 (setcdr prev (cdr headers)))
5491 (setq headers (cdr headers)))))))
5492 gnus-newsgroup-dependencies)
5494 (mapcar 'gnus-trim-thread
5496 (mapcar 'gnus-cut-thread
5497 (mapcar 'gnus-make-sub-thread roots))))))
5499 (defun gnus-cut-thread (thread)
5500 ;; Remove leaf dormant or ancient articles from THREAD.
5501 (let ((head (car thread))
5502 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5503 (if (and (null tail)
5504 (let ((number (header-number head)))
5505 (or (memq number gnus-newsgroup-ancient)
5506 (memq number gnus-newsgroup-dormant)
5507 (and gnus-summary-expunge-below
5508 (eq gnus-fetch-old-headers 'some)
5509 (< (or (cdr (assq number gnus-newsgroup-scored))
5510 gnus-summary-default-score 0)
5511 gnus-summary-expunge-below)
5513 (setq gnus-newsgroup-unreads
5514 (delq number gnus-newsgroup-unreads))
5517 (list (cons head tail)))))
5519 (defun gnus-trim-thread (thread)
5520 ;; Remove root ancient articles with only one child from THREAD.
5521 (if (and (eq gnus-fetch-old-headers 'some)
5522 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5523 (= (length thread) 2))
5524 (gnus-trim-thread (nth 1 thread))
5527 (defun gnus-make-sub-thread (root)
5528 ;; This function makes a sub-tree for a node in the tree.
5529 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5530 gnus-newsgroup-dependencies)))))
5531 (cons root (mapcar 'gnus-make-sub-thread children))))
5533 (defun gnus-build-old-threads ()
5534 ;; Look at all the articles that refer back to old articles, and
5535 ;; fetch the headers for the articles that aren't there. This will
5536 ;; build complete threads - if the roots haven't been expired by the
5541 (if (not (car (symbol-value refs)))
5543 (setq heads (cdr (symbol-value refs)))
5545 (if (not (memq (header-number (car heads))
5546 gnus-newsgroup-dormant))
5548 (setq id (symbol-name refs))
5549 (while (and (setq id (gnus-build-get-header id))
5550 (not (car (gnus-gethash
5551 id gnus-newsgroup-dependencies)))))
5553 (setq heads (cdr heads)))))))
5554 gnus-newsgroup-dependencies)))
5556 (defun gnus-build-get-header (id)
5557 ;; Look through the buffer of NOV lines and find the header to
5558 ;; ID. Enter this line into the dependencies hash table, and return
5559 ;; the id of the parent article (if any).
5560 (let ((deps gnus-newsgroup-dependencies)
5564 (set-buffer nntp-server-buffer)
5565 (goto-char (point-min))
5566 (while (and (not found) (search-forward id nil t))
5568 (setq found (looking-at
5569 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5570 (regexp-quote id))))
5571 (or found (beginning-of-line 2)))
5576 (setq header (gnus-nov-parse-line
5577 (read (current-buffer)) deps))
5578 (setq ref (header-references header))
5579 (string-match "\\(<[^>]+>\\) *$" ref)
5580 (substring ref (match-beginning 1) (match-end 1))))))
5582 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5583 gnus-newsgroup-ancient (cons (header-number header)
5584 gnus-newsgroup-ancient))))))
5586 ;; Re-build the thread containing ID.
5587 (defun gnus-rebuild-thread (id)
5588 (let ((dep gnus-newsgroup-dependencies)
5589 (buffer-read-only nil)
5590 parent headers refs thread art)
5591 (while (and id (setq headers
5592 (car (setq art (gnus-gethash (downcase id) dep)))))
5594 (setq id (and (setq refs (header-references headers))
5595 (string-match "\\(<[^>]+>\\) *$" refs)
5596 (substring refs (match-beginning 1) (match-end 1)))))
5597 (setq thread (gnus-make-sub-thread (car parent)))
5598 (gnus-rebuild-remove-articles thread)
5599 (let ((beg (point)))
5600 (gnus-summary-prepare-threads (list thread) 0)
5601 (gnus-summary-update-lines beg (point)))))
5603 ;; Delete all lines in the summary buffer that correspond to articles
5605 (defun gnus-rebuild-remove-articles (thread)
5606 (and (gnus-summary-goto-subject (header-number (car thread)))
5608 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
5610 (defun gnus-sort-threads (threads)
5611 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5612 (let ((fun gnus-thread-sort-functions))
5614 (setq threads (sort threads (car fun))
5618 (defun gnus-thread-header (thread)
5619 ;; Return header of first article in THREAD.
5621 (if (stringp (car thread))
5622 (car (car (cdr thread)))
5626 (defun gnus-thread-sort-by-number (h1 h2)
5627 "Sort threads by root article number."
5628 (let ((h1 (gnus-thread-header h1))
5629 (h2 (gnus-thread-header h2)))
5630 (< (header-number h1) (header-number h2))))
5632 (defun gnus-thread-sort-by-author (h1 h2)
5633 "Sort threads by root author."
5634 (let ((h1 (gnus-thread-header h1))
5635 (h2 (gnus-thread-header h2)))
5637 (let ((extract (funcall
5638 gnus-extract-address-components (header-from h1))))
5639 (or (car extract) (cdr extract)))
5640 (let ((extract (funcall
5641 gnus-extract-address-components (header-from h2))))
5642 (or (car extract) (cdr extract))))))
5644 (defun gnus-thread-sort-by-subject (h1 h2)
5645 "Sort threads by root subject."
5646 (let ((h1 (gnus-thread-header h1))
5647 (h2 (gnus-thread-header h2)))
5649 (downcase (gnus-simplify-subject (header-subject h1)))
5650 (downcase (gnus-simplify-subject (header-subject h2))))))
5652 (defun gnus-thread-sort-by-date (h1 h2)
5653 "Sort threads by root article date."
5654 (let ((h1 (gnus-thread-header h1))
5655 (h2 (gnus-thread-header h2)))
5657 (gnus-sortable-date (header-date h1))
5658 (gnus-sortable-date (header-date h2)))))
5660 (defun gnus-thread-sort-by-score (h1 h2)
5661 "Sort threads by root article score.
5662 Unscored articles will be counted as havin a score of zero."
5663 (let ((h1 (gnus-thread-header h1))
5664 (h2 (gnus-thread-header h2)))
5665 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5666 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5667 (> (or (cdr s1) gnus-summary-default-score 0)
5668 (or (cdr s2) gnus-summary-default-score 0)))))
5670 (defun gnus-thread-sort-by-total-score (h1 h2)
5671 "Sort threads by the sum of all scores in the thread.
5672 Unscored articles will be counted as havin a score of zero."
5673 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5675 (defun gnus-thread-total-score (thread)
5676 ;; This function find the total score of THREAD.
5678 (if (stringp (car thread))
5679 (apply gnus-thread-score-function 0
5680 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5681 (gnus-thread-total-score-1 thread))
5682 (gnus-thread-total-score-1 (list thread))))
5684 (defun gnus-thread-total-score-1 (root)
5685 ;; This function find the total score of the thread below ROOT.
5686 (setq root (car root))
5687 (apply gnus-thread-score-function
5688 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5689 gnus-summary-default-score 0)
5690 (mapcar 'gnus-thread-total-score
5691 (cdr (gnus-gethash (downcase (header-id root))
5692 gnus-newsgroup-dependencies)))))
5694 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5695 (defvar gnus-tmp-prev-subject "")
5696 (defvar gnus-tmp-adopt-thread nil)
5698 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5699 (defun gnus-summary-prepare-threads
5700 (threads level &optional not-child no-subject cull)
5701 "Prepare summary buffer from THREADS and indentation LEVEL.
5702 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5703 or a straight list of headers."
5704 (let (thread header number subject clevel)
5706 (setq thread (car threads)
5707 threads (cdr threads))
5708 ;; If `thread' is a cons, hierarchical threads are used. If not,
5709 ;; `thread' is the header.
5711 (setq header (car thread))
5712 (setq header thread)
5714 (or (memq (setq number (header-number header))
5715 gnus-newsgroup-dormant)
5716 (and gnus-summary-expunge-below
5717 (< (or (cdr (assq number gnus-newsgroup-scored))
5718 gnus-summary-default-score 0)
5719 gnus-summary-expunge-below)))
5722 (setq gnus-newsgroup-unreads
5723 (delq number gnus-newsgroup-unreads)))))
5726 ;; The header is a dummy root.
5727 (cond ((eq gnus-summary-make-false-root 'adopt)
5728 ;; We let the first article adopt the rest.
5729 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
5730 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5731 (setq thread (cdr (cdr thread)))
5733 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5734 (setq thread (cdr thread))))
5735 ((eq gnus-summary-make-false-root 'dummy)
5736 ;; We output a dummy root.
5737 (gnus-summary-insert-dummy-line
5738 nil header (header-number (car (car (cdr thread)))))
5740 ((eq gnus-summary-make-false-root 'empty)
5741 ;; We print the articles with empty subject fields.
5742 (let ((gnus-tmp-adopt-thread (list (cdr thread))))
5743 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5744 (setq thread (cdr (cdr thread)))
5746 (gnus-summary-prepare-threads
5747 (list (car thread)) 0 nil
5748 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5750 (gnus-simplify-subject-re
5751 (header-subject (car (car thread))))
5752 (gnus-simplify-subject-re header))))))
5753 (setq thread (cdr thread))))
5755 ;; We do not make a root for the gathered
5756 ;; sub-threads at all.
5758 ;; Print the sub-threads.
5759 (and (consp thread) (cdr thread)
5760 (gnus-summary-prepare-threads (cdr thread) clevel)))
5761 ;; The header is a real article.
5763 (setq number (header-number header)
5764 subject (header-subject header))
5765 (and gnus-newsgroup-async
5766 (setq gnus-newsgroup-threads
5767 (cons (cons (header-number header)
5768 (header-lines header)) gnus-newsgroup-threads)))
5769 (gnus-summary-insert-line
5770 nil header level nil
5771 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5772 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5773 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5774 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5775 (t gnus-ancient-mark))
5776 (memq number gnus-newsgroup-replied)
5777 (memq number gnus-newsgroup-expirable)
5779 gnus-summary-same-subject
5780 (if (or (zerop level)
5781 (and gnus-thread-ignore-subject
5783 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5784 (gnus-simplify-subject-re subject)))))
5786 gnus-summary-same-subject))
5788 (cdr (assq number gnus-newsgroup-scored)))
5789 (setq gnus-tmp-prev-subject subject)
5790 ;; Recursively print subthreads.
5791 (and (consp thread) (cdr thread)
5792 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5794 (defun gnus-select-newsgroup (group &optional read-all)
5795 "Select newsgroup GROUP.
5796 If READ-ALL is non-nil, all articles in the group are selected."
5797 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5798 (info (nth 2 entry))
5799 articles header-marks)
5800 (gnus-check-news-server
5801 (setq gnus-current-select-method (gnus-find-method-for-group group)))
5803 (or (gnus-server-opened gnus-current-select-method)
5804 (gnus-open-server gnus-current-select-method)
5805 (error "Couldn't open server"))
5807 (or (and (eq (car entry) t)
5808 (gnus-activate-newsgroup (car info)))
5809 (gnus-request-group group t)
5811 (kill-buffer (current-buffer))
5812 (error "Couldn't request group %s: %s"
5813 group (gnus-status-message group))))
5815 (setq gnus-newsgroup-name group)
5816 (setq gnus-newsgroup-unselected nil)
5817 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5819 (and gnus-asynchronous
5820 (gnus-check-backend-function
5821 'request-asynchronous gnus-newsgroup-name)
5822 (setq gnus-newsgroup-async
5823 (gnus-request-asynchronous gnus-newsgroup-name)))
5825 (setq articles (gnus-articles-to-read group read-all))
5829 (gnus-message 3 "Couldn't select newsgroup")
5831 ((eq articles 0) nil)
5833 ;; Init the dependencies hash table.
5834 (setq gnus-newsgroup-dependencies
5835 (gnus-make-hashtable (length articles)))
5836 ;; Retrieve the headers and read them in.
5837 (setq gnus-newsgroup-headers
5838 (if (eq 'nov (setq gnus-headers-retrieved-by
5839 (gnus-retrieve-headers
5840 (if gnus-fetch-old-headers
5841 (cons 1 articles) articles)
5842 gnus-newsgroup-name)))
5844 (gnus-get-newsgroup-headers-xover articles))
5845 (gnus-get-newsgroup-headers)))
5846 ;; If we were to fetch old headers, but the backend didn't
5847 ;; support XOVER, then it is possible we fetched one article
5848 ;; that we shouldn't have. If that's the case, we pop it off the
5850 (and (not (eq gnus-headers-retrieved-by 'nov))
5851 gnus-fetch-old-headers
5852 gnus-newsgroup-headers
5853 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5854 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5855 ;; Remove cancelled articles from the list of unread articles.
5856 (setq gnus-newsgroup-unreads
5857 (gnus-set-sorted-intersection
5858 gnus-newsgroup-unreads
5859 (mapcar (lambda (headers) (header-number headers))
5860 gnus-newsgroup-headers)))
5861 ;; Adjust and set lists of article marks.
5864 (gnus-adjust-marked-articles info)
5865 (setq gnus-newsgroup-marked
5866 (cdr (assq 'tick (setq marked (nth 3 info)))))
5867 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5868 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5869 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5870 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5871 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5872 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5873 (setq gnus-newsgroup-processable nil)))
5874 ;; Check whether auto-expire is to be done in this group.
5875 (setq gnus-newsgroup-auto-expire
5876 (or (and (stringp gnus-auto-expirable-newsgroups)
5877 (string-match gnus-auto-expirable-newsgroups group))
5878 (memq 'auto-expire (nth 5 info))))
5879 ;; First and last article in this newsgroup.
5880 (and gnus-newsgroup-headers
5881 (setq gnus-newsgroup-begin
5882 (header-number (car gnus-newsgroup-headers)))
5883 (setq gnus-newsgroup-end
5884 (header-number (gnus-last-element gnus-newsgroup-headers))))
5885 (setq gnus-reffed-article-number -1)
5886 ;; GROUP is successfully selected.
5887 (or gnus-newsgroup-headers t)))))
5889 (defun gnus-articles-to-read (group read-all)
5890 ;; Find out what articles the user wants to read.
5892 ;; Select all articles if `read-all' is non-nil, or if all the
5893 ;; unread articles are dormant articles.
5895 (= (length gnus-newsgroup-unreads)
5896 (length gnus-newsgroup-dormant)))
5897 (gnus-uncompress-range
5898 (gnus-gethash group gnus-active-hashtb))
5899 gnus-newsgroup-unreads))
5900 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5901 (scored (length scored-list))
5902 (number (length articles))
5903 (marked (+ (length gnus-newsgroup-marked)
5904 (length gnus-newsgroup-dormant)))
5907 (cond ((and (or (<= scored marked)
5909 (numberp gnus-large-newsgroup)
5910 (> number gnus-large-newsgroup))
5914 "How many articles from %s (default %d): "
5915 gnus-newsgroup-name number))))
5916 (if (string-equal input "")
5918 ((and (> scored marked) (< scored number))
5922 "%s %s (%d scored, %d total): "
5923 "How many articles from"
5924 group scored number))))
5925 (if (string-equal input "")
5930 (setq select (if (stringp select) (string-to-number select) select))
5931 (if (or (null select) (zerop select))
5933 (if (and (not (zerop scored)) (<= (abs select) scored))
5935 (setq articles (sort scored-list '<))
5936 (setq number (length articles)))
5937 (setq articles (copy-sequence articles)))
5939 (setq total-articles articles)
5941 (if (< (abs select) number)
5943 ;; Select the N oldest articles.
5944 (setcdr (nthcdr (1- (abs select)) articles) nil)
5945 ;; Select the N most recent articles.
5946 (setq articles (nthcdr (- number select) articles))))
5947 (setq gnus-newsgroup-unselected
5948 (gnus-sorted-intersection
5949 gnus-newsgroup-unreads
5950 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
5953 (defun gnus-killed-articles (killed articles)
5956 (if (inline (gnus-member-of-range (car articles) killed))
5957 (setq out (cons (car articles) out)))
5958 (setq articles (cdr articles)))
5961 (defun gnus-adjust-marked-articles (info &optional active)
5962 "Remove all marked articles that are no longer legal."
5963 (let ((marked-lists (nth 3 info))
5964 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5966 ;; There are many types of marked articles.
5968 (setq m (cdr (setq prev (car marked-lists))))
5969 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5970 ;; Make sure that all ticked articles are a subset of the
5971 ;; unread/unselected articles.
5973 (if (or (memq (car m) gnus-newsgroup-unreads)
5974 (memq (car m) gnus-newsgroup-unselected))
5976 (setcdr prev (cdr m)))
5978 ((eq 'score (car prev))
5979 ;; Scored articles should be a subset of
5980 ;; unread/unselected articles.
5982 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5983 (memq (car (car m)) gnus-newsgroup-unreads))
5985 (setcdr prev (cdr m)))
5987 ((eq 'bookmark (car prev))
5988 ;; Bookmarks should be a subset of active articles.
5990 (if (< (car (car m)) (car active))
5991 (setcdr prev (cdr m))
5994 ((eq 'killed (car prev))
5995 ;; Articles that have been through the kill process are
5996 ;; to be a subset of active articles.
5997 (while (and m (< (or (and (numberp (car m)) (car m))
6000 (setcdr prev (cdr m))
6002 (if (and m (< (or (and (numberp (car m)) (car m))
6005 (setcar (if (numberp (car m)) m (car m)) (car active))))
6006 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6007 ;; The replied and expirable articles have to be articles
6010 (if (< (car m) (car active))
6011 (setcdr prev (cdr m))
6014 (setq marked-lists (cdr marked-lists)))
6015 ;; Remove all lists that are empty.
6016 (setq marked-lists (nth 3 info))
6019 (while (= 1 (length (car marked-lists)))
6020 (setq marked-lists (cdr marked-lists)))
6021 (setq m (cdr (setq prev marked-lists)))
6023 (if (= 1 (length (car m)))
6024 (setcdr prev (cdr m))
6027 (setcar (nthcdr 3 info) marked-lists)))
6028 ;; Finally, if there are no marked lists at all left, and if there
6029 ;; are no elements after the lists in the info list, we just chop
6030 ;; the info list off before the marked lists.
6031 (and (null marked-lists)
6032 (not (nthcdr 4 info))
6033 (setcdr (nthcdr 2 info) nil)))
6036 (defun gnus-set-marked-articles
6037 (info ticked replied expirable killed dormant bookmark score)
6038 "Enter the various lists of marked articles into the newsgroup info list."
6040 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6041 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6042 (and expirable (setq newmarked (cons (cons 'expire expirable)
6044 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6045 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6046 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6048 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6051 (setcar (nthcdr 3 info) newmarked)
6052 (if (not (nthcdr 4 info))
6053 (setcdr (nthcdr 2 info) nil)
6054 (setcar (nthcdr 3 info) nil)))
6056 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
6058 (defun gnus-add-marked-articles (group type articles &optional info force)
6059 ;; Add ARTICLES of TYPE to the info of GROUP.
6060 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6061 ;; add, but replace marked articles of TYPE with ARTICLES.
6062 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6065 (and (not (setq marked (nthcdr 3 info)))
6066 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6067 (and (not (setq m (assq type (car marked))))
6068 (setcar marked (cons (cons type articles) (car marked))))
6071 (nconc m articles)))))
6073 (defun gnus-set-mode-line (where)
6074 "This function sets the mode line of the article or summary buffers.
6075 If WHERE is `summary', the summary mode line format will be used."
6076 (if (memq where gnus-updated-mode-lines)
6079 (set-buffer gnus-summary-buffer)
6080 (let* ((mformat (if (eq where 'article)
6081 gnus-article-mode-line-format-spec
6082 gnus-summary-mode-line-format-spec))
6083 (group-name gnus-newsgroup-name)
6084 (article-number (or gnus-current-article 0))
6085 (unread (- (length gnus-newsgroup-unreads)
6086 (length gnus-newsgroup-dormant)))
6087 (unread-and-unticked
6088 (- unread (length gnus-newsgroup-marked)))
6089 (unselected (length gnus-newsgroup-unselected))
6090 (unread-and-unselected
6091 (cond ((and (zerop unread-and-unticked)
6092 (zerop unselected)) "")
6094 (format "{%d more}" unread-and-unticked))
6095 (t (format "{%d(+%d) more}"
6096 unread-and-unticked unselected))))
6098 (if gnus-current-headers
6099 (header-subject gnus-current-headers) ""))
6100 (max-len (and gnus-mode-non-string-length
6101 (- (frame-width) gnus-mode-non-string-length)))
6102 header) ;; passed as argument to any user-format-funcs
6103 (setq mode-string (eval mformat))
6104 (or (numberp max-len)
6105 (setq max-len (length mode-string)))
6106 (if (< max-len 4) (setq max-len 4))
6107 (if (> (length mode-string) max-len)
6109 (concat (substring mode-string 0 (- max-len 3))
6111 (setq mode-string (format (format "%%-%ds" max-len)
6113 (setq mode-line-buffer-identification mode-string)
6114 (set-buffer-modified-p t))))
6116 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6117 "Go through the HEADERS list and add all Xrefs to a hash table.
6118 The resulting hash table is returned, or nil if no Xrefs were found."
6119 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6121 (gnus-group-foreign-p from-newsgroup)
6123 (assoc (symbol-name (car from-method))
6124 gnus-valid-select-methods))))
6125 (gnus-group-real-prefix from-newsgroup)))
6126 (xref-hashtb (make-vector 63 0))
6127 start group entry number xrefs header)
6129 (setq header (car headers))
6130 (if (and (setq xrefs (header-xref header))
6131 (not (memq (header-number header) unreads)))
6134 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6135 (setq start (match-end 0))
6136 (setq group (concat prefix (substring xrefs (match-beginning 1)
6139 (string-to-int (substring xrefs (match-beginning 2)
6141 (if (setq entry (gnus-gethash group xref-hashtb))
6142 (setcdr entry (cons number (cdr entry)))
6143 (gnus-sethash group (cons number nil) xref-hashtb)))))
6144 (setq headers (cdr headers)))
6145 (if start xref-hashtb nil)))
6147 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6148 "Look through all the headers and mark the Xrefs as read."
6149 (let ((virtual (memq 'virtual
6150 (assoc (symbol-name (car (gnus-find-method-for-group
6152 gnus-valid-select-methods)))
6153 name entry read info xref-hashtb idlist active num range exps method
6156 (set-buffer gnus-group-buffer)
6157 (if (setq xref-hashtb
6158 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6161 (if (string= from-newsgroup (setq name (symbol-name group)))
6163 (setq idlist (symbol-value group))
6164 ;; Dead groups are not updated.
6166 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6168 (if (stringp (setq nth4 (nth 4 info)))
6169 (setq nth4 (gnus-server-to-method nth4))))
6170 ;; Only do the xrefs if the group has the same
6171 ;; select method as the group we have just read.
6172 (or (gnus-methods-equal-p
6173 nth4 (gnus-find-method-for-group from-newsgroup))
6176 (setq method (gnus-find-method-for-group
6178 (and (equal (car nth4) (car method))
6179 (equal (nth 1 nth4) (nth 1 method))))
6180 gnus-use-cross-reference
6181 (or (not (eq gnus-use-cross-reference t))
6183 ;; Only do cross-references on subscribed
6184 ;; groups, if that is what is wanted.
6185 (<= (nth 1 info) gnus-level-subscribed)))
6188 ;; Set the new list of read articles in this group.
6189 (setq active (gnus-gethash name gnus-active-hashtb))
6190 ;; First peel off all illegal article numbers.
6193 (ticked (cdr (assq 'tick (nth 3 info))))
6194 (dormant (cdr (assq 'dormant (nth 3 info))))
6199 (if (or (> id (cdr active))
6203 (setq idlist (delq id idlist)))
6204 (and (memq id expirable)
6205 (setq exps (cons id exps)))
6206 (setq ids (cdr ids)))))
6207 ;; Update expirable articles.
6208 (gnus-add-marked-articles nil 'expirable exps info)
6212 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6213 (setcar (nthcdr 2 info)
6217 (setq idlist (sort idlist '<)))))
6218 ;; Then we have to re-compute how many unread
6219 ;; articles there are in this group.
6224 (setq num (- (1+ (cdr active)) (car active))))
6225 ((not (listp (cdr range)))
6226 (setq num (- (cdr active) (- (1+ (cdr range))
6230 (if (numberp (car range))
6232 (setq num (+ num (- (1+ (cdr (car range)))
6233 (car (car range))))))
6234 (setq range (cdr range)))
6235 (setq num (- (cdr active) num))))
6236 ;; Update the number of unread articles.
6240 (length (cdr (assq 'tick (nth 3 info))))
6242 (cdr (assq 'dormant (nth 3 info)))))))
6243 ;; Update the group buffer.
6244 (gnus-group-update-group name t)))))))
6247 (defun gnus-methods-equal-p (m1 m2)
6248 (let ((m1 (or m1 gnus-select-method))
6249 (m2 (or m2 gnus-select-method)))
6251 (and (eq (car m1) (car m2))
6252 (or (not (memq 'address (assoc (symbol-name (car m1))
6253 gnus-valid-select-methods)))
6254 (equal (nth 1 m1) (nth 1 m2)))))))
6256 (defsubst gnus-header-value ()
6257 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6259 (defvar gnus-newsgroup-none-id 0)
6261 (defun gnus-get-newsgroup-headers ()
6262 (setq gnus-article-internal-prepare-hook nil)
6263 (let ((cur nntp-server-buffer)
6264 (dependencies gnus-newsgroup-dependencies)
6265 headers char article id dep end)
6267 (set-buffer nntp-server-buffer)
6268 (goto-char (point-min))
6269 ;; Search to the beginning of the next header. Error messages
6270 ;; do not begin with 2 or 3.
6271 (while (re-search-forward "^[23][0-9]+ " nil t)
6272 (let ((header (make-vector 9 nil))
6273 (c (following-char))
6274 (case-fold-search t)
6276 from subject in-reply-to references ref)
6282 (header-set-number header (setq article (read cur)))
6283 ;; This implementation of this function, with nine
6284 ;; search-forwards instead of the one re-search-forward and
6285 ;; a case (which basically was the old function) is actually
6286 ;; about twice as fast, even though it looks messier. You
6287 ;; can't have everything, I guess. Speed and elegance
6288 ;; doesn't always come hand in hand.
6290 (narrow-to-region (point) (save-excursion
6291 (search-forward "\n.\n" nil t)))
6292 (if (search-forward "\nfrom: " nil t)
6293 (header-set-from header (gnus-header-value))
6294 (header-set-from header "(nobody)"))
6296 (if (search-forward "\nsubject: " nil t)
6297 (header-set-subject header (gnus-header-value))
6298 (header-set-subject header "(none)"))
6300 (and (search-forward "\nxref: " nil t)
6301 (header-set-xref header (gnus-header-value)))
6303 (or (numberp (and (search-forward "\nlines: " nil t)
6304 (header-set-lines header (read cur))))
6305 (header-set-lines header 0))
6307 (and (search-forward "\ndate: " nil t)
6308 (header-set-date header (gnus-header-value)))
6310 (if (search-forward "\nmessage-id: " nil t)
6311 (header-set-id header (setq id (gnus-header-value)))
6312 ;; If there was no message-id, we just fake one to make
6313 ;; subsequent routines simpler.
6316 (setq id (concat "none+"
6318 (setq gnus-newsgroup-none-id
6319 (1+ gnus-newsgroup-none-id)))))))
6321 (if (search-forward "\nreferences: " nil t)
6323 (header-set-references header (gnus-header-value))
6324 (setq end (match-end 0))
6331 (search-backward ">" end t)
6334 (search-backward "<" end t)
6336 ;; Get the references from the in-reply-to header if there
6337 ;; ware no references and the in-reply-to header looks
6339 (if (and (search-forward "\nin-reply-to: " nil t)
6340 (setq in-reply-to (gnus-header-value))
6341 (string-match "<[^>]+>" in-reply-to))
6343 (header-set-references
6345 (setq ref (substring in-reply-to (match-beginning 0)
6347 (setq ref (downcase ref)))
6349 ;; We do some threading while we read the headers. The
6350 ;; message-id and the last reference are both entered into
6351 ;; the same hash table. Some tippy-toeing around has to be
6352 ;; done in case an article has arrived before the article
6353 ;; which it refers to.
6354 (if (boundp (setq dep (intern (downcase id) dependencies)))
6355 (if (car (symbol-value dep))
6356 ;; An article with this Message-ID has already
6357 ;; been seen, so we ignore this one, except we add
6358 ;; any additional Xrefs (in case the two articles
6359 ;; came from different servers.
6362 (car (symbol-value dep))
6363 (concat (or (header-xref (car (symbol-value dep))) "")
6364 (or (header-xref header) "")))
6366 (setcar (symbol-value dep) header))
6367 (set dep (list header)))
6370 (if (boundp (setq dep (intern ref dependencies)))
6371 (setcdr (symbol-value dep)
6372 (cons header (cdr (symbol-value dep))))
6373 (set dep (list nil header)))
6374 (setq headers (cons header headers))))
6375 (goto-char (point-max))))))
6376 (nreverse headers)))
6378 ;; The following macros and functions were written by Felix Lee
6379 ;; <flee@cse.psu.edu>.
6381 (defmacro gnus-nov-read-integer ()
6383 (if (= (following-char) ?\t)
6385 (let ((num (condition-case nil (read buffer) (error nil))))
6386 (if (numberp num) num 0)))
6387 (or (eobp) (forward-char 1))))
6389 (defmacro gnus-nov-skip-field ()
6390 '(search-forward "\t" eol 'move))
6392 (defmacro gnus-nov-field ()
6393 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6395 ;; Goes through the xover lines and returns a list of vectors
6396 (defun gnus-get-newsgroup-headers-xover (sequence)
6397 "Parse the news overview data in the server buffer, and return a
6398 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6399 ;; Get the Xref when the users reads the articles since most/some
6400 ;; NNTP servers do not include Xrefs when using XOVER.
6401 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6402 (let ((cur nntp-server-buffer)
6403 (dependencies gnus-newsgroup-dependencies)
6405 number headers header)
6407 (set-buffer nntp-server-buffer)
6408 (goto-char (point-min))
6409 (while (and sequence (not (eobp)))
6410 (setq number (read cur))
6411 (while (and sequence (< (car sequence) number))
6412 (setq sequence (cdr sequence)))
6414 (eq number (car sequence))
6416 (setq sequence (cdr sequence))
6418 (inline (gnus-nov-parse-line number dependencies)))
6419 (setq headers (cons header headers)))))
6421 (setq headers (nreverse headers)))
6424 ;; This function has to be called with point after the article number
6425 ;; on the beginning of the line.
6426 (defun gnus-nov-parse-line (number dependencies)
6428 (eol (gnus-point-at-eol))
6429 (buffer (current-buffer))
6432 ;; overview: [num subject from date id refs chars lines misc]
6433 (narrow-to-region (point) eol)
6440 (gnus-nov-field) ; subject
6441 (gnus-nov-field) ; from
6442 (gnus-nov-field) ; date
6443 (setq id (or (gnus-nov-field)
6446 (setq none (1+ none)))))) ; id
6449 (let ((beg (point)))
6450 (search-forward "\t" eol)
6451 (if (search-backward ">" beg t)
6457 (search-backward "<" beg t)
6460 (gnus-nov-field)) ; refs
6461 (gnus-nov-read-integer) ; chars
6462 (gnus-nov-read-integer) ; lines
6463 (if (= (following-char) ?\n)
6465 (gnus-nov-field)) ; misc
6473 ;; We build the thread tree.
6475 (if (boundp (setq dep (intern (downcase id) dependencies)))
6476 (if (car (symbol-value dep))
6477 ;; An article with this Message-ID has already been seen,
6478 ;; so we ignore this one, except we add any additional
6479 ;; Xrefs (in case the two articles came from different
6483 (car (symbol-value dep))
6484 (concat (or (header-xref (car (symbol-value dep))) "")
6485 (or (header-xref header) "")))
6487 (setcar (symbol-value dep) header))
6488 (set dep (list header))))
6491 (if (boundp (setq dep (intern (or ref "none")
6493 (setcdr (symbol-value dep)
6494 (cons header (cdr (symbol-value dep))))
6495 (set dep (list nil header)))))
6498 (defun gnus-article-get-xrefs ()
6499 "Fill in the Xref value in `gnus-current-headers', if necessary.
6500 This is meant to be called in `gnus-article-internal-prepare-hook'."
6501 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6502 gnus-current-headers)))
6503 (or (not gnus-use-cross-reference)
6504 (and (header-xref headers)
6505 (not (string= (header-xref headers) "")))
6506 (let ((case-fold-search t)
6509 (gnus-narrow-to-headers)
6510 (goto-char (point-min))
6511 (if (or (and (eq (downcase (following-char)) ?x)
6512 (looking-at "Xref:"))
6513 (search-forward "\nXref:" nil t))
6515 (goto-char (1+ (match-end 0)))
6516 (setq xref (buffer-substring (point)
6517 (progn (end-of-line) (point))))
6518 (header-set-xref headers xref))))))))
6520 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6521 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6523 ;; Return a header specified by a NUMBER.
6524 (defun gnus-get-header-by-number (number)
6526 (set-buffer gnus-summary-buffer)
6527 (or gnus-newsgroup-headers-hashtb-by-number
6528 (gnus-make-headers-hashtable-by-number))
6529 (gnus-gethash (int-to-string number)
6530 gnus-newsgroup-headers-hashtb-by-number)))
6532 (defun gnus-make-headers-hashtable-by-number ()
6533 "Make hashtable for the variable gnus-newsgroup-headers by number."
6535 (set-buffer gnus-summary-buffer)
6536 (let ((headers gnus-newsgroup-headers)
6538 (setq gnus-newsgroup-headers-hashtb-by-number
6539 (gnus-make-hashtable (length headers)))
6541 (setq header (car headers))
6542 (gnus-sethash (int-to-string (header-number header))
6543 header gnus-newsgroup-headers-hashtb-by-number)
6544 (setq headers (cdr headers))))))
6546 (defun gnus-more-header-backward ()
6547 "Find new header backward."
6548 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6549 (artnum gnus-newsgroup-begin)
6551 (while (and (not header)
6553 (setq artnum (1- artnum))
6554 (setq header (gnus-read-header artnum)))
6557 (defun gnus-more-header-forward (&optional backward)
6558 "Find new header forward.
6559 If BACKWARD, find new header backward instead."
6561 (gnus-more-header-backward)
6562 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6563 (artnum gnus-newsgroup-end)
6565 (while (and (not header)
6567 (setq artnum (1+ artnum))
6568 (setq header (gnus-read-header artnum)))
6571 (defun gnus-extend-newsgroup (header &optional backward)
6572 "Extend newsgroup selection with HEADER.
6573 Optional argument BACKWARD means extend toward backward."
6575 (let ((artnum (header-number header)))
6576 (setq gnus-newsgroup-headers
6578 (cons header gnus-newsgroup-headers)
6579 (nconc gnus-newsgroup-headers (list header))))
6580 (setq gnus-newsgroup-unselected
6581 (delq artnum gnus-newsgroup-unselected))
6582 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6583 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6585 (defun gnus-summary-work-articles (n)
6586 "Return a list of articles to be worked upon. The prefix argument,
6587 the list of process marked articles, and the current article will be
6588 taken into consideration."
6590 (if (and n (numberp n))
6591 (let ((backward (< n 0))
6595 (setq articles (cons (gnus-summary-article-number)
6597 (gnus-summary-search-forward nil nil backward))
6599 (sort articles (function <)))
6600 (or (reverse gnus-newsgroup-processable)
6601 (list (gnus-summary-article-number))))))
6603 (defun gnus-summary-search-group (&optional backward use-level)
6604 "Search for next unread newsgroup.
6605 If optional argument BACKWARD is non-nil, search backward instead."
6607 (set-buffer gnus-group-buffer)
6609 ;; We don't want to alter current point of group mode buffer.
6610 (if (gnus-group-search-forward
6612 (if use-level (gnus-group-group-level) nil))
6613 (gnus-group-group-name)))))
6615 (defun gnus-summary-best-group (&optional exclude-group)
6616 "Find the name of the best unread group.
6617 If EXCLUDE-GROUP, do not go to this group."
6619 (set-buffer gnus-group-buffer)
6621 (gnus-group-best-unread-group exclude-group))))
6623 (defun gnus-summary-search-subject (&optional backward unread subject)
6624 "Search for article forward.
6625 If BACKWARD is non-nil, search backward.
6626 If UNREAD is non-nil, only unread articles are selected.
6627 If SUBJECT is non-nil, the article which has the same subject will be
6629 (let ((func (if backward 'previous-single-property-change
6630 'next-single-property-change))
6635 (and gnus-summary-check-current unread
6636 (eq (nth 1 (get-text-property (point) 'gnus)) gnus-unread-mark)
6640 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6643 (setq pos (funcall func (point) 'gnus))
6644 (goto-char (if backward (1- pos) pos))
6648 (eq (nth 1 (get-text-property (point) 'gnus))
6651 (equal (gnus-simplify-subject-re subject)
6652 (gnus-simplify-subject-re
6653 (gnus-summary-subject-string)))))))
6654 (if backward (if (bobp) nil (forward-char -1) t)
6655 (if (eobp) nil (forward-char 1) t)))))
6657 (progn (goto-char beg) nil)
6659 (car (get-text-property (point) 'gnus))
6660 (gnus-summary-position-cursor)))))
6662 (defun gnus-summary-search-forward (&optional unread subject backward)
6663 "Search for article forward.
6664 If UNREAD is non-nil, only unread articles are selected.
6665 If SUBJECT is non-nil, the article which has the same subject will be
6667 If BACKWARD is non-nil, the search will be performed backwards instead."
6668 (gnus-summary-search-subject backward unread subject))
6670 (defun gnus-summary-search-backward (&optional unread subject)
6671 "Search for article backward.
6672 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6673 If 2nd optional argument SUBJECT is non-nil, the article which has
6674 the same subject will be searched for."
6675 (gnus-summary-search-forward unread subject t))
6677 (defun gnus-summary-article-number (&optional number-or-nil)
6678 "The article number of the article on the current line.
6679 If there isn's an article number here, then we return the current
6682 (number (car (get-text-property
6683 (progn (beginning-of-line)
6684 (prog1 (point) (goto-char p)))
6686 (if number-or-nil number (or number gnus-current-article))))
6688 (defun gnus-summary-thread-level ()
6689 "The thread level of the article on the current line."
6690 (or (nth 2 (get-text-property (gnus-point-at-bol) 'gnus))
6693 (defun gnus-summary-pseudo-article ()
6694 "The thread level of the article on the current line."
6695 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
6697 (defun gnus-summary-article-mark ()
6698 "The mark on the current line."
6699 (nth 1 (get-text-property (gnus-point-at-bol) 'gnus)))
6701 (defun gnus-summary-subject-string ()
6702 "Return current subject string or nil if nothing."
6703 (let ((article (gnus-summary-article-number))
6706 (setq header (gnus-get-header-by-number article))
6708 (header-subject header))))
6710 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6711 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6712 (defun gnus-summary-article-score ()
6713 "Return current article score."
6714 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6715 gnus-summary-default-score 0))
6717 ;; Written by Sudish Joseph <joseph@cis.ohio-state.edu>.
6719 (defun gnus-summary-recenter ()
6720 "Center point in the summary window.
6721 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6722 displayed, no centering will be performed."
6723 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6724 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6725 (let* ((top (cond ((< (window-height) 4) 0)
6726 ((< (window-height) 6) 1)
6728 (height (1- (window-height)))
6729 (bottom (save-excursion (goto-char (point-max))
6730 (forward-line (- height))
6732 (window (get-buffer-window (current-buffer))))
6734 ;; The user has to want it,
6735 gnus-auto-center-summary
6736 ;; the article buffer must be displayed,
6737 (get-buffer-window gnus-article-buffer)
6738 ;; Set the window start to either `bottom', which is the biggest
6739 ;; possible valid number, or the second line from the top,
6740 ;; whichever is the least.
6742 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
6744 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6745 (defun gnus-short-group-name (group &optional levels)
6746 "Collapse GROUP name LEVELS."
6747 (let ((name "") (foreign "")
6748 (levels (or levels 2)))
6749 (if (string-match ":" group)
6750 (setq foreign (substring group 0 (match-end 0))
6751 group (substring group (match-end 0))))
6753 (if (and (string-match "\\." group) (> levels 0))
6754 (setq name (concat name (substring group 0 1))
6755 group (substring group (match-end 0))
6757 name (concat name "."))
6758 (setq name (concat foreign name group)
6762 (defun gnus-summary-jump-to-group (newsgroup)
6763 "Move point to NEWSGROUP in group mode buffer."
6764 ;; Keep update point of group mode buffer if visible.
6765 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6766 (save-window-excursion
6767 ;; Take care of tree window mode.
6768 (if (get-buffer-window gnus-group-buffer)
6769 (pop-to-buffer gnus-group-buffer))
6770 (gnus-group-jump-to-group newsgroup))
6772 ;; Take care of tree window mode.
6773 (if (get-buffer-window gnus-group-buffer)
6774 (pop-to-buffer gnus-group-buffer)
6775 (set-buffer gnus-group-buffer))
6776 (gnus-group-jump-to-group newsgroup))))
6778 ;; This function returns a list of article numbers based on the
6779 ;; difference between the ranges of read articles in this group and
6780 ;; the range of active articles.
6781 (defun gnus-list-of-unread-articles (group)
6782 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6783 (active (gnus-gethash group gnus-active-hashtb))
6785 unread first nlast unread)
6786 ;; If none are read, then all are unread.
6788 (setq first (car active))
6789 ;; If the range of read articles is a single range, then the
6790 ;; first unread article is the article after the last read
6791 ;; article. Sounds logical, doesn't it?
6792 (if (not (listp (cdr read)))
6793 (setq first (1+ (cdr read)))
6794 ;; `read' is a list of ranges.
6795 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6796 (car (car read)))) 1)
6800 (while (< first nlast)
6801 (setq unread (cons first unread))
6802 (setq first (1+ first))))
6803 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6804 (setq nlast (if (atom (car (cdr read)))
6806 (car (car (cdr read)))))
6807 (setq read (cdr read)))))
6808 ;; And add the last unread articles.
6809 (while (<= first last)
6810 (setq unread (cons first unread))
6811 (setq first (1+ first)))
6812 ;; Return the list of unread articles.
6815 (defun gnus-list-of-read-articles (group)
6816 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
6817 (active (gnus-gethash group gnus-active-hashtb)))
6819 (gnus-sorted-complement
6820 (gnus-uncompress-range active)
6821 (gnus-list-of-unread-articles group)))))
6823 ;; Various summary commands
6825 (defun gnus-summary-universal-argument ()
6826 "Perform any operation on all articles marked with the process mark."
6828 (gnus-set-global-variables)
6829 (let ((articles (reverse gnus-newsgroup-processable))
6831 (or articles (error "No articles marked"))
6832 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6833 (error "Undefined key"))
6835 (gnus-summary-goto-subject (car articles))
6836 (command-execute func)
6837 (gnus-summary-remove-process-mark (car articles))
6838 (setq articles (cdr articles)))))
6840 (defun gnus-summary-toggle-truncation (arg)
6841 "Toggle truncation of summary lines.
6842 With arg, turn line truncation on iff arg is positive."
6844 (setq truncate-lines
6845 (if (null arg) (not truncate-lines)
6846 (> (prefix-numeric-value arg) 0)))
6849 (defun gnus-summary-reselect-current-group (all)
6850 "Once exit and then reselect the current newsgroup.
6851 The prefix argument ALL means to select all articles."
6853 (gnus-set-global-variables)
6854 (let ((current-subject (gnus-summary-article-number))
6855 (group gnus-newsgroup-name))
6856 (setq gnus-newsgroup-threads nil)
6857 (gnus-summary-exit t)
6858 ;; We have to adjust the point of group mode buffer because the
6859 ;; current point was moved to the next unread newsgroup by
6861 (gnus-summary-jump-to-group group)
6862 (gnus-group-read-group all t)
6863 (gnus-summary-goto-subject current-subject)))
6865 (defun gnus-summary-rescan-group (all)
6866 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6868 (gnus-set-global-variables)
6869 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6870 (let ((group gnus-newsgroup-name))
6872 (gnus-summary-jump-to-group group)
6874 (set-buffer gnus-group-buffer)
6875 (gnus-group-get-new-news-this-group 1))
6876 (gnus-summary-jump-to-group group)
6877 (gnus-group-read-group all)))
6879 (defun gnus-summary-update-info ()
6880 (let* ((group gnus-newsgroup-name)
6881 (method (car (gnus-find-method-for-group group))))
6882 (if gnus-newsgroup-kill-headers
6883 (setq gnus-newsgroup-killed
6884 (gnus-compress-sequence
6886 (gnus-set-sorted-intersection
6887 (gnus-uncompress-range gnus-newsgroup-killed)
6888 (setq gnus-newsgroup-unselected
6889 (sort gnus-newsgroup-unselected '<)))
6890 (setq gnus-newsgroup-unreads
6891 (sort gnus-newsgroup-unreads '<))) t)))
6892 (or (listp (cdr gnus-newsgroup-killed))
6893 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6895 (headers gnus-newsgroup-headers))
6896 (gnus-close-group group)
6897 (run-hooks 'gnus-exit-group-hook)
6898 (gnus-update-read-articles
6899 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6900 gnus-newsgroup-marked
6901 t gnus-newsgroup-replied gnus-newsgroup-expirable
6902 gnus-newsgroup-killed gnus-newsgroup-dormant
6903 gnus-newsgroup-bookmarks
6904 (and gnus-save-score gnus-newsgroup-scored))
6905 (and gnus-use-cross-reference
6906 (gnus-mark-xrefs-as-read
6907 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6908 ;; Do adaptive scoring, and possibly save score files.
6909 (and gnus-newsgroup-adaptive
6910 (gnus-score-adaptive))
6911 (and (fboundp 'gnus-score-save)
6912 (funcall 'gnus-score-save))
6913 ;; Do not switch windows but change the buffer to work.
6914 (set-buffer gnus-group-buffer)
6915 (or (eq 'nndigest method)
6916 (gnus-group-update-group group)))))
6918 (defun gnus-summary-exit (&optional temporary)
6919 "Exit reading current newsgroup, and then return to group selection mode.
6920 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6922 (gnus-set-global-variables)
6923 (gnus-kill-save-kill-buffer)
6924 (let* ((group gnus-newsgroup-name)
6925 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6926 gnus-newsgroup-name))))
6928 (method (car (gnus-find-method-for-group group)))
6929 (buf (current-buffer)))
6930 (gnus-summary-update-info) ; Make all changes in this group permanent.
6931 ;; Make sure where I was, and go to next newsgroup.
6932 (if (eq method 'nndigest)
6934 (gnus-group-jump-to-group group)
6935 (gnus-group-next-unread-group 1))
6938 ;; We set all buffer-local variables to nil. It is unclear why
6939 ;; this is needed, but if we don't, buffer-local variables are
6940 ;; not garbage-collected, it seems. This would the lead to en
6941 ;; ever-growing Emacs.
6943 (gnus-summary-clear-local-variables)
6944 ;; We clear the global counterparts of the buffer-local
6945 ;; variables as well, just to be on the safe side.
6946 (gnus-configure-windows 'group)
6947 (gnus-summary-clear-local-variables)
6948 ;; Return to group mode buffer.
6949 (if (eq mode 'gnus-summary-mode)
6950 (gnus-kill-buffer buf))
6951 (if (get-buffer gnus-article-buffer)
6952 (bury-buffer gnus-article-buffer))
6953 (setq gnus-current-select-method gnus-select-method)
6954 (pop-to-buffer gnus-group-buffer)
6955 (if (eq method 'nndigest)
6957 (gnus-group-jump-to-group group)
6958 (gnus-group-next-unread-group 1))
6959 (if (gnus-buffer-exists-p quit-buffer)
6961 (switch-to-buffer quit-buffer)
6962 (gnus-set-global-variables)
6963 (gnus-configure-windows 'summary))))))
6965 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6966 (defun gnus-summary-exit-no-update (&optional no-questions)
6967 "Quit reading current newsgroup without updating read article info."
6969 (let* ((group gnus-newsgroup-name)
6970 (quit-buffer (cdr (assoc 'quit-buffer
6971 (gnus-find-method-for-group group)))))
6972 (if (or no-questions
6974 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6976 (gnus-close-group group)
6977 (gnus-summary-clear-local-variables)
6978 (set-buffer gnus-group-buffer)
6979 (gnus-summary-clear-local-variables)
6980 ;; Return to group selection mode.
6981 (gnus-configure-windows 'group)
6982 (if (get-buffer gnus-summary-buffer)
6983 (kill-buffer gnus-summary-buffer))
6984 (if (get-buffer gnus-article-buffer)
6985 (bury-buffer gnus-article-buffer))
6986 (if (equal (gnus-group-group-name) group)
6987 (gnus-group-next-unread-group 1))
6988 (if (gnus-buffer-exists-p quit-buffer)
6990 (switch-to-buffer quit-buffer)
6991 (gnus-configure-windows 'summary)))))))
6993 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6994 (defun gnus-summary-fetch-faq (group)
6995 "Fetch the FAQ for the current group."
6996 (interactive (list gnus-newsgroup-name))
6997 (gnus-configure-windows 'summary-faq)
6998 (find-file (concat gnus-group-faq-directory group)))
7000 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7001 (defun gnus-summary-describe-group (force)
7002 "Describe the current newsgroup."
7004 (gnus-group-describe-group force gnus-newsgroup-name))
7006 (defun gnus-summary-describe-briefly ()
7007 "Describe summary mode commands briefly."
7010 (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")))
7012 ;; Walking around group mode buffer from summary mode.
7014 (defun gnus-summary-next-group (&optional no-article group backward)
7015 "Exit current newsgroup and then select next unread newsgroup.
7016 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7017 If BACKWARD, go to previous group instead."
7019 (gnus-set-global-variables)
7020 (let ((ingroup gnus-newsgroup-name)
7021 (sumbuf (current-buffer))
7023 (gnus-summary-exit t) ;Update all information.
7025 (or (and (numberp (setq num (car (gnus-gethash
7026 group gnus-newsrc-hashtb))))
7030 (gnus-group-jump-to-group group)
7032 (gnus-group-jump-to-group ingroup))
7033 (gnus-summary-search-group backward)
7034 (let ((group (or group (gnus-summary-search-group backward)))
7035 (buf gnus-summary-buffer))
7037 (gnus-summary-exit-no-update t)
7038 (gnus-message 5 "Selecting %s..." group)
7039 ;; We are now in group mode buffer.
7040 ;; Make sure group mode buffer point is on GROUP.
7041 (gnus-group-jump-to-group group)
7042 (if (not (eq gnus-auto-select-next 'quietly))
7044 (gnus-summary-read-group group nil no-article buf)
7045 (and (string= gnus-newsgroup-name ingroup)
7046 (bufferp sumbuf) (buffer-name sumbuf)
7048 (set-buffer (setq gnus-summary-buffer sumbuf))
7049 (gnus-summary-exit-no-update t))))
7050 (let ((prevgroup group))
7051 (gnus-summary-read-group group nil no-article buf)
7052 (while (and (string= gnus-newsgroup-name ingroup)
7054 (buffer-name sumbuf)
7055 (not (string= prevgroup (gnus-group-group-name))))
7056 (set-buffer gnus-group-buffer)
7057 (gnus-summary-read-group
7058 (setq prevgroup (gnus-group-group-name))
7059 nil no-article buf))
7060 (and (string= prevgroup (gnus-group-group-name))
7061 ;; We have reached the final group in the group
7065 (gnus-summary-exit)))))))))
7067 (defun gnus-summary-prev-group (no-article)
7068 "Exit current newsgroup and then select previous unread newsgroup.
7069 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7071 (gnus-summary-next-group no-article nil t))
7073 ;; Walking around summary lines.
7075 (defun gnus-summary-first-subject (unread)
7076 "Go to the first unread subject.
7077 If UNREAD is non-nil, go to the first unread article.
7078 Returns nil if there are no unread articles."
7080 (let ((begin (point)))
7081 (goto-char (point-min))
7084 (while (and (not (eq (nth 1 (get-text-property (point) 'gnus))
7086 (zerop (forward-line 1))))
7090 ;; If there is no unread articles, stay where you are.
7092 (gnus-message 3 "No more unread articles")
7094 (gnus-summary-position-cursor)))))
7096 (defun gnus-summary-next-subject (n &optional unread dont-display)
7097 "Go to next N'th summary line.
7098 If N is negative, go to the previous N'th subject line.
7099 If UNREAD is non-nil, only unread articles are selected.
7100 The difference between N and the actual number of steps taken is
7103 (let ((backward (< n 0))
7106 (gnus-summary-search-forward unread nil backward))
7108 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7109 (if unread " unread" "")))
7112 (gnus-summary-recenter)
7113 (gnus-summary-position-cursor)))
7116 (defun gnus-summary-next-unread-subject (n)
7117 "Go to next N'th unread summary line."
7119 (gnus-summary-next-subject n t))
7121 (defun gnus-summary-prev-subject (n &optional unread)
7122 "Go to previous N'th summary line.
7123 If optional argument UNREAD is non-nil, only unread article is selected."
7125 (gnus-summary-next-subject (- n) unread))
7127 (defun gnus-summary-prev-unread-subject (n)
7128 "Go to previous N'th unread summary line."
7130 (gnus-summary-next-subject (- n) t))
7132 (defun gnus-summary-goto-subject (article)
7133 "Go the subject line of ARTICLE."
7137 (completing-read "Article number: "
7141 (int-to-string (header-number headers))))
7142 gnus-newsgroup-headers)
7143 nil 'require-match))))
7144 (or article (error "No article number"))
7146 (goto-char (point-min))
7147 (while (and (not (eq (car (get-text-property (point) 'gnus)) article))
7148 (zerop (forward-line 1))))
7149 (gnus-summary-show-thread)
7150 ;; Skip dummy articles.
7151 (if (eq (gnus-summary-article-mark) ?Z)
7158 (gnus-summary-position-cursor))))
7160 ;; Walking around summary lines with displaying articles.
7162 (defun gnus-summary-expand-window ()
7163 "Expand summary window to show headers full window."
7165 (gnus-set-global-variables)
7166 (gnus-configure-windows 'summary))
7168 (defun gnus-summary-display-article (article &optional all-header)
7169 "Display ARTICLE in article buffer."
7170 (gnus-set-global-variables)
7173 (gnus-article-prepare article all-header)
7174 (gnus-summary-show-thread)
7175 (if (eq (gnus-summary-article-mark) ?Z)
7178 (gnus-summary-position-cursor)))
7179 (run-hooks 'gnus-select-article-hook)
7180 (gnus-summary-recenter)
7181 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
7183 (gnus-summary-goto-subject article)
7184 ;; Successfully display article.
7185 (gnus-summary-update-line)
7186 (gnus-article-set-window-start
7187 (cdr (assq article gnus-newsgroup-bookmarks)))
7190 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7191 "Select the current article.
7192 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7193 non-nil, the article will be re-fetched even if it already present in
7194 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7196 (and (not pseudo) (gnus-summary-pseudo-article)
7197 (error "This is a pseudo-article."))
7198 (let ((article (or article (gnus-summary-article-number)))
7199 (all-headers (not (not all-headers))) ;Must be T or NIL.
7203 (set-buffer gnus-summary-buffer)
7204 (if (or (null gnus-current-article)
7205 (null gnus-article-current)
7206 (not (eq article (cdr gnus-article-current)))
7207 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7209 ;; The requested article is different from the current article.
7211 (gnus-summary-display-article article all-headers)
7212 (gnus-configure-windows 'article)
7214 (if all-headers (gnus-article-show-all-headers))
7215 (gnus-configure-windows 'article)
7217 (if did (gnus-article-set-window-start
7218 (cdr (assq article gnus-newsgroup-bookmarks)))))))
7220 (defun gnus-summary-set-current-mark (&optional current-mark)
7221 "Obsolete function."
7224 (defun gnus-summary-next-article (unread &optional subject backward)
7225 "Select the next article.
7226 If UNREAD, only unread articles are selected.
7227 If SUBJECT, only articles with SUBJECT are selected.
7228 If BACKWARD, the previous article is selected instead of the next."
7230 (let ((opoint (point))
7231 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
7234 ;; Is there such an article?
7235 ((gnus-summary-display-article
7236 (gnus-summary-search-forward unread subject backward))
7237 (gnus-summary-position-cursor))
7238 ;; If not, we try the first unread, if that is wanted.
7240 gnus-auto-select-same
7241 (gnus-summary-first-unread-article))
7242 (gnus-message 6 "Wrapped"))
7243 ;; Try to get next/previous article not displayed in this group.
7244 ((and gnus-auto-extend-newsgroup
7245 (not unread) (not subject)
7246 (setq header (gnus-more-header-forward backward)))
7247 (gnus-extend-newsgroup header backward)
7248 (let ((buffer-read-only nil))
7249 (goto-char (if backward (point-min) (point-max)))
7250 (gnus-summary-prepare-threads (list header) 0))
7251 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7252 gnus-newsgroup-end)))
7253 ;; Go to next/previous group.
7255 (or (eq method 'nndigest)
7256 (gnus-summary-jump-to-group gnus-newsgroup-name))
7257 (let ((cmd (aref (this-command-keys) 0))
7259 (if (eq gnus-keep-same-level 'best)
7260 (gnus-summary-best-group gnus-newsgroup-name)
7261 (gnus-summary-search-group backward gnus-keep-same-level))))
7262 ;; Keep just the event type of CMD.
7263 (and (listp cmd) (setq cmd (car cmd)))
7264 ;; Select next unread newsgroup automagically.
7266 ((not gnus-auto-select-next)
7267 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7268 ((eq gnus-auto-select-next 'quietly)
7270 (if (eq method 'nndigest)
7272 (gnus-message 7 "No more%s articles (%s)..."
7273 (if unread " unread" "")
7274 (if group (concat "selecting " group)
7276 (gnus-summary-next-group nil group backward)))
7278 (let ((keystrokes '(?\C-n ?\C-p))
7280 (while (or (null key) (memq key keystrokes))
7282 7 "No more%s articles%s" (if unread " unread" "")
7283 (if (and group (not (eq method 'nndigest)))
7284 (format " (Type %s for %s [%s])"
7285 (single-key-description cmd) group
7286 (car (gnus-gethash group gnus-newsrc-hashtb)))
7287 (format " (Type %s to exit %s)"
7288 (single-key-description cmd)
7289 gnus-newsgroup-name)))
7290 ;; Confirm auto selection.
7291 (let* ((event (read-event)))
7292 (setq key (if (listp event) (car event) event))
7293 (if (member key keystrokes)
7294 (let ((obuf (current-buffer)))
7295 (switch-to-buffer gnus-group-buffer)
7296 (gnus-group-jump-to-group group)
7297 (execute-kbd-macro (char-to-string key))
7298 (setq group (gnus-group-group-name))
7299 (switch-to-buffer obuf)))))
7301 (if (or (not group) (eq method 'nndigest))
7303 (gnus-summary-next-group nil group backward))
7304 (setq unread-command-events (list key)))))))))))
7306 (defun gnus-summary-next-unread-article ()
7307 "Select unread article after current one."
7309 (gnus-summary-next-article t (and gnus-auto-select-same
7310 (gnus-summary-subject-string))))
7312 (defun gnus-summary-prev-article (unread &optional subject)
7313 "Select the article after the current one.
7314 If UNREAD is non-nil, only unread articles are selected."
7316 (gnus-summary-next-article unread subject t))
7318 (defun gnus-summary-prev-unread-article ()
7319 "Select unred article before current one."
7321 (gnus-summary-prev-article t (and gnus-auto-select-same
7322 (gnus-summary-subject-string))))
7324 (defun gnus-summary-next-page (lines &optional circular)
7325 "Show next page of selected article.
7326 If end of article, select next article.
7327 Argument LINES specifies lines to be scrolled up.
7328 If CIRCULAR is non-nil, go to the start of the article instead of
7329 instead of selecting the next article when reaching the end of the
7332 (setq gnus-summary-buffer (current-buffer))
7333 (gnus-set-global-variables)
7334 (let ((article (gnus-summary-article-number))
7336 (if (or (null gnus-current-article)
7337 (null gnus-article-current)
7338 (/= article (cdr gnus-article-current))
7339 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7340 ;; Selected subject is different from current article's.
7341 (gnus-summary-display-article article)
7342 (gnus-configure-windows 'article)
7343 (gnus-eval-in-buffer-window
7345 (setq endp (gnus-article-next-page lines)))
7346 (gnus-summary-recenter)
7349 (gnus-summary-beginning-of-article))
7351 (gnus-message 3 "End of message"))
7353 (gnus-summary-next-unread-article)))))))
7355 (defun gnus-summary-prev-page (lines)
7356 "Show previous page of selected article.
7357 Argument LINES specifies lines to be scrolled down."
7359 (gnus-set-global-variables)
7360 (let ((article (gnus-summary-article-number)))
7361 (if (or (null gnus-current-article)
7362 (null gnus-article-current)
7363 (/= article (cdr gnus-article-current))
7364 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7365 ;; Selected subject is different from current article's.
7366 (gnus-summary-display-article article)
7367 (gnus-configure-windows 'article)
7368 (gnus-summary-recenter)
7369 (gnus-eval-in-buffer-window gnus-article-buffer
7370 (gnus-article-prev-page lines))))
7371 (gnus-summary-position-cursor))
7373 (defun gnus-summary-scroll-up (lines)
7374 "Scroll up (or down) one line current article.
7375 Argument LINES specifies lines to be scrolled up (or down if negative)."
7377 (gnus-set-global-variables)
7378 (or (gnus-summary-select-article nil nil 'pseudo)
7379 (gnus-eval-in-buffer-window
7382 (if (gnus-article-next-page lines)
7383 (gnus-message 3 "End of message")))
7385 (gnus-article-prev-page (- lines))))))
7386 (gnus-summary-recenter)
7387 (gnus-summary-position-cursor))
7389 (defun gnus-summary-next-same-subject ()
7390 "Select next article which has the same subject as current one."
7392 (gnus-set-global-variables)
7393 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7395 (defun gnus-summary-prev-same-subject ()
7396 "Select previous article which has the same subject as current one."
7398 (gnus-set-global-variables)
7399 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7401 (defun gnus-summary-next-unread-same-subject ()
7402 "Select next unread article which has the same subject as current one."
7404 (gnus-set-global-variables)
7405 (gnus-summary-next-article t (gnus-summary-subject-string)))
7407 (defun gnus-summary-prev-unread-same-subject ()
7408 "Select previous unread article which has the same subject as current one."
7410 (gnus-set-global-variables)
7411 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7413 (defun gnus-summary-first-unread-article ()
7414 "Select the first unread article.
7415 Return nil if there are no unread articles."
7417 (gnus-set-global-variables)
7419 (if (gnus-summary-first-subject t)
7420 (gnus-summary-display-article (gnus-summary-article-number)))
7421 (gnus-summary-position-cursor)))
7423 (defun gnus-summary-best-unread-article ()
7424 "Select the unread article with the highest score."
7426 (gnus-set-global-variables)
7427 (let ((scored gnus-newsgroup-scored)
7431 (or (> best (cdr (car scored)))
7432 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7433 (not (memq art gnus-newsgroup-marked))
7434 (not (memq art gnus-newsgroup-dormant))
7435 (if (= best (cdr (car scored)))
7436 (setq article (min art article))
7438 (setq best (cdr (car scored))))))
7439 (setq scored (cdr scored)))
7441 (gnus-summary-goto-article article)
7442 (gnus-summary-first-unread-article))
7443 (gnus-summary-position-cursor)))
7445 (defun gnus-summary-goto-article (article &optional all-headers)
7446 "Fetch ARTICLE and display it if it exists.
7447 If ALL-HEADERS is non-nil, no header lines are hidden."
7453 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7454 gnus-newsgroup-headers)
7455 nil 'require-match))))
7457 (and (gnus-summary-goto-subject article)
7458 (gnus-summary-display-article article all-headers))
7459 (gnus-summary-position-cursor)))
7461 (defun gnus-summary-goto-last-article ()
7462 "Go to the last article."
7465 (and gnus-last-article
7466 (gnus-summary-goto-article gnus-last-article))
7467 (gnus-summary-position-cursor)))
7469 (defun gnus-summary-pop-article (number)
7470 "Pop one article off the history and go to the previous.
7471 NUMBER articles will be popped off."
7474 (setq gnus-newsgroup-history
7475 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7477 (gnus-summary-goto-article (car to))
7478 (error "Article history empty")))
7479 (gnus-summary-position-cursor))
7481 ;; Summary article oriented commands
7483 (defun gnus-summary-refer-parent-article (n)
7484 "Refer parent article N times.
7485 The difference between N and the number of articles fetched is returned."
7487 (gnus-set-global-variables)
7491 (let ((ref (header-references (gnus-get-header-by-number
7492 (gnus-summary-article-number)))))
7493 (if (and ref (not (equal ref ""))
7494 (string-match "<[^<>]*>[ \t]*$" ref))
7495 (gnus-summary-refer-article
7496 (substring ref (match-beginning 0) (match-end 0))))))
7499 (gnus-message 1 "No references in article or expired article."))
7500 (gnus-summary-position-cursor)
7503 (defun gnus-summary-refer-article (message-id)
7504 "Refer article specified by MESSAGE-ID.
7505 NOTE: This command only works with newsgroup that use NNTP."
7506 (interactive "sMessage-ID: ")
7507 (if (or (not (stringp message-id))
7508 (zerop (length message-id)))
7510 ;; Construct the correct Message-ID if necessary.
7511 ;; Suggested by tale@pawl.rpi.edu.
7512 (or (string-match "^<" message-id)
7513 (setq message-id (concat "<" message-id)))
7514 (or (string-match ">$" message-id)
7515 (setq message-id (concat message-id ">")))
7516 (let ((header (car (gnus-gethash (downcase message-id)
7517 gnus-newsgroup-dependencies))))
7519 (or (gnus-summary-goto-article (header-number header))
7520 ;; The header has been read, but the article had been
7521 ;; expunged, so we insert it again.
7523 (gnus-summary-insert-line
7524 nil header 0 nil gnus-read-mark nil nil
7525 (header-subject header))
7527 (header-number header)))
7528 (let ((gnus-override-method gnus-refer-article-method)
7529 (gnus-ancient-mark gnus-read-mark)
7531 (and gnus-refer-article-method
7532 (or (gnus-server-opened gnus-refer-article-method)
7533 (gnus-open-server gnus-refer-article-method)))
7534 (if (gnus-article-prepare
7535 message-id nil (gnus-read-header message-id))
7537 (setq number (header-number gnus-current-headers))
7538 (gnus-rebuild-thread message-id)
7539 (gnus-summary-goto-subject number)
7540 (gnus-article-set-window-start
7541 (cdr (assq number gnus-newsgroup-bookmarks)))
7543 (gnus-message 1 "No such references")
7546 (defun gnus-summary-enter-digest-group ()
7547 "Enter a digest group based on the current article."
7549 (gnus-set-global-variables)
7550 (gnus-summary-select-article)
7551 ;; We do not want a narrowed article.
7552 (gnus-summary-stop-page-breaking)
7553 (let ((name (format "%s-%d"
7554 (gnus-group-prefixed-name
7555 gnus-newsgroup-name (list 'nndigest ""))
7556 gnus-current-article))
7557 (buf (current-buffer)))
7558 (set-buffer gnus-group-buffer)
7561 (list t nil (list name gnus-level-default-subscribed nil nil
7562 (list 'nndigest gnus-article-buffer
7563 (cons 'quit-buffer buf))))
7566 (gnus-group-read-group t nil name)
7569 (if (not (equal major-mode 'gnus-group-mode))
7571 (switch-to-buffer buf)
7572 (gnus-set-global-variables)
7573 (gnus-configure-windows 'summary)
7574 (gnus-message 3 "Article not a digest?"))))
7576 (defun gnus-summary-isearch-article ()
7577 "Do incremental search forward on current article."
7579 (gnus-set-global-variables)
7580 (gnus-summary-select-article)
7581 (gnus-eval-in-buffer-window gnus-article-buffer
7584 (defun gnus-summary-search-article-forward (regexp)
7585 "Search for an article containing REGEXP forward.
7586 gnus-select-article-hook is not called during the search."
7589 (concat "Search forward (regexp): "
7590 (if gnus-last-search-regexp
7591 (concat "(default " gnus-last-search-regexp ") "))))))
7592 (gnus-set-global-variables)
7593 (if (string-equal regexp "")
7594 (setq regexp (or gnus-last-search-regexp ""))
7595 (setq gnus-last-search-regexp regexp))
7596 (if (gnus-summary-search-article regexp nil)
7597 (gnus-eval-in-buffer-window
7600 (error "Search failed: \"%s\"" regexp)))
7602 (defun gnus-summary-search-article-backward (regexp)
7603 "Search for an article containing REGEXP backward.
7604 gnus-select-article-hook is not called during the search."
7607 (concat "Search backward (regexp): "
7608 (if gnus-last-search-regexp
7609 (concat "(default " gnus-last-search-regexp ") "))))))
7610 (gnus-set-global-variables)
7611 (if (string-equal regexp "")
7612 (setq regexp (or gnus-last-search-regexp ""))
7613 (setq gnus-last-search-regexp regexp))
7614 (if (gnus-summary-search-article regexp t)
7615 (gnus-eval-in-buffer-window
7618 (error "Search failed: \"%s\"" regexp)))
7620 (defun gnus-summary-search-article (regexp &optional backward)
7621 "Search for an article containing REGEXP.
7622 Optional argument BACKWARD means do search for backward.
7623 gnus-select-article-hook is not called during the search."
7624 (let ((gnus-select-article-hook nil) ;Disable hook.
7625 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7628 (function re-search-backward) (function re-search-forward)))
7631 ;; Hidden thread subtrees must be searched for ,too.
7632 (gnus-summary-show-all-threads)
7633 (if (eobp) (forward-line -1))
7634 ;; First of all, search current article.
7635 ;; We don't want to read article again from NNTP server nor reset
7637 (gnus-summary-select-article)
7638 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7639 (setq last gnus-current-article)
7640 (gnus-eval-in-buffer-window gnus-article-buffer
7643 ;; Begin search from current point.
7644 (setq found (funcall re-search regexp nil t))))
7645 ;; Then search next articles.
7646 (while (and (not found)
7647 (gnus-summary-display-article
7648 (gnus-summary-search-subject backward nil nil)))
7649 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7650 (gnus-eval-in-buffer-window gnus-article-buffer
7653 (goto-char (if backward (point-max) (point-min)))
7654 (setq found (funcall re-search regexp nil t)))))
7656 ;; Adjust article pointer.
7657 (or (eq last gnus-current-article)
7658 (setq gnus-last-article last))
7659 ;; Return T if found such article.
7662 (defun gnus-summary-execute-command (header regexp command &optional backward)
7663 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7664 If HEADER is an empty string (or nil), the match is done on the entire
7665 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7667 (list (let ((completion-ignore-case t))
7670 (mapcar (lambda (string) (list string))
7671 '("Number" "Subject" "From" "Lines" "Date"
7672 "Message-ID" "Xref" "References"))
7673 nil 'require-match))
7674 (read-string "Regexp: ")
7675 (read-key-sequence "Command: ")
7676 current-prefix-arg))
7677 (gnus-set-global-variables)
7678 ;; Hidden thread subtrees must be searched as well.
7679 (gnus-summary-show-all-threads)
7680 ;; We don't want to change current point nor window configuration.
7682 (save-window-excursion
7683 (gnus-message 6 "Executing %s..." (key-description command))
7684 ;; We'd like to execute COMMAND interactively so as to give arguments.
7685 (gnus-execute header regexp
7687 (call-interactively '(, (key-binding command)))))
7689 (gnus-message 6 "Executing %s... done" (key-description command)))))
7691 (defun gnus-summary-beginning-of-article ()
7692 "Scroll the article back to the beginning."
7694 (gnus-set-global-variables)
7695 (gnus-summary-select-article)
7696 (gnus-eval-in-buffer-window
7699 (goto-char (point-min))
7700 (and gnus-break-pages (gnus-narrow-to-page))))
7702 (defun gnus-summary-end-of-article ()
7703 "Scroll to the end of the article."
7705 (gnus-set-global-variables)
7706 (gnus-summary-select-article)
7707 (gnus-eval-in-buffer-window
7710 (goto-char (point-max))
7711 (and gnus-break-pages (gnus-narrow-to-page))))
7713 (defun gnus-summary-show-article ()
7714 "Force re-fetching of the current article."
7716 (gnus-set-global-variables)
7717 (gnus-summary-select-article gnus-have-all-headers t))
7719 (defun gnus-summary-toggle-header (arg)
7720 "Show the headers if they are hidden, or hide them if they are shown.
7721 If ARG is a positive number, show the entire header.
7722 If ARG is a negative number, hide the unwanted header lines."
7724 (gnus-set-global-variables)
7726 (set-buffer gnus-article-buffer)
7727 (let ((buffer-read-only nil))
7729 (if (> arg 0) (remove-text-properties (point-min) (point-max)
7730 gnus-hidden-properties)
7731 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7732 (if (text-property-any (point-min) (point-max) 'invisible t)
7733 (remove-text-properties (point-min) (point-max)
7734 gnus-hidden-properties)
7735 (let ((gnus-have-all-headers nil))
7736 (run-hooks 'gnus-article-display-hook))))
7737 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
7739 (defun gnus-summary-show-all-headers ()
7740 "Make all header lines visible."
7742 (gnus-set-global-variables)
7743 (gnus-article-show-all-headers))
7745 (defun gnus-summary-toggle-mime (arg)
7746 "Toggle MIME processing.
7747 If ARG is a positive number, turn MIME processing on."
7749 (gnus-set-global-variables)
7750 (setq gnus-show-mime
7751 (if (null arg) (not gnus-show-mime)
7752 (> (prefix-numeric-value arg) 0)))
7753 (gnus-summary-select-article t 'force))
7755 (defun gnus-summary-caesar-message (rotnum)
7756 "Caesar rotates all letters of current message by 13/47 places.
7757 With prefix arg, specifies the number of places to rotate each letter forward.
7758 Caesar rotates Japanese letters by 47 places in any case."
7760 (gnus-set-global-variables)
7761 (gnus-summary-select-article)
7762 (let ((mail-header-separator "")) ; !!! Is this necessary?
7763 (gnus-overload-functions)
7764 (gnus-eval-in-buffer-window
7768 ;; We don't want to jump to the beginning of the message.
7769 ;; `save-excursion' does not do its job.
7770 (move-to-window-line 0)
7771 (let ((last (point)))
7772 (news-caesar-buffer-body rotnum)
7776 (defun gnus-summary-stop-page-breaking ()
7777 "Stop page breaking in the current article."
7779 (gnus-set-global-variables)
7780 (gnus-summary-select-article)
7781 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7783 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7785 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7786 "Move the current article to a different newsgroup.
7787 If N is a positive number, move the N next articles.
7788 If N is a negative number, move the N previous articles.
7789 If N is nil and any articles have been marked with the process mark,
7790 move those articles instead.
7791 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7792 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7793 re-spool using this method.
7794 For this function to work, both the current newsgroup and the
7795 newsgroup that you want to move to have to support the `request-move'
7796 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7798 (gnus-set-global-variables)
7799 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7800 (error "The current newsgroup does not support article moving"))
7801 (let ((articles (gnus-summary-work-articles n))
7802 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7804 (if (and (not to-newsgroup) (not select-method))
7807 (format "Where do you want to move %s? %s"
7808 (if (> (length articles) 1)
7809 (format "these %d articles" (length articles))
7811 (if gnus-current-move-group
7812 (format "(%s default) " gnus-current-move-group)
7814 gnus-active-hashtb nil nil prefix)))
7817 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7818 (setq to-newsgroup (or gnus-current-move-group "")))
7819 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7820 (gnus-activate-newsgroup to-newsgroup)
7821 (error "No such group: %s" to-newsgroup))
7822 (setq gnus-current-move-group to-newsgroup)))
7823 (or (gnus-check-backend-function 'request-accept-article
7824 (or select-method to-newsgroup))
7825 (error "%s does not support article moving" to-newsgroup))
7826 (gnus-message 6 "Moving to %s: %s..."
7827 (or select-method to-newsgroup) articles)
7830 (gnus-request-move-article
7831 (car articles) ; Article to move
7832 gnus-newsgroup-name ; From newsgrouo
7833 (nth 1 (gnus-find-method-for-group
7834 gnus-newsgroup-name)) ; Server
7835 (list 'gnus-request-accept-article
7837 (list 'quote select-method)
7839 (not (cdr articles))) ; Accept form
7840 (not (cdr articles)))) ; Only save nov last time
7841 (let* ((buffer-read-only nil)
7844 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7846 (gnus-group-prefixed-name
7848 (if select-method (list select-method "")
7849 (gnus-find-method-for-group to-newsgroup)))
7850 gnus-newsrc-hashtb)))
7851 (info (nth 2 entry))
7852 (article (car articles))
7853 (marked (nth 3 info)))
7854 (gnus-summary-goto-subject article)
7856 (delete-region (point)
7857 (progn (forward-line 1) (point)))
7858 (if (not (memq article gnus-newsgroup-unreads))
7859 (setcar (cdr (cdr info))
7860 (gnus-add-to-range (nth 2 info)
7861 (list (cdr art-group)))))
7862 ;; Copy any marks over to the new group.
7863 (let ((marks '((tick . gnus-newsgroup-marked)
7864 (dormant . gnus-newsgroup-dormant)
7865 (expire . gnus-newsgroup-expirable)
7866 (bookmark . gnus-newsgroup-bookmarks)
7867 ; (score . gnus-newsgroup-scored)
7868 (reply . gnus-newsgroup-replied)))
7869 (to-article (cdr art-group)))
7871 (if (memq article (symbol-value (cdr (car marks))))
7872 (gnus-add-marked-articles
7873 (car info) (car (car marks)) (list to-article) info))
7874 (setq marks (cdr marks))))
7875 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7876 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7877 (setq gnus-newsgroup-dormant
7878 (delq article gnus-newsgroup-dormant)))
7879 (gnus-message 1 "Couldn't move article %s" (car articles)))
7880 (gnus-summary-remove-process-mark (car articles))
7881 (setq articles (cdr articles)))))
7883 (defun gnus-summary-respool-article (n &optional respool-method)
7884 "Respool the current article.
7885 The article will be squeezed through the mail spooling process again,
7886 which means that it will be put in some mail newsgroup or other
7887 depending on `nnmail-split-methods'.
7888 If N is a positive number, respool the N next articles.
7889 If N is a negative number, respool the N previous articles.
7890 If N is nil and any articles have been marked with the process mark,
7891 respool those articles instead.
7893 Respooling can be done both from mail groups and \"real\" newsgroups.
7894 In the former case, the articles in question will be moved from the
7895 current group into whatever groups they are destined to. In the
7896 latter case, they will be copied into the relevant groups."
7898 (gnus-set-global-variables)
7899 (let ((respool-methods (gnus-methods-using 'respool))
7901 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
7903 (setq respool-method
7905 "What method do you want to use when respooling? "
7906 respool-methods nil t methname)))
7907 (or (string= respool-method "")
7908 (if (assoc (symbol-name
7909 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7911 (gnus-summary-move-article n nil (intern respool-method))
7912 (gnus-summary-copy-article n nil (intern respool-method))))))
7914 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7915 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7916 "Move the current article to a different newsgroup.
7917 If N is a positive number, move the N next articles.
7918 If N is a negative number, move the N previous articles.
7919 If N is nil and any articles have been marked with the process mark,
7920 move those articles instead.
7921 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7922 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7923 re-spool using this method.
7924 For this function to work, the newsgroup that you want to move to have
7925 to support the `request-move' and `request-accept'
7926 functions. (Ie. mail newsgroups at present.)"
7928 (gnus-set-global-variables)
7929 (let ((articles (gnus-summary-work-articles n))
7930 (copy-buf (get-buffer-create "*copy work*"))
7931 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7933 (buffer-disable-undo copy-buf)
7934 (if (and (not to-newsgroup) (not select-method))
7937 (format "Where do you want to copy %s? %s"
7938 (if (> (length articles) 1)
7939 (format "these %d articles" (length articles))
7941 (if gnus-current-move-group
7942 (format "(%s default) " gnus-current-move-group)
7944 gnus-active-hashtb nil nil prefix)))
7947 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7948 (setq to-newsgroup (or gnus-current-move-group "")))
7949 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7950 (gnus-activate-newsgroup to-newsgroup)
7951 (error "No such group: %s" to-newsgroup))
7952 (setq gnus-current-move-group to-newsgroup)))
7953 (or (gnus-check-backend-function 'request-accept-article
7954 (or select-method to-newsgroup))
7955 (error "%s does not support article copying" to-newsgroup))
7956 (gnus-message 6 "Copying to %s: %s..."
7957 (or select-method to-newsgroup) articles)
7961 (set-buffer copy-buf)
7962 (gnus-request-article-this-buffer
7963 (car articles) gnus-newsgroup-name)
7964 (gnus-request-accept-article
7965 (if select-method (quote select-method) to-newsgroup)
7966 (not (cdr articles)))))
7969 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7971 (gnus-group-prefixed-name
7973 (if select-method (list select-method "")
7974 (gnus-find-method-for-group to-newsgroup)))
7975 gnus-newsrc-hashtb)))
7976 (info (nth 2 entry))
7977 (article (car articles))
7978 (marked (nth 3 info)))
7979 (if (not (memq article gnus-newsgroup-unreads))
7980 (setcar (cdr (cdr info))
7981 (gnus-add-to-range (nth 2 info)
7982 (list (cdr art-group)))))
7983 ;; Copy any marks over to the new group.
7984 (let ((marks '((tick . gnus-newsgroup-marked)
7985 (dormant . gnus-newsgroup-dormant)
7986 (expire . gnus-newsgroup-expirable)
7987 (bookmark . gnus-newsgroup-bookmarks)
7988 ; (score . gnus-newsgroup-scored)
7989 (reply . gnus-newsgroup-replied)))
7990 (to-article (cdr art-group)))
7992 (if (memq article (symbol-value (cdr (car marks))))
7993 (gnus-add-marked-articles
7994 (car info) (car (car marks)) (list to-article) info))
7995 (setq marks (cdr marks)))))
7996 (gnus-message 1 "Couldn't copy article %s" (car articles)))
7997 (gnus-summary-remove-process-mark (car articles))
7998 (setq articles (cdr articles)))
7999 (kill-buffer copy-buf)))
8001 (defun gnus-summary-expire-articles ()
8002 "Expire all articles that are marked as expirable in the current group."
8004 (if (and gnus-newsgroup-expirable
8005 (gnus-check-backend-function
8006 'request-expire-articles gnus-newsgroup-name))
8007 (let ((expirable gnus-newsgroup-expirable))
8008 ;; The list of articles that weren't expired is returned.
8009 (setq gnus-newsgroup-expirable
8010 (gnus-request-expire-articles gnus-newsgroup-expirable
8011 gnus-newsgroup-name))
8012 ;; We go through the old list of expirable, and mark all
8013 ;; really expired articles as non-existant.
8015 (or (memq (car expirable) gnus-newsgroup-expirable)
8016 (gnus-summary-mark-as-read (car expirable) "%"))
8017 (setq expirable (cdr expirable))))))
8019 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8020 (defun gnus-summary-delete-article (n)
8021 "Delete the N next (mail) articles.
8022 This command actually deletes articles. This is not a marking
8023 command. The article will disappear forever from you life, never to
8025 If N is negative, delete backwards.
8026 If N is nil and articles have been marked with the process mark,
8027 delete these instead."
8029 (or (gnus-check-backend-function 'request-expire-articles
8030 gnus-newsgroup-name)
8031 (error "The current newsgroup does not support article deletion."))
8032 ;; Compute the list of articles to delete.
8033 (let ((articles (gnus-summary-work-articles n)))
8034 (if (and gnus-novice-user
8036 (format "Do you really want to delete %s forever? "
8037 (if (> (length articles) 1) "these articles"
8040 ;; Delete the articles.
8041 (setq gnus-newsgroup-expirable
8042 (gnus-request-expire-articles
8043 articles gnus-newsgroup-name 'force))
8045 (gnus-summary-remove-process-mark (car articles))
8046 ;; The backend might not have been able to delete the article
8048 (or (memq (car articles) gnus-newsgroup-expirable)
8049 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
8050 (setq articles (cdr articles)))))
8051 (gnus-summary-position-cursor))
8053 (defun gnus-summary-edit-article ()
8054 "Enter into a buffer and edit the current article.
8055 This will have permanent effect only in mail groups."
8057 (or (gnus-check-backend-function
8058 'request-replace-article gnus-newsgroup-name)
8059 (error "The current newsgroup does not support article editing."))
8060 (gnus-summary-select-article t)
8062 (gnus-message 6 "C-c C-c to end edits")
8063 (setq buffer-read-only nil)
8065 (use-local-map (copy-keymap (current-local-map)))
8066 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8067 (goto-char (point-min))
8068 (search-forward "\n\n" nil t))
8070 (defun gnus-summary-edit-article-done ()
8071 "Make edits to the current article permanent."
8073 (if (not (gnus-request-replace-article
8074 (cdr gnus-article-current) (car gnus-article-current)
8076 (error "Couldn't replace article.")
8078 (use-local-map gnus-article-mode-map)
8079 (setq buffer-read-only t)
8080 (pop-to-buffer gnus-summary-buffer)))
8082 (defun gnus-summary-fancy-query ()
8083 "Query where the fancy respool algorithm would put this article."
8085 (gnus-summary-select-article)
8087 (set-buffer gnus-article-buffer)
8089 (goto-char (point-min))
8090 (search-forward "\n\n")
8091 (narrow-to-region (point-min) (point))
8092 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8094 ;; Summary score commands.
8096 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8098 (defun gnus-summary-raise-score (n)
8099 "Raise the score of the current article by N."
8101 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8103 (defun gnus-summary-lower-score (n)
8104 "Lower the score of the current article by N."
8106 (gnus-summary-raise-score (- n)))
8108 (defun gnus-summary-set-score (n)
8109 "Set the score of the current article to N."
8111 ;; Skip dummy header line.
8113 (gnus-summary-show-thread)
8114 (if (eq (gnus-summary-article-mark) ?Z)
8116 (let ((buffer-read-only nil))
8118 (gnus-summary-update-mark
8119 (if (= n (or gnus-summary-default-score 0)) ?
8120 (if (< n (or gnus-summary-default-score 0))
8121 gnus-score-below-mark gnus-score-over-mark)) 'score))
8122 (let* ((article (gnus-summary-article-number))
8123 (score (assq article gnus-newsgroup-scored)))
8124 (if score (setcdr score n)
8125 (setq gnus-newsgroup-scored
8126 (cons (cons article n) gnus-newsgroup-scored))))
8127 (gnus-summary-update-line)))
8129 (defun gnus-summary-current-score ()
8130 "Return the score of the current article."
8132 (message "%s" (gnus-summary-article-score)))
8134 ;; Summary marking commands.
8136 (defun gnus-summary-raise-same-subject-and-select (score)
8137 "Raise articles which has the same subject with SCORE and select the next."
8139 (let ((subject (gnus-summary-subject-string)))
8140 (gnus-summary-raise-score score)
8141 (while (gnus-summary-search-subject nil nil subject)
8142 (gnus-summary-raise-score score))
8143 (gnus-summary-next-article t)))
8145 (defun gnus-summary-raise-same-subject (score)
8146 "Raise articles which has the same subject with SCORE."
8148 (let ((subject (gnus-summary-subject-string)))
8149 (gnus-summary-raise-score score)
8150 (while (gnus-summary-search-subject nil nil subject)
8151 (gnus-summary-raise-score score))
8152 (gnus-summary-next-subject 1 t)))
8154 (defun gnus-score-default (level)
8155 (if level (prefix-numeric-value level)
8156 gnus-score-interactive-default-score))
8158 (defun gnus-summary-raise-thread (score)
8159 "Raise articles under current thread with SCORE."
8161 (setq score (1- (gnus-score-default score)))
8164 (let ((level (gnus-summary-thread-level)))
8165 (gnus-summary-raise-score score)
8166 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8167 (> (gnus-summary-thread-level) level))
8168 (gnus-summary-raise-score score))
8170 (let ((gnus-summary-check-current t))
8171 (or (zerop (gnus-summary-next-subject 1 t))
8173 (gnus-summary-recenter)
8174 (gnus-summary-position-cursor)
8175 (gnus-set-mode-line 'summary))
8177 (defun gnus-summary-lower-same-subject-and-select (score)
8178 "Raise articles which has the same subject with SCORE and select the next."
8180 (gnus-summary-raise-same-subject-and-select (- score)))
8182 (defun gnus-summary-lower-same-subject (score)
8183 "Raise articles which has the same subject with SCORE."
8185 (gnus-summary-raise-same-subject (- score)))
8187 (defun gnus-summary-lower-thread (score)
8188 "Raise articles under current thread with SCORE."
8190 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8192 (defun gnus-summary-kill-same-subject-and-select (unmark)
8193 "Mark articles which has the same subject as read, and then select the next.
8194 If UNMARK is positive, remove any kind of mark.
8195 If UNMARK is negative, tick articles."
8198 (setq unmark (prefix-numeric-value unmark)))
8200 (gnus-summary-mark-same-subject
8201 (gnus-summary-subject-string) unmark)))
8202 ;; Select next unread article. If auto-select-same mode, should
8203 ;; select the first unread article.
8204 (gnus-summary-next-article t (and gnus-auto-select-same
8205 (gnus-summary-subject-string)))
8206 (gnus-message 7 "%d articles are marked as %s"
8207 count (if unmark "unread" "read"))))
8209 (defun gnus-summary-kill-same-subject (unmark)
8210 "Mark articles which has the same subject as read.
8211 If UNMARK is positive, remove any kind of mark.
8212 If UNMARK is negative, tick articles."
8215 (setq unmark (prefix-numeric-value unmark)))
8217 (gnus-summary-mark-same-subject
8218 (gnus-summary-subject-string) unmark)))
8219 ;; If marked as read, go to next unread subject.
8221 ;; Go to next unread subject.
8222 (gnus-summary-next-subject 1 t))
8223 (gnus-message 7 "%d articles are marked as %s"
8224 count (if unmark "unread" "read"))))
8226 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8227 "Mark articles with same SUBJECT as read, and return marked number.
8228 If optional argument UNMARK is positive, remove any kinds of marks.
8229 If optional argument UNMARK is negative, mark articles as unread instead."
8232 (cond ((null unmark)
8233 (gnus-summary-mark-as-read nil gnus-killed-mark))
8235 (gnus-summary-tick-article nil t))
8237 (gnus-summary-tick-article)))
8239 (gnus-summary-search-forward nil subject))
8240 (cond ((null unmark)
8241 (gnus-summary-mark-as-read nil gnus-killed-mark))
8243 (gnus-summary-tick-article nil t))
8245 (gnus-summary-tick-article)))
8246 (setq count (1+ count))))
8247 ;; Hide killed thread subtrees. Does not work properly always.
8248 ;;(and (null unmark)
8249 ;; gnus-thread-hide-killed
8250 ;; (gnus-summary-hide-thread))
8251 ;; Return number of articles marked as read.
8254 (defun gnus-summary-mark-as-processable (n &optional unmark)
8255 "Set the process mark on the next N articles.
8256 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8257 the process mark instead. The difference between N and the actual
8258 number of articles marked is returned."
8260 (let ((backward (< n 0))
8265 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8266 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8267 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8269 (if (/= 0 n) (gnus-message 7 "No more articles"))
8270 (gnus-summary-recenter)
8271 (gnus-summary-position-cursor)
8274 (defun gnus-summary-unmark-as-processable (n)
8275 "Remove the process mark from the next N articles.
8276 If N is negative, mark backward instead. The difference between N and
8277 the actual number of articles marked is returned."
8279 (gnus-summary-mark-as-processable n t))
8281 (defun gnus-summary-unmark-all-processable ()
8282 "Remove the process mark from all articles."
8285 (while gnus-newsgroup-processable
8286 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8287 (gnus-summary-position-cursor))
8289 (defun gnus-summary-mark-as-expirable (n)
8290 "Mark N articles forward as expirable.
8291 If N is negative, mark backward instead. The difference between N and
8292 the actual number of articles marked is returned."
8294 (gnus-summary-mark-forward n gnus-expirable-mark))
8296 (defun gnus-summary-mark-article-as-replied (article)
8297 "Mark ARTICLE replied and update the summary line."
8298 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8299 (let ((buffer-read-only nil))
8300 (if (gnus-summary-goto-subject article)
8302 (gnus-summary-update-mark gnus-replied-mark 'replied)
8305 (defun gnus-summary-set-bookmark (article)
8306 "Set a bookmark in current article."
8307 (interactive (list (gnus-summary-article-number)))
8308 (if (or (not (get-buffer gnus-article-buffer))
8309 (not gnus-current-article)
8310 (not gnus-article-current)
8311 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8312 (error "No current article selected"))
8313 ;; Remove old bookmark, if one exists.
8314 (let ((old (assq article gnus-newsgroup-bookmarks)))
8315 (if old (setq gnus-newsgroup-bookmarks
8316 (delq old gnus-newsgroup-bookmarks))))
8317 ;; Set the new bookmark, which is on the form
8318 ;; (article-number . line-number-in-body).
8319 (setq gnus-newsgroup-bookmarks
8323 (set-buffer gnus-article-buffer)
8327 (goto-char (point-min))
8328 (search-forward "\n\n" nil t)
8331 gnus-newsgroup-bookmarks))
8332 (gnus-message 6 "A bookmark has been added to the current article."))
8334 (defun gnus-summary-remove-bookmark (article)
8335 "Remove the bookmark from the current article."
8336 (interactive (list (gnus-summary-article-number)))
8337 ;; Remove old bookmark, if one exists.
8338 (let ((old (assq article gnus-newsgroup-bookmarks)))
8341 (setq gnus-newsgroup-bookmarks
8342 (delq old gnus-newsgroup-bookmarks))
8343 (gnus-message 6 "Removed bookmark."))
8344 (gnus-message 6 "No bookmark in current article."))))
8346 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8347 (defun gnus-summary-mark-as-dormant (n)
8348 "Mark N articles forward as dormant.
8349 If N is negative, mark backward instead. The difference between N and
8350 the actual number of articles marked is returned."
8352 (gnus-summary-mark-forward n gnus-dormant-mark))
8354 (defun gnus-summary-set-process-mark (article)
8355 "Set the process mark on ARTICLE and update the summary line."
8356 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8357 (let ((buffer-read-only nil))
8358 (if (gnus-summary-goto-subject article)
8360 (gnus-summary-show-thread)
8361 (and (eq (gnus-summary-article-mark) ?Z)
8363 (gnus-summary-update-mark gnus-process-mark 'replied)
8366 (defun gnus-summary-remove-process-mark (article)
8367 "Remove the process mark from ARTICLE and update the summary line."
8368 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8369 (let ((buffer-read-only nil))
8370 (if (gnus-summary-goto-subject article)
8372 (gnus-summary-show-thread)
8373 (and (eq (gnus-summary-article-mark) ?Z)
8375 (gnus-summary-update-mark ? 'replied)
8376 (if (memq article gnus-newsgroup-replied)
8377 (gnus-summary-update-mark gnus-replied-mark 'replied))
8380 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8381 "Mark N articles as read forwards.
8382 If N is negative, mark backwards instead.
8383 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8385 The difference between N and the actual number of articles marked is
8388 (gnus-set-global-variables)
8389 (let ((backward (< n 0))
8391 (mark (or mark gnus-del-mark)))
8393 (gnus-summary-mark-article nil mark no-expire)
8394 (zerop (gnus-summary-next-subject
8395 (if backward -1 1) gnus-summary-goto-unread t)))
8397 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8398 (gnus-summary-recenter)
8399 (gnus-summary-position-cursor)
8400 (gnus-set-mode-line 'summary)
8403 (defun gnus-summary-mark-article (&optional article mark no-expire)
8404 "Mark ARTICLE with MARK.
8405 MARK can be any character.
8406 Five MARK strings are reserved: ? (unread),
8407 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8408 If MARK is nil, then the default character ?D is used.
8409 If ARTICLE is nil, then the article on the current line will be
8411 ;; If no mark is given, then we check auto-expiring.
8412 (and (not no-expire)
8413 gnus-newsgroup-auto-expire
8415 (and (numberp mark) (or (= mark gnus-killed-mark)
8416 (= mark gnus-del-mark)
8417 (= mark gnus-catchup-mark)
8418 (= mark gnus-low-score-mark)
8419 (= mark gnus-read-mark))))
8420 (setq mark gnus-expirable-mark))
8421 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8422 (article (or article (gnus-summary-article-number))))
8423 (if (or (= mark gnus-unread-mark)
8424 (= mark gnus-ticked-mark)
8425 (= mark gnus-dormant-mark))
8426 (gnus-mark-article-as-unread article mark)
8427 (gnus-mark-article-as-read article mark))
8429 ;; See whether the article is to be put in the cache.
8432 (gnus-cache-possibly-enter-article
8433 gnus-newsgroup-name article
8434 (gnus-get-header-by-number article)
8435 (= mark gnus-ticked-mark)
8436 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8438 (if (gnus-summary-goto-subject article)
8439 (let ((buffer-read-only nil))
8440 (gnus-summary-show-thread)
8441 (and (eq (gnus-summary-article-mark) ?Z)
8444 (gnus-summary-update-mark mark 'unread)
8447 (defun gnus-summary-update-mark (mark type)
8449 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8453 (forward-char forward)
8454 (setq plist (text-properties-at (point)))
8456 (and (memq 'gnus plist)
8457 (setcar (cdr (car (cdr (memq 'gnus plist)))) mark))
8459 (and plist (add-text-properties (1- (point)) (point) plist))
8460 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8462 (defun gnus-mark-article-as-read (article &optional mark)
8463 "Enter ARTICLE in the pertinent lists and remove it from others."
8464 ;; Make the article expirable.
8465 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
8466 (if (= mark gnus-expirable-mark)
8467 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8468 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8469 ;; Remove from unread and marked lists.
8470 (setq gnus-newsgroup-unreads
8471 (delq article gnus-newsgroup-unreads))
8472 (setq gnus-newsgroup-marked
8473 (delq article gnus-newsgroup-marked))
8474 (setq gnus-newsgroup-dormant
8475 (delq article gnus-newsgroup-dormant))))
8477 (defun gnus-mark-article-as-unread (article &optional mark)
8478 "Enter ARTICLE in the pertinent lists and remove it from others."
8479 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8480 ;; Add to unread list.
8481 (or (memq article gnus-newsgroup-unreads)
8482 (setq gnus-newsgroup-unreads
8483 (cons article gnus-newsgroup-unreads)))
8484 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
8485 ;; list. Otherwise, it must be added to the list.
8486 (setq gnus-newsgroup-marked
8487 (delq article gnus-newsgroup-marked))
8488 (setq gnus-newsgroup-dormant
8489 (delq article gnus-newsgroup-dormant))
8490 (setq gnus-newsgroup-expirable
8491 (delq article gnus-newsgroup-expirable))
8492 (if (= mark gnus-ticked-mark)
8493 (setq gnus-newsgroup-marked
8494 (cons article gnus-newsgroup-marked)))
8495 (if (= mark gnus-dormant-mark)
8496 (setq gnus-newsgroup-dormant
8497 (cons article gnus-newsgroup-dormant)))))
8499 (defalias 'gnus-summary-mark-as-unread-forward
8500 'gnus-summary-tick-article-forward)
8501 (make-obsolete 'gnus-summary-mark-as-unread-forward
8502 'gnus-summary-tick-article-forward)
8503 (defun gnus-summary-tick-article-forward (n)
8504 "Tick N articles forwards.
8505 If N is negative, tick backwards instead.
8506 The difference between N and the number of articles ticked is returned."
8508 (gnus-summary-mark-forward n gnus-ticked-mark))
8510 (defalias 'gnus-summary-mark-as-unread-backward
8511 'gnus-summary-tick-article-backward)
8512 (make-obsolete 'gnus-summary-mark-as-unread-backward
8513 'gnus-summary-tick-article-backward)
8514 (defun gnus-summary-tick-article-backward (n)
8515 "Tick N articles backwards.
8516 The difference between N and the number of articles ticked is returned."
8518 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8520 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8521 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8522 (defun gnus-summary-tick-article (&optional article clear-mark)
8523 "Mark current article as unread.
8524 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8525 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8526 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8529 (defun gnus-summary-mark-as-read-forward (n)
8530 "Mark N articles as read forwards.
8531 If N is negative, mark backwards instead.
8532 The difference between N and the actual number of articles marked is
8535 (gnus-summary-mark-forward n gnus-del-mark t))
8537 (defun gnus-summary-mark-as-read-backward (n)
8538 "Mark the N articles as read backwards.
8539 The difference between N and the actual number of articles marked is
8542 (gnus-summary-mark-forward (- n) gnus-del-mark t))
8544 (defun gnus-summary-mark-as-read (&optional article mark)
8545 "Mark current article as read.
8546 ARTICLE specifies the article to be marked as read.
8547 MARK specifies a string to be inserted at the beginning of the line."
8548 (gnus-summary-mark-article article mark))
8550 (defun gnus-summary-clear-mark-forward (n)
8551 "Clear marks from N articles forward.
8552 If N is negative, clear backward instead.
8553 The difference between N and the number of marks cleared is returned."
8555 (gnus-summary-mark-forward n gnus-unread-mark))
8557 (defun gnus-summary-clear-mark-backward (n)
8558 "Clear marks from N articles backward.
8559 The difference between N and the number of marks cleared is returned."
8561 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8563 (defun gnus-summary-mark-unread-as-read ()
8564 "Intended to be used by `gnus-summary-mark-article-hook'."
8565 (or (memq gnus-current-article gnus-newsgroup-marked)
8566 (memq gnus-current-article gnus-newsgroup-dormant)
8567 (memq gnus-current-article gnus-newsgroup-expirable)
8568 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8570 (defun gnus-summary-mark-region-as-read (point mark all)
8571 "Mark all unread articles between point and mark as read.
8572 If given a prefix, mark all articles between point and mark as read,
8573 even ticked and dormant ones."
8574 (interactive "r\nP")
8584 (not (memq (gnus-summary-article-number)
8585 gnus-newsgroup-marked))
8586 (not (memq (gnus-summary-article-number)
8587 gnus-newsgroup-dormant))))
8588 (gnus-summary-mark-article
8589 (gnus-summary-article-number) gnus-del-mark))
8591 (zerop (forward-line 1))))))
8593 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8594 (defalias 'gnus-summary-delete-marked-as-read
8595 'gnus-summary-remove-lines-marked-as-read)
8596 (make-obsolete 'gnus-summary-delete-marked-as-read
8597 'gnus-summary-remove-lines-marked-as-read)
8598 (defun gnus-summary-remove-lines-marked-as-read ()
8599 "Remove lines that are marked as read."
8601 (gnus-summary-remove-lines-marked-with
8603 (lambda (char) (char-to-string (symbol-value char)))
8604 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
8605 gnus-killed-mark gnus-kill-file-mark
8606 gnus-low-score-mark gnus-expirable-mark)
8609 (defalias 'gnus-summary-delete-marked-with
8610 'gnus-summary-remove-lines-marked-with)
8611 (make-obsolete 'gnus-summary-delete-marked-with
8612 'gnus-summary-remove-lines-marked-with)
8613 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8614 (defun gnus-summary-remove-lines-marked-with (marks)
8615 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8616 (interactive "sMarks: ")
8617 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8619 (set-buffer gnus-summary-buffer)
8620 (let ((buffer-read-only nil)
8621 (marks (concat "^[" marks "]")))
8622 (goto-char (point-min))
8623 (if gnus-newsgroup-adaptive
8624 (gnus-score-remove-lines-adaptive marks)
8625 (while (re-search-forward marks (point-max) t)
8627 (delete-region (point)
8628 (progn (forward-line 1) (point))))))
8629 (or (zerop (buffer-size))
8631 (gnus-summary-prev-subject 1)
8632 (gnus-summary-position-cursor)))))
8634 (defun gnus-summary-expunge-below (score)
8635 "Remove articles with score less than SCORE."
8637 (setq score (if score
8638 (prefix-numeric-value score)
8639 (or gnus-summary-default-score 0)))
8641 (set-buffer gnus-summary-buffer)
8642 (goto-char (point-min))
8643 (let ((buffer-read-only nil)
8646 (if (< (gnus-summary-article-score) score)
8650 (delete-region beg (point)))
8653 (or (zerop (buffer-size))
8655 (gnus-summary-prev-subject 1)
8656 (gnus-summary-position-cursor))))))
8658 (defun gnus-summary-mark-below (score mark)
8659 "Mark articles with score less than SCORE with MARK."
8660 (interactive "P\ncMark: ")
8661 (setq score (if score
8662 (prefix-numeric-value score)
8663 (or gnus-summary-default-score 0)))
8665 (set-buffer gnus-summary-buffer)
8666 (goto-char (point-min))
8668 (and (< (gnus-summary-article-score) score)
8669 (gnus-summary-mark-article nil mark))
8672 (defun gnus-summary-kill-below (score)
8673 "Mark articles with score below SCORE as read."
8675 (gnus-summary-mark-below score gnus-killed-mark))
8677 (defun gnus-summary-clear-above (score)
8678 "Clear all marks from articles with score above SCORE."
8680 (gnus-summary-mark-above score gnus-unread-mark))
8682 (defun gnus-summary-tick-above (score)
8683 "Tick all articles with score above SCORE."
8685 (gnus-summary-mark-above score gnus-ticked-mark))
8687 (defun gnus-summary-mark-above (score mark)
8688 "Mark articles with score over SCORE with MARK."
8689 (interactive "P\ncMark: ")
8690 (setq score (if score
8691 (prefix-numeric-value score)
8692 (or gnus-summary-default-score 0)))
8694 (set-buffer gnus-summary-buffer)
8695 (goto-char (point-min))
8697 (if (> (gnus-summary-article-score) score)
8699 (gnus-summary-mark-article nil mark)
8701 (forward-line 1)))))
8703 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8704 (defun gnus-summary-show-all-expunged ()
8705 "Display all the hidden articles that were expunged for low scores."
8707 (let ((buffer-read-only nil))
8708 (let ((scored gnus-newsgroup-scored)
8711 (or (gnus-summary-goto-subject (car (car scored)))
8712 (and (setq h (gnus-get-header-by-number (car (car scored))))
8713 (< (cdr (car scored)) gnus-summary-expunge-below)
8714 (setq headers (cons h headers))))
8715 (setq scored (cdr scored)))
8716 (or headers (error "No expunged articles hidden."))
8717 (goto-char (point-min))
8719 (gnus-summary-update-lines
8722 (gnus-summary-prepare-threads (nreverse headers) 0)
8724 (goto-char (point-min))
8725 (gnus-summary-position-cursor)))
8727 (defun gnus-summary-show-all-dormant ()
8728 "Display all the hidden articles that are marked as dormant."
8730 (let ((buffer-read-only nil))
8731 (goto-char (point-min))
8732 (let ((dormant gnus-newsgroup-dormant)
8735 (or (gnus-summary-goto-subject (car dormant))
8736 (and (setq h (gnus-get-header-by-number (car dormant)))
8737 (setq headers (cons h headers))))
8738 (setq dormant (cdr dormant)))
8739 (or headers (error "No dormant articles hidden."))
8741 (gnus-summary-update-lines
8744 (gnus-summary-prepare-threads (nreverse headers) 0)
8746 (goto-char (point-min))
8747 (gnus-summary-position-cursor)))
8749 (defun gnus-summary-hide-all-dormant ()
8750 "Hide all dormant articles."
8752 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8753 (gnus-summary-position-cursor))
8755 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
8756 "Mark all articles not marked as unread in this newsgroup as read.
8757 If prefix argument ALL is non-nil, all articles are marked as read.
8758 If QUIETLY is non-nil, no questions will be asked.
8759 If TO-HERE is non-nil, it should be a point in the buffer. All
8760 articles before this point will be marked as read.
8761 The number of articles marked as read is returned."
8765 (not gnus-interactive-catchup) ;Without confirmation?
8769 "Mark absolutely all articles as read? "
8770 "Mark all unread articles as read? ")))
8772 (not gnus-newsgroup-adaptive)
8773 (not gnus-newsgroup-auto-expire))
8775 (and all (setq gnus-newsgroup-marked nil
8776 gnus-newsgroup-dormant nil))
8777 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))
8778 (let ((unreads (length gnus-newsgroup-unreads)))
8779 (if (gnus-summary-first-subject (not all))
8780 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8781 (if to-here (< (point) to-here) t)
8782 (gnus-summary-search-subject nil (not all)))))
8783 (- unreads (length gnus-newsgroup-unreads))
8785 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
8786 (gnus-summary-position-cursor)))
8788 (defun gnus-summary-catchup-to-here (&optional all)
8789 "Mark all unticked articles before the current one as read.
8790 If ALL is non-nil, also mark ticked and dormant articles as read."
8793 (gnus-summary-catchup all t (point))
8794 (gnus-summary-position-cursor))
8796 (defun gnus-summary-catchup-all (&optional quietly)
8797 "Mark all articles in this newsgroup as read."
8799 (gnus-summary-catchup t quietly))
8801 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8802 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8803 If prefix argument ALL is non-nil, all articles are marked as read."
8805 (gnus-summary-catchup all quietly nil 'fast)
8806 ;; Select next newsgroup or exit.
8807 (if (eq gnus-auto-select-next 'quietly)
8808 (gnus-summary-next-group nil)
8809 (gnus-summary-exit)))
8811 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8812 "Mark all articles in this newsgroup as read, and then exit."
8814 (gnus-summary-catchup-and-exit t quietly))
8816 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8817 (defun gnus-summary-catchup-and-goto-next-group (all)
8818 "Mark all articles in this group as read and select the next group.
8819 If given a prefix, mark all articles, unread as well as ticked, as
8822 (gnus-summary-catchup all)
8823 (gnus-summary-next-group))
8825 ;; Thread-based commands.
8827 (defun gnus-summary-toggle-threads (arg)
8828 "Toggle showing conversation threads.
8829 If ARG is positive number, turn showing conversation threads on."
8831 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8832 (setq gnus-show-threads
8833 (if (null arg) (not gnus-show-threads)
8834 (> (prefix-numeric-value arg) 0)))
8835 (gnus-summary-prepare)
8836 (gnus-summary-goto-subject current)
8837 (gnus-summary-position-cursor)))
8839 (defun gnus-summary-show-all-threads ()
8843 (let ((buffer-read-only nil))
8844 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8845 (gnus-summary-position-cursor))
8847 (defun gnus-summary-show-thread ()
8848 "Show thread subtrees.
8849 Returns nil if no thread was there to be shown."
8853 (let ((buffer-read-only nil)
8854 ;; first goto end then to beg, to have point at beg after let
8855 (end (progn (end-of-line) (point)))
8856 (beg (progn (beginning-of-line) (point))))
8858 ;; Any hidden lines here?
8859 (search-forward "\r" end t)
8860 (subst-char-in-region beg end ?\^M ?\n t))))
8861 (gnus-summary-position-cursor)))
8863 (defun gnus-summary-hide-all-threads ()
8864 "Hide all thread subtrees."
8867 (goto-char (point-min))
8868 (gnus-summary-hide-thread)
8869 (while (and (not (eobp)) (zerop (forward-line 1)))
8870 (gnus-summary-hide-thread)))
8871 (gnus-summary-position-cursor))
8873 (defun gnus-summary-hide-thread ()
8874 "Hide thread subtrees.
8875 Returns nil if no threads were there to be hidden."
8877 (let ((buffer-read-only nil)
8879 (level (gnus-summary-thread-level))
8881 ;; Go forward until either the buffer ends or the subthread
8885 (while (and (zerop (forward-line 1))
8886 (> (gnus-summary-thread-level) level))
8891 (search-backward "\n" start t))
8892 (subst-char-in-region start end ?\n ?\^M t)
8893 (forward-line -1)))))
8895 (defun gnus-summary-go-to-next-thread (&optional previous)
8896 "Go to the same level (or less) next thread.
8897 If PREVIOUS is non-nil, go to previous thread instead.
8898 Return the article number moved to, or nil if moving was impossible."
8899 (let ((level (gnus-summary-thread-level))
8900 (article (gnus-summary-article-number)))
8902 (while (and (zerop (gnus-summary-prev-subject 1))
8903 (> (gnus-summary-thread-level) level)))
8904 (while (and (zerop (gnus-summary-next-subject 1))
8905 (> (gnus-summary-thread-level) level))))
8906 (gnus-summary-recenter)
8907 (gnus-summary-position-cursor)
8908 (let ((oart (gnus-summary-article-number)))
8909 (and (/= oart article) oart))))
8911 (defun gnus-summary-next-thread (n)
8912 "Go to the same level next N'th thread.
8913 If N is negative, search backward instead.
8914 Returns the difference between N and the number of skips actually
8917 (let ((backward (< n 0))
8920 (gnus-summary-go-to-next-thread backward))
8922 (gnus-summary-position-cursor)
8923 (if (/= 0 n) (gnus-message 7 "No more threads"))
8926 (defun gnus-summary-prev-thread (n)
8927 "Go to the same level previous N'th thread.
8928 Returns the difference between N and the number of skips actually
8931 (gnus-summary-next-thread (- n)))
8933 (defun gnus-summary-go-down-thread (&optional same)
8934 "Go down one level in the current thread.
8935 If SAME is non-nil, also move to articles of the same level."
8936 (let ((level (gnus-summary-thread-level))
8938 (if (and (zerop (forward-line 1))
8939 (> (gnus-summary-thread-level) level))
8944 (defun gnus-summary-go-up-thread ()
8945 "Go up one level in the current thread."
8946 (let ((level (gnus-summary-thread-level))
8948 (while (and (zerop (forward-line -1))
8949 (>= (gnus-summary-thread-level) level)))
8950 (if (>= (gnus-summary-thread-level) level)
8956 (defun gnus-summary-down-thread (n)
8957 "Go down thread N steps.
8958 If N is negative, go up instead.
8959 Returns the difference between N and how many steps down that were
8965 (if up (gnus-summary-go-up-thread)
8966 (gnus-summary-go-down-thread)))
8968 (gnus-summary-position-cursor)
8969 (if (/= 0 n) (gnus-message 7 "Can't go further"))
8972 (defun gnus-summary-up-thread (n)
8973 "Go up thread N steps.
8974 If N is negative, go up instead.
8975 Returns the difference between N and how many steps down that were
8978 (gnus-summary-down-thread (- n)))
8980 (defun gnus-summary-kill-thread (unmark)
8981 "Mark articles under current thread as read.
8982 If the prefix argument is positive, remove any kinds of marks.
8983 If the prefix argument is negative, tick articles instead."
8986 (setq unmark (prefix-numeric-value unmark)))
8988 (level (gnus-summary-thread-level)))
8991 ;; Mark the article...
8992 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8993 ((> unmark 0) (gnus-summary-tick-article nil t))
8994 (t (gnus-summary-tick-article)))
8995 ;; ...and go forward until either the buffer ends or the subtree
8997 (if (not (and (zerop (forward-line 1))
8998 (> (gnus-summary-thread-level) level)))
8999 (setq killing nil))))
9000 ;; Hide killed subtrees.
9002 gnus-thread-hide-killed
9003 (gnus-summary-hide-thread))
9004 ;; If marked as read, go to next unread subject.
9006 ;; Go to next unread subject.
9007 (gnus-summary-next-subject 1 t)))
9008 (gnus-set-mode-line 'summary))
9010 ;; Summary sorting commands
9012 (defun gnus-summary-sort-by-number (&optional reverse)
9013 "Sort summary buffer by article number.
9014 Argument REVERSE means reverse order."
9017 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9019 (defun gnus-summary-sort-by-author (&optional reverse)
9020 "Sort summary buffer by author name alphabetically.
9021 If case-fold-search is non-nil, case of letters is ignored.
9022 Argument REVERSE means reverse order."
9027 (let ((extract (funcall
9028 gnus-extract-address-components
9029 (header-from (gnus-get-header-by-number
9030 (gnus-summary-article-number))))))
9031 (or (car extract) (cdr extract))))
9032 'gnus-thread-sort-by-author)
9035 (defun gnus-summary-sort-by-subject (&optional reverse)
9036 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9037 If case-fold-search is non-nil, case of letters is ignored.
9038 Argument REVERSE means reverse order."
9043 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9044 'gnus-thread-sort-by-subject)
9047 (defun gnus-summary-sort-by-date (&optional reverse)
9048 "Sort summary buffer by date.
9049 Argument REVERSE means reverse order."
9056 (gnus-get-header-by-number (gnus-summary-article-number)))))
9057 'gnus-thread-sort-by-date)
9060 (defun gnus-summary-sort-by-score (&optional reverse)
9061 "Sort summary buffer by score.
9062 Argument REVERSE means reverse order."
9065 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9068 (defvar gnus-summary-already-sorted nil)
9069 (defun gnus-summary-sort (predicate reverse)
9070 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9071 (if gnus-summary-already-sorted
9073 (let (buffer-read-only)
9074 (if (not gnus-show-threads)
9076 (goto-char (point-min))
9077 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9078 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9079 (gnus-summary-prepare-hook nil)
9080 (gnus-summary-already-sorted nil))
9081 (gnus-summary-prepare)
9082 (and gnus-show-threads
9083 gnus-thread-hide-subtree
9084 (gnus-summary-hide-all-threads)))))))
9086 (defun gnus-sortable-date (date)
9087 "Make sortable string by string-lessp from DATE.
9088 Timezone package is used."
9089 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9090 (year (aref date 0))
9091 (month (aref date 1))
9092 (day (aref date 2)))
9093 (timezone-make-sortable-date
9095 (timezone-make-time-string
9096 (aref date 3) (aref date 4) (aref date 5)))))
9099 ;; Summary saving commands.
9101 (defun gnus-summary-save-article (n)
9102 "Save the current article using the default saver function.
9103 If N is a positive number, save the N next articles.
9104 If N is a negative number, save the N previous articles.
9105 If N is nil and any articles have been marked with the process mark,
9106 save those articles instead.
9107 The variable `gnus-default-article-saver' specifies the saver function."
9109 (let ((articles (gnus-summary-work-articles n)))
9111 (let ((header (gnus-get-header-by-number (car articles))))
9112 (if (vectorp header)
9114 (gnus-summary-select-article t nil nil (car articles))
9115 (or gnus-save-all-headers
9116 (gnus-article-hide-headers t))
9117 ;; Remove any X-Gnus lines.
9120 (set-buffer gnus-article-buffer)
9121 (let ((buffer-read-only nil))
9122 (goto-char (point-min))
9123 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9125 (while (re-search-forward "^X-Gnus" nil t)
9127 (delete-region (point)
9128 (progn (forward-line 1) (point))))
9131 (if gnus-default-article-saver
9132 (funcall gnus-default-article-saver)
9133 (error "No default saver is defined."))))
9134 (if (assq 'name header)
9135 (gnus-copy-file (cdr (assq 'name header)))
9136 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9137 (gnus-summary-remove-process-mark (car articles))
9138 (setq articles (cdr articles)))
9139 (gnus-summary-position-cursor)
9142 (defun gnus-summary-pipe-output (arg)
9143 "Pipe the current article to a subprocess.
9144 If N is a positive number, pipe the N next articles.
9145 If N is a negative number, pipe the N previous articles.
9146 If N is nil and any articles have been marked with the process mark,
9147 pipe those articles instead."
9149 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9150 (gnus-summary-save-article arg)))
9152 (defun gnus-summary-save-article-mail (arg)
9153 "Append the current article to an mail file.
9154 If N is a positive number, save the N next articles.
9155 If N is a negative number, save the N previous articles.
9156 If N is nil and any articles have been marked with the process mark,
9157 save those articles instead."
9159 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9160 (gnus-summary-save-article arg)))
9162 (defun gnus-summary-save-article-rmail (arg)
9163 "Append the current article to an rmail file.
9164 If N is a positive number, save the N next articles.
9165 If N is a negative number, save the N previous articles.
9166 If N is nil and any articles have been marked with the process mark,
9167 save those articles instead."
9169 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9170 (gnus-summary-save-article arg)))
9172 (defun gnus-summary-save-article-file (arg)
9173 "Append the current article to a file.
9174 If N is a positive number, save the N next articles.
9175 If N is a negative number, save the N previous articles.
9176 If N is nil and any articles have been marked with the process mark,
9177 save those articles instead."
9179 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9180 (gnus-summary-save-article arg)))
9182 (defun gnus-summary-save-article-folder (arg)
9183 "Append the current article to an mh folder.
9184 If N is a positive number, save the N next articles.
9185 If N is a negative number, save the N previous articles.
9186 If N is nil and any articles have been marked with the process mark,
9187 save those articles instead."
9189 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
9190 (gnus-summary-save-article arg)))
9192 (defun gnus-summary-save-article-vm (arg)
9193 "Append the current article to a vm folder.
9194 If N is a positive number, save the N next articles.
9195 If N is a negative number, save the N previous articles.
9196 If N is nil and any articles have been marked with the process mark,
9197 save those articles instead."
9199 (let ((gnus-default-article-saver 'gnus-summary-save-in-vm))
9200 (gnus-summary-save-article arg)))
9202 (defun gnus-read-save-file-name (prompt default-name)
9203 (let ((methods gnus-split-methods)
9205 (if (not gnus-split-methods)
9208 (set-buffer gnus-article-buffer)
9209 (gnus-narrow-to-headers)
9211 (goto-char (point-min))
9212 (and (condition-case ()
9213 (re-search-forward (car (car methods)) nil t)
9215 (setq split-name (cons (nth 1 (car methods)) split-name)))
9216 (setq methods (cdr methods)))
9218 (cond ((null split-name)
9220 (concat prompt " (default "
9221 (file-name-nondirectory default-name) ") ")
9222 (file-name-directory default-name)
9224 ((= 1 (length split-name))
9226 (concat prompt " (default " (car split-name) ") ")
9227 gnus-article-save-directory
9228 (concat gnus-article-save-directory (car split-name))))
9230 (setq split-name (mapcar (lambda (el) (list el))
9231 (nreverse split-name)))
9232 (let ((result (completing-read
9234 split-name nil nil)))
9235 (concat gnus-article-save-directory
9236 (if (string= result "")
9237 (car (car split-name))
9240 (defun gnus-summary-save-in-rmail (&optional filename)
9241 "Append this article to Rmail file.
9242 Optional argument FILENAME specifies file name.
9243 Directory to save to is default to `gnus-article-save-directory' which
9244 is initialized from the SAVEDIR environment variable."
9247 (funcall gnus-rmail-save-name gnus-newsgroup-name
9248 gnus-current-headers gnus-newsgroup-last-rmail)))
9250 (setq filename (gnus-read-save-file-name
9251 "Save in rmail file:" default-name)))
9252 (gnus-make-directory (file-name-directory filename))
9253 (gnus-eval-in-buffer-window
9258 (gnus-output-to-rmail filename))))
9259 ;; Remember the directory name to save articles.
9260 (setq gnus-newsgroup-last-rmail filename)))
9262 (defun gnus-summary-save-in-mail (&optional filename)
9263 "Append this article to Unix mail file.
9264 Optional argument FILENAME specifies file name.
9265 Directory to save to is default to `gnus-article-save-directory' which
9266 is initialized from the SAVEDIR environment variable."
9269 (funcall gnus-mail-save-name gnus-newsgroup-name
9270 gnus-current-headers gnus-newsgroup-last-mail)))
9272 (setq filename (gnus-read-save-file-name
9273 "Save in Unix mail file:" default-name)))
9275 (expand-file-name filename
9277 (file-name-directory default-name))))
9278 (gnus-make-directory (file-name-directory filename))
9279 (gnus-eval-in-buffer-window
9284 (if (and (file-readable-p filename) (rmail-file-p filename))
9285 (gnus-output-to-rmail filename)
9286 (rmail-output filename 1 t t)))))
9287 ;; Remember the directory name to save articles.
9288 (setq gnus-newsgroup-last-mail filename)))
9290 (defun gnus-summary-save-in-file (&optional filename)
9291 "Append this article to file.
9292 Optional argument FILENAME specifies file name.
9293 Directory to save to is default to `gnus-article-save-directory' which
9294 is initialized from the SAVEDIR environment variable."
9297 (funcall gnus-file-save-name gnus-newsgroup-name
9298 gnus-current-headers gnus-newsgroup-last-file)))
9300 (setq filename (gnus-read-save-file-name
9301 "Save in file:" default-name)))
9302 (gnus-make-directory (file-name-directory filename))
9303 (gnus-eval-in-buffer-window
9308 (gnus-output-to-file filename))))
9309 ;; Remember the directory name to save articles.
9310 (setq gnus-newsgroup-last-file filename)))
9312 (defun gnus-summary-save-in-pipe (&optional command)
9313 "Pipe this article to subprocess."
9315 (let ((command (read-string "Shell command on article: "
9316 gnus-last-shell-command)))
9317 (if (string-equal command "")
9318 (setq command gnus-last-shell-command))
9319 (gnus-eval-in-buffer-window
9323 (shell-command-on-region (point-min) (point-max) command nil)))
9324 (setq gnus-last-shell-command command)))
9326 ;; Summary extract commands
9328 (defun gnus-summary-insert-pseudos (pslist)
9329 (let ((buffer-read-only nil)
9330 (article (gnus-summary-article-number))
9332 (or (gnus-summary-goto-subject article)
9333 (error (format "No such article: %d" article)))
9334 (or gnus-newsgroup-headers-hashtb-by-number
9335 (gnus-make-headers-hashtable-by-number))
9336 (gnus-summary-position-cursor)
9337 ;; If all commands are to be bunched up on one line, we collect
9339 (if gnus-view-pseudos-separately
9341 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9344 (setq action (cdr (assq 'action (car ps))))
9345 (setq files (list (cdr (assq 'name (car ps)))))
9346 (while (and ps (cdr ps)
9347 (string= (or action "1")
9348 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9349 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9350 (setcdr ps (cdr (cdr ps))))
9353 (if (not (string-match "%s" action))
9354 (setq files (cons " " files)))
9355 (setq files (cons " " files))
9356 (and (assq 'execute (car ps))
9357 (setcdr (assq 'execute (car ps))
9358 (funcall (if (string-match "%s" action)
9361 (mapconcat (lambda (f) f) files " ")))))
9362 (setq ps (cdr ps)))))
9363 (if gnus-view-pseudos
9365 (and (assq 'execute (car pslist))
9366 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9367 (eq gnus-view-pseudos 'not-confirm)))
9368 (setq pslist (cdr pslist)))
9371 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9372 (gnus-summary-article-number)))
9375 (insert " " (file-name-nondirectory
9376 (cdr (assq 'name (car pslist))))
9377 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9378 (add-text-properties
9379 b (1+ b) (list 'gnus (list gnus-reffed-article-number
9381 'gnus-pseudo (car pslist)))
9383 (gnus-sethash (int-to-string gnus-reffed-article-number)
9384 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9385 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9386 (setq pslist (cdr pslist)))))))
9388 (defun gnus-pseudos< (p1 p2)
9389 (let ((c1 (cdr (assq 'action p1)))
9390 (c2 (cdr (assq 'action p2))))
9391 (and c1 c2 (string< c1 c2))))
9393 (defun gnus-request-pseudo-article (props)
9394 (cond ((assq 'execute props)
9395 (gnus-execute-command (cdr (assq 'execute props)))))
9396 (let ((gnus-current-article (gnus-summary-article-number)))
9397 (run-hooks 'gnus-mark-article-hook)))
9399 (defun gnus-execute-command (command &optional automatic)
9401 (gnus-article-setup-buffer)
9402 (set-buffer gnus-article-buffer)
9403 (let ((command (if automatic command (read-string "Command: " command)))
9404 (buffer-read-only nil))
9406 (insert "$ " command "\n\n")
9407 (if gnus-view-pseudo-asynchronously
9408 (start-process "gnus-execute" nil "sh" "-c" command)
9409 (call-process "sh" nil t nil "-c" command)))))
9411 (defun gnus-copy-file (file &optional to)
9414 (list (read-file-name "Copy file: " default-directory)
9415 (read-file-name "Copy file to: " default-directory)))
9416 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9417 (and (file-directory-p to)
9418 (setq to (concat (file-name-as-directory to)
9419 (file-name-nondirectory file))))
9420 (copy-file file to))
9422 ;; Summary kill commands.
9424 (defun gnus-summary-edit-global-kill (article)
9425 "Edit the \"global\" kill file."
9426 (interactive (list (gnus-summary-article-number)))
9427 (gnus-group-edit-global-kill article))
9429 (defun gnus-summary-edit-local-kill ()
9430 "Edit a local kill file applied to the current newsgroup."
9432 (setq gnus-current-headers
9434 (int-to-string (gnus-summary-article-number))
9435 gnus-newsgroup-headers-hashtb-by-number))
9436 (gnus-set-global-variables)
9437 (gnus-group-edit-local-kill
9438 (gnus-summary-article-number) gnus-newsgroup-name))
9442 ;;; Gnus article mode
9445 (put 'gnus-article-mode 'mode-class 'special)
9447 (if gnus-article-mode-map
9449 (setq gnus-article-mode-map (make-keymap))
9450 (suppress-keymap gnus-article-mode-map)
9451 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9452 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9453 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9454 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9455 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9456 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9457 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9458 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9459 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
9460 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
9461 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
9463 ;; Duplicate almost all summary keystrokes in the article mode map.
9465 (list "#" "\M-#" "\C-c\M-#" "n" "p"
9466 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9467 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9468 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k""x" "X"
9469 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9471 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "M"
9474 (define-key gnus-article-mode-map (car commands)
9475 'gnus-article-summary-command)
9476 (setq commands (cdr commands))))
9478 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F")))
9480 (define-key gnus-article-mode-map (car commands)
9481 'gnus-article-summary-command-nosave)
9482 (setq commands (cdr commands)))))
9485 (defun gnus-article-mode ()
9486 "Major mode for displaying an article.
9488 All normal editing commands are switched off.
9490 The following commands are available:
9492 \\<gnus-article-mode-map>
9493 \\[gnus-article-next-page]\t Scroll the article one page forwards
9494 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9495 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9496 \\[gnus-article-show-summary]\t Display the summary buffer
9497 \\[gnus-article-mail]\t Send a reply to the address near point
9498 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9499 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9500 \\[gnus-info-find-node]\t Go to the Gnus info node"
9502 (if gnus-visual (gnus-article-make-menu-bar))
9503 (kill-all-local-variables)
9504 (setq mode-line-modified "-- ")
9505 (make-local-variable 'mode-line-format)
9506 (setq mode-line-format (copy-sequence mode-line-format))
9507 (and (equal (nth 3 mode-line-format) " ")
9508 (setcar (nthcdr 3 mode-line-format) ""))
9509 (setq mode-name "Article")
9510 (setq major-mode 'gnus-article-mode)
9511 (make-local-variable 'minor-mode-alist)
9512 (or (assq 'gnus-show-mime minor-mode-alist)
9513 (setq minor-mode-alist
9514 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9515 (use-local-map gnus-article-mode-map)
9516 (make-local-variable 'page-delimiter)
9517 (setq page-delimiter gnus-page-delimiter)
9518 (buffer-disable-undo (current-buffer))
9519 (setq buffer-read-only t) ;Disable modification
9520 (run-hooks 'gnus-article-mode-hook))
9522 (defun gnus-article-setup-buffer ()
9523 "Initialize article mode buffer."
9524 (or (get-buffer gnus-article-buffer)
9526 (set-buffer (get-buffer-create gnus-article-buffer))
9527 (gnus-add-current-to-buffer-list)
9528 (gnus-article-mode))))
9530 ;; Set article window start at LINE, where LINE is the number of lines
9531 ;; from the head of the article.
9532 (defun gnus-article-set-window-start (&optional line)
9534 (get-buffer-window gnus-article-buffer)
9536 (set-buffer gnus-article-buffer)
9537 (goto-char (point-min))
9540 (gnus-message 6 "Moved to bookmark")
9541 (search-forward "\n\n" nil t)
9545 (defun gnus-request-article-this-buffer (article group)
9546 "Get an article and insert it into this buffer."
9547 (setq group (or group gnus-newsgroup-name))
9549 ;; Open server if it has closed.
9550 (gnus-check-news-server (gnus-find-method-for-group group))
9552 ;; Using `gnus-request-article' directly will insert the article into
9553 ;; `nntp-server-buffer' - so we'll save some time by not having to
9554 ;; copy it from the server buffer into the article buffer.
9556 ;; We only request an article by message-id when we do not have the
9557 ;; headers for it, so we'll have to get those.
9558 (and (stringp article)
9559 (let ((gnus-override-method gnus-refer-article-method))
9560 (gnus-read-header article)))
9562 ;; If the article number is negative, that means that this article
9563 ;; doesn't belong in this newsgroup (possibly), so we find its
9564 ;; message-id and request it by id instead of number.
9565 (if (and (numberp article) (< article 0))
9567 (set-buffer gnus-summary-buffer)
9568 (let ((header (gnus-gethash (int-to-string article)
9569 gnus-newsgroup-headers-hashtb-by-number)))
9570 (if (vectorp header)
9571 ;; It's a real article.
9572 (setq article (header-id header))
9573 ;; It is an extracted pseudo-article.
9575 (gnus-request-pseudo-article header)))))
9578 (if (and gnus-use-cache
9580 (gnus-cache-request-article article group))
9582 ;; Get the article and into the article buffer.
9586 (let ((gnus-override-method
9587 (and (stringp article) gnus-refer-article-method)))
9588 (and (gnus-request-article article group (current-buffer))
9592 (defun gnus-read-header (id)
9593 "Read the headers of article ID and enter them into the Gnus system."
9594 (or gnus-newsgroup-headers-hashtb-by-number
9595 (gnus-make-headers-hashtable-by-number))
9597 (if (not (setq header
9598 (car (if (let ((gnus-nov-is-evil t))
9599 (gnus-retrieve-headers
9600 (list id) gnus-newsgroup-name))
9601 (gnus-get-newsgroup-headers)))))
9604 (header-set-number header gnus-reffed-article-number))
9605 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9606 (gnus-sethash (int-to-string (header-number header)) header
9607 gnus-newsgroup-headers-hashtb-by-number)
9609 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9610 (setq gnus-current-headers header)
9613 (defun gnus-article-prepare (article &optional all-headers header)
9614 "Prepare ARTICLE in article mode buffer.
9615 ARTICLE should either be an article number or a Message-ID.
9616 If ARTICLE is an id, HEADER should be the article headers.
9617 If ALL-HEADERS is non-nil, no headers are hidden."
9619 ;; Make sure we start in a summary buffer.
9620 (or (eq major-mode 'gnus-summary-mode)
9621 (set-buffer gnus-summary-buffer))
9622 (setq gnus-summary-buffer (current-buffer))
9623 ;; Make sure the connection to the server is alive.
9624 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9626 (gnus-check-news-server
9627 (gnus-find-method-for-group gnus-newsgroup-name))
9628 (gnus-request-group gnus-newsgroup-name t)))
9629 (or gnus-newsgroup-headers-hashtb-by-number
9630 (gnus-make-headers-hashtable-by-number))
9631 (let* ((article (if header (header-number header) article))
9632 (summary-buffer (current-buffer))
9633 (internal-hook gnus-article-internal-prepare-hook)
9634 (group gnus-newsgroup-name)
9637 (gnus-article-setup-buffer)
9638 (set-buffer gnus-article-buffer)
9639 (if (not (setq result (let ((buffer-read-only nil))
9640 (gnus-request-article-this-buffer
9642 ;; There is no such article.
9645 (set-buffer gnus-summary-buffer)
9646 (setq gnus-current-article 0)
9647 (and (numberp article)
9648 (gnus-summary-mark-as-read article gnus-canceled-mark))
9649 (gnus-message 1 "No such article (may be canceled)")
9650 (and (numberp article)
9651 (setq gnus-current-article article))
9653 (and (numberp article)
9654 (setq gnus-article-current
9655 (cons gnus-newsgroup-name article)))
9657 (if (not (eq result 'article))
9660 (set-buffer summary-buffer)
9661 (setq gnus-last-article gnus-current-article
9662 gnus-newsgroup-history (cons gnus-current-article
9663 gnus-newsgroup-history)
9664 gnus-current-article 0
9665 gnus-current-headers nil
9666 gnus-article-current nil)
9667 (gnus-configure-windows 'article)
9668 (gnus-set-global-variables))
9669 (gnus-set-mode-line 'article))
9670 ;; The result from the `request' was an actual article -
9671 ;; or at least some text that is now displayed in the
9673 (if (and (numberp article)
9674 (not (eq article gnus-current-article)))
9675 ;; Seems like a new article has been selected.
9676 ;; `gnus-current-article' must be an article number.
9678 (set-buffer summary-buffer)
9679 (setq gnus-last-article gnus-current-article
9680 gnus-newsgroup-history (cons gnus-current-article
9681 gnus-newsgroup-history)
9682 gnus-current-article article
9683 gnus-current-headers
9684 (gnus-get-header-by-number gnus-current-article)
9685 gnus-article-current
9686 (cons gnus-newsgroup-name gnus-current-article))
9687 (gnus-summary-show-thread)
9688 (run-hooks 'gnus-mark-article-hook)
9689 (gnus-set-mode-line 'summary)
9691 (run-hooks 'gnus-visual-mark-article-hook))
9692 ;; Set the global newsgroup variables here.
9693 ;; Suggested by Jim Sisolak
9694 ;; <sisolak@trans4.neep.wisc.edu>.
9695 (gnus-set-global-variables)
9697 (gnus-cache-possibly-enter-article
9699 (gnus-get-header-by-number article)
9700 (memq article gnus-newsgroup-marked)
9701 (memq article gnus-newsgroup-dormant)
9702 (memq article gnus-newsgroup-unreads)))))
9703 ;; gnus-have-all-headers must be either T or NIL.
9704 (setq gnus-have-all-headers
9705 (not (not (or all-headers gnus-show-all-headers))))
9706 ;; Hooks for getting information from the article.
9707 ;; This hook must be called before being narrowed.
9708 (let (buffer-read-only)
9709 (run-hooks 'internal-hook)
9710 (run-hooks 'gnus-article-prepare-hook))
9711 ;; Decode MIME message.
9712 (if (and gnus-show-mime
9713 (gnus-fetch-field "Mime-Version"))
9714 (funcall gnus-show-mime-method))
9715 ;; Perform the article display hooks.
9716 (let (buffer-read-only)
9717 (run-hooks 'gnus-article-display-hook))
9719 (goto-char (point-min))
9720 (and gnus-break-pages (gnus-narrow-to-page))
9721 (gnus-set-mode-line 'article)
9722 (gnus-configure-windows 'article)
9723 (goto-char (point-min))
9726 (defun gnus-article-show-all-headers ()
9727 "Show all article headers in article mode buffer."
9729 (gnus-article-setup-buffer)
9730 (set-buffer gnus-article-buffer)
9731 (let ((buffer-read-only nil))
9732 (remove-text-properties (point-min) (point-max)
9733 gnus-hidden-properties))))
9735 (defun gnus-article-hide-headers-if-wanted ()
9736 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9737 Provided for backwards compatability."
9738 (or gnus-have-all-headers
9739 (gnus-article-hide-headers)))
9741 (defun gnus-article-hide-headers (&optional delete)
9742 "Hide unwanted headers and possibly sort them as well."
9745 (set-buffer gnus-article-buffer)
9747 (let ((sorted gnus-sorted-header-list)
9748 (buffer-read-only nil)
9749 want want-list beg want-l)
9750 ;; First we narrow to just the headers.
9752 (goto-char (point-min))
9753 ;; Hide any "From " lines at the beginning of (mail) articles.
9754 (while (looking-at "From ")
9757 (add-text-properties (point-min) (point) gnus-hidden-properties))
9758 ;; Then treat the rest of the header lines.
9761 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9762 ;; Then we use the two regular expressions
9763 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9764 ;; select which header lines is to remain visible in the
9766 (goto-char (point-min))
9767 (while (re-search-forward "^[^ \t]*:" nil t)
9769 ;; We add the headers we want to keep to a list and delete
9770 ;; them from the buffer.
9771 (if (or (and (stringp gnus-visible-headers)
9772 (looking-at gnus-visible-headers))
9773 (and (not (stringp gnus-visible-headers))
9774 (stringp gnus-ignored-headers)
9775 (not (looking-at gnus-ignored-headers))))
9779 ;; Be sure to get multi-line headers...
9780 (re-search-forward "^[^ \t]*:" nil t)
9783 (cons (buffer-substring beg (point)) want-list))
9784 (delete-region beg (point))
9787 ;; Next we perform the sorting by looking at
9788 ;; `gnus-sorted-header-list'.
9789 (goto-char (point-min))
9790 (while (and sorted want-list)
9791 (setq want-l want-list)
9793 (not (string-match (car sorted) (car want-l))))
9794 (setq want-l (cdr want-l)))
9797 (insert (car want-l))
9798 (setq want-list (delq (car want-l) want-list))))
9799 (setq sorted (cdr sorted)))
9800 ;; Any headers that were not matched by the sorted list we
9801 ;; just tack on the end of the visible header list.
9803 (insert (car want-list))
9804 (setq want-list (cdr want-list)))
9805 ;; And finally we make the unwanted headers invisible.
9807 (delete-region (point) (point-max))
9808 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9809 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
9811 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9812 (defun gnus-article-treat-overstrike ()
9813 "Translate overstrikes into bold text."
9816 (set-buffer gnus-article-buffer)
9817 (let ((buffer-read-only nil))
9818 (while (search-forward "\b" nil t)
9819 (let ((next (following-char))
9820 (previous (char-after (- (point) 2))))
9821 (cond ((eq next previous)
9822 (delete-region (- (point) 2) (point))
9823 (put-text-property (point) (1+ (point))
9826 (delete-region (1- (point)) (1+ (point)))
9827 (put-text-property (1- (point)) (point)
9830 (delete-region (- (point) 2) (point))
9831 (put-text-property (point) (1+ (point))
9832 'face 'underline))))))))
9834 (defun gnus-article-word-wrap ()
9835 "Format too long lines."
9838 (set-buffer gnus-article-buffer)
9839 (let ((buffer-read-only nil))
9840 (goto-char (point-min))
9841 (search-forward "\n\n" nil t)
9843 (let ((paragraph-start "^\\W"))
9845 (and (>= (current-column) (window-width))
9846 (/= (preceding-char) ?:)
9847 (fill-paragraph nil))
9848 (end-of-line 2))))))
9850 (defun gnus-article-remove-cr ()
9851 "Remove carriage returns from an article."
9854 (set-buffer gnus-article-buffer)
9855 (let ((buffer-read-only nil))
9856 (goto-char (point-min))
9857 (while (search-forward "\r" nil t)
9858 (replace-match "" t t)))))
9860 (defun gnus-article-display-x-face (&optional force)
9861 "Look for an X-Face header and display it if present."
9862 (interactive (list 'force))
9864 (set-buffer gnus-article-buffer)
9865 (let ((inhibit-point-motion-hooks t)
9866 (case-fold-search nil))
9868 (goto-char (point-min))
9869 (search-forward "\n\n")
9870 (narrow-to-region (point-min) (point))
9871 (goto-char (point-min))
9872 (if (or (not gnus-article-x-face-command)
9874 (or (not gnus-article-x-face-too-ugly)
9875 (string-match gnus-article-x-face-too-ugly
9876 (mail-fetch-field "from"))))
9878 (goto-char (point-min))
9879 (not (re-search-forward "^X-Face: " nil t))))
9882 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
9883 (if (symbolp gnus-article-x-face-command)
9884 (and (or (fboundp gnus-article-x-face-command)
9885 (error "%s is not a function"
9886 gnus-article-x-face-command))
9887 (funcall gnus-article-x-face-command beg end))
9888 (call-process-region beg end "sh" nil 0 nil
9889 "-c" gnus-article-x-face-command))))))))
9891 (defun gnus-article-de-quoted-unreadable (&optional force)
9892 "Do a naïve translation of a quoted-printable-encoded article.
9893 This is in no way, shape or form meant as a replacement for real MIME
9894 processing, but is simply a stop-gap measure until MIME support is
9896 If FORCE, decode the article whether it is marked as quoted-printable
9898 (interactive (list 'force))
9900 (set-buffer gnus-article-buffer)
9901 (let ((case-fold-search t)
9902 (buffer-read-only nil)
9903 (type (gnus-fetch-field "content-transfer-encoding")))
9904 (if (or force (and type (string-match "quoted-printable" type)))
9906 (goto-char (point-min))
9907 (search-forward "\n\n" nil 'move)
9908 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
9910 (defun gnus-mime-decode-quoted-printable (from to)
9911 ;; Decode quoted-printable from region between FROM and TO.
9914 (while (search-forward "=" to t)
9915 (cond ((eq (following-char) ?\n)
9918 ((looking-at "[0-9A-F][0-9A-F]")
9920 (insert (hexl-hex-string-to-integer
9921 (buffer-substring (point) (+ 2 (point)))))
9923 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
9925 (defun gnus-article-date-ut (&optional type)
9926 "Convert DATE date to universal time in the current article.
9927 If TYPE is `local', convert to local time; if it is `lapsed', output
9928 how much time has lapsed since DATE."
9929 (interactive (list 'ut))
9930 (let ((date (header-date (or gnus-current-headers
9931 (gnus-get-header-by-number
9932 (gnus-summary-article-number)))))
9933 (date-regexp "^Date: \\|^X-Sent: "))
9935 (set-buffer gnus-article-buffer)
9936 (let ((buffer-read-only nil))
9937 (goto-char (point-min))
9938 (if (and (re-search-forward date-regexp nil t)
9941 (looking-at date-regexp)))
9942 (delete-region (gnus-point-at-bol)
9943 (progn (end-of-line) (1+ (point))))
9944 (goto-char (point-min))
9945 (goto-char (- (search-forward "\n\n") 2)))
9949 (concat "Date: " (timezone-make-date-arpa-standard date) "\n"))
9951 (concat "Date: " (timezone-make-date-arpa-standard date nil "UT")
9954 (let* ((sec (- (gnus-seconds-since-epoch
9955 (timezone-make-date-arpa-standard
9956 (current-time-string) (current-time-zone) "UT"))
9957 (gnus-seconds-since-epoch
9958 (timezone-make-date-arpa-standard date nil "UT"))))
9959 (units (list (cons 'year (* 365.25 24 60 60))
9960 (cons 'week (* 7 24 60 60))
9961 (cons 'day (* 24 60 60))
9962 (cons 'hour (* 60 60))
9970 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
9972 (setq sec (- sec (* num (cdr unit))))
9974 (concat (if prev ", " "") (int-to-string (floor num))
9975 " " (symbol-name (car unit))
9976 (if (> num 1) "s" ""))
9981 (error "Unknown conversion type: %s" type))))))))
9983 (defun gnus-article-date-local ()
9984 "Convert the current article date to the local timezone."
9986 (gnus-article-date-ut 'local))
9988 (defun gnus-article-date-lapsed ()
9989 "Convert the current article date to time lapsed since it was sent."
9991 (gnus-article-date-ut 'lapsed))
9993 (defun gnus-article-maybe-highlight ()
9994 (if gnus-visual (gnus-article-highlight)))
9998 (defun gnus-output-to-rmail (file-name)
9999 "Append the current article to an Rmail file named FILE-NAME."
10001 ;; Most of these codes are borrowed from rmailout.el.
10002 (setq file-name (expand-file-name file-name))
10003 (setq rmail-default-rmail-file file-name)
10004 (let ((artbuf (current-buffer))
10005 (tmpbuf (get-buffer-create " *Gnus-output*")))
10007 (or (get-file-buffer file-name)
10008 (file-exists-p file-name)
10009 (if (gnus-yes-or-no-p
10010 (concat "\"" file-name "\" does not exist, create it? "))
10011 (let ((file-buffer (create-file-buffer file-name)))
10013 (set-buffer file-buffer)
10014 (rmail-insert-rmail-file-header)
10015 (let ((require-final-newline nil))
10016 (write-region (point-min) (point-max) file-name t 1)))
10017 (kill-buffer file-buffer))
10018 (error "Output file does not exist")))
10019 (set-buffer tmpbuf)
10020 (buffer-disable-undo (current-buffer))
10022 (insert-buffer-substring artbuf)
10023 (gnus-convert-article-to-rmail)
10024 ;; Decide whether to append to a file or to an Emacs buffer.
10025 (let ((outbuf (get-file-buffer file-name)))
10027 (append-to-file (point-min) (point-max) file-name)
10028 ;; File has been visited, in buffer OUTBUF.
10029 (set-buffer outbuf)
10030 (let ((buffer-read-only nil)
10031 (msg (and (boundp 'rmail-current-message)
10032 (symbol-value 'rmail-current-message))))
10033 ;; If MSG is non-nil, buffer is in RMAIL mode.
10036 (narrow-to-region (point-max) (point-max))))
10037 (insert-buffer-substring tmpbuf)
10040 (goto-char (point-min))
10042 (search-backward "\^_")
10043 (narrow-to-region (point) (point-max))
10044 (goto-char (1+ (point-min)))
10045 (rmail-count-new-messages t)
10046 (rmail-show-message msg)))))))
10047 (kill-buffer tmpbuf)))
10049 (defun gnus-output-to-file (file-name)
10050 "Append the current article to a file named FILE-NAME."
10051 (setq file-name (expand-file-name file-name))
10052 (let ((artbuf (current-buffer))
10053 (tmpbuf (get-buffer-create " *Gnus-output*")))
10055 (set-buffer tmpbuf)
10056 (buffer-disable-undo (current-buffer))
10058 (insert-buffer-substring artbuf)
10059 ;; Append newline at end of the buffer as separator, and then
10060 ;; save it to file.
10061 (goto-char (point-max))
10063 (append-to-file (point-min) (point-max) file-name))
10064 (kill-buffer tmpbuf)))
10066 (defun gnus-convert-article-to-rmail ()
10067 "Convert article in current buffer to Rmail message format."
10068 (let ((buffer-read-only nil))
10069 ;; Convert article directly into Babyl format.
10070 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10071 (goto-char (point-min))
10072 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10073 (while (search-forward "\n\^_" nil t) ;single char
10074 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10075 (goto-char (point-max))
10078 (defun gnus-narrow-to-page (&optional arg)
10079 "Make text outside current page invisible except for page delimiter.
10080 A numeric arg specifies to move forward or backward by that many pages,
10081 thus showing a page other than the one point was originally in."
10083 (setq arg (if arg (prefix-numeric-value arg) 0))
10085 (forward-page -1) ;Beginning of current page.
10090 (forward-page (1- arg))))
10091 ;; Find the end of the page.
10093 ;; If we stopped due to end of buffer, stay there.
10094 ;; If we stopped after a page delimiter, put end of restriction
10095 ;; at the beginning of that line.
10096 ;; These are commented out.
10097 ;; (if (save-excursion (beginning-of-line)
10098 ;; (looking-at page-delimiter))
10099 ;; (beginning-of-line))
10100 (narrow-to-region (point)
10102 ;; Find the top of the page.
10104 ;; If we found beginning of buffer, stay there.
10105 ;; If extra text follows page delimiter on same line,
10107 ;; Otherwise, show text starting with following line.
10108 (if (and (eolp) (not (bobp)))
10112 (defun gnus-gmt-to-local ()
10113 "Rewrite Date header described in GMT to local in current buffer.
10114 Intended to be used with gnus-article-prepare-hook."
10118 (goto-char (point-min))
10119 (narrow-to-region (point-min)
10120 (progn (search-forward "\n\n" nil 'move) (point)))
10121 (goto-char (point-min))
10122 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10123 (let ((buffer-read-only nil)
10124 (date (buffer-substring (match-beginning 1) (match-end 1))))
10125 (delete-region (match-beginning 1) (match-end 1))
10127 (timezone-make-date-arpa-standard
10128 date nil (current-time-zone))))))))
10131 ;; Article mode commands
10133 (defun gnus-article-next-page (lines)
10134 "Show next page of current article.
10135 If end of article, return non-nil. Otherwise return nil.
10136 Argument LINES specifies lines to be scrolled up."
10138 (move-to-window-line -1)
10139 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10140 (if (save-excursion
10142 (and (pos-visible-in-window-p) ;Not continuation line.
10144 ;; Nothing in this page.
10145 (if (or (not gnus-break-pages)
10148 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10150 (gnus-narrow-to-page 1) ;Go to next page.
10152 ;; More in this page.
10156 ;; Long lines may cause an end-of-buffer error.
10157 (goto-char (point-max))))
10160 (defun gnus-article-prev-page (lines)
10161 "Show previous page of current article.
10162 Argument LINES specifies lines to be scrolled down."
10164 (move-to-window-line 0)
10165 (if (and gnus-break-pages
10167 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10169 (gnus-narrow-to-page -1) ;Go to previous page.
10170 (goto-char (point-max))
10172 (scroll-down lines)))
10174 (defun gnus-article-refer-article ()
10175 "Read article specified by message-id around point."
10177 (search-forward ">" nil t) ;Move point to end of "<....>".
10178 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10180 (buffer-substring (match-beginning 1) (match-end 1))))
10181 (set-buffer gnus-summary-buffer)
10182 (gnus-summary-refer-article message-id))
10183 (error "No references around point")))
10185 (defun gnus-article-show-summary ()
10186 "Reconfigure windows to show summary buffer."
10188 (gnus-configure-windows 'article)
10189 (gnus-summary-goto-subject gnus-current-article))
10191 (defun gnus-article-describe-briefly ()
10192 "Describe article mode commands briefly."
10195 (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")))
10197 (defun gnus-article-summary-command ()
10198 "Execute the last keystroke in the summary buffer."
10200 (let ((obuf (current-buffer))
10201 (owin (current-window-configuration))
10203 (switch-to-buffer gnus-summary-buffer 'norecord)
10204 (setq func (lookup-key (current-local-map) (this-command-keys)))
10205 (call-interactively func)
10207 (let ((npoint (point)))
10208 (set-window-configuration owin)
10209 (set-window-start (get-buffer-window (current-buffer)) (point)))))
10211 (defun gnus-article-summary-command-nosave ()
10212 "Execute the last keystroke in the summary buffer."
10214 (let ((obuf (current-buffer))
10215 (owin (current-window-configuration))
10217 (switch-to-buffer gnus-summary-buffer 'norecord)
10218 (setq func (lookup-key (current-local-map) (this-command-keys)))
10219 (call-interactively func)))
10221 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
10222 ;; Modified by tower@prep Nov 86
10223 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
10225 (defun gnus-caesar-region (&optional n)
10226 "Caesar rotation of region by N, default 13, for decrypting netnews.
10227 ROT47 will be performed for Japanese text in any case."
10228 (interactive (if current-prefix-arg ; Was there a prefix arg?
10229 (list (prefix-numeric-value current-prefix-arg))
10231 (cond ((not (numberp n)) (setq n 13))
10232 (t (setq n (mod n 26)))) ;canonicalize N
10233 (if (not (zerop n)) ; no action needed for a rot of 0
10235 (if (or (not (boundp 'caesar-translate-table))
10236 (not caesar-translate-table)
10237 (/= (aref caesar-translate-table ?a) (+ ?a n)))
10239 (lower "abcdefghijklmnopqrstuvwxyz")
10241 (gnus-message 9 "Building caesar-translate-table...")
10242 (setq caesar-translate-table (make-vector 256 0))
10244 (aset caesar-translate-table i i)
10246 (setq lower (concat lower lower)
10247 upper (upcase lower)
10250 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
10251 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
10253 ;; ROT47 for Japanese text.
10254 ;; Thanks to ichikawa@flab.fujitsu.junet.
10256 (let ((t1 (logior ?O 128))
10257 (t2 (logior ?! 128))
10258 (t3 (logior ?~ 128)))
10260 (aset caesar-translate-table i
10261 (let ((v (aref caesar-translate-table i)))
10262 (if (<= v t1) (if (< v t2) v (+ v 47))
10263 (if (<= v t3) (- v 47) v))))
10265 (gnus-message 9 "Building caesar-translate-table... done")))
10266 (let ((from (region-beginning))
10269 (setq str (buffer-substring from to))
10270 (setq len (length str))
10272 (aset str i (aref caesar-translate-table (aref str i)))
10275 (delete-region from to)
10279 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10282 (defalias 'gnus-batch-kill 'gnus-batch-score)
10284 (defun gnus-batch-score ()
10285 "Run batched scoring.
10286 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10287 Newsgroups is a list of strings in Bnews format. If you want to score
10288 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10289 score the alt hierarchy, you'd say \"!alt.all\"."
10292 (gnus-newsrc-parse-options
10293 (apply (function concat)
10294 (mapcar (lambda (g) (concat g " "))
10295 command-line-args-left))))
10296 (gnus-expert-user t)
10297 (nnmail-spool-file nil)
10298 (gnus-use-dribble-file nil)
10299 (yes (car yes-and-no))
10300 (no (cdr yes-and-no))
10301 group subscribed newsrc entry
10302 ;; Disable verbose message.
10303 gnus-novice-user gnus-large-newsgroup)
10304 ;; Eat all arguments.
10305 (setq command-line-args-left nil)
10308 ;; Apply kills to specified newsgroups in command line arguments.
10309 (setq newsrc (cdr gnus-newsrc-alist))
10311 (setq group (car (car newsrc)))
10312 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10313 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10315 (or (eq (car entry) t)
10316 (not (zerop (car entry)))))
10317 (if yes (string-match yes group) t)
10318 (or (null no) (not (string-match no group))))
10320 (gnus-summary-read-group group nil t)
10321 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10322 (gnus-summary-exit))))
10323 (setq newsrc (cdr newsrc)))
10325 (switch-to-buffer gnus-group-buffer)
10326 (gnus-group-save-newsrc)))
10328 (defun gnus-apply-kill-file ()
10329 "Apply a kill file to the current newsgroup.
10330 Returns the number of articles marked as read."
10331 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10332 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10333 (gnus-apply-kill-file-internal)
10336 (defun gnus-kill-save-kill-buffer ()
10338 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10339 (if (get-file-buffer file)
10341 (set-buffer (get-file-buffer file))
10342 (and (buffer-modified-p) (save-buffer))
10343 (kill-buffer (current-buffer)))))))
10345 (defvar gnus-kill-file-name "KILL"
10346 "Suffix of the kill files.")
10348 (defun gnus-newsgroup-kill-file (newsgroup)
10349 "Return the name of a kill file name for NEWSGROUP.
10350 If NEWSGROUP is nil, return the global kill file name instead."
10351 (cond ((or (null newsgroup)
10352 (string-equal newsgroup ""))
10353 ;; The global KILL file is placed at top of the directory.
10354 (expand-file-name gnus-kill-file-name
10355 (or gnus-kill-files-directory "~/News")))
10356 ((gnus-use-long-file-name 'not-kill)
10357 ;; Append ".KILL" to newsgroup name.
10358 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10359 (or gnus-kill-files-directory "~/News")))
10361 ;; Place "KILL" under the hierarchical directory.
10362 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10363 "/" gnus-kill-file-name)
10364 (or gnus-kill-files-directory "~/News")))))
10371 (defvar gnus-dribble-ignore nil)
10373 (defun gnus-dribble-file-name ()
10374 (concat gnus-startup-file "-dribble"))
10376 (defun gnus-dribble-open ()
10379 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10380 (buffer-disable-undo (current-buffer))
10381 (bury-buffer gnus-dribble-buffer)
10383 (goto-char (point-max))))
10385 (defun gnus-dribble-enter (string)
10386 (if (and (not gnus-dribble-ignore)
10387 gnus-dribble-buffer
10388 (buffer-name gnus-dribble-buffer))
10389 (let ((obuf (current-buffer)))
10390 (set-buffer gnus-dribble-buffer)
10391 (insert string "\n")
10392 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10393 (set-buffer obuf))))
10395 (defun gnus-dribble-read-file ()
10396 (let ((dribble-file (gnus-dribble-file-name)))
10398 (set-buffer (setq gnus-dribble-buffer
10400 (file-name-nondirectory dribble-file))))
10401 (gnus-add-current-to-buffer-list)
10403 (set-visited-file-name dribble-file)
10404 (buffer-disable-undo (current-buffer))
10405 (bury-buffer (current-buffer))
10406 (set-buffer-modified-p nil)
10407 (let ((auto (make-auto-save-file-name))
10408 (gnus-dribble-ignore t))
10409 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10411 (if (file-newer-than-file-p auto dribble-file)
10412 (setq dribble-file auto))
10413 (insert-file-contents dribble-file)
10414 (if (not (zerop (buffer-size)))
10415 (set-buffer-modified-p t))
10417 "Auto-save file exists. Do you want to read it? ")
10419 (gnus-message 5 "Reading %s..." dribble-file)
10420 (eval-current-buffer)
10421 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
10423 (defun gnus-dribble-delete-file ()
10424 (if (file-exists-p (gnus-dribble-file-name))
10425 (delete-file (gnus-dribble-file-name)))
10426 (if gnus-dribble-buffer
10428 (set-buffer gnus-dribble-buffer)
10429 (let ((auto (make-auto-save-file-name)))
10430 (if (file-exists-p auto)
10431 (delete-file auto))
10433 (set-buffer-modified-p nil)))))
10435 (defun gnus-dribble-save ()
10436 (if (and gnus-dribble-buffer
10437 (buffer-name gnus-dribble-buffer))
10439 (set-buffer gnus-dribble-buffer)
10442 (defun gnus-dribble-clear ()
10444 (if (gnus-buffer-exists-p gnus-dribble-buffer)
10446 (set-buffer gnus-dribble-buffer)
10448 (set-buffer-modified-p nil)
10449 (setq buffer-saved-size (buffer-size))))))
10452 ;;; Server Communication
10455 ;; All the Gnus backends have the same interface, and should return
10456 ;; data in a similar format. Below is an overview of what functions
10457 ;; these packages must supply and what results they should return.
10461 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
10464 ;; Functions for the imaginary backend `choke':
10466 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
10467 ;; Should return all headers for all ARTICLES, or return NOV lines for
10470 ;; `choke-request-group GROUP &optional SERVER DISCARD'
10471 ;; Switch to GROUP. If DISCARD is nil, active information on the group
10472 ;; must be returned.
10474 ;; `choke-close-group GROUP &optional SERVER'
10475 ;; Close group. Most backends won't have to do anything with this
10476 ;; call, but it is an opportunity to clean up, if that is needed. It
10477 ;; is called when Gnus exits a group.
10479 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
10480 ;; Return ARTICLE, which is either an article number or
10481 ;; message-id. Note that not all backends can return articles based on
10484 ;; `choke-request-list SERVER'
10485 ;; Return a list of all newsgroups on SERVER.
10487 ;; `choke-request-list-newsgroups SERVER'
10488 ;; Return a list of descriptions of all newsgroups on SERVER.
10490 ;; `choke-request-newgroups DATE &optional SERVER'
10491 ;; Return a list of all groups that have arrived after DATE on
10492 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
10493 ;; always check whether the groups are old or not. Backends that do
10494 ;; not store date information may just return the entire list of
10495 ;; groups, although this might not be a good idea in general.
10497 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
10498 ;; Should return a buffer that is suitable for "posting". nnspool and
10499 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
10500 ;; buffer. This function should fill out the appropriate headers.
10502 ;; `choke-request-post &optional SERVER'
10503 ;; Function that will be called from a buffer to be posted.
10505 ;; `choke-open-server SERVER &optional ARGUMENT'
10506 ;; Open a connection to SERVER.
10508 ;; `choke-close-server &optional SERVER'
10509 ;; Close the connection to SERVER.
10511 ;; `choke-server-opened &optional SERVER'
10512 ;; Whether the conenction to SERVER is opened or not.
10514 ;; `choke-server-status &optional SERVER'
10515 ;; Should return a status string (not in the nntp buffer, but as the
10516 ;; result of the function).
10518 ;; `choke-retrieve-groups GROUPS &optional SERVER'
10519 ;; Optional function for retrieving active file info on all groups in
10520 ;; GROUPS. Two return formats are supported: The normal active file
10521 ;; format, and a list of GROUP lines. This function should return (as
10522 ;; a function value) either `active' or `group', depending on what
10523 ;; format it returns.
10525 ;; The following functions are optional and apply only to backends
10526 ;; that are able to control the contents of their groups totally
10527 ;; (ie. mail backends.) Backends that aren't able to do that
10528 ;; shouldn't define these functions at all. Gnus will check for their
10529 ;; presence before attempting to call them.
10531 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
10532 ;; Should expire (according to some aging scheme) all ARTICLES. Most
10533 ;; backends will not be able to expire articles. Should return a list
10534 ;; of all articles that were not expired.
10536 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
10537 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
10538 ;; Removes any information it has added to the article (extra headers,
10539 ;; whatever - make it as clean as possible), and then passes the
10540 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
10541 ;; function described below. If the ACCEPT-FORM returns a non-nil
10542 ;; value, the article should then be deleted. If LAST is nil, that
10543 ;; means that there will be further calls to this function. This might
10544 ;; be taken as an advice not to save buffers/internal variables just
10545 ;; yet, but wait until the last call to speed things up.
10547 ;; `choke-request-accept-article GROUP &optional LAST'
10548 ;; The contents of the current buffer will be put into GROUP. There
10549 ;; should, of course, be an article in the current buffer. This
10550 ;; function is normally only called by the function described above,
10551 ;; and LAST works the same way as in that function.
10553 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
10554 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
10555 ;; This provides an easy interface for allowing editing of
10556 ;; articles. Note that even headers may be edited, so the backend has
10557 ;; to update any tables (nov buffers, etc) that it maintains after
10558 ;; replacing the article.
10560 ;; `choke-request-create-group GROUP &optional SERVER'
10561 ;; Create GROUP on SERVER. This might be a new, empty group, or it
10562 ;; might be a group that already exists, but hasn't been registered
10565 ;; All these functions must return nil if they couldn't service the
10566 ;; request. If the optional arguments are not supplied, some "current"
10567 ;; or "default" values should be used. In short, one should emulate an
10568 ;; NNTP server, in a way.
10570 ;; If you want to write a new backend, you just have to supply the
10571 ;; functions listed above. In addition, you must enter the new backend
10572 ;; into the list of valid select methods:
10573 ;; (setq gnus-valid-select-methods
10574 ;; (cons '("choke" mail) gnus-valid-select-methods))
10575 ;; The first element in this list is the name of the backend. Other
10576 ;; elemnets may be `mail' (for mail groups), `post' (for news
10577 ;; groups), `none' (neither), `respool' (for groups that can control
10578 ;; their contents).
10580 (defun gnus-start-news-server (&optional confirm)
10581 "Open a method for getting news.
10582 If CONFIRM is non-nil, the user will be asked for an NNTP server."
10584 (if gnus-current-select-method
10585 ;; Stream is already opened.
10587 ;; Open NNTP server.
10588 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
10591 ;; Read server name with completion.
10592 (setq gnus-nntp-server
10593 (completing-read "NNTP server: "
10594 (mapcar (lambda (server) (list server))
10595 (cons (list gnus-nntp-server)
10596 gnus-secondary-servers))
10597 nil nil gnus-nntp-server))))
10599 (if (and gnus-nntp-server
10600 (stringp gnus-nntp-server)
10601 (not (string= gnus-nntp-server "")))
10602 (setq gnus-select-method
10603 (cond ((or (string= gnus-nntp-server "")
10604 (string= gnus-nntp-server "::"))
10605 (list 'nnspool (system-name)))
10606 ((string-match "^:" gnus-nntp-server)
10607 (list 'nnmh gnus-nntp-server
10608 (list 'nnmh-directory
10609 (file-name-as-directory
10611 (concat "~/" (substring
10612 gnus-nntp-server 1)))))))
10614 (list 'nntp gnus-nntp-server)))))
10616 (setq how (car gnus-select-method))
10617 (setq where (car (cdr gnus-select-method)))
10618 (cond ((eq how 'nnspool)
10620 (gnus-message 5 "Looking up local news spool..."))
10623 (gnus-message 5 "Looking up mh spool..."))
10626 (setq gnus-current-select-method gnus-select-method)
10627 (run-hooks 'gnus-open-server-hook)
10629 ;; gnus-open-server-hook might have opened it
10630 (gnus-server-opened gnus-select-method)
10631 (gnus-open-server gnus-select-method)
10634 "%s server on %s can't be opened. Continue? "
10635 (car gnus-select-method) (nth 1 gnus-select-method)))
10637 (gnus-message 1 "Couldn't open server on %s"
10638 (nth 1 gnus-select-method))
10642 (defun gnus-check-news-server (&optional method)
10643 "If the news server is down, start it up again."
10644 (let ((method (if method method gnus-select-method)))
10645 (and (stringp method)
10646 (setq method (gnus-server-to-method method)))
10647 (if (gnus-server-opened method)
10648 ;; Stream is already opened.
10651 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
10652 (run-hooks 'gnus-open-server-hook)
10653 (or (gnus-server-opened method)
10654 (gnus-open-server method))
10657 (defun gnus-nntp-message (&optional message)
10658 "Check the status of the NNTP server.
10659 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
10660 is returned insted of the status string."
10661 (let ((status (gnus-status-message (gnus-find-method-for-group
10662 gnus-newsgroup-name)))
10663 (message (or message "")))
10664 (if (and (stringp status) (> (length status) 0))
10667 (defun gnus-get-function (method function)
10668 (and (stringp method)
10669 (setq method (gnus-server-to-method method)))
10670 (let ((func (intern (format "%s-%s" (car method) function))))
10671 (if (not (fboundp func))
10673 (require (car method))
10674 (if (not (fboundp func))
10675 (error "No such function: %s" func))))
10678 ;;; Interface functions to the backends.
10680 (defun gnus-open-server (method)
10681 (funcall (gnus-get-function method 'open-server)
10682 (nth 1 method) (nthcdr 2 method)))
10684 (defun gnus-close-server (method)
10685 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
10687 (defun gnus-request-list (method)
10688 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
10690 (defun gnus-request-list-newsgroups (method)
10691 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
10693 (defun gnus-request-newgroups (date method)
10694 (funcall (gnus-get-function method 'request-newgroups)
10695 date (nth 1 method)))
10697 (defun gnus-server-opened (method)
10698 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
10700 (defun gnus-status-message (method)
10701 (let ((method (if (stringp method) (gnus-find-method-for-group method)
10703 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
10705 (defun gnus-request-group (group &optional dont-check)
10706 (let ((method (gnus-find-method-for-group group)))
10707 (funcall (gnus-get-function method 'request-group)
10708 (gnus-group-real-name group) (nth 1 method) dont-check)))
10710 (defun gnus-request-asynchronous (group &optional articles)
10711 (let ((method (gnus-find-method-for-group group)))
10712 (funcall (gnus-get-function method 'request-asynchronous)
10713 (gnus-group-real-name group) (nth 1 method) articles)))
10715 (defun gnus-list-active-group (group)
10716 (let ((method (gnus-find-method-for-group group))
10717 (func 'list-active-group))
10718 (and (gnus-check-backend-function func group)
10719 (funcall (gnus-get-function method func)
10720 (gnus-group-real-name group) (nth 1 method)))))
10722 (defun gnus-request-group-description (group)
10723 (let ((method (gnus-find-method-for-group group))
10724 (func 'request-group-description))
10725 (and (gnus-check-backend-function func group)
10726 (funcall (gnus-get-function method func)
10727 (gnus-group-real-name group) (nth 1 method)))))
10729 (defun gnus-close-group (group)
10730 (let ((method (gnus-find-method-for-group group)))
10731 (funcall (gnus-get-function method 'close-group)
10732 (gnus-group-real-name group) (nth 1 method))))
10734 (defun gnus-retrieve-headers (articles group)
10735 (let ((method (gnus-find-method-for-group group)))
10737 (gnus-cache-retrieve-headers articles group)
10738 (funcall (gnus-get-function method 'retrieve-headers)
10739 articles (gnus-group-real-name group) (nth 1 method)))))
10741 (defun gnus-retrieve-groups (groups method)
10742 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
10744 (defun gnus-request-article (article group &optional buffer)
10745 (let ((method (gnus-find-method-for-group group)))
10746 (funcall (gnus-get-function method 'request-article)
10747 article (gnus-group-real-name group) (nth 1 method) buffer)))
10749 (defun gnus-request-head (article group)
10750 (let ((method (gnus-find-method-for-group group)))
10751 (funcall (gnus-get-function method 'request-head)
10752 article (gnus-group-real-name group) (nth 1 method))))
10754 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10755 (defun gnus-request-post-buffer (post group subject header artbuf
10756 info follow-to respect-poster)
10757 (let* ((info (or info (and group (nth 2 (gnus-gethash
10758 group gnus-newsrc-hashtb)))))
10760 (if (and gnus-post-method
10761 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10763 (format "%s" (car (gnus-find-method-for-group
10764 gnus-newsgroup-name)))
10765 gnus-valid-select-methods)))
10767 (gnus-find-method-for-group gnus-newsgroup-name))))
10768 (or (gnus-server-opened method)
10769 (gnus-open-server method)
10770 (error "Can't open server %s:%s" (car method) (nth 1 method)))
10771 (let ((mail-self-blind nil)
10772 (mail-archive-file-name nil))
10773 (funcall (gnus-get-function method 'request-post-buffer)
10774 post group subject header artbuf info follow-to
10777 (defun gnus-request-post (method &optional force)
10778 (and (stringp method)
10779 (setq method (gnus-server-to-method method)))
10780 (and (not force) gnus-post-method
10781 (memq 'post (assoc (format "%s" (car method))
10782 gnus-valid-select-methods))
10783 (setq method gnus-post-method))
10784 (funcall (gnus-get-function method 'request-post)
10787 (defun gnus-request-expire-articles (articles group &optional force)
10788 (let ((method (gnus-find-method-for-group group)))
10789 (funcall (gnus-get-function method 'request-expire-articles)
10790 articles (gnus-group-real-name group) (nth 1 method)
10793 (defun gnus-request-move-article
10794 (article group server accept-function &optional last)
10795 (let ((method (gnus-find-method-for-group group)))
10796 (funcall (gnus-get-function method 'request-move-article)
10797 article (gnus-group-real-name group)
10798 (nth 1 method) accept-function last)))
10800 (defun gnus-request-accept-article (group &optional last)
10801 (let ((func (if (symbolp group) group
10802 (car (gnus-find-method-for-group group)))))
10803 (funcall (intern (format "%s-request-accept-article" func))
10804 (if (stringp group) (gnus-group-real-name group) group)
10807 (defun gnus-request-replace-article (article group buffer)
10808 (let ((func (car (gnus-find-method-for-group group))))
10809 (funcall (intern (format "%s-request-replace-article" func))
10810 article (gnus-group-real-name group) buffer)))
10812 (defun gnus-request-create-group (group)
10813 (let ((method (gnus-find-method-for-group group)))
10814 (funcall (gnus-get-function method 'request-create-group)
10815 (gnus-group-real-name group) (nth 1 method))))
10817 (defun gnus-member-of-valid (symbol group)
10818 (memq symbol (assoc
10819 (format "%s" (car (gnus-find-method-for-group group)))
10820 gnus-valid-select-methods)))
10822 (defun gnus-find-method-for-group (group &optional info)
10823 (or gnus-override-method
10825 gnus-select-method)
10826 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
10829 (not (setq method (nth 4 info))))
10830 (setq method gnus-select-method)
10832 (cond ((stringp method)
10833 (gnus-server-to-method method))
10834 ((stringp (car method))
10835 (gnus-server-extend-method group method))
10838 (gnus-server-add-address method))))
10840 (defun gnus-check-backend-function (func group)
10841 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
10843 (fboundp (intern (format "%s-%s" method func)))))
10845 (defun gnus-methods-using (method)
10846 (let ((valids gnus-valid-select-methods)
10849 (if (memq method (car valids))
10850 (setq outs (cons (car valids) outs)))
10851 (setq valids (cdr valids)))
10855 ;;; Active & Newsrc File Handling
10858 ;; Newsrc related functions.
10859 ;; Gnus internal format of gnus-newsrc-alist:
10860 ;; (("alt.general" 3 (1 . 1))
10861 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
10862 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
10863 ;; The first item is the group name; the second is the subscription
10864 ;; level; the third is either a range of a list of ranges of read
10865 ;; articles, the optional fourth element is a list of marked articles,
10866 ;; the optional fifth element is the select method.
10868 ;; Gnus internal format of gnus-newsrc-hashtb:
10869 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
10870 ;; This is the entry for "alt.misc". The first element is the number
10871 ;; of unread articles in "alt.misc". The cdr of this entry is the
10872 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
10873 ;; trivial to remove or add new elements into gnus-newsrc-alist
10874 ;; without scanning the entire list. So, to get the actual information
10875 ;; of "alt.misc", you'd say something like
10876 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
10878 ;; Gnus internal format of gnus-active-hashtb:
10882 ;; The only element in each entry in this hash table is a range of
10883 ;; (possibly) available articles. (Articles in this range may have
10884 ;; been expired or cancelled.)
10886 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
10887 ;; ("alt.misc" "alt.test" "alt.general" ...)
10889 (defun gnus-setup-news (&optional rawfile level)
10890 "Setup news information.
10891 If RAWFILE is non-nil, the .newsrc file will also be read.
10892 If LEVEL is non-nil, the news will be set up at level LEVEL."
10893 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
10894 ;; Clear some variables to re-initialize news information.
10895 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
10897 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
10898 (if init (gnus-read-newsrc-file rawfile))
10900 ;; Read the active file and create `gnus-active-hashtb'.
10901 ;; If `gnus-read-active-file' is nil, then we just create an empty
10902 ;; hash table. The partial filling out of the hash table will be
10903 ;; done in `gnus-get-unread-articles'.
10904 (if (and gnus-read-active-file
10906 (gnus-server-opened gnus-select-method))
10907 (gnus-read-active-file)
10908 (setq gnus-active-hashtb (make-vector 4095 0)))
10910 (and init gnus-use-dribble-file (gnus-dribble-read-file))
10912 ;; Find the number of unread articles in each non-dead group.
10913 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
10914 ;; Find new newsgroups and treat them.
10915 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
10916 (gnus-server-opened gnus-select-method))
10917 (gnus-find-new-newsgroups))
10918 (if (and init gnus-check-bogus-newsgroups
10919 gnus-read-active-file (not level)
10920 (gnus-server-opened gnus-select-method))
10921 (gnus-check-bogus-newsgroups))))
10923 (defun gnus-find-new-newsgroups ()
10924 "Search for new newsgroups and add them.
10925 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
10926 The `-n' option line from .newsrc is respected."
10928 (or (gnus-check-first-time-used)
10929 (if (or (consp gnus-check-new-newsgroups)
10930 (eq gnus-check-new-newsgroups 'ask-server))
10931 (gnus-ask-server-for-new-groups)
10933 group new-newsgroups)
10934 (or gnus-have-read-active-file (gnus-read-active-file))
10935 (setq gnus-newsrc-last-checked-date (current-time-string))
10936 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
10937 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
10938 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
10941 (setq group (symbol-name sym))
10942 (if (or (gnus-gethash group gnus-killed-hashtb)
10943 (gnus-gethash group gnus-newsrc-hashtb))
10945 (let ((do-sub (gnus-matches-options-n group)))
10946 (cond ((eq do-sub 'subscribe)
10947 (setq groups (1+ groups))
10948 (gnus-sethash group group gnus-killed-hashtb)
10950 gnus-subscribe-options-newsgroup-method group))
10951 ((eq do-sub 'ignore)
10954 (setq groups (1+ groups))
10955 (gnus-sethash group group gnus-killed-hashtb)
10956 (if gnus-subscribe-hierarchical-interactive
10957 (setq new-newsgroups (cons group new-newsgroups))
10958 (funcall gnus-subscribe-newsgroup-method group)))))))
10959 gnus-active-hashtb)
10961 (gnus-subscribe-hierarchical-interactive new-newsgroups))
10962 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10964 (gnus-message 6 "%d new newsgroup%s arrived."
10965 groups (if (> groups 1) "s have" " has")))))))
10967 (defun gnus-matches-options-n (group)
10968 ;; Returns `subscribe' if the group is to be uncoditionally
10969 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
10970 ;; no match for the group.
10972 ;; First we check the two user variables.
10974 ((and gnus-options-subscribe
10975 (string-match gnus-options-not-subscribe group))
10977 ((and gnus-options-not-subscribe
10978 (string-match gnus-options-subscribe group))
10980 ;; Then we go through the list that was retrieved from the .newsrc
10981 ;; file. This list has elements on the form
10982 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
10983 ;; is in the reverse order of the options line) is returned.
10985 (let ((regs gnus-newsrc-options-n))
10987 (not (string-match (car (car regs)) group)))
10988 (setq regs (cdr regs)))
10989 (and regs (cdr (car regs)))))))
10991 (defun gnus-ask-server-for-new-groups ()
10992 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
10993 (methods (cons gnus-select-method
10995 (and (consp gnus-check-new-newsgroups)
10996 gnus-check-new-newsgroups)
10997 gnus-secondary-select-methods)))
10999 (new-date (current-time-string))
11000 hashtb group new-newsgroups got-new)
11001 ;; Go thorugh both primary and secondary select methods and
11002 ;; request new newsgroups.
11004 (if (gnus-request-newgroups date (car methods))
11007 (or hashtb (setq hashtb (gnus-make-hashtable
11008 (count-lines (point-min) (point-max)))))
11009 (set-buffer nntp-server-buffer)
11010 ;; Enter all the new groups in a hashtable.
11011 (gnus-active-to-gnus-format (car methods) hashtb)))
11012 (setq methods (cdr methods)))
11013 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11014 ;; Now all new groups from all select methods are in `hashtb'.
11016 (lambda (group-sym)
11017 (setq group (symbol-name group-sym))
11018 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11019 (member group gnus-zombie-list)
11020 (member group gnus-killed-list))
11021 ;; The group is already known.
11023 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
11024 (let ((do-sub (gnus-matches-options-n group)))
11025 (cond ((eq do-sub 'subscribe)
11026 (setq groups (1+ groups))
11027 (gnus-sethash group group gnus-killed-hashtb)
11029 gnus-subscribe-options-newsgroup-method group))
11030 ((eq do-sub 'ignore)
11033 (setq groups (1+ groups))
11034 (gnus-sethash group group gnus-killed-hashtb)
11035 (if gnus-subscribe-hierarchical-interactive
11036 (setq new-newsgroups (cons group new-newsgroups))
11037 (funcall gnus-subscribe-newsgroup-method group)))))))
11040 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11041 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11043 (gnus-message 6 "%d new newsgroup%s arrived."
11044 groups (if (> groups 1) "s have" " has")))
11047 (defun gnus-check-first-time-used ()
11048 (if (or (> (length gnus-newsrc-alist) 1)
11049 (file-exists-p gnus-startup-file)
11050 (file-exists-p (concat gnus-startup-file ".el"))
11051 (file-exists-p (concat gnus-startup-file ".eld")))
11053 (gnus-message 6 "First time user; subscribing you to default groups")
11054 (or gnus-have-read-active-file (gnus-read-active-file))
11055 (setq gnus-newsrc-last-checked-date (current-time-string))
11056 (let ((groups gnus-default-subscribed-newsgroups)
11060 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11063 (setq group (symbol-name sym))
11064 (let ((do-sub (gnus-matches-options-n group)))
11065 (cond ((eq do-sub 'subscribe)
11066 (gnus-sethash group group gnus-killed-hashtb)
11068 gnus-subscribe-options-newsgroup-method group))
11069 ((eq do-sub 'ignore)
11072 (setq gnus-killed-list (cons group gnus-killed-list))))))
11073 gnus-active-hashtb)
11075 (if (gnus-gethash (car groups) gnus-active-hashtb)
11076 (gnus-group-change-level
11077 (car groups) gnus-level-default-subscribed gnus-level-killed))
11078 (setq groups (cdr groups)))
11079 (gnus-group-make-help-group)
11080 (and gnus-novice-user
11081 (gnus-message 7 "`A k' to list killed groups"))))))
11083 ;; `gnus-group-change-level' is the fundamental function for changing
11084 ;; subscription levels of newsgroups. This might mean just changing
11085 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11086 ;; again, which subscribes/unsubscribes a group, which is equally
11087 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11088 ;; from 8-9 to 1-7 means that you remove the group from the list of
11089 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11090 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11091 ;; which is trivial.
11092 ;; ENTRY can either be a string (newsgroup name) or a list (if
11093 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11094 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11096 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11097 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11099 (defun gnus-group-change-level (entry level &optional oldlevel
11100 previous fromkilled)
11101 (let ((pinfo entry)
11102 group info active num)
11103 ;; Glean what info we can from the arguments
11105 (if fromkilled (setq group (nth 1 entry))
11106 (setq group (car (nth 2 entry))))
11107 (setq group entry))
11108 (if (and (stringp entry)
11110 (< oldlevel gnus-level-zombie))
11111 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11112 (if (and (not oldlevel)
11114 (setq oldlevel (car (cdr (nth 2 entry)))))
11115 (if (stringp previous)
11116 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11118 (gnus-dribble-enter
11119 (format "(gnus-group-change-level %S %S %S %S %S)"
11120 group level oldlevel (car (nth 2 previous)) fromkilled))
11122 ;; Then we remove the newgroup from any old structures, if needed.
11123 ;; If the group was killed, we remove it from the killed or zombie
11124 ;; list. If not, and it is in fact going to be killed, we remove
11125 ;; it from the newsrc hash table and assoc.
11126 (cond ((>= oldlevel gnus-level-zombie)
11127 (if (= oldlevel gnus-level-zombie)
11128 (setq gnus-zombie-list (delete group gnus-zombie-list))
11129 (setq gnus-killed-list (delete group gnus-killed-list))))
11131 (if (>= level gnus-level-zombie)
11133 (gnus-sethash (car (nth 2 entry))
11134 nil gnus-newsrc-hashtb)
11136 (setcdr (gnus-gethash (car (nth 3 entry))
11137 gnus-newsrc-hashtb)
11139 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11141 ;; Finally we enter (if needed) the list where it is supposed to
11142 ;; go, and change the subscription level. If it is to be killed,
11143 ;; we enter it into the killed or zombie list.
11144 (cond ((>= level gnus-level-zombie)
11145 (and (string= group (gnus-group-real-name group))
11146 (if (= level gnus-level-zombie)
11147 (setq gnus-zombie-list (cons group gnus-zombie-list))
11148 (setq gnus-killed-list (cons group gnus-killed-list)))))
11150 ;; If the list is to be entered into the newsrc assoc, and
11151 ;; it was killed, we have to create an entry in the newsrc
11152 ;; hashtb format and fix the pointers in the newsrc assoc.
11153 (if (>= oldlevel gnus-level-zombie)
11157 (setq info (cdr entry))
11158 (setq num (car entry)))
11159 (setq active (gnus-gethash group gnus-active-hashtb))
11160 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11161 ;; Check whether the group is foreign. If so, the
11162 ;; foreign select method has to be entered into the
11164 (let ((method (gnus-group-method-name group)))
11165 (if (eq method gnus-select-method)
11166 (setq info (list group level nil))
11167 (setq info (list group level nil nil method)))))
11170 (let ((p gnus-newsrc-alist))
11171 (while (cdr (cdr p))
11174 (setq entry (cons info (cdr (cdr previous))))
11177 (setcdr (cdr previous) entry)
11178 (gnus-sethash group (cons num (cdr previous))
11179 gnus-newsrc-hashtb))
11180 (setcdr previous entry)
11181 (gnus-sethash group (cons num previous)
11182 gnus-newsrc-hashtb))
11184 (setcdr (gnus-gethash (car (car (cdr entry)))
11185 gnus-newsrc-hashtb)
11187 ;; It was alive, and it is going to stay alive, so we
11188 ;; just change the level and don't change any pointers or
11189 ;; hash table entries.
11190 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11192 (defun gnus-kill-newsgroup (newsgroup)
11193 "Obsolete function. Kills a newsgroup."
11194 (gnus-group-change-level
11195 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11197 (defun gnus-check-bogus-newsgroups (&optional confirm)
11198 "Remove bogus newsgroups.
11199 If CONFIRM is non-nil, the user has to confirm the deletion of every
11201 (let ((newsrc (cdr gnus-newsrc-alist))
11203 (gnus-message 5 "Checking bogus newsgroups...")
11204 (or gnus-have-read-active-file (gnus-read-active-file))
11205 ;; Find all bogus newsgroup that are subscribed.
11207 (setq group (car (car newsrc)))
11208 (if (or (gnus-gethash group gnus-active-hashtb)
11209 (nth 4 (car newsrc))
11211 (not (gnus-y-or-n-p
11212 (format "Remove bogus newsgroup: %s " group)))))
11213 ;; Active newsgroup.
11215 ;; Found a bogus newsgroup.
11216 (setq bogus (cons group bogus)))
11217 (setq newsrc (cdr newsrc)))
11218 ;; Remove all bogus subscribed groups by first killing them, and
11219 ;; then removing them from the list of killed groups.
11221 (gnus-group-change-level
11222 (gnus-gethash (car bogus) gnus-newsrc-hashtb) gnus-level-killed)
11223 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
11224 (setq bogus (cdr bogus)))
11225 ;; Then we remove all bogus groups from the list of killed and
11226 ;; zombie groups. They are are removed without confirmation.
11227 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11230 (setq killed (symbol-value (car dead-lists)))
11232 (setq group (car killed))
11233 (or (gnus-gethash group gnus-active-hashtb)
11234 ;; The group is bogus.
11235 (set (car dead-lists)
11236 (delete group (symbol-value (car dead-lists)))))
11237 (setq killed (cdr killed)))
11238 (setq dead-lists (cdr dead-lists))))
11239 (gnus-message 5 "Checking bogus newsgroups... done")))
11241 (defun gnus-check-duplicate-killed-groups ()
11242 "Remove duplicates from the list of killed groups."
11244 (let ((killed gnus-killed-list))
11246 (gnus-message 9 "%d" (length killed))
11247 (setcdr killed (delete (car killed) (cdr killed)))
11248 (setq killed (cdr killed)))))
11250 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11251 ;; and compute how many unread articles there are in each group.
11252 (defun gnus-get-unread-articles (&optional level)
11253 (let* ((newsrc (cdr gnus-newsrc-alist))
11254 (conditional level)
11255 (level (or level (1+ gnus-level-subscribed)))
11256 info group active virtuals method)
11257 (gnus-message 5 "Checking new news...")
11259 (setq info (car newsrc))
11260 (setq group (car info))
11261 (setq active (gnus-gethash group gnus-active-hashtb))
11263 ;; Check newsgroups. If the user doesn't want to check them, or
11264 ;; they can't be checked (for instance, if the news server can't
11265 ;; be reached) we just set the number of unread articles in this
11266 ;; newsgroup to t. This means that Gnus thinks that there are
11267 ;; unread articles, but it has no idea how many.
11268 (if (and (setq method (nth 4 info))
11269 (not (gnus-server-equal gnus-select-method
11270 (gnus-server-get-method nil method))))
11271 (if (or (and gnus-activate-foreign-newsgroups
11272 (not (numberp gnus-activate-foreign-newsgroups)))
11273 (and (numberp gnus-activate-foreign-newsgroups)
11274 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
11275 (<= (nth 1 info) level)))
11276 (if (eq (car (if (stringp method)
11277 (gnus-server-to-method method)
11278 (nth 4 info))) 'nnvirtual)
11279 (setq virtuals (cons info virtuals))
11280 (setq active (gnus-activate-newsgroup (car info)))))
11281 (if (and (not gnus-read-active-file)
11282 (<= (nth 1 info) level))
11284 (setq active (gnus-activate-newsgroup (car info))))))
11286 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
11287 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
11289 (gnus-get-unread-articles-in-group info active)
11290 ;; Close the groups as we look at them!
11291 (gnus-close-group group))
11292 (setq newsrc (cdr newsrc)))
11294 ;; Activate the virtual groups. This has to be done after all the
11296 ;; !!! If one virtual group contains another virtual group, even
11297 ;; doing it this way might cause problems.
11299 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11300 (gnus-get-unread-articles-in-group (car virtuals) active))
11301 (setq virtuals (cdr virtuals)))
11303 (gnus-message 5 "Checking new news... done")))
11305 ;; Create a hash table out of the newsrc alist. The `car's of the
11306 ;; alist elements are used as keys.
11307 (defun gnus-make-hashtable-from-newsrc-alist ()
11308 (let ((alist gnus-newsrc-alist)
11310 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11312 (setq prev (setq gnus-newsrc-alist
11313 (cons (list "dummy.group" 0 nil) alist))))
11315 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
11317 (setq alist (cdr alist)))))
11319 (defun gnus-make-hashtable-from-killed ()
11320 "Create a hash table from the killed and zombie lists."
11321 (let ((lists '(gnus-killed-list gnus-zombie-list))
11323 (setq gnus-killed-hashtb
11324 (gnus-make-hashtable
11325 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11327 (setq list (symbol-value (car lists)))
11328 (setq lists (cdr lists))
11330 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11331 (setq list (cdr list))))))
11333 (defun gnus-get-unread-articles-in-group (info active)
11334 (let* ((range (nth 2 info))
11336 (marked (nth 3 info))
11337 srange lowest group highest)
11338 ;; If a cache is present, we may have to alter the active info.
11339 (and gnus-use-cache
11340 (gnus-cache-possibly-alter-active (car info) active))
11341 ;; Modify the list of read articles according to what articles
11342 ;; are available; then tally the unread articles and add the
11343 ;; number to the group hash table entry.
11344 (cond ((zerop (cdr active))
11347 (setq num (- (1+ (cdr active)) (car active))))
11348 ((not (listp (cdr range)))
11349 ;; Fix a single (num . num) range according to the
11350 ;; active hash table.
11351 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
11352 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
11353 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
11354 ;; Compute number of unread articles.
11355 (setq num (max 0 (- (cdr active)
11356 (- (1+ (cdr range)) (car range))))))
11358 ;; The read list is a list of ranges. Fix them according to
11359 ;; the active hash table.
11360 ;; First peel off any elements that are below the lower
11362 (while (and (cdr range)
11364 (or (and (atom (car (cdr range))) (car (cdr range)))
11365 (car (car (cdr range))))))
11366 (if (numberp (car range))
11369 (or (and (numberp (car (cdr range)))
11371 (cdr (car (cdr range))))))
11372 (setcdr (car range)
11373 (or (and (numberp (nth 1 range)) (nth 1 range))
11374 (cdr (car (cdr range))))))
11375 (setcdr range (cdr (cdr range))))
11376 ;; Adjust the first element to be the same as the lower limit.
11377 (if (and (not (atom (car range)))
11378 (< (cdr (car range)) (car active)))
11379 (setcdr (car range) (1- (car active))))
11380 ;; Then we want to peel off any elements that are higher
11381 ;; than the upper active limit.
11382 (let ((srange range))
11383 ;; Go past all legal elements.
11384 (while (and (cdr srange)
11385 (<= (or (and (atom (car (cdr srange)))
11386 (car (cdr srange)))
11387 (car (car (cdr srange)))) (cdr active)))
11388 (setq srange (cdr srange)))
11390 ;; Nuke all remaining illegal elements.
11391 (setcdr srange nil))
11393 ;; Adjust the final element.
11394 (if (and (not (atom (car srange)))
11395 (> (cdr (car srange)) (cdr active)))
11396 (setcdr (car srange) (cdr active))))
11397 ;; Compute the number of unread articles.
11399 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
11400 (cdr (car range))))
11401 (or (and (atom (car range)) (car range))
11402 (car (car range))))))
11403 (setq range (cdr range)))
11404 (setq num (max 0 (- (cdr active) num)))))
11407 (and (assq 'tick marked)
11408 (inline (gnus-remove-illegal-marked-articles
11409 (assq 'tick marked) (nth 2 info))))
11410 (and (assq 'dormant marked)
11411 (inline (gnus-remove-illegal-marked-articles
11412 (assq 'dormant marked) (nth 2 info))))
11414 (gnus-gethash (car info) gnus-newsrc-hashtb)
11415 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
11416 (length (cdr (assq 'dormant marked)))))))))
11419 (defun gnus-remove-illegal-marked-articles (marked ranges)
11420 (let ((m (cdr marked)))
11421 ;; Make sure that all ticked articles are a subset of the unread
11424 (if (gnus-member-of-range (car m) ranges)
11425 (setcdr marked (cdr m))
11427 (setq m (cdr m)))))
11429 (defun gnus-activate-newsgroup (group)
11430 (let ((method (gnus-find-method-for-group group))
11432 (and (or (gnus-server-opened method) (gnus-open-server method))
11433 (gnus-request-group group)
11435 (set-buffer nntp-server-buffer)
11436 (goto-char (point-min))
11437 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
11439 (goto-char (match-beginning 1))
11441 group (setq active (cons (read (current-buffer))
11442 (read (current-buffer))))
11443 gnus-active-hashtb))
11446 (defun gnus-update-read-articles
11447 (group unread unselected ticked &optional domarks replied expirable killed
11448 dormant bookmark score)
11449 "Update the list of read and ticked articles in GROUP using the
11450 UNREAD and TICKED lists.
11451 Note: UNSELECTED has to be sorted over `<'.
11452 Returns whether the updating was successful."
11453 (let* ((active (or gnus-newsgroup-active
11454 (gnus-gethash group gnus-active-hashtb)))
11455 (entry (gnus-gethash group gnus-newsrc-hashtb))
11456 (number (car entry))
11457 (info (nth 2 entry))
11458 (marked (nth 3 info))
11460 (unread (sort (copy-sequence unread) (function <)))
11462 (if (or (not info) (not active))
11463 ;; There is no info on this group if it was, in fact,
11464 ;; killed. Gnus stores no information on killed groups, so
11465 ;; there's nothing to be done.
11466 ;; One could store the information somewhere temporarily,
11467 ;; perhaps... Hmmm...
11469 ;; Remove any negative articles numbers.
11470 (while (and unread (< (car unread) 0))
11471 (setq unread (cdr unread)))
11472 ;; Remove any expired article numbers
11473 (while (and unread (< (car unread) (car active)))
11474 (setq unread (cdr unread)))
11475 (while (and ticked (< (car ticked) (car active)))
11476 (setq ticked (cdr ticked)))
11477 (while (and dormant (< (car dormant) (car active)))
11478 (setq dormant (cdr dormant)))
11479 (setq unread (sort (append unselected unread) '<))
11480 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11481 (setcar entry (max 0 (- (length unread) (length ticked)
11482 (length dormant))))
11483 ;; Compute the ranges of read articles by looking at the list of
11484 ;; unread articles.
11486 (if (/= (car unread) prev)
11487 (setq read (cons (if (= prev (1- (car unread))) prev
11488 (cons prev (1- (car unread)))) read)))
11489 (setq prev (1+ (car unread)))
11490 (setq unread (cdr unread)))
11491 (if (<= prev (cdr active))
11492 (setq read (cons (cons prev (cdr active)) read)))
11493 ;; Enter this list into the group info.
11494 (setcar (cdr (cdr info))
11495 (if (> (length read) 1) (nreverse read) read))
11496 ;; Enter the list of ticked articles.
11497 (gnus-set-marked-articles
11499 (if domarks replied (cdr (assq 'reply marked)))
11500 (if domarks expirable (cdr (assq 'expire marked)))
11501 (if domarks killed (cdr (assq 'killed marked)))
11502 (if domarks dormant (cdr (assq 'dormant marked)))
11503 (if domarks bookmark (cdr (assq 'bookmark marked)))
11504 (if domarks score (cdr (assq 'score marked))))
11507 (defun gnus-make-articles-unread (group articles)
11508 "Mark ARTICLES in GROUP as unread."
11509 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
11510 (gnus-gethash (gnus-group-real-name group)
11511 gnus-newsrc-hashtb))))
11512 (ranges (nth 2 info))
11515 (and (gnus-member-of-range (car articles) ranges)
11516 (setq news (cons (car articles) news)))
11517 (setq articles (cdr articles)))
11520 (setcar (nthcdr 2 info)
11521 (gnus-remove-from-range (nth 2 info) (nreverse news)))
11522 (gnus-group-update-group group t))))
11524 (defun gnus-read-active-file ()
11525 "Get active file from NNTP server."
11526 (gnus-group-set-mode-line)
11527 (let ((methods (cons gnus-select-method gnus-secondary-select-methods))
11530 (setq gnus-have-read-active-file nil)
11532 (set-buffer nntp-server-buffer)
11534 (let* ((where (nth 1 (car methods)))
11535 (mesg (format "Reading active file%s via %s..."
11536 (if (and where (not (zerop (length where))))
11537 (concat " from " where) "")
11538 (car (car methods)))))
11539 (gnus-message 5 mesg)
11540 (gnus-check-news-server (car methods))
11542 ((and (eq gnus-read-active-file 'some)
11543 (gnus-check-backend-function
11544 'retrieve-groups (car (car methods))))
11545 (let ((newsrc (cdr gnus-newsrc-alist))
11548 (and (gnus-server-equal
11549 (gnus-find-method-for-group
11550 (car (car newsrc)) (car newsrc))
11551 (gnus-server-get-method nil (car methods)))
11552 (setq groups (cons (car (car newsrc)) groups)))
11553 (setq newsrc (cdr newsrc)))
11554 (setq list-type (gnus-retrieve-groups groups (car methods)))
11555 (cond ((not list-type)
11557 1 "Cannot read partial active file from %s server."
11558 (car (car methods)))
11561 ((eq list-type 'active)
11562 (gnus-active-to-gnus-format (and not-first (car methods)))
11563 (setq not-first t))
11565 (gnus-groups-to-gnus-format (and not-first (car methods)))
11566 (setq not-first t)))))
11568 (if (not (gnus-request-list (car methods)))
11570 (gnus-message 1 "Cannot read active file from %s server."
11571 (car (car methods)))
11573 (gnus-active-to-gnus-format
11574 (and gnus-have-read-active-file (car methods)))
11575 (setq gnus-have-read-active-file t)
11576 (gnus-message 5 "%s...done" mesg)))))
11577 (setq methods (cdr methods))))))
11579 ;; Read an active file and place the results in `gnus-active-hashtb'.
11580 (defun gnus-active-to-gnus-format (method &optional hashtb)
11581 (let ((cur (current-buffer))
11585 (setq gnus-active-hashtb
11586 (gnus-make-hashtable
11587 (count-lines (point-min) (point-max))))))))
11588 ;; Delete unnecessary lines.
11589 (goto-char (point-min))
11590 (while (search-forward "\nto." nil t)
11591 (delete-region (match-beginning 0) (progn (forward-line 1) (point))))
11592 (or (string= gnus-ignored-newsgroups "")
11594 (goto-char (point-min))
11595 (delete-matching-lines gnus-ignored-newsgroups)))
11596 (and method (not (eq method gnus-select-method))
11597 (let ((prefix (gnus-group-prefixed-name "" method)))
11598 (goto-char (point-min))
11599 (while (and (not (eobp))
11600 (null (insert prefix))
11601 (zerop (forward-line 1))))))
11602 (goto-char (point-min))
11603 ;; Store active file in hashtable.
11604 (goto-char (point-min))
11605 (if (string-match "%[oO]" gnus-group-line-format)
11606 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
11607 ;; If we want information on moderated groups, we use this
11609 (let* ((mod-hashtb (make-vector 7 0))
11610 (m (intern "m" mod-hashtb))
11612 (while (not (eobp))
11613 (condition-case nil
11615 (narrow-to-region (point) (gnus-point-at-eol))
11616 (setq group (let ((obarray hashtb)) (read cur)))
11617 (setq max (read cur))
11618 (set group (cons (read cur) max))
11619 ;; Enter moderated groups into a list.
11620 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
11621 (setq gnus-moderated-list
11622 (cons (symbol-name group) gnus-moderated-list))))
11626 ;; And if we do not care about moderation, we use this loop,
11627 ;; which is faster.
11629 (while (not (eobp))
11632 (narrow-to-region (point) (gnus-point-at-eol))
11633 ;; group gets set to a symbol interned in the hash table
11635 (setq group (let ((obarray hashtb)) (read cur)))
11636 (setq max (read cur))
11637 (set group (cons (read cur) max)))
11640 (gnus-message 3 "Illegal active: %s"
11642 (gnus-point-at-bol) (gnus-point-at-eol)))
11645 (forward-line 1))))))
11647 (defun gnus-groups-to-gnus-format (method &optional hashtb)
11648 ;; Parse a "groups" active file.
11649 (let ((cur (current-buffer))
11653 (setq gnus-active-hashtb
11654 (gnus-make-hashtable
11655 (count-lines (point-min) (point-max)))))))
11656 (prefix (and method (not (eq method gnus-select-method))
11657 (gnus-group-prefixed-name "" method))))
11659 (goto-char (point-min))
11661 ;; We split this into to separate loops, one with the prefix
11662 ;; and one without to speed the reading up somewhat.
11664 (let (min max opoint)
11665 (while (not (eobp))
11666 (read cur) (read cur)
11667 (setq min (read cur)
11670 (skip-chars-forward " \t")
11673 (set (let ((obarray hashtb)) (read cur))
11676 (let (min max opoint)
11677 (while (not (eobp))
11678 (if (= (following-char) ?2)
11680 (read cur) (read cur)
11681 (setq min (read cur)
11683 (set (let ((obarray hashtb)) (read cur))
11685 (forward-line 1))))
11687 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
11689 (defun gnus-read-newsrc-file (&optional force)
11690 "Read startup file.
11691 If FORCE is non-nil, the .newsrc file is read."
11692 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
11693 ;; Reset variables that might be defined in the .newsrc.eld file.
11694 (let ((variables gnus-variable-list))
11696 (set (car variables) nil)
11697 (setq variables (cdr variables))))
11698 (let* ((newsrc-file gnus-current-startup-file)
11699 (quick-file (concat newsrc-file ".el")))
11701 ;; We always load the .newsrc.eld file. If always contains
11702 ;; much information that can not be gotten from the .newsrc
11703 ;; file (ticked articles, killed groups, foreign methods, etc.)
11704 (gnus-read-newsrc-el-file quick-file)
11707 (and (file-newer-than-file-p newsrc-file quick-file)
11708 (file-newer-than-file-p newsrc-file
11709 (concat quick-file "d")))
11710 (not gnus-newsrc-alist))
11711 ;; We read the .newsrc file. Note that if there if a
11712 ;; .newsrc.eld file exists, it has already been read, and
11713 ;; the `gnus-newsrc-hashtb' has been created. While reading
11714 ;; the .newsrc file, Gnus will only use the information it
11715 ;; can find there for changing the data already read -
11716 ;; ie. reading the .newsrc file will not trash the data
11717 ;; already read (except for read articles).
11719 (gnus-message 5 "Reading %s..." newsrc-file)
11720 (set-buffer (find-file-noselect newsrc-file))
11721 (buffer-disable-undo (current-buffer))
11722 (gnus-newsrc-to-gnus-format)
11723 (kill-buffer (current-buffer))
11724 (gnus-message 5 "Reading %s... done" newsrc-file))))))
11726 (defun gnus-read-newsrc-el-file (file)
11727 (let ((ding-file (concat file "d")))
11728 ;; We always, always read the .eld file.
11729 (gnus-message 5 "Reading %s..." ding-file)
11730 (let (gnus-newsrc-assoc)
11731 (condition-case nil
11732 (load ding-file t t t)
11734 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
11735 (let ((inhibit-quit t))
11736 (gnus-uncompress-newsrc-assoc))
11737 (gnus-make-hashtable-from-newsrc-alist)
11738 (if (not (file-newer-than-file-p file ding-file))
11740 ;; Old format quick file
11741 (gnus-message 5 "Reading %s..." file)
11742 ;; The .el file is newer than the .eld file, so we read that one
11744 (gnus-read-old-newsrc-el-file file))))
11746 ;; Parse the old-style quick startup file
11747 (defun gnus-read-old-newsrc-el-file (file)
11748 (let (newsrc killed marked group g m len info)
11750 (let ((gnus-killed-assoc nil)
11751 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
11753 (condition-case nil
11756 (setq newsrc gnus-newsrc-assoc
11757 killed gnus-killed-assoc
11758 marked gnus-marked-assoc)))
11759 (setq gnus-newsrc-alist nil)
11761 (setq group (car newsrc))
11762 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
11765 (setcar (nthcdr 2 info) (cdr (cdr group)))
11767 (if (nth 1 group) gnus-level-default-subscribed
11768 gnus-level-default-unsubscribed))
11769 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
11770 (setq gnus-newsrc-alist
11774 (if (nth 1 group) gnus-level-default-subscribed
11775 gnus-level-default-unsubscribed)
11776 (cdr (cdr group))))
11777 gnus-newsrc-alist)))
11778 (if (setq m (assoc (car group) marked))
11779 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
11780 (setq newsrc (cdr newsrc)))
11781 (setq newsrc killed)
11783 (setcar newsrc (car (car newsrc)))
11784 (setq newsrc (cdr newsrc)))
11785 (setq gnus-killed-list killed))
11786 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
11787 (gnus-make-hashtable-from-newsrc-alist)))
11789 (defun gnus-make-newsrc-file (file)
11790 "Make server dependent file name by catenating FILE and server host name."
11791 (let* ((file (expand-file-name file nil))
11792 (real-file (concat file "-" (nth 1 gnus-select-method))))
11793 (if (file-exists-p real-file)
11796 (defun gnus-uncompress-newsrc-assoc ()
11797 ;; Uncompress all lists of marked articles in the newsrc assoc.
11798 (let ((newsrc gnus-newsrc-alist)
11801 (if (not (setq marked (nth 3 (car newsrc))))
11804 (or (eq 'score (car (car marked)))
11805 (eq 'bookmark (car (car marked)))
11806 (eq 'killed (car (car marked)))
11807 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
11808 (setq marked (cdr marked))))
11809 (setq newsrc (cdr newsrc)))))
11811 (defun gnus-compress-newsrc-assoc ()
11812 ;; Compress all lists of marked articles in the newsrc assoc.
11813 (let ((newsrc gnus-newsrc-alist)
11816 (if (not (setq marked (nth 3 (car newsrc))))
11819 (or (eq 'score (car (car marked)))
11820 (eq 'bookmark (car (car marked)))
11821 (eq 'killed (car (car marked)))
11822 (setcdr (car marked)
11823 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
11824 (setq marked (cdr marked))))
11825 (setq newsrc (cdr newsrc)))))
11827 (defun gnus-newsrc-to-gnus-format ()
11828 (setq gnus-newsrc-options "")
11829 (or gnus-active-hashtb
11830 (setq gnus-active-hashtb (make-vector 4095 0)))
11831 (let ((buf (current-buffer))
11832 (already-read (> (length gnus-newsrc-alist) 1))
11833 group level subscribed info options-symbol newsrc
11835 (goto-char (point-min))
11836 ;; We intern the symbol `options' in the active hashtb so that we
11837 ;; can `eq' against it later.
11838 (setq options-symbol (intern "options" gnus-active-hashtb))
11840 (while (not (eobp))
11841 ;; We first read the first word on the line by narrowing and
11842 ;; then reading into `gnus-active-hashtb'. Most groups will
11843 ;; already exist in that hashtb, so this will save some string
11847 (progn (skip-chars-forward "^ \t!:\n") (point)))
11848 (goto-char (point-min))
11850 (and (/= (point-min) (point-max))
11851 (let ((obarray gnus-active-hashtb)) (read buf))))
11853 ;; Now, the symbol we have read is either `options' or a group
11854 ;; name. If it is an options line, we just add it to a string.
11856 ((eq symbol options-symbol)
11857 (setq gnus-newsrc-options
11858 ;; This concatting is quite inefficient, but since our
11859 ;; thorough studies show that approx 99.37% of all
11860 ;; .newsrc files only contain a single options line, we
11861 ;; don't give a damn, frankly, my dear.
11862 (concat gnus-newsrc-options
11864 (gnus-point-at-bol)
11865 ;; Options may continue on the next line.
11866 (or (and (re-search-forward "^[^ \t]" nil 'move)
11867 (progn (beginning-of-line) (point)))
11870 ;; It was a group name.
11871 (setq subscribed (= (following-char) ?:)
11872 group (symbol-name symbol)
11875 ;; If the line ends here, this is clearly a buggy line, so
11876 ;; we put point a the beginning of line and let the cond
11877 ;; below do the error handling.
11878 (beginning-of-line)
11879 ;; We skip to the beginning of the ranges.
11880 (skip-chars-forward "!: \t"))
11881 ;; We are now at the beginning of the list of read articles.
11882 ;; We read them range by range.
11885 ((looking-at "[0-9]+")
11886 ;; We narrow and read a number instead of buffer-substring/
11887 ;; string-to-int because it's faster. narrow/widen is
11888 ;; faster than save-restriction/narrow, and save-restriction
11889 ;; produces a garbage object.
11891 (narrow-to-region (match-beginning 0) (match-end 0))
11894 ;; If the next character is a dash, then this is a range.
11895 (if (= (following-char) ?-)
11897 ;; We read the upper bound of the range.
11899 (if (not (looking-at "[0-9]+"))
11900 ;; This is a buggy line, by we pretend that
11901 ;; it's kinda OK. Perhaps the user should be
11903 (setq reads (cons num1 reads))
11907 (narrow-to-region (match-beginning 0)
11912 ;; It was just a simple number, so we add it to the
11914 (setq reads (cons num1 reads)))
11915 ;; If the next char in ?\n, then we have reached the end
11916 ;; of the line and return nil.
11917 (/= (following-char) ?\n))
11918 ((= (following-char) ?\n)
11919 ;; End of line, so we end.
11922 ;; Not numbers and not eol, so this might be a buggy
11924 (or (eobp) ; If it was eob instead of ?\n, we allow it.
11926 ;; The line was buggy.
11928 (gnus-message 3 "Mangled line: %s"
11929 (buffer-substring (gnus-point-at-bol)
11930 (gnus-point-at-eol)))
11934 ;; Skip past ", ". Spaces are illegal in these ranges, but
11935 ;; we allow them, because it's a common mistake to put a
11936 ;; space after the comma.
11937 (skip-chars-forward ", "))
11939 ;; We have already read .newsrc.eld, so we gently update the
11940 ;; data in the hash table with the information we have just
11944 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
11947 ;; There is an entry for this file in the alist.
11949 (setcar (nthcdr 2 info) (nreverse reads))
11950 ;; We update the level very gently. In fact, we
11951 ;; only change it if there's been a status change
11952 ;; from subscribed to unsubscribed, or vice versa.
11953 (setq level (nth 1 info))
11954 (cond ((and (<= level gnus-level-subscribed)
11956 (setq level (if reads
11957 gnus-level-default-unsubscribed
11958 (1+ gnus-level-default-unsubscribed))))
11959 ((and (> level gnus-level-subscribed) subscribed)
11960 (setq level gnus-level-default-subscribed)))
11961 (setcar (cdr info) level))
11962 ;; This is a new group.
11963 (setq info (list group
11965 gnus-level-default-subscribed
11967 (1+ gnus-level-subscribed)
11968 gnus-level-default-unsubscribed))
11969 (nreverse reads))))
11970 (setq newsrc (cons info newsrc))))
11971 (forward-line 1))))
11973 (setq newsrc (nreverse newsrc))
11975 (if (not already-read)
11977 ;; We now have two newsrc lists - `newsrc', which is what we
11978 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
11979 ;; what we've read from .newsrc.eld. We have to merge these
11980 ;; lists. We do this by "attaching" any (foreign) groups in the
11981 ;; gnus-newsrc-alist to the (native) group that precedes them.
11982 (let ((rc (cdr gnus-newsrc-alist))
11983 (prev gnus-newsrc-alist)
11986 (or (assoc (car (car rc)) newsrc)
11987 (if (setq entry (assoc (car (car prev)) newsrc))
11988 (setcdr (setq mentry (memq entry newsrc))
11989 (cons (car rc) (cdr mentry)))
11990 (setq newsrc (cons (car rc) newsrc))))
11994 (setq gnus-newsrc-alist newsrc)
11995 ;; We make the newsrc hashtb.
11996 (gnus-make-hashtable-from-newsrc-alist)
11998 ;; Finally, if we read some options lines, we parse them.
11999 (or (string= gnus-newsrc-options "")
12000 (gnus-newsrc-parse-options gnus-newsrc-options))
12003 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12004 ;; The return value will be a list on the form
12005 ;; ((regexp1 . ignore)
12006 ;; (regexp2 . subscribe)...)
12007 ;; When handling new newsgroups, groups that match a `ignore' regexp
12008 ;; will be ignored, and groups that match a `subscribe' regexp will be
12009 ;; subscribed. A line like
12010 ;; options -n !all rec.all
12011 ;; will lead to a list that looks like
12012 ;; (("^rec\\..+" . subscribe)
12013 ;; ("^.+" . ignore))
12014 ;; So all "rec.*" groups will be subscribed, while all the other
12015 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12016 ;; different from "options -n rec.all !all".
12017 (defun gnus-newsrc-parse-options (options)
12020 (gnus-set-work-buffer)
12021 (insert (regexp-quote options))
12022 ;; First we treat all continuation lines.
12023 (goto-char (point-min))
12024 (while (re-search-forward "\n[ \t]+" nil t)
12025 (replace-match " " t t))
12026 ;; Then we transform all "all"s into ".+"s.
12027 (goto-char (point-min))
12028 (while (re-search-forward "\\ball\\b" nil t)
12029 (replace-match ".+" t t))
12030 (goto-char (point-min))
12031 ;; We remove all other options than the "-n" ones.
12032 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12033 (replace-match " ")
12035 (goto-char (point-min))
12037 ;; We are only interested in "options -n" lines - we
12038 ;; ignore the other option lines.
12039 (while (re-search-forward "[ \t]-n" nil t)
12041 (or (save-excursion
12042 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12044 (gnus-point-at-eol)))
12045 ;; Search for all "words"...
12046 (while (re-search-forward "[^ \t,\n-]+" eol t)
12047 (if (= (char-after (match-beginning 0)) ?!)
12048 ;; If the word begins with a bang (!), this is a "not"
12049 ;; spec. We put this spec (minus the bang) and the
12050 ;; symbol `ignore' into the list.
12051 (setq out (cons (cons (concat
12052 "^" (buffer-substring
12053 (1+ (match-beginning 0))
12056 ;; There was no bang, so this is a "yes" spec.
12057 (setq out (cons (cons (concat
12058 "^" (buffer-substring (match-beginning 0)
12060 'subscribe) out)))))
12062 (setq gnus-newsrc-options-n out))))
12065 (defun gnus-save-newsrc-file ()
12066 "Save .newsrc file."
12067 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12068 ;; from the variable gnus-newsrc-alist.
12069 (and (or gnus-newsrc-alist gnus-killed-list)
12070 gnus-current-startup-file
12071 (let ((make-backup-files t)
12072 (version-control nil)
12073 (require-final-newline t)) ;Don't ask even if requested.
12074 ;; You can stop or change version control of backup file.
12075 ;; Suggested by jason@violet.berkeley.edu.
12076 (run-hooks 'gnus-save-newsrc-hook)
12078 (if (or (not gnus-dribble-buffer)
12079 (not (buffer-name gnus-dribble-buffer))
12080 (zerop (save-excursion
12081 (set-buffer gnus-dribble-buffer)
12083 (gnus-message 4 "(No changes need to be saved)")
12084 (if gnus-save-newsrc-file
12086 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12087 ;; Make backup file of master newsrc.
12088 (gnus-gnus-to-newsrc-format)
12089 (gnus-message 5 "Saving %s... done"
12090 gnus-current-startup-file)))
12091 ;; Quickly loadable .newsrc.
12092 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12093 (gnus-add-current-to-buffer-list)
12094 (buffer-disable-undo (current-buffer))
12096 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12097 (gnus-gnus-to-quick-newsrc-format)
12098 (write-region 1 (point-max)
12099 (concat gnus-current-startup-file ".eld")
12101 (kill-buffer (current-buffer))
12102 (gnus-message 5 "Saving %s.eld... done" gnus-current-startup-file)
12103 (gnus-dribble-delete-file))))))
12105 (defun gnus-gnus-to-quick-newsrc-format ()
12106 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12107 (insert ";; (ding) Gnus startup file.\n")
12108 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12109 (insert ";; to read .newsrc.\n")
12110 (let ((variables gnus-variable-list)
12112 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12114 ;; insert lisp expressions.
12115 (gnus-compress-newsrc-assoc)
12117 (setq variable (car variables))
12118 (and (boundp variable)
12119 (symbol-value variable)
12120 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12121 (insert "(setq " (symbol-name variable) " '"
12122 (prin1-to-string (symbol-value variable))
12124 (setq variables (cdr variables)))
12125 (gnus-uncompress-newsrc-assoc)))
12128 (defun gnus-gnus-to-newsrc-format ()
12129 ;; Generate and save the .newsrc file.
12130 (let ((newsrc (cdr gnus-newsrc-alist))
12133 (set-buffer (create-file-buffer gnus-startup-file))
12134 (buffer-disable-undo (current-buffer))
12137 (if gnus-newsrc-options (insert gnus-newsrc-options))
12138 ;; Write subscribed and unsubscribed.
12140 (setq info (car newsrc))
12141 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12143 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12145 (if (setq ranges (nth 2 info))
12148 (if (not (listp (cdr ranges)))
12149 (if (= (car ranges) (cdr ranges))
12150 (insert (int-to-string (car ranges)))
12151 (insert (int-to-string (car ranges)) "-"
12152 (int-to-string (cdr ranges))))
12154 (setq range (car ranges)
12155 ranges (cdr ranges))
12156 (if (or (atom range) (= (car range) (cdr range)))
12157 (insert (int-to-string
12158 (or (and (atom range) range)
12160 (insert (int-to-string (car range)) "-"
12161 (int-to-string (cdr range))))
12162 (if ranges (insert ","))))))
12164 (setq newsrc (cdr newsrc)))
12165 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12166 (kill-buffer (current-buffer)))))
12168 (defun gnus-read-descriptions-file ()
12169 (gnus-message 5 "Reading descriptions file...")
12171 ((not (or (gnus-server-opened gnus-select-method)
12172 (gnus-open-server gnus-select-method)))
12173 (gnus-message 1 "Couldn't open server")
12175 ((not (gnus-request-list-newsgroups gnus-select-method))
12176 (gnus-message 1 "Couldn't read newsgroups descriptions")
12180 (setq gnus-description-hashtb
12181 (gnus-make-hashtable (length gnus-active-hashtb)))
12184 (set-buffer nntp-server-buffer)
12185 (goto-char (point-min))
12186 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
12187 (goto-char (point-min))
12188 (if (or (search-forward "\n.\n" nil t)
12189 (goto-char (point-max)))
12191 (beginning-of-line)
12192 (narrow-to-region (point-min) (point))))
12193 (goto-char (point-min))
12194 (while (not (eobp))
12195 (setq group (let ((obarray gnus-description-hashtb))
12196 (read (current-buffer))))
12197 (skip-chars-forward " \t")
12198 (and (symbolp group)
12199 (set group (buffer-substring (point) (gnus-point-at-eol))))
12200 (forward-line 1))))
12201 (gnus-message 5 "Reading descriptions file...done")
12204 (defun gnus-group-get-description (group)
12205 ;; Get the description of a group by sending XGTITLE to the server.
12206 (and (gnus-request-group-description group)
12208 (set-buffer nntp-server-buffer)
12209 (goto-char (point-min))
12210 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12211 (buffer-substring (match-beginning 1) (match-end 1))))))
12217 (defvar gnus-server-mode-hook nil
12218 "Hook run in `gnus-server-mode' buffers.")
12220 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12221 "Format of server lines.
12222 It works along the same lines as a normal formatting string,
12223 with some simple extensions.")
12225 (defvar gnus-server-mode-line-format "(ding) List of servers"
12226 "The format specification for the server mode line.")
12228 (defconst gnus-server-line-format-alist
12229 (list (list ?h 'how ?s)
12231 (list ?w 'where ?s)
12234 (defconst gnus-server-mode-line-format-alist
12235 (list (list ?S 'news-server ?s)
12236 (list ?M 'news-method ?s)
12237 (list ?u 'user-defined ?s)))
12239 (defvar gnus-server-line-format-spec nil)
12240 (defvar gnus-server-mode-line-format-spec nil)
12241 (defvar gnus-server-killed-servers nil)
12243 (defvar gnus-server-mode-map nil)
12244 (put 'gnus-server-mode 'mode-class 'special)
12246 (if gnus-server-mode-map
12248 (setq gnus-server-mode-map (make-sparse-keymap))
12249 (suppress-keymap gnus-server-mode-map)
12250 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12251 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12252 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12253 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12254 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12255 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12256 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12257 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12258 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12259 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12261 (defun gnus-server-mode ()
12262 "Major mode for listing and editing servers.
12264 All normal editing commands are switched off.
12265 \\<gnus-server-mode-map>
12267 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12269 The following commands are available:
12271 \\{gnus-server-mode-map}"
12273 (if gnus-visual (gnus-server-make-menu-bar))
12274 (kill-all-local-variables)
12275 (setq mode-line-modified "-- ")
12276 (make-local-variable 'mode-line-format)
12277 (setq mode-line-format (copy-sequence mode-line-format))
12278 (and (equal (nth 3 mode-line-format) " ")
12279 (setcar (nthcdr 3 mode-line-format) ""))
12280 (setq major-mode 'gnus-server-mode)
12281 (setq mode-name "Server")
12282 ; (gnus-group-set-mode-line)
12283 (setq mode-line-process nil)
12284 (use-local-map gnus-server-mode-map)
12285 (buffer-disable-undo (current-buffer))
12286 (setq truncate-lines t)
12287 (setq buffer-read-only t)
12288 (run-hooks 'gnus-server-mode-hook))
12290 (defun gnus-server-insert-server-line (sformat name method)
12291 (let* ((sformat (or sformat gnus-server-line-format-spec))
12293 (where (nth 1 method))
12295 (beginning-of-line)
12297 ;; Insert the text.
12298 (insert (eval sformat))
12299 (add-text-properties
12300 b (1+ b) (list 'gnus-server (intern name)))))
12302 (defun gnus-server-setup-buffer ()
12303 (if (get-buffer gnus-server-buffer)
12306 (set-buffer (get-buffer-create gnus-server-buffer))
12308 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
12310 (defun gnus-server-prepare ()
12311 (setq gnus-server-mode-line-format-spec
12312 (gnus-parse-format gnus-server-mode-line-format
12313 gnus-server-mode-line-format-alist))
12314 (setq gnus-server-line-format-spec
12315 (gnus-parse-format gnus-server-line-format
12316 gnus-server-line-format-alist))
12317 (let ((alist gnus-server-alist)
12318 (buffer-read-only nil))
12321 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
12322 (setq alist (cdr alist))))
12323 (goto-char (point-min))
12324 (gnus-server-position-cursor))
12326 (defun gnus-server-server-name ()
12327 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
12328 (and server (symbol-name server))))
12330 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
12332 (defconst gnus-server-edit-buffer "*Gnus edit server*")
12334 (defun gnus-server-update-server (server)
12336 (set-buffer gnus-server-buffer)
12337 (let ((buffer-read-only nil)
12338 (info (cdr (assoc server gnus-server-alist))))
12339 (gnus-dribble-enter
12340 (concat "(gnus-server-set-info \"" server "\" '"
12341 (prin1-to-string info) ")"))
12342 ;; Buffer may be narrowed.
12345 (if (gnus-server-goto-server server)
12346 (delete-region (progn (beginning-of-line) (point))
12347 (progn (forward-line 1) (point))))
12348 (let ((entry (assoc server gnus-server-alist)))
12349 (gnus-server-insert-server-line nil (car entry) (cdr entry))
12350 (gnus-server-position-cursor))))))
12352 (defun gnus-server-set-info (server info)
12353 ;; Enter a select method into the virtual server alist.
12354 (gnus-dribble-enter
12355 (concat "(gnus-server-set-info \"" server "\" '"
12356 (prin1-to-string info) ")"))
12357 (let* ((server (nth 1 info))
12358 (entry (assoc server gnus-server-alist)))
12359 (if entry (setcdr entry info)
12360 (setq gnus-server-alist
12361 (nconc gnus-server-alist (list (cons server info)))))))
12363 (defun gnus-server-to-method (server)
12364 ;; Map virtual server names to select methods.
12365 (or (and (equal server "native") gnus-select-method)
12366 (cdr (assoc server gnus-server-alist))))
12368 (defun gnus-server-extend-method (group method)
12369 ;; This function "extends" a virtual server. If the server is
12370 ;; "hello", and the select method is ("hello" (my-var "something"))
12371 ;; in the group "alt.alt", this will result in a new virtual server
12372 ;; called "helly+alt.alt".
12374 (gnus-copy-sequence
12375 (if (equal (car method) "native") gnus-select-method
12376 (cdr (assoc (car method) gnus-server-alist))))))
12377 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
12378 (nconc entry (cdr method))))
12380 (defun gnus-server-get-method (group method)
12381 ;; Input either a server name, and extended server name, or a
12382 ;; select method, and return a select method.
12383 (cond ((stringp method)
12384 (gnus-server-to-method method))
12385 ((stringp (car method))
12386 (gnus-server-extend-method group method))
12388 (gnus-server-add-address method))))
12390 (defun gnus-server-add-address (method)
12391 (let ((method-name (symbol-name (car method))))
12392 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
12393 (not (assq (intern (concat method-name "-address")) method)))
12394 (append method (list (list (intern (concat method-name "-address"))
12398 (defun gnus-server-equal (s1 s2)
12400 (and (= (length s1) (length s2))
12402 (while (and s1 (member (car s1) s2))
12403 (setq s1 (cdr s1)))
12406 ;;; Interactive server functions.
12408 (defun gnus-server-kill-server (server)
12409 "Kill the server on the current line."
12410 (interactive (list (gnus-server-server-name)))
12411 (or (gnus-server-goto-server server)
12412 (if server (error "No such server: %s" server)
12413 (error "No server on the current line")))
12414 (let ((buffer-read-only nil))
12415 (delete-region (progn (beginning-of-line) (point))
12416 (progn (forward-line 1) (point))))
12417 (setq gnus-server-killed-servers
12418 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
12419 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
12420 gnus-server-alist))
12421 (gnus-server-position-cursor))
12423 (defun gnus-server-yank-server ()
12424 "Yank the previously killed server."
12426 (or gnus-server-killed-servers
12427 (error "No killed servers to be yanked"))
12428 (let ((alist gnus-server-alist)
12429 (server (gnus-server-server-name))
12430 (killed (car gnus-server-killed-servers)))
12432 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
12433 (if (string= server (car (car gnus-server-alist)))
12434 (setq gnus-server-alist (cons killed gnus-server-alist))
12435 (while (and (cdr alist)
12436 (not (string= server (car (car (cdr alist))))))
12437 (setq alist (cdr alist)))
12438 (setcdr alist (cons killed (cdr alist)))))
12439 (gnus-server-update-server (car killed))
12440 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
12441 (gnus-server-position-cursor)))
12443 (defun gnus-server-exit ()
12444 "Return to the group buffer."
12446 (kill-buffer (current-buffer))
12447 (switch-to-buffer gnus-group-buffer))
12449 (defun gnus-server-list-servers ()
12450 "List all available servers."
12452 (let ((cur (gnus-server-server-name)))
12453 (gnus-server-prepare)
12454 (if cur (gnus-server-goto-server cur)
12455 (goto-char (point-max))
12457 (gnus-server-position-cursor)))
12459 (defun gnus-server-copy-server (from to)
12462 (or (gnus-server-server-name)
12463 (error "No server on the current line"))
12464 (read-string "Copy to: ")))
12465 (or from (error "No server on current line"))
12466 (or (and to (not (string= to ""))) (error "No name to copy to"))
12467 (and (assoc to gnus-server-alist) (error "%s already exists" to))
12468 (or (assoc from gnus-server-alist)
12469 (error "%s: no such server" from))
12470 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
12471 (setcar to-entry to)
12472 (setcar (nthcdr 2 to-entry) to)
12473 (setq gnus-server-killed-servers
12474 (cons to-entry gnus-server-killed-servers))
12475 (gnus-server-yank-server)))
12477 (defun gnus-server-add-server (how where)
12479 (list (intern (completing-read "Server method: "
12480 gnus-valid-select-methods nil t))
12481 (read-string "Server name: ")))
12482 (setq gnus-server-killed-servers
12483 (cons (list where how where) gnus-server-killed-servers))
12484 (gnus-server-yank-server))
12486 (defun gnus-server-goto-server (server)
12487 "Jump to a server line."
12489 (list (completing-read "Goto server: " gnus-server-alist nil t)))
12490 (let ((to (text-property-any (point-min) (point-max)
12491 'gnus-server (intern server))))
12495 (gnus-server-position-cursor)))))
12497 (defun gnus-server-edit-server (server)
12498 "Edit the server on the current line."
12499 (interactive (list (gnus-server-server-name)))
12501 (error "No server on current line"))
12502 (let ((winconf (current-window-configuration)))
12503 (get-buffer-create gnus-server-edit-buffer)
12504 (gnus-configure-windows 'edit-server)
12505 (gnus-add-current-to-buffer-list)
12507 (make-local-variable 'gnus-prev-winconf)
12508 (setq gnus-prev-winconf winconf)
12509 (use-local-map (copy-keymap (current-local-map)))
12510 (let ((done-func '(lambda ()
12511 "Exit editing mode and update the information."
12513 (gnus-server-edit-server-done 'group))))
12514 (setcar (cdr (nth 4 done-func)) server)
12515 (local-set-key "\C-c\C-c" done-func))
12517 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
12518 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
12520 (defun gnus-server-edit-server-done (server)
12522 (set-buffer (get-buffer-create gnus-server-edit-buffer))
12523 (goto-char (point-min))
12524 (let ((form (read (current-buffer)))
12525 (winconf gnus-prev-winconf))
12526 (gnus-server-set-info server form)
12527 (kill-buffer (current-buffer))
12528 (and winconf (set-window-configuration winconf))
12529 (set-buffer gnus-server-buffer)
12530 (gnus-server-update-server (gnus-server-server-name))
12531 (gnus-server-position-cursor)))
12533 (defun gnus-server-read-server (server)
12535 (interactive (list (gnus-server-server-name)))
12536 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
12538 (defun gnus-mouse-pick-server (e)
12540 (mouse-set-point e)
12541 (gnus-server-read-server (gnus-server-server-name)))
12543 ;; Allow redefinition of Gnus functions.
12545 (gnus-ems-redefine)
12549 ;;; gnus.el ends here